]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-8177 - Random questions selected deleted questions. Merged from MOODLE_18_STABLE.
authortjhunt <tjhunt>
Sat, 10 Mar 2007 00:34:05 +0000 (00:34 +0000)
committertjhunt <tjhunt>
Sat, 10 Mar 2007 00:34:05 +0000 (00:34 +0000)
question/type/random/questiontype.php

index 793716ccb2716220c8032c5dac82365b76c4e373..4a2c3a368c50d4ae1793d17aaacc588d2efb3159 100644 (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();
             }