diff options
Diffstat (limited to 'lib/models')
| -rw-r--r-- | lib/models/LtiDeployment.php | 34 | ||||
| -rw-r--r-- | lib/models/LtiGrade.php | 3 | ||||
| -rw-r--r-- | lib/models/LtiResourceLink.php | 51 |
3 files changed, 56 insertions, 32 deletions
diff --git a/lib/models/LtiDeployment.php b/lib/models/LtiDeployment.php index e59e738..86f18a0 100644 --- a/lib/models/LtiDeployment.php +++ b/lib/models/LtiDeployment.php @@ -12,15 +12,10 @@ * @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2 * * @property int $id database column - * @property string $title database column - * @property string $description database column * @property int $tool_id database column - * @property string $launch_url database column * @property int $mkdate database column * @property int $chdate database column - * @property JSONArrayObject|null $options database column * @property SimpleORMapCollection<LtiGrade> $grades has_many LtiGrade - * @property Course $course belongs_to Course * @property LtiTool $tool belongs_to LtiTool */ @@ -33,8 +28,6 @@ class LtiDeployment extends SimpleORMap { $config['db_table'] = 'lti_deployments'; - $config['serialized_fields']['options'] = JSONArrayObject::class; - $config['belongs_to']['tool'] = [ 'class_name' => LtiTool::class, 'foreign_key' => 'tool_id' @@ -61,6 +54,8 @@ class LtiDeployment extends SimpleORMap /** * Get the launch_url of this entry. + * + * @deprecated */ public function getLaunchURL() { @@ -72,6 +67,8 @@ class LtiDeployment extends SimpleORMap /** * Get the consumer_key of this entry. + * + * @deprecated */ public function getConsumerKey() { @@ -80,6 +77,8 @@ class LtiDeployment extends SimpleORMap /** * Get the consumer_secret of this entry. + * + * @deprecated */ public function getConsumerSecret() { @@ -88,6 +87,8 @@ class LtiDeployment extends SimpleORMap /** * Get the oauth_signature_method of this entry. + * + * @deprecated */ public function getOauthSignatureMethod() { @@ -96,6 +97,8 @@ class LtiDeployment extends SimpleORMap /** * Get the custom_parameters of this entry. + * + * @deprecated */ public function getCustomParameters() { @@ -107,23 +110,6 @@ class LtiDeployment extends SimpleORMap 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]; - } - /** * Get the send_lis_person attribute of this entry. */ diff --git a/lib/models/LtiGrade.php b/lib/models/LtiGrade.php index a7a5dbc..b037f30 100644 --- a/lib/models/LtiGrade.php +++ b/lib/models/LtiGrade.php @@ -18,6 +18,9 @@ * @property int $chdate database column * @property LtiDeployment $link belongs_to LtiDeployment * @property User $user belongs_to User + * + * NOTE: LtiGrade is only for the LTI 1.0/1.1 interface. + * The LTI 1.3A interface uses the grade book tables for storing grades. */ class LtiGrade extends SimpleORMap 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]; + } } |
