Skip to content

Commit

Permalink
MDL-75126 core_question: Deprecate get_bulk_action_key
Browse files Browse the repository at this point in the history
This commit will deprecate get_bulk_action_key and move
the implementation in the get_key method entirely by
making this an absract method.
  • Loading branch information
safatshahin committed Nov 10, 2022
1 parent c3245f6 commit cf7d613
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
20 changes: 8 additions & 12 deletions question/classes/local/bank/bulk_action_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ abstract public function get_bulk_action_title(): string;
*
* @return string
*/
public function get_bulk_action_key(): string {
return '';
}
abstract function get_key(): string;

/**
* URL of the bulk action redirect page.
Expand All @@ -71,21 +69,19 @@ public function get_bulk_action_capabilities(): ?array {
return null;
}


/**
* A unique key for the bulk action, this will be used in the api to identify the action data.
* Every bulk must have a unique key to perform the action as a part of the form post in the base view.
* When questions are selected, it will post according to the key its selected from the dropdown.
*
* Note: This method is the first towards moving from get_bulk_action_key() to get_key().
*
* @return string
* @deprecated since Moodle 4.1
* @see get_key()
* @todo Final deprecation on Moodle 4.5 MDL-72438
*/
public function get_key(): string {
if (!empty($this->get_bulk_action_key())) {
return $this->get_bulk_action_key();
}
throw new \coding_exception('Bulk actions must implement the get_key() or get_bulk_action_key() method.
In Moodle 4.1, get_bulk_action_key() is being deprecated and replaced by get_key().');
public function get_bulk_action_key() {
debugging("The method get_bulk_action_key() in bulk_action_base class is deprecated.
Please use the abstract method get_key() instead.", DEBUG_DEVELOPER);
return $this->get_key();
}
}
7 changes: 4 additions & 3 deletions question/classes/local/bank/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,10 @@ protected function init_bulk_actions(): void {
$pluginentrypoint = new $plugin();
$bulkactions = $pluginentrypoint->get_bulk_actions();
if (!is_array($bulkactions)) {
debugging("The method {$componentname}::get_bulk_actions() must return an array of bulk actions instead of
a single bulk action. Please update your implementation of get_bulk_actions() to return an array. Check out the
qbank_bulkmove plugin for a working example.", DEBUG_DEVELOPER);
debugging("The method {$componentname}::get_bulk_actions() must return an " .
"array of bulk actions instead of a single bulk action. " .
"Please update your implementation of get_bulk_actions() to return an array. " .
"Check out the qbank_bulkmove plugin for a working example.", DEBUG_DEVELOPER);
$bulkactions = [$bulkactions];
}

Expand Down
4 changes: 4 additions & 0 deletions question/upgrade.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
This files describes API changes for code that uses the question API.

=== 4.1 ===

1) get_bulk_action_key() in core_question\local\bank\bulk_action_base class is deprecated and renamed to get_key().

=== 4.0.5 ===

1) Question bank plugins can now define more than one bulk action. Therefore, plugin_features_base::get_bulk_actions has been
Expand Down

0 comments on commit cf7d613

Please sign in to comment.