def post(self, request, ora_location, submission_uuid, *args, **kwargs): """Update a grade""" try: # Reassert that we have ownership of the submission lock lock_info = check_submission_lock(request, ora_location, submission_uuid) if not lock_info.get("lock_status") == "in-progress": assessment_info = get_assessment_info(request, ora_location, submission_uuid) submission_status = SubmissionStatusFetchSerializer({ "assessment_info": assessment_info, "lock_info": lock_info, }).data log.error(f"Grade contested for submission: {submission_uuid}") return GradeContestedResponse(context=submission_status) # Transform grade data and submit assessment, rasies on failure context = {"submission_uuid": submission_uuid} grade_data = StaffAssessSerializer(request.data, context=context).data submit_grade(request, ora_location, grade_data) # Clear the lock on the graded submission delete_submission_lock(request, ora_location, submission_uuid) # Return submission status info to frontend assessment_info = get_assessment_info(request, ora_location, submission_uuid) lock_info = check_submission_lock(request, ora_location, submission_uuid) response_data = SubmissionStatusFetchSerializer({ "assessment_info": assessment_info, "lock_info": lock_info, }).data log.info(response_data) return Response(response_data) # Issues with the XBlock handlers except XBlockInternalError as ex: log.error(ex) return InternalErrorResponse(context=ex.context) # Blanket exception handling in case something blows up except Exception as ex: log.exception(ex) return UnknownErrorResponse()
def delete(self, request, ora_location, submission_uuid, *args, **kwargs): """Clear a submission lock""" try: # Validate ORA location UsageKey.from_string(ora_location) lock_info = delete_submission_lock(request, ora_location, submission_uuid) response_data = LockStatusSerializer(lock_info).data log.info(response_data) return Response(response_data) # Catch bad ORA location except (InvalidKeyError, ItemNotFoundError): log.error(f"Bad ORA location provided: {ora_location}") return BadOraLocationResponse() # Return updated lock info on error except LockContestedError: lock_info = check_submission_lock(request, ora_location, submission_uuid) lock_status = LockStatusSerializer(lock_info).data return LockContestedResponse(context=lock_status) # Issues with the XBlock handlers except XBlockInternalError as ex: log.error(ex) return InternalErrorResponse(context=ex.context) # Blanket exception handling in case something blows up except Exception as ex: log.exception(ex) return UnknownErrorResponse()
def get(self, request, ora_location, submission_uuid, *args, **kwargs): try: assessment_info = get_assessment_info( request, ora_location, submission_uuid ) lock_info = check_submission_lock(request, ora_location, submission_uuid) response_data = SubmissionStatusFetchSerializer( { "assessment_info": assessment_info, "lock_info": lock_info, } ).data log.info(response_data) return Response(response_data) # Issues with the XBlock handlers except XBlockInternalError as ex: log.error(ex) return InternalErrorResponse(context=ex.context) # Blanket exception handling in case something blows up except Exception as ex: log.exception(ex) return UnknownErrorResponse()