1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
namespace core_question\local\bank;
|
|
|
18 |
|
|
|
19 |
/**
|
|
|
20 |
* Class bulk_action_base is the base class for bulk actions ui.
|
|
|
21 |
*
|
|
|
22 |
* Every plugin wants to implement a bulk action, should extend this class, add appropriate values to the methods
|
|
|
23 |
* and finally pass this object via plugin_feature class.
|
|
|
24 |
*
|
|
|
25 |
* @package core_question
|
|
|
26 |
* @copyright 2021 Catalyst IT Australia Pty Ltd
|
|
|
27 |
* @author Safat Shahin <safatshahin@catalyst-au.net>
|
|
|
28 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
29 |
*/
|
|
|
30 |
abstract class bulk_action_base {
|
|
|
31 |
|
|
|
32 |
/**
|
|
|
33 |
* Title of the bulk action.
|
|
|
34 |
* Every bulk action will have a string to show in the list.
|
|
|
35 |
*
|
|
|
36 |
* @return string
|
|
|
37 |
*/
|
|
|
38 |
abstract public function get_bulk_action_title(): string;
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* A unique key for the bulk action, this will be used in the api to identify the action data.
|
|
|
42 |
* Every bulk must have a unique key to perform the action as a part of the form post in the base view.
|
|
|
43 |
* When questions are selected, it will post according to the key its selected from the dropdown.
|
|
|
44 |
*
|
|
|
45 |
* @return string
|
|
|
46 |
*/
|
|
|
47 |
abstract function get_key(): string;
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
* URL of the bulk action redirect page.
|
|
|
51 |
* Bulk action can be performed by redirecting to a page and doing the appropriate selection
|
|
|
52 |
* and finally doing the action. The url will be url of the page where users will be redirected to
|
|
|
53 |
* select what to do with the selected questions.
|
|
|
54 |
*
|
|
|
55 |
* @return \moodle_url
|
|
|
56 |
*/
|
|
|
57 |
abstract public function get_bulk_action_url(): \moodle_url;
|
|
|
58 |
|
|
|
59 |
/**
|
|
|
60 |
* Get the capabilities for the bulk action.
|
|
|
61 |
* The bulk actions might have some capabilities to action them as a user.
|
|
|
62 |
* This method helps to get those caps which will be used by the base view before actioning the bulk action.
|
|
|
63 |
* For ex: ['moodle/question:moveall', 'moodle/question:add']
|
|
|
64 |
* At least one of the cap need to be true for the user to use this action.
|
|
|
65 |
*
|
|
|
66 |
* @return array|null
|
|
|
67 |
*/
|
|
|
68 |
public function get_bulk_action_capabilities(): ?array {
|
|
|
69 |
return null;
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
/**
|
|
|
73 |
* @deprecated since Moodle 4.0
|
|
|
74 |
*/
|
|
|
75 |
public function get_bulk_action_key() {
|
|
|
76 |
throw new \coding_exception(__FUNCTION__ . '() has been removed.');
|
|
|
77 |
}
|
|
|
78 |
}
|