@edx/edx-proctoring
Advanced tools
Comparing version 1.5.0-rc.5 to 1.5.0-rc.6
@@ -191,6 +191,6 @@ var edx = edx || {}; | ||
} | ||
edx.courseware.proctored_exam.pingApplication = function() { | ||
edx.courseware.proctored_exam.pingApplication = function(timeoutInSeconds) { | ||
return Promise.race([ | ||
workerPromiseForEventNames(actionToMessageTypesMap.ping)(), | ||
timeoutPromise(ONE_MINUTE_MS) | ||
timeoutPromise(timeoutInSeconds * 1000) | ||
]); | ||
@@ -197,0 +197,0 @@ } |
@@ -145,9 +145,10 @@ var edx = edx || {}; | ||
updateRemainingTime: function (self) { | ||
var pingInterval = self.model.get('ping_interval'); | ||
self.timerTick ++; | ||
self.secondsLeft --; | ||
if ( | ||
self.timerTick % self.poll_interval === self.poll_interval / 2 && | ||
self.timerTick % pingInterval === pingInterval / 2 && | ||
edx.courseware.proctored_exam.configuredWorkerURL | ||
) { | ||
edx.courseware.proctored_exam.pingApplication().catch(self.endExamForFailureState.bind(self)); | ||
edx.courseware.proctored_exam.pingApplication(pingInterval).catch(self.endExamForFailureState.bind(self)); | ||
} | ||
@@ -197,4 +198,6 @@ if (self.timerTick % self.poll_interval === 0) { | ||
type: 'PUT' | ||
}).done(function() { | ||
self.reloadPage(); | ||
}).done(function(result) { | ||
if (result.exam_attempt_id) { | ||
self.reloadPage(); | ||
} | ||
}); | ||
@@ -201,0 +204,0 @@ }, |
@@ -99,5 +99,6 @@ describe('ProctoredExamView', function () { | ||
it("calls external js global function on off-beat", function() { | ||
this.proctored_exam_view.model.set('ping_interval', 60); | ||
edx.courseware.proctored_exam.pingApplication = jasmine.createSpy().and.returnValue(Promise.resolve()); | ||
edx.courseware.proctored_exam.configuredWorkerURL = 'nonempty/string.html'; | ||
this.proctored_exam_view.timerTick = this.proctored_exam_view.poll_interval / 2 - 1; | ||
this.proctored_exam_view.timerTick = this.proctored_exam_view.model.get('ping_interval') / 2 - 1; | ||
this.proctored_exam_view.updateRemainingTime(this.proctored_exam_view); | ||
@@ -113,3 +114,3 @@ expect(edx.courseware.proctored_exam.pingApplication).toHaveBeenCalled(); | ||
{"Content-Type": "application/json"}, | ||
"{}" | ||
'{"exam_attempt_id": "abcde"}' | ||
); | ||
@@ -125,2 +126,22 @@ } | ||
}); | ||
it("does not reload the page after failure-state ajax call when server responds with no attempt id", function(done) { | ||
// this case mimics current behavior of the server when the | ||
// proctoring backend is configured to not block the user for a | ||
// failed ping. | ||
this.server.respondWith( | ||
function(request) { | ||
request.respond(200, | ||
{"Content-Type": "application/json"}, | ||
'{"exam_attempt_id": false}' | ||
); | ||
} | ||
); | ||
var reloadPage = spyOn(this.proctored_exam_view, 'reloadPage'); | ||
this.proctored_exam_view.endExamForFailureState().done(function() { | ||
expect(reloadPage).not.toHaveBeenCalled(); | ||
done(); | ||
}); | ||
this.server.respond(); | ||
}); | ||
it("sets global variable when unset", function() { | ||
@@ -127,0 +148,0 @@ expect(window.edx.courseware.proctored_exam.configuredWorkerURL).toBeUndefined(); |
@@ -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.5", | ||
"version": "1.5.0-rc.6", | ||
"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
408474
5577