def test_valid_double(self):
        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.save()

        course = models.Course()
        course.num_labs = 2
        course.current_num_TA = 0
        course.num_lectures = 2
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        inscourse = models.InstructorCourse()
        inscourse.instructor = inst1
        inscourse.course = course
        inscourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()

        lec2 = models.Lecture()
        lec2.course = course
        lec2.lecture_section = "402"
        lec2.save()

        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'supervisor'
        session.save()
        response = client.post('/assign_instructor_lec/',
                               data={
                                   'email': "*****@*****.**",
                                   'course_id': "301",
                                   'course_department': "COMPSCI",
                                   'course_section': "401"
                               },
                               follow="true")
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Assign Instructor To Lecture")
        self.assertContains(response, "Instructor assigned to lecture")
        response = client.post('/assign_instructor_lec/',
                               data={
                                   'email': "*****@*****.**",
                                   'course_id': "301",
                                   'course_department': "COMPSCI",
                                   'course_section': "402"
                               },
                               follow="true")
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Assign Instructor To Lecture")
        self.assertContains(response, "Instructor assigned to lecture")
Ejemplo n.º 2
0
    def test_delete_account_after_instructor_assign(self):

        tester = models.User()
        tester.email = "*****@*****.**"
        tester.password = "******"
        tester.type = "instructor"
        tester.save()

        course = models.Course()
        course.num_labs = 2
        course.current_num_TA = 0
        course.num_lectures = 1
        course.instructor = "DEFAULT"
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        lecture = models.Lecture()
        lecture.instructor = tester.email
        lecture.course = course
        lecture.lecture_section = 499
        lecture.save()

        self.assertEqual(Commands.delete_account("*****@*****.**"), "[email protected] has been deleted successfully")
        self.assertEqual(len(models.User.objects.filter(email="*****@*****.**")), 0)
        self.assertEqual(models.Lecture.objects.get(lecture_section=499).instructor, "no instructor")
Ejemplo n.º 3
0
    def test_no_such_lab_or_lec_sup(self):
        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        sup1 = models.User()
        sup1.email = "*****@*****.**"
        sup1.type = "supervisor"
        sup1.save()

        course = models.Course()
        course.num_labs = 0
        course.current_num_TA = 0
        course.num_lectures = 1
        course.instructor = "DEFAULT"
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()

        response = Commands.assign_ta_to_lablec(sup1.email, ta1.email,
                                                course.course_id, "804",
                                                course.course_department)
        self.assertEqual(response, "No Such Lab or Lecture")
    def test_proper(self):
        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.save()

        course = models.Course()
        course.num_labs = 2
        course.current_num_TA = 0
        course.num_lectures = 1
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        inscourse = models.InstructorCourse()
        inscourse.instructor = inst1
        inscourse.course = course
        inscourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()

        response = Commands.assign_instructor_to_lec(inst1.email,
                                                     course.course_id,
                                                     lec.lecture_section,
                                                     course.course_department)
        self.assertEqual(response, "Instructor assigned to lecture")
    def test_improper_admin_ins(self):
        ad1 = models.User()
        ad1.email = "*****@*****.**"
        ad1.type = "administrator"
        ad1.save()

        sup1 = models.User()
        sup1.email = "*****@*****.**"
        sup1.type = "supervisor"
        sup1.save()

        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.save()

        course = models.Course()
        course.num_labs = 0
        course.current_num_TA = 1
        course.num_lectures = 1
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        inscourse = models.InstructorCourse()
        inscourse.instructor = inst1
        inscourse.course = course
        inscourse.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()
        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'instructor'
        session.save()
        response = client.post('/assign_ta_lablec/',
                               data={
                                   'email': "*****@*****.**",
                                   'course_id': "301",
                                   'course_department': "COMPSCI",
                                   'course_section': "401"
                               },
                               follow="true")
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Assign TA to Labs/Lectures")
        self.assertContains(response, "no such ta")
    def test_ta_not_assigned_sup(self):
        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        sup1 = models.User()
        sup1.email = "*****@*****.**"
        sup1.type = "supervisor"
        sup1.save()

        course = models.Course()
        course.num_labs = 0
        course.current_num_TA = 0
        course.num_lectures = 1
        course.instructor = "DEFAULT"
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        course1 = models.Course()
        course1.num_labs = 0
        course1.current_num_TA = 0
        course1.num_lectures = 1
        course1.instructor = "DEFAULT"
        course1.course_id = "302"
        course1.course_department = "COMPSCI"
        course1.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()

        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'supervisor'
        session.save()
        response = client.post('/assign_ta_lablec/',
                               data={
                                   'email': "*****@*****.**",
                                   'course_id': "302",
                                   'course_department': "COMPSCI",
                                   'course_section': "401"
                               },
                               follow="true")
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Assign TA")
        self.assertContains(response, "TA not assigned to this course!")
    def test_not_assigned_to_course_ins(self):
        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.save()

        inst3 = models.User()
        inst3.email = "*****@*****.**"
        inst3.type = "instructor"
        inst3.save()

        course = models.Course()
        course.num_labs = 0
        course.current_num_TA = 1
        course.num_lectures = 1
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        inscourse = models.InstructorCourse()
        inscourse.instructor = inst1
        inscourse.course = course
        inscourse.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()
        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'instructor'
        session.save()
        response = client.post('/assign_ta_lablec/',
                               data={
                                   'email': "*****@*****.**",
                                   'course_id': "301",
                                   'course_department': "COMPSCI",
                                   'course_section': "401"
                               },
                               follow="true")
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, "Assign TA to Labs/Lectures")
        self.assertContains(response, "You are not assigned to this course")
Ejemplo n.º 8
0
    def create_course(department, course_id, num_lectures, num_labs):
        good_dept = [
            "COMPSCI", "ELECENG", "PHYSICS", "MATH", "BIOMED", "CIVIL",
            "INDENG", "MATENG", "MECHENG", "STRUCENG", "WEBDEV"
        ]
        if department not in good_dept:
            return "That department is not offered"
        if not course_id.isdigit():
            return "Course ID must be a number"
        if int(course_id) < 101 or int(course_id) > 999:
            return "Course ID must be 3 digits long and between 101 and 999"
        if not num_labs.isdigit():
            return "Number of lab sections must be a number"
        if not num_lectures.isdigit():
            return "Number of lecture sections must be a number"
        if int(num_labs) < 0 or int(num_labs) > 5:
            return "Number of lab sections cannot be less than 0 or greater than 5"
        if int(num_lectures) < 1 or int(num_lectures) > 5:
            return "Number of lecture sections cannot be less than 1 or greater than 5"

        try:
            find_course = models.Course.objects.get(
                course_department=department, course_id=course_id)
        except models.Course.DoesNotExist:
            find_course = "none"
        if find_course != "none":
            return "Course already exists"

        some_course = models.Course()
        some_course.course_department = department
        some_course.course_id = course_id
        some_course.course_dept_id = department + str(course_id)
        some_course.num_lectures = num_lectures
        some_course.num_labs = num_labs
        some_course.save()

        for i in range(int(num_labs)):
            lab = models.Lab()
            lab.lab_section = 801 + i
            lab.course = some_course
            lab.save()

        for i in range(int(num_lectures)):
            lec = models.Lecture()
            if int(num_labs) == 0:
                temp = 1 + i
                lec.lecture_section = "00" + str(temp)
            else:
                lec.lecture_section = 401 + i
            lec.course = some_course
            lec.save()

        return "Course created successfully"
    def setUp(self):
        course1 = models.Course()
        course1.course_department = "COMPSCI"
        course1.course_id = 361
        course1.num_lectures = 1
        course1.num_labs = 1
        course1.save()

        lec1 = models.Lecture()
        lec1.course = course1
        lec1.lecture_section = "401"
        lec1.lecture_location = "Somewhere"
        lec1.lecture_time = datetime.time(12, 00)
        lec1.save()

        lab1 = models.Lecture()
        lab1.course = course1
        lab1.lab_section = "801"
        lab1.lab_location = "Somewhere"
        lab1.lab_time = datetime.time(12, 00)
        lab1.save()
Ejemplo n.º 10
0
    def test_ta_not_assigned_ins(self):
        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.save()

        course = models.Course()
        course.num_labs = 0
        course.current_num_TA = 1
        course.num_lectures = 1
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        course1 = models.Course()
        course1.num_labs = 0
        course1.current_num_TA = 0
        course1.num_lectures = 1
        course1.instructor = "DEFAULT"
        course1.course_id = "302"
        course1.course_department = "COMPSCI"
        course1.save()

        inscourse = models.InstructorCourse()
        inscourse.instructor = inst1
        inscourse.course = course
        inscourse.save()

        inscourse1 = models.InstructorCourse()
        inscourse1.instructor = inst1
        inscourse1.course = course1
        inscourse1.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()
        response = Commands.assign_ta_to_lablec(inst1.email, ta1.email,
                                                course1.course_id,
                                                lec.lecture_section,
                                                course.course_department)
        self.assertEqual(response, "TA not assigned to this course!")
Ejemplo n.º 11
0
    def test_improper_admin_ins(self):
        ad1 = models.User()
        ad1.email = "*****@*****.**"
        ad1.type = "administrator"
        ad1.save()

        sup1 = models.User()
        sup1.email = "*****@*****.**"
        sup1.type = "supervisor"
        sup1.save()

        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.save()

        course = models.Course()
        course.num_labs = 0
        course.current_num_TA = 1
        course.num_lectures = 1
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        inscourse = models.InstructorCourse()
        inscourse.instructor = inst1
        inscourse.course = course
        inscourse.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()
        response = Commands.assign_ta_to_lablec(inst1.email, ad1.email,
                                                course.course_id,
                                                lec.lecture_section,
                                                course.course_department)
        self.assertEqual(response, "no such ta")
    def test_access_info_ta_course_lecture_tapage(self):

        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.name = "Ted"
        ta1.save()

        course1 = models.Course()
        course1.course_department = "COMPSCI"
        course1.course_id = "100"
        course1.course_dept_id = "COMPSCI100"
        course1.TA = "*****@*****.**"
        course1.num_lectures = 1
        course1.current_num_lectures = 1
        course1.save()

        ta1_course1 = models.TACourse()
        ta1_course1.TA = ta1
        ta1_course1.course = course1
        ta1_course1.save()

        lecture1 = models.Lecture()
        lecture1.TA = "*****@*****.**"
        lecture1.course = course1
        lecture1.lecture_section = "401"
        lecture1.save()

        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'administrator'
        session.save()

        response = client.get('/access_info/')
        self.assertEqual(response.status_code, 200)
        response = client.get('/ta/[email protected]/')
        self.assertContains(response, "Lectures")
        self.assertContains(response, "COMPSCI100-401")
    def test_access_info_inst_course_lecture_instpage(self):

        inst1 = models.User()
        inst1.email = "*****@*****.**"
        inst1.type = "instructor"
        inst1.name = "Bob"
        inst1.save()

        course1 = models.Course()
        course1.course_department = "COMPSCI"
        course1.course_id = "100"
        course1.course_dept_id = "COMPSCI100"
        course1.instructor = "*****@*****.**"
        course1.num_lectures = 1
        course1.current_num_lectures = 1
        course1.save()

        inst1_course1 = models.InstructorCourse()
        inst1_course1.instructor = inst1
        inst1_course1.course = course1
        inst1_course1.save()

        lecture1 = models.Lecture()
        lecture1.instructor = "*****@*****.**"
        lecture1.course = course1
        lecture1.lecture_section = "401"
        lecture1.save()

        client = Client()
        session = client.session
        session['email'] = '*****@*****.**'
        session['type'] = 'administrator'
        session.save()

        response = client.get('/access_info/')
        self.assertEqual(response.status_code, 200)
        response = client.get('/instructor/[email protected]/')
        self.assertContains(response, "Lectures")
        self.assertContains(response, "COMPSCI100-401")
Ejemplo n.º 14
0
    def test_invalid_lec_assign_sup(self):
        ta1 = models.User()
        ta1.email = "*****@*****.**"
        ta1.type = "ta"
        ta1.save()

        sup1 = models.User()
        sup1.email = "*****@*****.**"
        sup1.type = "supervisor"
        sup1.save()

        course = models.Course()
        course.num_labs = 2
        course.current_num_TA = 0
        course.num_lectures = 1
        course.instructor = "DEFAULT"
        course.course_id = "301"
        course.course_department = "COMPSCI"
        course.save()

        tacourse = models.TACourse()
        tacourse.TA = ta1
        tacourse.course = course
        tacourse.save()

        lec = models.Lecture()
        lec.course = course
        lec.lecture_section = "401"
        lec.save()

        response = Commands.assign_ta_to_lablec(sup1.email, ta1.email,
                                                course.course_id,
                                                lec.lecture_section,
                                                course.course_department)
        self.assertEqual(response,
                         "TA cannot be assigned to this lecture(labs exist)!")