def test_admin_or_staff_or_handgrader_valid_get(self):
        [admin] = obj_build.make_admin_users(self.course, 1)
        [staff] = obj_build.make_staff_users(self.course, 1)
        [handgrader] = obj_build.make_handgrader_users(self.course, 1)

        for user in admin, staff, handgrader:
            self.do_get_object_test(self.client, user, self.url,
                                    self.applied_annotation.to_dict())
    def test_non_admin_list_project_download_tasks_permission_denied(self):
        [staff] = obj_build.make_staff_users(self.project.course, 1)
        [handgrader] = obj_build.make_handgrader_users(self.project.course, 1)

        url = reverse('project-download-tasks', kwargs={'pk': self.project.pk})
        for user in staff, handgrader:
            self.client.force_authenticate(user)
            response = self.client.get(url)
            self.assertEqual(status.HTTP_403_FORBIDDEN, response.status_code)
    def test_non_staff_get_order_permission_denied(self):
        [enrolled] = obj_build.make_student_users(self.course, 1)
        [handgrader] = obj_build.make_handgrader_users(self.course, 1)

        for user in enrolled, handgrader:
            self.client.force_authenticate(user)

            response = self.client.get(self.url)
            self.assertEqual(status.HTTP_403_FORBIDDEN, response.status_code)
    def setUp(self):
        super().setUp()
        self.course = obj_build.make_course()
        self.client = APIClient()
        self.url = reverse('course-staff', kwargs={'pk': self.course.pk})

        [self.admin] = obj_build.make_admin_users(self.course, 1)
        [self.student] = obj_build.make_student_users(self.course, 1)
        [self.guest] = obj_build.make_users(1)
        [self.handgrader] = obj_build.make_handgrader_users(self.course, 1)
Ejemplo n.º 5
0
    def test_admin_or_staff_or_handgrader_valid_list_comments(self):
        [admin] = obj_build.make_admin_users(self.course, 1)
        [staff] = obj_build.make_staff_users(self.course, 1)
        [handgrader] = obj_build.make_handgrader_users(self.course, 1)

        for user in admin, handgrader, staff:
            self.client.force_authenticate(user)

            response = self.client.get(self.url)
            self.assertEqual(status.HTTP_200_OK, response.status_code)
            self.assertSequenceEqual(self.comment.to_dict(), response.data[0])
Ejemplo n.º 6
0
 def test_handgrader_valid_create_with_location(self):
     self.handgrading_rubric.validate_and_update(
         handgraders_can_leave_comments=True)
     [handgrader] = obj_build.make_handgrader_users(self.course, 1)
     response = self.do_create_object_test(
         handgrading_models.Comment.objects,
         self.client,
         handgrader,
         self.url,
         self.data,
         check_data=False)
     self._check_valid_comment_with_location_created(response)
    def test_admin_or_staff_or_handgrader_update_bad_values(self):
        bad_data = {
            "location": "Not an editable field!",
        }
        [admin] = obj_build.make_admin_users(self.course, 1)
        [handgrader] = obj_build.make_handgrader_users(self.course, 1)
        [staff] = obj_build.make_staff_users(self.course, 1)

        for user in admin, staff, handgrader:
            self.do_patch_object_invalid_args_test(self.applied_annotation,
                                                   self.client, user, self.url,
                                                   bad_data)
    def test_non_admin_set_order_permission_denied(self):
        [staff] = obj_build.make_staff_users(self.course, 1)
        [enrolled] = obj_build.make_student_users(self.course, 1)
        [handgrader] = obj_build.make_handgrader_users(self.course, 1)

        for user in staff, enrolled, handgrader:
            self.client.force_authenticate(user)

            original_order = list(self.handgrading_rubric.get_criterion_order())
            response = self.client.put(self.url, original_order[::-1])

            self.assertEqual(status.HTTP_403_FORBIDDEN, response.status_code)
            self.assertSequenceEqual(original_order, self.handgrading_rubric.get_criterion_order())
    def setUp(self):
        super().setUp()
        self.maxDiff = None

        self.client = APIClient()
        self.course = obj_build.make_course()
        self.project = obj_build.make_project(course=self.course)
        self.assertEqual(ag_models.UltimateSubmissionPolicy.most_recent,
                         self.project.ultimate_submission_policy)

        self.rubric = hg_models.HandgradingRubric.objects.validate_and_create(
            project=self.project,
            points_style=hg_models.PointsStyle.start_at_max_and_subtract,
            max_points=43)

        [self.staff] = obj_build.make_staff_users(self.course, 1)
        [self.handgrader] = obj_build.make_handgrader_users(self.course, 1)
Ejemplo n.º 10
0
    def setUp(self):
        super().setUp()
        self.handgrading_rubric = handgrading_models.HandgradingRubric.objects.validate_and_create(
            points_style=handgrading_models.PointsStyle.
            start_at_max_and_subtract,
            max_points=0,
            show_grades_and_rubric_to_students=False,
            handgraders_can_leave_comments=False,
            handgraders_can_adjust_points=True,
            project=obj_build.build_project())

        submission = obj_build.make_submission(
            submitted_filenames=["test.cpp"])

        self.handgrading_result = handgrading_models.HandgradingResult.objects.validate_and_create(
            submission=submission,
            group=submission.group,
            handgrading_rubric=self.handgrading_rubric)

        comment_data = {
            "location": {
                "first_line": 0,
                "last_line": 1,
                "filename": "test.cpp"
            },
            "text": "Sample comment text.",
            "handgrading_result": self.handgrading_result
        }

        self.comment = handgrading_models.Comment.objects.validate_and_create(
            **comment_data)
        self.comment2 = handgrading_models.Comment.objects.validate_and_create(
            **comment_data)
        self.course = self.handgrading_rubric.project.course
        self.client = APIClient()
        self.url = reverse('comment-detail', kwargs={'pk': self.comment.pk})

        [self.admin] = obj_build.make_admin_users(self.course, 1)
        [self.staff] = obj_build.make_staff_users(self.course, 1)
        [self.handgrader] = obj_build.make_handgrader_users(self.course, 1)
        [self.student] = obj_build.make_student_users(self.course, 1)
Ejemplo n.º 11
0
    def setUp(self):
        super().setUp()
        handgrading_rubric = handgrading_models.HandgradingRubric.objects.validate_and_create(
            points_style=handgrading_models.PointsStyle.
            start_at_max_and_subtract,
            max_points=0,
            show_grades_and_rubric_to_students=False,
            handgraders_can_leave_comments=True,
            handgraders_can_adjust_points=True,
            project=obj_build.build_project())

        criterion = handgrading_models.Criterion.objects.validate_and_create(
            points=0, handgrading_rubric=handgrading_rubric)

        submission = obj_build.make_submission(
            submitted_filenames=["test.cpp"])

        self.handgrading_result = handgrading_models.HandgradingResult.objects.validate_and_create(
            submission=submission,
            group=submission.group,
            handgrading_rubric=handgrading_rubric)

        criterion_result_data = {
            "selected": True,
            "criterion": criterion,
            "handgrading_result": self.handgrading_result
        }

        self.criterion_result = handgrading_models.CriterionResult.objects.validate_and_create(
            **criterion_result_data)

        self.course = handgrading_rubric.project.course
        self.client = APIClient()
        self.url = reverse('criterion-result-detail',
                           kwargs={'pk': self.criterion_result.pk})

        [self.admin] = obj_build.make_admin_users(self.course, 1)
        [self.handgrader] = obj_build.make_handgrader_users(self.course, 1)
        [self.staff] = obj_build.make_staff_users(self.course, 1)
        [self.enrolled] = obj_build.make_student_users(self.course, 1)
Ejemplo n.º 12
0
 def test_handgrader_comments_not_allowed_permission_denied(self):
     [handgrader] = obj_build.make_handgrader_users(self.course, 1)
     self.do_permission_denied_create_test(
         handgrading_models.Comment.objects, self.client, handgrader,
         self.url, self.data)
 def test_handgrader_valid_delete(self):
     [handgrader] = obj_build.make_handgrader_users(self.course, 1)
     self.do_delete_object_test(self.applied_annotation, self.client,
                                handgrader, self.url)