MDL-51855 mod_question: fix offset error during upgrade

This commit is contained in:
Simey Lameze 2015-10-22 14:09:54 +08:00
parent 9382ac38d6
commit abc2491211
2 changed files with 4 additions and 2 deletions

View 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) );

View 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) );
}