Skip to content

Commit

Permalink
The timer counts down in every navigation mode
Browse files Browse the repository at this point in the history
No idea why it was only counting down in sequence mode.
  • Loading branch information
christianp committed Dec 13, 2024
1 parent 855f5cc commit 18325dd
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions runtime/scripts/exam.js
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,9 @@ Exam.prototype = /** @lends Numbas.Exam.prototype */ {
this.timeRemaining = this.settings.duration;
this.updateScore(); //initialise score
//set countdown going
if(this.mode!='review')
if(this.mode!='review') {
this.startTiming();
}

switch(this.settings.navigateMode) {
case 'sequence':
Expand Down Expand Up @@ -925,8 +926,7 @@ Exam.prototype = /** @lends Numbas.Exam.prototype */ {
* @fires Numbas.Exam#event:hideTiming
* @fires Numbas.Exam#event:showTiming
*/
startTiming: function()
{
startTiming: function() {
this.inProgress = true;
this.stopwatch = {
start: new Date(),
Expand All @@ -951,12 +951,10 @@ Exam.prototype = /** @lends Numbas.Exam.prototype */ {
* @fires Numbas.Exam#event:countDown
* @fires Numbas.Exam#event:alert
*/
countDown: function()
{
countDown: function() {
var t = new Date();
this.timeSpent = this.stopwatch.oldTimeSpent + (t - this.stopwatch.start)/1000;
if(this.settings.navigateMode=='sequence' && this.settings.duration > 0)
{
if(this.settings.duration > 0) {
this.timeRemaining = Math.ceil((this.stopwatch.end - t)/1000);
this.display && this.display.showTiming();
this.events.trigger('showTiming');
Expand Down Expand Up @@ -988,8 +986,7 @@ Exam.prototype = /** @lends Numbas.Exam.prototype */ {
*
* @fires Numbas.Exam#event:endTiming
*/
endTiming: function()
{
endTiming: function() {
this.inProgress = false;
clearInterval( this.stopwatch.id );
this.events.trigger('endTiming');
Expand Down

0 comments on commit 18325dd

Please sign in to comment.