]> _ Git - fluidbook-toolbox-quiz.git/commitdiff
wip #6194 @1:30 compte à rebours
authorsoufiane <soufiane@cubedesigners.com>
Tue, 22 Aug 2023 10:38:22 +0000 (12:38 +0200)
committersoufiane <soufiane@cubedesigners.com>
Tue, 22 Aug 2023 10:38:22 +0000 (12:38 +0200)
js/quiz.screens.js

index 30fd1232e03562e06a7477854f2e67697bdda945..570068bbd3334bd0979687917f6cc2fbae0f700f 100644 (file)
@@ -32,7 +32,10 @@ QuizScreens.prototype = {
 
         // Cliquer sur le bouton suivant
         $(document).on("click", ".next .action", function () {
-            if ($this.currentQuestionAnswers.length === 0) {
+            console.log("countdown_enable",parseInt($this.quiz.question.current().countdown_enable))
+            console.log("intervalCountDown",$this.intervalCountDown)
+            if (($this.currentQuestionAnswers.length === 0 && !parseInt($this.quiz.question.current().countdown_enable))
+            || (parseInt($this.quiz.question.current().countdown_enable) && $this.intervalCountDown !== 0 && $this.currentQuestionAnswers.length === 0)) {
                 alert('Please select at least one answer');
                 return false;
             }
@@ -139,8 +142,10 @@ QuizScreens.prototype = {
             $this.quiz.progressbar.update();
 
             // if countdown enable
-            if(parseInt($this.quiz.question.current().countdown_enable)) {
-                $this.countdown()
+            if($this.quiz.question.current() !== undefined) {
+                if (parseInt($this.quiz.question.current().countdown_enable)) {
+                    $this.countdown()
+                }
             }
 
             if (screen === 'outro') {
@@ -200,6 +205,8 @@ QuizScreens.prototype = {
             document.documentElement.style.setProperty("--width-bg-countdown", value + "%")
             if(value <= 0) {
                 clearInterval($this.intervalCountDown)
+                $this.intervalCountDown = 0;
+                $this.currentQuestionAnswers = []
                 /**
                  *
                  * provisoire