Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-30742 restoring 1.9 backups with missing question data should be …

…robust
  • Loading branch information...
commit ca25589fb5ef198b9ccfb69ae7402ca1c91751f3 1 parent 6508da4
@timhunt timhunt authored
View
15 question/type/multichoice/backup/moodle1/lib.php
@@ -50,6 +50,21 @@ public function process_question(array $data, array $raw) {
}
// convert and write the multichoice
+ if (!isset($data['multichoice'])) {
+ // This should never happen, but it can do if the 1.9 site contained
+ // corrupt data/
+ $data['multichoice'] = array(array(
+ 'single' => 1,
+ 'shuffleanswers' => 1,
+ 'correctfeedback' => '',
+ 'correctfeedbackformat' => FORMAT_HTML,
+ 'partiallycorrectfeedback' => '',
+ 'partiallycorrectfeedbackformat' => FORMAT_HTML,
+ 'incorrectfeedback' => '',
+ 'incorrectfeedbackformat' => FORMAT_HTML,
+ 'answernumbering' => 'abc',
+ ));
+ }
$this->write_multichoice($data['multichoice'], $data['oldquestiontextformat']);
}
View
6 question/type/multichoice/backup/moodle2/restore_qtype_multichoice_plugin.class.php
@@ -73,7 +73,11 @@ public function process_multichoice($data) {
// Adjust some columns
$data->question = $newquestionid;
// Map sequence of question_answer ids
- $answersarr = explode(',', $data->answers);
+ if ($data->answers) {
+ $answersarr = explode(',', $data->answers);
+ } else {
+ $answersarr = array();
+ }
foreach ($answersarr as $key => $answer) {
$answersarr[$key] = $this->get_mappingid('question_answer', $answer);
}
Please sign in to comment.
Something went wrong with that request. Please try again.