From: skodak Date: Wed, 7 Jun 2006 14:57:26 +0000 (+0000) Subject: Bug #5522 - question/restorelib.php error; merged from MOODLE_16_STABLE X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=e7251cdd218e69ef2d8e6a8014aa10717db733f5;p=moodle.git Bug #5522 - question/restorelib.php error; merged from MOODLE_16_STABLE --- diff --git a/question/restorelib.php b/question/restorelib.php index a28238fe8b..3206a15b1a 100644 --- a/question/restorelib.php +++ b/question/restorelib.php @@ -182,6 +182,7 @@ $oldid = backup_todb($que_info['#']['ID']['0']['#']); //Now, build the question record structure + $question = new object; $question->category = $new_category_id; $question->parent = backup_todb($que_info['#']['PARENT']['0']['#']); $question->name = backup_todb($que_info['#']['NAME']['0']['#']); @@ -242,6 +243,8 @@ $newid = $restored_questions[$i]->newid; $oldid = $restored_questions[$i]->oldid; + + $question = new object; $question->qtype = $restored_questions[$i]->qtype; $question->parent = $restored_questions[$i]->parent; @@ -256,21 +259,31 @@ } elseif ($question->parent = $oldid) { $question->parent = $newid; } else { - echo 'Could not recode parent '.$question->parent.' for question '.$question->id.'
'; + echo 'Could not recode parent '.$question->parent.' for question '.$oldid.'
'; } } //Now, restore every question_answers in this question $status = question_restore_answers($oldid,$newid,$que_info,$restore); // Restore questiontype specific data - $status = $QTYPES[$question->qtype]->restore($oldid,$newid,$que_info,$restore); + if (array_key_exists($question->qtype, $QTYPES)) { + $status = $QTYPES[$question->qtype]->restore($oldid,$newid,$que_info,$restore); + } else { + echo 'Unknown question type '.$question->qtype.' for question '.$oldid.'
'; + $status = false; + } } else { //We are NOT creating the question, but we need to know every question_answers //map between the XML file and the database to be able to restore the states //in each attempt. $status = question_restore_map_answers($oldid,$newid,$que_info,$restore); // Do the questiontype specific mapping - $status = $QTYPE[$question->qtype]->restore_map($oldid,$newid,$que_info,$restore); + if (array_key_exists($question->qtype, $QTYPES)) { + $status = $QTYPES[$question->qtype]->restore_map($oldid,$newid,$que_info,$restore); + } else { + echo 'Unknown question type '.$question->qtype.' for question '.$oldid.'
'; + $status = false; + } } //Do some output