]> _ Git - fluidbook-toolbox.git/commitdiff
wip #6182 @0:40 gestion navigation status
authorsoufiane <soufiane@cubedesigners.com>
Mon, 7 Aug 2023 16:20:51 +0000 (18:20 +0200)
committersoufiane <soufiane@cubedesigners.com>
Mon, 7 Aug 2023 16:20:51 +0000 (18:20 +0200)
resources/quizv2/js/quiz.js
resources/quizv2/js/quiz.question.js
resources/quizv2/style/101-header-footer.sass

index 52f94808fd85182e7d21354e696c872026304a8b..57ca88fa03fb66092ce8c2241ea72a7fa83bce11 100644 (file)
@@ -133,14 +133,13 @@ Quiz.prototype = {
     next: function (responses) {
         const $el = $(".active-screen .btn.action")
         let status = quiz.score.questionStatus
-        let currentPosition = this.question.currentPosition()
 
         quiz.score.updateScore()
         // if form exist and responses are validated
         // dont miss to add this second condition
         if($(".active-screen form").length > 0) {
             if(status.length > 0) {
-                if(status[currentPosition].ok === "not answered") {
+                if(status[this.question.currentPosition()].ok === "not answered") {
                     this.validateResponse(responses);
                     this.updateBtnValidation("validated")
                     return false
@@ -150,7 +149,9 @@ Quiz.prototype = {
 
         $el.parents(".container-screen").addClass("none").removeClass("next active-screen").next(".container-screen").removeClass("none").addClass("next active-screen")
         this.resetForm()
-        this.activeNav(currentPosition)
+        // on incrémente de 1 la position actuelle de la question (qui commence à l'index zero)
+        // pour récupérer le premier enfant de la nav
+        this.activeNav(  (parseInt(this.question.currentPosition())+1)  )
         this.updateBtnValidation()
     },
 
@@ -198,14 +199,19 @@ Quiz.prototype = {
 
     activeNav: function(position = 1) {
         const questionStatus = quiz.score.questionStatus
+        console.log("position",position,"status",questionStatus)
         let $el = $(".progress-container .progress-item:nth-child("+position+")")
+        $(".progress-container .progress-item").removeClass("active")
         $el.addClass("active")
 
         for(let k in questionStatus) {
-            let $el = $(".progress-container .progress-item:nth-child("+k+")")
+            let n = (k + 1)
+            let $el = $(".progress-container .progress-item:nth-child("+n+")")
             if(questionStatus[k].ok === 'ok') {
                 $el.addClass("ok")
-            }else if(questionStatus[k].ok === 'nok'){
+            }
+
+            if(questionStatus[k].ok === 'nok'){
                 $el.addClass("nok")
             }
         }
index 0f2afe8137715229756b69068d0ded9105518ac2..78aa33a2d2ae920dc94a10cc462dc90a6c4840c4 100644 (file)
@@ -17,7 +17,7 @@ QuizQuestion.prototype = {
     },
 
     currentPosition: function() {
-        return $(".active-screen").data("position");
+        return $(document).find(".active-screen").data("position");
     },
 
     current: function() {
index 04114ccde5bc97d52eac198f16d99a8174b24806..e4e046d67625e1f9d649862970a9592e45d21751 100644 (file)
@@ -31,10 +31,10 @@ header
             margin-right: 7px
         &.active
             background-color: $texts-color
-        &.error
-            background-color: red
-        &.success
-            background-color: green
+        &.ok
+            background-color: $ok-color
+        &.nok
+            background-color: $nok-color
     h1
         +font-size(24)