Skip to content

Commit

Permalink
Merge branch 'MDL-78753-master' of https://github.com/snake/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
HuongNV13 authored and sarjona committed Aug 17, 2023
2 parents e1a6cdb + 1e886c3 commit 8ecb766
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -61,7 +62,7 @@ protected function initialise(): void {
$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'));
Expand Down
2 changes: 1 addition & 1 deletion mod/lti/coursetools.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
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'));
}

Expand Down
2 changes: 1 addition & 1 deletion mod/lti/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', ''));
Expand Down
12 changes: 12 additions & 0 deletions mod/lti/tests/behat/managecoursetools.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8ecb766

Please sign in to comment.