Browse files

MDL-9395:

Tried to call function that didn't exist. Made old function have
the functionality to return valid categories list and used that.
  • Loading branch information...
1 parent f359daa commit 72449953e41ae7eddcb8e846c3f4347ac01cbbe4 thepurpleblob committed Apr 20, 2007
Showing with 21 additions and 15 deletions.
  1. +21 −15 lib/questionlib.php
View
36 lib/questionlib.php
@@ -1515,11 +1515,13 @@ function add_indented_names($categories) {
* are included. Optionally, only categories the current user may edit can be included.
*
* @param integer $courseid the id of the course to get the categories for.
- * @param integer $published if true, include publised categories from other courses.
- * @param integer $only_editable if true, exclude categories this user is not allowed to edit.
+ * @param boolean $published if true, include publised categories from other courses.
+ * @param boolean $only_editable if true, exclude categories this user is not allowed to edit.
* @param integer $selected optionally, the id of a category to be selected by default in the dropdown.
+ * @param boolean $display display the menu only if true, otherwise just return the data
+ * @return array the valid categories
*/
-function question_category_select_menu($courseid, $published = false, $only_editable = false, $selected = "") {
+function question_category_select_menu($courseid, $published = false, $only_editable = false, $selected = "", $display=true) {
global $CFG;
// get sql fragment for published
@@ -1536,19 +1538,23 @@ function question_category_select_menu($courseid, $published = false, $only_edit
$categories = add_indented_names($categories);
- echo "<select name=\"category\">\n";
- foreach ($categories as $category) {
- $cid = $category->id;
- $cname = question_category_coursename($category, $courseid);
- $seltxt = "";
- if ($cid==$selected) {
- $seltxt = "selected=\"selected\"";
- }
- if ((!$only_editable) || has_capability('moodle/question:managecategory', get_context_instance(CONTEXT_COURSE, $category->course))) {
- echo " <option value=\"$cid\" $seltxt>$cname</option>\n";
+ if ($display) {
+ echo "<select name=\"category\">\n";
+ foreach ($categories as $category) {
+ $cid = $category->id;
+ $cname = question_category_coursename($category, $courseid);
+ $seltxt = "";
+ if ($cid==$selected) {
+ $seltxt = "selected=\"selected\"";
+ }
+ if ((!$only_editable) || has_capability('moodle/question:managecategory', get_context_instance(CONTEXT_COURSE, $category->course))) {
+ echo " <option value=\"$cid\" $seltxt>$cname</option>\n";
+ }
}
- }
- echo "</select>\n";
+ echo "</select>\n";
+ }
+
+ return $categories;
}
/**

0 comments on commit 7244995

Please sign in to comment.