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

This commit is contained in:
Jun Pataleta 2023-09-20 16:22:53 +02:00
commit 9c4435e874
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7
2 changed files with 20 additions and 7 deletions

View File

@ -75,10 +75,20 @@ class course_external_tools_list extends system_report {
$paramprefix = database::generate_param_name();
$coursevisibleparam = database::generate_param_name();
$categoryparam = database::generate_param_name();
$toolstateparam = 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}) ".
"AND ({$cattablealias}.id IS NULL OR {$cattablealias}.categoryid = :{$categoryparam})";
$params = array_merge($params, [$coursevisibleparam => LTI_COURSEVISIBLE_NO, $categoryparam => $this->course->category]);
$wheresql = "{$entitymainalias}.course {$insql} ".
"AND {$entitymainalias}.coursevisible NOT IN (:{$coursevisibleparam}) ".
"AND ({$cattablealias}.id IS NULL OR {$cattablealias}.categoryid = :{$categoryparam}) ".
"AND {$entitymainalias}.state = :{$toolstateparam}";
$params = array_merge(
$params,
[
$coursevisibleparam => LTI_COURSEVISIBLE_NO,
$categoryparam => $this->course->category,
$toolstateparam => LTI_TOOL_STATE_CONFIGURED
]
);
$this->add_base_condition_sql($wheresql, $params);
$this->set_downloadable(false, get_string('pluginname', 'mod_lti'));

View File

@ -34,11 +34,13 @@ Feature: Manage course tools
And I should see "A short description of the tool" in the "Teaching Tool 1" "table_row"
Scenario: Viewing a site level tool in the course tools table
# The first tool isn't visible in courses, the next two are, and the last tool is in a pending state and is not visible.
Given the following "mod_lti > tool types" exist:
| name | description | baseurl | coursevisible |
| Example tool | Another description | https://example.com/tool1 | 0 |
| Test tool 2 | Tool2 description | https://example.com/tool2 | 1 |
| Test tool 3 | Tool3 description | https://example.com/tool3 | 2 |
| name | description | baseurl | coursevisible | state |
| Example tool | Another description | https://example.com/tool1 | 0 | 1 |
| Test tool 2 | Tool2 description | https://example.com/tool2 | 1 | 1 |
| Test tool 3 | Tool3 description | https://example.com/tool3 | 2 | 1 |
| Test tool 4 | Tool4 description | https://example.com/tool4 | 2 | 2 |
And I am on the "Course 1" course page logged in as teacher1
When I navigate to "LTI External tools" in current page administration
Then I should see "Test tool 2" in the "reportbuilder-table" "table"
@ -46,6 +48,7 @@ Feature: Manage course tools
And I should see "Test tool 3" in the "reportbuilder-table" "table"
And "You don't have permission to edit this tool" "icon" should exist in the "Test tool 3" "table_row"
And I should not see "Example tool" in the "reportbuilder-table" "table"
And I should not see "Test tool 4" in the "reportbuilder-table" "table"
Scenario: Viewing course tools without the capability to add/edit but having the capability to use
Given the following "role capability" exists: