Made sure the questions that can be parent questions are backed up and restored first so that the recoding of the parent field will work.

This commit is contained in:
gustav_delius 2005-05-10 09:49:58 +00:00
parent 2e1111c5b1
commit 9a62a7634b
2 changed files with 7 additions and 2 deletions

View File

@ -247,8 +247,11 @@
$status = true;
$questions = get_records("quiz_questions","category",$category,"id");
//If there is questions
// We'll fetch the questions sorted by parent so that questions with no parents
// (these are the ones which could be parents themselves) are backed up first. This
// is important for the recoding of the parent field during the restore process
$questions = get_records("quiz_questions","category",$category,"parent ASC, id");
//If there are questions
if ($questions) {
//Write start tag
$status =fwrite ($bf,start_tag("QUESTIONS",4,true));

View File

@ -203,6 +203,8 @@
$question->hidden = backup_todb($que_info['#']['HIDDEN']['0']['#']);
////We have to recode the parent field
// This should work alright because we ordered the questions appropriately during backup so that
// questions that can be parents are restored first
if ($question->parent and $parent = backup_getid($restore->backup_unique_code,"quiz_questions",$question->parent)) {
$question->parent = $parent->new_id;
}