Example #1
0
def main():
    course_code = input("Enter course code: ")
    quota = int(input("Enter course quota: "))
    course1 = Course(course_code, quota)

    user_input = 5
    while user_input != 0:
        user_input = int(
            input("Enter 1 for add student, 2 for drop student,"
                  "3 for course info, 0 for exit: "))

        if user_input == 1:
            course1.add_student()
            print("Enrollment: ", course1.getEnrollment())
            print()
        elif user_input == 2:
            course1.drop_student()
            print("Enrollment: ", course1.getEnrollment())
            print()
        elif user_input == 3:
            print("Course code: ", course1.getCourse_code())
            print("Quota: ", course1.getQuota())
            print("Enrollment: ", course1.getEnrollment())
            print()
        elif user_input == 4:
            new_quota = int(input("Enter new quota: "))
            course1.setQuota(new_quota)
Example #2
0
class TestCourse(unittest.TestCase):

    def setUp(self):
        self.course = Course()
        self.id_course = self.course.id_course

    def test_init(self):
        self.assertEqual(self.course.language, None)
        self.assertEqual(self.course.level, None)
        self.assertEqual(self.course.price, None)
        self.assertEqual(self.course.teachers, [])
        self.assertEqual(self.course.students, [])
        self.assertEqual(self.course.address, None)
        self.assertEqual(self.course.books, [])

    def test_add_teacher(self):
        self.course.add_teacher(11)
        self.assertIn(11, self.course.teachers)

    def test_add_student(self):
        self.course.add_student(18)
        self.assertIn(18, self.course.students)

    def test_str(self):
        self.assertEqual(str(self.course), f'id_course: {self.id_course}, ')

    def tearDown(self):
        Course.id -= 1
Example #3
0
def add_course():
    """adds a new course to school
    
    Returns:
        response -- status
    """

    content = request.json
    try:
        _validate_string_input('Course ID', content['course_id'])
        if len(content) == 4:
            if school.course_exists(content['course_id']):
                response = app.response_class(response='Course exists',
                                              status=400)
            else:
                course = Course(content['course_id'], content['crn'],
                                content['program'])
                school.add_course(course)
                for student in content['students']:
                    course.add_student(student)

                response = app.response_class(status=200)
        else:
            response = app.response_class(response='Course is invalid',
                                          status=400)
    except ValueError as e:
        response = app.response_class(response='Course is invalid', status=400)
    return response
Example #4
0
def main():

    # input course code and max size
    c_code = input("Enter course code: ")
    c_max_size = int(input("Enter maximum class size: "))
    # create Course object, pass course code and max size as arguments
    course = Course(c_code, c_max_size)
    # initialize choice to 4
    choice = 4

    while (choice != 0):

        # input choice
        choice = int(
            input(
                "Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: "
            ))

        # if choice is 1, call add_student method of Course object and display enrollment of Course object
        if (choice == 1):
            course.add_student()
            print("Enrollment: ", course.enrollment)

        # if choice is 2, call drop_student method of Course object and display enrollment of Course object
        if (choice == 2):
            course.drop_student()
            print("Enrollment: ", course.enrollment)

        # if choice is 3, display course code, max size and enrollment of Course object
        if (choice == 3):
            print("Course code: ", course.code)
            print("Maximum class size: ", course.max_size)
            print("Enrollment: ", course.enrollment)
def main():
    course_code = input("Enter course code: ")
    try:
        max_size = int(input("Enter maximum class size: "))
    except:
        print("must be an integer")
    else:
        print()
    my_course = Course(course_code,
                       max_size)  # creates an instance of the course

    choice = -1
    while choice != 0:
        try:
            choice = int(
                input(
                    "Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: "
                ))
            if choice < 0 or choice > 3:
                raise
        except:
            print("\033[1minvalid command. \033[0m")
        else:
            if choice == 1:
                my_course.add_student()  # call add_student from Course
            elif choice == 2:
                my_course.drop_student()
            elif choice == 3:
                print("Course Code:", my_course.code)
                print("Maximum Class Size:", my_course.max_size)
                print("Enrollment:", my_course.enrollment)
            else:
                break
Example #6
0
    def test_add_student_already_enrolled(self):
        """TP-5B: check if the student already enrolled check works"""
        course = Course("ACIT2515", "123456", "CIT")
        course.add_student("A01048668")
        course.add_student("A01048668")

        self.assertEqual(course.get_num_students(), 1,
                         "You cannot have two of the same student enrolled")
Example #7
0
 def test_remove_student_empty(self):
     """TP-6D: check if the student ID is empty"""
     course = Course("ACIT2515", "123456", "CIT")
     student = "A01048668"
     self.assertNotEqual(student, "")
     course.add_student(student)
     course.remove_student(student)
     self.assertEqual(course.get_num_students(), 0,
                      "Student ID cannot be empty")
Example #8
0
 def test_remove_student_invalid(self):
     """TP-6C: check if the student ID is set to none"""
     course = Course("ACIT2515", "123456", "CIT")
     student = "A01048668"
     self.assertIsNotNone(student)
     course.add_student(student)
     course.remove_student(student)
     self.assertEqual(course.get_num_students(), 0,
                      "Student ID cannot be undefined")
Example #9
0
 def test_get_details(self):
     """TP-9A: check the get_details function"""
     course = Course("ACIT2515", "123456", "CIT")
     student = "A01048668"
     course.add_student(student)
     self.assertNotEqual(
         course.get_details(),
         "ACIT2515 (123456) is a course in the CIT Program with the following students: ",
         "Course cannot be empty")
Example #10
0
    def test_add_student_empty(self):
        """TP-5D: check if the student ID is empty"""
        course = Course("ACIT2515", "123456", "CIT")
        student = "A01048668"
        self.assertNotEqual(student, "")
        course.add_student(student)

        self.assertNotEqual(
            course.get_details(),
            "ACIT2515 (123456) is a course in the CIT Program with the following students: ",
            "Student ID cannot be empty")
Example #11
0
    def test_add_student_invalid(self):
        """TP-5C: check the validity of the student ID"""
        course = Course("ACIT2515", "123456", "CIT")
        student = "A01048668"
        self.assertIsNotNone(student)
        course.add_student(student)

        self.assertNotEqual(
            course.get_details(),
            "ACIT2515 (123456) is a course in the CIT Program with the following students: ",
            "Student ID cannot be undefined")
Example #12
0
 def test_get_num_students(self):
     """TP-8A: check if the get_num_students method returns a valid number"""
     course = Course("ACIT2515", "123456", "CIT")
     student1 = "A00000001"
     student2 = "A00000002"
     student3 = "A00000003"
     course.add_student(student1)
     course.add_student(student2)
     course.add_student(student3)
     course.get_num_students
     self.assertEqual(course.get_num_students(), 3,
                      "There should be 3 students enrolled")
Example #13
0
    def test_get_num_courses_in_program(self):
        """ 060A - Valid Get Number of Courses in Program """

        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A01000056")

        test_course_2 = Course("COMP1409", "123444", "CSD")
        test_course_2.add_student("A01000056")

        test_course_3 = Course("COMP1510", "123555", "CSD")
        test_course_3.add_student("A01000045")

        test_course_4 = Course("COMP2530", "123667", "CSD")
        test_course_4.add_student("A01000034")

        test_school = School("Computing and Academic Studies")
        test_school.add_course(test_course_1)
        test_school.add_course(test_course_2)
        test_school.add_course(test_course_3)
        test_school.add_course(test_course_4)

        self.assertEqual(test_school.get_num_courses_in_program("CIT"), 1,
                         "Must be only 1 CIT course")
        self.assertEqual(test_school.get_num_courses_in_program("CSD"), 3,
                         "Must be 3 CSD courses")
        self.assertEqual(test_school.get_num_courses_in_program("SSD"), 0,
                         "Must be no SSD courses")
Example #14
0
    def test_add_course_already_exists(self):
        """ 020C - Course Already Exists """

        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_school = School("Computing and Academic Studies")
        self.assertEqual(test_school.get_num_courses(), 0, "School must have no courses")

        test_school.add_course(test_course_1)
        self.assertEqual(test_school.get_num_courses(), 1, "School must have 1 course")

        # Add the same course again
        test_school.add_course(test_course_1)
        self.assertEqual(test_school.get_num_courses(), 1, "School must still have only 1 course")
Example #15
0
    def test_get_non_existent_course(self):
        """ 050C - Invalid Get Course Non-Existent """

        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_course_2 = Course("COMP1510", "456321", "CST")
        test_course_2.add_student("A010000056")
        test_course_2.add_student("A010450012")

        test_school = School("Computing and Academic Studies")
        test_school.add_course(test_course_1)
        test_school.add_course(test_course_2)

        self.assertIsNone(test_school.get_course("ACIT1234"), "No course should exists for ACIT1234")
Example #16
0
 def test_is_enrolled_in_course_morethan0(self):
     """TP-7A: check if there are more than 0 students enrolled"""
     course = Course("ACIT2515", "123456", "CIT")
     student1 = "A00000001"
     student2 = "A00000002"
     student3 = "A00000003"
     course.add_student(student1)
     course.add_student(student2)
     course.add_student(student3)
     self.assertEqual(course.is_enrolled_in_course("A00000001"), True,
                      "A00000001 should be enrolled")
     self.assertEqual(course.is_enrolled_in_course("A00000002"), True,
                      "A00000002 should be enrolled")
     self.assertEqual(course.is_enrolled_in_course("A00000003"), True,
                      "A00000003 should be enrolled")
def main():
    course_code = input("Enter course code: ").upper()
    max_class_size = int(input("Enter maximum class size: "))
    course1 = Course(course_code, max_class_size)

    option = 4
    while option != 0:
        option = int(input("Enter 1 to add student, 2 to drop student, "
                           "3 for class info, 0 to exit: "))
        if option == 1:
            course1.add_student()
        elif option == 2:
            course1.drop_student()
        elif option == 3:
            print("Course code: ", course1.course_code, "\nMaximum class size: ", course1.max_class_size,
                  "\nEnrollment: ", course1.enrollment)
Example #18
0
    def test_course_exists_not_existent_course(self):
        """ 030C - Valid Course Does Not Exist """

        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_course_2 = Course("COMP1510", "456321", "CST")
        test_course_2.add_student("A010000056")
        test_course_2.add_student("A010450012")

        test_school = School("Computing and Academic Studies")
        test_school.add_course(test_course_1)
        test_school.add_course(test_course_2)

        self.assertFalse(test_school.course_exists("ACIT1234"), "Course ACIT1234 must NOT exist")
        self.assertFalse(test_school.course_exists("COMP4321"), "Course4321 must NOT exist")
Example #19
0
    def test_course_exists(self):
        """ 030A - Valid Course Exists """

        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_course_2 = Course("COMP1510", "456321", "CST")
        test_course_2.add_student("A010000056")
        test_course_2.add_student("A010450012")

        test_school = School("Computing and Academic Studies")
        test_school.add_course(test_course_1)
        test_school.add_course(test_course_2)

        self.assertTrue(test_school.course_exists("ACIT2515"), "Course ACIT2515 must exist")
        self.assertTrue(test_school.course_exists("COMP1510"), "Course COMP1510 must exist")
Example #20
0
    def test_add_course(self):
        """ 020A - Valid Add Course """
        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_course_2 = Course("COMP1510", "456321", "CST")
        test_course_2.add_student("A010000056")
        test_course_2.add_student("A010450012")

        test_school = School("Computing and Academic Studies")
        self.assertEqual(test_school.get_num_courses(), 0, "School must have no courses")

        test_school.add_course(test_course_1)
        self.assertEqual(test_school.get_num_courses(), 1, "School must have 1 course")

        test_school.add_course(test_course_2)
        self.assertEqual(test_school.get_num_courses(), 2, "School must have 2 courses")
Example #21
0
    def test_get_school_details(self):
        """ 050A - Valid Get Course """
        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_course_2 = Course("COMP1510", "456321", "CST")
        test_course_2.add_student("A010000056")
        test_course_2.add_student("A010450012")

        test_school = School("BCIT")
        test_school.add_course(test_course_1)
        test_school.add_course(test_course_2)
        
        retreived_school = test_school.get_school_details()
        self.assertEqual(retreived_school["school_name"], "BCIT", "School must be named BCIT")
        self.assertEqual(retreived_school["num_courses"], 2, "School must have two programs")
        self.assertEqual(sorted(retreived_school["programs"]), sorted(["CIT", "CST"]), "School must have CST as the program")
Example #22
0
    def test_get_course(self):
        """ 050A - Valid Get Course """
        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_course_2 = Course("COMP1510", "456321", "CST")
        test_course_2.add_student("A010000056")
        test_course_2.add_student("A010450012")

        test_school = School("Computing and Academic Studies")
        test_school.add_course(test_course_1)
        test_school.add_course(test_course_2)

        retrieved_course = test_school.get_course("ACIT2515")
        self.assertEqual(retrieved_course.get_course_id(), "ACIT2515", "Course must have course ID ACIT2515")
        self.assertEqual(retrieved_course.get_crn(), "123456", "Course must have CRN 123456")
        self.assertEqual(retrieved_course.get_program(), "CIT", "Course must be in CIT program")
def main():
    course_code = input('Enter course code: ')
    max_size = int(input('Enter maximum class size: '))
    course1 = Course(course_code, max_size)
    choice = -1

    while choice != 0:
        choice = int(
            input(
                'Enter 1 for add student, 2 for drop student, 3 for crouse info, 0 for exit: '
            ))
        if choice == 1:
            course1.add_student()
        elif choice == 2:
            course1.drop_student()
        elif choice == 3:
            print('Course code: ', course_code)
            print('Maximum class size: ', max_size)
            print('Enrollment: ', course1.enrollment)
Example #24
0
    def test_remove_non_existent_course(self):
        """ 040C - Invalid Remove Course Non-Existent """

        test_course_1 = Course("ACIT2515", "123456", "CIT")
        test_course_1.add_student("A010000056")

        test_course_2 = Course("COMP1510", "456321", "CST")
        test_course_2.add_student("A010000056")
        test_course_2.add_student("A010450012")

        test_school = School("Computing and Academic Studies")
        test_school.add_course(test_course_1)
        test_school.add_course(test_course_2)

        self.assertEqual(test_school.get_num_courses(), 2, "School must have 2 courses")
        self.assertTrue(test_school.course_exists("ACIT2515"))
        self.assertTrue(test_school.course_exists("COMP1510"))

        test_school.remove_course("ACIT1234")
        self.assertEqual(test_school.get_num_courses(), 2, "School must have 2 courses")
    def __init__(self,
                 uid,
                 name,
                 courses_html,
                 user_html,
                 course_list,
                 senior=False):
        self.uid = uid
        Student.student_ids.append(uid)
        self.name = name

        # Courses
        soup = BeautifulSoup(courses_html, 'html.parser')

        item_names = soup.select('.course-item-right')
        courses = []
        for item in item_names:
            course_link = item.select('a')[0].attrs['href']
            course_id = int(course_link[8:])
            course_name = item.select('a')[0].get_text()
            if course_id not in Course.course_ids:
                new_course = Course(course_id, course_name)
                new_course.add_student(self)
                course_list.append(new_course)
            else:
                for c in course_list:
                    if c.cid == course_id:
                        c.add_student(self)
            courses.append(course_id)

        self.courses = courses

        # Name, Grade
        soup2 = BeautifulSoup(user_html, 'html.parser')

        self.grade = None
        if (len(soup2.select("span.admin-val.email")) > 0):
            email = soup2.select("span.admin-val.email")[0].get_text()
            # Frosh = 1, Soph = 2, Junior = 3, Senior = 4
            if not senior or (senior and "*****@*****.**" in email):
                self.grade = 24 - int(email[-13:-11])
Example #26
0
def init_lists(c_list, s_list, a_list):

    course1 = Course("CSC227", 2)
    course1.add_student("1003")
    course1.add_student("1004")
    c_list.append(course1)
    course2 = Course("CTI115", 2)
    course2.add_student("1001")
    c_list.append(course2)
    course3 = Course("DBA130", 1)
    course3.add_student("1002")
    c_list.append(course3)

    student1 = Student("1001", "111")
    s_list.append(student1)
    student2 = Student("1002", "222")
    s_list.append(student2)
    student3 = Student("1003", "333")
    s_list.append(student3)
    student4 = Student("1004", "444")
    s_list.append(student4)

    admin1 = Admin("8001", "888")
    a_list.append(admin1)
    admin2 = Admin("9001", "999")
    a_list.append(admin2)
def init_lists(c_list, s_list, a_list):
    """
    This function adds elements to course_list, student_list and
    admin_list.  It makes testing and grading easier.  It has
    three parameters: c_list is the list of Course objects;
    s_list is the list of Student objects; a_list is the list of
    Admin objects.  This function has no return value.
    
    """

    course1 = Course("CSC121", 2)
    course1.add_student("1004")
    course1.add_student("1003")
    c_list.append(course1)
    course2 = Course("CSC122", 2)
    course2.add_student("1001")
    c_list.append(course2)
    course3 = Course("CSC221", 1)
    course3.add_student("1002")
    c_list.append(course3)

    student1 = Student("1001", "111")
    s_list.append(student1)
    student2 = Student("1002", "222")
    s_list.append(student2)
    student3 = Student("1003", "333")
    s_list.append(student3)
    student4 = Student("1004", "444")
    s_list.append(student4)

    admin1 = Admin("7001", "777")
    a_list.append(admin1)
    admin2 = Admin("8001", "888")
    a_list.append(admin2)
def main():
    course_code = input('Enter course code: ')
    quota = int(input('Enter course quota: '))
    course1 = Course(course_code, quota)

    oper = 1
    while oper != 0:
        oper = int(input('Enter 1 for add student, 2 for drop student, '
                     '3 for course info, 0 for exit: '))
        if oper == 1:
            course1.add_student()
            print('Enrollment:', course1.enrollment)
            print()
        elif oper == 2:
            course1.drop_student()
            print('Enrollment:', course1.enrollment)
            print()
        elif oper == 3:
            print('Course code:', course1.course_code)
            print('Quota:', course1.quota)
            print('Enrollment:', course1.enrollment)
            print()
def main():
    course_code = input('Enter course code: ')
    max_size = int(input('Enter maximum class size: '))
    course1 = Course(course_code, max_size)
    choice = -1

    while choice != 0:
        choice = int(
            input(
                'Enter 1 for add student, 2 for drop student, 3 for crouse info, 4 to change maximum class size, 0 for exit: '
            ))
        if choice == 1:
            course1.add_student()
        elif choice == 2:
            course1.drop_student()
        elif choice == 3:
            print('Course code: ', course1.getCode())
            print('Maximum class size: ', course1.getMax_size())
            print('Enrollment: ', course1.getEnrollment())
        elif choice == 4:
            new_max_size = int(input('Enter new maximum class size: '))
            course1.setMax_size(new_max_size)
def main():
    course_code = input('Enter course code: ')
    max_size = input('Enter maximum class size: ')
    max_size = max_size_error_check(max_size)
    course1 = Course(course_code, max_size)

    usr_input = input(
        'Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: '
    )
    usr_input = error_check(usr_input)

    while usr_input != 0:
        usr_input = int(usr_input)
        if usr_input == 3:
            print('Course code:', course1.course_code)
            print('Maximum class size:', course1.max_size)
            print('Enrollment:', course1.enrollment)
            usr_input = input(
                '\nEnter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: '
            )
            usr_input = error_check(usr_input)
        elif usr_input == 2:
            course1.drop_student()
            print('Enrollment:', course1.enrollment)
            usr_input = input(
                '\nEnter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: '
            )
            usr_input = error_check(usr_input)
        elif usr_input == 1:
            course1.add_student()
            print('Enrollment:', course1.enrollment)
            usr_input = input(
                '\nEnter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: '
            )
            usr_input = error_check(usr_input)
        elif usr_input == 0:
            pass