Commit 185e8304 by Afzal Wali Committed by Muhammad Shoaib

used the api's function.

parent 07f070c4
......@@ -306,18 +306,18 @@ def stop_exam_attempt(exam_id, user_id):
exam_attempt_obj.save()
return exam_attempt_obj.id
def remove_exam_attempt_by_code(attempt_code):
def remove_exam_attempt_by_id(attempt_id):
"""
Removes an exam attempt given the attempt code.
Removes an exam attempt given the attempt id.
"""
existing_attempt = ProctoredExamStudentAttempt.get_exam_attempt_by_code(attempt_code)
existing_attempt = ProctoredExamStudentAttempt.get_exam_attempt_by_id(attempt_id)
if not existing_attempt:
err_msg = (
'Cannot remove attempt for attempt_code = {attempt_code} '
'Cannot remove attempt for attempt_id = {attempt_id} '
'because it does not exist!'
).format(attempt_code=attempt_code)
).format(attempt_id=attempt_id)
raise StudentExamAttemptDoesNotExistsException(err_msg)
......
......@@ -27,7 +27,8 @@ from edx_proctoring.api import (
get_allowances_for_course,
get_all_exams_for_course,
get_exam_attempt_by_id,
get_all_exam_attempts
get_all_exam_attempts,
remove_exam_attempt_by_id,
)
from edx_proctoring.exceptions import (
ProctoredBaseException,
......@@ -328,11 +329,8 @@ class StudentProctoredExamAttempt(AuthenticatedAPIView):
)
raise StudentExamAttemptDoesNotExistsException(err_msg)
exam_attempt_id = stop_exam_attempt(
exam_id=attempt['proctored_exam']['id'],
user_id=request.user.id
)
return Response({"exam_attempt_id": exam_attempt_id})
remove_exam_attempt_by_id(attempt_id)
return Response()
except ProctoredBaseException, ex:
return Response(
......
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