ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjLTIConsumerGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
26 {
27  const CFORM_CUSTOM_NEW = 99;
28 
29  const TAB_ID_INFO = 'tab_info';
30  const TAB_ID_CONTENT = 'tab_content';
31  const TAB_ID_SETTINGS = 'tab_settings';
32  const TAB_ID_STATEMENTS = 'tab_statements';
33  const TAB_ID_SCORING = 'tab_scoring';
34  const TAB_ID_METADATA = 'tab_metadata';
35  const TAB_ID_LEARNING_PROGRESS = 'learning_progress';
36  const TAB_ID_PERMISSIONS = 'perm_settings';
37 
38  const DEFAULT_CMD = 'infoScreen';
39 
43  public $object;
44 
48  protected $ltiAccess;
49 
50  public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
51  {
52  global $DIC; /* @var \ILIAS\DI\Container $DIC */
53 
54  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
55 
56  if ($this->object instanceof ilObjLTIConsumer) {
57  $this->ltiAccess = new ilLTIConsumerAccess($this->object);
58  }
59 
60  $DIC->language()->loadLanguageModule("lti");
61  $DIC->language()->loadLanguageModule("rep");
62  }
63 
64  public function getType()
65  {
66  return 'lti';
67  }
68 
69  public function initCreationForms($a_new_type)
70  {
71  global $DIC; /* @var \ILIAS\DI\Container $DIC */
72 
73  $forms = array(
74  self::CFORM_NEW => $this->initCreateForm($a_new_type)
75  );
76 
78  $forms[self::CFORM_CUSTOM_NEW] = $this->initCustomCreateForm($a_new_type);
79  }
80 
81  //$forms[self::CFORM_IMPORT] = $this->initImportForm($a_new_type), // no import yet
82  $forms[self::CFORM_CLONE] = $this->fillCloneTemplate(null, $a_new_type);
83 
84  return $forms;
85  }
86 
87  public function initCreateForm($a_new_type)
88  {
89  global $DIC; /* @var \ILIAS\DI\Container $DIC */
90 
91  $form = $this->buildProviderSelectionForm($a_new_type);
92 
93  $globalProviderList = new ilLTIConsumeProviderList();
94  $globalProviderList->setAvailabilityFilter(ilLTIConsumeProvider::AVAILABILITY_CREATE);
95  $globalProviderList->setScopeFilter(ilLTIConsumeProviderList::SCOPE_GLOBAL);
96 
97  $userProviderList = new ilLTIConsumeProviderList();
98  $userProviderList->setAvailabilityFilter(ilLTIConsumeProvider::AVAILABILITY_CREATE);
99  $userProviderList->setScopeFilter(ilLTIConsumeProviderList::SCOPE_USER);
100  $userProviderList->setCreatorFilter($DIC->user()->getId());
101 
102  if ($form->getFilter('title')) {
103  $globalProviderList->setTitleFilter($form->getFilter('title'));
104  $userProviderList->setTitleFilter($form->getFilter('title'));
105  }
106 
107  if ($form->getFilter('category')) {
108  $globalProviderList->setCategoryFilter($form->getFilter('category'));
109  $userProviderList->setCategoryFilter($form->getFilter('category'));
110  }
111 
112  if ($form->getFilter('keyword')) {
113  $globalProviderList->setKeywordFilter($form->getFilter('keyword'));
114  $userProviderList->setKeywordFilter($form->getFilter('keyword'));
115  }
116 
117  if ($form->getFilter('outcome')) {
118  $globalProviderList->setHasOutcomeFilter(true);
119  $userProviderList->setHasOutcomeFilter(true);
120  }
121 
122  if ($form->getFilter('internal')) {
123  $globalProviderList->setIsExternalFilter(false);
124  $userProviderList->setIsExternalFilter(false);
125  }
126 
127  if ($form->getFilter('with_key')) {
128  $globalProviderList->setIsProviderKeyCustomizableFilter(false);
129  $userProviderList->setIsProviderKeyCustomizableFilter(false);
130  }
131 
132  $globalProviderList->load();
133  $userProviderList->load();
134 
135  $form->setData(array_merge(
136  $globalProviderList->getTableData(),
137  $userProviderList->getTableData()
138  ));
139 
140  return $form;
141  }
142 
143  public function initCustomCreateForm($a_new_type)
144  {
145  global $DIC; /* @var \ILIAS\DI\Container $DIC */
146 
147  $provider = new ilLTIConsumeProvider();
148 
149  $form = new ilLTIConsumeProviderFormGUI($provider);
150 
151  $form->initForm($this->ctrl->getFormAction($this, "save"), '', '');
152 
153  $form->clearCommandButtons();
154  $form->addCommandButton("saveCustom", $this->lng->txt($a_new_type . "_add_own_provider"));
155  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
156 
157  $form->setTitle($DIC->language()->txt($a_new_type . '_custom_new'));
158 
159  return $form;
160  }
161 
162  protected function buildProviderSelectionForm($a_new_type)
163  {
165  $a_new_type,
166  $this,
167  'create',
168  'applyProviderFilter',
169  'resetProviderFilter'
170  );
171  }
172 
173  protected function applyProviderFilter()
174  {
175  $form = $this->buildProviderSelectionForm('');
176  $form->applyFilter();
177  $this->createObject();
178  }
179 
180  protected function resetProviderFilter()
181  {
182  $form = $this->buildProviderSelectionForm('');
183  $form->resetFilter();
184  $this->createObject();
185  }
186 
187  protected function createNewObject($newType, $title, $description)
188  {
189  $classname = "ilObj" . $this->objDefinition->getClassName($newType);
190 
191  $newObj = new $classname();
192  $newObj->setType($newType);
193  $newObj->setTitle($title);
194  $newObj->setDescription($description);
195  $newObj->create();
196 
197  $this->putObjectInTree($newObj);
198 
199  return $newObj;
200  }
201 
202  public function saveCustom()
203  {
205  throw new ilLtiConsumerException('permission denied!');
206  }
207 
208  global $DIC; /* @var \ILIAS\DI\Container $DIC */
209 
210  $new_type = $_REQUEST["new_type"];
211  $DIC->ctrl()->setParameter($this, "new_type", $new_type);
212 
213  $DIC->language()->loadLanguageModule($new_type);
214 
215  $form = $this->initCustomCreateForm($new_type);
216 
217  if ($form->checkInput()) {
218  $DIC->ctrl()->setParameter($this, "new_type", "");
219 
220  // create object
221  $newObj = $this->createNewObject(
222  $new_type,
223  $form->getInput('title'),
224  $form->getInput('desc')
225  );
226 
227  // apply didactic template?
228  $dtpl = $this->getDidacticTemplateVar("dtpl");
229  if ($dtpl) {
230  $newObj->applyDidacticTemplate($dtpl);
231  }
232 
233  // auto rating
234  $this->handleAutoRating($newObj);
235 
236  $this->afterSave($newObj);
237 
238  return;
239  }
240 
241  $form->setValuesByPost();
242 
243  $DIC->ui()->mainTemplate()->setContent($form->getHtml());
244  }
245 
246  public function afterSave(ilObject $newObject)
247  {
248  /* @var ilObjLTIConsumer $newObject */
249  global $DIC; /* @var \ILIAS\DI\Container $DIC */
250 
251  if (isset($_GET['provider_id']) && (int) $_GET['provider_id']) {
252  $newObject->setProviderId((int) $_GET['provider_id']);
253  $newObject->initProvider();
254  $newObject->save();
255 
256  $newObject->setTitle($newObject->getProvider()->getTitle());
257  $newObject->setMasteryScore($newObject->getProvider()->getMasteryScore());
258  $newObject->update();
259 
260  $this->initMetadata($newObject);
261 
262  $DIC->ctrl()->redirectByClass(ilLTIConsumerSettingsGUI::class);
263  }
264 
266  throw new ilLtiConsumerException('permission denied!');
267  }
268 
269  $form = $this->initCustomCreateForm($newObject->getType());
270 
271  if ($form->checkInput()) {
272  $provider = new ilLTIConsumeProvider();
273  $form->initProvider($provider);
274  $provider->setAvailability(ilLTIConsumeProvider::AVAILABILITY_CREATE);
275  $provider->setIsGlobal(false);
276  $provider->setCreator($DIC->user()->getId());
277  $provider->save();
278 
279  $newObject->setProviderId($provider->getId());
280  $newObject->setProvider($provider);
281  $newObject->save();
282 
283  $newObject->setTitle($provider->getTitle());
284  $newObject->setMasteryScore($newObject->getProvider()->getMasteryScore());
285  $newObject->update();
286 
287  $this->initMetadata($newObject);
288 
289  $DIC->ctrl()->redirectByClass(ilObjLTIConsumerGUI::class);
290  }
291 
292  throw new ilLtiConsumerException(
293  'form validation seems to not have worked in ilObjLTIConsumer::saveCustom()!'
294  );
295  }
296 
298  {
299  $metadata = new ilMD($object->getId(), $object->getId(), $object->getType());
300 
301  $generalMetadata = $metadata->getGeneral();
302 
303  if (!$generalMetadata) {
304  $generalMetadata = $metadata->addGeneral();
305  }
306 
307  $generalMetadata->setTitle($object->getTitle());
308  $generalMetadata->save();
309 
310  $id = $generalMetadata->addIdentifier();
311  $id->setCatalog('ILIAS');
312  $id->setEntry('il__' . $object->getType() . '_' . $object->getId());
313  $id->save();
314 
315  $keywords = $object->getProvider()->getKeywordsArray();
316  ilMDKeyword::updateKeywords($generalMetadata, $keywords);
317  }
318 
319  protected function initHeaderAction($a_sub_type = null, $a_sub_id = null)
320  {
321  global $DIC; /* @var \ILIAS\DI\Container $DIC */
322 
323  $return = parent::initHeaderAction($a_sub_type, $a_sub_id);
324 
325  if ($this->creation_mode) {
326  return $return;
327  }
328 
329  $validator = new ilCertificateDownloadValidator();
330  if ($validator->isCertificateDownloadable((int) $DIC->user()->getId(), (int) $this->object->getId())) {
331  $certLink = $DIC->ctrl()->getLinkTargetByClass(
332  [ilObjLTIConsumerGUI::class, ilLTIConsumerSettingsGUI::class],
334  );
335 
336  $DIC->language()->loadLanguageModule('certificate');
337 
338  $return->addCustomCommand($certLink, 'download_certificate');
339 
340  $return->addHeaderIcon(
341  'cert_icon',
342  ilUtil::getImagePath('icon_cert.svg'),
343  $DIC->language()->txt('download_certificate'),
344  null,
345  null,
346  $certLink
347  );
348  }
349 
350  return $return;
351  }
352 
353  public static function _goto($a_target)
354  {
355  global $DIC; /* @var \ILIAS\DI\Container $DIC */
356  $err = $DIC['ilErr']; /* @var ilErrorHandling $err */
357  $ctrl = $DIC->ctrl();
358  $request = $DIC->http()->request();
359  $access = $DIC->access();
360  $lng = $DIC->language();
361 
362  $targetParameters = explode('_', $a_target);
363  $id = (int) $targetParameters[0];
364 
365  if ($id <= 0) {
366  $err->raiseError($lng->txt('msg_no_perm_read'), $err->FATAL);
367  }
368 
369  if ($access->checkAccess('read', '', $id)) {
370  $ctrl->setTargetScript('ilias.php');
371  $ctrl->initBaseClass(ilRepositoryGUI::class);
372  $ctrl->setParameterByClass(ilObjLTIConsumerGUI::class, 'ref_id', $id);
373  if (isset($request->getQueryParams()['gotolp'])) {
374  $ctrl->setParameterByClass(ilObjLTIConsumerGUI::class, 'gotolp', 1);
375  }
376  $ctrl->redirectByClass([ilRepositoryGUI::class, ilObjLTIConsumerGUI::class]);
377  } elseif ($access->checkAccess('visible', '', $id)) {
378  ilObjectGUI::_gotoRepositoryNode($id, 'infoScreen');
379  } elseif ($access->checkAccess('read', '', ROOT_FOLDER_ID)) {
381  sprintf(
382  $DIC->language()->txt('msg_no_perm_read_item'),
384  ),
385  true
386  );
387 
389  }
390 
391  $err->raiseError($DIC->language()->txt("msg_no_perm_read_lm"), $err->FATAL);
392  }
393 
397  public function executeCommand()
398  {
399  global $DIC; /* @var \ILIAS\DI\Container $DIC */
400 
401  // TODO: general access checks (!)
402 
404  $this->prepareOutput();
405  $this->addHeaderAction();
406  }
407 
408  if (!$this->creation_mode) {
409  $this->trackObjectReadEvent();
410 
411  if ($this->object->getProvider()->hasProviderIcon()) {
412  $DIC->ui()->mainTemplate()->setTitleIcon(
413  $this->object->getProvider()->getProviderIcon()->getAbsoluteFilePath(),
414  'Icon ' . $this->object->getProvider()->getTitle()
415  );
416  }
417 
418  $link = ilLink::_getLink($this->object->getRefId(), $this->object->getType());
419  $navigationHistory = $DIC['ilNavigationHistory']; /* @var ilNavigationHistory $navigationHistory */
420  $navigationHistory->addItem($this->object->getRefId(), $link, $this->object->getType());
421  }
422 
423  switch ($DIC->ctrl()->getNextClass()) {
424  case strtolower(ilObjectCopyGUI::class):
425 
426  $gui = new ilObjectCopyGUI($this);
427  $gui->setType($this->getType());
428  $DIC->ctrl()->forwardCommand($gui);
429  break;
430 
431  case strtolower(ilCommonActionDispatcherGUI::class):
432 
434  $DIC->ctrl()->forwardCommand($gui);
435  break;
436 
437  case strtolower(ilLearningProgressGUI::class):
438 
439  $DIC->tabs()->activateTab(self::TAB_ID_LEARNING_PROGRESS);
440 
441  $gui = new ilLearningProgressGUI(
443  $this->object->getRefId()
444  );
445 
446  $DIC->ctrl()->forwardCommand($gui);
447 
448  break;
449 
450  case strtolower(ilObjectMetaDataGUI::class):
451 
452  $DIC->tabs()->activateTab(self::TAB_ID_METADATA);
453 
454  $gui = new ilObjectMetaDataGUI($this->object);
455  $DIC->ctrl()->forwardCommand($gui);
456  break;
457 
458  case strtolower(ilPermissionGUI::class):
459 
460  $DIC->tabs()->activateTab(self::TAB_ID_PERMISSIONS);
461 
462  $gui = new ilPermissionGUI($this);
463  $DIC->ctrl()->forwardCommand($gui);
464  break;
465 
466  case strtolower(ilLTIConsumerSettingsGUI::class):
467 
468  $DIC->tabs()->activateTab(self::TAB_ID_SETTINGS);
469 
470  $gui = new ilLTIConsumerSettingsGUI($this->object, $this->ltiAccess);
471  $DIC->ctrl()->forwardCommand($gui);
472  break;
473 
474  case strtolower(ilLTIConsumerXapiStatementsGUI::class):
475 
476  $DIC->tabs()->activateTab(self::TAB_ID_STATEMENTS);
477 
478  $gui = new ilLTIConsumerXapiStatementsGUI($this->object);
479  $DIC->ctrl()->forwardCommand($gui);
480 
481  break;
482 
483  case strtolower(ilLTIConsumerScoringGUI::class):
484 
485  $DIC->tabs()->activateTab(self::TAB_ID_SCORING);
486 
487  $gui = new ilLTIConsumerScoringGUI($this->object);
488  $DIC->ctrl()->forwardCommand($gui);
489 
490  break;
491 
492  case strtolower(ilLTIConsumerEmbeddedContentGUI::class):
493 
494  $DIC->tabs()->activateTab(self::TAB_ID_CONTENT);
495 
496  $gui = new ilLTIConsumerEmbeddedContentGUI($this->object);
497  $DIC->ctrl()->forwardCommand($gui);
498 
499  break;
500 
501  default:
502  $command = $DIC->ctrl()->getCmd(self::DEFAULT_CMD);
503  $this->{$command}();
504  }
505  }
506 
507  public function setTabs()
508  {
509  global $DIC; /* @var \ILIAS\DI\Container $DIC */
510  $DIC->language()->loadLanguageModule('lti');
511 
512  $DIC->tabs()->addTab(
513  self::TAB_ID_INFO,
514  $DIC->language()->txt(self::TAB_ID_INFO),
515  $DIC->ctrl()->getLinkTargetByClass(self::class)
516  );
517 
518  if (!$this->object->getOfflineStatus() && $this->object->isLaunchMethodEmbedded() &&
519  $this->object->getProvider()->getAvailability() != ilLTIConsumeProvider::AVAILABILITY_NONE
520  ) {
521  $DIC->tabs()->addTab(
522  self::TAB_ID_CONTENT,
523  $DIC->language()->txt(self::TAB_ID_CONTENT),
524  $DIC->ctrl()->getLinkTargetByClass(ilLTIConsumerEmbeddedContentGUI::class)
525  );
526  }
527 
528  if ($this->ltiAccess->hasWriteAccess()) {
529  $DIC->tabs()->addTab(
530  self::TAB_ID_SETTINGS,
531  $DIC->language()->txt(self::TAB_ID_SETTINGS),
532  $DIC->ctrl()->getLinkTargetByClass(ilLTIConsumerSettingsGUI::class)
533  );
534  }
535 
536  if ($this->ltiAccess->hasStatementsAccess()) {
537  $DIC->tabs()->addTab(
538  self::TAB_ID_STATEMENTS,
539  $DIC->language()->txt(self::TAB_ID_STATEMENTS),
540  $DIC->ctrl()->getLinkTargetByClass(ilLTIConsumerXapiStatementsGUI::class)
541  );
542  }
543 
544  if ($this->ltiAccess->hasHighscoreAccess()) {
545  $DIC->language()->loadLanguageModule('lti');
546  $DIC->tabs()->addTab(
547  self::TAB_ID_SCORING,
548  $DIC->language()->txt(self::TAB_ID_SCORING),
549  $DIC->ctrl()->getLinkTargetByClass(ilLTIConsumerScoringGUI::class)
550  );
551  }
552 
553  if ($this->ltiAccess->hasLearningProgressAccess() && $this->object->getProvider()->getHasOutcome()) {
554  $DIC->tabs()->addTab(
555  self::TAB_ID_LEARNING_PROGRESS,
556  $DIC->language()->txt(self::TAB_ID_LEARNING_PROGRESS),
557  $DIC->ctrl()->getLinkTargetByClass(ilLearningProgressGUI::class)
558  );
559  }
560 
561  if ($this->ltiAccess->hasWriteAccess()) {
562  $gui = new ilObjectMetaDataGUI($this->object);
563  $link = $gui->getTab();
564 
565  if (strlen($link)) {
566  $DIC->tabs()->addTab(
567  self::TAB_ID_METADATA,
568  $DIC->language()->txt('meta_data'),
569  $link
570  );
571  }
572  }
573 
574  if ($this->ltiAccess->hasEditPermissionsAccess()) {
575  $DIC->tabs()->addTab(
576  self::TAB_ID_PERMISSIONS,
577  $DIC->language()->txt(self::TAB_ID_PERMISSIONS),
578  $DIC->ctrl()->getLinkTargetByClass(ilPermissionGUI::class, 'perm')
579  );
580  }
581 
582  if (defined('DEVMODE') && DEVMODE) {
583  $DIC->tabs()->addTab(
584  'debug',
585  'DEBUG',
586  $DIC->ctrl()->getLinkTarget($this, 'debug')
587  );
588  }
589  }
590 
591  protected function debug()
592  {
593  global $DIC; /* @var \ILIAS\DI\Container $DIC */
594 
595  $DIC->tabs()->activateTab('debug');
596 
597  $filter = new ilCmiXapiStatementsReportFilter();
598  $filter->setActivityId($this->object->getActivityId());
599 
600  $aggregateEndPointUrl = str_replace(
601  'data/xAPI',
602  'api/statements/aggregate',
603  $this->object->getProvider()->getXapiLaunchUrl() // should be named endpoint not launch url
604  );
605 
606  $linkBuilder = new ilCmiXapiHighscoreReportLinkBuilder(
607  $this->object,
608  $aggregateEndPointUrl,
609  $filter
610  );
611 
613  $this->object->getProvider()->getXapiLaunchKey(),
614  $this->object->getProvider()->getXapiLaunchSecret()
615  );
616 
617  $request = new ilCmiXapiHighscoreReportRequest(
618  $basicAuth,
619  $linkBuilder
620  );
621 
622  try {
623  $report = $request->queryReport($this->object);
624 
625  $DIC->ui()->mainTemplate()->setContent(
626  $report->getResponseDebug()
627  );
628 
629  //ilUtil::sendSuccess('Object ID: '.$this->object->getId());
630  ilUtil::sendInfo($linkBuilder->getPipelineDebug());
631  ilUtil::sendQuestion('<pre>' . print_r($report->getTableData(), 1) . '</pre>');
632  } catch (Exception $e) {
633  ilUtil::sendFailure($e->getMessage());
634  }
635  }
636 
637  public function addLocatorItems()
638  {
639  global $DIC; /* @var \ILIAS\DI\Container $DIC */
640 
641  $locator = $DIC['ilLocator']; /* @var ilLocatorGUI $locator */
642  $locator->addItem(
643  $this->object->getTitle(),
644  $this->ctrl->getLinkTarget($this, self::DEFAULT_CMD),
645  "",
646  $_GET["ref_id"]
647  );
648  }
649 
650  protected function trackObjectReadEvent()
651  {
652  global $DIC; /* @var \ILIAS\DI\Container $DIC */
653 
655  $this->object->getType(),
656  $this->object->getRefId(),
657  $this->object->getId(),
658  $DIC->user()->getId()
659  );
660 
661  ilLPStatusWrapper::_updateStatus($this->object->getId(), $DIC->user()->getId());
662  }
663 
664  protected function infoScreen()
665  {
666  global $DIC; /* @var \ILIAS\DI\Container $DIC */
667 
668  $DIC->tabs()->activateTab(self::TAB_ID_INFO);
669 
670  $DIC->ctrl()->setCmd("showSummary");
671  $DIC->ctrl()->setCmdClass("ilinfoscreengui");
672  $this->infoScreenForward();
673  }
674 
675  protected function infoScreenForward()
676  {
677  global $DIC; /* @var \ILIAS\DI\Container $DIC */
678  $ilErr = $DIC['ilErr']; /* @var ilErrorHandling $ilErr */
679 
680  if (!$this->checkPermissionBool("visible") && !$this->checkPermissionBool("read")) {
681  $ilErr->raiseError($DIC->language()->txt("msg_no_perm_read"));
682  }
683 
684  $this->handleAvailablityMessage();
685  $this->initInfoScreenToolbar();
686 
687  $info = new ilInfoScreenGUI($this);
688 
689  $info->enablePrivateNotes();
690 
691  if ($this->checkPermissionBool("read")) {
692  $info->enableNews();
693  }
694 
695  $info->enableNewsEditing(false);
696 
697  if ($this->checkPermissionBool("write")) {
698  $news_set = new ilSetting("news");
699  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
700 
701  if ($enable_internal_rss) {
702  $info->setBlockProperty("news", "settings", true);
703  $info->setBlockProperty("news", "public_notifications_option", true);
704  }
705  }
706 
707  // standard meta data
708  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
709 
710  if (DEVMODE) {
711  // Development Info
712  $info->addSection('DEVMODE Info');
713  $info->addProperty('Local Object ID', $this->object->getId());
714  $info->addProperty('Current User ID', $DIC->user()->getId());
715  }
716 
717  require_once('Services/Tracking/classes/class.ilLPObjSettings.php');
718  if ($this->object->getProvider()->getHasOutcome() && ilLPObjSettings::_lookupDBMode($this->object->getId()) != 0) {
719  $info->addSection($DIC->language()->txt("lti_info_learning_progress_section"));
720  $info->addProperty(
721  $DIC->language()->txt("mastery_score"),
722  ($this->object->getMasteryScorePercent()) . ' %'
723  );
724  }
725 
726  // LTI Ressource Info about privacy
727  $info->addSection($DIC->language()->txt("lti_info_privacy_section"));
728 
729  $info->addProperty(
730  $DIC->language()->txt("lti_con_prov_url"),
731  $this->object->getProvider()->getProviderUrl()
732  );
733 
734  $info->addProperty(
735  $DIC->language()->txt("conf_privacy_name"),
736  $DIC->language()->txt('conf_privacy_name_' . ilObjCmiXapiGUI::getPrivacyNameString($this->object->getProvider()->getPrivacyName()))
737  );
738 
739  $info->addProperty(
740  $DIC->language()->txt("conf_privacy_ident"),
741  $DIC->language()->txt('conf_privacy_ident_' . ilObjCmiXapiGUI::getPrivacyIdentString($this->object->getProvider()->getPrivacyIdent()))
742  );
743  if ($this->object->getProvider()->isExternalProvider()) {
744  $info->addProperty(
745  $DIC->language()->txt("lti_info_external_provider_label"),
746  $DIC->language()->txt('lti_info_external_provider_info')
747  );
748  }
749 
750  if ($this->object->getProvider()->getUseXapi()) {
751  $info->addProperty(
752  $DIC->language()->txt("lti_con_prov_xapi_launch_url"),
753  $this->object->getProvider()->getXapiLaunchUrl()
754  );
755  }
756 
757  // FINISHED INFO SCREEN, NOW FORWARD
758  $this->ctrl->forwardCommand($info);
759  }
760 
761  protected function initInfoScreenToolbar()
762  {
763  global $DIC; /* @var \ILIAS\DI\Container $DIC */
764 
765  if ($this->object->getOfflineStatus() ||
766  $this->object->isLaunchMethodEmbedded() ||
767  $this->object->getProvider()->getAvailability() == ilLTIConsumeProvider::AVAILABILITY_NONE) {
768  return;
769  }
770 
771  $cmixUser = new ilCmiXapiUser($this->object->getId(), $this->user->getId(), $this->object->getProvider()->getPrivacyIdent());
772  $user_ident = $cmixUser->getUsrIdent();
773  if ($user_ident == '' || $user_ident == null) {
774  $user_ident = ilCmiXapiUser::getIdent($this->object->getProvider()->getPrivacyIdent(), $DIC->user());
775  $cmixUser->setUsrIdent($user_ident);
776  $cmixUser->save();
777  }
778 
779  include_once("./Modules/LTIConsumer/classes/class.ilLTIConsumerLaunch.php");
780  $ilLTIConsumerLaunch = new ilLTIConsumerLaunch($this->object->getRefId());
781  $context = $ilLTIConsumerLaunch->getContext();
782  $contextType = $ilLTIConsumerLaunch::getLTIContextType($context["type"]);
783  $contextId = $context["id"];
784  $contextTitle = $context["title"];
785 
786  require_once("Modules/SystemFolder/classes/class.ilObjSystemFolder.php");
787  require_once('./Services/Link/classes/class.ilLink.php');
788 
790  $DIC->user()->getId(),
791  $this->object->getRefId(),
792  $this->object->getId()
793  );
794 
795  $returnUrl = !$this->object->isLaunchMethodOwnWin() ? '' : str_replace(
796  '&amp;',
797  '&',
798  ILIAS_HTTP_PATH . "/" . $DIC->ctrl()->getLinkTarget($this, "", "", false)
799  );
800 
801  $launchParameters = $this->object->buildLaunchParameters(
802  $cmixUser,
803  $token,
804  $contextType,
805  $contextId,
806  $contextTitle,
807  $returnUrl
808  );
809 
810  $button = '<input class="btn btn-default ilPre" type="button" onClick="ltilaunch()" value = "' . $this->lng->txt("launch") . '" />';
811  $target = $this->object->getLaunchMethod() == "newWin" ? "_blank" : "_self";
812 
813  $output = '<form id="lti_launch_form" name="lti_launch_form" action="' . $this->object->getProvider()->getProviderUrl() . '" method="post" target="' . $target . '" encType="application/x-www-form-urlencoded">';
814  foreach ($launchParameters as $field => $value) {
815  $output .= sprintf('<input type="hidden" name="%s" value="%s" />', $field, $value) . "\n";
816  }
817  $output .= $button;
818  $output .= '</form>';
819  $output .= '<span id ="lti_launched" style="display:none">' . $this->lng->txt("launched") . '</span>';
820  $output .= '<script type="text/javascript">
821  function ltilaunch() {
822  document.lti_launch_form.submit();
823  document.getElementById("lti_launch_form").style.display = "none";
824  document.getElementById("lti_launched").style.display = "inline";
825  }</script>';
826  $DIC->toolbar()->addText($output);
827  }
828 
829  protected function handleAvailablityMessage()
830  {
831  global $DIC; /* @var \ILIAS\DI\Container $DIC */
832  if ($this->object->getProvider()->getProviderUrl() == '') {
833  ilUtil::sendFailure($DIC->language()->txt('lti_provider_not_set_msg'));
834  } elseif ($this->object->getProvider()->getAvailability() == ilLTIConsumeProvider::AVAILABILITY_NONE) {
835  ilUtil::sendFailure($DIC->language()->txt('lti_provider_not_avail_msg'));
836  }
837  }
838 }
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
Class ilObjectMetaDataGUI.
Class ilInfoScreenGUI.
$context
Definition: webdav.php:26
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
New implementation of ilObjectGUI.
GUI class for the workflow of copying objects.
$_GET["client_id"]
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
afterSave(ilObject $newObject)
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
fillCloneTemplate($a_tpl_varname, $a_type)
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
static _lookupTitle($a_id)
lookup object title
createObject()
create new object form
user()
Definition: user.php:4
setTitle($a_title)
set object title
static updateKeywords(ilMDGeneral $a_md_section, array $a_keywords)
Update keywords from input array.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
& addGeneral()
Definition: class.ilMD.php:52
static _lookupDBMode($a_obj_id)
createNewObject($newType, $title, $description)
getId()
get object id public
static getPrivacyIdentString(int $ident)
$token
Definition: xapitoken.php:57
static _gotoRepositoryNode($a_ref_id, $a_cmd="frameset")
Goto repository root.
static getPrivacyNameString(int $ident)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static _lookupObjId($a_id)
static buildBasicAuth($lrsKey, $lrsSecret)
Validates if an active certificate is stored in the database and can be downloaded by the user...
handleAutoRating(ilObject $a_new_obj)
getTitle()
get object title public
& getGeneral()
Definition: class.ilMD.php:40
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
getType()
get object type public
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static fillToken($usrId, $refId, $objId, $lrsTypeId=0)
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
__construct(Container $dic, ilPlugin $plugin)
$DIC
Definition: xapitoken.php:46
static getIdent($userIdentMode, ilObjUser $user)
prepareOutput($a_show_subobjects=true)
getDidacticTemplateVar($a_type)
Get didactic template setting from creation screen.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
initMetadata(ilObjLTIConsumer $object)
update()
update object in db
initHeaderAction($a_sub_type=null, $a_sub_id=null)
addHeaderAction()
Add header action menu.
Class ilObjUserTrackingGUI.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call