ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilCmiXapiSettingsGUI.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 
18 {
19  const CMD_SHOW = 'show';
20  const CMD_DELIVER_CERTIFICATE = 'deliverCertificate';
21 
22  const CMD_SAVE = 'save';
23 
24  const DEFAULT_CMD = self::CMD_SHOW;
25 
26  const SUBTAB_ID_SETTINGS = 'settings';
27  const SUBTAB_ID_CERTIFICATE = 'certificate';
28 
32  protected $object;
33 
37  public function __construct(ilObjCmiXapi $object)
38  {
39  $this->object = $object;
40  }
41 
42  public function initSubtabs()
43  {
44  global $DIC; /* @var \ILIAS\DI\Container $DIC */
45 
46  $DIC->tabs()->addSubTab(
47  self::SUBTAB_ID_SETTINGS,
48  $DIC->language()->txt(self::SUBTAB_ID_SETTINGS),
49  $DIC->ctrl()->getLinkTarget($this, self::CMD_SHOW)
50  );
51 
52  $validator = new ilCertificateActiveValidator();
53 
54  if ($validator->validate()) {
55  $DIC->tabs()->addSubTab(
56  self::SUBTAB_ID_CERTIFICATE,
57  $DIC->language()->txt(self::SUBTAB_ID_CERTIFICATE),
58  $DIC->ctrl()->getLinkTargetByClass(ilCertificateGUI::class, 'certificateEditor')
59  );
60  }
61  }
62 
63  public function executeCommand()
64  {
65  global $DIC; /* @var \ILIAS\DI\Container $DIC */
66 
67  $this->initSubtabs();
68 
69  switch ($DIC->ctrl()->getNextClass()) {
70  case strtolower(ilCertificateGUI::class):
71 
72  $validator = new ilCertificateActiveValidator();
73 
74  if (!$validator->validate()) {
75  throw new ilCmiXapiException('access denied!');
76  }
77 
78  $DIC->tabs()->activateSubTab(self::SUBTAB_ID_CERTIFICATE);
79 
80  $guiFactory = new ilCertificateGUIFactory();
81  $gui = $guiFactory->create($this->object);
82 
83  $DIC->ctrl()->forwardCommand($gui);
84 
85  break;
86 
87  default:
88  $command = $DIC->ctrl()->getCmd(self::DEFAULT_CMD) . 'Cmd';
89  $this->{$command}();
90  }
91  }
92 
93  protected function saveCmd()
94  {
95  global $DIC; /* @var \ILIAS\DI\Container $DIC */
96 
97  $form = $this->buildForm();
98 
99  if ($form->checkInput()) {
100  $this->saveSettings($form);
101 
102  ilUtil::sendSuccess($DIC->language()->txt('msg_obj_modified'), true);
103  $DIC->ctrl()->redirect($this, self::CMD_SHOW);
104  }
105 
106  $this->showCmd($form);
107  }
108 
109  protected function showCmd(ilPropertyFormGUI $form = null)
110  {
111  global $DIC; /* @var \ILIAS\DI\Container $DIC */
112 
113  $DIC->tabs()->activateSubTab(self::SUBTAB_ID_SETTINGS);
114 
115  $form = $this->buildForm();
116 
117  $DIC->ui()->mainTemplate()->setContent($form->getHTML());
118  }
119 
120  protected function buildForm()
121  {
122  global $DIC;
123  /* @var \ILIAS\DI\Container $DIC */
124 
125  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
126  $form = new ilPropertyFormGUI();
127  $form->setFormAction($DIC->ctrl()->getFormAction($this));
128 
129  $ne = new ilNonEditableValueGUI($DIC->language()->txt('type'), "");
130  $ne->setValue($DIC->language()->txt('type_' . $this->object->getContentType()));
131  $form->addItem($ne);
132 
133  $ne = new ilNonEditableValueGUI($DIC->language()->txt('cmix_lrs_type'), "");
134  $ne->setValue($this->object->getLrsType()->getTitle());
135  $form->addItem($ne);
136 
137  $item = new ilTextInputGUI($DIC->language()->txt('title'), 'title');
138  $item->setSize(40);
139  $item->setMaxLength(128);
140  $item->setRequired(true);
141  $item->setInfo($DIC->language()->txt('title_info'));
142  $item->setValue($this->object->getTitle());
143  $form->addItem($item);
144 
145  $item = new ilTextAreaInputGUI($DIC->language()->txt('description'), 'description');
146  $item->setInfo($DIC->language()->txt('description_info'));
147  $item->setRows(2);
148  $item->setCols(80);
149  $item->setValue($this->object->getDescription());
150  $form->addItem($item);
151 
152  $item = new ilTextInputGUI($DIC->language()->txt('activity_id'), 'activity_id');
153  $item->setRequired(true);
154  $item->setSize(40);
155  $item->setMaxLength(128);
156  // $item->setRequired(true);
157  $item->setInfo($DIC->language()->txt('activity_id_info'));
158  $item->setValue($this->object->getActivityId());
159  $form->addItem($item);
160 
161  $item = new ilCheckboxInputGUI($DIC->language()->txt('online'), 'online');
162  $item->setInfo($DIC->language()->txt("online_info"));
163  $item->setValue("1");
164  if (!$this->object->getOfflineStatus()) {
165  $item->setChecked(true);
166  }
167  $form->addItem($item);
168 
169  if (!$this->object->isSourceTypeExternal()) {
170  $item = new ilFormSectionHeaderGUI();
171  $item->setTitle($DIC->language()->txt("launch_options"));
172  $form->addItem($item);
173 
174  if ($this->object->isSourceTypeRemote()) {
175  $item = new ilTextInputGUI($DIC->language()->txt('launch_url'), 'launch_url');
176  $item->setSize(40);
177  $item->setMaxLength(128);
178  $item->setRequired(true);
179  $item->setInfo($DIC->language()->txt('launch_url_info'));
180  $item->setValue($this->object->getLaunchUrl());
181  $form->addItem($item);
182  }
183 
184  if ($this->object->getContentType() != ilObjCmiXapi::CONT_TYPE_CMI5) {
185  $item = new ilCheckboxInputGUI($DIC->language()->txt('use_fetch'), 'use_fetch');
186  $item->setInfo($DIC->language()->txt("use_fetch_info"));
187  $item->setValue("1");
188 
189  if ($this->object->isAuthFetchUrlEnabled()) {
190  $item->setChecked(true);
191  }
192  $form->addItem($item);
193  }
194 
195  $display = new ilRadioGroupInputGUI($DIC->language()->txt('launch_options'), 'display');
196  $display->setRequired(true);
197  $display->setValue($this->object->getLaunchMethod());
198  $optOwnWindow = new ilRadioOption($DIC->language()->txt('conf_own_window'), ilObjCmiXapi::LAUNCH_METHOD_OWN_WIN);
199  $optOwnWindow->setInfo($DIC->language()->txt('conf_own_window_info'));
200  $display->addOption($optOwnWindow);
201  $optAnyWindow = new ilRadioOption($DIC->language()->txt('conf_new_window'), ilObjCmiXapi::LAUNCH_METHOD_NEW_WIN);
202  $optAnyWindow->setInfo($DIC->language()->txt('conf_new_window_info'));
203  $display->addOption($optAnyWindow);
204  $form->addItem($display);
205 
206  $launchMode = new ilRadioGroupInputGUI($DIC->language()->txt('conf_launch_mode'), 'launch_mode');
207  $launchMode->setRequired(true);
208  $launchMode->setValue($this->object->getLaunchMode());
209  $optNormal = new ilRadioOption($DIC->language()->txt('conf_launch_mode_normal'), ilObjCmiXapi::LAUNCH_MODE_NORMAL);
210  $optNormal->setInfo($DIC->language()->txt('conf_launch_mode_normal_info'));
211  $launchMode->addOption($optNormal);
212  $optBrowse = new ilRadioOption($DIC->language()->txt('conf_launch_mode_browse'), ilObjCmiXapi::LAUNCH_MODE_BROWSE);
213  $optBrowse->setInfo($DIC->language()->txt('conf_launch_mode_browse_info'));
214  $launchMode->addOption($optBrowse);
215  $optReview = new ilRadioOption($DIC->language()->txt('conf_launch_mode_review'), ilObjCmiXapi::LAUNCH_MODE_REVIEW);
216  $optReview->setInfo($DIC->language()->txt('conf_launch_mode_review_info'));
217  $launchMode->addOption($optReview);
218  $form->addItem($launchMode);
219  }
220 
221  $lpDeterioration = new ilCheckboxInputGUI($DIC->language()->txt('conf_keep_lp'), 'avoid_lp_deterioration');
222  $lpDeterioration->setInfo($DIC->language()->txt('conf_keep_lp_info'));
223  if ($this->object->isKeepLpStatusEnabled()) {
224  $lpDeterioration->setChecked(true);
225  }
226  if (!$this->object->isSourceTypeExternal()) {
227  $optNormal->addSubItem($lpDeterioration);
228  } else {
229  $form->addItem($lpDeterioration);
230  }
231 
232  if ($this->object->getContentType() == ilObjCmiXapi::CONT_TYPE_CMI5) {
233  $switchMode = new ilCheckboxInputGUI($DIC->language()->txt('conf_switch_to_review'), 'switch_to_review');
234  $switchMode->setInfo($DIC->language()->txt("conf_switch_to_review_info"));
235  if ($this->object->isSwitchToReviewEnabled()) {
236  $switchMode->setChecked(true);
237  }
238  $optNormal->addSubItem($switchMode);
239 
240  $masteryScore = new ilNumberInputGUI($DIC->language()->txt('conf_mastery_score'), 'mastery_score');
241  $masteryScore->setInfo($DIC->language()->txt('conf_mastery_score_info'));
242  $masteryScore->setSuffix('%');
243  $masteryScore->allowDecimals(true);
244  $masteryScore->setDecimals(2);
245  $masteryScore->setMinvalueShouldBeGreater(false);
246  $masteryScore->setMinValue(0);
247  $masteryScore->setMaxvalueShouldBeLess(false);
248  $masteryScore->setMaxValue(100);
249  $masteryScore->setSize(4);
250  if (empty($this->object->getMasteryScore())) {
251  $this->object->setMasteryScorePercent(ilObjCmiXapi::LMS_MASTERY_SCORE);
252  }
253  $masteryScore->setValue($this->object->getMasteryScorePercent());
254  $optNormal->addSubItem($masteryScore);
255  }
256 
257  if (!$this->object->isSourceTypeExternal()) {
258  if ($this->object->getContentType() != ilObjCmiXapi::CONT_TYPE_CMI5) {
259  $sectionHeader = new ilFormSectionHeaderGUI();
260  $sectionHeader->setTitle($DIC->language()->txt('sect_learning_progress_options'));
261  $form->addItem($sectionHeader);
262  $bypassProxy = new ilRadioGroupInputGUI($DIC->language()->txt('conf_bypass_proxy'), 'bypass_proxy');
263  $bypassProxy->setInfo($DIC->language()->txt('conf_bypass_proxy_info'));
264  $bypassProxy->setValue($this->object->isBypassProxyEnabled());
265  $opt1 = new ilRadioOption($DIC->language()->txt('conf_bypass_proxy_disabled'), 0);
266  $bypassProxy->addOption($opt1);
267  $opt2 = new ilRadioOption($DIC->language()->txt('conf_bypass_proxy_enabled'), 1);
268  $bypassProxy->addOption($opt2);
269  $form->addItem($bypassProxy);
270  if ($this->object->getLrsType()->isBypassProxyEnabled()) {
271  $bypassProxy->setDisabled(true);
272  }
273  }
274 
275  $item = new ilFormSectionHeaderGUI();
276  $item->setTitle($DIC->language()->txt("privacy_options"));
277  $form->addItem($item);
278 
279  $userIdent = new ilRadioGroupInputGUI($DIC->language()->txt('conf_privacy_ident'), 'privacy_ident');
280  $op = new ilRadioOption(
281  $DIC->language()->txt('conf_privacy_ident_il_uuid_user_id'),
283  );
284  $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_user_id_info'));
285  $userIdent->addOption($op);
286  $op = new ilRadioOption(
287  $DIC->language()->txt('conf_privacy_ident_il_uuid_login'),
289  );
290  $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_login_info'));
291  $userIdent->addOption($op);
292  $op = new ilRadioOption(
293  $DIC->language()->txt('conf_privacy_ident_il_uuid_ext_account'),
295  );
296  $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_ext_account_info'));
297  $userIdent->addOption($op);
298  $op = new ilRadioOption(
299  $DIC->language()->txt('conf_privacy_ident_il_uuid_sha256'),
301  );
302  $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_sha256_info'));
303  $userIdent->addOption($op);
304  $op = new ilRadioOption(
305  $DIC->language()->txt('conf_privacy_ident_il_uuid_sha256url'),
307  );
308  $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_sha256url_info'));
309  $userIdent->addOption($op);
310  $op = new ilRadioOption(
311  $DIC->language()->txt('conf_privacy_ident_il_uuid_random'),
313  );
314  $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_random_info'));
315  $userIdent->addOption($op);
316  $op = new ilRadioOption(
317  $DIC->language()->txt('conf_privacy_ident_real_email'),
319  );
320  $op->setInfo($DIC->language()->txt('conf_privacy_ident_real_email_info'));
321  $userIdent->addOption($op);
322  $userIdent->setValue($this->object->getPrivacyIdent());
323  $userIdent->setInfo(
324  $DIC->language()->txt('conf_privacy_ident_info') . ' ' . ilCmiXapiUser::getIliasUuid()
325  );
326  $userIdent->setRequired(false);
327  $form->addItem($userIdent);
328 
329  $userName = new ilRadioGroupInputGUI($DIC->language()->txt('conf_privacy_name'), 'privacy_name');
330  $op = new ilRadioOption($DIC->language()->txt('conf_privacy_name_none'), ilCmiXapiLrsType::PRIVACY_NAME_NONE);
331  $op->setInfo($DIC->language()->txt('conf_privacy_name_none_info'));
332  $userName->addOption($op);
333  $op = new ilRadioOption($DIC->language()->txt('conf_privacy_name_firstname'), ilCmiXapiLrsType::PRIVACY_NAME_FIRSTNAME);
334  $op->setInfo($DIC->language()->txt('conf_privacy_name_firstname_info'));
335  $userName->addOption($op);
336  $op = new ilRadioOption($DIC->language()->txt('conf_privacy_name_lastname'), ilCmiXapiLrsType::PRIVACY_NAME_LASTNAME);
337  $op->setInfo($DIC->language()->txt('conf_privacy_name_lastname_info'));
338  $userName->addOption($op);
339  $op = new ilRadioOption($DIC->language()->txt('conf_privacy_name_fullname'), ilCmiXapiLrsType::PRIVACY_NAME_FULLNAME);
340  $op->setInfo($DIC->language()->txt('conf_privacy_name_fullname_info'));
341  $userName->addOption($op);
342  $userName->setValue($this->object->getPrivacyName());
343  $userName->setInfo($DIC->language()->txt('conf_privacy_name_info'));
344  $userName->setRequired(false);
345  $form->addItem($userName);
346 
347  if ($this->object->getLrsType()->getForcePrivacySettings()) {
348  $userIdent->setDisabled(true);
349  $userName->setDisabled(true);
350  }
351 
352  $item = new ilCheckboxInputGUI($DIC->language()->txt('only_moveon_label'), 'only_moveon');
353  $item->setInfo($DIC->language()->txt('only_moveon_info'));
354  $item->setChecked($this->object->getOnlyMoveon());
355 
356  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('achieved_label'), 'achieved');
357  $subitem->setInfo($DIC->language()->txt('achieved_info'));
358  $subitem->setChecked($this->object->getAchieved());
359  if ($this->object->getLrsType()->getForcePrivacySettings()) {
360  $subitem->setDisabled(true);
361  }
362  $item->addSubItem($subitem);
363 
364  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('answered_label'), 'answered');
365  $subitem->setInfo($DIC->language()->txt('answered_info'));
366  $subitem->setChecked($this->object->getAnswered());
367  if ($this->object->getLrsType()->getForcePrivacySettings()) {
368  $subitem->setDisabled(true);
369  }
370  $item->addSubItem($subitem);
371 
372  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('completed_label'), 'completed');
373  $subitem->setInfo($DIC->language()->txt('completed_info'));
374  $subitem->setChecked($this->object->getCompleted());
375  if ($this->object->getLrsType()->getForcePrivacySettings()) {
376  $subitem->setDisabled(true);
377  }
378  $item->addSubItem($subitem);
379 
380  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('failed_label'), 'failed');
381  $subitem->setInfo($DIC->language()->txt('failed_info'));
382  $subitem->setChecked($this->object->getFailed());
383  if ($this->object->getLrsType()->getForcePrivacySettings()) {
384  $subitem->setDisabled(true);
385  }
386  $item->addSubItem($subitem);
387 
388  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('initialized_label'), 'initialized');
389  $subitem->setInfo($DIC->language()->txt('initialized_info'));
390  $subitem->setChecked($this->object->getInitialized());
391  if ($this->object->getLrsType()->getForcePrivacySettings()) {
392  $subitem->setDisabled(true);
393  }
394  $item->addSubItem($subitem);
395 
396  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('passed_label'), 'passed');
397  $subitem->setInfo($DIC->language()->txt('passed_info'));
398  $subitem->setChecked($this->object->getPassed());
399  if ($this->object->getLrsType()->getForcePrivacySettings()) {
400  $subitem->setDisabled(true);
401  }
402  $item->addSubItem($subitem);
403 
404  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('progressed_label'), 'progressed');
405  $subitem->setInfo($DIC->language()->txt('progressed_info'));
406  $subitem->setChecked($this->object->getProgressed());
407  if ($this->object->getLrsType()->getForcePrivacySettings()) {
408  $subitem->setDisabled(true);
409  }
410  $item->addSubItem($subitem);
411  if ($this->object->getContentType() != ilObjCmiXapi::CONT_TYPE_CMI5) {
412  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('satisfied_label'), 'satisfied');
413  $subitem->setInfo($DIC->language()->txt('satisfied_info'));
414  $subitem->setChecked($this->object->getSatisfied());
415  if ($this->object->getLrsType()->getForcePrivacySettings()) {
416  $subitem->setDisabled(true);
417  }
418  $item->addSubItem($subitem);
419 
420  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('terminated_label'), 'terminated');
421  $subitem->setInfo($DIC->language()->txt('terminated_info'));
422  $subitem->setChecked($this->object->getTerminated());
423  if ($this->object->getLrsType()->getForcePrivacySettings()) {
424  $subitem->setDisabled(true);
425  }
426  $item->addSubItem($subitem);
427  }
428  if ($this->object->getLrsType()->getForcePrivacySettings()) {
429  $item->setDisabled(true);
430  }
431  $form->addItem($item);
432 
433  $item = new ilCheckboxInputGUI($DIC->language()->txt('hide_data_label'), 'hide_data');
434  $item->setInfo($DIC->language()->txt('hide_data_info'));
435  $item->setChecked($this->object->getHideData());
436 
437  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('timestamp_label'), 'timestamp');
438  $subitem->setInfo($DIC->language()->txt('timestamp_info'));
439  $subitem->setChecked($this->object->getTimestamp());
440  if ($this->object->getLrsType()->getForcePrivacySettings()) {
441  $subitem->setDisabled(true);
442  }
443  $item->addSubItem($subitem);
444 
445  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('duration_label'), 'duration');
446  $subitem->setInfo($DIC->language()->txt('duration_info'));
447  $subitem->setChecked($this->object->getDuration());
448  if ($this->object->getLrsType()->getForcePrivacySettings()) {
449  $subitem->setDisabled(true);
450  }
451  $item->addSubItem($subitem);
452 
453  if ($this->object->getLrsType()->getForcePrivacySettings()) {
454  $item->setDisabled(true);
455  }
456  $form->addItem($item);
457 
458  $item = new ilCheckboxInputGUI($DIC->language()->txt('no_substatements_label'), 'no_substatements');
459  $item->setInfo($DIC->language()->txt('no_substatements_info'));
460  $item->setChecked($this->object->getNoSubstatements());
461  if ($this->object->getLrsType()->getForcePrivacySettings()) {
462  $item->setDisabled(true);
463  }
464  $form->addItem($item);
465  }
466 
467  $item = new ilFormSectionHeaderGUI();
468  $item->setTitle($DIC->language()->txt("log_options"));
469  $form->addItem($item);
470 
471  $item = new ilCheckboxInputGUI($DIC->language()->txt('show_debug'), 'show_debug');
472  $item->setInfo($DIC->language()->txt("show_debug_info"));
473  $item->setValue("1");
474  if ($this->object->isStatementsReportEnabled()) {
475  $item->setChecked(true);
476  }
477  $form->addItem($item);
478 
479  $highscore = new ilCheckboxInputGUI($DIC->language()->txt("highscore_enabled"), "highscore_enabled");
480  $highscore->setValue(1);
481  $highscore->setChecked($this->object->getHighscoreEnabled());
482  $highscore->setInfo($DIC->language()->txt("highscore_description"));
483  $form->addItem($highscore);
484  $highscore_tables = new ilRadioGroupInputGUI($DIC->language()->txt('highscore_mode'), 'highscore_mode');
485  $highscore_tables->setRequired(true);
486  $highscore_tables->setValue($this->object->getHighscoreMode());
487  $highscore_table_own = new ilRadioOption($DIC->language()->txt('highscore_own_table'), ilObjCmiXapi::HIGHSCORE_SHOW_OWN_TABLE);
488  $highscore_table_own->setInfo($DIC->language()->txt('highscore_own_table_description'));
489  $highscore_tables->addOption($highscore_table_own);
490  $highscore_table_other = new ilRadioOption($DIC->language()->txt('highscore_top_table'), ilObjCmiXapi::HIGHSCORE_SHOW_TOP_TABLE);
491  $highscore_table_other->setInfo($DIC->language()->txt('highscore_top_table_description'));
492  $highscore_tables->addOption($highscore_table_other);
493  $highscore_table_other = new ilRadioOption($DIC->language()->txt('highscore_all_tables'), ilObjCmiXapi::HIGHSCORE_SHOW_ALL_TABLES);
494  $highscore_table_other->setInfo($DIC->language()->txt('highscore_all_tables_description'));
495  $highscore_tables->addOption($highscore_table_other);
496  $highscore->addSubItem($highscore_tables);
497  $highscore_top_num = new ilNumberInputGUI($DIC->language()->txt("highscore_top_num"), "highscore_top_num");
498  $highscore_top_num->setSize(4);
499  $highscore_top_num->setRequired(true);
500  $highscore_top_num->setMinValue(1);
501  $highscore_top_num->setSuffix($DIC->language()->txt("highscore_top_num_unit"));
502  $highscore_top_num->setValue($this->object->getHighscoreTopNum(null));
503  $highscore_top_num->setInfo($DIC->language()->txt("highscore_top_num_description"));
504  $highscore->addSubItem($highscore_top_num);
505  $highscore_achieved_ts = new ilCheckboxInputGUI($DIC->language()->txt("highscore_achieved_ts"), "highscore_achieved_ts");
506  $highscore_achieved_ts->setValue(1);
507  $highscore_achieved_ts->setChecked($this->object->getHighscoreAchievedTS());
508  $highscore_achieved_ts->setInfo($DIC->language()->txt("highscore_achieved_ts_description"));
509  $highscore->addSubItem($highscore_achieved_ts);
510  $highscore_percentage = new ilCheckboxInputGUI($DIC->language()->txt("highscore_percentage"), "highscore_percentage");
511  $highscore_percentage->setValue(1);
512  $highscore_percentage->setChecked($this->object->getHighscorePercentage());
513  $highscore_percentage->setInfo($DIC->language()->txt("highscore_percentage_description"));
514  $highscore->addSubItem($highscore_percentage);
515  $highscore_wtime = new ilCheckboxInputGUI($DIC->language()->txt("highscore_wtime"), "highscore_wtime");
516  $highscore_wtime->setValue(1);
517  $highscore_wtime->setChecked($this->object->getHighscoreWTime());
518  $highscore_wtime->setInfo($DIC->language()->txt("highscore_wtime_description"));
519  $highscore->addSubItem($highscore_wtime);
520 
521 
522  $form->setTitle($DIC->language()->txt('settings'));
523  $form->addCommandButton(self::CMD_SAVE, $DIC->language()->txt("save"));
524  $form->addCommandButton(self::CMD_SHOW, $DIC->language()->txt("cancel"));
525 
526  return $form;
527  }
528 
529  protected function saveSettings(ilPropertyFormGUI $form)
530  {
531  $this->object->setTitle($form->getInput('title'));
532  $this->object->setDescription($form->getInput('description'));
533 
534  $this->object->setActivityId($form->getInput('activity_id'));
535  $this->object->setOfflineStatus(!(bool) $form->getInput('online'));
536 
537  if (!$this->object->isSourceTypeExternal()) {
538  $this->object->setLaunchMethod($form->getInput('display'));
539 
540  $this->object->setLaunchMode($form->getInput('launch_mode'));
541 
542  if ($this->object->getLaunchMode() == ilObjCmiXapi::LAUNCH_MODE_NORMAL) {
543  if ($this->object->getContentType() == ilObjCmiXapi::CONT_TYPE_CMI5) {
544  $this->object->setMasteryScorePercent($form->getInput('mastery_score'));
545  }
546  $this->object->setKeepLpStatusEnabled((bool) $form->getInput('avoid_lp_deterioration'));
547  $this->object->setSwitchToReviewEnabled((bool) $form->getInput('switch_to_review'));
548  } else {
549  $this->object->setKeepLpStatusEnabled(true);
550  $this->object->setSwitchToReviewEnabled(false);
551  }
552 
553  if ($this->object->isSourceTypeRemote()) {
554  $this->object->setLaunchUrl($form->getInput('launch_url'));
555  }
556 
557  if ($this->object->getContentType() == ilObjCmiXapi::CONT_TYPE_CMI5) {
558  $this->object->setAuthFetchUrlEnabled(true);
559  } else {
560  $this->object->setAuthFetchUrlEnabled((bool) $form->getInput('use_fetch'));
561  }
562 
563  if (!$this->object->getLrsType()->isBypassProxyEnabled()) {
564  if ($this->object->getContentType() == ilObjCmiXapi::CONT_TYPE_CMI5) {
565  $this->object->setBypassProxyEnabled(false);
566  } else {
567  $this->object->setBypassProxyEnabled((bool) $form->getInput('bypass_proxy'));
568  }
569  }
570 
571  if (!$this->object->getLrsType()->getForcePrivacySettings()) {
572  $this->object->setPrivacyIdent($form->getInput('privacy_ident'));
573  $this->object->setPrivacyName($form->getInput('privacy_name'));
574  $this->object->setOnlyMoveon((bool) $form->getInput("only_moveon"));
575  $this->object->setAchieved((bool) $form->getInput("achieved"));
576  $this->object->setAnswered((bool) $form->getInput("answered"));
577  $this->object->setCompleted((bool) $form->getInput("completed"));
578  $this->object->setFailed((bool) $form->getInput("failed"));
579  $this->object->setInitialized((bool) $form->getInput("initialized"));
580  $this->object->setPassed((bool) $form->getInput("passed"));
581  $this->object->setProgressed((bool) $form->getInput("progressed"));
582  if ($this->object->getContentType() == ilObjCmiXapi::CONT_TYPE_CMI5) {
583  $this->object->setSatisfied(true);
584  $this->object->setTerminated(true);
585  } else {
586  $this->object->setSatisfied((bool) $form->getInput("satisfied"));
587  $this->object->setTerminated((bool) $form->getInput("terminated"));
588  }
589  $this->object->setHideData((bool) $form->getInput("hide_data"));
590  $this->object->setTimestamp((bool) $form->getInput("timestamp"));
591  $this->object->setDuration((bool) $form->getInput("duration"));
592  $this->object->setNoSubstatements((bool) $form->getInput("no_substatements"));
593  }
594  } else { //SourceTypeExternal
595  $this->object->setBypassProxyEnabled(true);
596  $this->object->setKeepLpStatusEnabled((bool) $form->getInput('avoid_lp_deterioration'));
597  }
598 
599  $this->object->setStatementsReportEnabled((bool) $form->getInput('show_debug'));
600 
601  $this->object->setHighscoreEnabled((bool) $form->getInput('highscore_enabled'));
602  if ($this->object->getHighscoreEnabled()) {
603  // highscore settings
604  $this->object->setHighscoreEnabled((bool) $form->getInput('highscore_enabled'));
605  $this->object->setHighscoreAchievedTS((bool) $form->getInput('highscore_achieved_ts'));
606  $this->object->setHighscorePercentage((bool) $form->getInput('highscore_percentage'));
607  $this->object->setHighscoreWTime((bool) $form->getInput('highscore_wtime'));
608  $this->object->setHighscoreMode((int) $form->getInput('highscore_mode'));
609  $this->object->setHighscoreTopNum((int) $form->getInput('highscore_top_num'));
610  }
611 
612  $this->object->update();
613  }
614 
615  protected function deliverCertificateCmd()
616  {
617  global $DIC; /* @var \ILIAS\DI\Container $DIC */
618 
619  $validator = new ilCertificateDownloadValidator();
620 
621  if (!$validator->isCertificateDownloadable((int) $DIC->user()->getId(), (int) $this->object->getId())) {
622  ilUtil::sendFailure($DIC->language()->txt("permission_denied"), true);
623  $DIC->ctrl()->redirectByClass(ilObjCmiXapiGUI::class, ilObjCmiXapiGUI::CMD_INFO_SCREEN);
624  }
625 
626  $repository = new ilUserCertificateRepository();
627 
628  $certLogger = $DIC->logger()->cert();
629  $pdfGenerator = new ilPdfGenerator($repository, $certLogger);
630 
631  $pdfAction = new ilCertificatePdfAction(
632  $certLogger,
633  $pdfGenerator,
635  $DIC->language()->txt('error_creating_certificate_pdf')
636  );
637 
638  $pdfAction->downloadPdf((int) $DIC->user()->getId(), (int) $this->object->getId());
639  }
640 }
This class represents an option in a radio group.
Class ilPdfGeneratorConstantsTest.
This class represents a property form user interface.
__construct(ilObjCmiXapi $object)
This class represents a section header in a property form.
This class represents a checkbox property in a property form.
setInfo($a_info)
Set Info.
setInfo($a_info)
Set Information Text.
This class represents a property in a property form.
This class represents a number property in a property form.
setValue($a_value)
Set Value.
Validates if an active certificate is stored in the database and can be downloaded by the user...
global $DIC
Definition: goto.php:24
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
saveSettings(ilPropertyFormGUI $form)
setSize($a_size)
Set Size.
Just a wrapper class to create Unit Test for other classes.
This class represents a non editable value in a property form.
This class represents a text area property in a property form.
showCmd(ilPropertyFormGUI $form=null)
setDisabled($a_disabled)
setRequired($a_required)
Set Required.
downloadPdf(int $userId, int $objectId)