Merge branch 'master_MDL-60276' of https://github.com/CengageEng/moodle
authorAndrew Nicols <andrew@nicols.co.uk>
Wed, 11 Oct 2017 01:38:47 +0000 (09:38 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Wed, 11 Oct 2017 01:38:47 +0000 (09:38 +0800)
1  2 
mod/lti/locallib.php

diff --combined mod/lti/locallib.php
@@@ -889,12 -889,7 +889,7 @@@ function lti_tool_configuration_from_co
          }
          if (isset($item->url)) {
              $url = new moodle_url($item->url);
-             // Assign item URL to securetoolurl or toolurl depending on its scheme.
-             if (strtolower($url->get_scheme()) === 'https') {
-                 $config->securetoolurl = $url->out(false);
-             } else {
-                 $config->toolurl = $url->out(false);
-             }
+             $config->toolurl = $url->out(false);
              $config->typeid = 0;
          } else {
              $config->typeid = $typeid;
@@@ -1248,8 -1243,6 +1243,8 @@@ function lti_parse_custom_parameter($to
                              $value = str_replace('<br>' , ' ', $value);
                              $value = format_string($value);
                          }
 +                    } else {
 +                        $value = lti_calculate_custom_parameter($value1);
                      }
                  } else if ($islti2) {
                      $val = $value;
      return $value;
  }
  
 +/**
 + * Calculates the value of a custom parameter that has not been specified earlier
 + *
 + * @param string    $value          Custom parameter value
 + *
 + * @return string Calculated value of custom parameter
 + */
 +function lti_calculate_custom_parameter($value) {
 +    global $USER, $COURSE;
 +
 +    switch ($value) {
 +        case 'Moodle.Person.userGroupIds':
 +            return implode(",", groups_get_user_groups($COURSE->id, $USER->id)[0]);
 +    }
 +    return null;
 +}
 +
  /**
   * Used for building the names of the different custom parameters
   *
@@@ -2576,8 -2552,7 +2571,8 @@@ function lti_get_capabilities() 
         'Person.webaddress' => '$USER->url',
         'Membership.role' => 'roles',
         'Result.sourcedId' => 'lis_result_sourcedid',
 -       'Result.autocreate' => 'lis_outcome_service_url');
 +       'Result.autocreate' => 'lis_outcome_service_url',
 +       'Moodle.Person.userGroupIds' => null);
  
      return $capabilities;