示例#1
0
    def setUp(self):
        self.student1 = StudentFactory()
        self.student1.is_active = True
        self.student1.set_password(BaseUserFactory.password)
        self.student1.save()

        self.student2 = StudentFactory()
        self.student2.is_active = True
        self.student2.set_password(BaseUserFactory.password)
        self.student2.save()

        self.course = CourseFactory(start_time=datetime.now().date() - timedelta(days=10),
                                    end_time=datetime.now().date() + timedelta(days=10))
        self.course_assignment = CourseAssignmentFactory(course=self.course,
                                                         user=self.student1)
        self.course_assignment2 = CourseAssignmentFactory(course=self.course,
                                                          user=self.student2)

        LectureFactory(course=self.course,
                       date=datetime.now().date() - timedelta(days=9))

        LectureFactory(course=self.course,
                       date=datetime.now().date() - timedelta(days=7))

        LectureFactory(course=self.course,
                       date=datetime.now().date() - timedelta(days=5))

        LectureFactory(course=self.course,
                       date=datetime.now().date() - timedelta(days=3))
示例#2
0
    def test_teacher_can_see_student_detail_information(self):
        teacher = BaseUser.objects.promote_to_teacher(self.baseuser)
        teacher.teached_courses = [self.course]

        solution1 = SolutionFactory(task=self.task, student=self.student)
        solution1.status = 3
        solution1.save()

        solution2 = SolutionFactory(task=self.task, student=self.student)
        solution2.status = 2
        solution2.save()

        solution3 = SolutionFactory(task=self.task, student=self.student)
        solution3.status = 2
        solution3.save()

        url_task = TaskFactory(course=self.course, gradable=False)
        SolutionFactory(task=url_task, student=self.student)

        LectureFactory(course=self.course,
                       date=datetime.now().date() - timedelta(days=9))

        LectureFactory(course=self.course,
                       date=datetime.now().date() - timedelta(days=7))

        LectureFactory(course=self.course,
                       date=datetime.now().date() - timedelta(days=5))

        LectureFactory(course=self.course,
                       date=datetime.now().date() - timedelta(days=3))

        check_in1 = CheckInFactory(mac=self.student.mac, user=self.student)
        check_in1.date = datetime.now().date() - timedelta(days=9)
        check_in1.save()
        check_in2 = CheckInFactory(mac=self.student.mac, user=self.student)
        check_in2.date = datetime.now().date() - timedelta(days=7)
        check_in2.save()

        with self.login(email=teacher.email,
                        password=BaseUserFactory.password):
            response = self.get('education:student-detail',
                                course=self.course.id,
                                ca=self.ca.id)
            self.assertEqual(response.status_code, 200)
            self.assertEqual(self.ca, response.context['object'])
            self.assertEqual(2, response.context['passed_solutions'])
            self.assertEqual(1, response.context['failed_solutions'])
            self.assertEqual(1, response.context['url_solutions'])
示例#3
0
 def test_baseuser_cannot_access_course_materials(self):
     week = WeekFactory()
     LectureFactory(week=week, course=self.course)
     MaterialFactory(week=week, course=self.course)
     with self.login(email=self.baseuser.email,
                     password=BaseUserFactory.password):
         response = self.get('education:material-list',
                             course=self.course.id)
         self.assertEqual(response.status_code, 403)
示例#4
0
 def test_student_cannot_access_other_courses_materials(self):
     course2 = CourseFactory()
     week = WeekFactory()
     LectureFactory(week=week, course=course2)
     MaterialFactory(week=week, course=course2)
     with self.login(email=self.student.email,
                     password=BaseUserFactory.password):
         response = self.get('education:material-list', course=course2.id)
         self.assertEqual(response.status_code, 403)
示例#5
0
 def test_teacher_can_access_course_materials(self):
     teacher = BaseUser.objects.promote_to_teacher(self.baseuser)
     teacher.teached_courses = [self.course]
     week = WeekFactory()
     LectureFactory(week=week, course=self.course)
     MaterialFactory(week=week, course=self.course)
     with self.login(email=teacher.email,
                     password=BaseUserFactory.password):
         response = self.get('education:material-list',
                             course=self.course.id)
         self.assertEqual(response.status_code, 200)
示例#6
0
 def test_no_access_to_material_list_without_login(self):
     week = WeekFactory()
     LectureFactory(week=week, course=self.course)
     MaterialFactory(week=week, course=self.course)
     response = self.get('education:material-list', course=self.course.id)
     self.assertEquals(response.status_code, 302)