Commit 5825f78b by chrisndodge

Merge pull request #242 from edx/ibrahimahmed443/PHX-223-multiple-callback-bug

fix the bug where hitting software secure callback URL second time  w…
parents e06b956f f7ed3247
......@@ -48,7 +48,8 @@ def start_exam_callback(request, attempt_code): # pylint: disable=unused-argume
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')
......
......@@ -515,6 +515,47 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
attempt = get_exam_attempt_by_id(old_attempt_id)
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):
"""
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