Пример #1
0
    def setUp(self):
        self.course = Course("test", CourseType.CORE)
        self.testTeach = Teacher("test_t", ["test"], [1], [])
        self.testStudent = Student("test_s", 9, [])
        self.section = self.course.newSection()
        self.section.changePeriod(1)
        self.section.changeInstructor(self.testTeach)
        self.section.addStudent(self.testStudent)

        self.schedule = Schedule("test_sched", 2)
Пример #2
0
class TestCourseMethods(unittest.TestCase):
    def setUp(self):
        self.course = Course("test", CourseType.CORE)
        self.testTeach = Teacher("test_t", ["test"], [1], [])
        self.testStudent = Student("test_s", 9, [])
        self.section = self.course.newSection()
        self.section.changePeriod(1)
        self.section.changeInstructor(self.testTeach)
        self.section.addStudent(self.testStudent)

        self.schedule = Schedule("test_sched", 2)

    def testAll(self):
        self.assertEqual(self.schedule.getOpenPeriods(),
                         [1, 2, 3, 4, 5, 6, 7, 8])
        self.schedule.addSection(self.section)
        self.assertEqual(self.schedule.getOpenPeriods(), [2, 3, 4, 5, 6, 7, 8])

        haveTeachers = [res for res in self.schedule.haveTeachers()]
        self.assertTrue(haveTeachers[0])

        expr1 = [constr for constr in self.schedule.getValidityConstr()]
        expr2 = LpAffineExpression([(LpVariable("test_sched_1_0"), 1),
                                    (LpVariable("test_sched_1_1"), 1)]) <= 1
        self.assertEqual(expr1[0], expr2)

        self.schedule.removeSection(self.section)
        self.assertEqual(self.schedule.getOpenPeriods(),
                         [1, 2, 3, 4, 5, 6, 7, 8])
Пример #3
0
    def test_student(self):
        # remove, request vector, request checking, course checking
        testCore = Course("test_core", CourseType.CORE)
        testElective = Course("test_elective", CourseType.ELECTIVE)
        testOff = Course("test_off", CourseType.OFF)

        self.stud.addReqCore(testCore)
        self.assertEqual(self.stud.reqCores, [testCore])
        self.assertEqual(self.stud.reqAll, [testCore])

        self.stud.addReqElective(testElective)
        self.assertEqual(self.stud.reqElectives, [testElective])
        self.assertEqual(self.stud.reqAll, [testCore, testElective])

        self.stud.addReqOffPeriod(testOff)
        self.assertEqual(self.stud.reqOffPeriods, [testOff])
        self.assertEqual(self.stud.reqAll, [testCore, testElective, testOff])

        res1 = self.stud.getReqVector(
            ["test_core", "test_elective", "test_off"])
        self.assertEqual(res1, [1, 1, 1])
        res2 = self.stud.getReqVector(
            ["test_core", "test_elective", "test_offS"])
        self.assertEqual(res2, [1, 1, 0])

        right = [(LpVariable("test_s_1_0"), 1), (LpVariable("test_s_2_0"), 1),
                 (LpVariable("test_s_3_0"), 1), (LpVariable("test_s_4_0"), 1),
                 (LpVariable("test_s_5_0"), 1), (LpVariable("test_s_6_0"), 1),
                 (LpVariable("test_s_7_0"), 1), (LpVariable("test_s_8_0"), 1)]

        for res in self.stud.getConstraints(["test"]):
            self.assertEqual(res, LpAffineExpression(right) == 1)

        self.stud.removeReqOff(testOff)
        self.assertEqual(self.stud.reqOffPeriods, [])
        self.assertEqual(self.stud.reqAll, [testCore, testElective])

        self.stud.removeReqElective(testElective)
        self.assertEqual(self.stud.reqElectives, [])
        self.assertEqual(self.stud.reqAll, [testCore])

        self.stud.removeReqCore(testCore)
        self.assertEqual(self.stud.reqCores, [])
        self.assertEqual(self.stud.reqAll, [])
def test_remove_elec(plan):
    # add an elec and then remove it, make sure length of reqs is the same
    reqs = list((plan.get_outstanding_reqs()).items())
    original_reqs_len = len(reqs)


    uni = University(query_db)

    econ1202 = Course('ECON', '1202', 'Quantitative analysis for business and economics', 6,
            [Term(2021, 1)], 'UNSW Business School')
    plan.add_course(econ1202, Term(2021, 1))

    assert len(reqs) == original_reqs_len
Пример #5
0
    def create_courses_and_pathways(self):
        """
        Return a list of course objects and a list of pathways. Pathways are
        sequences of courses where earlier courses in the sequence are 
        prerequisites for later courses in the sequence.
        """

        all_courses = [
            Course(c, CourseType.CORE) for c in range(self.num_courses)
        ]
        pathways = [[] for _ in range(self.num_pathways)]
        for c in all_courses:
            # add it to the shortest pathway to keep them mostly even
            min(pathways, key=lambda p: len(p)).append(c)
        return all_courses, pathways
Пример #6
0
    def defined_available_courses(self):
        """
        creat list of defined courses for student field from all courses
        :return: nothing
        """

        available_courses = []
        courses_list = read_db()
        for course in courses_list:
            if self.field_code == int(course['field_code']) or int(
                    course['field_code']) == 0:
                available_courses.append(
                    Course(course['name'], int(course['units']),
                           int(course['total_quantity']),
                           course['teacher_name'], int(course['course_code']),
                           int(course['field_code'])))
        return available_courses
Пример #7
0
def new_course(course_name, teachers, description):
    """
    PRE :   - course_name et description sont de type str
            - teachers est de type list
    POST : cree une instance de Course ssi le code de cours n'existe pas deja
    RAISES : ObjectAlreadyExistantException si le code du cours existe deja
    """
    persistent_data = cli.cli_misc.pickle_get(courses_arg=True,
                                              id_dict_arg=True)
    all_courses = persistent_data[3]
    id_dict = persistent_data[4]
    course_instance = Course(course_name, teachers, id_dict["course"],
                             description)
    id_dict["course"] += 1
    if course_name in all_courses["name_id_dict"]:
        raise ObjectAlreadyExistantException
    all_courses["objects_dict"][course_instance.course_id] = course_instance
    all_courses["name_id_dict"][course_name] = course_instance.course_id
    cli.cli_misc.pickle_save(all_courses=all_courses, id_dict=id_dict)
Пример #8
0
def reset():
    """
    PRE:
    POST: reinitialise la memoire du programme (reinitialise les fichiers de sauvegarde pickle)
    """
    id_dict = {"user": 0, "file": 0, "course": 0}

    all_students = {"name_id_dict": {}, "objects_dict": {}}
    all_admins = {"name_id_dict": {}, "objects_dict": {}}
    all_files = {"name_id_dict": {}, "objects_dict": {}}
    all_courses = {"name_id_dict": {}, "objects_dict": {}}

    for i in range(len(initial_admins)):
        admin_instance = Admin(initial_admins[i], initial_admin_fullnames[i],
                               initial_admin_pwds[i], id_dict["user"])
        id_dict["user"] += 1
        all_admins["objects_dict"][admin_instance.user_id] = admin_instance
        all_admins["name_id_dict"][
            admin_instance.username] = admin_instance.user_id

    for i in range(len(initial_students)):
        student_instance = Student(initial_students[i],
                                   initial_student_fullnames[i],
                                   initial_student_pwds[i], id_dict["user"])
        id_dict["user"] += 1
        all_students["objects_dict"][
            student_instance.user_id] = student_instance
        all_students["name_id_dict"][
            student_instance.username] = student_instance.user_id

    for i in range(len(initial_courses)):
        course_instance = Course(initial_courses[i],
                                 initial_course_teachers[i], id_dict["course"],
                                 initial_course_descriptions[i])
        id_dict["course"] += 1
        all_courses["objects_dict"][
            course_instance.course_id] = course_instance
        all_courses["name_id_dict"][
            course_instance.name] = course_instance.course_id

    return all_students, all_admins, all_files, all_courses, id_dict
Пример #9
0
 def setUp(self):
     self.course = Course("test", CourseType.CORE)
     self.otherCourse = Course("test2", CourseType.CORE)
     self.testTeach = Teacher("test_t", ["test"], [1], [])
     self.testStudent = Student("test_s", 9, [])
Пример #10
0
class TestCourseMethods(unittest.TestCase):
    def setUp(self):
        self.course = Course("test", CourseType.CORE)
        self.otherCourse = Course("test2", CourseType.CORE)
        self.testTeach = Teacher("test_t", ["test"], [1], [])
        self.testStudent = Student("test_s", 9, [])

    def test_eq(self):
        self.assertNotEqual(self.course, self.otherCourse)
        self.otherCourse.courseCode = "test"
        self.assertEqual(self.course, self.otherCourse)

    def test_add_del(self):
        self.course.addReqStudent()
        self.assertEqual(self.course.getReqStudents(), 1)

        self.course.addTeacher(self.testTeach)
        self.assertEqual(self.course.getTeachers(), [self.testTeach])
        self.assertEqual(self.course.potentialPeriods, [1])

        self.course.removeReqStudent()
        self.assertEqual(self.course.getReqStudents(), 0)

        self.course.removeTeacher(self.testTeach)
        self.assertEqual(self.course.getTeachers(), [])
        self.assertEqual(self.course.potentialPeriods, [])

    def test_section(self):
        self.section = self.course.newSection()
        self.otherCourse.addTeacher(self.testTeach)
        self.otherCourse.courseCode = "test"
        self.otherSection = self.otherCourse.newSection()

        self.assertTrue(self.section.sameBaseCourse(self.otherSection))
        self.otherSection.courseCode = "test2"
        self.assertFalse(self.section.sameBaseCourse(self.otherSection))
        self.otherSection.courseCode = "test"

        self.section.changePeriod(1)
        self.otherSection.changePeriod(1)
        self.assertEqual(self.section.getPeriod(), 1)

        self.section.changeInstructor(self.testTeach)
        self.otherSection.changeInstructor(self.testTeach)
        self.assertEqual(self.section.getInstructor(), self.testTeach)

        self.section.addStudent(self.testStudent)
        self.otherSection.addStudent(self.testStudent)
        self.assertEqual(self.section.getStudents(), [self.testStudent])
        self.assertEqual(self.section.getStudentCount(), 1)
        self.assertTrue(self.section.isTaking(self.testStudent))

        self.assertTrue(self.section.isValid())
        self.assertEqual(self.section, self.otherSection)

        self.assertEqual(
            str(self.section),
            "CourseCode: test\n of type: CORE\n with teacher: test_t\n in period: 1\n with students: [\'test_s\']"
        )

        self.assertTrue(self.section.isValid())
        self.assertEqual(self.section, self.otherSection)

        self.section.removeStudent(self.testStudent)
        self.assertEqual(self.section.getStudents(), [])
Пример #11
0
 def setUpClass(self):
     self.single_course = [Course({
         "subject": "Hospitality and Tourism Management",
         "departments": ["School of Hospitality", "Food and Tourism Management"],
         "code": "HTM",
         "number": "4080",
         "name": "Experiential Learning and Leadership in the Service Industry",
         "semesters_offered": [SemesterOffered.F, SemesterOffered.W],
         "lecture_hours": 3.5,
         "lab_hours": 0.0,
         "credits": 0.5,
         "description": "An integration of the students' academic studies with their work experiences. Emphasis\n\
         will be placed on applying and evaluating theoretical concepts in different working environments. \
         Students will investigate the concept of workplace fit applying this to their prospective career path.",
         "distance_education": DistanceEducation.ONLY,
         "year_parity_restrictions": YearParityRestrictions.EVEN_YEARS,
         "other": "Last offering - Winter 2021",
         "prerequisites": {
             "complex":
                 [
                     "14.00 credits and a minimum of 700 hours of verified work experience in the hospitality, sport and tourism industries."
                 ],
             "original": "14.00 credits and a minimum of 700 hours of verified work experience in the hospitality, sport and tourism industries."
         },
         "equates": "HISP*2040",
         "corequisites": "HTM*4075",
         "restrictions": ["MGMT*1000", "Not available to students in the BCOMM program."],
         "capacity_available": 0,
         "capacity_max": 5,
     })]
     self.two_courses = self.single_course + [
         Course({
             "subject": "Computing and Information Science",
             "departments": ["School of Computer Science"],
             "code": "CIS",
             "number": "2250",
             "name": "Software Design II",
             "semesters_offered": [SemesterOffered.W],
             "lecture_hours": float(3),
             "lab_hours": float(2),
             "credits": 0.5,
             "description": "This course focuses on the process of software design. Best practices for code development\n\
             and review will be the examined. The software development process and tools to support \
             this will be studied along with methods for project management. The course has an applied \
             focus and will involve software design and development experiences in teams, a literacy \
             component, and the use of software development tools.",
             "distance_education": DistanceEducation.NO,
             "year_parity_restrictions": YearParityRestrictions.NONE,
             "prerequisites": {
                 "simple":
                     [
                         "CIS*1250",
                         "CIS*1300"
                     ],
                 "original": "CIS*1250, CIS*1300"
             },
             "restrictions": ["Restricted to BCOMP:SENG majors"],
             "capacity_available": 10,
             "capacity_max": 20,
         })
     ]
     self.three_courses = self.two_courses + [
         Course({
             "subject": "Computing and Information Science",
             "departments": ["School of Computer Science"],
             "code": "CIS",
             "number": "3250",
             "name": "Software Design III",
             "semesters_offered": [SemesterOffered.W, SemesterOffered.S],
             "lecture_hours": float(3),
             "lab_hours": float(2),
             "credits": 7.5,
             "description": "Some description here...",
             "distance_education": DistanceEducation.NO,
             "year_parity_restrictions": YearParityRestrictions.NONE,
             "prerequisites": {
                 "simple": [
                     "CIS*2250",
                     "CIS*1300"
                 ],
                 "original": "CIS*2250, CIS*1300"
             },
             "restrictions": ["Restricted to BCOMP:SENG majors"]
         })
     ]
#!/usr/bin/env python3
from classes.course import Course
course_test1 = Course("T201", [], 1)
course_test2 = Course("T203", [], 2)
course_test3 = Course("T207", [], 3)

teacher1 = "VVDS"
teacher2 = "XD"
teacher3 = "JN"
teacher4 = "LS"
teacher5 = "MNV"
teacher6 = "YB"
teacher7 = "AD"

course_test1.add_teacher(teacher1)
course_test1.add_teacher(teacher2)
course_test1.add_teacher(teacher3)

course_test2.add_teacher(teacher4)
course_test2.add_teacher(teacher5)

course_test3.add_teacher(teacher6)
course_test3.add_teacher(teacher7)

file_id1 = 2
file_id2 = 5
file_id3 = 18
file_id4 = 111
file_id5 = 66
file_id6 = 43