@edx/edx-proctoring
Advanced tools
Comparing version 1.5.0-rc.3 to 1.5.0-rc.4
@@ -27,2 +27,28 @@ var edx = edx || {}; | ||
/** | ||
* Launch modals, handling a11y focus behavior | ||
* | ||
* Note: don't try to leverage this for the heartbeat; the DOM | ||
* structure this depends on doesn't live everywhere that handler | ||
* needs to live | ||
*/ | ||
function accessibleError(title, message) { | ||
accessible_modal( | ||
"#accessible-error-modal #confirm_open_button", | ||
"#accessible-error-modal .close-modal", | ||
"#accessible-error-modal", | ||
".content-wrapper" | ||
); | ||
$("#accessible-error-modal #confirm_open_button").click(); | ||
$("#accessible-error-modal .message-title").html(message); | ||
$('#accessible-error-modal #acessible-error-title').html(title); | ||
$("#accessible-error-modal .ok-button") | ||
.html(gettext("OK")) | ||
.off('click.closeModal') | ||
.on('click.closeModal', function(){ | ||
$("#accessible-error-modal .close-modal").click(); | ||
}); | ||
}; | ||
function workerPromiseForEventNames(eventNames) { | ||
@@ -70,3 +96,20 @@ return function() { | ||
function setActionButtonLoadingState($button) { | ||
$button.prop('disabled', true); | ||
$button.html($button.data('loading-text')); | ||
} | ||
function setActionButtonSteadyState($button) { | ||
$button.prop('disabled', false); | ||
$button.html($button.data('cta-text')); | ||
} | ||
function errorHandlerGivenMessage($button, title, message) { | ||
setActionButtonSteadyState($button); | ||
return function() { | ||
accessibleError(title, message); | ||
}; | ||
} | ||
edx.courseware = edx.courseware || {}; | ||
@@ -82,2 +125,4 @@ edx.courseware.proctored_exam = edx.courseware.proctored_exam || {}; | ||
setActionButtonLoadingState($this); | ||
var shouldUseWorker = window.Worker && edx.courseware.proctored_exam.configuredWorkerURL; | ||
@@ -87,6 +132,23 @@ if(shouldUseWorker) { | ||
.then(updateExamAttemptStatusPromise(actionUrl, action)) | ||
.then(reloadPage); | ||
.then(reloadPage) | ||
.catch(errorHandlerGivenMessage( | ||
$this, | ||
gettext('Error Starting Exam'), | ||
gettext( | ||
'Something has gone wrong starting your exam. ' + | ||
'Please double-check that the application is running.' | ||
), | ||
)); | ||
} else { | ||
updateExamAttemptStatusPromise(actionUrl, action)() | ||
.then(reloadPage); | ||
.then(reloadPage) | ||
.catch(errorHandlerGivenMessage( | ||
$this, | ||
gettext('Error Starting Exam'), | ||
gettext( | ||
'Something has gone wrong starting your exam. ' + | ||
'Please reload the page and start again.' | ||
), | ||
)); | ||
} | ||
@@ -102,2 +164,4 @@ }; | ||
setActionButtonLoadingState($this); | ||
var shouldUseWorker = window.Worker && | ||
@@ -110,6 +174,22 @@ edx.courseware.proctored_exam.configuredWorkerURL && | ||
.then(workerPromiseForEventNames(actionToMessageTypesMap[action])) | ||
.then(reloadPage); | ||
.then(reloadPage) | ||
.catch(errorHandlerGivenMessage( | ||
$this, | ||
gettext('Error Ending Exam'), | ||
gettext( | ||
'Something has gone wrong ending your exam. ' + | ||
'Please double-check that the application is running.' | ||
) | ||
)); | ||
} else { | ||
updateExamAttemptStatusPromise(actionUrl, action)() | ||
.then(reloadPage); | ||
.then(reloadPage) | ||
.catch(errorHandlerGivenMessage( | ||
$this, | ||
gettext('Error Ending Exam'), | ||
gettext( | ||
'Something has gone wrong ending your exam. ' + | ||
'Please reload the page and start again.' | ||
) | ||
)); | ||
} | ||
@@ -123,4 +203,3 @@ } | ||
} | ||
edx.courseware.proctored_exam.accessibleError = accessibleError; | ||
}).call(this, $); |
@@ -5,3 +5,3 @@ { | ||
"//": "Note that the version format is slightly different than that of the Python version when using prereleases.", | ||
"version": "1.5.0-rc.3", | ||
"version": "1.5.0-rc.4", | ||
"main": "edx_proctoring/static/index.js", | ||
@@ -8,0 +8,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
407372
5554