ILIAS  release_8 Revision v8.24
class.ilObjLTIConsumer.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24
35{
36 public const DB_TABLE_NAME = 'lti_consumer_settings';
37
41 protected bool $activationLimited = false;
42 protected ?int $activationStartingTime = null;
43 protected ?int $activationEndingTime = null;
44 protected ?bool $activationVisibility = null;
45
46 protected int $providerId = 0;
47
49
50 public const LAUNCH_METHOD_OWN_WIN = 'ownWin';
51 public const LAUNCH_METHOD_NEW_WIN = 'newWin';
52 public const LAUNCH_METHOD_EMBEDDED = 'embedded';
53
54 protected bool $use_xapi = false;
55 protected string $custom_activity_id = '';
56 protected bool $statementsReportEnabled = false;
57
58 protected float $mastery_score = 0.5;
59
61
62 protected string $customLaunchKey = '';
63
64 protected string $customLaunchSecret = '';
65
66 protected string $customParams = '';
67
68 protected ?int $ref_id = 0;
69
70 //Highscore
71 protected bool $_highscore_enabled = false;
72
73 protected int $anonymity = 0;
74
75 protected bool $_highscore_achieved_ts = true;
76
77 protected bool $_highscore_percentage = true;
78
79 protected bool $_highscore_wtime = true;
80
81 protected bool $_highscore_own_table = true;
82
83 protected bool $_highscore_top_table = true;
84
85 protected int $_highscore_top_num = 10;
86
87 public const HIGHSCORE_SHOW_ALL_TABLES = 1;
88 public const HIGHSCORE_SHOW_TOP_TABLE = 2;
89 public const HIGHSCORE_SHOW_OWN_TABLE = 3;
90
91 public const LTI_JWT_CLAIM_PREFIX = 'https://purl.imsglobal.org/spec/lti';
92 public const LTI_1_3_KID = 'lti_1_3_kid';
93 public const LTI_1_3_PRIVATE_KEY = 'lti_1_3_privatekey';
94 public const ERROR_OPEN_SSL_CONF = 'error openssl config invalid';
95 public const OPENSSL_KEYTYPE_RSA = '';
96
97 public const REG_TOKEN_OP_NEW_REG = 'reg';
98 public const REG_TOKEN_OP_UPDATE_REG = 'reg-update';
99
103 public function __construct(int $a_id = 0, bool $a_reference = true)
104 {
105 parent::__construct($a_id, $a_reference);
106 }
107
108 protected function initType(): void
109 {
110 $this->type = "lti";
111 }
112
113 public function isActivationLimited(): bool
114 {
116 }
117
118 public function setActivationLimited(bool $activationLimited): void
119 {
120 $this->activationLimited = $activationLimited;
121 }
122
123 public function getActivationStartingTime(): ?int
124 {
126 }
127
128 public function setActivationStartingTime(?int $activationStartingTime = null): void
129 {
130 $this->activationStartingTime = $activationStartingTime;
131 }
132
133 public function getActivationEndingTime(): ?int
134 {
136 }
137
138 public function setActivationEndingTime(?int $activationEndingTime = null): void
139 {
140 $this->activationEndingTime = $activationEndingTime;
141 }
142
143 public function getActivationVisibility(): ?bool
144 {
146 }
147
149 {
150 $this->activationVisibility = $activationVisibility;
151 }
152
153 public function getMasteryScore(): float
154 {
156 }
157
158 public function setMasteryScore(float $mastery_score): void
159 {
160 $this->mastery_score = $mastery_score;
161 }
162
163 public function getMasteryScorePercent(): float
164 {
165 return $this->mastery_score * 100;
166 }
167
168 public function setMasteryScorePercent(float $mastery_score_percent): void
169 {
170 $this->mastery_score = $mastery_score_percent / 100;
171 }
172
173 public function getProviderId(): int
174 {
175 return $this->providerId;
176 }
177
178 public function setProviderId(int $providerId): void
179 {
180 $this->providerId = $providerId;
181 }
182
183 public function initProvider(): void
184 {
185 $this->provider = new ilLTIConsumeProvider($this->getProviderId());
186 }
187
189 {
190 return $this->provider;
191 }
192
194 {
195 $this->provider = $provider;
196 }
197
198 public function isLaunchMethodOwnWin(): bool
199 {
200 return $this->launchMethod == self::LAUNCH_METHOD_OWN_WIN;
201 }
202
203 public function isLaunchMethodEmbedded(): bool
204 {
205 return $this->launchMethod == self::LAUNCH_METHOD_EMBEDDED;
206 }
207
208 public function getLaunchMethod(): string
209 {
210 return $this->launchMethod;
211 }
212
213 public function setLaunchMethod(string $launchMethod): void
214 {
215 $this->launchMethod = $launchMethod;
216 }
217
218 public function getCustomLaunchKey(): string
219 {
221 }
222
223 public function setCustomLaunchKey(string $customLaunchKey): void
224 {
225 $this->customLaunchKey = $customLaunchKey;
226 }
227
228 public function getCustomLaunchSecret(): string
229 {
231 }
232
233 public function setCustomLaunchSecret(string $customLaunchSecret): void
234 {
235 $this->customLaunchSecret = $customLaunchSecret;
236 }
237
238 public function getCustomParams(): string
239 {
240 return $this->customParams;
241 }
242
243 public function setCustomParams(string $customParams): void
244 {
245 $this->customParams = $customParams;
246 }
247
248 public function getLaunchKey(): string
249 {
250 if ($this->getProvider()->isProviderKeyCustomizable()) {
251 return $this->getCustomLaunchKey();
252 }
253
254 return $this->getProvider()->getProviderKey();
255 }
256
257 public function getLaunchSecret(): string
258 {
259 if ($this->getProvider()->isProviderKeyCustomizable()) {
260 return $this->getCustomLaunchSecret();
261 }
262
263 return $this->getProvider()->getProviderSecret();
264 }
265
266 public function getUseXapi(): bool
267 {
268 return $this->use_xapi;
269 }
270
271 public function setUseXapi(bool $use_xapi): void
272 {
273 $this->use_xapi = $use_xapi;
274 }
275
276 public function getCustomActivityId(): string
277 {
279 }
280
281 public function setCustomActivityId(string $custom_activity_id): void
282 {
283 $this->custom_activity_id = $custom_activity_id;
284 }
285
286 public function getActivityId(): string
287 {
288 if (strlen($this->getProvider()->getXapiActivityId())) {
289 return $this->getProvider()->getXapiActivityId();
290 }
291
293 }
294
295 public function isStatementsReportEnabled(): bool
296 {
298 }
299
301 {
302 $this->statementsReportEnabled = $statementsReportEnabled;
303 }
304
308 public function getCustomParamsArray(): array
309 {
310 $paramsAsArray = [];
311
312 $params = $this->getCustomParams();
313 // allows foo=bar;foo2=baz2; foo3=baz3
314 $params = preg_split('/; ?/', $params);
315
316 foreach ($params as $param) {
317 $param = explode('=', $param);
318 // empty field, duplicate/leading/trailing semicolon?
319 if ($param[0] != '') {
320 $value = isset($param[1]) ? $param[1] : '';
321 $paramsAsArray[$param[0]] = $value;
322 }
323 }
324
325 return $paramsAsArray;
326 }
327
332 {
333 $paramsAsArray = [];
334
336 // allows foo=bar;foo2=baz2; foo3=baz3
337 $params = preg_split('/; ?/', $params);
338
339 foreach ($params as $param) {
340 $param = explode('=', $param);
341 // empty field, duplicate/leading/trailing semicolon?
342 if ($param[0] != '') {
343 $value = isset($param[1]) ? $param[1] : '';
344 $paramsAsArray[$param[0]] = $value;
345 }
346 }
347
348 return $paramsAsArray;
349 }
350
351 protected function doRead(): void
352 {
353 $this->load();
354 }
355
356 public function load(): void
357 {
358 global $DIC; /* @var \ILIAS\DI\Container $DIC */
359
360 $query = "SELECT * FROM {$this->dbTableName()} WHERE obj_id = %s";
361 $res = $DIC->database()->queryF($query, ['integer'], [$this->getId()]);
362
363 while ($row = $DIC->database()->fetchAssoc($res)) {
364 // if ($row['provider_id']) { //always set
365 $this->setProviderId((int) $row['provider_id']);
366 $this->setProvider(new ilLTIConsumeProvider((int) $row['provider_id']));
367 // }
368
369 $this->setLaunchMethod($row['launch_method']);
370
371 $this->setCustomLaunchKey((string) $row['launch_key']);
372 $this->setCustomLaunchSecret((string) $row['launch_secret']);
373 $this->setCustomParams((string) $row['custom_params']);
374
375 $this->setUseXapi((bool) $row['use_xapi']);
376 $this->setCustomActivityId((string) $row['activity_id']);
377 $this->setStatementsReportEnabled((bool) $row['show_statements']);
378 $this->setHighscoreEnabled((bool) $row['highscore_enabled']);
379 $this->setHighscoreAchievedTS((bool) $row['highscore_achieved_ts']);
380 $this->setHighscorePercentage((bool) $row['highscore_percentage']);
381 $this->setHighscoreWTime((bool) $row['highscore_wtime']);
382 $this->setHighscoreOwnTable((bool) $row['highscore_own_table']);
383 $this->setHighscoreTopTable((bool) $row['highscore_top_table']);
384 $this->setHighscoreTopNum((int) $row['highscore_top_num']);
385
386 $this->setMasteryScore((float) $row['mastery_score']);
387 }
388
390 }
391
392 protected function doUpdate(): void
393 {
394 $this->save();
395 }
396
397 public function save(): void
398 {
399 global $DIC; /* @var \ILIAS\DI\Container $DIC */
400
401 $DIC->database()->replace($this->dbTableName(), [
402 'obj_id' => ['integer', $this->getId()]
403 ], [
404 'provider_id' => ['integer', $this->getProviderId()],
405 'launch_method' => ['text', $this->getLaunchMethod()],
406 'launch_key' => ['text', $this->getCustomLaunchKey()],
407 'launch_secret' => ['text', $this->getCustomLaunchSecret()],
408 'custom_params' => ['text', $this->getCustomParams()],
409 'use_xapi' => ['integer',$this->getUseXapi()],
410 'activity_id' => ['text',$this->getCustomActivityId()],
411 'show_statements' => ['integer',$this->isStatementsReportEnabled()],
412 'highscore_enabled' => ['integer', (int) $this->getHighscoreEnabled()],
413 'highscore_achieved_ts' => ['integer', (int) $this->getHighscoreAchievedTS()],
414 'highscore_percentage' => ['integer', (int) $this->getHighscorePercentage()],
415 'highscore_wtime' => ['integer', (int) $this->getHighscoreWTime()],
416 'highscore_own_table' => ['integer', (int) $this->getHighscoreOwnTable()],
417 'highscore_top_table' => ['integer', (int) $this->getHighscoreTopTable()],
418 'highscore_top_num' => ['integer', $this->getHighscoreTopNum()],
419 'mastery_score' => ['float', $this->getMasteryScore()]
420 ]);
421
423 }
424
425 protected function loadRepositoryActivationSettings(): void
426 {
427 if ($this->ref_id > 0) {
428 $activation = ilObjectActivation::getItem($this->ref_id);
429 switch ($activation["timing_type"]) {
431 $this->setActivationLimited(true);
432 if (!is_null($activation["timing_start"])) {
433 $activation["timing_start"] = (int) $activation["timing_start"];
434 }
435 $this->setActivationStartingTime($activation["timing_start"]);
436 if (!is_null($activation["timing_end"])) {
437 $activation["timing_end"] = (int) $activation["timing_end"];
438 }
439 $this->setActivationEndingTime($activation["timing_end"]);
440 $this->setActivationVisibility((bool) $activation["visible"]);
441 break;
442
443 default:
444 $this->setActivationLimited(false);
445 break;
446 }
447 }
448 }
449
450 protected function saveRepositoryActivationSettings(): void
451 {
452 if ($this->ref_id > 0) {
453 ilObjectActivation::getItem($this->ref_id);
454
455 $item = new ilObjectActivation();
456 if (!$this->isActivationLimited()) {
457 $item->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
458 } else {
459 $item->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
460 $item->setTimingStart($this->getActivationStartingTime());
461 $item->setTimingEnd($this->getActivationEndingTime());
462 $item->toggleVisible($this->getActivationVisibility());
463 }
464
465 $item->update($this->ref_id);
466 }
467 }
468
469 protected function dbTableName(): string
470 {
471 return self::DB_TABLE_NAME;
472 }
473
476
477
481 public function setHighscoreEnabled(bool $a_enabled): void
482 {
483 $this->_highscore_enabled = $a_enabled;
484 }
485
491 public function getHighscoreEnabled(): bool
492 {
494 }
495
496
500 public function setHighscoreAchievedTS(bool $a_achieved_ts): void
501 {
502 $this->_highscore_achieved_ts = $a_achieved_ts;
503 }
504
510 public function getHighscoreAchievedTS(): bool
511 {
513 }
514
518 public function setHighscorePercentage(bool $a_percentage): void
519 {
520 $this->_highscore_percentage = $a_percentage;
521 }
522
528 public function getHighscorePercentage(): bool
529 {
531 }
532
536 public function setHighscoreWTime(bool $a_wtime): void
537 {
538 $this->_highscore_wtime = $a_wtime;
539 }
540
546 public function getHighscoreWTime(): bool
547 {
549 }
550
556 public function setHighscoreOwnTable(bool $a_own_table): void
557 {
558 $this->_highscore_own_table = $a_own_table;
559 }
560
566 public function getHighscoreOwnTable(): bool
567 {
569 }
570
574 public function setHighscoreTopTable(bool $a_top_table): void
575 {
576 $this->_highscore_top_table = $a_top_table;
577 }
578
584 public function getHighscoreTopTable(): bool
585 {
587 }
588
595 public function setHighscoreTopNum(int $a_top_num): void
596 {
597 $this->_highscore_top_num = $a_top_num;
598 }
599
608 public function getHighscoreTopNum(int $a_retval = 10): int
609 {
610 $retval = $a_retval;
611 if ($this->_highscore_top_num != 0) {
613 }
614
615 return $retval;
616 }
617
618 public function getHighscoreMode(): int
619 {
620 switch (true) {
621 case $this->getHighscoreOwnTable() && $this->getHighscoreTopTable():
623
624 case $this->getHighscoreTopTable():
626
627 case $this->getHighscoreOwnTable():
628 default:
630 }
631 }
632
636 public function setHighscoreMode(int $mode): void
637 {
638 switch ($mode) {
640 $this->setHighscoreTopTable(true);
641 $this->setHighscoreOwnTable(true);
642 break;
643
645 $this->setHighscoreTopTable(true);
646 $this->setHighscoreOwnTable(false);
647 break;
648
650 default:
651 $this->setHighscoreTopTable(false);
652 $this->setHighscoreOwnTable(true);
653 break;
654 }
655 }
656 /* End GET/SET for highscore feature*/
660 public function buildLaunchParameters(ilCmiXapiUser $cmixUser, string $token, string $contextType, string $contextId, string $contextTitle, ?string $returnUrl = ''): array
661 {
662 global $DIC; /* @var \ILIAS\DI\Container $DIC */
663
664 $roles = $DIC->access()->checkAccess('write', '', $this->getRefId()) ? "Instructor" : "Learner";
665 //todo if object is in course or group, roles would have to be taken from there s. Mantis 35435 - if necessary Jour Fixe topic
666 if ($DIC->rbac()->review()->isAssigned($DIC->user()->getId(), SYSTEM_ROLE_ID)) {
667 $roles = "Administrator";
668 }
669
670 if ($this->getProvider()->getAlwaysLearner() == true) {
671 $roles = "Learner";
672 }
673
674 $resource_link_id = $this->getRefId();
675 if ($this->getProvider()->getUseProviderId() == true) {
676 $resource_link_id = 'p' . $this->getProvider()->getId();
677 }
678
679 $usrImage = '';
680 if ($this->getProvider()->getIncludeUserPicture()) {
681 $usrImage = self::getIliasHttpPath() . "/" . $DIC->user()->getPersonalPicturePath("small");
682 }
683
684 $documentTarget = "window";
685 if ($this->getLaunchMethod() == self::LAUNCH_METHOD_EMBEDDED) {
686 $documentTarget = "iframe";
687 }
688
689 $nameGiven = '-';
690 $nameFamily = '-';
691 $nameFull = '-';
692 switch ($this->getProvider()->getPrivacyName()) {
694 $nameGiven = $DIC->user()->getFirstname();
695 $nameFull = $DIC->user()->getFirstname();
696 break;
698 $usrName = $DIC->user()->getUTitle() ? $DIC->user()->getUTitle() . ' ' : '';
699 $usrName .= $DIC->user()->getLastname();
700 $nameFamily = $usrName;
701 $nameFull = $usrName;
702 break;
704 $nameGiven = $DIC->user()->getFirstname();
705 $nameFamily = $DIC->user()->getLastname();
706 $nameFull = $DIC->user()->getFullname();
707 break;
708 }
709
710 $userIdLTI = ilCmiXapiUser::getIdentAsId($this->getProvider()->getPrivacyIdent(), $DIC->user());
711
712 $emailPrimary = $cmixUser->getUsrIdent();
713 if ($this->getProvider()->getPrivacyIdent() == ilObjCmiXapi::PRIVACY_IDENT_IL_UUID_RANDOM) {
714 $userIdLTI = strstr($emailPrimary, '@' . ilCmiXapiUser::getIliasUuid(), true);
715 }
716
717 ilLTIConsumerResult::getByKeys($this->getId(), $DIC->user()->getId(), true);
718
719 //ToDo: Check!
720 $provider_custom_params = self::getProviderCustomParamsArray($this->getProvider());
721 $custom_params = $this->getCustomParamsArray();
722 $merged_params = array_merge($provider_custom_params, $custom_params);
723
724 $toolConsumerInstanceGuid = CLIENT_ID . ".";
725 $parseIliasUrl = parse_url(self::getIliasHttpPath());
726 if (array_key_exists("path", $parseIliasUrl)) {
727 $toolConsumerInstanceGuid .= implode(".", array_reverse(explode("/", $parseIliasUrl["path"])));
728 }
729 $toolConsumerInstanceGuid .= $parseIliasUrl["host"];
730 $launch_vars = [
731 "lti_message_type" => "basic-lti-launch-request",
732 "lti_version" => "LTI-1p0",
733 "resource_link_id" => $resource_link_id,
734 "resource_link_title" => $this->getTitle(),
735 "resource_link_description" => $this->getDescription(),
736 "user_id" => $userIdLTI,
737 "user_image" => $usrImage,
738 "roles" => $roles,
739 "lis_person_name_given" => $nameGiven,
740 "lis_person_name_family" => $nameFamily,
741 "lis_person_name_full" => $nameFull,
742 "lis_person_contact_email_primary" => $emailPrimary,
743 "context_id" => $contextId,
744 "context_type" => $contextType,
745 "context_title" => $contextTitle,
746 "context_label" => $contextType . " " . $contextId,
747 "launch_presentation_locale" => $this->lng->getLangKey(),
748 "launch_presentation_document_target" => $documentTarget,
749 "launch_presentation_width" => "",//recommended
750 "launch_presentation_height" => "",//recommended
751 "launch_presentation_return_url" => $returnUrl,
752 "tool_consumer_instance_guid" => $toolConsumerInstanceGuid,
753 "tool_consumer_instance_name" => $DIC->settings()->get("short_inst_name") ? $DIC->settings()->get("short_inst_name") : CLIENT_ID,
754 "tool_consumer_instance_description" => ilObjSystemFolder::_getHeaderTitle(),
755 "tool_consumer_instance_url" => ilLink::_getLink(ROOT_FOLDER_ID, "root"),//ToDo? "https://vb52p70.example.com/release_5-3/goto.php?target=root_1&client_id=inno",
756 "tool_consumer_instance_contact_email" => $DIC->settings()->get("admin_email"),
757 "launch_presentation_css_url" => "",
758 "tool_consumer_info_product_family_code" => "ilias",
759 "tool_consumer_info_version" => ILIAS_VERSION,
760 "lis_result_sourcedid" => $token,
761 "lis_outcome_service_url" => self::getIliasHttpPath() . "/Modules/LTIConsumer/result.php?client_id=" . CLIENT_ID,
762 "role_scope_mentor" => ""
763 ];
764
765 $OAuthParams = [
766 "url" => $this->getProvider()->getProviderUrl(),
767 "key" => $this->getLaunchKey(),
768 "secret" => $this->getLaunchSecret(),
769 "callback" => "about:blank",
770 "http_method" => "POST",
771 "sign_method" => "HMAC_SHA1",
772 "token" => null,
773 "data" => ($launch_vars + $merged_params)
774 ];
775
776 return ilLTIConsumerLaunch::signOAuth($OAuthParams);
777 }
778
783 public function buildLaunchParametersLTI13(ilCmiXapiUser $cmixUser, string $endpoint, string $clientId, int $deploymentId, string $nonce, string $contextType, string $contextId, string $contextTitle, ?string $returnUrl = ''): ?array
784 {
785 global $DIC; /* @var \ILIAS\DI\Container $DIC */
786
787 $roles = $DIC->access()->checkAccess('write', '', $this->getRefId()) ? "Instructor" : "Learner";
788 if ($DIC->rbac()->review()->isAssigned($DIC->user()->getId(), SYSTEM_ROLE_ID)) {
789 $roles = "Administrator";
790 }
791 if ($this->getProvider()->getAlwaysLearner() == true) {
792 $roles = "Learner";
793 }
794
795 $resource_link_id = $this->getRefId();
796 if ($this->getProvider()->getUseProviderId() == true) {
797 $resource_link_id = 'p' . $this->getProvider()->getId();
798 }
799
800 $usrImage = '';
801 if ($this->getProvider()->getIncludeUserPicture()) {
802 $usrImage = self::getIliasHttpPath() . "/" . $DIC->user()->getPersonalPicturePath("small");
803 }
804
805 $documentTarget = "window";
806 if ($this->getLaunchMethod() == self::LAUNCH_METHOD_EMBEDDED) {
807 $documentTarget = "iframe";
808 }
809
810 $nameGiven = '-';
811 $nameFamily = '-';
812 $nameFull = '-';
813 switch ($this->getProvider()->getPrivacyName()) {
815 $nameGiven = $DIC->user()->getFirstname();
816 $nameFull = $DIC->user()->getFirstname();
817 break;
819 $usrName = $DIC->user()->getUTitle() ? $DIC->user()->getUTitle() . ' ' : '';
820 $usrName .= $DIC->user()->getLastname();
821 $nameFamily = $usrName;
822 $nameFull = $usrName;
823 break;
825 $nameGiven = $DIC->user()->getFirstname();
826 $nameFamily = $DIC->user()->getLastname();
827 $nameFull = $DIC->user()->getFullname();
828 break;
829 }
830
831 $userIdLTI = ilCmiXapiUser::getIdent($this->getProvider()->getPrivacyIdent(), $DIC->user()); //was: getIdentAsId
832
833 $emailPrimary = $cmixUser->getUsrIdent();
834
835 ilLTIConsumerResult::getByKeys($this->getId(), $DIC->user()->getId(), true);
836
837 $toolConsumerInstanceGuid = CLIENT_ID . ".";
838 $parseIliasUrl = parse_url(self::getIliasHttpPath());
839 if (array_key_exists("path", $parseIliasUrl)) {
840 $toolConsumerInstanceGuid .= implode(".", array_reverse(explode("/", $parseIliasUrl["path"])));
841 }
842 $toolConsumerInstanceGuid .= $parseIliasUrl["host"];
843 $launch_vars = [
844 "lti_message_type" => "basic-lti-launch-request",
845 "lti_version" => "1.3.0",
846 "resource_link_id" => (string) $resource_link_id,
847 "resource_link_title" => $this->getTitle(),
848 "resource_link_description" => $this->getDescription(),
849 "user_id" => (string) $userIdLTI,
850 "user_image" => $usrImage,
851 "roles" => $roles,
852 "lis_person_name_given" => $nameGiven,
853 "lis_person_name_family" => $nameFamily,
854 "lis_person_name_full" => $nameFull,
855 "lis_person_contact_email_primary" => $emailPrimary,
856 "context_id" => $contextId,
857 "context_type" => $contextType,
858 "context_title" => $contextTitle,
859 "context_label" => $contextType . " " . $contextId,
860 "launch_presentation_locale" => $this->lng->getLangKey(),
861 "launch_presentation_document_target" => $documentTarget,
862 "launch_presentation_width" => "",//recommended
863 "launch_presentation_height" => "",//recommended
864 "launch_presentation_return_url" => $returnUrl,
865 "tool_consumer_instance_guid" => $toolConsumerInstanceGuid,
866 "tool_consumer_instance_name" => $DIC->settings()->get("short_inst_name") ? $DIC->settings()->get("short_inst_name") : CLIENT_ID,
867 "tool_consumer_instance_description" => ilObjSystemFolder::_getHeaderTitle(),
868 "tool_consumer_instance_url" => ilLink::_getLink(ROOT_FOLDER_ID, "root"),//ToDo? "https://vb52p70.example.com/release_5-3/goto.php?target=root_1&client_id=inno",
869 "tool_consumer_instance_contact_email" => $DIC->settings()->get("admin_email"),
870 "launch_presentation_css_url" => "",
871 "tool_consumer_info_product_family_code" => "ilias",
872 "tool_consumer_info_version" => ILIAS_VERSION,
873 "lis_result_sourcedid" => "",//$token,
874 "lis_outcome_service_url" => self::getIliasHttpPath() . "/Modules/LTIConsumer/result.php?client_id=" . CLIENT_ID,
875 "role_scope_mentor" => ""
876 ];
877
878 $provider_custom_params = self::getProviderCustomParamsArray($this->getProvider());
879 $custom_params = $this->getCustomParamsArray();
880 $merged_params = array_merge($provider_custom_params, $custom_params);
881 foreach ($merged_params as $key => $value) {
882 $launch_vars['custom_' . $key] = $value;
883 }
884
885 if ($this->getProvider()->isGradeSynchronization() || $this->getProvider()->getHasOutcome()) {
886 include_once("Modules/LTIConsumer/classes/class.ilLTIConsumerGradeService.php");
887 $gradeservice = new ilLTIConsumerGradeService();
888 $launch_vars['custom_lineitem_url'] = self::getIliasHttpPath() . "/Modules/LTIConsumer/ltiservices.php/gradeservice/" . $contextId . "/lineitems/" . $this->id . "/lineitem";
889
890 // ! Moodle as tool provider requires a custom_lineitems_url even though this should be optional in launch request, especially if only posting score scope is permitted by platform
891 // http://www.imsglobal.org/spec/lti-ags/v2p0#example-link-has-a-single-line-item-tool-can-only-post-score
892 $launch_vars['custom_lineitems_url'] = self::getIliasHttpPath() . "/Modules/LTIConsumer/ltiservices.php/gradeservice/" . $contextId . "/linetitems/";
893
894 $launch_vars['custom_ags_scopes'] = implode(",", $gradeservice->getPermittedScopes());
895 }
896
897 if (!empty(self::verifyPrivateKey())) {
898 $DIC->ui()->mainTemplate()->setOnScreenMessage('failure', 'ERROR_OPEN_SSL_CONF', true);
899 return null;
900 }
901 return self::LTISignJWT($launch_vars, $endpoint, $clientId, $deploymentId, $nonce);
902 }
903
908 // ToDo:
909
910 public static function buildContentSelectionParameters(ilLTIConsumeProvider $provider, int $refId, string $returnUrl, string $nonce): ?array
911 {
912 global $DIC;
913
915 $deploymentId = $provider->getId();
916 $ilLTIConsumerLaunch = new ilLTIConsumerLaunch($refId);
917 $context = $ilLTIConsumerLaunch->getContext();
918 $contextType = $ilLTIConsumerLaunch::getLTIContextType($context["type"]);
919 $contextId = $context["id"];
920 $contextTitle = $context["title"];
921
922 $roles = "Instructor";
923 $usrImage = '';
925 $usrImage = self::getIliasHttpPath() . "/" . $DIC->user()->getPersonalPicturePath("small");
926 }
927 $documentTarget = "window";
928 if ($provider->getLaunchMethod() == self::LAUNCH_METHOD_EMBEDDED) {
929 $documentTarget = "iframe";
930 }
931 $nameGiven = '-';
932 $nameFamily = '-';
933 $nameFull = '-';
934 switch ($provider->getPrivacyName()) {
936 $nameGiven = $DIC->user()->getFirstname();
937 $nameFull = $DIC->user()->getFirstname();
938 break;
940 $usrName = $DIC->user()->getUTitle() ? $DIC->user()->getUTitle() . ' ' : '';
941 $usrName .= $DIC->user()->getLastname();
942 $nameFamily = $usrName;
943 $nameFull = $usrName;
944 break;
946 $nameGiven = $DIC->user()->getFirstname();
947 $nameFamily = $DIC->user()->getLastname();
948 $nameFull = $DIC->user()->getFullname();
949 break;
950 }
951
952 $userIdLTI = ilCmiXapiUser::getIdent($provider->getPrivacyIdent(), $DIC->user()); //was: getIdentAsId
953 $emailPrimary = ilCmiXapiUser::getIdent($provider->getPrivacyIdent(), $DIC->user());
954 $toolConsumerInstanceGuid = CLIENT_ID . ".";
955 $parseIliasUrl = parse_url(self::getIliasHttpPath());
956 if (array_key_exists("path", $parseIliasUrl)) {
957 $toolConsumerInstanceGuid .= implode(".", array_reverse(explode("/", $parseIliasUrl["path"])));
958 }
959 $toolConsumerInstanceGuid .= $parseIliasUrl["host"];
960
961 $content_select_vars = [
962 "lti_message_type" => "ContentItemSelectionRequest",
963 "lti_version" => "1.3.0",
964 "user_id" => (string) $userIdLTI,
965 "user_image" => $usrImage,
966 "roles" => $roles,
967 "lis_person_name_given" => $nameGiven,
968 "lis_person_name_family" => $nameFamily,
969 "lis_person_name_full" => $nameFull,
970 "lis_person_contact_email_primary" => $emailPrimary,
971 "context_id" => (string) $contextId,
972 "context_type" => $contextType,
973 "context_title" => $contextTitle,
974 "context_label" => $contextType . " " . $contextId,
975 "launch_presentation_locale" => $DIC->language()->getLangKey(),
976 "launch_presentation_document_target" => $documentTarget,
977 "launch_presentation_width" => "",//recommended
978 "launch_presentation_height" => "",//recommended
979 "tool_consumer_instance_guid" => $toolConsumerInstanceGuid,
980 "tool_consumer_instance_name" => $DIC->settings()->get("short_inst_name") ? $DIC->settings()->get("short_inst_name") : CLIENT_ID,
981 "tool_consumer_instance_description" => ilObjSystemFolder::_getHeaderTitle(),
982 "tool_consumer_instance_url" => ilLink::_getLink(ROOT_FOLDER_ID, "root"),//ToDo? "https://vb52p70.example.com/release_5-3/goto.php?target=root_1&client_id=inno",
983 "tool_consumer_instance_contact_email" => $DIC->settings()->get("admin_email"),
984 "tool_consumer_info_product_family_code" => "ilias",
985 "tool_consumer_info_version" => ILIAS_VERSION,
986 "content_item_return_url" => $returnUrl,
987 "accept_types" => "ltiResourceLink",
988 "accept_presentation_document_targets" => "iframe,window,embed",
989 "accept_multiple" => true,
990 "auto_create" => true,
991 ];
992 $provider_custom_params = self::getProviderCustomParamsArray($provider);
993 foreach ($provider_custom_params as $key => $value) {
994 $content_select_vars['custom_' . $key] = $value;
995 }
996
997 if (!empty(self::verifyPrivateKey())) {
998 $DIC->ui()->mainTemplate()->setOnScreenMessage('failure', 'ERROR_OPEN_SSL_CONF', true);
999 return null;
1000 }
1001 return self::LTISignJWT($content_select_vars, '', $clientId, $deploymentId, $nonce);
1002 }
1003
1004 public static function LTISignJWT(array $parms, string $endpoint, string $oAuthConsumerKey, $typeId = 0, string $nonce = ''): array
1005 {
1006 if (empty($typeId)) {
1007 $typeId = 0;
1008 }
1010 if (isset($parms['lti_message_type']) && array_key_exists($parms['lti_message_type'], $messageTypeMapping)) {
1011 $parms['lti_message_type'] = $messageTypeMapping[$parms['lti_message_type']];
1012 }
1013 if (isset($parms['roles'])) {
1014 $roles = explode(',', $parms['roles']);
1015 $newRoles = array();
1016 foreach ($roles as $role) {
1017 if (strpos($role, 'urn:lti:role:ims/lis/') === 0) {
1018 $role = 'http://purl.imsglobal.org/vocab/lis/v2/membership#' . substr($role, 21);
1019 } elseif (strpos($role, 'urn:lti:instrole:ims/lis/') === 0) {
1020 $role = 'http://purl.imsglobal.org/vocab/lis/v2/institution/person#' . substr($role, 25);
1021 } elseif (strpos($role, 'urn:lti:sysrole:ims/lis/') === 0) {
1022 $role = 'http://purl.imsglobal.org/vocab/lis/v2/system/person#' . substr($role, 24);
1023 } elseif ((strpos($role, '://') === false) && (strpos($role, 'urn:') !== 0)) {
1024 $role = "http://purl.imsglobal.org/vocab/lis/v2/membership#{$role}";
1025 }
1026 $newRoles[] = $role;
1027 }
1028 $parms['roles'] = implode(',', $newRoles);
1029 }
1030 $now = time();
1031 if (empty($nonce)) {
1032 $nonce = bin2hex(openssl_random_pseudo_bytes(10));
1033 }
1035 $payLoad = array(
1036 'nonce' => $nonce,
1037 'iat' => $now,
1038 'exp' => $now + 60,
1039 );
1040 $payLoad['iss'] = self::getIliasHttpPath();
1041 $payLoad['aud'] = $oAuthConsumerKey;
1042 $payLoad[self::LTI_JWT_CLAIM_PREFIX . '/claim/deployment_id'] = strval($typeId);
1043 if (!empty($endpoint)) { // only for launch request
1044 $payLoad[self::LTI_JWT_CLAIM_PREFIX . '/claim/target_link_uri'] = $endpoint;
1045 }
1046
1047 foreach ($parms as $key => $value) {
1049 if (array_key_exists($key, $claimMapping)) {
1050 $mapping = $claimMapping[$key];
1051
1052 if (isset($mapping['isArray']) && $mapping['isArray']) {
1053 $value = explode(',', $value);
1054 sort($value);
1055 } elseif (isset($mapping['isBoolean'])) {
1056 $value = $mapping['isBoolean'];
1057 }
1058 if (!empty($mapping['suffix'])) {
1059 $claim .= "-{$mapping['suffix']}";
1060 }
1061 $claim .= '/claim/';
1062 if (is_null($mapping['group'])) {
1063 $payLoad[$mapping['claim']] = $value;
1064 } elseif (empty($mapping['group'])) {
1065 $payLoad["{$claim}{$mapping['claim']}"] = $value;
1066 } else {
1067 $claim .= $mapping['group'];
1068 $payLoad[$claim][$mapping['claim']] = $value;
1069 }
1070 } elseif (strpos($key, 'custom_') === 0) {
1071 $payLoad["{$claim}/claim/custom"][substr($key, 7)] = $value;
1072 } elseif (strpos($key, 'ext_') === 0) {
1073 $payLoad["{$claim}/claim/ext"][substr($key, 4)] = $value;
1074 }
1075 }
1076 //self::getLogger()->debug(json_encode($payLoad,JSON_PRETTY_PRINT));
1077 if (!empty(self::verifyPrivateKey())) {
1078 throw new DomainException(self::ERROR_OPEN_SSL_CONF);
1079 }
1081 $jwt = Firebase\JWT\JWT::encode($payLoad, $privateKey['key'], 'RS256', $privateKey['kid']);
1082 $newParms = $parms;//was array();
1083 $newParms['id_token'] = $jwt;
1084 return $newParms;
1085 }
1086
1087 public static function getPrivateKey(): array
1088 {
1089 global $ilSetting;
1090 $err = self::verifyPrivateKey();
1091 if (!empty($err)) {
1092 return [];
1093 }
1094 $privatekey = $ilSetting->get(self::LTI_1_3_PRIVATE_KEY);
1095 $kid = $ilSetting->get(self::LTI_1_3_KID);
1096 return [
1097 "key" => $privatekey,
1098 "kid" => $kid
1099 ];
1100 }
1101
1102 public static function verifyPrivateKey(): string
1103 {
1104 global $ilSetting;
1105 $key = $ilSetting->get(self::LTI_1_3_PRIVATE_KEY);
1106
1107 if (empty($key)) {
1108 $kid = bin2hex(openssl_random_pseudo_bytes(10));
1109 $ilSetting->set(self::LTI_1_3_KID, $kid);
1110 $config = array(
1111 "digest_alg" => "sha256",
1112 "private_key_bits" => 2048,
1113 "private_key_type" => self::OPENSSL_KEYTYPE_RSA
1114 );
1115 $res = openssl_pkey_new($config);
1116 openssl_pkey_export($res, $privatekey);
1117 if (!empty($privatekey)) {
1118 $ilSetting->set(self::LTI_1_3_PRIVATE_KEY, $privatekey);
1119 } else {
1121 }
1122 }
1123 return '';
1124 }
1125
1126 public static function getPublicKey(): string
1127 {
1128 $publicKey = null;
1130 $res = openssl_pkey_get_private($privateKey['key']);
1131 if ($res !== false) {
1132 $details = openssl_pkey_get_details($res);
1133 $publicKey = $details['key'];
1134 }
1135 return $publicKey;
1136 }
1137
1138 public static function getJwks(): array
1139 {
1140 $jwks = ['keys' => []];
1141
1142 $privatekey = self::getPrivateKey();
1143 $res = openssl_pkey_get_private($privatekey['key']);
1144 $details = openssl_pkey_get_details($res);
1145
1146 $jwk = [];
1147 $jwk['kty'] = 'RSA';
1148 $jwk['alg'] = 'RS256';
1149 $jwk['kid'] = $privatekey['kid'];
1150 $jwk['e'] = rtrim(strtr(base64_encode($details['rsa']['e']), '+/', '-_'), '=');
1151 $jwk['n'] = rtrim(strtr(base64_encode($details['rsa']['n']), '+/', '-_'), '=');
1152 $jwk['use'] = 'sig';
1153
1154 $jwks['keys'][] = $jwk;
1155 return $jwks;
1156 }
1157
1158 public static function getIliasHttpPath(): string
1159 {
1160 global $DIC;
1161
1162 if ($DIC['https']->isDetected()) {
1163 $protocol = 'https://';
1164 } else {
1165 $protocol = 'http://';
1166 }
1167 $host = $_SERVER['HTTP_HOST'];
1168
1169 $rq_uri = strip_tags($_SERVER['REQUEST_URI']);
1170
1171 // security fix: this failed, if the URI contained "?" and following "/"
1172 // -> we remove everything after "?"
1173 if (is_int($pos = strpos($rq_uri, "?"))) {
1174 $rq_uri = substr($rq_uri, 0, $pos);
1175 }
1176
1177 $path = pathinfo($rq_uri);
1178 if (isset($path['extension']) && $path['extension'] !== '') {
1179 $uri = dirname($rq_uri);
1180 } else {
1181 $uri = $rq_uri;
1182 }
1183 $uri = str_replace("Modules/LTIConsumer", "", $uri);
1184 $iliasHttpPath = ilContext::modifyHttpPath(implode('', [$protocol, $host, $uri]));
1185 $f = new \ILIAS\Data\Factory();
1186 $uri = $f->uri(rtrim($iliasHttpPath, "/"));
1187 return $uri->getBaseURI();
1188 }
1189
1190 public static function getPlattformId(): string
1191 {
1192 return self::getIliasHttpPath();
1193 }
1194
1195 public static function getAuthenticationRequestUrl(): string
1196 {
1197 return self::getIliasHttpPath() . "/Modules/LTIConsumer/ltiauth.php";
1198 }
1199
1200 public static function getAccessTokenUrl(): string
1201 {
1202 return self::getIliasHttpPath() . "/Modules/LTIConsumer/ltitoken.php";
1203 }
1204
1205 public static function getPublicKeysetUrl(): string
1206 {
1207 return self::getIliasHttpPath() . "/Modules/LTIConsumer/lticerts.php";
1208 }
1209
1210 public static function getRegistrationUrl(): string
1211 {
1212 return self::getIliasHttpPath() . "/Modules/LTIConsumer/ltiregistration.php";
1213 }
1214
1215 public static function getRegistrationStartUrl(): string
1216 {
1217 return self::getIliasHttpPath() . "/Modules/LTIConsumer/ltiregstart.php";
1218 }
1219
1220 public static function getRegistrationEndUrl(): string
1221 {
1222 return self::getIliasHttpPath() . "/Modules/LTIConsumer/ltiregend.php";
1223 }
1224
1225 public static function getOpenidConfigUrl(): string
1226 {
1227 return self::getIliasHttpPath() . "/Modules/LTIConsumer/lticonfig.php";
1228 }
1229
1230 public static function getOpenidConfig(): array
1231 {
1232 $scopesSupported = array('openid');
1233 $gradeservice = new ilLTIConsumerGradeService();
1234 $scopesSupported = array_merge($scopesSupported, $gradeservice->getPermittedScopes());
1235 return [
1236 "issuer" => self::getPlattformId(),
1237 "authorization_endpoint" => self::getAuthenticationRequestUrl(),
1238 "token_endpoint" => self::getAccessTokenUrl(),
1239 "token_endpoint_auth_methods_supported" => ["private_key_jwt"],
1240 "token_endpoint_auth_signing_alg_values_supported" => ["RS256"],
1241 "jwks_uri" => self::getPublicKeysetUrl(),
1242 "registration_endpoint" => self::getRegistrationUrl(),
1243 "scopes_supported" => $scopesSupported,
1244 "response_types_supported" => ["id_token"],
1245 "subject_types_supported" => ["public", "pairwise"],
1246 "id_token_signing_alg_values_supported" => ["RS256"],
1247 "claims_supported" => ["iss", "aud"],
1248 "https://purl.imsglobal.org/spec/lti-platform-configuration" => [
1249 "product_family_code" => "ilias.de",
1250 "version" => ILIAS_VERSION,
1251 "messages_supported" => [
1252 [
1253 "type" => "LtiResourceLinkRequest",
1254 "placements" => [
1255 ]
1256 ],
1257 [
1258 "type" => "LtiDeepLinkingRequest",
1259 "placements" => [
1260 ]
1261 ]
1262 ]
1263 ]
1264 ];
1265 }
1266
1267 public static function registerClient(array $data, object $tokenObj): array
1268 {
1269 // first analyse tool_config and filter only accepted params
1270 // append client_id (required) and deployment_id(=provider_id in ILIAS) (optional) to tool_config response
1271 global $DIC;
1272 $reponseData = $data;
1274 $toolConfig = $data['https://purl.imsglobal.org/spec/lti-tool-configuration'];
1276 $provider->setProviderUrl($toolConfig['target_link_uri']);
1277 $provider->setInitiateLogin($data['initiate_login_uri']);
1278 $provider->setRedirectionUris(implode(",", $data['redirect_uris']));
1279 if (isset($data['jwks_uri'])) {
1280 $provider->setPublicKeyset($data['jwks_uri']);
1281 }
1282 foreach ($toolConfig['messages'] as $message) {
1283 if (isset($message['type']) && $message['type'] === 'LtiDeepLinkingRequest') {
1284 $provider->setContentItemUrl($message['target_link_uri']);
1285 }
1286 }
1287 /*
1288 if (isset($data['logo_uri'])) { // needs to be uploaded and then assign filepath
1289 $provider->setProviderIconFilename($data['logo_uri']);
1290 }
1291 */
1292 $provider->setKeyType('JWK_KEYSET');
1293 $provider->setLtiVersion('1.3.0');
1294 $provider->setClientId((string) $tokenObj->aud); //client_id
1295 $provider->setCreator((int) $tokenObj->sub); // user_id
1297 $provider->setIsGlobal(false);
1298 $provider->insert();
1299 $reponseData['client_id'] = $tokenObj->aud;
1300 $reponseData['https://purl.imsglobal.org/spec/lti-tool-configuration']['deployment_id'] = $provider->getId();
1301 return $reponseData;
1302 }
1303
1304 public static function getNewClientId(): string
1305 {
1307 }
1308
1309 public static function sendResponseError(int $code, string $message, $log = true): void
1310 {
1311 global $DIC;
1312 try {
1313 if ($log) {
1314 self::getLogger()->error("$code $message");
1315 }
1316 $DIC->http()->saveResponse(
1317 $DIC->http()->response()
1318 ->withStatus($code)
1319 ->withBody(Streams::ofString($message))
1320 );
1321 $DIC->http()->sendResponse();
1322 $DIC->http()->close();
1323 } catch (Exception $e) {
1324 $DIC->http()->close();
1325 }
1326 }
1327
1328 public static function sendResponseJson(array $obj): void
1329 {
1330 global $DIC;
1331 try {
1332 header('Content-Type: application/json; charset=utf-8');
1333 header('Cache-Control: no-store');
1334 header('Pragma: no-cache');
1335 echo json_encode($obj, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
1336 } catch (Exception $e) {
1337 self::sendResponseError(500, "error in sendResponseJson");
1338 $DIC->http()->close();
1339 }
1340 }
1341
1342 public static function getInstance(int $a_id = 0, bool $a_reference = true): \ilObjLTIConsumer
1343 {
1344 return new self($a_id, $a_reference);
1345 }
1346
1347 public function isMixedContentType(): bool
1348 {
1349 return true;
1350 }
1351
1352 public static function getRawData(): ?string
1353 {
1354 return file_get_contents('php://input');
1355 }
1356
1357 public static function getTokenObject(string $token): ?object
1358 {
1359 try {
1360 $keys = JWK::parseKeySet(self::getJwks());
1361 return JWT::decode($token, $keys);
1362 } catch (Exception $e) {
1363 return null;
1364 }
1365 }
1366
1367 public static function verifyToken(): ?object
1368 {
1369 global $DIC;
1370 $auth = $DIC->http()->request()->getHeader("Authorization");
1371 // self::getLogger()->dump($auth);
1372 if (count($auth) < 1) {
1373 self::sendResponseError(405, "missing Authorization header");
1374 }
1375 preg_match('/Bearer\s+(.+)$/i', $auth[0], $matches);
1376 if (count($matches) != 2) {
1377 // self::getLogger()->error("405, missing required Authorization Baerer token in ".$auth[0]);
1378 self::sendResponseError(405, "missing required Authorization Baerer token");
1379 }
1380
1381 $token = $matches[1];
1382 // self::getLogger()->dump($token);
1384 }
1385
1386 public static function getLogger(): ilLogger
1387 {
1388 return ilLoggerFactory::getLogger('lti');
1389 }
1390}
static encode(array $payload, $key, string $alg, string $keyId=null, array $head=null)
Converts and signs a PHP array into a JWT string.
Definition: JWT.php:199
const JWT_CLAIM_MAPPING
Mapping for standard message parameters to JWT claim.
Definition: Util.php:58
static getRandomString(int $length=8)
Generate a random string.
Definition: Util.php:558
const MESSAGE_TYPE_MAPPING
Mapping for standard message types.
Definition: Util.php:48
static getIdent(int $userIdentMode, ilObjUser $user)
static getIdentAsId(int $userIdentMode, ilObjUser $user)
static modifyHttpPath(string $httpPath)
setProviderUrl(string $provider_url)
setPublicKeyset(string $public_keyset)
setLtiVersion(string $lti_version)
setContentItemUrl(string $content_item_url)
setRedirectionUris(string $redirection_uris)
setInitiateLogin(string $initiate_login)
static signOAuth(array $a_params)
sign request data with OAuth
static getByKeys(int $a_obj_id, int $a_usr_id, ?bool $a_create=false)
Get a result by object and user key.
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
const PRIVACY_IDENT_IL_UUID_RANDOM
bool $activationLimited
repository object activation settings (handled by ilObject)
static sendResponseError(int $code, string $message, $log=true)
setCustomLaunchSecret(string $customLaunchSecret)
getHighscoreEnabled()
Gets the setting which determines if the highscore feature is enabled.
getHighscoreTopTable()
Gets, if the top-rankings table should be shown.
setProvider(ilLTIConsumeProvider $provider)
setHighscorePercentage(bool $a_percentage)
Sets if the percentages of the scores pass should be shown.
setCustomParams(string $customParams)
static getTokenObject(string $token)
setHighscoreEnabled(bool $a_enabled)
HIGHSCORE.
setHighscoreAchievedTS(bool $a_achieved_ts)
Sets if the date and time of the scores achievement should be displayed.
buildLaunchParametersLTI13(ilCmiXapiUser $cmixUser, string $endpoint, string $clientId, int $deploymentId, string $nonce, string $contextType, string $contextId, string $contextTitle, ?string $returnUrl='')
setHighscoreOwnTable(bool $a_own_table)
Sets if the table with the own ranking should be shown.
setLaunchMethod(string $launchMethod)
getHighscoreOwnTable()
Gets if the own rankings table should be shown.
static getInstance(int $a_id=0, bool $a_reference=true)
getHighscorePercentage()
Gets if the percentage column should be shown.
setActivationEndingTime(?int $activationEndingTime=null)
buildLaunchParameters(ilCmiXapiUser $cmixUser, string $token, string $contextType, string $contextId, string $contextTitle, ?string $returnUrl='')
setActivationLimited(bool $activationLimited)
setStatementsReportEnabled(bool $statementsReportEnabled)
setMasteryScorePercent(float $mastery_score_percent)
static LTISignJWT(array $parms, string $endpoint, string $oAuthConsumerKey, $typeId=0, string $nonce='')
static buildContentSelectionParameters(ilLTIConsumeProvider $provider, int $refId, string $returnUrl, string $nonce)
setHighscoreTopNum(int $a_top_num)
Sets the number of entries which are to be shown in the top-rankings table.
ilLTIConsumeProvider $provider
static registerClient(array $data, object $tokenObj)
setHighscoreWTime(bool $a_wtime)
Sets if the workingtime of the scores should be shown.
setCustomLaunchKey(string $customLaunchKey)
setProviderId(int $providerId)
static getProviderCustomParamsArray(ilLTIConsumeProvider $provider)
setHighscoreTopTable(bool $a_top_table)
Sets if the top-rankings table should be shown.
getHighscoreAchievedTS()
Returns if date and time of the scores achievement should be displayed.
setActivationVisibility(bool $activationVisibility)
setMasteryScore(float $mastery_score)
getHighscoreWTime()
Gets if the column with the workingtime should be shown.
__construct(int $a_id=0, bool $a_reference=true)
ilObjLTIConsumer constructor.
getHighscoreTopNum(int $a_retval=10)
Gets the number of entries which are to be shown in the top-rankings table.
setCustomActivityId(string $custom_activity_id)
setActivationStartingTime(?int $activationStartingTime=null)
static sendResponseJson(array $obj)
setUseXapi(bool $use_xapi)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjectActivation.
static getItem(int $ref_id)
const ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
ilLogger $log
const CLIENT_ID
Definition: constants.php:41
const SYSTEM_ROLE_ID
Definition: constants.php:29
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: feed.php:28
$iliasHttpPath
Definition: imgupload.php:50
const ILIAS_VERSION
$clientId
Definition: ltiregend.php:27
$privateKey
Definition: ltiregstart.php:68
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
$typeId
Definition: ltiregstart.php:36
$path
Definition: ltiservices.php:32
$res
Definition: ltiservices.php:69
$auth
Definition: metadata.php:76
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
$keys
Definition: metadata.php:204
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
ClientInterface $jwt
JWT object, if any.
Definition: System.php:165
string $kid
Key ID.
Definition: System.php:88
string $key
Consumer key/client ID value.
Definition: System.php:193
array $details
Details for error message relating to last request processed.
Definition: System.php:109
global $ilSetting
Definition: privfeed.php:17
$query
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$context
Definition: webdav.php:29
$message
Definition: xapiexit.php:32
$token
Definition: xapitoken.php:70
$refId
Definition: xapitoken.php:58
$param
Definition: xapitoken.php:46