MDL-62880 qtype_ddwtos: drop support for legacy import format
[moodle.git] / question / type / ddwtos / questiontype.php
index d8901b3..d96ef4d 100644 (file)
@@ -71,32 +71,17 @@ class qtype_ddwtos extends qtype_gapselect_base {
         $question->shuffleanswers = $format->trans_single(
                 $format->getpath($data, array('#', 'shuffleanswers', 0, '#'), 1));
 
-        if (!empty($data['#']['dragbox'])) {
-            // Modern XML format.
-            $dragboxes = $data['#']['dragbox'];
-            $question->answer = array();
-            $question->draggroup = array();
-            $question->infinite = array();
-
-            foreach ($data['#']['dragbox'] as $dragboxxml) {
-                $question->choices[] = array(
-                    'answer' => $format->getpath($dragboxxml, array('#', 'text', 0, '#'), '', true),
-                    'choicegroup' => $format->getpath($dragboxxml, array('#', 'group', 0, '#'), 1),
-                    'infinite' => array_key_exists('infinite', $dragboxxml['#']),
-                );
-            }
-
-        } else {
-            // Legacy format containing PHP serialisation.
-            foreach ($data['#']['answer'] as $answerxml) {
-                $ans = $format->import_answer($answerxml);
-                $options = unserialize(stripslashes($ans->feedback['text']));
-                $question->choices[] = array(
-                    'answer' => $ans->answer,
-                    'choicegroup' => $options->draggroup,
-                    'infinite' => $options->infinite,
-                );
-            }
+        // Import the choices.
+        $question->answer = array();
+        $question->draggroup = array();
+        $question->infinite = array();
+
+        foreach ($data['#']['dragbox'] as $dragboxxml) {
+            $question->choices[] = array(
+                'answer' => $format->getpath($dragboxxml, array('#', 'text', 0, '#'), '', true),
+                'choicegroup' => $format->getpath($dragboxxml, array('#', 'group', 0, '#'), 1),
+                'infinite' => array_key_exists('infinite', $dragboxxml['#']),
+            );
         }
 
         $format->import_combined_feedback($question, $data, true);