From 7440723ac0941e8f8472d7d9ab1647afa56bd09e Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 28 Jan 2016 16:21:02 -0500 Subject: [PATCH] Delete Student State ORA fix (Proof-of-concept) Not at all the final version of this, but I have tested this locally, and it deletes what we need to delete and seems to solve all the problems described in TNL-3880. --- submissions/api.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/submissions/api.py b/submissions/api.py index 9105d58d..ab84fe56 100644 --- a/submissions/api.py +++ b/submissions/api.py @@ -643,6 +643,37 @@ def get_latest_score_for_submission(submission_uuid, read_replica=False): return ScoreSerializer(score).data +def delete_student_item(student_id, course_id, item_id): + """ + EFischer - dev testing this on my devstack, will document more fully after trying proof-of-concept + """ + # Retrieve the student item + try: + student_item = StudentItem.objects.get( + student_id=student_id, course_id=course_id, item_id=item_id + ) + student_item.delete() + except StudentItem.DoesNotExist: + msg = ( + u"No record found when deleting student item {item_id}" + u"in course {course_id} for student {student_id}." + ).format(item_id=item_id, course_id=course_id, student_id=student_id) + logger.exception(msg) + raise SubmissionInternalError(msg) + except DatabaseError: + msg = ( + u"Error occurred while reseting scores for" + u" item {item_id} in course {course_id} for student {student_id}" + ).format(item_id=item_id, course_id=course_id, student_id=student_id) + logger.exception(msg) + raise SubmissionInternalError(msg) + else: + msg = u"Successfully deleted item {item_id} in course {course_id} for student {student_id}".format( + item_id=item_id, course_id=course_id, student_id=student_id + ) + logger.info(msg) + + def reset_score(student_id, course_id, item_id): """ Reset scores for a specific student on a specific problem.