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