Commit f7ed3247 by ibrahimahmed443 Committed by Chris Dodge

fix the bug where hitting software secure callback URL second time would revert…

fix the bug where hitting software secure callback URL second time  would revert the state back to 'ready to start' from 'started'
parent 74eaaa9f
...@@ -48,7 +48,8 @@ def start_exam_callback(request, attempt_code): # pylint: disable=unused-argume ...@@ -48,7 +48,8 @@ def start_exam_callback(request, attempt_code): # pylint: disable=unused-argume
status=404 status=404
) )
mark_exam_attempt_as_ready(attempt['proctored_exam']['id'], attempt['user']['id']) if attempt['status'] == "created":
mark_exam_attempt_as_ready(attempt['proctored_exam']['id'], attempt['user']['id'])
template = loader.get_template('proctored_exam/proctoring_launch_callback.html') template = loader.get_template('proctored_exam/proctoring_launch_callback.html')
......
...@@ -515,6 +515,47 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase): ...@@ -515,6 +515,47 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
attempt = get_exam_attempt_by_id(old_attempt_id) attempt = get_exam_attempt_by_id(old_attempt_id)
self.assertIsNotNone(attempt['started_at']) self.assertIsNotNone(attempt['started_at'])
def test_start_exam_callback(self):
"""
Test that hitting software secure callback URL twice does not change the state
from 'started' back to 'ready to start'
"""
# Create an exam.
proctored_exam = ProctoredExam.objects.create(
course_id='a/b/c',
content_id='test_content',
exam_name='Test Exam',
external_id='123aXqe3',
time_limit_mins=90,
is_proctored=True
)
attempt_id = create_exam_attempt(proctored_exam.id, self.user.id)
attempt = get_exam_attempt_by_id(attempt_id)
self.assertEqual(attempt['status'], "created")
# hit callback and verify that exam status is 'ready to start'
code = attempt['attempt_code']
self.client.get(
reverse('edx_proctoring.anonymous.proctoring_launch_callback.start_exam', kwargs={'attempt_code': code})
)
attempt = get_exam_attempt_by_id(attempt_id)
self.assertEqual(attempt['status'], "ready_to_start")
# update exam status to 'started'
exam_id = attempt['proctored_exam']['id']
user_id = attempt['user']['id']
update_attempt_status(exam_id, user_id, ProctoredExamStudentAttemptStatus.started)
attempt = get_exam_attempt_by_id(attempt_id)
self.assertEqual(attempt['status'], "started")
# hit callback again and verify that status is still 'started' and not 'ready to start'
self.client.get(
reverse('edx_proctoring.anonymous.proctoring_launch_callback.start_exam', kwargs={'attempt_code': code})
)
attempt = get_exam_attempt_by_id(attempt_id)
self.assertEqual(attempt['status'], "started")
self.assertFalse(attempt['status'] == "ready_to_start")
def test_attempt_readback(self): def test_attempt_readback(self):
""" """
Confirms that an attempt can be read Confirms that an attempt can be read
......
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