From 216a0e6f35cd31c4bed05bc53b4db289e6e82c3e Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Mon, 8 May 2017 14:24:01 -0500 Subject: [PATCH] Fix multiples draggable questions - refs BT#12712 --- main/inc/lib/exercise.lib.php | 9 ++++++--- main/template/default/exercise/submit.js.tpl | 14 ++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/main/inc/lib/exercise.lib.php b/main/inc/lib/exercise.lib.php index b88ca279c5..22fa24381c 100644 --- a/main/inc/lib/exercise.lib.php +++ b/main/inc/lib/exercise.lib.php @@ -115,9 +115,12 @@ class ExerciseLib if ($answerType == DRAGGABLE) { $isVertical = $objQuestionTmp->extra == 'v'; - $s .= '
-
-
    '; + $s .= ' +
    +
    +
      + '; } else { $s .= '
      '; diff --git a/main/template/default/exercise/submit.js.tpl b/main/template/default/exercise/submit.js.tpl index 25e20c1636..bce9313da3 100644 --- a/main/template/default/exercise/submit.js.tpl +++ b/main/template/default/exercise/submit.js.tpl @@ -28,15 +28,21 @@ var DraggableAnswer = { }); }, recycleItem: function (item) { + var droppedId = item.attr('id'), + originSelectId = 'window_' + droppedId + '_select', + idParts = droppedId.split('_'), + questionId = parseInt(idParts[0]) || 0; + + if (!questionId) { + return; + } + item.fadeOut(function () { item - .appendTo(DraggableAnswer.gallery) + .appendTo(DraggableAnswer.gallery.filter('[data-question="' + questionId + '"]')) .fadeIn(); }); - var droppedId = item.attr('id'), - originSelectId = 'window_' + droppedId + '_select'; - $('#' + originSelectId + ' option').prop('selected', false); $('#' + originSelectId + ' option:first').prop('selected', true); },