MDL-68011 course: Final deprecation of the callback get_shortcuts()

Removal of the callback get_shortcuts() and its plugin implementations.
The private methods in the content_item_readonly_repository class
which were only used by the callback hook logic are also removed.
This commit is contained in:
Mihail Geshoski 2022-06-17 13:53:40 +08:00
parent 2ca262a5e3
commit 6a122984da
7 changed files with 46 additions and 143 deletions

32
mod/lti/deprecatedlib.php Normal file
View file

@ -0,0 +1,32 @@
<?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/>.
/**
* List of deprecated mod_lti functions.
*
* @package mod_lti
* @copyright 2022 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* @deprecated since 3.9
**/
function lti_get_shortcuts() {
throw new coding_exception(
'The callback get_shortcuts() is now removed. Please use get_course_content_items and get_all_content_items instead.'
);
}

View file

@ -225,39 +225,6 @@ function lti_delete_instance($id) {
}
/**
* Return aliases of this activity. LTI should have an alias for each configured tool type
* This is so you can add an external tool types directly to the activity chooser
*
* @deprecated since 3.9
* @todo MDL-68011 This is to be moved from here to deprecatedlib.php in Moodle 4.1
* @param stdClass $defaultitem default item that would be added to the activity chooser if this callback was not present.
* It has properties: archetype, name, title, help, icon, link
* @return array An array of aliases for this activity. Each element is an object with same list of properties as $defaultitem,
* plus an additional property, helplink.
* Properties title and link are required
**/
function lti_get_shortcuts($defaultitem) {
global $CFG, $COURSE;
require_once($CFG->dirroot.'/mod/lti/locallib.php');
$types = lti_get_configured_types($COURSE->id, $defaultitem->link->param('sr'));
if (has_capability('mod/lti:addmanualinstance', context_course::instance($COURSE->id))) {
$types[] = $defaultitem;
}
// Add items defined in ltisource plugins.
foreach (core_component::get_plugin_list('ltisource') as $pluginname => $dir) {
// LTISOURCE plugins can also implement callback get_shortcuts() to add items to the activity chooser.
// The return values are the same as of the 'mod' callbacks except that $defaultitem is only passed for reference and
// should not be added to the return value.
if ($moretypes = component_callback("ltisource_$pluginname", 'get_shortcuts', array($defaultitem))) {
$types = array_merge($types, $moretypes);
}
}
return $types;
}
/**
* Return the preconfigured tools which are configured for inclusion in the activity picker.
*

View file

@ -1,6 +1,10 @@
This files describes API changes in /mod/lti/source/* - LTI source plugins,
information provided here is intended especially for developers.
=== 4.1 ===
* The callback get_shortcuts() is now removed. Please use get_course_content_items and get_all_content_items instead.
=== 3.9 ===
* The callback get_shortcuts() is now deprecated. Please use get_course_content_items and get_all_content_items instead.

View file

@ -1,5 +1,9 @@
This files describes API changes in the lti code.
=== 4.1 ===
* The callback get_shortcuts() is now removed. Please use get_course_content_items and get_all_content_items instead.
=== 3.10 ===
* Select Content supports multiple, allowing a tool to return more than one link at a time.