def create(self, disciplineID, name):

        redo = FunctionCall(self.addDiscipline, discipline(disciplineID, name))
        undo = FunctionCall(self.removeDiscipline, disciplineID)
        operation = Operation(redo, undo)
        self._undoController.newOperation()
        self._undoController.recordOperation(operation)
Exemplo n.º 2
0
    def add_Discipline(self):
        try:
            top = tk.Toplevel()
            top.title('Input')
            Input = Window2('Enter discipline ID: ', 'Enter discipline Name: ',
                            top)
            Input.mainloop()
            top.destroy()

            if not Input.getvar(str(Input.Input1)) == None or not Input.getvar(
                    str(Input.Input2)) == None:
                disciplineID = Input.getvar(str(Input.Input1))
                name = Input.getvar(str(Input.Input2))
                Valid().name(name)
                Valid().ID(disciplineID)
                self._disciplineControl.getCurentRepo().addDiscipline(
                    discipline(int(disciplineID), name))

                self._disciplineControl.create(int(disciplineID), name)

                self.refreshALL()

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

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

        except TclError:
            self.displayError('No item selected')

        except idError:
            self.displayError('Invalid ID')
Exemplo n.º 3
0
 def readRepo(self):
     with open(
             'C:\Users\user\Desktop\Uni\FP\Eclipse\Lab 5-7 Propper\Initializers\disciplines',
             'r') as dFile:
         for line in dFile:
             self._list.append(
                 discipline(int(line.split(' ', 1)[0]),
                            line.split(' ', 1)[1][:-1]))
Exemplo n.º 4
0
 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))
Exemplo n.º 5
0
 def addDiscipline(self):
     disciplineID = int(input('\nEnter discipline ID: '))
     name = str(raw_input('Enter discipline Name: '))
     
     Valid().name(name)
     Valid().ID(disciplineID)
     
     S = self._studentControl
     D = self._disciplineControl
     E = self._enrolControl
     G = self._gradeControl
     
     self.addRepo(S,D,E,G)
     
     self._disciplineControl.addDiscipline(discipline(disciplineID,name))
     print '\nDiscipline has been added'
     self.oCont += 1
     self.compare()
    def delete(self, disciplineID, eList, gList, name):

        disciplineID = int(disciplineID)

        redo = FunctionCall(self.removeDiscipline, disciplineID)
        undo = FunctionCall(self.addDiscipline, discipline(disciplineID, name))

        operation = Operation(redo, undo)
        self._undoController.newOperation()
        self._undoController.recordOperation(operation)

        for Grade in gList:
            redo = FunctionCall(self._gCTRL.removeGradeList, Grade)
            undo = FunctionCall(self._gCTRL.addGradeList, Grade)
            operation = Operation(redo, undo)
            self._undoController.recordOperation(operation)

        for Enroll in eList:
            redo = FunctionCall(self._eCTRL.removeEnrollDiscipline,
                                Enroll.get_discipline_id())
            undo = FunctionCall(self._eCTRL.addEnroll, Enroll)
            operation = Operation(redo, undo)
            self._undoController.recordOperation(operation)
Exemplo n.º 7
0
 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._disciplines = [discipline(1,'Fundamental of Programing')]
Exemplo n.º 9
0
    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]
Exemplo n.º 10
0
 def readRepo(self):
     with open(self._path, 'r') as dFile:
         for line in dFile:
             self._disciplines.append(
                 discipline(int(line.split(' ', 1)[0]),
                            line.split(' ', 1)[1][:-1]))
Exemplo n.º 11
0
    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]