def remove_assignment(self,assign): if assign.assign_id not in self.__assignments: raise Assignment_repository_exception("This assignment ID does not belong to a assignment!") elif assign.description not in self.__assignments: raise Assignment_repository_exception("This assignment description does not belong to a assignment!\n") elif assign.group not in self.__assignments: raise Assignment_repository_exception("This group does not exist/contain any assignments!\n") else: del self.__assignments[assign.assign_id]
def remove_assignment(self,assign): ''' Removes a student with the given properties Input: :param assign Raises: :exception Assignment_repository_exception("This assignment ID does not belong to a assignment!") :exception Assignment_repository_exception("This assignment description does not belong to a assignment!\n") :exception Assignment_repository_exception("This group does not exist/contain any assignments!\n") ''' if assign.assign_id not in self.__assignments: raise Assignment_repository_exception("This assignment ID does not belong to a assignment!") elif assign.description not in self.__assignments: raise Assignment_repository_exception("This assignment description does not belong to a assignment!\n") elif assign.group not in self.__assignments: raise Assignment_repository_exception("This group does not exist/contain any assignments!\n") else: del self.__assignments[assign.assign_id]
def remove_assignment_by_id(self,assign_id): ''' Removes the assignment with the given ID from the repository if it exists Input: :param assign_id Raises: :exception Assignment_repository_exception("This assignment ID does not belong to a assignment!") ''' if assign_id not in self.__assignments: raise Assignment_repository_exception("This assignment ID does not belong to a assignment!") else: del self.__assignments[assign_id]
def update_assignment(self,assign): ''' Updates an assignment from the repository Input: :param stud Raises: :exception Assignment_repository_exception("This assignment ID does not belong to a assignment!") ''' if assign.assign_id not in self.__assignments: raise Assignment_repository_exception("This assignment ID does not belong to a assignment!") else: self.__assignments[assign.assign_id] = assign
def add_assignment(self,assign): ''' Adds an assignment to the repository if the ID is free Input: :param assign Raises: :exception Assignment_repository_exception("Assignment ID is already taken!") ''' if assign.assign_id in self.__assignments: raise Assignment_repository_exception("Assignment ID is already taken!") else: self.__assignments[assign.assign_id] = assign
def find_assignment_by_id(self,assign_id): ''' Finds the assignment with the given ID if it exists Input: :param assign_id Output: :return assign_with_id Raises: :exception Assignment_repository_exception("This ID does not belong to an assignment!") ''' if assign_id not in self.__assignments: raise Assignment_repository_exception("This ID does not belong to an assignment!") else: assign_with_id = self.__assignments[assign_id] return assign_with_id
def find_assignment_by_id(self,assign_id): if assign_id not in self.__assignments: raise Assignment_repository_exception("Invalid Id!") else: return self.__assignments[assign_id]
def remove_assignment_by_id(self,assign_id): if assign_id not in self.__assignments: raise Assignment_repository_exception("This assignment ID does not belong to a assignment!") else: del self.__assignments[assign_id]
def update_assignment(self,assign): if assign.assign_id not in self.__assignments: raise Assignment_repository_exception("This assignment ID does not belong to a assignment!") else: self.__assignments[assign.assign_id] = assign
def add_assignment(self,assign): if assign.assign_id in self.__assignments: raise Assignment_repository_exception("Assignment ID is already taken!") else: self.__assignments[assign.assign_id] = assign