diff --git a/models/classes/LtiService.php b/models/classes/LtiService.php index 968a8491..846f63c1 100644 --- a/models/classes/LtiService.php +++ b/models/classes/LtiService.php @@ -28,6 +28,7 @@ use core_kernel_classes_Property; use core_kernel_classes_Resource; use oat\generis\model\GenerisRdf; +use OAT\Library\Lti1p3Core\Message\Payload\Claim\LaunchPresentationClaim; use OAT\Library\Lti1p3Core\Message\Payload\LtiMessagePayloadInterface; use OAT\Library\Lti1p3Core\Message\Payload\MessagePayloadInterface; use OAT\Library\Lti1p3Core\Registration\RegistrationRepositoryInterface; @@ -105,6 +106,7 @@ public function createLti1p3Session( $ltiUser->setUserFirstTimeUri(GenerisRdf::GENERIS_FALSE); $ltiUser->setUserLatestExtension(self::DEFAULT_USER_EXTENSION); + $userLatestExtensionValue = (string)$user->getOnePropertyValue($userLatestExtension); if (!empty($userLatestExtensionValue)) { $ltiUser->setUserLatestExtension($userLatestExtensionValue); @@ -123,7 +125,7 @@ public function createLti1p3Session( $userId->getIdentifier(), $userId->getName(), $userId->getEmail(), - $userId->getLocale() + $userId->getLocale() ?? $this->getLocaleFromMessagePayload($messagePayload) ), new TenantDataSessionContext(end($clientIdParts)) ]; @@ -231,4 +233,13 @@ public static function singleton() { return ServiceManager::getServiceManager()->get(static::class); } + + private function getLocaleFromMessagePayload(LtiMessagePayloadInterface $messagePayload): ?string + { + if ($messagePayload && $messagePayload->getLaunchPresentation() instanceof LaunchPresentationClaim) { + return $messagePayload->getLaunchPresentation()->getLocale(); + } + + return null; + } } diff --git a/models/classes/ServiceProvider/LtiServiceProvider.php b/models/classes/ServiceProvider/LtiServiceProvider.php index 04af106a..e5b30318 100644 --- a/models/classes/ServiceProvider/LtiServiceProvider.php +++ b/models/classes/ServiceProvider/LtiServiceProvider.php @@ -102,6 +102,7 @@ public function __invoke(ContainerConfigurator $configurator): void [ 'help' => self::PORTAL_ACCESS_ROLES, 'settings_my_password' => self::PORTAL_ACCESS_ROLES, + 'settings_my_settings' => self::PORTAL_ACCESS_ROLES ] );