Commit 2df28d2a by Eric Fischer

Clear state option

To fix the buggy behavior reported in TNL-3880, we need to ensure
that the submission we're dropping is unlinked from the student_item
used to find it. This prevents code (say, an ORA staff tool) from
constructing a student item with an id, a course, and a problem, and
using that to find a "cleared" submission.
parent 02ccd59d
...@@ -643,7 +643,7 @@ def get_latest_score_for_submission(submission_uuid, read_replica=False): ...@@ -643,7 +643,7 @@ def get_latest_score_for_submission(submission_uuid, read_replica=False):
return ScoreSerializer(score).data return ScoreSerializer(score).data
def reset_score(student_id, course_id, item_id): def reset_score(student_id, course_id, item_id, clear_state=False):
""" """
Reset scores for a specific student on a specific problem. Reset scores for a specific student on a specific problem.
...@@ -655,6 +655,7 @@ def reset_score(student_id, course_id, item_id): ...@@ -655,6 +655,7 @@ def reset_score(student_id, course_id, item_id):
student_id (unicode): The ID of the student for whom to reset scores. student_id (unicode): The ID of the student for whom to reset scores.
course_id (unicode): The ID of the course containing the item to reset. course_id (unicode): The ID of the course containing the item to reset.
item_id (unicode): The ID of the item for which to reset scores. item_id (unicode): The ID of the item for which to reset scores.
clear_state (boolean): If True, unlink the Submission and StudentItem so the Submission cannot be accessed.
Returns: Returns:
None None
...@@ -684,6 +685,11 @@ def reset_score(student_id, course_id, item_id): ...@@ -684,6 +685,11 @@ def reset_score(student_id, course_id, item_id):
item_id=item_id, item_id=item_id,
) )
if clear_state:
# sever the link between this student item and any submissions it may current have
for sub in student_item.submission_set.all():
sub.student_item = None
except DatabaseError: except DatabaseError:
msg = ( msg = (
u"Error occurred while reseting scores for" u"Error occurred while reseting scores for"
......
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