Example #1
0
def score_override(student_item_dict, points_override, points_possible):
    """
    Given a student's ID, override the regular score with a score provided by the instructor.

    Args:
        student_item_dict (dict): The dictionary representation of a student item.
        points_override (string): The override points given by the instructor
        points_possible (string): The max allowed points for this submission.
        
    Returns:
        dict of:
            'success': (boolean)
            'msg': (string) if success is False
            'points_override': (string) if success is True
    """
    if student_item_dict.get("student_id"):
        return_status = _validate_override_data(points_override, points_possible)
        if not return_status["success"]:
            return {"success": False, "msg": return_status["msg"]}

        try:
            sub_api.score_override(student_item_dict, points_override, points_possible)
            # Override score was created successfully
            return {"success": True, "points_override": points_override}

        except sub_api.SubmissionInternalError:
            return {"success": False, "msg": "There was a problem creating the override score."}
    # student_id wasn't passed
    else:
        return {"success": False, "msg": "An error was encountered. Please try again."}
 def test_database_error(self, create_mock):
     # Simulate a database error when creating the override score
     create_mock.side_effect = DatabaseError('Test error')
     with self.assertRaises(sub_api.SubmissionInternalError):
         sub_api.score_override(
             self.STUDENT_ITEM,
             7,
             10,
         )
 def test_database_error(self, create_mock):
     # Simulate a database error when creating the override score
     create_mock.side_effect = DatabaseError('Test error')
     with self.assertRaises(sub_api.SubmissionInternalError):
         sub_api.score_override(
             self.STUDENT_ITEM,
             7,
             10,
         )
    def test_override_with_no_score(self):

        sub_api.score_override(
            self.STUDENT_ITEM,
            8,
            10,
        )

        self.assertEqual(sub_api.get_score(self.STUDENT_ITEM)['points_earned'], 8)
        self.assertEqual(sub_api.get_score(self.STUDENT_ITEM)['points_possible'], 10)
    def test_override_with_no_score(self):

        sub_api.score_override(
            self.STUDENT_ITEM,
            8,
            10,
        )

        self.assertEqual(
            sub_api.get_score(self.STUDENT_ITEM)['points_earned'], 8)
        self.assertEqual(
            sub_api.get_score(self.STUDENT_ITEM)['points_possible'], 10)
    def test_override_with_one_score(self):
        # Create a submission for the student and score it
        submission = sub_api.create_submission(self.STUDENT_ITEM, 'test answer')
        sub_api.set_score(submission['uuid'], 1, 10)

        sub_api.score_override(
            self.STUDENT_ITEM,
            5,
            10,
        )

        self.assertEqual(sub_api.get_score(self.STUDENT_ITEM)['points_earned'], 5)
        self.assertEqual(sub_api.get_score(self.STUDENT_ITEM)['points_possible'], 10)
Example #7
0
    def test_grade_score_override(self, xblock):
        # Graded peers, but haven't completed self assessment
        self._create_submission_and_assessments(
            xblock, self.SUBMISSION, [self.PEERS[0]], [self.ASSESSMENTS[0]], None
        )

        # Create an override score for the submission
        submission_dict = sub_api.get_submission_and_student(xblock.submission_uuid)
        student_item = submission_dict['student_item']
        sub_api.score_override(student_item, '14', '15')

        # Verify that we're on the grade override template
        resp = self.request(xblock, 'render_grade', json.dumps(dict()))
        self.assertIn(u'<span class="grade__value__earned">14</span> out of <span class="grade__value__potential">15</span>, set by the instructor.', resp.decode('utf-8').lower())
    def test_override_with_one_score(self):
        # Create a submission for the student and score it
        submission = sub_api.create_submission(self.STUDENT_ITEM,
                                               'test answer')
        sub_api.set_score(submission['uuid'], 1, 10)

        sub_api.score_override(
            self.STUDENT_ITEM,
            5,
            10,
        )

        self.assertEqual(
            sub_api.get_score(self.STUDENT_ITEM)['points_earned'], 5)
        self.assertEqual(
            sub_api.get_score(self.STUDENT_ITEM)['points_possible'], 10)
    def test_override_doesnt_overwrite_submission_score(self):
        # Create a submission for the student and score it
        submission = sub_api.create_submission(self.STUDENT_ITEM, 'test answer')
        sub_api.set_score(submission['uuid'], 1, 10)

        sub_api.score_override(
            self.STUDENT_ITEM,
            8,
            10,
        )

        submission_score = sub_api.get_latest_score_for_submission(submission['uuid'])
        self.assertEqual(submission_score['points_earned'], 1)
        self.assertEqual(submission_score['points_possible'], 10)

        override_score = sub_api.get_score_override(self.STUDENT_ITEM)
        self.assertEqual(override_score['points_earned'], 8)
        self.assertEqual(override_score['points_possible'], 10)
    def test_override_doesnt_overwrite_submission_score(self):
        # Create a submission for the student and score it
        submission = sub_api.create_submission(self.STUDENT_ITEM,
                                               'test answer')
        sub_api.set_score(submission['uuid'], 1, 10)

        sub_api.score_override(
            self.STUDENT_ITEM,
            8,
            10,
        )

        submission_score = sub_api.get_latest_score_for_submission(
            submission['uuid'])
        self.assertEqual(submission_score['points_earned'], 1)
        self.assertEqual(submission_score['points_possible'], 10)

        override_score = sub_api.get_score_override(self.STUDENT_ITEM)
        self.assertEqual(override_score['points_earned'], 8)
        self.assertEqual(override_score['points_possible'], 10)
    def test_override_after_reset_score(self):
        # Create a submission for the student and score it
        submission = sub_api.create_submission(self.STUDENT_ITEM, 'test answer')
        sub_api.set_score(submission['uuid'], 1, 10)

        # Reset score
        sub_api.reset_score(
            self.STUDENT_ITEM['student_id'],
            self.STUDENT_ITEM['course_id'],
            self.STUDENT_ITEM['item_id'],
        )

        sub_api.score_override(
            self.STUDENT_ITEM,
            5,
            10,
        )

        self.assertEqual(sub_api.get_score(self.STUDENT_ITEM)['points_earned'], 5)
        self.assertEqual(sub_api.get_score(self.STUDENT_ITEM)['points_possible'], 10)
    def test_override_after_reset_score(self):
        # Create a submission for the student and score it
        submission = sub_api.create_submission(self.STUDENT_ITEM,
                                               'test answer')
        sub_api.set_score(submission['uuid'], 1, 10)

        # Reset score
        sub_api.reset_score(
            self.STUDENT_ITEM['student_id'],
            self.STUDENT_ITEM['course_id'],
            self.STUDENT_ITEM['item_id'],
        )

        sub_api.score_override(
            self.STUDENT_ITEM,
            5,
            10,
        )

        self.assertEqual(
            sub_api.get_score(self.STUDENT_ITEM)['points_earned'], 5)
        self.assertEqual(
            sub_api.get_score(self.STUDENT_ITEM)['points_possible'], 10)