Exemplo n.º 1
0
    def test_access(self):
        """
        Make sure only staff have access.
        """
        self.login(self.student, self.password)

        # both get and post should return 404
        for view_name in ("staff_grading_get_next", "staff_grading_save_grade"):
            url = reverse(view_name, kwargs={"course_id": self.course_id.to_deprecated_string()})
            check_for_get_code(self, 404, url)
            check_for_post_code(self, 404, url)
Exemplo n.º 2
0
    def test_access(self):
        """
        Make sure only staff have access.
        """
        self.login(self.student, self.password)

        # both get and post should return 404
        for view_name in ('staff_grading_get_next', 'staff_grading_save_grade'):
            url = reverse(view_name, kwargs={'course_id': self.course_id})
            check_for_get_code(self, 404, url)
            check_for_post_code(self, 404, url)
Exemplo n.º 3
0
    def test_save_grade_with_long_feedback(self):
        """
        Test if feedback is too long save_grade() should return error message.
        """
        self.login(self.instructor, self.password)

        url = reverse('staff_grading_save_grade', kwargs={'course_id': self.course_id})

        data = {
            'score': '12',
            'feedback': '',
            'submission_id': '123',
            'location': self.location,
            'submission_flagged': "false",
            'rubric_scores[]': ['1', '2']
        }

        feedback_fragment = "This is very long feedback."
        data["feedback"] = feedback_fragment * (
            (staff_grading_service.MAX_ALLOWED_FEEDBACK_LENGTH / len(feedback_fragment) + 1)
        )

        response = check_for_post_code(self, 200, url, data)
        content = json.loads(response.content)

        # Should not succeed.
        self.assertEquals(content['success'], False)
        self.assertEquals(
            content['error'],
            "Feedback is too long, Max length is {0} characters.".format(
                staff_grading_service.MAX_ALLOWED_FEEDBACK_LENGTH
            )
        )
Exemplo n.º 4
0
    def test_save_grade_with_long_feedback(self):
        """
        Test if feedback is too long save_grade() should return error message.
        """
        self.login(self.instructor, self.password)

        url = reverse('staff_grading_save_grade', kwargs={'course_id': self.course_id.to_deprecated_string()})

        data = {
            'score': '12',
            'feedback': '',
            'submission_id': '123',
            'location': self.location_string,
            'submission_flagged': "false",
            'rubric_scores[]': ['1', '2']
        }

        feedback_fragment = "This is very long feedback."
        data["feedback"] = feedback_fragment * (
            (staff_grading_service.MAX_ALLOWED_FEEDBACK_LENGTH / len(feedback_fragment) + 1)
        )

        response = check_for_post_code(self, 200, url, data)
        content = json.loads(response.content)

        # Should not succeed.
        self.assertEquals(content['success'], False)
        self.assertEquals(
            content['error'],
            "Feedback is too long, Max length is {0} characters.".format(
                staff_grading_service.MAX_ALLOWED_FEEDBACK_LENGTH
            )
        )
Exemplo n.º 5
0
    def test_save_grade_with_long_feedback(self):
        """
        Test if feedback is too long save_grade() should return error message.
        """
        self.login(self.instructor, self.password)

        url = reverse("staff_grading_save_grade", kwargs={"course_id": self.course_id.to_deprecated_string()})

        data = {
            "score": "12",
            "feedback": "",
            "submission_id": "123",
            "location": self.location_string,
            "submission_flagged": "false",
            "rubric_scores[]": ["1", "2"],
        }

        feedback_fragment = "This is very long feedback."
        data["feedback"] = feedback_fragment * (
            (staff_grading_service.MAX_ALLOWED_FEEDBACK_LENGTH / len(feedback_fragment) + 1)
        )

        response = check_for_post_code(self, 200, url, data)
        content = json.loads(response.content)

        # Should not succeed.
        self.assertEquals(content["success"], False)
        self.assertEquals(
            content["error"],
            "Feedback is too long, Max length is {0} characters.".format(
                staff_grading_service.MAX_ALLOWED_FEEDBACK_LENGTH
            ),
        )
Exemplo n.º 6
0
    def test_get_problem_list(self):
        self.login(self.instructor, self.password)

        url = reverse('staff_grading_get_problem_list', kwargs={'course_id': self.course_id})
        data = {}

        response = check_for_post_code(self, 200, url, data)
        content = json.loads(response.content)

        self.assertTrue(content['success'])
        self.assertEqual(content['problem_list'], [])
Exemplo n.º 7
0
    def test_get_problem_list(self):
        self.login(self.instructor, self.password)

        url = reverse("staff_grading_get_problem_list", kwargs={"course_id": self.course_id})
        data = {}

        response = check_for_post_code(self, 200, url, data)
        content = json.loads(response.content)

        self.assertTrue(content["success"], str(content))
        self.assertIsNotNone(content["problem_list"])
 def _do_register_attempt(self, **extra_fields_values):
     """
     Helper method to make the call to the do registration
     """
     username = '******' + uuid.uuid4().hex
     fields_values = {
         'username': username,
         'email': 'foo' + uuid.uuid4().hex + '@bar.com',
         'password': '******',
         'name': username,
         'terms_of_service': 'true',
     }
     fields_values = dict(fields_values.items() + extra_fields_values.items())
     resp = check_for_post_code(self, 200, reverse('create_account'), fields_values)
     data = json.loads(resp.content)
     return data
Exemplo n.º 9
0
    def save_grade_base(self, skip=False):
        self.login(self.instructor, self.password)

        url = reverse('staff_grading_save_grade', kwargs={'course_id': self.course_id})

        data = {'score': '12',
                'feedback': 'great!',
                'submission_id': '123',
                'location': self.location,
                'submission_flagged': "true",
                'rubric_scores[]': ['1', '2']}
        if skip:
            data.update({'skipped': True})

        response = check_for_post_code(self, 200, url, data)
        content = json.loads(response.content)
        self.assertTrue(content['success'], str(content))
        self.assertEquals(content['submission_id'], self.mock_service.cnt)
Exemplo n.º 10
0
    def test_get_next(self):
        self.login(self.instructor, self.password)

        url = reverse('staff_grading_get_next', kwargs={'course_id': self.course_id})
        data = {'location': self.location}

        response = check_for_post_code(self, 200, url, data)

        content = json.loads(response.content)

        self.assertTrue(content['success'])
        self.assertEquals(content['submission_id'], self.mock_service.cnt)
        self.assertIsNotNone(content['submission'])
        self.assertIsNotNone(content['num_graded'])
        self.assertIsNotNone(content['min_for_ml'])
        self.assertIsNotNone(content['num_pending'])
        self.assertIsNotNone(content['prompt'])
        self.assertIsNotNone(content['ml_error_info'])
        self.assertIsNotNone(content['max_score'])
        self.assertIsNotNone(content['rubric'])
Exemplo n.º 11
0
    def test_get_next(self):
        self.login(self.instructor, self.password)

        url = reverse("staff_grading_get_next", kwargs={"course_id": self.course_id})
        data = {"location": self.location}

        response = check_for_post_code(self, 200, url, data)

        content = json.loads(response.content)

        self.assertTrue(content["success"])
        self.assertEquals(content["submission_id"], self.mock_service.cnt)
        self.assertIsNotNone(content["submission"])
        self.assertIsNotNone(content["num_graded"])
        self.assertIsNotNone(content["min_for_ml"])
        self.assertIsNotNone(content["num_pending"])
        self.assertIsNotNone(content["prompt"])
        self.assertIsNotNone(content["ml_error_info"])
        self.assertIsNotNone(content["max_score"])
        self.assertIsNotNone(content["rubric"])
Exemplo n.º 12
0
    def save_grade_base(self, skip=False):
        self.login(self.instructor, self.password)

        url = reverse("staff_grading_save_grade", kwargs={"course_id": self.course_id})

        data = {
            "score": "12",
            "feedback": "great!",
            "submission_id": "123",
            "location": self.location,
            "submission_flagged": "true",
            "rubric_scores[]": ["1", "2"],
        }
        if skip:
            data.update({"skipped": True})

        response = check_for_post_code(self, 200, url, data)
        content = json.loads(response.content)
        self.assertTrue(content["success"], str(content))
        self.assertEquals(content["submission_id"], self.mock_service.cnt)