def remove_student(self, studentID):
        """
        Removes a student by it's id

        :param studentID: the id of the student
        :return None: success
        :raises NotAnInt: the id is not an int
        :raises NotExistent: the student does not exist
        """
        ValidationServices.validate_id(studentID)
        self._studentRepo.remove_object(studentID)
Пример #2
0
 def update_assignment(self, assignmentID, newAssignment: Assignment):
     ValidationServices.validate_id(assignmentID)
     idx = self._assignmentRepo.find_object(assignmentID)
     if idx is None:
         raise NotExistent("Student does not exist")
     if newAssignment.id.isnumeric() or newAssignment.id == '':
         for assignment in self._assignmentRepo:
             if assignment.id == newAssignment.id and assignment.id != assignmentID:
                 raise NotUnique("ID should be unique!")
     else:
         raise NotAnInt("ID should be an int!")
     self._assignmentRepo.update_object(idx, newAssignment)
Пример #3
0
 def update_assignment(self, assignmentID, new_id, new_description, new_day, new_month, new_year):
     ValidationServices.validate_id(assignmentID)
     ValidationServices.validate_id(new_id)
     newAssignment = Assignment(new_id, new_description, new_year, new_month, new_day)
     oldAssignment = self._assignmentController.get_assignment_object(assignmentID)
     self._assignmentController.update_assignment(assignmentID, newAssignment)
     operations = []
     redo = FunctionCall(self.update_assignment, assignmentID, new_id, new_description, new_day, new_month, new_year)
     undo = FunctionCall(self.update_assignment, new_id, oldAssignment.id, oldAssignment.description,
                         str(oldAssignment.deadline.day), str(oldAssignment.deadline.month), str(oldAssignment.deadline.year))
     operation = Operation(undo, redo)
     operations.append(operation)
     operation = self._gradeController.update_assignment_id(assignmentID, new_id)
     operations.append(operation)
     cascade = CascadingOperation(operations)
     self._undoController.recordOp(cascade)
Пример #4
0
 def update_student(self, studentID, new_id, new_name, new_group):
     ValidationServices.validate_id(studentID)
     ValidationServices.validate_id(new_id)
     newStudent = Student(new_id, new_name, new_group)
     ValidationServices.validate_student(newStudent)
     oldStudent = self._studentController.get_student_object(studentID)
     self._studentController.update_student(studentID, newStudent)
     operations = []
     redo = FunctionCall(self.update_student, studentID, new_id, new_name, new_group)
     undo = FunctionCall(self.update_student, new_id, oldStudent.id, oldStudent.name, oldStudent.group)
     operation = Operation(undo, redo)
     operations.append(operation)
     operation = self._gradeController.update_student_id(studentID, new_id)
     operations.append(operation)
     cascade = CascadingOperation(operations)
     self._undoController.recordOp(cascade)
Пример #5
0
 def remove_assignment(self, aid):
     ValidationServices.validate_id(aid)
     self._assignmentRepo.remove_object(aid)
Пример #6
0
 def add_assignment(self, assignment: Assignment):
     ValidationServices.validate_id(assignment.id)
     ValidationServices.is_unique(self.get_assignments(), assignment)
     self._assignmentRepo.add_object(assignment)