Ejemplo n.º 1
0
 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')
Ejemplo n.º 2
0
 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')
Ejemplo n.º 3
0
 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!')
Ejemplo n.º 4
0
    def remove_Student(self):
        try:
            index = self.sList.curselection()
            studentID = self.SreadID(self.sList.get(index))
            studentID = int(studentID)

            name = ''
            eList = []
            gList = []

            for Student in self._studentControl.getCurentRepo().getStudents():
                if int(Student.getId()) == studentID:
                    name = Student.getName()

            for enroll in self._enrolControl.getCurentRepo().getEnroll():
                if enroll.get_student_id() == studentID:
                    eList.append(enroll)

            for grade in self._gradeControl.getCurentRepo().getGrades():
                if int(grade.getStudentID()) == studentID:
                    gList.append(grade)

            try:
                self._studentControl.removeStudent(studentID)
            except classException:
                pass
            try:
                self._enrolControl.removeEnrollStudent(studentID)
            except classException:
                pass
            try:
                self._gradeControl.removeGradeStudent(studentID)
            except classException:
                pass

            self._studentControl.delete(studentID, eList, gList, name)

            self.refreshALL()

        except ValueError:
            self.displayError('Invalid Input')

        except NameError:
            self.displayError('Invalid Name')

        except TclError:
            self.displayError('No item selected')
Ejemplo n.º 5
0
 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[:]