2022-12-20 06:18:48 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
from dataclasses import dataclass
|
|
|
|
from datetime import date
|
2022-12-20 07:23:52 +00:00
|
|
|
from typing import TYPE_CHECKING, Optional
|
2022-12-20 06:18:48 +00:00
|
|
|
|
2022-12-20 07:23:52 +00:00
|
|
|
if TYPE_CHECKING:
|
2022-12-20 07:28:45 +00:00
|
|
|
from backend.model.tribe import Tribe
|
2022-12-20 06:18:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Assessment:
|
|
|
|
def __init__(self, name: str, tribe: Tribe, term: int) -> None:
|
|
|
|
self.tribe = tribe
|
|
|
|
self.term = term
|
|
|
|
self.name = name
|
|
|
|
self.exercises = []
|
|
|
|
|
2022-12-20 07:23:52 +00:00
|
|
|
self.tribe.register_assessment(self)
|
|
|
|
|
2022-12-20 06:18:48 +00:00
|
|
|
def register_exercise(self, exercise: Exercise):
|
|
|
|
self.exercises.append(exercise)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def questions(self):
|
|
|
|
return sum([exercise.questions for exercise in self.exercises])
|
|
|
|
|
|
|
|
|
|
|
|
class Exercise:
|
|
|
|
def __init__(self, name: str, assessment: Assessment, date: Optional[date]) -> None:
|
|
|
|
self.name = name
|
|
|
|
self.assessment = assessment
|
|
|
|
self.date = date
|
|
|
|
self.questions = []
|
|
|
|
|
|
|
|
self.assessment.register_exercise(self)
|
|
|
|
|
|
|
|
def register_question(self, question: Question):
|
|
|
|
self.questions.append(question)
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
class Domain:
|
|
|
|
name: str
|
|
|
|
description: str
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
|
|
class Skill:
|
|
|
|
name: str
|
|
|
|
description: str
|
|
|
|
|
|
|
|
|
|
|
|
class Question:
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
name: str,
|
|
|
|
exercise: Exercise,
|
|
|
|
description: str,
|
|
|
|
skill: Skill,
|
|
|
|
domain: Domain,
|
|
|
|
is_leveled: bool,
|
|
|
|
scale: int,
|
|
|
|
) -> None:
|
|
|
|
self.name = name
|
|
|
|
self.exercise = exercise
|
|
|
|
self.exercise.register_question(self)
|
|
|
|
self.description = description
|
|
|
|
self.skill = skill
|
|
|
|
self.domain = domain
|
|
|
|
self.is_leveled = is_leveled
|
|
|
|
self.scale = scale
|