mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
MDL-76602 mod_lti: move lti13 claim declaration in subplugin
This commit is contained in:
parent
1d863c338a
commit
e56fec2662
@ -353,6 +353,16 @@ abstract class service_base {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of key/claim mapping allowing LTI 1.1 custom parameters
|
||||
* to be transformed to LTI 1.3 claims.
|
||||
*
|
||||
* @return array Key/value pairs of params to claim mapping.
|
||||
*/
|
||||
public function get_jwt_claim_mappings(): array {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path for service requests.
|
||||
*
|
||||
|
@ -126,7 +126,12 @@ function lti_get_jwt_message_type_mapping() {
|
||||
* @return array
|
||||
*/
|
||||
function lti_get_jwt_claim_mapping() {
|
||||
return array(
|
||||
$mapping = [];
|
||||
$services = lti_get_services();
|
||||
foreach ($services as $service) {
|
||||
$mapping = array_merge($mapping, $service->get_jwt_claim_mappings());
|
||||
}
|
||||
$mapping = array_merge($mapping, array(
|
||||
'accept_copy_advice' => [
|
||||
'suffix' => 'dl',
|
||||
'group' => 'deep_linking_settings',
|
||||
@ -443,74 +448,9 @@ function lti_get_jwt_claim_mapping() {
|
||||
'group' => 'tool_platform',
|
||||
'claim' => 'url',
|
||||
'isarray' => false
|
||||
],
|
||||
'custom_context_memberships_v2_url' => [
|
||||
'suffix' => 'nrps',
|
||||
'group' => 'namesroleservice',
|
||||
'claim' => 'context_memberships_url',
|
||||
'isarray' => false
|
||||
],
|
||||
'custom_context_memberships_versions' => [
|
||||
'suffix' => 'nrps',
|
||||
'group' => 'namesroleservice',
|
||||
'claim' => 'service_versions',
|
||||
'isarray' => true
|
||||
],
|
||||
'custom_gradebookservices_scope' => [
|
||||
'suffix' => 'ags',
|
||||
'group' => 'endpoint',
|
||||
'claim' => 'scope',
|
||||
'isarray' => true
|
||||
],
|
||||
'custom_lineitems_url' => [
|
||||
'suffix' => 'ags',
|
||||
'group' => 'endpoint',
|
||||
'claim' => 'lineitems',
|
||||
'isarray' => false
|
||||
],
|
||||
'custom_lineitem_url' => [
|
||||
'suffix' => 'ags',
|
||||
'group' => 'endpoint',
|
||||
'claim' => 'lineitem',
|
||||
'isarray' => false
|
||||
],
|
||||
'custom_results_url' => [
|
||||
'suffix' => 'ags',
|
||||
'group' => 'endpoint',
|
||||
'claim' => 'results',
|
||||
'isarray' => false
|
||||
],
|
||||
'custom_result_url' => [
|
||||
'suffix' => 'ags',
|
||||
'group' => 'endpoint',
|
||||
'claim' => 'result',
|
||||
'isarray' => false
|
||||
],
|
||||
'custom_scores_url' => [
|
||||
'suffix' => 'ags',
|
||||
'group' => 'endpoint',
|
||||
'claim' => 'scores',
|
||||
'isarray' => false
|
||||
],
|
||||
'custom_score_url' => [
|
||||
'suffix' => 'ags',
|
||||
'group' => 'endpoint',
|
||||
'claim' => 'score',
|
||||
'isarray' => false
|
||||
],
|
||||
'lis_outcome_service_url' => [
|
||||
'suffix' => 'bo',
|
||||
'group' => 'basicoutcome',
|
||||
'claim' => 'lis_outcome_service_url',
|
||||
'isarray' => false
|
||||
],
|
||||
'lis_result_sourcedid' => [
|
||||
'suffix' => 'bo',
|
||||
'group' => 'basicoutcome',
|
||||
'claim' => 'lis_result_sourcedid',
|
||||
'isarray' => false
|
||||
],
|
||||
);
|
||||
]
|
||||
));
|
||||
return $mapping;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,4 +90,25 @@ class basicoutcomes extends \mod_lti\local\ltiservice\service_base {
|
||||
return [self::SCOPE_BASIC_OUTCOMES];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of key/claim mapping allowing LTI 1.1 custom parameters
|
||||
* to be transformed to LTI 1.3 claims.
|
||||
*
|
||||
* @return array Key/value pairs of params to claim mapping.
|
||||
*/
|
||||
public function get_jwt_claim_mappings(): array {
|
||||
return array('lis_outcome_service_url' => [
|
||||
'suffix' => 'bo',
|
||||
'group' => 'basicoutcome',
|
||||
'claim' => 'lis_outcome_service_url',
|
||||
'isarray' => false
|
||||
],
|
||||
'lis_result_sourcedid' => [
|
||||
'suffix' => 'bo',
|
||||
'group' => 'basicoutcome',
|
||||
'claim' => 'lis_result_sourcedid',
|
||||
'isarray' => false
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -183,6 +183,58 @@ class gradebookservices extends service_base {
|
||||
return [$targetlinkuri, $customstr];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of key/claim mapping allowing LTI 1.1 custom parameters
|
||||
* to be transformed to LTI 1.3 claims.
|
||||
*
|
||||
* @return array Key/value pairs of params to claim mapping.
|
||||
*/
|
||||
public function get_jwt_claim_mappings(): array {
|
||||
return array('custom_gradebookservices_scope' => [
|
||||
'suffix' => 'ags',
|
||||
'group' => 'endpoint',
|
||||
'claim' => 'scope',
|
||||
'isarray' => true
|
||||
],
|
||||
'custom_lineitems_url' => [
|
||||
'suffix' => 'ags',
|
||||
'group' => 'endpoint',
|
||||
'claim' => 'lineitems',
|
||||
'isarray' => false
|
||||
],
|
||||
'custom_lineitem_url' => [
|
||||
'suffix' => 'ags',
|
||||
'group' => 'endpoint',
|
||||
'claim' => 'lineitem',
|
||||
'isarray' => false
|
||||
],
|
||||
'custom_results_url' => [
|
||||
'suffix' => 'ags',
|
||||
'group' => 'endpoint',
|
||||
'claim' => 'results',
|
||||
'isarray' => false
|
||||
],
|
||||
'custom_result_url' => [
|
||||
'suffix' => 'ags',
|
||||
'group' => 'endpoint',
|
||||
'claim' => 'result',
|
||||
'isarray' => false
|
||||
],
|
||||
'custom_scores_url' => [
|
||||
'suffix' => 'ags',
|
||||
'group' => 'endpoint',
|
||||
'claim' => 'scores',
|
||||
'isarray' => false
|
||||
],
|
||||
'custom_score_url' => [
|
||||
'suffix' => 'ags',
|
||||
'group' => 'endpoint',
|
||||
'claim' => 'score',
|
||||
'isarray' => false
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an array of key/values to add to the launch parameters.
|
||||
*
|
||||
|
@ -551,4 +551,24 @@ class memberships extends \mod_lti\local\ltiservice\service_base {
|
||||
return $launchparameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of key/claim mapping allowing LTI 1.1 custom parameters
|
||||
* to be transformed to LTI 1.3 claims.
|
||||
*
|
||||
* @return array Key/value pairs of params to claim mapping.
|
||||
*/
|
||||
public function get_jwt_claim_mappings(): array {
|
||||
return array('custom_context_memberships_v2_url' => [
|
||||
'suffix' => 'nrps',
|
||||
'group' => 'namesroleservice',
|
||||
'claim' => 'context_memberships_url',
|
||||
'isarray' => false
|
||||
],
|
||||
'custom_context_memberships_versions' => [
|
||||
'suffix' => 'nrps',
|
||||
'group' => 'namesroleservice',
|
||||
'claim' => 'service_versions',
|
||||
'isarray' => true
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -1026,8 +1026,8 @@ class locallib_test extends mod_lti_testcase {
|
||||
'isarray' => false
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertEquals($mapping, lti_get_jwt_claim_mapping());
|
||||
$actual = lti_get_jwt_claim_mapping();
|
||||
$this->assertEquals($mapping, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,10 @@
|
||||
This files describes API changes in the lti code.
|
||||
|
||||
=== 4.2 ===
|
||||
|
||||
* get_jwt_claim_mappings() function has been added to service_base class. It allows a service subplugin to be
|
||||
compatible with LTI 1.3 by exposing its 1.1 custom parameters to LTI 1.3 claim mapping.
|
||||
|
||||
=== 4.1 ===
|
||||
|
||||
* The callback get_shortcuts() is now removed. Please use get_course_content_items and get_all_content_items instead.
|
||||
|
Loading…
x
Reference in New Issue
Block a user