libdir.'/questionlib.php'); /** * Array of question types names translated to the user's language * * The $QTYPE_MENU array holds the names of all the question types that the user should * be able to create directly. Some internal question types like random questions are excluded. * The complete list of question types can be found in {@link $QTYPES}. */ $QTYPE_MENU = array ( MULTICHOICE => get_string("multichoice", "quiz"), TRUEFALSE => get_string("truefalse", "quiz"), SHORTANSWER => get_string("shortanswer", "quiz"), NUMERICAL => get_string("numerical", "quiz"), CALCULATED => get_string("calculated", "quiz"), MATCH => get_string("match", "quiz"), DESCRIPTION => get_string("description", "quiz"), RANDOMSAMATCH => get_string("randomsamatch", "quiz"), MULTIANSWER => get_string("multianswer", "quiz"), ESSAY => get_string("essay", "quiz") ); // add remote question types if ($rqp_types = get_records('question_rqp_types')) { foreach($rqp_types as $type) { $QTYPE_MENU[100+$type->id] = $type->name; } } 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"; } ?>