Commit dcbc5b69 by Eric Fischer Committed by Andy Armstrong

Staff assessments and workflow status

Staff assessments can now mark workflow as being done, with proper handling
for blocking workflows (such as peer), to hide a score if the submitter
has not yet fulfilled their obligations. Includes tests.

Also contains a tiny bugfix for a previously unexecuted codepath.
parent 28460037
......@@ -573,7 +573,7 @@ class Assessment(models.Model):
"""
assessments = list(assessments) # Force us to read it all
if not assessments:
return []
return {}
# Generate a cache key that represents all the assessments we're being
# asked to grab scores from (comma separated list of assessment IDs)
......
......@@ -193,10 +193,13 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel):
def score(self):
"""Latest score for the submission we're tracking.
Note that while it is usually the case that we're setting the score,
that may not always be the case. We may have some course staff override.
Returns:
score (dict): The latest score for this workflow, or None if the workflow is incomplete.
"""
return sub_api.get_latest_score_for_submission(self.submission_uuid)
score = None
if self.status == self.STATUS.done:
score = sub_api.get_latest_score_for_submission(self.submission_uuid)
return score
def status_details(self, assessment_requirements):
status_dict = {}
......@@ -309,17 +312,25 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel):
new_staff_score = self.get_score(assessment_requirements, {'staff': step_for_name.get('staff', None)})
if new_staff_score:
old_score = self.score
if not old_score or old_score['points_earned'] != new_staff_score['points_earned']:
# 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
):
# Set the staff score using submissions api, and log that fact
self.set_staff_score(new_staff_score)
self.save()
logger.info((
u"Workflow for submission UUID {uuid} has updated score using staff assessment."
).format(uuid=self.submission_uuid))
staff_step = step_for_name.get('staff')
staff_step.assessment_completed_at=now()
staff_step.save()
self.status = self.STATUS.done
# Update the assessment_completed_at field for all steps
# All steps are considered "assessment complete", as the staff score will override all
for step in steps:
step.assessment_completed_at=now()
step.save()
if self.status == self.STATUS.done:
return
......@@ -350,7 +361,9 @@ class AssessmentWorkflow(TimeStampedModel, StatusModel):
score = self.get_score(assessment_requirements, step_for_name)
# If we found a score, then we're done
if score is not None:
self.set_score(score)
# Only set the score if it's not a staff score, in which case it will have already been set above
if score.get("staff_id") is None:
self.set_score(score)
new_status = self.STATUS.done
# Finally save our changes if the status has changed
......
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