From 85cf9f89b9c046ff408e16734ea9eb781864ec9f Mon Sep 17 00:00:00 2001 From: Benjamin Auder <benjamin.auder@somewhere> Date: Mon, 29 Jan 2018 16:06:02 +0100 Subject: [PATCH] Fix timing when reloading exam --- public/javascripts/assessment.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/javascripts/assessment.js b/public/javascripts/assessment.js index 1d62894..d0567d5 100644 --- a/public/javascripts/assessment.js +++ b/public/javascripts/assessment.js @@ -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) -- 2.44.0