Merge branch 'MDL-78753-master' of https://github.com/snake/moodle

This commit is contained in:
Huong Nguyen 2023-08-15 16:41:48 +07:00 committed by Sara Arjona
commit 8ecb766d53
No known key found for this signature in database
4 changed files with 17 additions and 4 deletions

View File

@ -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'));

View File

@ -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'));
}

View File

@ -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', ''));

View File

@ -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: