From 3b5086f5107186762f3383159d619bdd69257c35 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Fri, 10 Oct 2014 17:58:30 +0100 Subject: [PATCH] MDL-45851 restore: random questions must always be created They are really a pointer from a particular quiz to a question category. They should never be shared, because if they are, unexpected things happend when they are edited. --- backup/util/dbops/restore_dbops.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backup/util/dbops/restore_dbops.class.php b/backup/util/dbops/restore_dbops.class.php index a4c7075ada7..8b6c78d4815 100644 --- a/backup/util/dbops/restore_dbops.class.php +++ b/backup/util/dbops/restore_dbops.class.php @@ -586,7 +586,8 @@ abstract class restore_dbops { // 6b) User cannot, check if we are in some contextlevel with fallback // 7a) There is fallback, move ALL the qcats to fallback, warn. End qcat loop // 7b) No fallback, error. End qcat loop - // 5b) Match, mark q to be mapped + // 5b) Random question, must always create new. + // 5c) Match, mark q to be mapped // Get all the contexts (question banks) in restore for the given contextlevel $contexts = self::restore_get_question_banks($restoreid, $contextlevel); @@ -683,7 +684,11 @@ abstract class restore_dbops { break 2; // out from qcat loop (both 7a and 7b), we have decided about ALL categories in context (bank) } - // 5b) Match, mark q to be mapped + // 5b) Random questions must always be newly created. + } else if ($question->qtype == 'random') { + // Nothing to mark, newitemid means create + + // 5c) Match, mark q to be mapped. } else { self::set_backup_ids_record($restoreid, 'question', $question->id, $matchqid); }