Browse files

First quiz edit in a new course now always has a default category def…

…ined
  • Loading branch information...
1 parent 8fcb9eb commit d4b57dfe199f2986f4abc44cfb30651ce09fbf63 moodler committed Nov 18, 2004
Showing with 9 additions and 4 deletions.
  1. +9 −4 mod/quiz/lib.php
View
13 mod/quiz/lib.php
@@ -1074,14 +1074,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)) {

0 comments on commit d4b57df

Please sign in to comment.