def setUp(self):
     self.courses = CourseRepository()
     self.course1 = Course(1, "Asc", "Vancea")
     self.courses.save(self.course1)
     self.course2 = Course(2, "Fp", "Is")
     self.course3 = Course(3, "Logica", "Pop")
     self.course4 = Course(1, "L", "Pop")
     self.courses.save(self.course2)
 def setUp(self):
     courses = CourseRepository()
     self.course1 = Course(1, "Asc", "Vancea")
     self.course2 = Course(2, "Fp", "I")
     self.course3 = Course(3, "Logica", "Pop")
     courses.save(self.course1)
     courses.save(self.course2)
     self.course_controller = CourseController(courses)
Exemple #3
0
 def setUp(self):
     self.grades = GradeRepository()
     self.course1 = Course(1, "Asc", "Vancea")
     self.student1 = Student(1, "Vlad")
     self.student2 = Student(2, "Ion")
     self.course2 = Course(2, "Fp", "I")
     self.grade1 = Grade(self.student1, self.course1, 10)
     self.grade2 = Grade(self.student1, self.course2, 4)
     self.grade3 = Grade(self.student2, self.course1, 7)
     self.grade4 = Grade(self.student1, self.course1, 8)
     self.grades.save(self.grade1)
     self.grades.save(self.grade2)
Exemple #4
0
    def __init__(self):
        # Put csv in dataframe object
        dfStudents = pd.read_csv("files/studentenenvakken.csv",
                                 encoding="ISO-8859-1")
        dfCourses = pd.read_csv("files/courses.csv")

        students = []
        for index, row in dfStudents.iterrows():
            newStudent = Student(row[2])
            students.append(newStudent)

        self.courses = []
        for index, row in dfCourses.iterrows():
            newCourse = Course(row[0], students, row[3])
            self.courses.append(newCourse)

        # Set rooms with sizes
        room1 = Room(1, 41)
        room2 = Room(2, 22)
        room3 = Room(3, 20)
        room4 = Room(4, 56)
        room5 = Room(5, 48)
        room6 = Room(6, 117)
        room7 = Room(7, 60)
        self.rooms = [room1, room2, room3, room4, room5, room6, room7]

        # Set timeblocks
        timeblock1 = TimeBlock(1, 9)
        timeblock2 = TimeBlock(2, 11)
        timeblock3 = TimeBlock(3, 13)
        timeblock4 = TimeBlock(4, 15)
        self.timeblocks = [timeblock1, timeblock2, timeblock3, timeblock4]
Exemple #5
0
 def delete(self, id):
     try:
         f = open("data/courses", "r")
         f1 = open("data/temp", "w")
         found = False
         for line in f:
             object = line.split(",")
             course = Course(int(object[0]), object[1], object[2])
             self.validator.validate(course)
             if course.get_id() != id:
                 s = str(course.get_id()) + "," + course.get_name(
                 ) + "," + course.get_professor() + ",\n"
                 f1.write(s)
             else:
                 found = True
         f.close()
         f1.close()
         if found == False:
             raise CourseError("Course not found")
         f1 = open("data/temp", "r")
         f = open("data/courses", "w")
         for line in f1:
             f.write(line)
         f.close()
         f1.close()
     except IOError:
         raise ValueError("Cannot read course data")
 def setUp(self):
     self.student = Student(1, "Vlad")
     self.course = Course(10, "Asc", "Vancea")
     self.grade = Grade(self.student, self.course, 10)
     self.invalid_grade = Grade(self.student, self.course, 30)
     self.invalid_grade2 = Grade(self.student, self.course, -30)
     self.validator_g = GradeValidator()
Exemple #7
0
 def setUp(self):
     self.students = StudentRepository()
     courses = CourseRepository()
     grades = GradeRepository()
     self.course1 = Course(1, "Asc", "Vancea")
     self.student1 = Student(1, "Vlad")
     self.student2 = Student(2, "Alex")
     courses.save(self.course1)
     self.students.save(self.student1)
     self.students.save(self.student2)
     self.course2 = Course(2, "Fp", "I")
     courses.save(self.course2)
     self.grade1 = Grade(self.student1, self.course1, 10)
     self.grade2 = Grade(self.student1, self.course2, 4)
     grades.save(self.grade1)
     grades.save(self.grade2)
     self.grade_controller = GradeController(courses, self.students, grades)
Exemple #8
0
 def create(self, id, name, professor):
     '''
     create -> Course
     Creates and returns a Course that has the given id, name, professor
     :param id: int >= 0
     :param name: string
     :param professor: string
     '''
     course = Course(id, name, professor)
     return course
Exemple #9
0
 def find_by_professor(self, professor):
     try:
         f = open("data/courses", "r")
         courses = []
         for line in f:
             object = line.split(",")
             course = Course(int(object[0]), object[1], object[2])
             self.validator.validate(course)
             if course.get_professor() == professor:
                 courses.append(course)
         return courses
     except IOError:
         raise ValueError("Cannot read course data")
Exemple #10
0
 def find_by_id(self, id):
     try:
         f = open("data/courses", "r")
         for line in f:
             object = line.split(",")
             course = Course(int(object[0]), object[1], object[2])
             self.validator.validate(course)
             if course.get_id() == id:
                 f.close()
                 return course
         return -1
     except IOError:
         raise ValueError("Cannot read course data")
Exemple #11
0
 def save(self, course_to_add):
     try:
         f = open("data/courses", "a+")
         for line in f:
             object = line.split(",")
             course = Course(int(object[0]), object[1], object[2])
             self.validator.validate(course)
             if course.get_id() == course_to_add.get_id():
                 raise CourseError("Duplicated Id's")
         s = str(course_to_add.get_id()) + "," + course_to_add.get_name(
         ) + "," + course_to_add.get_professor() + ",\n"
         f.write(s)
         f.close()
     except IOError:
         raise ValueError("Cannot read course data")
Exemple #12
0
 def find_index(self, course_to_add):
     try:
         f = open("data/courses", "r")
         index = 0
         for line in f:
             object = line.split(",")
             course = Course(int(object[0]), object[1], object[2])
             self.validator.validate(course)
             if course.get_id() == course_to_add.get_id():
                 f.close()
                 return index
             else:
                 index = index + 1
         return -1
     except IOError:
         raise ValueError("Cannot read course data")
Exemple #13
0
 def update_course(self, id, name, professor):
     '''
     update_course -> None
     Updates a Course from the list of courses
     If the course doesn't exist or there id a validation error, raises CourseError
     :param id: int
     :param name: string
     :param professor: string
     '''
     course = Course(id, name, professor)
     self.course_validator.validate(course)
     self.course_repository.update(course)
     grades_to_update = self.grade_repository.find_by_course(
         course.get_id())
     for i in range(0, len(grades_to_update)):
         student = self.student_repository.find_by_id(
             grades_to_update[i].get_id_student())
         grade = grades_to_update[i].get_grade()
         grade = self.create(student, course, grade)
         self.grade_repository.update(grade)
Exemple #14
0
 def read_from_file(self):
     '''
     read_from_file -> list of Courses
     Reads information about courses written in a file and puts it in a list,
     raises IOError if the file is corrupted
     '''
     courses = []
     try:
         f = open("data/courses", "r")
         line = f.readline()
         while line != "":
             object = line.split(",")
             course = Course(int(object[0]), object[1], object[2])
             for i in range(0, len(courses)):
                 if int(object[0]) == courses[i].get_id():
                     raise IOError
             self.validator.validate(course)
             courses.append(course)
             line = f.readline()
         f.close()
         return courses
     except IOError:
         raise ValueError("Cannot read courses")
 def setUp(self):
     self.course = Course(10, "Asc", "Vancea")
     self.invalid_course = Course(-1, "", "v")
     self.validator_c = CourseValidator()