Commit 85bd3040 by Diana Huang

Switch to using status instead of time.

parent 1d4d81c2
...@@ -23,7 +23,6 @@ from edx_proctoring.api import ( ...@@ -23,7 +23,6 @@ from edx_proctoring.api import (
from edx_proctoring.backends import get_backend_provider from edx_proctoring.backends import get_backend_provider
from edx_proctoring.exceptions import ProctoredBaseException from edx_proctoring.exceptions import ProctoredBaseException
from edx_proctoring.models import ProctoredExamStudentAttemptStatus from edx_proctoring.models import ProctoredExamStudentAttemptStatus
from edx_proctoring.utils import get_time_remaining_for_attempt
from edx_proctoring import constants from edx_proctoring import constants
...@@ -157,9 +156,8 @@ class AttemptStatus(APIView): ...@@ -157,9 +156,8 @@ class AttemptStatus(APIView):
) )
update_exam_attempt(attempt['id'], last_poll_timestamp=timestamp, last_poll_ipaddr=ip_address) update_exam_attempt(attempt['id'], last_poll_timestamp=timestamp, last_poll_ipaddr=ip_address)
time_remaining_seconds = get_time_remaining_for_attempt(attempt)
polling_interval = constants.DEFAULT_CLIENT_POLLING_INTERVAL polling_interval = constants.DEFAULT_CLIENT_POLLING_INTERVAL
if time_remaining_seconds < constants.EXAM_CONCLUDING_INTERVAL: if ProctoredExamStudentAttemptStatus.is_completed_status(attempt['status']):
polling_interval = constants.REDUCED_CLIENT_POLLING_INTERVAL polling_interval = constants.REDUCED_CLIENT_POLLING_INTERVAL
return Response( return Response(
......
...@@ -64,13 +64,7 @@ DEFAULT_CLIENT_POLLING_INTERVAL = ( ...@@ -64,13 +64,7 @@ DEFAULT_CLIENT_POLLING_INTERVAL = (
REDUCED_CLIENT_POLLING_INTERVAL = ( REDUCED_CLIENT_POLLING_INTERVAL = (
settings.PROCTORING_SETTINGS['REDUCED_CLIENT_POLLING_INTERVAL'] if settings.PROCTORING_SETTINGS['REDUCED_CLIENT_POLLING_INTERVAL'] if
'REDUCED_CLIENT_POLLING_INTERVAL' in settings.PROCTORING_SETTINGS 'REDUCED_CLIENT_POLLING_INTERVAL' in settings.PROCTORING_SETTINGS
else getattr(settings, 'REDUCED_CLIENT_POLLING_INTERVAL', 10) else getattr(settings, 'REDUCED_CLIENT_POLLING_INTERVAL', 15)
)
EXAM_CONCLUDING_INTERVAL = (
settings.PROCTORING_SETTINGS['EXAM_CONCLUDING_INTERVAL'] if
'EXAM_CONCLUDING_INTERVAL' in settings.PROCTORING_SETTINGS
else getattr(settings, 'EXAM_CONCLUDING_INTERVAL', 180)
) )
......
...@@ -837,8 +837,7 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase): ...@@ -837,8 +837,7 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
) )
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
@patch('edx_proctoring.callbacks.get_time_remaining_for_attempt') def test_attempt_status_poll_interval(self):
def test_attempt_status_poll_interval(self, time_remaining_mock):
""" """
Test that the poll interval is correct depending on the amount of time remaining. Test that the poll interval is correct depending on the amount of time remaining.
""" """
...@@ -850,12 +849,14 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase): ...@@ -850,12 +849,14 @@ class TestStudentProctoredExamAttempt(LoggedInTestCase):
) )
# When the exam has not reached the concluding interval. # When the exam has not reached the concluding interval.
time_remaining_mock.return_value = constants.EXAM_CONCLUDING_INTERVAL + 5 exam_attempt.status = ProctoredExamStudentAttemptStatus.started
exam_attempt.save()
response = self.client.get(polling_status_endpoint) response = self.client.get(polling_status_endpoint)
response_data = json.loads(response.content) response_data = json.loads(response.content)
self.assertEqual(response_data['polling_interval'], constants.DEFAULT_CLIENT_POLLING_INTERVAL) self.assertEqual(response_data['polling_interval'], constants.DEFAULT_CLIENT_POLLING_INTERVAL)
time_remaining_mock.return_value = constants.EXAM_CONCLUDING_INTERVAL - 5 exam_attempt.status = ProctoredExamStudentAttemptStatus.submitted
exam_attempt.save()
response = self.client.get(polling_status_endpoint) response = self.client.get(polling_status_endpoint)
response_data = json.loads(response.content) response_data = json.loads(response.content)
self.assertEqual(response_data['polling_interval'], constants.REDUCED_CLIENT_POLLING_INTERVAL) self.assertEqual(response_data['polling_interval'], constants.REDUCED_CLIENT_POLLING_INTERVAL)
......
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