Fix timing when reloading exam
authorBenjamin Auder <benjamin.auder@somewhere>
Mon, 29 Jan 2018 15:06:02 +0000 (16:06 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Mon, 29 Jan 2018 15:06:02 +0000 (16:06 +0100)
public/javascripts/assessment.js

index 1d62894..d0567d5 100644 (file)
@@ -281,7 +281,8 @@ new Vue({
                                $("#leftButton, #rightButton").hide();
                                if (assessment.time > 0)
                                {
-                                       this.remainingTime = assessment.time * 60 - (!!paper ? paper.startTime/1000 : 0);
+                                       const deltaTime = !!paper ? Date.now() - paper.startTime : 0;
+                                       this.remainingTime = assessment.time * 60 - Math.round(deltaTime / 1000);
                                        this.runTimer();
                                }
                                // Initialize structured answer(s) based on questions type and nesting (TODO: more general)