69 lines
1.5 KiB
Python
69 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from datetime import date
|
|
from typing import Optional
|
|
|
|
from backend.model.student import Tribe
|
|
|
|
|
|
class Assessment:
|
|
def __init__(self, name: str, tribe: Tribe, term: int) -> None:
|
|
self.tribe = tribe
|
|
self.term = term
|
|
self.name = name
|
|
self.exercises = []
|
|
|
|
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
|