Skip to content

Commit

Permalink
Fix coding style and Moodle documentation issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed Sep 5, 2024
1 parent 0f1eac2 commit ca06c49
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 10 deletions.
6 changes: 5 additions & 1 deletion classes/plugin_feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// 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_bulkxmlexport;
use core_question\local\bank\plugin_features_base;

Expand All @@ -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(),
Expand Down
6 changes: 6 additions & 0 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
28 changes: 28 additions & 0 deletions classes/xmlexport.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
20 changes: 11 additions & 9 deletions tests/behat/bulk_xml_export_action.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 | Top | top |
| Course | C1 | top | Default for C1 |
| Course | C1 | Default for C1 | Subcategory |
| Course | C1 | Test questions | testquestions |
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"
Expand Down
1 change: 1 addition & 0 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit ca06c49

Please sign in to comment.