Merge branch 'MDL-51855-master' of git://github.com/lameze/moodle
authorDan Poltawski <dan@moodle.com>
Mon, 26 Oct 2015 10:20:02 +0000 (10:20 +0000)
committerDan Poltawski <dan@moodle.com>
Mon, 26 Oct 2015 10:20:02 +0000 (10:20 +0000)
question/type/multianswer/backup/moodle2/restore_qtype_multianswer_plugin.class.php
question/type/multianswer/db/upgrade.php

index e63b777..c61c2dd 100644 (file)
@@ -118,7 +118,8 @@ class restore_qtype_multianswer_plugin extends restore_qtype_plugin {
                         question_bank::get_qtype($wrapped->qtype)->get_question_options($wrapped);
                         if (isset($wrapped->options->shuffleanswers)) {
                             preg_match('/'.ANSWER_REGEX.'/s', $wrapped->questiontext, $answerregs);
-                            if ($answerregs[ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE] != '' ) {
+                            if (isset($answerregs[ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE]) &&
+                                    $answerregs[ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE] !== '') {
                                 $wrapped->options->shuffleanswers = 0;
                                 $DB->set_field_select('qtype_multichoice_options', 'shuffleanswers', '0', "id =:select",
                                     array('select' => $wrapped->options->id) );
index 1b58ec7..c6935d3 100644 (file)
@@ -76,7 +76,8 @@ function xmldb_qtype_multianswer_upgrade($oldversion) {
                         $options = $DB->get_record('qtype_multichoice_options', array('questionid' => $wrapped->id), '*');
                         if (isset($options->shuffleanswers)) {
                             preg_match('/'.ANSWER_REGEX.'/s', $wrapped->questiontext, $answerregs);
-                            if ($answerregs[ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE] != '' ) {
+                            if (isset($answerregs[ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE]) &&
+                                    $answerregs[ANSWER_REGEX_ANSWER_TYPE_MULTICHOICE] !== '') {
                                 $DB->set_field('qtype_multichoice_options', 'shuffleanswers', '0',
                                         array('id' => $options->id) );
                             }