From 4b1f48e2ae2e97f07df9941b8294c69f748d2e43 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Sat, 10 Mar 2007 00:34:35 +0000 Subject: [PATCH] MDL-8177 - Random questions selected deleted questions. Backported from MOODLE_18_STABLE. --- question/type/random/questiontype.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/question/type/random/questiontype.php b/question/type/random/questiontype.php index 793716ccb27..4a2c3a368c5 100644 --- a/question/type/random/questiontype.php +++ b/question/type/random/questiontype.php @@ -45,6 +45,7 @@ class random_qtype extends default_questiontype { // 1. All questions that are explicitly assigned to the quiz // 2. All random questions // 3. All questions that are already chosen by an other random question + // 4. Deleted questions if (!isset($cmoptions->questionsinuse)) { $cmoptions->questionsinuse = $attempt->layout; } @@ -59,14 +60,14 @@ class random_qtype extends default_questiontype { } else { $categorylist = $question->category; } - if ($catrandoms = get_records_sql - ("SELECT id,id FROM {$CFG->prefix}question - WHERE category IN ($categorylist) + if ($catrandoms = get_records_select('question', + "category IN ($categorylist) AND parent = '0' + AND hidden = '0' AND id NOT IN ($cmoptions->questionsinuse) - AND qtype NOT IN ($QTYPE_EXCLUDE_FROM_RANDOM)")) { + AND qtype NOT IN ($QTYPE_EXCLUDE_FROM_RANDOM)", '', 'id')) { $this->catrandoms[$question->category][$question->questiontext] = - draw_rand_array($catrandoms, count($catrandoms)); // from bug 1889 + draw_rand_array($catrandoms, count($catrandoms)); } else { $this->catrandoms[$question->category][$question->questiontext] = array(); }