Commit db17759a by Eric Fischer

Verify annotation on staff scores from submissions

Previously, there was no way for ORA to check whether a given score
was a staff score or not; we've leveraged the annotations stored with
those scores to expose and use that data.
parent 9701adb4
......@@ -302,6 +302,24 @@ class TestStaffAssessment(CacheResetTest):
self.assertEqual(tim_workflow["score"], None)
self.assertNotEqual(tim_workflow["status"], "done")
def test_update_with_override(self):
"""
Test that, when viewing a submission with a staff override present, the workflow is not updated repeatedly.
See TNL-6092 for some historical context.
"""
tim_sub, tim = TestStaffAssessment._create_student_and_submission("Tim", "Tim's answer", problem_steps=['self'])
tim_assessment = staff_api.create_assessment(
tim_sub["uuid"],
"Dumbledore",
OPTIONS_SELECTED_DICT["none"]["options"], dict(), "",
RUBRIC,
)
tim_workflow = workflow_api.get_workflow_for_submission(tim_sub["uuid"], {})
with mock.patch('openassessment.workflow.models.sub_api.reset_score') as mock_reset:
tim_workflow = workflow_api.get_workflow_for_submission(tim_sub["uuid"], {})
self.assertFalse(mock_reset.called)
def test_invalid_rubric_exception(self):
# Create a submission
tim_sub, tim = self._create_student_and_submission("Tim", "Tim's answer")
......
......@@ -82,6 +82,8 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel):
DEFAULT_ASSESSMENT_SCORE_PRIORITY
)
STAFF_ANNOTATION_TYPE = "staff_defined"
submission_uuid = models.CharField(max_length=36, db_index=True, unique=True)
uuid = UUIDField(version=1, db_index=True, unique=True)
......@@ -315,9 +317,12 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel):
# new_staff_score is just the most recent staff score, it may already be recorded in sub_api
old_score = sub_api.get_latest_score_for_submission(self.submission_uuid)
if (
not old_score or # There is no recorded score
not old_score.get('staff_id') or # The recorded score is not a staff score
old_score['points_earned'] != new_staff_score['points_earned'] # Previous staff score doesn't match
# Does a prior score exist? Is it a staff score? Do the points earned match?
not old_score or
not self.STAFF_ANNOTATION_TYPE in [
annotation['annotation_type'] for annotation in old_score['annotations']
] or
old_score['points_earned'] != new_staff_score['points_earned']
):
# Set the staff score using submissions api, and log that fact
self.set_staff_score(new_staff_score)
......@@ -426,7 +431,6 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel):
will be used in the event that this parameter is not provided.
"""
annotation_type = "staff_defined"
if reason is None:
reason = "A staff member has defined the score for this submission"
sub_dict = sub_api.get_submission_and_student(self.submission_uuid)
......@@ -440,7 +444,7 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel):
score["points_earned"],
score["points_possible"],
annotation_creator=score["staff_id"],
annotation_type=annotation_type,
annotation_type=self.STAFF_ANNOTATION_TYPE,
annotation_reason=reason
)
......
......@@ -6,7 +6,7 @@
git+https://github.com/edx/XBlock.git@xblock-0.4.12#egg=XBlock==0.4.12
# edx-submissions
git+https://github.com/edx/edx-submissions.git@1.1.2#egg=edx-submissions==1.1.2
git+https://github.com/edx/edx-submissions.git@1.1.3#egg=edx-submissions==1.1.3
# Third Party Requirements
boto>=2.32.1,<3.0.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment