Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 16a1a40

Browse files
committed
added restoring time and score from localstorage if they exist
1 parent 9fbdf29 commit 16a1a40

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

runestone/assess/js/timed.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ Timed.prototype.randomizeRQA = function () {
276276
this.renderedQuestionArray[randomIndex] = temporaryValue;
277277

278278
}
279-
console.log(this.renderedQuestionArray);
280279
};
281280

282281
Timed.prototype.renderTimedQuestion = function () {
@@ -308,7 +307,6 @@ Timed.prototype.startAssessment = function () {
308307
this.running = 0;
309308
this.done = 1;
310309
$(this.timedDiv).show();
311-
$(this.time).text("Already completed");
312310
this.submitTimedProblems();
313311
}
314312
};
@@ -348,7 +346,7 @@ Timed.prototype.showTime = function () { // displays the timer value
348346
}
349347
var timeString = beginning + minsString + ":" + secsString;
350348

351-
if (this.done || this.finished) {
349+
if (this.done || this.taken) {
352350
var minutes = Math.floor(this.timeTaken / 60);
353351
var seconds = Math.floor(this.timeTaken % 60);
354352
if (minutes < 10) {
@@ -365,6 +363,9 @@ Timed.prototype.showTime = function () { // displays the timer value
365363
for (var i = 0; i <= timeTips.length - 1; i++) {
366364
timeTips[i].title = timeString;
367365
}
366+
367+
368+
368369
};
369370

370371
Timed.prototype.increment = function () { // increments the timer
@@ -436,6 +437,7 @@ Timed.prototype.tookTimedExam = function () {
436437
if (len > 0) {
437438
if (localStorage.getItem(eBookConfig.email + ":" + this.divid) !== null) {
438439
this.taken = 1;
440+
this.restoreFromStorage();
439441

440442
} else {
441443
this.taken = 0;
@@ -519,6 +521,16 @@ Timed.prototype.logScore = function () {
519521
logBookEvent({"event": "timedExam", "act": "finish", "div_id": this.divid, "correct": this.score, "incorrect": this.incorrect, "skipped": this.skipped, "time": this.timeTaken});
520522
};
521523

524+
Timed.prototype.restoreFromStorage = function () {
525+
var tmpArr = localStorage.getItem(eBookConfig.email + ":" + this.divid).split(";");
526+
this.score = tmpArr[0];
527+
this.incorrect = tmpArr[1];
528+
this.skipped = tmpArr[2];
529+
this.timeTaken = tmpArr[3];
530+
this.displayScore();
531+
this.showTime();
532+
};
533+
522534
Timed.prototype.displayScore = function () {
523535
if (this.showResults) {
524536
var scoreString = "Num Correct: " + this.score + " Num Wrong: " + this.incorrect + " Num Skipped: " + this.skipped;

0 commit comments

Comments
 (0)