From 369c822e90ee3163451a96ad36a1d365f9bbbae4 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 26 Sep 2023 15:58:36 +0200 Subject: [PATCH] wip #6305 @0.5 --- js/quiz.animations.js | 2 +- js/quiz.match.js | 4 ++-- js/quiz.score.js | 15 ++++++++++++--- views/screens/question_match.blade.php | 15 ++++++++++----- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/js/quiz.animations.js b/js/quiz.animations.js index da7ba19..7dde747 100644 --- a/js/quiz.animations.js +++ b/js/quiz.animations.js @@ -46,7 +46,7 @@ QuizAnimations.prototype = { selector.addClass("active") this.instantReviewAnimationTimeout = setTimeout(function (e) { $this.stopInstantReviewAnimation() - }, 400000) + }, 4000) }, stopInstantReviewAnimation: function () { diff --git a/js/quiz.match.js b/js/quiz.match.js index 3a7526f..bafd9cc 100644 --- a/js/quiz.match.js +++ b/js/quiz.match.js @@ -106,9 +106,9 @@ QuizMatch.prototype = { confirmTheMatch: function () { let lastIndex = this.swiperTop.slides.length - 1 - let index = this.swiperBottom.activeIndex + let index = parseInt($(this.swiperBottom.slides[this.swiperBottom.activeIndex]).attr('data-prop')); this.quiz.screens.currentQuestionAnswers.push(index) - this.swiperBottomEl.find(".swiper-slide").get(index).remove() + this.swiperBottomEl.find(".swiper-slide[data-prop='" + index + "']").remove() this.swiperBottom.update() if (this.swiperTop.activeIndex === lastIndex) { diff --git a/js/quiz.score.js b/js/quiz.score.js index 7025a19..d178e92 100644 --- a/js/quiz.score.js +++ b/js/quiz.score.js @@ -36,7 +36,6 @@ QuizScore.prototype = { checkQuestion: function (questionIndex) { let question = this.quiz.data.questions[questionIndex]; - let a = []; let ok = 'ok'; let count = question.count_for_score; let log = { @@ -82,7 +81,7 @@ QuizScore.prototype = { } ok = this_score >= min_score ? 'ok' : 'nok'; - log.answer = a; + log.answer = userAnswers; } else if (question.type === 'draganddrop') { min_score = this.getMinScore(question); this_score = 0; @@ -92,7 +91,17 @@ QuizScore.prototype = { } ok = this_score >= min_score ? 'ok' : 'nok'; - log.answer = a; + log.answer = userAnswers; + } else if (question.type === 'match') { + min_score = this.getMinScore(question); + this_score = 0; + for (let k in userAnswers) { + if (parseInt(k) === parseInt(userAnswers[k])) { + this_score++; + } + } + ok = this_score >= min_score ? 'ok' : 'nok'; + log.answer = userAnswers; } else { log.answer = $(this).find('input,textarea,select').val(); } diff --git a/views/screens/question_match.blade.php b/views/screens/question_match.blade.php index 8e7a180..f5d9393 100644 --- a/views/screens/question_match.blade.php +++ b/views/screens/question_match.blade.php @@ -1,7 +1,12 @@ @php - $propositions = array_map(function($n) { return $n['proposition']; }, $question['answers']); - $additional_prop = array_map(function($n) { return $n['content']; }, $question['additional_proposition']); - $propositions = [...$additional_prop,...$propositions]; + $propositions=[]; + foreach ($question['answers'] as $k=>$a) { + $propositions[]=['n'=>$k,'p'=>$a['proposition']]; + } + $k++; + foreach ($question['additional_proposition'] as $j=>$additional_prop) { + $propositions[]=['n'=>$k+$j,'p'=>$additional_prop['content']]; + } shuffle($propositions); @endphp @@ -27,8 +32,8 @@
@foreach($propositions as $prop) -
- {{ $prop }} +
+ {{ $prop['p'] }}
@endforeach
-- 2.39.5