def searchDiscipline(self, disciplineID): ''' Funtion to find a discipline ID in the list :param: disciplineID - id to searh for ''' for grade in self._grades: if grade.getDisciplineID() == disciplineID: return grade raise classException('Discipline not found')
def searchDiscipline(self, disciplineID): ''' Funtion to find a discipline ID in the list :param: disciplineID - id to searh for ''' for enrollment in self._enrolment: if enrollment.get_discipline_id() == disciplineID: return enrollment raise classException('Discipline not found')
def searchDiscipline(self,disciplineID): ''' Function to find a discipline in the list :param: disciplindeID - dicipline to be found ''' for discipline in self.getDisciplines(): if discipline.getId() == disciplineID: return discipline raise classException('Discipline not found')
def searchStudent(self, studentID): ''' Funtion to find a student ID in the list :param: studentID - id to searh for ''' for grade in self._grades: if grade.getStudentID() == studentID: return grade raise classException('Student not found')
def searchStudent(self, studentID): ''' Function to find a student in the list :param: studentID - student to be found ''' for student in self.getStudents(): if student.getId() == studentID: return student raise classException('Student not found!')
def searchStudent(self, studentID): ''' Funtion to find a student ID in the list :param: studentID - id to searh for ''' for enrollment in self._enrolment: if enrollment.get_student_id() == studentID: return enrollment raise classException('Student not found')
def searchEnrolment(self, enroll): ''' Function to find enrollment in enrolment list :param: enroll - enrolment to search for ''' for enrollment in self._enrolment: if enrollment.get_student_id() == enroll.get_student_id( ) and enrollment.get_discipline_id() == enroll.get_discipline_id(): return enroll raise classException('Student not enrolled')
def undo(self): if self._index < 0: return False self._recorded = False try: for oper in self._operations[self._index]: oper.undo() except classException: print classException() except ValueError: pass self._recorded = True self._index -= 1 return True
def removeDiscipline(self,disciplineID): ''' Function to remove a discipline from the discipline list :param: disciplineID - discipline to be removed ''' for index in range(len(self._disciplines)): discipline = self._disciplines[index] if discipline.getId() == disciplineID: del self._disciplines[index] return raise classException('ID not found')
def searchGrade(self, grade): ''' Function to find a grade in the list :param: grade - grade to search for ''' for grades in self._grades: if grades.getDisciplineID() == grade.getDisciplineID( ) and grades.getStudentID() == grade.getStudentID(): return grade raise classException('Grade not found')
def removeGrade(self, grade): ''' Function to remove a grade based on enrollment :param: enroll - enrollment to be removed ''' for index in range(len(self._grades) - 1): gradeObj = self._grades[index] if gradeObj == grade: del self._grades[index] return raise classException('ID not found')
def updateStudentName(self, studentID, newName): ''' Function to update a student name :param: studentID - the student ID to be updated :param: newName - the new name ''' for student in self.getStudents(): if student.getId() == studentID: student.setName(newName) return raise classException('ID not found!')
def updateDisciplineName(self,disciplineID,newName): ''' Function to update a discipline name :param: disciplineID - the discipline ID to be updated :param: newName - the new name ''' for discipline in self.getDisciplines(): if discipline.getId() == disciplineID: discipline.setName(newName) return raise classException('ID not found!')
def removeStudent(self, studentID): ''' Function to remove a student from the list :param: studentID - student to be removed ''' for index in range(len(self._students)): student = self._students[index] if student.getId() == studentID: del self._students[index] return raise classException('ID not found!')
def removeGradeDiscipline(self, disciplineID): ''' Funciton to remove a discipline from the grade list :param: disciplineID - discipline to be removed ''' index = 0 while index <= len(self._grades) - 1: enroll = self._grades[index] if enroll.getDisciplineID() == disciplineID: del self._grades[index] index = 0 index += 1 raise classException('ID not found')
def removeGradeStudent(self, studentID): ''' Funciton to remove a student from the grade list :param: studentID - student to be removed ''' index = 0 while index <= len(self._grades) - 1: grade = self._grades[index] if int(grade.getStudentID()) == int(studentID): del self._grades[index] index = 0 index += 1 raise classException('ID not found')
def removeEnrollStudent(self, studentID): ''' Funciton to remove a student from the enrollment list :param: studentID - student to be removed ''' index = 0 while index <= len(self._enrolment) - 1: enroll = self._enrolment[index] if enroll.get_student_id() == studentID: del self._enrolment[index] index = 0 index += 1 raise classException('ID not found')
def removeEnrollDiscipline(self, disciplineID): ''' Funciton to remove a discipline from the enroll list :param: disciplineID - discipline to be removed ''' index = 0 while index <= len(self._enrolment) - 1: enroll = self._enrolment[index] if enroll.get_discipline_id() == disciplineID: del self._enrolment[index] index = 0 index += 1 raise classException('ID not found')
def updateStudentID(self, studentID, newID): ''' Function to update a student ID :param: studentID - the student ID to be updated :param: newID - the new ID ''' try: self.searchStudent(newID) raise ValueError('Student ID already taken') except classException: for student in self.getStudents(): if student.getId() == studentID: student.setId(newID) return raise classException('ID not found!')
def updateDisciplineID(self,disciplineID,newID): ''' Function to update the ID of a discipline :param: disciplineID - the discipline ID to be updated :param: newID - the new ID ''' try: self.searchDiscipline(newID) raise ValueError('Discipline ID already taken') except classException: for discipline in self.getDisciplines(): if discipline.getId() == disciplineID: discipline.setId(newID) return raise classException('ID not found!')