]> _ Git - fluidbook-toolbox-quiz.git/commitdiff
wait #6409 @2:30
authorsoufiane <soufiane@cubedesigners.com>
Fri, 13 Oct 2023 15:33:17 +0000 (17:33 +0200)
committersoufiane <soufiane@cubedesigners.com>
Fri, 13 Oct 2023 15:33:17 +0000 (17:33 +0200)
js/quiz.draganddrop.js
views/screens/question_draganddrop.blade.php

index f0cd3164332535d7d02448205fae3def34ebae49..c693bdbb907306ef50cfbe44b6135ad3577ac923 100644 (file)
@@ -44,11 +44,13 @@ QuizDragAndDrop.prototype = {
         this.initQuestion();
     },
 
-    sendCurrentAnswerToArea: function (area) {
+    sendCurrentAnswerToArea: function (area, index) {
         if (this.animating === true) {
             return;
         }
-        this.quiz.screens.currentQuestionAnswers.push(area === 'zone-1' ? 1 : 2);
+        //this.quiz.screens.currentQuestionAnswers.push(area === 'zone-1' ? 1 : 2);
+        console.log("index",index)
+        this.quiz.screens.currentQuestionAnswers.splice(index, 0, area === 'zone-1' ? 1 : 2)
 
         this.animating = true;
         const $this = this;
@@ -71,7 +73,6 @@ QuizDragAndDrop.prototype = {
                 position: 'absolute',
             }
             if (this.quiz.resize.isMobile()) {
-
                 rules = {
                     scale: 0.8, duration: .3, autoAlpha: 0,
                 }
@@ -149,7 +150,7 @@ QuizDragAndDrop.prototype = {
                 //
                 let zone = $this.getZoneOverlap(this.target)
                 if (zone) {
-                    $this.sendCurrentAnswerToArea(zone);
+                    $this.sendCurrentAnswerToArea(zone, $(this.target).data("id"));
                 }
             },
             onRelease: function () {
@@ -280,7 +281,7 @@ QuizDragAndDrop.prototype = {
         this.createDraggable(this)
         let tl = gsap.timeline()
         this.quiz.animations.animateDragAndDropCarrousel(tl)
-    },
+    }
 }
 
 export default QuizDragAndDrop;
index 5562b56f148289badabf03731d1be81305ad050a..cc7340623f0272b944269a5723c246ac63ae7613 100644 (file)
@@ -8,10 +8,14 @@
         <div class="screen question-draganddrop">
             @include('screens.arrow',['side'=>'left','action'=>'move-card'])
             <ul class="list">
-                @foreach($question['answers'] as $key => $answer)
-                    <li class="list-item {{ $key === 0 ? 'current' : '' }}" data-id="{{$key}}">
-                        <h4>{{$answer['answer']}}</h4>
-                        <p>{{$answer['answer_text']}}</p>
+                @php
+                    $keys = array_keys($question['answers']);
+                    shuffle($keys);
+                @endphp
+                @foreach($keys as $index => $key)
+                    <li class="list-item {{ $index === 0 ? 'current' : '' }}" data-id="{{$key}}">
+                        <h4>{{$question['answers'][$key]['answer']}}</h4>
+                        <p>{{$question['answers'][$key]['answer_text']}}</p>
                     </li>
                 @endforeach
                 <li class="overlay"></li>