/** * Shows the question bank editing interface. * * The function also processes a number of actions: * * Actions affecting the question pool: * move Moves a question to a different category * deleteselected Deletes the selected questions from the category * Other actions: * category Chooses the category * displayoptions Sets display options * * @author Martin Dougiamas and many others. This has recently been extensively * rewritten by Gustav Delius and other members of the Serving Mathematics project * {@link http://maths.york.ac.uk/serving_maths} * @param moodle_url $pageurl object representing this pages url. */ function question_showbank($tabname, $contexts, $pageurl, $cm, $page, $perpage, $sortorder, $sortorderdecoded, $cat, $recurse, $showhidden, $showquestiontext) { global $COURSE; if (optional_param('deleteselected', false, PARAM_BOOL)) { // teacher still has to confirm // make a list of all the questions that are selected $rawquestions = $_REQUEST; // This code is called by both POST forms and GET links, so cannot use data_submitted. $questionlist = ''; // comma separated list of ids of questions to be deleted $questionnames = ''; // string with names of questions separated by <br /> with // an asterix in front of those that are in use $inuse = false; // set to true if at least one of the questions is in use foreach ($rawquestions as $key => $value) { // Parse input for question ids if (preg_match('!^q([0-9]+)$!', $key, $matches)) { $key = $matches[1]; $questionlist .= $key . ','; question_require_capability_on($key, 'edit'); if (record_exists('quiz_question_instances', 'question', $key)) { $questionnames .= '* '; $inuse = true; } $questionnames .= get_field('question', 'name', 'id', $key) . '<br />'; } } if (!$questionlist) { // no questions were selected redirect($pageurl->out()); } $questionlist = rtrim($questionlist, ','); // Add an explanation about questions in use if ($inuse) { $questionnames .= '<br />' . get_string('questionsinuse', 'quiz'); } notice_yesno(get_string("deletequestionscheck", "quiz", $questionnames), $pageurl->out_action(), $pageurl->out(true), array('deleteselected' => $questionlist, 'confirm' => md5($questionlist)), $pageurl->params(), 'post', 'get'); echo '</td></tr>'; echo '</table>'; print_footer($COURSE); exit; } // starts with category selection form print_box_start('generalbox questionbank'); print_heading(get_string('questionbank', 'question'), '', 2); question_category_form($contexts->having_one_edit_tab_cap($tabname), $pageurl, $cat, $recurse, $showhidden, $showquestiontext); // continues with list of questions question_list($contexts->having_one_edit_tab_cap($tabname), $pageurl, $cat, isset($cm) ? $cm : null, $recurse, $page, $perpage, $showhidden, $sortorder, $sortorderdecoded, $showquestiontext, $contexts->having_cap('moodle/question:add')); print_box_end(); }
$SESSION->questionpage = 0; } if (empty($SESSION->questioncat) or !count_records_select("question_categories", "id = '{$SESSION->questioncat}' AND (course = '{$course->id}' OR publish = '1')")) { $category = get_default_question_category($course->id); $SESSION->questioncat = $category->id; } if (($recurse = optional_param('recurse', -1, PARAM_BOOL)) != -1) { $SESSION->questionrecurse = $recurse; } if (!isset($SESSION->questionrecurse)) { $SESSION->questionrecurse = 1; } if (($showhidden = optional_param('showhidden', -1, PARAM_BOOL)) != -1) { $SESSION->questionshowhidden = $showhidden; } if (!isset($SESSION->questionshowhidden)) { $SESSION->questionshowhidden = 0; } if (($showquestiontext = optional_param('showquestiontext', -1, PARAM_BOOL)) != -1) { $SESSION->questionshowquestiontext = $showquestiontext; } if (!isset($SESSION->questionshowquestiontext)) { $SESSION->questionshowquestiontext = 0; } // starts with category selection form print_box_start('generalbox questionbank'); print_heading(get_string('questionbank', 'question'), '', 2); question_category_form($course, $SESSION->questioncat, $SESSION->questionrecurse, $SESSION->questionshowhidden, $SESSION->questionshowquestiontext); // continues with list of questions question_list($course, $SESSION->questioncat, isset($modform->instance) ? $modform->instance : 0, $SESSION->questionrecurse, $page, $perpage, $SESSION->questionshowhidden, $sortorder, $SESSION->questionshowquestiontext); print_box_end();