def SearchALL(self): top = tk.Toplevel() top.title('Input') Input = WindowRemove('Search: ', top) Input.mainloop() top.destroy() searchString = Input.getvar(str(Input.Input1)) top = tk.Toplevel() top.title('Serch Results') top.text = Listbox(top) top.text.grid(row=0, column=0) top.text.config(width=50) top.text.insert(END, 'Disciplines:') for discipline in self._disciplineControl.getCurentRepo( ).getDisciplines(): if searchString.lower() in str(discipline.getId()).lower() or str( discipline.getId()).lower() in searchString.lower( ) or searchString.lower() in discipline.getName().lower( ) or discipline.getName().lower() in searchString.lower(): top.text.insert(END, discipline) top.text.insert(END, 'Students:') for student in self._studentControl.getCurentRepo().getStudents(): if searchString.lower() in str(student.getId()).lower() or str( student.getId()).lower() in searchString.lower( ) or searchString.lower() in student.getName().lower( ) or student.getName().lower() in searchString.lower(): top.text.insert(END, student)
def search(self, searchString): ''' Function to search in the student list :param: searchString - string to be searched for ''' for student in self._students: if searchString.lower() in str(student.getId()).lower() or str( student.getId()).lower() in searchString.lower( ) or searchString.lower() in student.getName().lower( ) or student.getName().lower() in searchString.lower(): print student
def BestStudents(self): top = tk.Toplevel() top.title('Enrollment List') top.text = Listbox(top) top.text.grid(row=0, column=0) top.text.config(width=50) sList = [['', '']] gList = [] sName = '' for student in self._studentControl.getCurentRepo().getStudents(): for grade in self._gradeControl.getCurentRepo().getGrades(): if student.getId() == grade.getStudentID(): if (grade.getGrade() != []): gAvg = self.listAvg(grade.getGrade(), grade.getGradeSize()) gList.append(gAvg) sName = student.getName() if gList != []: sAvg = self.listAvg(gList, len(gList)) sList.append([sName, round(sAvg, 2)]) sList.sort(key=itemgetter(1), reverse=True) for index in range(1, len(sList)): top.text.insert( END, str(sList[index][0] + ' - ' + str(sList[index][1]))) del sList[:]
def FailingStudents(self): top = tk.Toplevel() top.title('Enrollment List') top.text = Listbox(top) top.text.grid(row=0, column=0) top.text.config(width=50) sList = [['', '']] for grade in self._gradeControl.getCurentRepo().getGrades(): for student in self._studentControl.getCurentRepo().getStudents(): for discipline in self._disciplineControl.getCurentRepo( ).getDisciplines(): if grade.getStudentID() == student.getId(): if grade.getDisciplineID() == discipline.getId(): if grade.getGrade() != []: gradeAvg = self.listAvg( grade.getGrade(), grade.getGradeSize()) if gradeAvg < 5: sList.append([ student.getName(), discipline.getName() ]) for index in sList: top.text.insert(END, '\n' + index[0] + ' - ' + index[1]) del sList[:]
def StudentEnrollB(self): try: top = tk.Toplevel() top.title('Enrollment List') top.text = Listbox(top) top.text.grid(row=0, column=0) index = self.dList.curselection() disciplineID = self.DreadID(self.dList.get(index)) disciplineID = int(disciplineID) 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) del SList[-1] for index in SList: top.text.insert(END, index) del SList[:] except TclError: top.destroy() self.displayError('No disicpline Selected')
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[:]
def statFailing(self): sList = [['','']] for grade in self._gradeControl.getCurentRepo().getGrades(): for student in self._studentControl.getCurentRepo().getStudents(): for discipline in self._disciplineControl.getCurentRepo().getDisciplines(): if grade.getStudentID() == student.getId(): if grade.getDisciplineID() == discipline.getId(): if grade.getGrade() != []: gradeAvg = self.listAvg(grade.getGrade(),grade.getGradeSize()) if gradeAvg < 5: sList.append([student.getName(),discipline.getName()]) print '\n' for index in sList: print index[0],' - ',index[1] del sList[:]
def statBest(self): sList =[['','']] gList =[] sName = '' for student in self._studentControl.getCurentRepo().getStudents(): for grade in self._gradeControl.getCurentRepo().getGrades(): if student.getId() == grade.getStudentID(): if(grade.getGrade() != []): gAvg = self.listAvg(grade.getGrade(), grade.getGradeSize()) gList.append(gAvg) sName = student.getName() if gList != []: sAvg = self.listAvg(gList, len(gList)) sList.append([sName,round(sAvg,2)]) sList.sort(key=itemgetter(1),reverse = True) print '\n' for index in range(1,len(sList)): print sList[index][0],' - ',sList[index][1] del sList[:]