Skip to content

Commit

Permalink
LTI: Set AGS claim
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Dec 25, 2019
1 parent 1e21258 commit c41f2ed
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
30 changes: 27 additions & 3 deletions plugin/ims_lti/auth.php
Expand Up @@ -23,6 +23,9 @@

$em = Database::getManager();

$webPath = api_get_path(WEB_PATH);
$webPluginPath = api_get_path(WEB_PLUGIN_PATH);

try {
if (empty($scope) || empty($responseType) || empty($clientId) || empty($redirectUri) || empty($loginHint) ||
empty($nonce)
Expand Down Expand Up @@ -137,7 +140,7 @@
'name' => api_get_setting('siteName'),
'family_code' => 'Chamilo LMS',
'version' => api_get_version(),
'url' => api_get_path(WEB_PATH),
'url' => $webPath,
];

// Launch info
Expand Down Expand Up @@ -170,7 +173,7 @@
'title' => $tool->getName(),
'text' => $tool->getDescription(),
'data' => "tool:{$tool->getId()}",
'deep_link_return_url' => api_get_path(WEB_PLUGIN_PATH).'ims_lti/item_return2.php',
'deep_link_return_url' => $webPluginPath.'ims_lti/item_return2.php',
];
$jwtContent['https://purl.imsglobal.org/spec/lti/claim/target_link_uri'] = $tool->getRedirectUrl();
} else {
Expand All @@ -192,14 +195,35 @@
// 'lis_result_sourcedid' => json_encode(
// ['e' => $toolEval->getId(), 'u' => $user->getId(), 'l' => uniqid(), 'lt' => time()]
// ),
// 'lis_outcome_service_url' => api_get_path(WEB_PATH).'lti/os',
// 'lis_outcome_service_url' => $webPath.'lti/os',
//];

$jwtContent['https://purl.imsglobal.org/spec/lti/claim/lis'] = [
'person_sourcedid' => ImsLti::getPersonSourcedId($platformDomain, $user),
'course_section_sourcedid' => ImsLti::getCourseSectionSourcedId($platformDomain, $course, $session),
];
}

$advServices = $tool->getAdvantageServices();

if (!empty($advServices)) {
if (!empty($advServices['ags'])) {
$agsClaim = [
'scope' => [
'https://purl.imsglobal.org/spec/lti-ags/scope/lineitem',
'https://purl.imsglobal.org/spec/lti-ags/scope/result.readonly',
'https://purl.imsglobal.org/spec/lti-ags/scope/score',
],
'lineitems' => $webPluginPath."ims_lti/gradebook/service/lineitems.php?c=".$tool->getId(),
];

if (LtiAssignmentGradesService::AGS_FULL === $advServices['ags']) {
$agsClaim['lineitem'] = $webPluginPath."ims_lti/gradebook/service/lineitem.php?c=".$tool->getId();
}

$jwtContent['https://purl.imsglobal.org/spec/lti-ags/claim/endpoint'] = $agsClaim;
}
}
}

// Custom params info
Expand Down
5 changes: 5 additions & 0 deletions plugin/ims_lti/gradebook/service/lineitems.php
@@ -0,0 +1,5 @@
<?php
/* For licensing terms, see /license.txt */

require_once __DIR__.'/../../main/inc/global.inc.php';

0 comments on commit c41f2ed

Please sign in to comment.