def add_Enroll(self): try: index = self.sList.curselection() studentID = self.SreadID(self.sList.get(index)) studentID = int(studentID) index = self.dList.curselection() disciplineID = self.DreadID(self.dList.get(index)) disciplineID = int(disciplineID) #try: self._enrolControl.addEnroll(enroll(studentID, disciplineID)) #except ValueError: #self.displayError('Enrollment allready exists') self._enrolControl.create(enroll(studentID, disciplineID)) self.refreshALL() except ValueError: self.displayError('Invalid Input') except NameError: self.displayError('Invalid Name') except TclError: self.displayError('No item selected')
def gradeStudent(self): studentID = int(input('\nEnter student ID: ')) disciplineID = int(input('Enter discipline ID: ')) gradeValue = float(input('Enter grade: ')) Valid().ID(studentID) Valid().ID(disciplineID) Valid().grade(gradeValue) S = self._studentControl D = self._disciplineControl E = self._enrolControl G = self._gradeControl self.addRepo(S,D,E,G) try: self._enrolControl.searchEnroll(enroll(studentID,disciplineID)) self._gradeControl.addGrade(grade(disciplineID,studentID),gradeValue) self.oCont += 1 self.compare() except ValueError: print '\nStudent has been graded'
def removeEnrollment(self): studentID = int(input('\nEnter student ID: ')) disciplineID = int(input('Enter discipline ID: ')) self._enrolControl.removeEnroll(enroll(studentID,disciplineID)) print '\nErnollment had been removed' self.oCont += 1 self.compare()
def readRepo(self): with open( 'C:\Users\user\Desktop\Uni\FP\Eclipse\Lab 5-7 Propper\Initializers\enrollments', 'r') as eFile: for line in eFile: self._list.append( enroll(int(line.split(' ', 1)[0]), int(line.split(' ', 1)[1])))
def remove_Enroll(self): try: index = self.eList.curselection() IDs = self.EreadID(self.eList.get(index)) studentID = int(IDs[0]) disicplineID = int(IDs[1]) self.eList.delete(ANCHOR) self._gradeControl.removeGrade(enroll(studentID, disicplineID)) self._enrolControl.removeEnroll(enroll(studentID, disicplineID)) self.Erefresh() self.Grefresh() self.refreshALL() except ValueError: self.displayError('Invalid Input') except NameError: self.displayError('Invalid Name') except TclError: self.displayError('No item selected')
def testClasses(self): ''' Function for the class tests ''' ''' :Student: :Section: ''' sTest = student(-1, 'Test') assert sTest.getId() == -1 assert sTest.getName() == 'Test' sTest.setId(int(-2)) assert sTest.getId() == -2 sTest.setName('Test2') assert sTest.getName() == 'Test2' ''' :Discipline: :Section: ''' dTest = discipline(-1, 'Test') assert dTest.getId() == -1 assert dTest.getName() == 'Test' dTest.setId(int(-2)) assert dTest.getId() == -2 dTest.setName('Test2') assert dTest.getName() == 'Test2' ''' :Enroll: :Section: ''' eTest = enroll(1, 1) assert eTest.get_discipline_id() == 1 assert eTest.get_student_id() == 1 eTest.set_discipline_id(2) assert eTest.get_discipline_id() == 2 eTest.set_student_id(2) assert eTest.get_student_id() == 2 ''' :Grade: :Section: ''' gTest = grade(1, 1) assert gTest.getDisciplineID() == 1 assert gTest.getStudentID() == 1 gTest.addGrade(10) assert gTest.getGrade() == [10] assert gTest.getGradeSize() == 1 gTest.setDisciplieID(2) assert gTest.getDisciplineID() == 2 gTest.setStudentID(int(-2))
def addEnrollment(self): studentID = int(input('\nEnter student ID: ')) disciplineID = int(input('Enter discipline ID: ')) Valid().ID(studentID) Valid().ID(disciplineID) S = self._studentControl D = self._disciplineControl E = self._enrolControl G = self._gradeControl self.addRepo(S,D,E,G) self._disciplineControl.searchDiscipline(disciplineID) self._studentControl.searchStudent(studentID) self._enrolControl.addEnroll(enroll(studentID,disciplineID)) print '\nEnrollment has been added' self.oCont += 1 self.compare()
def readRepo(self): with open(self._path,'r') as eFile: for line in eFile: self._enrolment.append(enroll(int(line.split(' ',1)[0]),int(line.split(' ',1)[1])))
def NewFile(self): self._studentControl.setRepo(deepcopy(student(1, ''))) self._disciplineControl.setRepo(deepcopy(discipline(1, ''))) self._enrolControl.setRepo(deepcopy(enroll(1, 1))) self._gradeControl.setRepo(deepcopy(grade(1, 1))) self.refreshALL()
def __init__(self): self._enrolment = [enroll(1, 1)]
def testRepos(self): ''' Function for the repository test ''' ''' :Student: :Section: ''' sTest = studentRepository() sTest.setStudents([]) assert sTest.getStudents() == [] assert sTest.getStudentSize() == 0 sTest.addStudent(student(1, 'Test')) assert sTest.getStudents() == [student(1, 'Test')] assert sTest.searchStudent(1) == student(1, 'Test') sTest.updateStudentID(1, 2) assert sTest.getStudents()[0].getId() == 2 sTest.updateStudentName(2, 'Test2') assert sTest.getStudents()[0].getName() == 'Test2' sTest.removeStudent(2) assert sTest.getStudents() == [] ''' :Discipline: :Section: ''' dTest = disciplineRepository() dTest.setDisciplines([]) assert dTest.getDisciplines() == [] assert dTest.getDisciplinesSize() == 0 dTest.addDiscipline(discipline(1, 'Test')) assert dTest.getDisciplines() == [discipline(1, 'Test')] assert dTest.searchDiscipline(1) == discipline(1, 'Test') dTest.updateDisciplineID(1, 2) assert dTest.getDisciplines()[0].getId() == 2 dTest.updateDisciplineName(2, 'Test2') assert dTest.getDisciplines()[0].getName() == 'Test2' dTest.removeDiscipline(2) assert dTest.getDisciplines() == [] ''' :Enroll: :Section: ''' eTest = enrollRepository() eTest.setEnroll([]) assert eTest.getEnroll() == [] assert eTest.getEnrollSize() == 0 en = enroll(1, 1) eTest.addEnrolment(en) assert eTest.getEnrollSize() == 1 assert eTest.getEnroll() == [en] assert eTest.searchEnrolment(en) == en eTest.addEnrolment(enroll(1, 2)) eTest.addEnrolment(enroll(2, 3)) eTest.removeEnrollDiscipline(2) eTest.removeEnrollStudent(2) assert eTest.getEnrollSize() == 1 ''' :Grade: :Section: ''' gTest = gradeRepository() gTest.setGrade([]) assert gTest.getGradesSize() == 0 assert gTest.getGrades() == [] gr = grade(1, 1) gTest.addGrade(gr, 10) assert gTest.getGrades() == [gr] assert gTest.getGrades()[0].getGrade() == [10.0] gTest.updateGradeDisciplineID(1, 2) assert gTest.getGrades()[0].getDisciplineID() == 2 gTest.updateGradeStudentID(1, 10) assert gTest.getGrades()[0].getStudentID() == 10 gTest.removeGradeDiscipline(2) assert gTest.getGradesSize() == 0 gr = grade(1, 1) gTest.addGrade(gr, 10) gr1 = grade(10, 1) gTest.addGrade(gr1, 10) assert gTest.getGradesSize() == 2 assert gTest.getGrades() == [gr, gr1] gr2 = grade(1, 10) gTest.addGrade(gr2, 10) assert gTest.getGrades() == [gr, gr1, gr2] gTest.removeGradeDiscipline(10) assert gTest.getGrades() == [gr, gr2] gTest.removeGradeStudent(10) assert gTest.getGrades() == [gr]
def createMemoryControllers(self): sRepo = studentRepository() sRepo.addStudent(student(2, 'Ion Pascu')) sRepo.addStudent(student(3, 'Anrei Istoc')) sRepo.addStudent(student(4, 'Maria Jiu')) sRepo.addStudent(student(5, 'Camelia Danu')) sRepo.addStudent(student(6, 'Ionut Frunza')) sRepo.addStudent(student(7, 'Eleanor Popescu')) sRepo.addStudent(student(8, 'Ana-Maria Biju')) sRepo.addStudent(student(9, 'Dan Lautar')) sRepo.addStudent(student(10, 'Maria Babos')) sRepo.addStudent(student(11, 'Irina Mase')) sRepo.addStudent(student(12, 'Estera Chelariu')) sRepo.addStudent(student(13, 'Florin Andreescu')) sRepo.addStudent(student(14, 'Bobes Bogdan')) sRepo.addStudent(student(15, 'Victor Paul')) dRepo = disciplineRepository() dRepo.addDiscipline(discipline(2, 'Analiza Lexicografica')) dRepo.addDiscipline(discipline(3, 'Sport')) eRepo = enrollRepository() eRepo.addEnrolment(enroll(2, 1)) eRepo.addEnrolment(enroll(3, 1)) eRepo.addEnrolment(enroll(4, 1)) eRepo.addEnrolment(enroll(5, 1)) eRepo.addEnrolment(enroll(6, 2)) eRepo.addEnrolment(enroll(7, 2)) eRepo.addEnrolment(enroll(8, 2)) eRepo.addEnrolment(enroll(9, 2)) eRepo.addEnrolment(enroll(10, 2)) eRepo.addEnrolment(enroll(11, 3)) eRepo.addEnrolment(enroll(12, 3)) eRepo.addEnrolment(enroll(13, 3)) eRepo.addEnrolment(enroll(14, 3)) eRepo.addEnrolment(enroll(15, 3)) gRepo = gradeRepository() gRepo.addGrade(grade(1, 1), 10) gRepo.addGrade(grade(1, 2), 6.5) gRepo.addGrade(grade(1, 3), 4.3) gRepo.addGrade(grade(1, 4), 2.3) gRepo.addGrade(grade(1, 5), 6) gRepo.addGrade(grade(2, 6), 7) gRepo.addGrade(grade(2, 7), 7) gRepo.addGrade(grade(2, 8), 7) gRepo.addGrade(grade(2, 9), 7) gRepo.addGrade(grade(2, 10), 7) gRepo.addGrade(grade(3, 11), 7) gRepo.addGrade(grade(3, 12), 7) gRepo.addGrade(grade(3, 13), 7) gRepo.addGrade(grade(3, 14), 7) gRepo.addGrade(grade(3, 15), 7) E = enrollControllerWithUndo(eRepo, self._undoController) G = gradeControllerWithUndo(gRepo, self._undoController) S = studentControlWithUndo(sRepo, E, G, self._undoController) D = disciplineControlWithUndo(dRepo, E, G, self._undoController) return [S, D, E, G]