]> git.mjollnir.org Git - moodle.git/commitdiff
factored out functionality to check if question is in use on delete
authorthepurpleblob <thepurpleblob>
Thu, 27 Jan 2005 16:18:27 +0000 (16:18 +0000)
committerthepurpleblob <thepurpleblob>
Thu, 27 Jan 2005 16:18:27 +0000 (16:18 +0000)
will be using this to delete whole categories of questions (or not)

mod/quiz/question.php

index 0369dcb7a34e510e1ca42664ae2471dcf4d91ce2..231b2468473b980db4a90af9dcdff7c6b4b644b9 100644 (file)
             
         } else {
             // determine if the question is being used in any quiz
-            if ($category->publish) {
-                $quizzes = get_records("quiz");
-            } else {
-                $quizzes = get_records("quiz", "course", $course->id);
-            }
-            $beingused = array();
-            if ($quizzes) {
-                foreach ($quizzes as $quiz) {
-                    $qqq = explode(",", $quiz->questions);
-                    foreach ($qqq as $key => $value) {
-                        if ($value == $delete) {
-                            $beingused[] = $quiz->name;
-                        }
-                    }
-                }
-            }
+            $beingused = quizzes_question_used( $delete, $category->publish, $course->id );
             if ($beingused) {
                 $beingused = implode(", ", $beingused);
                 $beingused = get_string("questioninuse", "quiz", "<i>$question->name</i>")."<p>".$beingused;