From 52e8ce82effe96b79cd48c4b033bb7aa15bc3026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Marsza=C5=82?= Date: Thu, 13 Jun 2024 11:26:06 +0200 Subject: [PATCH 1/3] fix: use getLaunchPresentation language in Authoring --- models/classes/LtiService.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/classes/LtiService.php b/models/classes/LtiService.php index 968a8491..a7d848df 100644 --- a/models/classes/LtiService.php +++ b/models/classes/LtiService.php @@ -105,6 +105,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 +124,7 @@ public function createLti1p3Session( $userId->getIdentifier(), $userId->getName(), $userId->getEmail(), - $userId->getLocale() + $userId->getLocale() ?? $messagePayload->getLaunchPresentation()->getLocale() ), new TenantDataSessionContext(end($clientIdParts)) ]; From 62b08d1269ea0d016eccb600fc32af0f00142a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Marsza=C5=82?= Date: Thu, 13 Jun 2024 12:52:47 +0200 Subject: [PATCH 2/3] fix: make sure messagePayload and getLaunchPresentation exist --- models/classes/LtiService.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/models/classes/LtiService.php b/models/classes/LtiService.php index a7d848df..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; @@ -124,7 +125,7 @@ public function createLti1p3Session( $userId->getIdentifier(), $userId->getName(), $userId->getEmail(), - $userId->getLocale() ?? $messagePayload->getLaunchPresentation()->getLocale() + $userId->getLocale() ?? $this->getLocaleFromMessagePayload($messagePayload) ), new TenantDataSessionContext(end($clientIdParts)) ]; @@ -232,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; + } } From 353f2d0fc539163b6e504aaa3b4ab2f6f66561b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Marsza=C5=82?= Date: Thu, 13 Jun 2024 16:24:23 +0200 Subject: [PATCH 3/3] fix: remove settings_my_settings from portal users --- models/classes/ServiceProvider/LtiServiceProvider.php | 1 + 1 file changed, 1 insertion(+) 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 ] );