def FindStudentbyID(self,stid):
     f = open(self.getFileN(),"r")
     line = f.readline().strip()
     l = line.split()
     end = False
     while end != True:
         s = Student(int(l[0]),l[1])
         if(s.getId() == stid):
             return s 
         line = f.readline().strip()
         l = line.split()
         if(line == ["End"]):
             end = True
Example #2
0
 def __addStudent(self):
     try:
         id=int(input("Input id "))
         name=input("Input name ")
         group=int(input("Input group"))
         self.__ctrl.addStudent(Student(id,name,group))
     except ValueError as e:
         print(e)
Example #3
0
 def createStudent(self, studentID, studentName):
     '''
         Function that creates a student based on an ID and on a name
         input: studentID - integer
                studentName - string
         output: student - a student
     '''
     student = Student(studentID, studentName)
     return student
    def test_studetController(self):
        repoStudents = StudentRepo('studentstest', Student.write_student, Student.read_student)
        studentController = StudentController(repoStudents)

        studentController.create(1, 'Name', 'Group')
        self.assertEqual(studentController.repo.getAll()[0], Student(1, 'Name', 'Group'))

        studentController.remove(1)
        self.assertEqual(len(studentController.repo.getAll()), 0)
Example #5
0
 def grade(self, studentId, laboratoryNo, val):
     grade = Grades(None, None, None, val)
     self.__validateGrades.validate(grade)
     student = Student(studentId, None, None)
     if student not in self.studentRepo.getAll():
         raise ValidError('The student does not exist!')
     for grade in self.gradeRepo.getAll(studentId):
         if grade.labNo == laboratoryNo:
             grade.value = val
             self.gradeRepo.update()
    def test_student(self):
        validateStudent = ValidateStudent()
        student = Student(1, 'Name', 'Group')

        validateStudent.validate(student)

        self.assertEqual(student.id, 1)
        self.assertEqual(student.name, 'Name')
        self.assertEqual(student.group, 'Group')
        self.assertEqual(str(student), '1 Name Group')

        student1 = Student(2, 'Name', 'Group')

        self.assertEqual(student, student)
        self.assertFalse(student == student1, True)

        badStudent = Student('x', 100, '')
        try:
            validateStudent.validate(badStudent)
        except ValidError as ve:
            self.assertEqual(str(ve), 'Wrong ID!\nWrong name!\nWrong group!\n')
Example #7
0
    def __loadFromFile(self):
        try:
            f = open(self._fName, 'r')
            t = f.readline().strip()
            while t != '':
                args = t.split(',')
                self.__data.append(Student(int(args[0]), args[1],
                                           int(args[2])))
                t = f.readline().strip()

            f.close()
        except IOError:
            return
    def test_repoStudents(self):
        repoStudents = StudentRepo('studentstest', Student.write_student, Student.read_student)
        self.assertEqual(len(repoStudents.getAll()), 0)

        repoStudents.store(Student(1, 'Name', 'Group'))
        self.assertEqual(len(repoStudents.getAll()), 1)

        try:
            repoStudents.store(Student(1, 'Name', 'Group'))
        except RepoError as re:
            self.assertEqual(str(re), 'The object already exists!')
            self.assertEqual(len(repoStudents.getAll()), 1)

        repoStudents.delete(Student(1, None, None))
        self.assertEqual(len(repoStudents.getAll()), 0)

        try:
            repoStudents.delete(Student(1, None, None))
        except RepoError as re:
            self.assertEqual(str(re), 'The object does not exist!')
            self.assertEqual(len(repoStudents.getAll()), 0)

        try:
            repoStudents.find(Student(1, None, None))
        except RepoError as re:
            self.assertEqual(str(re), 'Could not find the object!')

        repoStudents.store(Student(1, 'Name', 'Group'))
        self.assertEqual(repoStudents.find(Student(1, None, None)) == Student(1, 'Name', 'Group'), True)

        repoStudents.saveToFile()
        with open('studentstest', 'r') as f:
            line = f.read()
            self.assertEqual(line, str(Student(1, 'Name', 'Group'))+'\n')

        repoStudents.delete(Student(1, None, None))
    def create_student_obj(self, line):
        print(line)

        studentID = line[0]
        studentName = line[1]
        studentGrp = line[2]
        snew = Student(studentID, studentName, studentGrp, '')
        if line[3] != '\n':
            assignments_list = line[3].split('/')

            for ass in assignments_list:

                b = ass.split('.')
                a = self.create_assignment_object(b)
                snew.assignments_owned.append(a)

        return snew
Example #10
0
 def initialiseStudentRegister(self, n):
     '''
         Function that initialise the student register by adding n random students
         input: n - integer
         output: -
         raises: -
     '''
     listOfNames = [
         "Abel Crosby", 
         "Jaylan Church", 
         "Kolten Beard", 
         "Alfonso Cole", 
         "Liana Travis", 
         "Jaidyn Benton", 
         "Jazlene Grimes", 
         "Kane Obrien", 
         "Cory Tyler", 
         "Joyce Hopkins", 
         "Adelyn Richardson", 
         "Savannah Kent", 
         "Jase Frazier", 
         "Kaeden Mills", 
         "Liam Wu", 
         "Zaiden Knight", 
         "Efrain Olsen", 
         "Zackery Olsen", 
         "Luciano Dorsey", 
         "Waylon White", 
         "Raul Joseph", 
         "Magdalena Fitzgerald", 
         "Reese Mccann", 
         "Jaylee Spencer", 
         "Litzy Olsen", 
         "Emery Summers", 
         "Deangelo Jimenez", 
         "Trace Macias", 
         "Hana Padilla", 
         "Nash Best", 
         "Jakayla Shannon", 
         "Kamden Green", 
         "Crystal Cain", 
         "Niko Liu", 
         "Aniyah Foley", 
         "Colin Castro", 
         "Stephany Davies", 
         "Jacquelyn Oneill", 
         "Alma Riddle", 
         "Ryland White", 
         "Mariyah Conley", 
         "Karlee Lang", 
         "Jaeden Espinoza", 
         "Cruz Valenzuela", 
         "Priscilla Coleman", 
         "Amiah Nash", 
         "Matias Briggs", 
         "Paisley Porter", 
         "Dulce Hall", 
         "Parker Molina", 
         "Oscar Wolf", 
         "Richard Marshall", 
         "Kiley Friedman", 
         "Charity Spence", 
         "Jamir Steele", 
         "Nathanial Blanchard", 
         "Veronica Sutton", 
         "Misael Cooley", 
         "Claudia Wilkins", 
         "Madelyn Trujillo", 
         "Julius Parrish", 
         "Brandon Graham", 
         "Yaretzi Robbins", 
         "Emilee Holder", 
         "Elvis Thompson", 
         "Trevin Ferrell", 
         "Slade Norris", 
         "Carla Pruitt", 
         "Josh Love", 
         "Weston Steele", 
         "Phoebe Wilkerson", 
         "Memphis Dodson", 
         "Ibrahim White", 
         "Amiya Pierce", 
         "Kaiya Mcintosh", 
         "Tamara Reyes", 
         "Carley Lutz", 
         "Asia Andrade", 
         "Isabell Curry", 
         "Ayden Clements", 
         "Princess Hunter", 
         "Caroline Mitchell", 
         "Dakota Browning", 
         "Dangelo Hurley", 
         "Tyrone Chambers", 
         "Darien Walker"]
     for x in range(1, n + 1):
         studName = random.choice(listOfNames)
         listOfNames.remove(studName)
         studID = x * 14
         student = Student(studID, studName)
         self.studentRegister.append(student)
Example #11
0
 def assignLab(self, studentId, labNo, labProblemNo):
     student = Student(studentId, None, None)
     if student not in self.studentRepo.getAll():
         raise ValidError('The student does not exist!')
     lab = Grades(studentId, labNo, labProblemNo, 0)
     self.gradeRepo.store(lab)
Example #12
0
 def remove(self, studentId):
     student = Student(studentId, None, None)
     self.repo.delete(student)
Example #13
0
 def create(self, id, name, group):
     student = Student(id, name, group)
     self.__validateStudent.validate(student)
     self.undorepo = copy.deepcopy(self.repo)
     self.repo.store(student)