From: jamiesensei Date: Tue, 5 Feb 2008 11:27:02 +0000 (+0000) Subject: MDL-13005 When trying to restore a course when you have more then one quiz and you... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=5111051663788a49f0b9cb1c1b0a14f7641a6342;p=moodle.git MDL-13005 When trying to restore a course when you have more then one quiz and you choose only one quiz, the restore fails when trying to create categories and questions. Fixed this by ignoring module context level q categories in backup when the course module has not already been restored. merged from MOODLE_19_STABLE --- diff --git a/question/restorelib.php b/question/restorelib.php index 48426518f5..1600ccfe71 100644 --- a/question/restorelib.php +++ b/question/restorelib.php @@ -96,7 +96,10 @@ function restore_question_get_best_category_context($restore, $contextinfo) { switch ($contextinfo['LEVEL'][0]['#']) { case 'module': - $instanceinfo = backup_getid($restore->backup_unique_code, 'course_modules', $contextinfo['INSTANCE'][0]['#']); + if (!$instanceinfo = backup_getid($restore->backup_unique_code, 'course_modules', $contextinfo['INSTANCE'][0]['#'])){ + //module has not been restored, probably not selected for restore + return false; + } $tocontext = get_context_instance(CONTEXT_MODULE, $instanceinfo->new_id); break; case 'course': @@ -168,7 +171,9 @@ $tocontext = get_context_instance(CONTEXT_COURSE, $course); } } else { - $tocontext = restore_question_get_best_category_context($restore, $info['QUESTION_CATEGORY']['#']['CONTEXT']['0']['#']); + if (!$tocontext = restore_question_get_best_category_context($restore, $info['QUESTION_CATEGORY']['#']['CONTEXT']['0']['#'])){ + return $status; // context doesn't exist - a module has not been restored + } } $question_cat->contextid = $tocontext->id;