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 discipline list :param: searchString - string to be searched for ''' for discipline in self._disciplines: 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(): print discipline
def DisciplineH(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 = [] dName = '' for discipline in self._disciplineControl.getCurentRepo( ).getDisciplines(): for grade in self._gradeControl.getCurentRepo().getGrades(): if discipline.getId() == grade.getDisciplineID(): if (grade.getGrade() != []): gAvg = self.listAvg(grade.getGrade(), grade.getGradeSize()) gList.append(gAvg) dName = discipline.getName() if gList != []: sAvg = self.listAvg(gList, len(gList)) sList.append([dName, round(sAvg, 2)]) sList.sort(key=itemgetter(1), reverse=True) for index in range(1, len(sList)): top.text.insert( END, '\n' + 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 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 addDiscipline(self,discipline): ''' Funciton to add discipline to the discipline list :param: discipline - discipline to be added ''' try: self.searchDiscipline(discipline.getId()) raise ValueError('Discipline ID already taken') except classException: self._disciplines.append(discipline)
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 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 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!')
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 statDiscipline(self): sList =[['','']] gList =[] dName = '' for discipline in self._disciplineControl.getCurentRepo().getDisciplines(): for grade in self._gradeControl.getCurentRepo().getGrades(): if discipline.getId() == grade.getDisciplineID(): if(grade.getGrade() != []): gAvg = self.listAvg(grade.getGrade(), grade.getGradeSize()) gList.append(gAvg) dName = discipline.getName() if gList != []: sAvg = self.listAvg(gList, len(gList)) sList.append([dName,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[:]