MDL-71679 mod_quiz: Updates for new qbank api

This implementation will introduct changes to
the mod_quiz to implement the new qbank api
for view. Major changes are introduced in
the custom view and also all the legacy points
to the old qbank are changed to qbank plugins
where needed. It also deprecated and deletes
classes and scripts which were kept not to
break mod_quiz for the new api implementation.
This commit is contained in:
Safat Shahin
2021-10-04 15:44:25 +11:00
parent 1a9bee69e6
commit f9fc355ec7
64 changed files with 286 additions and 5970 deletions
+10 -154
View File
@@ -108,7 +108,7 @@ function question_is_only_child_of_top_category_in_context($categoryid) {
has been deprecated and moved to qbank_managecategories plugin,
Please use qbank_managecategories\helper::question_is_only_child_of_top_category_in_context() instead.',
DEBUG_DEVELOPER);
return \qbank_managecategories\helper::question_is_only_child_of_top_category_in_contextt($categoryid);
return \qbank_managecategories\helper::question_is_only_child_of_top_category_in_context($categoryid);
}
/**
@@ -140,151 +140,6 @@ function question_can_delete_cat($todelete) {
\qbank_managecategories\helper::question_can_delete_cat($todelete);
}
/**
* Base class for representing a column in a {@see question_bank_view}.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since Moodle 2.7 MDL-40457
* @todo MDl-72004 delete the class alias, not done in MDL-71516 for any potential error from other plugins.
*/
class_alias('core_question\local\bank\column_base', 'question_bank_column_base', true);
/**
* A column with a checkbox for each question with name q{questionid}.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since Moodle 2.7 MDL-40457
* @todo MDl-72004 delete the class alias, not done in MDL-71516 for any potential error from other plugins.
*/
class_alias('core_question\local\bank\checkbox_column', 'question_bank_checkbox_column', true);
/**
* A column type for the name of the question type.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since Moodle 2.7 MDL-40457
* @todo MDl-72004 delete the class alias, not done in MDL-71516 for any potential error from other plugins.
*/
class_alias('qbank_viewquestiontype\question_type_column', 'question_bank_question_type_column', true);
/**
* A column type for the name of the question name.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since Moodle 2.7 MDL-40457
* @todo MDl-72004 delete the class alias, not done in MDL-71516 for any potential error from other plugins.
*/
class_alias('qbank_viewquestionname\viewquestionname_column_helper', 'question_bank_question_name_column', true);
/**
* A column type for the name of the question creator.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since Moodle 2.7 MDL-40457
* @todo MDl-72004 delete the class alias, not done in MDL-71516 for any potential error from other plugins.
*/
class_alias('qbank_viewcreator\creator_name_column', 'question_bank_creator_name_column', true);
/**
* A column type for the name of the question last modifier.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since Moodle 2.7 MDL-40457
* @todo MDl-72004 delete the class alias, not done in MDL-71516 for any potential error from other plugins.
*/
class_alias('qbank_viewcreator\modifier_name_column', 'question_bank_modifier_name_column', true);
/**
* A base class for actions that are an icon that lets you manipulate the question in some way.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since Moodle 2.7 MDL-40457
* @todo MDl-72004 delete the class alias, not done in MDL-71516 for any potential error from other plugins.
*/
class_alias('core_question\local\bank\action_column_base', 'question_bank_action_column_base', true);
/**
* Base class for question bank columns that just contain an action icon.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since Moodle 2.7 MDL-40457
* @todo MDl-72004 delete the class alias, not done in MDL-71516 for any potential error from other plugins.
*/
class_alias('qbank_editquestion\edit_action_column', 'question_bank_edit_action_column', true);
/**
* Question bank column for the duplicate action icon.
*
* @copyright 2013 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since Moodle 2.7 MDL-40457
* @todo MDl-72004 delete the class alias, not done in MDL-71516 for any potential error from other plugins.
*/
class_alias('qbank_editquestion\copy_action_column', 'question_bank_copy_action_column', true);
/**
* Question bank columns for the preview action icon.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since Moodle 2.7 MDL-40457
* @todo MDl-72004 delete the class alias, not done in MDL-71516 for any potential error from other plugins.
*/
class_alias('qbank_previewquestion\preview_action_column', 'question_bank_preview_action_column', true);
/**
* action to delete (or hide) a question, or restore a previously hidden question.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since Moodle 2.7 MDL-40457
* @todo MDl-72004 delete the class alias, not done in MDL-71516 for any potential error from other plugins.
*/
class_alias('core_question\bank\delete_action_column', 'question_bank_delete_action_column', true);
/**
* Base class for 'columns' that are actually displayed as a row following the main question row.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since Moodle 2.7 MDL-40457
* @todo MDl-72004 delete the class alias, not done in MDL-71516 for any potential error from other plugins.
*/
class_alias('core_question\local\bank\row_base', 'question_bank_row_base', true);
/**
* A column type for the name of the question name.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since Moodle 2.7 MDL-40457
* @todo MDl-72004 delete the class alias, not done in MDL-71516 for any potential error from other plugins.
*/
class_alias('qbank_viewquestiontext\question_text_row', 'question_bank_question_text_row', true);
/**
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated since Moodle 2.7 MDL-40457
* @todo MDl-72004 delete the class alias, not done in MDL-71516 for any potential error from other plugins.
*/
class_alias('core_question\local\bank\view', 'question_bank_view', true);
/**
* Common setup for all pages for editing questions.
* @param string $baseurl the name of the script calling this funciton. For examle 'qusetion/edit.php'.
@@ -322,7 +177,7 @@ function question_edit_setup($edittab, $baseurl, $requirecmid = false, $unused =
$params['qperpage'] = optional_param('qperpage', null, PARAM_INT);
// Question table sorting options.
for ($i = 1; $i <= question_bank_view::MAX_SORTS; $i++) {
for ($i = 1; $i <= core_question\local\bank\view::MAX_SORTS; $i++) {
$param = 'qbs' . $i;
if ($sort = optional_param($param, '', PARAM_TEXT)) {
$params[$param] = $sort;
@@ -371,7 +226,7 @@ function question_edit_setup($edittab, $baseurl, $requirecmid = false, $unused =
* 'qbs1' => PARAM_TEXT,
* 'qbs2' => PARAM_TEXT,
* 'qbs3' => PARAM_TEXT,
* ... and more qbs keys up to question_bank_view::MAX_SORTS ...
* ... and more qbs keys up to core_question\local\bank\view::MAX_SORTS ...
* ];
*
* @param string $edittab Code for this edit tab
@@ -481,7 +336,7 @@ function question_build_edit_resources($edittab, $baseurl, $params) {
// This need to occur after the override_active_url call above because
// these values change on the page request causing the URLs to mismatch
// when trying to work out the active node.
for ($i = 1; $i <= question_bank_view::MAX_SORTS; $i++) {
for ($i = 1; $i <= core_question\local\bank\view::MAX_SORTS; $i++) {
$param = 'qbs' . $i;
if (isset($params[$param])) {
$value = clean_param($params[$param], PARAM_TEXT);
@@ -637,12 +492,14 @@ function require_login_in_context($contextorid = null){
* those qtypes will be shown. Example value array('description', 'multichoice').
* @deprecated since Moodle 4.0
* @see \qbank_editquestion\editquestion_helper::print_choose_qtype_to_add_form()
* @todo MDL-72004 deprecate the function and add debugging message.
* @todo Final deprecation of this class in moodle 4.4 MDL-72438
*/
function print_choose_qtype_to_add_form($hiddenparams, array $allowedqtypes = null, $enablejs = true) {
debugging('Function print_choose_qtype_to_add_form() is deprecated,
please use \qbank_editquestion\editquestion_helper::print_choose_qtype_to_add_form() instead.', DEBUG_DEVELOPER);
global $CFG, $PAGE, $OUTPUT;
$chooser = core_question\output\qbank_chooser::get($PAGE->course, $hiddenparams, $allowedqtypes);
$chooser = \qbank_editquestion\qbank_chooser::get($PAGE->course, $hiddenparams, $allowedqtypes);
$renderer = $PAGE->get_renderer('question', 'bank');
return $renderer->render($chooser);
@@ -661,6 +518,7 @@ function print_choose_qtype_to_add_form($hiddenparams, array $allowedqtypes = nu
* @param bool $disabled if true, the button will be disabled.
* @deprecated since Moodle 4.0
* @see \qbank_editquestion\editquestion_helper::create_new_question_button()
* @todo Final deprecation of this class in moodle 4.4 MDL-72438
*/
function create_new_question_button($categoryid, $params, $caption, $tooltip = '', $disabled = false) {
debugging('Function create_new_question_button() has been deprecated and moved to bank/editquestion,
@@ -668,7 +526,7 @@ function create_new_question_button($categoryid, $params, $caption, $tooltip = '
global $CFG, $PAGE, $OUTPUT;
static $choiceformprinted = false;
$params['category'] = $categoryid;
$url = new moodle_url('/question/addquestion.php', $params);
$url = new moodle_url('/question/bank/editquestion/addquestion.php', $params);
echo $OUTPUT->single_button($url, $caption, 'get', array('disabled'=>$disabled, 'title'=>$tooltip));
if (!$choiceformprinted) {
@@ -678,5 +536,3 @@ function create_new_question_button($categoryid, $params, $caption, $tooltip = '
$choiceformprinted = true;
}
}