Beispiel #1
0
    def get_majors(self, path):
        """ Read the required course information from path and add to self.students """
        try:
            #read major file and add required and elective courses to the Majorfile

            for dept, req, elect in file_reader(path, 3, '\t', False):
                self.majors[dept] = Major(req, elect)
        except ValueError as ex:
            print(ex)
Beispiel #2
0
    def get_students(self, path):
        """ Read the students information from path and add to self.students """
        try:
            #ask Student to add grades to the file

            for cwid, name, major in file_reader(path, 5, '\t', False):
                self.students[cwid] = Student(cwid, name, major)
        except ValueError as ex:
            print(ex)
Beispiel #3
0
 def get_instructors(self, path):
     """ Read the students information and add to the instructor's file """
     try:
         for cwid, name, major in file_reader(path,
                                              3,
                                              sep='\t',
                                              header=False):
             self.students[cwid] = Student(cwid, name, major)
     except ValueError as ex:
         print(ex)
Beispiel #4
0
 def read_grades(self, path):
     """ read each grade and add it to the students and instructor """
     try:
         for student_cwid, course, grade, instructor_cwid in file_reader(
                 path, 3, '\t', False):
             if student_cwid in self.students:
                 self.students[student_cwid].add_course(course, grade)
         else:
             print(f"There was no grade found in '{instructor_cwid}'")
     except ValueError as ex:
         print(ex)
Beispiel #5
0
 def get_grade(self, path):
     """ Read grades and add to both files """
     try:
         for student_cwid, major_dept, grade, instructor_cwid in file_reader(
                 path, 4, '\t', False):
             if student_cwid in self.students:
                 self.students[student_cwid].add_grade(grade)
         else:
             print(f"No grade was found in the student's file")
     except ValueError as ex:
         print(ex)
         self.instructors[instructor_cwid].add_grade(grade)
Beispiel #6
0
 def read_major(self, path):
     """ read student's remaining course and add an instance to class major to self.major"""
     for dept, name, major in file_reader(path, 3, '\t', False):
         self.majors[dept].add_courses(name, major)
Beispiel #7
0
 def read_instructors(self, path):
     """ read each student and add an instance of class Instructor to self.Instructors """
     for cwid, name, dept in file_reader(path, 3, '\t', False):
         self.instructors[cwid] = Instructor(cwid, name, dept)
Beispiel #8
0
 def read_students(self, path):
     """ read each student and add an instance of class Student to self.students """
     for cwid, name, major in file_reader(path, 3, '\t', False):
         self.students[cwid] = Student(cwid, name, major)
Beispiel #9
0
        expected_instructor = None

        students = [x.pt_row() for x in stevens.students]
        majors = [k.pt_row() for k in stevens.majors]
        instructors = [
            i for inst in stevens.instructors.values() for i in instructors
        ]

        self.assertTrue(expected_student, students)
        self.assertEqual(expected_instructor, instructors)
        self.assertEqual(expected_major, majors)


if __name__ == '__main__':
    path = '/Users/user/AppData/Local/Programs/Python/Python38/HW08work.py'
    print(list(file_reader(path, n=3, sep=',', header=False)))
    unittest.main(exit=False, verbosity=2)


def test_Student_attributes(self):
    """ Verify that a specific student is set up properly """
    expected_student = {
        '10103':
        ['10103', 'Baldwin, C', ['CS 501', 'SSW 564', 'SSW 567', 'SSW 687']],
        '10115':
        ['10115', 'Wyart, X', ['CS 545', 'SSW 564', 'SSW 567', 'SSW 687']],
        '10172': ['10172', 'Forbes, I', ['SSW 555', 'SSW 567']],
        '10175': ['10175', 'Erickson, D', ['SSW 564', 'SSW567', 'SSW 687']],
        '11788': ['11788', 'Fuller, E', ['SSW 540']]
    }
    calculated = {