Commit 1088e5d5 by Diana Huang

Refactor SS polling code.

parent 85bd3040
...@@ -68,7 +68,8 @@ def start_exam_callback(request, attempt_code): # pylint: disable=unused-argume ...@@ -68,7 +68,8 @@ def start_exam_callback(request, attempt_code): # pylint: disable=unused-argume
Context({ Context({
'exam_attempt_status_url': poll_url, 'exam_attempt_status_url': poll_url,
'platform_name': settings.PLATFORM_NAME, 'platform_name': settings.PLATFORM_NAME,
'link_urls': settings.PROCTORING_SETTINGS.get('LINK_URLS', {}) 'link_urls': settings.PROCTORING_SETTINGS.get('LINK_URLS', {}),
'default_polling_interval': constants.DEFAULT_CLIENT_POLLING_INTERVAL,
}) })
) )
) )
......
...@@ -187,12 +187,25 @@ ...@@ -187,12 +187,25 @@
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var _poll_interval = null; var _poll_interval_id = null;
var _current_interval;
$(document).ready(function() { $(document).ready(function() {
poll_exam_status(); set_poll_interval({{default_polling_interval}});
poll_exam_status();
}); });
function set_poll_interval(new_polling_interval) {
// The polling interval will be in seconds, so we need to multiply by 1000 to get the interval in miliseconds.
new_pollint_interval = new_polling_interval * 1000;
if (new_polling_interval != _current_interval) {
clearInterval(_poll_interval_id);
_poll_interval_id = setInterval(poll_exam_status, new_polling_interval);
}
}
function poll_exam_status() { function poll_exam_status() {
var url = '{{exam_attempt_status_url}}'; var url = '{{exam_attempt_status_url}}';
...@@ -203,9 +216,9 @@ ...@@ -203,9 +216,9 @@
// NOTE: This is per the API documentation from SoftwareSecure // NOTE: This is per the API documentation from SoftwareSecure
window.external.quitApplication(); window.external.quitApplication();
} }
clearInterval(_poll_interval);
// The polling interval is returned in seconds, so we need to multiply by 1000. // The polling interval is returned in seconds, so we need to multiply by 1000.
_poll_interval = setInterval(poll_exam_status, parseInt(data.polling_interval) * 1000); set_poll_interval(parseInt(data.polling_intervall));
}); });
} }
......
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