Merge branch 'MDL-55358-master' of https://github.com/davidknu/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2017-10-11 00:00:10 +02:00
commit f8a86c157d

View File

@ -1248,6 +1248,8 @@ function lti_parse_custom_parameter($toolproxy, $tool, $params, $value, $islti2)
$value = str_replace('<br>' , ' ', $value);
$value = format_string($value);
}
} else {
$value = lti_calculate_custom_parameter($value1);
}
} else if ($islti2) {
$val = $value;
@ -1266,6 +1268,23 @@ function lti_parse_custom_parameter($toolproxy, $tool, $params, $value, $islti2)
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
*
@ -2557,7 +2576,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;