Permalink
Browse files

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)
  • Loading branch information...
1 parent 83c5e8f commit 6d85897f87d846f610b6a5b3bd27e86a13a2d8fe stronk7 committed May 29, 2005
Showing with 19 additions and 0 deletions.
  1. +19 −0 mod/quiz/locallib.php
View
@@ -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
*/

0 comments on commit 6d85897

Please sign in to comment.