Feat: add overwrite when 2 students have the same id and split tests
This commit is contained in:
@@ -8,6 +8,10 @@ if TYPE_CHECKING:
|
||||
from backend.model.student import Student
|
||||
|
||||
|
||||
class TribeError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
@dataclass
|
||||
class Tribe:
|
||||
name: str
|
||||
@@ -18,7 +22,22 @@ class Tribe:
|
||||
def register_assessment(self, assessment: Assessment) -> None:
|
||||
self.assessments.append(assessment)
|
||||
|
||||
@property
|
||||
def students_id(self) -> list[str]:
|
||||
return [s.id for s in self.students]
|
||||
|
||||
def register_student(self, student: Student) -> None:
|
||||
"""Register a student
|
||||
|
||||
If the student is already registered, it is modified.
|
||||
"""
|
||||
try:
|
||||
old_student = next(filter(lambda s: s.id == student.id, self.students))
|
||||
except StopIteration:
|
||||
pass
|
||||
else:
|
||||
self.students.remove(old_student)
|
||||
|
||||
self.students.append(student)
|
||||
|
||||
def __eq__(self, other: object) -> bool:
|
||||
|
Reference in New Issue
Block a user