diff --git a/mod/lti/db/access.php b/mod/lti/db/access.php index 12e7941f502..f699c47ed11 100644 --- a/mod/lti/db/access.php +++ b/mod/lti/db/access.php @@ -71,6 +71,16 @@ $capabilities = array( ) ), + // When the user arrives at the external tool, if they have this capability + // in Moodle, then they are given the Administrator role in the remote system, + // otherwise they are given Learner. See the lti_get_ims_role function. + 'mod/lti:admin' => array( + 'riskbitmask' => RISK_PERSONAL, // A bit of a guess, but seems likely. + + 'captype' => 'write', + 'contextlevel' => CONTEXT_MODULE + ), + // The ability to create or edit tool configurations for particular courses. 'mod/lti:addcoursetool' => array( 'captype' => 'write', diff --git a/mod/lti/lang/en/lti.php b/mod/lti/lang/en/lti.php index 79a2ed20152..b262a269dff 100644 --- a/mod/lti/lang/en/lti.php +++ b/mod/lti/lang/en/lti.php @@ -243,6 +243,7 @@ $string['lti:addinstance'] = 'Add new external tool activities'; $string['lti:addcoursetool'] = 'Add course-specific tool configurations'; $string['lti:grade'] = 'View grades returned by the external tool'; $string['lti:manage'] = 'Be an Instructor when the tool is launched'; +$string['lti:admin'] = 'Be an Admininstrator when the tool is launched'; $string['lti:requesttooladd'] = 'Request a tool is configured site-wide'; $string['lti:view'] = 'Launch external tool activities'; $string['ltisettings'] = 'LTI settings'; diff --git a/mod/lti/locallib.php b/mod/lti/locallib.php index c526a9799d7..4254760559e 100644 --- a/mod/lti/locallib.php +++ b/mod/lti/locallib.php @@ -1319,7 +1319,9 @@ function lti_get_ims_role($user, $cmid, $courseid, $islti2) { } } - if (is_siteadmin($user)) { + if (is_siteadmin($user) || has_capability('mod/lti:admin', $context)) { + // Make sure admins do not have the Learner role, then set admin role. + $roles = array_diff($roles, array('Learner')); if (!$islti2) { array_push($roles, 'urn:lti:sysrole:ims/lis/Administrator', 'urn:lti:instrole:ims/lis/Administrator'); } else { diff --git a/mod/lti/version.php b/mod/lti/version.php index 00100c129ae..8199088690c 100644 --- a/mod/lti/version.php +++ b/mod/lti/version.php @@ -48,7 +48,7 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2017051500; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2017051600; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2017050500; // Requires this Moodle version. $plugin->component = 'mod_lti'; // Full name of the plugin (used for diagnostics). $plugin->cron = 0;