Browse Source

Manage Matching Draggable answer - refs #7611

Angel Fernando Quiroz Campos 10 years ago
parent
commit
47bd70b243
2 changed files with 13 additions and 8 deletions
  1. 4 4
      main/exercice/answer_admin.inc.php
  2. 9 4
      main/exercice/exercise.class.php

+ 4 - 4
main/exercice/answer_admin.inc.php

@@ -62,7 +62,7 @@ if ($modifyIn) {
         $reponse = unserialize($reponse);
         $comment = unserialize($comment);
         $weighting = unserialize($weighting);
-    } elseif ($answerType == MATCHING) {
+    } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
         $option = unserialize($option);
         $match = unserialize($match);
         $sel = unserialize($sel);
@@ -368,7 +368,7 @@ if ($submitAnswers || $buttonBack) {
         } else {
             unset($setWeighting);
         }
-    } elseif ($answerType == MATCHING) {
+    } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
         if ($debug > 0) {
             echo str_repeat('&nbsp;', 2) . '$answerType is MATCHING' . "<br />\n";
         }
@@ -621,7 +621,7 @@ if ($modifyAnswers) {
                 $weighting = unserialize($weighting);
             }
         }
-    } elseif ($answerType == MATCHING) {
+    } elseif(in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
         if ($debug > 0) {
             echo str_repeat('&nbsp;', 2) . '$answerType is MATCHING' . "<br />\n";
         }
@@ -1066,7 +1066,7 @@ if ($modifyAnswers) {
                     <?php
                 }
                 //end of FREE_ANSWER type*/
-                elseif ($answerType == MATCHING) {
+                elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
                     ?>
 
                 <h3>

+ 9 - 4
main/exercice/exercise.class.php

@@ -2774,6 +2774,8 @@ class Exercise
                     break;
                 case DRAGGABLE:
                     //no break
+                case MATCHING_DRAGGABLE:
+                    //no break
                 case MATCHING:
                     if ($from_database) {
                         $sql = 'SELECT id, answer, id_auto
@@ -2851,7 +2853,8 @@ class Exercise
                                 echo '<tr>';
                                 echo '<td>' . $s_answer_label . '</td>';
                                 echo '<td>' . $user_answer;
-                                if ($answerType == MATCHING) {
+
+                                if (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
                                     if (isset($real_list[$i_answer_correct_answer])) {
                                         echo Display::span(
                                             $real_list[$i_answer_correct_answer],
@@ -2977,7 +2980,7 @@ class Exercise
                     if (
                         !in_array(
                             $answerType,
-                            [MATCHING, DRAGGABLE]
+                            [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE]
                         ) ||
                         $answerCorrect
                     ) {
@@ -3245,7 +3248,7 @@ class Exercise
                                     error_log(__LINE__.' first',0);
                                 }
                             }
-                        } elseif($answerType == MATCHING) {
+                        } elseif (in_array($answerType, [MATCHING, MATCHING_DRAGGABLE])) {
                             echo '<tr>';
                             echo Display::tag('td', $answerMatching[$answerId]);
                             echo Display::tag(
@@ -3571,6 +3574,8 @@ class Exercise
                             break;
                         case DRAGGABLE:
                             //no break
+                        case MATCHING_DRAGGABLE:
+                            //no break
                         case MATCHING:
                             echo '<tr>';
                             echo Display::tag('td', $answerMatching[$answerId]);
@@ -3883,7 +3888,7 @@ class Exercise
                 } else {
                     Event::saveQuestionAttempt($questionScore, 0, $quesId, $exeId, 0, $this->id);
                 }
-            } elseif (in_array($answerType, [MATCHING, DRAGGABLE])) {
+            } elseif (in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE])) {
                 if (isset($matching)) {
                     foreach ($matching as $j => $val) {
                         Event::saveQuestionAttempt($questionScore, $val, $quesId, $exeId, $j, $this->id);