MDL-8177 - Random questions selected deleted questions. Backported from MOODLE_18_STABLE.

This commit is contained in:
tjhunt
2007-03-10 00:34:35 +00:00
parent 5530732c16
commit 4b1f48e2ae
+6 -5
View File
@@ -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();
}