From: Benjamin Auder Date: Mon, 29 Jan 2018 15:06:02 +0000 (+0100) Subject: Fix timing when reloading exam X-Git-Url: https://git.auder.net/%7B%7B%20asset%28%27mixstore/css/store/img/DESCRIPTION?a=commitdiff_plain;h=85cf9f89b9c046ff408e16734ea9eb781864ec9f;p=qomet.git Fix timing when reloading exam --- 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)