@edx/edx-proctoring
Advanced tools
Comparing version 2.5.4 to 2.5.5
@@ -179,14 +179,23 @@ edx = edx || {}; | ||
queryString = '?sourceid=in_exam&proctored=' + self.model.get('taking_as_proctored'); | ||
$.ajax(url + queryString).success(function(data) { | ||
if (data.status === 'error') { | ||
// The proctoring session is in error state | ||
// refresh the page to bring up the new Proctoring state from the backend. | ||
clearInterval(self.timerId); // stop the timer once the time finishes. | ||
$(window).unbind('beforeunload', self.unloadMessage); | ||
location.reload(); | ||
} else { | ||
self.secondsLeft = data.time_remaining_seconds; | ||
self.accessibility_time_string = data.accessibility_time_string; | ||
} | ||
}); | ||
$.ajax(url + queryString) | ||
.success(function(data) { | ||
if (data.status === 'error') { | ||
// The proctoring session is in error state | ||
// refresh the page to bring up the new Proctoring state from the backend. | ||
clearInterval(self.timerId); // stop the timer once the time finishes. | ||
$(window).unbind('beforeunload', self.unloadMessage); | ||
self.reloadPage(); | ||
} else { | ||
self.secondsLeft = data.time_remaining_seconds; | ||
self.accessibility_time_string = data.accessibility_time_string; | ||
} | ||
}) | ||
.error(function(error) { | ||
// if unauthorized refresh the page to kick user out of exam | ||
if (error.status === 403) { | ||
clearInterval(self.timerId); | ||
$(window).unbind('beforeunload', self.unloadMessage); | ||
self.reloadPage(); | ||
} | ||
}); | ||
} | ||
@@ -193,0 +202,0 @@ self.$el.find('div.exam-timer').attr('class'); |
@@ -133,2 +133,65 @@ /* global ProctoredExamModel:false */ | ||
}); | ||
it('reloads the page after unauthorized ajax ping', function() { | ||
var reloadPage = spyOn(this.proctored_exam_view, 'reloadPage'); | ||
this.server.respondWith( | ||
'GET', | ||
'/api/edx_proctoring/v1/proctored_exam/attempt/' + | ||
this.proctored_exam_view.model.get('attempt_id') + | ||
'?sourceid=in_exam&proctored=true', | ||
[ | ||
403, | ||
{'Content-Type': 'application/json'}, | ||
JSON.stringify({ | ||
message: 'Attempted to access attempt_id but user does not have access' | ||
}) | ||
] | ||
); | ||
this.proctored_exam_view.timerTick = this.proctored_exam_view.poll_interval - 1; // to make the ajax call. | ||
this.proctored_exam_view.updateRemainingTime(this.proctored_exam_view); | ||
this.server.respond(); | ||
this.proctored_exam_view.updateRemainingTime(this.proctored_exam_view); | ||
expect(reloadPage).toHaveBeenCalled(); | ||
}); | ||
it('reloads the page after error state ajax ping', function() { | ||
var reloadPage = spyOn(this.proctored_exam_view, 'reloadPage'); | ||
this.server.respondWith( | ||
'GET', | ||
'/api/edx_proctoring/v1/proctored_exam/attempt/' + | ||
this.proctored_exam_view.model.get('attempt_id') + | ||
'?sourceid=in_exam&proctored=true', | ||
[ | ||
200, | ||
{'Content-Type': 'application/json'}, | ||
JSON.stringify({ | ||
status: 'error' | ||
}) | ||
] | ||
); | ||
this.proctored_exam_view.timerTick = this.proctored_exam_view.poll_interval - 1; // to make the ajax call. | ||
this.proctored_exam_view.updateRemainingTime(this.proctored_exam_view); | ||
this.server.respond(); | ||
this.proctored_exam_view.updateRemainingTime(this.proctored_exam_view); | ||
expect(reloadPage).toHaveBeenCalled(); | ||
}); | ||
it('does not reload the page on general 400 errors', function() { | ||
var reloadPage = spyOn(this.proctored_exam_view, 'reloadPage'); | ||
this.server.respondWith( | ||
'GET', | ||
'/api/edx_proctoring/v1/proctored_exam/attempt/' + | ||
this.proctored_exam_view.model.get('attempt_id') + | ||
'?sourceid=in_exam&proctored=true', | ||
[ | ||
400, | ||
{'Content-Type': 'application/json'}, | ||
JSON.stringify({ | ||
message: 'Attempted to access attempt_id but it does not exist' | ||
}) | ||
] | ||
); | ||
this.proctored_exam_view.timerTick = this.proctored_exam_view.poll_interval - 1; // to make the ajax call. | ||
this.proctored_exam_view.updateRemainingTime(this.proctored_exam_view); | ||
this.server.respond(); | ||
this.proctored_exam_view.updateRemainingTime(this.proctored_exam_view); | ||
expect(reloadPage).not.toHaveBeenCalled(); | ||
}); | ||
it('calls external js global function on off-beat', function() { | ||
@@ -135,0 +198,0 @@ this.proctored_exam_view.model.set('ping_interval', 60); |
@@ -5,3 +5,3 @@ { | ||
"//": "Note that the version format is slightly different than that of the Python version when using prereleases.", | ||
"version": "2.5.4", | ||
"version": "2.5.5", | ||
"main": "edx_proctoring/static/index.js", | ||
@@ -8,0 +8,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
443962
6281