diff --git a/lib/adminlib.php b/lib/adminlib.php index f6edb2cf1b52d..41337be98fafb 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -4796,9 +4796,8 @@ public function search($query) { $found = false; $textlib = textlib_get_instance(); - require_once($CFG->libdir . '/questionlib.php'); - global $QTYPES; - foreach ($QTYPES as $qtype) { + require_once($CFG->dirroot . '/question/engine/bank.php'); + foreach (question_bank::get_all_qtypes() as $qtype) { if (strpos($textlib->strtolower($qtype->local_name()), $query) !== false) { $found = true; break; diff --git a/lib/questionlib.php b/lib/questionlib.php index cf520359e3af5..7898cbec329be 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -130,7 +130,7 @@ function question_type_menu() { * Sort an array of question type names according to the question type sort order stored in * config_plugins. Entries for which there is no xxx_sortorder defined will go * at the end, sorted according to textlib_get_instance()->asort($inarray). - * @param $inarray an array $qtype => $QTYPES[$qtype]->local_name(). + * @param $inarray an array $qtypename => $qtype->local_name(). * @param $config get_config('question'), if you happen to have it around, to save one DB query. * @return array the sorted version of $inarray. */ @@ -431,7 +431,7 @@ function question_category_in_use($categoryid, $recursive = false) { * @param object $question The question being deleted */ function question_delete_question($questionid) { - global $QTYPES, $DB; + global $DB; $question = $DB->get_record_sql(' SELECT q.*, qc.contextid diff --git a/local/qedatabase/db/upgrade.php b/local/qedatabase/db/upgrade.php index 81c5baaf2101b..8fb8eba9d151a 100755 --- a/local/qedatabase/db/upgrade.php +++ b/local/qedatabase/db/upgrade.php @@ -1,7 +1,7 @@ get_manager(); diff --git a/mod/quiz/accessrules.php b/mod/quiz/accessrules.php index eaec86e1c36bc..219a482e19f66 100644 --- a/mod/quiz/accessrules.php +++ b/mod/quiz/accessrules.php @@ -235,7 +235,7 @@ public function safebrowser_required($canpreview) { * @param boolean $unfinished whether the button is to continue an existing attempt, * or start a new one. This affects whether a javascript alert is shown. */ - public function print_start_attempt_button($canpreview, $buttontext, $unfinished) { + public function print_start_attempt_button($canpreview, $buttontext, $unfinished) { global $OUTPUT; $url = $this->_quizobj->start_attempt_url(); diff --git a/mod/quiz/edit.js b/mod/quiz/edit.js index a5d43f1b55932..4a4d8727c4cd1 100644 --- a/mod/quiz/edit.js +++ b/mod/quiz/edit.js @@ -1,4 +1,27 @@ -/** JavaScript for /mod/quiz/edit.php */ +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * JavaScript library for the quiz module editing interface. + * + * @package mod + * @subpackage quiz + * @copyright 2008 Olli Savolainen + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + // Initialise everything on the quiz edit/order and paging page. var quiz_edit = {}; diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php index 1f826c45a549b..35c4ce8b8a006 100644 --- a/mod/quiz/edit.php +++ b/mod/quiz/edit.php @@ -1,27 +1,20 @@ . + /** * Page to edit quizzes @@ -43,15 +36,19 @@ * delete Removes a question from the quiz * savechanges Saves the order and grades for questions in the quiz * - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * @package quiz - *//** */ + * @package mod + * @subpackage quiz + * @copyright 1999 onwards Martin Dougiamas and others {@link http://moodle.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + require_once('../../config.php'); require_once($CFG->dirroot . '/mod/quiz/editlib.php'); require_once($CFG->dirroot . '/mod/quiz/addrandomform.php'); require_once($CFG->dirroot . '/question/category_class.php'); + /** * Callback function called from question_list() function * (which is called from showbank()) @@ -74,7 +71,7 @@ function module_specific_buttons($cmid, $cmoptions) { * (which is called from showbank()) */ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmoptions) { - global $QTYPES, $OUTPUT; + global $OUTPUT; $out = ''; $catcontext = get_context_instance_by_id($category->contextid); if (has_capability('moodle/question:useall', $catcontext)) { @@ -84,7 +81,8 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo $disabled = ''; } $randomusablequestions = - $QTYPES['random']->get_usable_questions_from_category($category->id, $recurse, '0'); + question_bank::get_qtype('random')->get_available_questions_from_category( + $category->id, $recurse); $maxrand = count($randomusablequestions); if ($maxrand > 0) { for ($i = 1; $i <= min(10, $maxrand); $i++) { @@ -120,6 +118,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo list($thispageurl, $contexts, $cmid, $cm, $quiz, $pagevars) = question_edit_setup('editq', '/mod/quiz/edit.php', true); +$quiz->questions = quiz_clean_layout($quiz->questions); $defaultcategoryobj = question_make_default_categories($contexts->all()); $defaultcategory = $defaultcategoryobj->id . ',' . $defaultcategoryobj->contextid; @@ -164,7 +163,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo // You need mod/quiz:manage in addition to question capabilities to access this page. require_capability('mod/quiz:manage', $contexts->lowest()); -if (empty($quiz->grades)) { // Construct an array to hold all the grades. +if (empty($quiz->grades)) { $quiz->grades = quiz_get_all_question_grades($quiz); } @@ -186,13 +185,15 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo if (($up = optional_param('up', false, PARAM_INT)) && confirm_sesskey()) { $quiz->questions = quiz_move_question_up($quiz->questions, $up); - quiz_save_new_layout($quiz); + $DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id)); + quiz_delete_previews($quiz); redirect($thispageurl); } if (($down = optional_param('down', false, PARAM_INT)) && confirm_sesskey()) { $quiz->questions = quiz_move_question_down($quiz->questions, $down); - quiz_save_new_layout($quiz); + $DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id)); + quiz_delete_previews($quiz); redirect($thispageurl); } @@ -200,15 +201,17 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo // Re-paginate the quiz $questionsperpage = optional_param('questionsperpage', $quiz->questionsperpage, PARAM_INT); $quiz->questions = quiz_repaginate($quiz->questions, $questionsperpage ); - quiz_save_new_layout($quiz); + $DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id)); + quiz_delete_previews($quiz); + redirect($thispageurl); } if (($addquestion = optional_param('addquestion', 0, PARAM_INT)) && confirm_sesskey()) { /// Add a single question to the current quiz $addonpage = optional_param('addonpage', 0, PARAM_INT); quiz_add_quiz_question($addquestion, $quiz, $addonpage); - quiz_update_sumgrades($quiz); quiz_delete_previews($quiz); + quiz_update_sumgrades($quiz); $thispageurl->param('lastchanged', $addquestion); redirect($thispageurl); } @@ -216,21 +219,17 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) { /// Add selected questions to the current quiz $rawdata = (array) data_submitted(); - foreach ($rawdata as $key => $value) { // Parse input for question ids + foreach ($rawdata as $key => $value) { // Parse input for question ids if (preg_match('!^q([0-9]+)$!', $key, $matches)) { $key = $matches[1]; quiz_add_quiz_question($key, $quiz); } } - quiz_update_sumgrades($quiz); quiz_delete_previews($quiz); + quiz_update_sumgrades($quiz); redirect($thispageurl); } -$qcobject = new question_category_object($pagevars['cpage'], $thispageurl, - $contexts->having_one_edit_tab_cap('categories'), $defaultcategoryobj->id, - $defaultcategory, null, $contexts->having_cap('moodle/question:add')); - if ((optional_param('addrandom', false, PARAM_BOOL)) && confirm_sesskey()) { // Add random questions to the quiz $recurse = optional_param('recurse', 0, PARAM_BOOL); @@ -239,8 +238,8 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo $randomcount = required_param('randomcount', PARAM_INT); quiz_add_random_questions($quiz, $addonpage, $categoryid, $randomcount, $recurse); - quiz_update_sumgrades($quiz); quiz_delete_previews($quiz); + quiz_update_sumgrades($quiz); redirect($thispageurl); } @@ -248,21 +247,24 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo foreach ($selectedquestionids as $questionid) { $quiz->questions = quiz_add_page_break_after($quiz->questions, $questionid); } - quiz_save_new_layout($quiz); + $DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id)); + quiz_delete_previews($quiz); redirect($thispageurl); } $addpage = optional_param('addpage', false, PARAM_INT); if ($addpage !== false && confirm_sesskey()) { $quiz->questions = quiz_add_page_break_at($quiz->questions, $addpage); - quiz_save_new_layout($quiz); + $DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id)); + quiz_delete_previews($quiz); redirect($thispageurl); } $deleteemptypage = optional_param('deleteemptypage', false, PARAM_INT); if (($deleteemptypage !== false) && confirm_sesskey()) { $quiz->questions = quiz_delete_empty_page($quiz->questions, $deleteemptypage); - quiz_save_new_layout($quiz); + $DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id)); + quiz_delete_previews($quiz); redirect($thispageurl); } @@ -278,12 +280,15 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo foreach ($selectedquestionids as $questionid) { quiz_remove_question($quiz, $questionid); } - quiz_update_sumgrades($quiz); quiz_delete_previews($quiz); + quiz_update_sumgrades($quiz); redirect($thispageurl); } if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) { + $deletepreviews = false; + $recomputesummarks = false; + $oldquestions = explode(',', $quiz->questions); // the questions in the old order $questions = array(); // for questions in the new order $rawdata = (array) data_submitted(); @@ -298,9 +303,9 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo /// Parse input for question -> grades $questionid = $matches[1]; $quiz->grades[$questionid] = clean_param($value, PARAM_FLOAT); - quiz_update_question_instance($quiz->grades[$questionid], $questionid, $quiz->id); - quiz_delete_previews($quiz); - quiz_update_sumgrades($quiz); + quiz_update_question_instance($quiz->grades[$questionid], $questionid, $quiz); + $deletepreviews = true; + $recomputesummarks = true; } else if (preg_match('!^o(pg)?([0-9]+)$!', $key, $matches)) { /// Parse input for ordering info @@ -317,6 +322,7 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo } else { $questions[$value] = $questionid; } + $deletepreviews = true; } } @@ -325,8 +331,8 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo ksort($questions); $questions[] = 0; $quiz->questions = implode(',', $questions); - quiz_save_new_layout($quiz); - quiz_delete_previews($quiz); + $DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id)); + $deletepreviews = true; } //get a list of questions to move, later to be added in the appropriate @@ -350,8 +356,8 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo $moveselectedpos = $pagebreakpositions[$moveselectedonpage - 1]; array_splice($questions, $moveselectedpos, 0, $selectedquestionids); $quiz->questions = implode(',', $questions); - quiz_save_new_layout($quiz); - quiz_delete_previews($quiz); + $DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id)); + $deletepreviews = true; } // If rescaling is required save the new maximum @@ -360,6 +366,15 @@ function module_specific_controls($totalnumber, $recurse, $category, $cmid, $cmo quiz_set_grade($maxgrade, $quiz); } + if ($deletepreviews) { + quiz_delete_previews($quiz); + } + if ($recomputesummarks) { + quiz_update_sumgrades($quiz); + quiz_update_all_attempt_sumgrades($quiz); + quiz_update_all_final_grades($quiz); + quiz_update_grades($quiz, 0, true); + } redirect($thispageurl); } diff --git a/mod/quiz/editlib.php b/mod/quiz/editlib.php index f93d9c0ef5ae9..13c80b7f8204f 100644 --- a/mod/quiz/editlib.php +++ b/mod/quiz/editlib.php @@ -1,37 +1,38 @@ . + /** - * Functions used by edit.php to edit quizzes + * This contains functions that are called from within the quiz module only + * Functions that are also called by core Moodle are in {@link lib.php} + * This script also loads the code in {@link questionlib.php} which holds + * the module-indpendent code for handling questions and which in turn + * initialises all the questiontype classes. * - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - * @package quiz - *//** */ + * @package mod + * @subpackage quiz + * @copyright 1999 onwards Martin Dougiamas and others {@link http://moodle.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + require_once($CFG->dirroot . '/mod/quiz/locallib.php'); + define('NUM_QS_TO_SHOW_IN_RANDOM', 3); /** @@ -141,15 +142,16 @@ function quiz_add_quiz_question($id, $quiz, $page = 0) { $quiz->questions = implode(',', $questions); $DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id)); - // update question grades - $quiz->grades[$id] = $DB->get_field('question', 'defaultgrade', array('id' => $id)); - quiz_update_question_instance($quiz->grades[$id], $id, $quiz->instance); - - return true; + // Add the new question instance. + $instance = new stdClass; + $instance->quiz = $quiz->id; + $instance->question = $id; + $instance->grade = $DB->get_field('question', 'defaultmark', array('id' => $id)); + $DB->insert_record('quiz_question_instances', $instance); } function quiz_add_random_questions($quiz, $addonpage, $categoryid, $number, $includesubcategories) { - global $DB, $QTYPES; + global $DB; $category = $DB->get_record('question_categories', array('id' => $categoryid)); if (!$category) { @@ -163,7 +165,7 @@ function quiz_add_random_questions($quiz, $addonpage, $categoryid, $number, $inc // not used by any quiz. if ($existingquestions = $DB->get_records_sql( "SELECT q.id,q.qtype FROM {question} q - WHERE qtype = '" . RANDOM . "' + WHERE qtype = 'random' AND category = ? AND " . $DB->sql_compare_text('questiontext') . " = ? AND NOT EXISTS (SELECT * FROM {quiz_question_instances} WHERE question = q.id) @@ -181,14 +183,14 @@ function quiz_add_random_questions($quiz, $addonpage, $categoryid, $number, $inc // More random questions are needed, create them. $form->questiontext = array('text' => $includesubcategories, 'format' => 0); - $form->defaultgrade = 1; + $form->defaultmark = 1; $form->hidden = 1; for ($i = 0; $i < $number; $i += 1) { $form->category = $category->id . ',' . $category->contextid; $form->stamp = make_unique_id_code(); // Set the unique code (not to be changed) $question = new stdClass; - $question->qtype = RANDOM; - $question = $QTYPES[RANDOM]->save_question($question, $form); + $question->qtype = 'random'; + $question = question_bank::get_qtype('random')->save_question($question, $form); if (!isset($question->id)) { print_error('cannotinsertrandomquestion', 'quiz'); } @@ -248,23 +250,29 @@ function quiz_save_new_layout($quiz) { * * Saves changes to the question grades in the quiz_question_instances table. * It does not update 'sumgrades' in the quiz table. - * @return boolean Indicates success or failure. + * * @param integer grade The maximal grade for the question * @param integer $questionid The id of the question * @param integer $quizid The id of the quiz to update / add the instances for. */ -function quiz_update_question_instance($grade, $questionid, $quizid) { - global $DB; - if ($instance = $DB->get_record('quiz_question_instances', array('quiz' => $quizid, 'question' => $questionid))) { - $instance->grade = $grade; - return $DB->update_record('quiz_question_instances', $instance); - } else { - unset($instance); - $instance->quiz = $quizid; - $instance->question = $questionid; - $instance->grade = $grade; - return $DB->insert_record('quiz_question_instances', $instance); +function quiz_update_question_instance($grade, $questionid, $quiz) { + $instance = $DB->get_record('quiz_question_instances', array('quiz' => $quizid, + 'question' => $questionid)); + $slot = quiz_get_slot_for_question($quiz, $questionid); + + if (!$instance || !$slot) { + throw new coding_exception('Attempt to change the grade of a quesion not in the quiz.'); } + + if (abs($grade - $instance->grade) < 1e-7) { + // Grade has not changed. Nothing to do. + return; + } + + $instance->grade = $grade; + $DB->update_record('quiz_question_instances', $instance); + question_engine::set_max_mark_in_attempts(new quibaid_for_quiz($quiz->id), + $slot, $grade); } // Private function used by the following two. @@ -330,7 +338,7 @@ function quiz_move_question_down($layout, $questionid) { */ function quiz_print_question_list($quiz, $pageurl, $allowdelete, $reordertool, $quiz_qbanktool, $hasattempts, $defaultcategoryobj) { - global $USER, $CFG, $QTYPES, $DB, $OUTPUT; + global $USER, $CFG, $DB, $OUTPUT; $strorder = get_string('order'); $strquestionname = get_string('questionname', 'quiz'); $strgrade = get_string('grade'); @@ -351,11 +359,12 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete, $reordertool, if ($quiz->questions) { list($usql, $params) = $DB->get_in_or_equal(explode(',', $quiz->questions)); - $questions = $DB->get_records_sql("SELECT q.*,c.contextid - FROM {question} q, - {question_categories} c - WHERE q.id $usql - AND q.category = c.id", $params); + $params[] = $quiz->id; + $questions = $DB->get_records_sql("SELECT q.*, qc.contextid, qqi.grade as maxmark + FROM {question} q + JOIN {question_categories} qc ON qc.id = q.category + JOIN {quiz_question_instances} qqi ON qqi.question = q.id + WHERE q.id $usql AND qqi.quiz = ?", $params); } else { $questions = array(); } @@ -429,20 +438,15 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete, $reordertool, $qno = 1; //the current question (includes questions and descriptions) $questioncount = 0; - //the ordinal of current element in the layout - //(includes page breaks, questions and descriptions) - $count = 0; //the current page number in iteration $pagecount = 0; - $sumgrade = 0; - $pageopen = false; $returnurl = str_replace($CFG->wwwroot, '', $pageurl->out(false)); $questiontotalcount = count($order); - foreach ($order as $i => $qnum) { + foreach ($order as $count => $qnum) { $reordercheckbox = ''; $reordercheckboxlabel = ''; @@ -451,10 +455,22 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete, $reordertool, if ($qnum && empty($questions[$qnum])) { continue; } + // If the questiontype is missing change the question type - if ($qnum && !array_key_exists($questions[$qnum]->qtype, $QTYPES)) { + if ($qnum && !array_key_exists($qnum, $questions)) { + $fakequestion = new stdClass(); + $fakequestion->id = 0; + $fakequestion->qtype = 'missingtype'; + $fakequestion->name = get_string('deletedquestion', 'qtype_missingtype'); + $fakequestion->questiontext = '

' . get_string('deletedquestion', 'qtype_missing') . '

'; + $fakequestion->length = 0; + $questions[$qnum] = $fakequestion; + $quiz->grades[$qnum] = 0; + + } else if ($qnum and question_bank::qtype_exists($questions[$qnum]->qtype)) { $questions[$qnum]->qtype = 'missingtype'; } + if ($qnum != 0 || ($qnum == 0 && !$pageopen)) { //this is either a question or a page break after another // (no page is currently open) @@ -466,7 +482,7 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete, $reordertool, '
'; $pageopen = true; } - if ($qnum == 0 && $i < $questiontotalcount) { + if ($qnum == 0 && $count < $questiontotalcount) { // This is the second successive page break. Tell the user the page is empty. echo '
'; print_string('noquestionsonpage', 'quiz'); @@ -474,7 +490,7 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete, $reordertool, if ($allowdelete) { echo '
'; echo '' . $strremove . ''; echo '
'; @@ -551,7 +567,7 @@ function quiz_print_question_list($quiz, $pageurl, $allowdelete, $reordertool, " alt=\"$strmovedown\" />"; } } - if ($allowdelete && question_has_capability_on($question, 'use', $question->category)) { + if ($allowdelete && (empty($question->id) || question_has_capability_on($question, 'use', $question->category))) { // remove from quiz, not question delete. if (!$hasattempts) { echo " grades[$qnum]; - } } //a page break: end the existing page. if ($qnum == 0) { if ($pageopen) { - if (!$reordertool && !($quiz->shufflequestions && $i < $questiontotalcount - 1)) { + if (!$reordertool && !($quiz->shufflequestions && $count < $questiontotalcount - 1)) { quiz_print_pagecontrols($quiz, $pageurl, $pagecount, $hasattempts, $defaultcategoryobj); - } else if ($i < $questiontotalcount - 1) { + } else if ($count < $questiontotalcount - 1) { //do not include the last page break for reordering //to avoid creating a new extra page in the end echo ''; echo quiz_question_edit_button($quiz->cmid, $question, $returnurl, quiz_question_tostring($question) . ' '); echo ''; - $namestr = $QTYPES[$question->qtype]->local_name(); print_question_icon($question); - echo " $namestr"; + echo ' ' . question_bank::get_qtype_name($question->qtype) . ''; echo '' . quiz_question_preview_button($quiz, $question, true) . ''; echo "
\n"; } @@ -752,7 +760,7 @@ function quiz_print_singlequestion($question, $returnurl, $quiz) { * @param boolean $quiz_qbanktool Indicate to this function if the question bank window open */ function quiz_print_randomquestion(&$question, &$pageurl, &$quiz, $quiz_qbanktool) { - global $DB, $QTYPES, $OUTPUT; + global $DB, $OUTPUT; echo '
'; if (!$category = $DB->get_record('question_categories', array('id' => $question->category))) { @@ -778,7 +786,7 @@ function quiz_print_randomquestion(&$question, &$pageurl, &$quiz, $quiz_qbanktoo echo '' . quiz_question_preview_button($quiz, $question, true) . ''; echo '
'; - $questionids = $QTYPES['random']->get_usable_questions_from_category( + $questionids = question_bank::get_qtype('random')->get_usable_questions_from_category( $category->id, $question->questiontext == '1', '0'); $questioncount = count($questionids); @@ -829,7 +837,6 @@ function quiz_print_randomquestion(&$question, &$pageurl, &$quiz, $quiz_qbanktoo echo '
'; echo '
'; echo '
'; - } /** @@ -860,14 +867,14 @@ function quiz_print_singlequestion_reordertool($question, $returnurl, $quiz) { * @param object $quiz The quiz in the context of which the question is being displayed */ function quiz_print_randomquestion_reordertool(&$question, &$pageurl, &$quiz) { - global $DB, $QTYPES, $OUTPUT; + global $DB, $OUTPUT; // Load the category, and the number of available questions in it. if (!$category = $DB->get_record('question_categories', array('id' => $question->category))) { echo $OUTPUT->notification('Random question category not found!'); return; } - $questioncount = count($QTYPES['random']->get_usable_questions_from_category( + $questioncount = count(question_bank::get_qtype('random')->get_usable_questions_from_category( $category->id, $question->questiontext == '1', '0')); $reordercheckboxlabel = '