From 69580424644ab64500e72d69ed64dcc172bde31f Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 18 Nov 2004 07:32:31 +0000 Subject: [PATCH] Merged default categpory fix from stable --- mod/quiz/lib.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 654b0b7529..d90ebe3043 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -1124,14 +1124,19 @@ function quiz_get_category_menu($courseid, $published=false) { } function quiz_print_category_form($course, $current) { -// Prints a form to choose categories +/// Prints a form to choose categories - if (!$categories = get_records_select("quiz_categories", "course = '$course->id' OR publish = '1'", "name ASC")) { +/// Make sure the default category exists for this course + if (!$categories = get_records("quiz_categories", "course", $course->id, "id ASC")) { if (!$category = quiz_get_default_category($course->id)) { notify("Error creating a default category!"); - return false; } - $categories[$category->id] = $category; + } + +/// Get all the existing categories now + if (!$categories = get_records_select("quiz_categories", "course = '$course->id' OR publish = '1'", "name ASC")) { + notify("Could not find any question categories!"); + return false; // Something is really wrong } foreach ($categories as $key => $category) { if ($catcourse = get_record("course", "id", $category->course)) { -- 2.39.5