]> _ Git - fluidbook-toolbox-quiz.git/commitdiff
wip #6305 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 26 Sep 2023 13:58:36 +0000 (15:58 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 26 Sep 2023 13:58:36 +0000 (15:58 +0200)
js/quiz.animations.js
js/quiz.match.js
js/quiz.score.js
views/screens/question_match.blade.php

index da7ba19040e4853e67f2d7f8e916c607d63bf1c1..7dde747a9b7654801da018b6edb23d94e27370bc 100644 (file)
@@ -46,7 +46,7 @@ QuizAnimations.prototype = {
         selector.addClass("active")
         this.instantReviewAnimationTimeout = setTimeout(function (e) {
             $this.stopInstantReviewAnimation()
-        }, 400000)
+        }, 4000)
     },
 
     stopInstantReviewAnimation: function () {
index 3a7526fe19671fb15d2ff529b370288d537a44e6..bafd9ccf0b90b16eb052dd5931d228f53f1a36cc 100644 (file)
@@ -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) {
index 7025a197c11f33a17faf32ee454fc35f6be40dcd..d178e92adb2c06aac4d8df4b461279d5a71698d2 100644 (file)
@@ -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();
             }
index 8e7a18062a09572d799a84b569f7e25a4e2e422f..f5d9393e1e37d4bf4f99a38a7dcaa63ad5b0535d 100644 (file)
@@ -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 @@
         <div class="swiper-container bottom-slider">
             <div class="swiper-wrapper">
                 @foreach($propositions as $prop)
-                    <div class="swiper-slide">
-                        {{ $prop }}
+                    <div class="swiper-slide" data-prop="{{$prop['n']}}">
+                        {{ $prop['p'] }}
                     </div>
                 @endforeach
             </div>