Esempio n. 1
0
 def setUp(self):
     self.baseuser = BaseUserFactory()
     self.baseuser.is_active = True
     self.baseuser.save()
     self.baseuser2 = BaseUserFactory()
     self.baseuser2.is_active = True
     self.baseuser2.save()
     self.student = BaseUser.objects.promote_to_student(self.baseuser2)
     self.course = CourseFactory()
     self.task = TaskFactory(course=self.course)
     self.course_assignment = CourseAssignmentFactory(course=self.course,
                                                      user=self.student)
Esempio n. 2
0
    def test_teacher_can_see_only_courses_for_which_is_teacher(self):
        teacher = BaseUser.objects.promote_to_teacher(self.baseuser)
        course = CourseFactory()
        teacher.teached_courses = [course]
        course2 = CourseFactory()

        with self.login(username=teacher.email,
                        password=BaseUserFactory.password):
            response = self.get('education:course-list')
            self.assertEqual(response.status_code, 200)
            self.assertIn(course, response.context['teacher_courses'])
            self.assertNotIn(course2, response.context['teacher_courses'])

            self.assertNotIn('student_courses', response.context)
Esempio n. 3
0
    def test_create_file_if_there_is_db(self):
        baseuser = BaseUserFactory()
        baseuser.is_active = True
        baseuser.save()
        student = BaseUser.objects.promote_to_student(baseuser)
        course = CourseFactory()

        CourseAssignmentFactory(course=course,
                                user=student)
        course1 = CourseFactory()
        course2 = CourseFactory()

        self.assertFalse(os.path.exists('working_ats.csv'))
        call_command('create_csv_with_all_workingats', "{}, {}".format(course1.id, course2.id))
        self.assertTrue(os.path.exists('working_ats.csv'))
Esempio n. 4
0
    def test_student_can_see_only_courses_for_which_have_courseassignments(
            self):
        student = BaseUser.objects.promote_to_student(self.baseuser)

        course = CourseFactory()
        course2 = CourseFactory()
        CourseAssignmentFactory(course=course, user=student)

        with self.login(username=student.email,
                        password=BaseUserFactory.password):
            response = self.get('education:course-list')
            self.assertEqual(response.status_code, 200)
            self.assertIn(course, response.context['student_courses'])
            self.assertNotIn(course2, response.context['student_courses'])

            self.assertNotIn('teacher_courses', response.context)
Esempio n. 5
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))
Esempio n. 6
0
 def test_student_cannot_access_task_list_of_course_without_tasks(self):
     course2 = CourseFactory()
     CourseAssignmentFactory(course=course2, user=self.student)
     with self.login(email=self.student.email,
                     password=BaseUserFactory.password):
         response = self.get('education:task-list', course=course2.id)
         self.assertEqual(response.status_code, 404)
Esempio n. 7
0
 def setUp(self):
     self.course = CourseFactory()
     self.user = BaseUserFactory()
     self.user.is_active = True
     self.user.save()
     self.course_description = CourseDescriptionFactory(course=self.course)
     self.application_info = ApplicationInfoFactory(course=self.course_description)
Esempio n. 8
0
 def setUp(self):
     now = datetime.now()
     self.student = StudentFactory()
     self.course = CourseFactory(start_time=now.date() - timedelta(days=10),
                                 end_time=now.date() + timedelta(days=10),
                                 generate_certificates_until=now.date() + timedelta(days=10))
     self.course_assignment = CourseAssignmentFactory(course=self.course,
                                                      user=self.student)
Esempio n. 9
0
    def setUp(self):
        self.student = StudentFactory()
        self.course = CourseFactory()

        self.task = TaskFactory(course=self.course)
        self.solution = SolutionFactory(student=self.student,
                                        task=self.task,
                                        status=Solution.PENDING)
Esempio n. 10
0
 def test_teacher_cannot_access_no_materials_of_course_not_in_teached_courses(
         self):
     teacher = BaseUser.objects.promote_to_teacher(self.baseuser)
     teacher.teached_courses = [self.course]
     course2 = CourseFactory()
     with self.login(email=teacher.email,
                     password=BaseUserFactory.password):
         response = self.get('education:material-list', course=course2.id)
         self.assertEqual(response.status_code, 403)
Esempio n. 11
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)
Esempio n. 12
0
    def test_teacher_can_see_only_his_course(self):
        teacher = BaseUser.objects.promote_to_teacher(self.baseuser)
        teacher.teached_courses = [self.course]
        course2 = CourseFactory()

        with self.login(username=teacher.email,
                        password=BaseUserFactory.password):
            response = self.get('education:course-detail', course=course2.id)
            self.assertEqual(response.status_code, 403)
Esempio n. 13
0
 def setUp(self):
     self.baseuser = BaseUserFactory()
     self.baseuser.is_active = True
     self.baseuser.save()
     self.student = BaseUser.objects.promote_to_student(self.baseuser)
     self.course = CourseFactory()
     self.course_assignment = CourseAssignmentFactory(course=self.course,
                                                      user=self.student)
     self.certificate = CertificateFactory(
         assignment=self.course_assignment)
Esempio n. 14
0
    def test_teacher_can_see_student_task_only_course_if_he_teaches_it(self):
        course2 = CourseFactory()
        TaskFactory(course=course2)
        self.teacher.teached_courses = [self.course]

        with self.login(email=self.teacher.email,
                        password=BaseUserFactory.password):
            response = self.get('education:student-task-list',
                                course=course2.id,
                                student=self.student.id)
            self.assertEqual(response.status_code, 403)
Esempio n. 15
0
    def setUp(self):
        self.student = StudentFactory()
        self.course = CourseFactory()

        self.language = ProgrammingLanguageFactory(name='Python')
        self.task = TaskFactory(course=self.course)
        self.test = SourceCodeTest.objects.create(task=self.task,
                                                  language=self.language,
                                                  code='import this')
        self.solution = SolutionFactory(student=self.student,
                                        task=self.task,
                                        status=Solution.SUBMITED)
Esempio n. 16
0
    def test_student_see_only_tasks_for_his_course(self):
        task2 = TaskFactory(course=self.course)
        course2 = CourseFactory()
        task_for_course2 = TaskFactory(course=course2)

        with self.login(email=self.student.email,
                        password=BaseUserFactory.password):
            response = self.get('education:task-list', course=self.course.id)
            self.assertEqual(response.status_code, 200)
            self.assertIn(self.task, response.context['object_list'])
            self.assertIn(task2, response.context['object_list'])
            self.assertNotIn(task_for_course2, response.context['object_list'])
Esempio n. 17
0
    def test_teacher_can_see_student_task_list_only_if_he_teaches_course(self):
        course2 = CourseFactory()
        task2 = TaskFactory(course=course2)
        self.teacher.teached_courses = [self.course]

        with self.login(email=self.teacher.email,
                        password=BaseUserFactory.password):
            response = self.get('education:student-task-list',
                                course=self.course.id,
                                student=self.student.id)
            self.assertEqual(response.status_code, 200)
            self.assertIn(self.task, response.context['object_list'])
            self.assertNotIn(task2, response.context['object_list'])
Esempio n. 18
0
    def test_teacher_cannot_drop_students_from_other_courses(self):
        teacher = BaseUser.objects.promote_to_teacher(self.baseuser2)

        course = CourseFactory()
        teacher.teached_courses = [course]
        teacher.save()

        with self.login(email=teacher.email,
                        password=BaseUserFactory.password):
            response = self.post('education:drop-student',
                                 course=self.course.id,
                                 ca=self.course_assignment.id)
            self.assertEqual(response.status_code, 403)
Esempio n. 19
0
 def setUp(self):
     self.baseuser = BaseUserFactory()
     self.baseuser.is_active = True
     self.baseuser.save()
     self.baseuser2 = BaseUserFactory()
     self.baseuser2.is_active = True
     self.baseuser2.save()
     self.student = BaseUser.objects.promote_to_student(self.baseuser2)
     self.student.mac = "22:44:55:66:77"
     self.course = CourseFactory()
     self.ca = CourseAssignmentFactory(course=self.course,
                                       user=self.student)
     self.task = TaskFactory(course=self.course, gradable=True)
     self.baseuser3 = BaseUserFactory()
     self.baseuser3.is_active = True
     self.baseuser3.save()
Esempio n. 20
0
    def test_teacher_cannot_see_other_students_detail_information(self):
        teacher = BaseUser.objects.promote_to_teacher(self.baseuser)
        teacher.teached_courses = [self.course]

        other_student = BaseUser.objects.promote_to_student(self.baseuser3)
        other_student_course = CourseFactory()
        other_student_ca = CourseAssignmentFactory(course=other_student_course,
                                                   user=other_student)

        self.assertFalse(other_student_course in teacher.teached_courses.all())

        with self.login(email=teacher.email,
                        password=BaseUserFactory.password):
            response = self.get('education:student-detail',
                                course=other_student_course.id,
                                ca=other_student_ca.id)
            self.assertEqual(response.status_code, 403)
Esempio n. 21
0
    def test_teacher_can_see_student_list_only_for_his_course(self):
        teacher = BaseUser.objects.promote_to_teacher(self.baseuser)
        teacher.teached_courses = [self.course]

        baseuser3 = BaseUserFactory()
        baseuser3.is_active = True
        baseuser3.save()
        student = BaseUser.objects.promote_to_student(baseuser3)
        course2 = CourseFactory()
        course_assignment_for_baseuser3 = CourseAssignmentFactory(
            course=course2, user=student)

        with self.login(email=teacher.email,
                        password=BaseUserFactory.password):
            response = self.get('education:student-list',
                                course=self.course.id)
            self.assertEqual(response.status_code, 200)
            self.assertIn(self.course_assignment,
                          response.context['object_list'])
            self.assertNotIn(course_assignment_for_baseuser3,
                             response.context['object_list'])
Esempio n. 22
0
 def setUp(self):
     self.base_user = BaseUserFactory()
     self.course = CourseFactory()
Esempio n. 23
0
class TaskListViewTests(TestCase):
    def setUp(self):
        self.baseuser = BaseUserFactory()
        self.baseuser.is_active = True
        self.baseuser.save()
        self.baseuser2 = BaseUserFactory()
        self.baseuser2.is_active = True
        self.baseuser2.save()
        self.student = BaseUser.objects.promote_to_student(self.baseuser2)
        self.course = CourseFactory()
        self.task = TaskFactory(course=self.course)
        self.course_assignment = CourseAssignmentFactory(course=self.course,
                                                         user=self.student)

    def test_no_access_to_task_list_without_login(self):
        response = self.get('education:task-list', course=self.course.id)
        self.assertEquals(response.status_code, 302)

    def test_baseuser_cannot_access_task_list(self):
        with self.login(email=self.baseuser.email,
                        password=BaseUserFactory.password):
            response = self.get('education:task-list', course=self.course.id)
            self.assertEqual(response.status_code, 403)

    def test_teacher_cannot_access_task_list(self):
        teacher = BaseUser.objects.promote_to_teacher(self.baseuser)
        with self.login(email=teacher.email,
                        password=BaseUserFactory.password):
            response = self.get('education:task-list', course=self.course.id)
            self.assertEqual(response.status_code, 403)

    def test_student_access_task_list(self):
        with self.login(email=self.student.email,
                        password=BaseUserFactory.password):
            response = self.get('education:task-list', course=self.course.id)
            self.assertEqual(response.status_code, 200)

    def test_student_cannot_access_task_list_of_course_without_tasks(self):
        course2 = CourseFactory()
        CourseAssignmentFactory(course=course2, user=self.student)
        with self.login(email=self.student.email,
                        password=BaseUserFactory.password):
            response = self.get('education:task-list', course=course2.id)
            self.assertEqual(response.status_code, 404)

    def test_student_see_only_tasks_for_his_course(self):
        task2 = TaskFactory(course=self.course)
        course2 = CourseFactory()
        task_for_course2 = TaskFactory(course=course2)

        with self.login(email=self.student.email,
                        password=BaseUserFactory.password):
            response = self.get('education:task-list', course=self.course.id)
            self.assertEqual(response.status_code, 200)
            self.assertIn(self.task, response.context['object_list'])
            self.assertIn(task2, response.context['object_list'])
            self.assertNotIn(task_for_course2, response.context['object_list'])

    def test_cannot_submit_solutions_if_date_is_not_in_deadline(self):
        self.course.deadline_date = datetime.now().date() - timedelta(days=2)
        self.course.save()

        with self.login(email=self.student.email,
                        password=BaseUserFactory.password):
            response = self.get('education:task-list', course=self.course.id)
            self.assertEqual(response.status_code, 404)