From 58ad3e449c3f1c7c0ccb3a70a0cebbc4c0d763a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20B=C3=B6sch?= Date: Thu, 5 Sep 2024 07:49:44 +0200 Subject: [PATCH] Fix coding style and Moodle documentation issues. --- classes/plugin_feature.php | 6 ++++- classes/privacy/provider.php | 6 +++++ classes/xmlexport.php | 28 ++++++++++++++++++++++ tests/behat/bulk_xml_export_action.feature | 20 +++++++++------- version.php | 1 + 5 files changed, 51 insertions(+), 10 deletions(-) diff --git a/classes/plugin_feature.php b/classes/plugin_feature.php index 74f24a4..8fad807 100644 --- a/classes/plugin_feature.php +++ b/classes/plugin_feature.php @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - namespace qbank_bulkxmlexport; use core_question\local\bank\plugin_features_base; @@ -27,6 +26,11 @@ */ class plugin_feature extends plugin_features_base { + /** + * This method will return the array objects for the bulk actions ui. + * + * @return bulk_action_base[] + */ public function get_bulk_actions(): array { return [ new xmlexport(), diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 8c0215e..f948a17 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -26,6 +26,12 @@ */ class provider implements \core_privacy\local\metadata\null_provider { + /** + * Get the language string identifier with the component's language + * file to explain why this plugin stores no data. + * + * @return string + */ public static function get_reason(): string { return 'privacy:metadata'; } diff --git a/classes/xmlexport.php b/classes/xmlexport.php index 74e011b..78db5cf 100644 --- a/classes/xmlexport.php +++ b/classes/xmlexport.php @@ -25,21 +25,49 @@ */ class xmlexport extends \core_question\local\bank\bulk_action_base { + /** + * The key for the action. + */ public const KEY = 'bulkxmlexport'; + + /** + * The URL for the action. + */ public const URL = '/question/bank/bulkxmlexport/export.php'; + /** + * Return the string to show in the list. + * + * @return string + * @throws \coding_exception + */ public function get_bulk_action_title(): string { return get_string('exportasxml', 'question'); } + /** + * Return the key for the action. + * + * @return string + */ public function get_key(): string { return self::KEY; } + /** + * Return the URL of the bulk action redirect page. + * + * @return \moodle_url + */ public function get_bulk_action_url(): \moodle_url { return new \moodle_url(self::URL); } + /** + * Get the capabilities for the bulk action. + * + * @return string[]|null + */ public function get_bulk_action_capabilities(): ?array { return [ 'moodle/question:viewall', diff --git a/tests/behat/bulk_xml_export_action.feature b/tests/behat/bulk_xml_export_action.feature index e8226fe..1718ebc 100644 --- a/tests/behat/bulk_xml_export_action.feature +++ b/tests/behat/bulk_xml_export_action.feature @@ -2,27 +2,29 @@ Feature: Use the plugin to export several question at once in the qbank manager. Background: - Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | Teacher | 1 | teacher1@example.com | - And the following "courses" exist: + 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 "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | activity | name | course | idnumber | + | quiz | Test quiz | C1 | quiz1 | And the following "question categories" exist: | contextlevel | reference | questioncategory | name | + | Course | C1 | Test questions | testquestions | | Course | C1 | Top | top | | Course | C1 | top | Default for C1 | | Course | C1 | Default for C1 | Subcategory | And the following "questions" exist: | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | First question | Answer the first question | | Default for C1 | truefalse | First question | Answer the first question | | Subcategory | essay | Essay Foo Bar | Write about whatever you want | + And the following "users" exist: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@example.com | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | Scenario: Enable/disable bulk export xml questions bulk action from the base view Given I log in as "admin" diff --git a/version.php b/version.php index 38f2182..eaee0e9 100644 --- a/version.php +++ b/version.php @@ -18,6 +18,7 @@ * Version information for qbank_bulkxmlexport. * * @package qbank_bulkxmlexport + * @copyright 2024 Stephan Robotta * @author 2024 Stephan Robotta * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */