From 6d85897f87d846f610b6a5b3bd27e86a13a2d8fe Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 29 May 2005 18:58:14 +0000 Subject: [PATCH] Added the quizzes_category_used() to detect the list of quizzes that are using questions from one category. It relies in the quizzes_question_used() function. Will be use in the 'orphan_categories' bug (#2459) (http://moodle.org/bugs/bug.php?op=show&bugid=2459) --- mod/quiz/locallib.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php index 1e5001a0e67..fe02ec49717 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -2465,6 +2465,25 @@ function quizzes_question_used($id) { return $quizlist; } +/** +* Array of names of quizzes a category appears in +* +* @return array Array of quiz names (with quiz->id as array keys) +* @param integer Quiz category id +*/ +function quizzes_category_used($id) { + + $quizlist = array(); + if ($questions = get_records('quiz_questions', 'category', $id)) { + foreach ($questions as $question) { + $qlist = quizzes_question_used($question->id); + $quizlist = $quizlist + $qlist; + } + } + + return $quizlist; +} + /** * Parse field names used for the replace options on question edit forms */