aboutsummaryrefslogtreecommitdiff
path: root/lib/models/LtiResourceLink.php
diff options
context:
space:
mode:
authorRasmus Fuhse <fuhse@data-quest.de>2025-07-04 11:26:38 +0000
committerRasmus Fuhse <fuhse@data-quest.de>2025-07-04 11:26:38 +0000
commitf1613a24917bf32de90f042801d72b9fc18e43a2 (patch)
tree8d298c4deb1b12e3a5104b311a144d21a57beb60 /lib/models/LtiResourceLink.php
parent64a29f7621f459a444835ea85be204f7d12ed302 (diff)
course/lti/process_select_link: redirect on error with deployments, fixes #5488cherry-pick-d98e8f81
Closes #5488 Merge request studip/studip!4183 (cherry picked from commit d98e8f811ee969fc94f922a70ad270ff02d057fc) 6e3310be course/lti/process_select_link: redirect on error with deployments b1f72a9f began rewriting course/lti/select_link and course/lti/process_select_link actions 74f13cb3 use LtiResourceLink instead of LtiDeployment 8c9e7707 course/lti/process_select_link: made lti resource link ID mandatory 5ee5de11 Revert "course/lti/process_select_link: made lti resource link ID mandatory" c26e2605 Revert "use LtiResourceLink instead of LtiDeployment" d466a82c Revert "began rewriting course/lti/select_link and course/lti/process_select_link actions" ec9ebdd9 course/lti/process_select_link action: create LtiResourceLink objects bb8aadb6 fixed typos 7c399153 fixed errors c3d046b3 added redirects 6be413d1 Revert "added redirects" 3d4462f7 Revert "fixed errors" adb61667 Revert "fixed typos" fcd16406 Revert "course/lti/process_select_link action: create LtiResourceLink objects" 1f34f17d began rewriting course/lti/select_link and course/lti/process_select_link actions 5411e842 use LtiResourceLink instead of LtiDeployment 7d3b22fb course/lti/process_select_link: made lti resource link ID mandatory a92bec66 added migration 6f1d77ec changed code a08519ee changed more code, fixed errors ecfab68d extended migration 4b441ca9 extended migration 18f6a0bb added columns to lti_deployments table, rewrote code for new database structure 40776ead replaced attribute access of LtiDeployment with LtiResourceLink 1150e772 continued moving attribute access 28ac0808 fixed course/lti/select_link action a9189788 fixed lti/tool/index for tools in courses 14e29ec7 fixed errors d1cf3aae fixed errors, added warning for more than one general LTI deployment per tool 46f0ea9a added deep link count to admin/lti/index dc8058f3 removed unused code d6d1491d fixed errors a7f34412 removed debug code 944782dd fixed errors 7ee7716d fixed more errors 35563dc9 set course-ID as URL parameter for deep linking return URL a1af83e5 fixed error f2bd12cc course/lti/save_link: attempted to fix "no registration platform side" error 041d65de fixed error d77844e0 fixed errors 581630b5 added debug code, allow setting link in registration manager c9174799 removed debug code b39ddf23 test 1f99d252 removed extra claim 75a25a15 made LTI requests have the same registration 680e9945 Prioritize JWKS URL over static key chain 46f3f6f4 Return LTi exception on public key failure 9d97dbbf Make public key unsetable Co-authored-by: Moritz Strohm <strohm@data-quest.de>
Diffstat (limited to 'lib/models/LtiResourceLink.php')
-rw-r--r--lib/models/LtiResourceLink.php51
1 files changed, 43 insertions, 8 deletions
diff --git a/lib/models/LtiResourceLink.php b/lib/models/LtiResourceLink.php
index 785c350..0ea15aa 100644
--- a/lib/models/LtiResourceLink.php
+++ b/lib/models/LtiResourceLink.php
@@ -23,7 +23,11 @@ use OAT\Library\Lti1p3Core\Util\Collection\CollectionInterface;
* @property int $id database column
* @property int $deployment_id database column
* @property string $course_id database column
+ * @property string $title database column
+ * @property string $description database column
* @property int $position database column
+ * @property string $launch_url database column
+ * @property JSONArrayObject|null $options database column
* @property int $mkdate database column
* @property int $chdate database column
* @property ?LtiDeployment $deployment related object
@@ -35,6 +39,8 @@ class LtiResourceLink extends \SimpleORMap implements LtiResourceLinkInterface
{
$config['db_table'] = 'lti_resource_links';
+ $config['serialized_fields']['options'] = JSONArrayObject::class;
+
$config['belongs_to']['course'] = [
'class_name' => Course::class,
'foreign_key' => 'course_id'
@@ -89,14 +95,19 @@ class LtiResourceLink extends \SimpleORMap implements LtiResourceLinkInterface
return self::findOneBySQL('course_id = ? AND position = ?', [$course_id, $position]);
}
+ public function getLaunchURL()
+ {
+ if (!empty($this->deployment->tool) && empty($this->deployment->tool->allow_custom_url) && empty($this->deployment->tool->deep_linking) || empty($this->launch_url)) {
+ return $this->deployment->tool->launch_url;
+ }
+ return $this->launch_url;
+ }
+
//OAT library LtiResourceLinkInterface and ResourceInterface implementation:
public function getUrl(): ?string
{
- if ($this->deployment) {
- return $this->deployment->getLaunchURL();
- }
- return null;
+ return $this->getLaunchURL();
}
public function getIcon(): ?array
@@ -154,10 +165,7 @@ class LtiResourceLink extends \SimpleORMap implements LtiResourceLinkInterface
public function getTitle(): ?string
{
- if ($this->deployment) {
- return $this->deployment->title;
- }
- return null;
+ return $this->title ?? $this->deployment->tool->name ?? null;
}
public function getText(): ?string
@@ -184,4 +192,31 @@ class LtiResourceLink extends \SimpleORMap implements LtiResourceLinkInterface
)
);
}
+
+ public function getCustomParameters()
+ {
+ $parameters = '';
+ if (!empty($this->deployment->tool)) {
+ $parameters = $this->deployment->tool->custom_parameters;
+ }
+ $parameters .= $this->options['custom_parameters'] ?? '';
+ return $parameters;
+ }
+
+ public function getCustomLtiParameterArray() : array
+ {
+ $parameter_str = $this->getCustomParameters();
+ if (empty($parameter_str)) {
+ return [];
+ }
+ $parameters = explode("\n", $parameter_str);
+ $array = [];
+ foreach ($parameters as $parameter) {
+ $key_value_parts = explode('=', $parameter, 2);
+ if (count($key_value_parts) === 2) {
+ $array[trim($key_value_parts[0])] = trim($key_value_parts[1]);
+ }
+ }
+ return ['https://purl.imsglobal.org/spec/lti/claim/custom' => $array];
+ }
}