Merge branch 'MDL-59485' of https://github.com/IMSGlobal/moodle
authorDavid Monllao <davidm@moodle.com>
Tue, 25 Jul 2017 09:11:09 +0000 (11:11 +0200)
committerDavid Monllao <davidm@moodle.com>
Tue, 25 Jul 2017 09:11:09 +0000 (11:11 +0200)
1  2 
mod/lti/locallib.php

diff --combined mod/lti/locallib.php
@@@ -386,11 -386,11 +386,11 @@@ function lti_build_request($instance, $
          'lis_person_sourcedid' => $USER->idnumber,
          'roles' => $role,
          'context_id' => $course->id,
 -        'context_label' => trim(html_to_text($course->shortname)),
 -        'context_title' => trim(html_to_text($course->fullname)),
 +        'context_label' => trim(html_to_text($course->shortname, 0)),
 +        'context_title' => trim(html_to_text($course->fullname, 0)),
      );
      if (!empty($instance->name)) {
 -        $requestparams['resource_link_title'] = trim(html_to_text($instance->name));
 +        $requestparams['resource_link_title'] = trim(html_to_text($instance->name, 0));
      }
      if (!empty($instance->cmid)) {
          $intro = format_module_intro('lti', $instance, $instance->cmid);
@@@ -531,11 -531,11 +531,11 @@@ function lti_build_standard_request($in
          $requestparams["tool_consumer_instance_guid"] = $orgid;
      }
      if (!empty($CFG->mod_lti_institution_name)) {
 -        $requestparams['tool_consumer_instance_name'] = trim(html_to_text($CFG->mod_lti_institution_name));
 +        $requestparams['tool_consumer_instance_name'] = trim(html_to_text($CFG->mod_lti_institution_name, 0));
      } else {
          $requestparams['tool_consumer_instance_name'] = get_site()->shortname;
      }
 -    $requestparams['tool_consumer_instance_description'] = trim(html_to_text(get_site()->fullname));
 +    $requestparams['tool_consumer_instance_description'] = trim(html_to_text(get_site()->fullname, 0));
  
      return $requestparams;
  }
@@@ -1302,9 -1302,9 +1302,9 @@@ function lti_get_ims_role($user, $cmid
          // If no cmid is passed, check if the user is a teacher in the course
          // This allows other modules to programmatically "fake" a launch without
          // a real LTI instance.
 -        $coursecontext = context_course::instance($courseid);
 +        $context = context_course::instance($courseid);
  
 -        if (has_capability('moodle/course:manageactivities', $coursecontext, $user)) {
 +        if (has_capability('moodle/course:manageactivities', $context, $user)) {
              array_push($roles, 'Instructor');
          } else {
              array_push($roles, 'Learner');
          }
      }
  
 -    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 {
@@@ -2522,7 -2520,13 +2522,13 @@@ function lti_get_capabilities() 
      $capabilities = array(
         'basic-lti-launch-request' => '',
         'ContentItemSelectionRequest' => '',
+        'ToolProxyRegistrationRequest' => '',
         'Context.id' => 'context_id',
+        'Context.title' => 'context_title',
+        'Context.label' => 'context_label',
+        'Context.sourcedId' => 'lis_course_section_sourcedid',
+        'Context.longDescription' => '$COURSE->summary',
+        'Context.timeFrame.begin' => '$COURSE->startdate',
         'CourseSection.title' => 'context_title',
         'CourseSection.label' => 'context_label',
         'CourseSection.sourcedId' => 'lis_course_section_sourcedid',