예제 #1
0
def get_data_for_override_score(submission_uuid, student_item, rubric_dict):
    """
    Gets the data needed to render the score override section of the student data page.

    Args:
        submission_uuid (string): UUID of the student's submission
        student_item (dict): The dictionary representation of a student item.
        rubric_dict (dict): The dictionary representation of a rubric

    Returns:
        scores (dict): points_earned, pointed_possible, points_override
    """
    scores = {}
    score_data = sub_api.get_latest_score_for_submission(submission_uuid)
    if score_data:
        scores["points_earned"] = score_data.get("points_earned")
        scores["points_possible"] = score_data.get("points_possible")

    # If there is no Score, retrieve points_possible from the rubric as there may not be any assessments yet.
    if not scores.get("points_possible"):
        try:
            rubric = rubric_from_dict(rubric_dict)
        except InvalidRubric:
            points_possible = None
        else:
            points_possible = rubric.points_possible

        scores["points_possible"] = points_possible
    latest_override_score = sub_api.get_score_override(student_item)
    if latest_override_score:
        scores["points_override"] = latest_override_score["points_earned"]

    return scores
예제 #2
0
    def override_score(self):
        """
        Latest override score.
        
        Note an override score has no submission associated with it.
        """

        try:
            submission_dict = sub_api.get_submission_and_student(self.submission_uuid)
        except sub_api.SubmissionError:
            return None
        student_item = submission_dict["student_item"]
        return sub_api.get_score_override(student_item)
    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_get_override_when_no_studentItem(self):
     override_score = sub_api.get_score_override(self.STUDENT_ITEM)
     self.assertIsNone(override_score)
 def test_get_override_when_no_override(self):
     sub_api.create_submission(self.STUDENT_ITEM, 'test answer')
     override_score = sub_api.get_score_override(self.STUDENT_ITEM)
     self.assertIsNone(override_score)
 def test_get_override_when_no_studentItem(self):
     override_score = sub_api.get_score_override(self.STUDENT_ITEM)
     self.assertIsNone(override_score)
 def test_get_override_when_no_override(self):
     sub_api.create_submission(self.STUDENT_ITEM, 'test answer')
     override_score = sub_api.get_score_override(self.STUDENT_ITEM)
     self.assertIsNone(override_score)