Commit c4eb3bda authored by Safat Shahin's avatar Safat Shahin
Browse files

MDL-71577 qbank_viewquestiontype: Add View question type plugin to core

This implementation will introduce a qbank plugin "viewquestiontype"
which will view the question type column in the question bank view
by replacing the core class. Having this plugin will give users
the flexibility of enabling or disabling the question type
in the question bank view.
parent 206023c1
...@@ -1943,6 +1943,7 @@ class core_plugin_manager { ...@@ -1943,6 +1943,7 @@ class core_plugin_manager {
'editquestion', 'editquestion',
'exportquestions', 'exportquestions',
'importquestions', 'importquestions',
'viewquestiontype',
], ],
'qbehaviour' => array( 'qbehaviour' => array(
......
<?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 <http://www.gnu.org/licenses/>.
namespace qbank_viewquestiontype;
use core_question\local\bank\plugin_features_base;
/**
* Class plugin_feature is the entrypoint for the columns.
*
* @package qbank_viewquestiontype
* @copyright 2021 Catalyst IT Australia Pty Ltd
* @author Safat Shahin <safatshahin@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class plugin_feature extends plugin_features_base {
public function get_question_columns($qbank): array {
return [
new question_type_column($qbank)
];
}
}
<?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 <http://www.gnu.org/licenses/>.
namespace qbank_viewquestiontype\privacy;
/**
* Privacy Subsystem for qbank_viewquestiontype implementing null_provider.
*
* @package qbank_viewquestiontype
* @copyright 2021 Catalyst IT Australia Pty Ltd
* @author Safat Shahin <safatshahin@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
public static function get_reason(): string {
return 'privacy:metadata';
}
}
<?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 <http://www.gnu.org/licenses/>.
namespace qbank_viewquestiontype;
use core_question\local\bank\column_base;
/**
* A column with a type of question for each question with name q{questionid}.
*
* @package qbank_viewquestiontype
* @copyright 2009 Tim Hunt
* @author 2021 Safat Shahin <safatshahin@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class question_type_column extends column_base {
public function get_name(): string {
return 'qtype';
}
protected function get_title(): string {
return get_string('qtypeveryshort', 'question');
}
protected function get_title_tip(): string {
return get_string('questiontype', 'question');
}
protected function display_content($question, $rowclasses): void {
echo print_question_icon($question);
}
public function get_required_fields(): array {
return ['q.qtype'];
}
public function is_sortable() {
return 'q.qtype';
}
}
<?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 <http://www.gnu.org/licenses/>.
/**
* Strings for component qbank_viewquestiontype, language 'en'
*
* @package qbank_viewquestiontype
* @copyright 2021 Catalyst IT Australia Pty Ltd
* @author Safat Shahin <safatshahin@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'View question type';
$string['privacy:metadata'] = 'View question type question bank plugin does not store any user data.';
@qbank @qbank_viewquestiontype
Feature: Use the qbank plugin manager page for viewquestiontype
In order to check the plugin behaviour with enable and disable
Background:
Given the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "activities" exist:
| activity | name | course | idnumber |
| quiz | Test quiz | C1 | quiz1 |
And the following "question categories" exist:
| contextlevel | reference | name |
| Course | C1 | Test questions |
And the following "questions" exist:
| questioncategory | qtype | name | questiontext |
| Test questions | truefalse | First question | Answer the first question |
@javascript
Scenario: Enable/disable viewquestiontype column from the base view
Given I log in as "admin"
When I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration
And I should see "View question type"
And I click on "Disable" "link" in the "View question type" "table_row"
And I am on the "Test quiz" "quiz activity" page
And I navigate to "Question bank > Questions" in current page administration
Then "#categoryquestions .header.qtype" "css_element" should not be visible
And I navigate to "Plugins > Question bank plugins > Manage question bank plugins" in site administration
And I click on "Enable" "link" in the "View question type" "table_row"
And I am on the "Test quiz" "quiz activity" page
And I navigate to "Question bank > Questions" in current page administration
And "#categoryquestions .header.qtype" "css_element" should be visible
<?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 <http://www.gnu.org/licenses/>.
/**
* Version information for qbank_viewquestiontype.
*
* @package qbank_viewquestiontype
* @copyright 2021 Catalyst IT Australia Pty Ltd
* @author Safat Shahin <safatshahin@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'qbank_viewquestiontype';
$plugin->version = 2021070700;
$plugin->requires = 2021052500;
$plugin->maturity = MATURITY_STABLE;
...@@ -167,7 +167,7 @@ class_alias('core_question\local\bank\checkbox_column', 'question_bank_checkbox_ ...@@ -167,7 +167,7 @@ class_alias('core_question\local\bank\checkbox_column', 'question_bank_checkbox_
* @deprecated since Moodle 2.7 MDL-40457 * @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. * @todo MDl-72004 delete the class alias, not done in MDL-71516 for any potential error from other plugins.
*/ */
class_alias('core_question\bank\question_type_column', 'question_bank_question_type_column', true); class_alias('qbank_viewquestiontype\question_type_column', 'question_bank_question_type_column', true);
/** /**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment