diff --git a/mod/lti/classes/reportbuilder/local/systemreports/course_external_tools_list.php b/mod/lti/classes/reportbuilder/local/systemreports/course_external_tools_list.php index abc4cbf8be6..01ff5baa114 100644 --- a/mod/lti/classes/reportbuilder/local/systemreports/course_external_tools_list.php +++ b/mod/lti/classes/reportbuilder/local/systemreports/course_external_tools_list.php @@ -37,7 +37,8 @@ class course_external_tools_list extends system_report { * Initialise report, we need to set the main table, load our entities and set columns/filters */ protected function initialise(): void { - global $DB; + global $DB, $CFG; + require_once($CFG->dirroot . '/mod/lti/locallib.php'); $this->course = get_course($this->get_context()->instanceid); @@ -61,7 +62,7 @@ class course_external_tools_list extends system_report { $coursevisibleparam = database::generate_param_name(); [$insql, $params] = $DB->get_in_or_equal([get_site()->id, $this->course->id], SQL_PARAMS_NAMED, "{$paramprefix}_"); $wheresql = "{$entitymainalias}.course {$insql} AND {$entitymainalias}.coursevisible NOT IN (:{$coursevisibleparam})"; - $params = array_merge($params, [$coursevisibleparam => 0]); + $params = array_merge($params, [$coursevisibleparam => LTI_COURSEVISIBLE_NO]); $this->add_base_condition_sql($wheresql, $params); $this->set_downloadable(false, get_string('pluginname', 'mod_lti')); diff --git a/mod/lti/coursetools.php b/mod/lti/coursetools.php index e1192d0b633..dbd3e6a0e6e 100644 --- a/mod/lti/coursetools.php +++ b/mod/lti/coursetools.php @@ -35,7 +35,7 @@ $course = get_course($id); require_course_login($course, false); $context = context_course::instance($course->id); -if (!has_any_capability(['mod/lti:addpreconfiguredinstance', 'mod/lti:addcoursetool'], $context)) { +if (!has_capability('mod/lti:addpreconfiguredinstance', $context)) { throw new \moodle_exception('nopermissions', 'error', '', get_string('courseexternaltoolsnoviewpermissions', 'mod_lti')); } diff --git a/mod/lti/lib.php b/mod/lti/lib.php index 4d6951af5fb..bf7b379eb22 100644 --- a/mod/lti/lib.php +++ b/mod/lti/lib.php @@ -775,7 +775,7 @@ function mod_lti_core_calendar_provide_event_action(calendar_event $event, * @return void */ function mod_lti_extend_navigation_course($navigation, $course, $context): void { - if (has_any_capability(['mod/lti:addpreconfiguredinstance', 'mod/lti:addcoursetool'], $context)) { + if (has_capability('mod/lti:addpreconfiguredinstance', $context)) { $url = new moodle_url('/mod/lti/coursetools.php', ['id' => $course->id]); $settingsnode = navigation_node::create(get_string('courseexternaltools', 'mod_lti'), $url, navigation_node::TYPE_SETTING, null, 'coursetools', new pix_icon('i/settings', '')); diff --git a/mod/lti/tests/behat/managecoursetools.feature b/mod/lti/tests/behat/managecoursetools.feature index 78492e9eb64..8276b7d9b59 100644 --- a/mod/lti/tests/behat/managecoursetools.feature +++ b/mod/lti/tests/behat/managecoursetools.feature @@ -59,6 +59,18 @@ Feature: Manage course tools When I navigate to "LTI External tools" in current page administration Then "You don't have permission to edit this tool" "icon" should exist in the "Test tool" "table_row" + Scenario: Viewing course tools with the capability to add/edit and without the capability to use + Given the following "role capability" exists: + | role | editingteacher | + | mod/lti:addcoursetool | allow | + | mod/lti:addmanualinstance | allow | + | mod/lti:addpreconfiguredinstance | prohibit | + And the following "mod_lti > course tools" exist: + | name | description | baseurl | course | + | Test tool | Example description | https://example.com/tool | C1 | + When I am on the "Course 1" course page logged in as teacher1 + Then "LTI External tools" "link" should not exist in current page administration + @javascript Scenario: Edit a course tool Given the following "mod_lti > course tools" exist: