libdir.'/questionlib.php'); function question_category_form($course, $current, $recurse=1, $showhidden=false) { global $CFG; /// Prints a form to choose categories /// Make sure the default category exists for this course if (!$categories = get_records("question_categories", "course", $course->id, "id ASC")) { if (!$category = get_default_question_category($course->id)) { notify("Error creating a default category!"); } } /// Get all the existing categories now if (!$categories = get_records_select("question_categories", "course = '{$course->id}' OR publish = '1'", "parent, sortorder, name ASC")) { notify("Could not find any question categories!"); return false; // Something is really wrong } $categories = add_indented_names( $categories ); foreach ($categories as $key => $category) { if ($catcourse = get_record("course", "id", $category->course)) { if ($category->publish && $category->course != $course->id) { $category->indentedname .= " ($catcourse->shortname)"; } $catmenu[$category->id] = $category->indentedname; } } $strcategory = get_string("category", "quiz"); $strshow = get_string("show", "quiz"); $streditcats = get_string("editcategories", "quiz"); echo "
"; echo "$strcategory: "; echo " | "; popup_form ("edit.php?courseid=$course->id&cat=", $catmenu, "catmenu", $current, "", "", "", false, "self"); echo " | "; echo ""; echo ' |
"; print_string("selectcategoryabove", "quiz"); echo "
"; if ($quizid) { echo ""; print_string("addingquestions", "quiz"); echo "
"; } return; } if (!$category = get_record("question_categories", "id", "$categoryid")) { notify("Category not found!"); return; } echo "$strcreatenewquestion: | "; echo ''; popup_form ("$CFG->wwwroot/question/question.php?category=$category->id&qtype=", $QTYPE_MENU, "addquestion", "", "choose", "", "", false, "self"); echo ' | '; helpbutton("questiontypes", $strcreatenewquestion, "quiz"); echo ' |
'; print_string("publishedit","quiz"); echo ' | ||
'; if (isteacheredit($category->course)) { echo ''.$strimportquestions.''; helpbutton("import", $strimportquestions, "quiz"); echo ' | '; } echo "wwwroot/question/export.php?category={$category->id}&courseid={$course->id}\">$strexportquestions"; helpbutton("export", $strexportquestions, "quiz"); echo ' |
"; print_string("noquestions", "quiz"); echo "
"; return; } if (!$questions = get_records_select('question', "category IN ($categorylist) AND parent = '0' $showhidden", $sortorder, '*', $page*$perpage, $perpage)) { // There are no questions on the requested page. $page = 0; if (!$questions = get_records_select('question', "category IN ($categorylist) AND parent = '0' $showhidden", $sortorder, '*', 0, $perpage)) { // There are no questions at all echo ""; print_string("noquestions", "quiz"); echo "
"; return; } } print_paging_bar($totalnumber, $page, $perpage, "edit.php?courseid={$course->id}&perpage=$perpage&"); $canedit = isteacheredit($category->course); echo '\n"; } ?>