Permalink
Browse files

MDL-14750 - Multianswer questions get broken by backup and restore be…

…cuase question->parent is not recoded properly in the database.
  • Loading branch information...
1 parent 6fa56c5 commit cfdfc85ddce75d46387c49f224a6d36cbac5b94e tjhunt committed May 9, 2008
Showing with 11 additions and 5 deletions.
  1. +11 −5 question/restorelib.php
View
16 question/restorelib.php
@@ -259,17 +259,23 @@ function restore_questions ($old_category_id,$new_category_id,$info,$restore) {
$question->parent = $restored_questions[$i]->parent;
- //If it's a new question in the DB, restore it
+ /// If it's a new question in the DB, restore it
if ($restored_questions[$i]->is_new) {
- ////We have to recode the parent field
- if ($question->parent) {
+ /// We have to recode the parent field
+ if ($question->parent && $question->qtype != 'random') {
+ /// If the parent field needs to be changed, do it here. Random questions are dealt with above.
if ($parent = backup_getid($restore->backup_unique_code,"question",$question->parent)) {
$question->parent = $parent->new_id;
- } elseif ($question->parent = $oldid) {
- $question->parent = $newid;
+ if ($question->parent != $restored_questions[$i]->parent) {
+ if (!set_field('question', 'parent', $question->parent, 'id', $newid)) {
+ echo 'Could not update parent '.$question->parent.' for question '.$oldid.'<br />';
+ $status = false;
+ }
+ }
} else {
echo 'Could not recode parent '.$question->parent.' for question '.$oldid.'<br />';
+ $status = false;
}
}

0 comments on commit cfdfc85

Please sign in to comment.