Merge branch 'wip-MDL-52203-master' of https://github.com/marinaglancy/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 19 Nov 2015 08:43:19 +0000 (09:43 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 19 Nov 2015 08:45:30 +0000 (09:45 +0100)
question/type/multianswer/db/upgrade.php

index 075000a..0cd685c 100644 (file)
@@ -65,10 +65,10 @@ function xmldb_qtype_multianswer_upgrade($oldversion) {
                  FROM {question} q
                  JOIN {question_multianswer} qma ON q.id = qma.question");
         foreach ($rs as $q) {
-            if (!empty($q->sequence)) {
+            $sequence = preg_split('/,/', $q->sequence, -1, PREG_SPLIT_NO_EMPTY);
+            if ($sequence) {
                 // Get relevant data indexed by positionkey from the multianswers table.
-                $wrappedquestions = $DB->get_records_list('question', 'id',
-                        explode(',', $q->sequence), 'id ASC');
+                $wrappedquestions = $DB->get_records_list('question', 'id', $sequence, 'id ASC');
                 foreach ($wrappedquestions as $wrapped) {
                     if ($wrapped->qtype == 'multichoice') {
                         $options = $DB->get_record('qtype_multichoice_options', array('questionid' => $wrapped->id), '*');