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 remove_Discipline(self): try: index = self.dList.curselection() disciplineID = self.DreadID(self.dList.get(index)) disciplineID = int(disciplineID) name = '' eList = [] gList = [] for Discipline in self._disciplineControl.getCurentRepo( ).getDisciplines(): if int(Discipline.getId()) == disciplineID: name = Discipline.getName() for enroll in self._enrolControl.getCurentRepo().getEnroll(): if enroll.get_discipline_id() == disciplineID: eList.append(enroll) for grade in self._gradeControl.getCurentRepo().getGrades(): if grade.getDisciplineID() == disciplineID: gList.append(grade) try: self._disciplineControl.removeDiscipline(disciplineID) except classException: pass try: self._gradeControl.removeGradeDiscipline(disciplineID) except classException: pass try: self._enrolControl.removeEnrollDiscipline(disciplineID) except classException: pass try: self._disciplineControl.delete(disciplineID, eList, gList, name) except classException: pass self.refreshALL() except ValueError: self.displayError('Invalid Input') except NameError: self.displayError('Invalid Name') except TclError: self.displayError('No item selected')
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 removeEnrolment(self, enroll): ''' Function to remove a student Enrolment :param: enroll - enroll to be removed ''' try: self.searchEnrolment(enroll) for index in range(len(self._enrolment) - 1): if self._enrolment[index].get_student_id( ) == enroll.get_student_id( ) and self._enrolment[index].get_discipline_id( ) == enroll.get_discipline_id(): del self._enrolment[index] except classException: raise ValueError('Enrolment not found!')
def statEnroll(self): disciplineID =int(input('\nEnter discipline ID:')) print '\n1). Sort alphabetically' print '2). Sort by grade' option = input('Enter Option:') if option != 1 and option != 2: print 'Option invalid' return elif option == 1: sList = [] for enroll in self._enrolControl.getCurentRepo().getEnroll(): if enroll.get_discipline_id() == disciplineID: sList.append(enroll.get_student_id()) for index in range(len(sList)): for student in self._studentControl.getCurentRepo().getStudents(): if sList[index] == student.getId(): sList[index] = student.getName() sList.sort() print '\n' for index in sList: print index del sList[:] elif option == 2: sList = [[' ',-1]] for grade in self._gradeControl.getCurentRepo().getGrades(): if grade.getDisciplineID() == disciplineID: for student in self._studentControl.getCurentRepo().getStudents(): if student.getId() == grade.getStudentID(): if grade.getGrade() != []: gradeAvg = self.listAvg(grade.getGrade(),grade.getGradeSize()) sList.append([student.getName(),gradeAvg]) sList.sort(key=itemgetter(1),reverse = True) print '\n' for index in range(len(sList)-1): print sList[index] del sList[:]