From 997bcf0eb8cf7d5c2be5c3a3ff47d782f09dd594 Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Thu, 16 Feb 2006 18:15:15 +0000 Subject: [PATCH] As Eloy pointed out, my recent addition for including child categories used by random questions did not restrict to the course or the instances currently being backed up. --- mod/quiz/backuplib.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mod/quiz/backuplib.php b/mod/quiz/backuplib.php index 4a0f9023fe2..0fa9f384dd5 100644 --- a/mod/quiz/backuplib.php +++ b/mod/quiz/backuplib.php @@ -114,7 +114,8 @@ $from = ", {$CFG->prefix}quiz q"; // but if we have an array of quiz ids, use those instead. if (!empty($instances) && is_array($instances) && count($instances)) { - $where = ' g.quiz IN ('.implode(',',array_keys($instances)).') AND '; + $where = ' g.quiz IN ('.implode(',',array_keys($instances)).') AND '; + $from = ''; } //Detect used categories (by category in questions) @@ -159,11 +160,12 @@ // Now we look for random questions that can use questions from subcategories // because we will have to add these subcategories $sql = "SELECT q.id, q.category - FROM {$CFG->prefix}quiz_question_instances AS i, - {$CFG->prefix}quiz_questions AS q - WHERE q.id = i.question - AND q.qtype = '".RANDOM."' - AND q.questiontext = '1'"; + FROM {$CFG->prefix}quiz_question_instances AS g, + {$CFG->prefix}quiz_questions AS t + $from + WHERE $where t.id = g.question + AND t.qtype = '".RANDOM."' + AND t.questiontext = '1'"; if ($randoms = get_records_sql($sql)) { foreach ($randoms as $random) { $status = $status && quiz_backup_add_category_tree($random->category);