]> git.mjollnir.org Git - moodle.git/commitdiff
Added functions to only display categories that the user is actually
authorthepurpleblob <thepurpleblob>
Fri, 18 Jun 2004 12:59:06 +0000 (12:59 +0000)
committerthepurpleblob <thepurpleblob>
Fri, 18 Jun 2004 12:59:06 +0000 (12:59 +0000)
allowed to edit. Used in question edit screens

mod/quiz/lib.php

index 3197a3c26aa67bde262780f652cca88ee8009dbf..27da0de875ab909322d9d872d62be4d118116b1d 100644 (file)
@@ -1331,6 +1331,26 @@ function quiz_print_category_form($course, $current) {
     echo "</td></tr></table>";
 }
 
+function quiz_category_select_menu($courseid,$published=false,$only_editable=false) {
+/// displays a select menu of categories with appended coursenames
+/// optionaly non editable categories may be excluded
+/// added Howard Miller June '04
+    // get sql fragment for published
+    $publishsql="";
+    if ($published) {
+        $publishsql = "or publish=1";
+    }
+    $categories = get_records_select("quiz_categories","course=$courseid $publishsql");
+    echo "<select name=\"category\">\n";
+    foreach ($categories as $category) {
+        $cid = $category->id;
+        $cname = quiz_get_category_coursename( $category );
+        if ((!$only_editable) || isteacheredit($category->course)) {
+            echo "    <option value=\"$cid\">$cname</option>\n";
+        }
+    }
+    echo "</select>\n";
+}
 
 function quiz_get_category_coursename($category) {
 /// if the category is published, adds on the course