mirror of
https://github.com/moodle/moodle.git
synced 2025-04-15 13:33:52 +02:00
MDL-78597 mod_lti: let content item callbacks obey preconfigured cap
Users without the 'mod/lti:addpreconfiguredinstance' capability won't be able to see any mod_lti content items in the activity chooser. Note: this patch doesn't address the underlying locallib method, lti_get_lti_types_by_course(), which will be addressed elsewhere.
This commit is contained in:
parent
5b01727107
commit
85679c47da
@ -240,7 +240,12 @@ function lti_get_course_content_items(\core_course\local\entity\content_item $de
|
||||
|
||||
$types = [];
|
||||
|
||||
// Use of a tool type, whether site or course level, is controlled by the following cap.
|
||||
if (!has_capability('mod/lti:addpreconfiguredinstance', \core\context\course::instance($course->id), $user)) {
|
||||
return $types;
|
||||
}
|
||||
$preconfiguredtools = lti_get_configured_types($course->id, $defaultmodulecontentitem->get_link()->param('sr'));
|
||||
|
||||
foreach ($preconfiguredtools as $preconfiguredtool) {
|
||||
|
||||
// Append the help link to the help text.
|
||||
|
@ -435,6 +435,13 @@ class lib_test extends \advanced_testcase {
|
||||
$this->assertContains($course2toolrecord->id + 1, $ids);
|
||||
$this->assertNotContains($sitetoolrecordnonchooser->id + 1, $ids);
|
||||
|
||||
// Removing the capability to use preconfigured (site or course level) tools, should result in no content items.
|
||||
$teacherrole = $DB->get_record('role', array('shortname' => 'editingteacher'));
|
||||
assign_capability('mod/lti:addpreconfiguredinstance', CAP_PROHIBIT, $teacherrole->id,
|
||||
\core\context\course::instance($course2->id));
|
||||
$course2items = lti_get_course_content_items($defaultmodulecontentitem, $teacher2, $course2);
|
||||
$this->assertCount(0, $course2items);
|
||||
|
||||
// When fetching all content items, we expect to see all items available in activity choosers (in any course).
|
||||
$this->setAdminUser();
|
||||
$allitems = mod_lti_get_all_content_items($defaultmodulecontentitem);
|
||||
|
Loading…
x
Reference in New Issue
Block a user