From 7784af1f52d413a8aef87dd9b2ae962b6f911274 Mon Sep 17 00:00:00 2001 From: soufiane Date: Mon, 7 Aug 2023 18:20:51 +0200 Subject: [PATCH] wip #6182 @0:40 gestion navigation status --- resources/quizv2/js/quiz.js | 16 +++++++++++----- resources/quizv2/js/quiz.question.js | 2 +- resources/quizv2/style/101-header-footer.sass | 8 ++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/resources/quizv2/js/quiz.js b/resources/quizv2/js/quiz.js index 52f94808f..57ca88fa0 100644 --- a/resources/quizv2/js/quiz.js +++ b/resources/quizv2/js/quiz.js @@ -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") } } diff --git a/resources/quizv2/js/quiz.question.js b/resources/quizv2/js/quiz.question.js index 0f2afe813..78aa33a2d 100644 --- a/resources/quizv2/js/quiz.question.js +++ b/resources/quizv2/js/quiz.question.js @@ -17,7 +17,7 @@ QuizQuestion.prototype = { }, currentPosition: function() { - return $(".active-screen").data("position"); + return $(document).find(".active-screen").data("position"); }, current: function() { diff --git a/resources/quizv2/style/101-header-footer.sass b/resources/quizv2/style/101-header-footer.sass index 04114ccde..e4e046d67 100644 --- a/resources/quizv2/style/101-header-footer.sass +++ b/resources/quizv2/style/101-header-footer.sass @@ -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) -- 2.39.5