ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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_random'),
307  );
308  $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_random_info'));
309  $userIdent->addOption($op);
310  $op = new ilRadioOption(
311  $DIC->language()->txt('conf_privacy_ident_real_email'),
313  );
314  $op->setInfo($DIC->language()->txt('conf_privacy_ident_real_email_info'));
315  $userIdent->addOption($op);
316  $userIdent->setValue($this->object->getPrivacyIdent());
317  $userIdent->setInfo(
318  $DIC->language()->txt('conf_privacy_ident_info') . ' ' . ilCmiXapiUser::getIliasUuid()
319  );
320  $userIdent->setRequired(false);
321  $form->addItem($userIdent);
322 
323  $userName = new ilRadioGroupInputGUI($DIC->language()->txt('conf_privacy_name'), 'privacy_name');
324  $op = new ilRadioOption($DIC->language()->txt('conf_privacy_name_none'), ilCmiXapiLrsType::PRIVACY_NAME_NONE);
325  $op->setInfo($DIC->language()->txt('conf_privacy_name_none_info'));
326  $userName->addOption($op);
327  $op = new ilRadioOption($DIC->language()->txt('conf_privacy_name_firstname'), ilCmiXapiLrsType::PRIVACY_NAME_FIRSTNAME);
328  $op->setInfo($DIC->language()->txt('conf_privacy_name_firstname_info'));
329  $userName->addOption($op);
330  $op = new ilRadioOption($DIC->language()->txt('conf_privacy_name_lastname'), ilCmiXapiLrsType::PRIVACY_NAME_LASTNAME);
331  $op->setInfo($DIC->language()->txt('conf_privacy_name_lastname_info'));
332  $userName->addOption($op);
333  $op = new ilRadioOption($DIC->language()->txt('conf_privacy_name_fullname'), ilCmiXapiLrsType::PRIVACY_NAME_FULLNAME);
334  $op->setInfo($DIC->language()->txt('conf_privacy_name_fullname_info'));
335  $userName->addOption($op);
336  $userName->setValue($this->object->getPrivacyName());
337  $userName->setInfo($DIC->language()->txt('conf_privacy_name_info'));
338  $userName->setRequired(false);
339  $form->addItem($userName);
340 
341  if ($this->object->getLrsType()->getForcePrivacySettings()) {
342  $userIdent->setDisabled(true);
343  $userName->setDisabled(true);
344  }
345 
346  $item = new ilCheckboxInputGUI($DIC->language()->txt('only_moveon_label'), 'only_moveon');
347  $item->setInfo($DIC->language()->txt('only_moveon_info'));
348  $item->setChecked($this->object->getOnlyMoveon());
349 
350  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('achieved_label'), 'achieved');
351  $subitem->setInfo($DIC->language()->txt('achieved_info'));
352  $subitem->setChecked($this->object->getAchieved());
353  if ($this->object->getLrsType()->getForcePrivacySettings()) $subitem->setDisabled(true);
354  $item->addSubItem($subitem);
355 
356  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('answered_label'), 'answered');
357  $subitem->setInfo($DIC->language()->txt('answered_info'));
358  $subitem->setChecked($this->object->getAnswered());
359  if ($this->object->getLrsType()->getForcePrivacySettings()) $subitem->setDisabled(true);
360  $item->addSubItem($subitem);
361 
362  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('completed_label'), 'completed');
363  $subitem->setInfo($DIC->language()->txt('completed_info'));
364  $subitem->setChecked($this->object->getCompleted());
365  if ($this->object->getLrsType()->getForcePrivacySettings()) $subitem->setDisabled(true);
366  $item->addSubItem($subitem);
367 
368  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('failed_label'), 'failed');
369  $subitem->setInfo($DIC->language()->txt('failed_info'));
370  $subitem->setChecked($this->object->getFailed());
371  if ($this->object->getLrsType()->getForcePrivacySettings()) $subitem->setDisabled(true);
372  $item->addSubItem($subitem);
373 
374  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('initialized_label'), 'initialized');
375  $subitem->setInfo($DIC->language()->txt('initialized_info'));
376  $subitem->setChecked($this->object->getInitialized());
377  if ($this->object->getLrsType()->getForcePrivacySettings()) $subitem->setDisabled(true);
378  $item->addSubItem($subitem);
379 
380  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('passed_label'), 'passed');
381  $subitem->setInfo($DIC->language()->txt('passed_info'));
382  $subitem->setChecked($this->object->getPassed());
383  if ($this->object->getLrsType()->getForcePrivacySettings()) $subitem->setDisabled(true);
384  $item->addSubItem($subitem);
385 
386  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('progressed_label'), 'progressed');
387  $subitem->setInfo($DIC->language()->txt('progressed_info'));
388  $subitem->setChecked($this->object->getProgressed());
389  if ($this->object->getLrsType()->getForcePrivacySettings()) $subitem->setDisabled(true);
390  $item->addSubItem($subitem);
391  if ($this->object->getContentType() != ilObjCmiXapi::CONT_TYPE_CMI5) {
392  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('satisfied_label'), 'satisfied');
393  $subitem->setInfo($DIC->language()->txt('satisfied_info'));
394  $subitem->setChecked($this->object->getSatisfied());
395  if ($this->object->getLrsType()->getForcePrivacySettings()) $subitem->setDisabled(true);
396  $item->addSubItem($subitem);
397 
398  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('terminated_label'), 'terminated');
399  $subitem->setInfo($DIC->language()->txt('terminated_info'));
400  $subitem->setChecked($this->object->getTerminated());
401  if ($this->object->getLrsType()->getForcePrivacySettings()) $subitem->setDisabled(true);
402  $item->addSubItem($subitem);
403  }
404  if ($this->object->getLrsType()->getForcePrivacySettings()) $item->setDisabled(true);
405  $form->addItem($item);
406 
407  $item = new ilCheckboxInputGUI($DIC->language()->txt('hide_data_label'), 'hide_data');
408  $item->setInfo($DIC->language()->txt('hide_data_info'));
409  $item->setChecked($this->object->getHideData());
410 
411  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('timestamp_label'), 'timestamp');
412  $subitem->setInfo($DIC->language()->txt('timestamp_info'));
413  $subitem->setChecked($this->object->getTimestamp());
414  if ($this->object->getLrsType()->getForcePrivacySettings()) $subitem->setDisabled(true);
415  $item->addSubItem($subitem);
416 
417  $subitem = new ilCheckboxInputGUI($DIC->language()->txt('duration_label'), 'duration');
418  $subitem->setInfo($DIC->language()->txt('duration_info'));
419  $subitem->setChecked($this->object->getDuration());
420  if ($this->object->getLrsType()->getForcePrivacySettings()) $subitem->setDisabled(true);
421  $item->addSubItem($subitem);
422 
423  if ($this->object->getLrsType()->getForcePrivacySettings()) $item->setDisabled(true);
424  $form->addItem($item);
425 
426  $item = new ilCheckboxInputGUI($DIC->language()->txt('no_substatements_label'), 'no_substatements');
427  $item->setInfo($DIC->language()->txt('no_substatements_info'));
428  $item->setChecked($this->object->getNoSubstatements());
429  if ($this->object->getLrsType()->getForcePrivacySettings()) $item->setDisabled(true);
430  $form->addItem($item);
431 
432  }
433 
434  $item = new ilFormSectionHeaderGUI();
435  $item->setTitle($DIC->language()->txt("log_options"));
436  $form->addItem($item);
437 
438  $item = new ilCheckboxInputGUI($DIC->language()->txt('show_debug'), 'show_debug');
439  $item->setInfo($DIC->language()->txt("show_debug_info"));
440  $item->setValue("1");
441  if ($this->object->isStatementsReportEnabled()) {
442  $item->setChecked(true);
443  }
444  $form->addItem($item);
445 
446  $highscore = new ilCheckboxInputGUI($DIC->language()->txt("highscore_enabled"), "highscore_enabled");
447  $highscore->setValue(1);
448  $highscore->setChecked($this->object->getHighscoreEnabled());
449  $highscore->setInfo($DIC->language()->txt("highscore_description"));
450  $form->addItem($highscore);
451  $highscore_tables = new ilRadioGroupInputGUI($DIC->language()->txt('highscore_mode'), 'highscore_mode');
452  $highscore_tables->setRequired(true);
453  $highscore_tables->setValue($this->object->getHighscoreMode());
454  $highscore_table_own = new ilRadioOption($DIC->language()->txt('highscore_own_table'), ilObjCmiXapi::HIGHSCORE_SHOW_OWN_TABLE);
455  $highscore_table_own->setInfo($DIC->language()->txt('highscore_own_table_description'));
456  $highscore_tables->addOption($highscore_table_own);
457  $highscore_table_other = new ilRadioOption($DIC->language()->txt('highscore_top_table'), ilObjCmiXapi::HIGHSCORE_SHOW_TOP_TABLE);
458  $highscore_table_other->setInfo($DIC->language()->txt('highscore_top_table_description'));
459  $highscore_tables->addOption($highscore_table_other);
460  $highscore_table_other = new ilRadioOption($DIC->language()->txt('highscore_all_tables'), ilObjCmiXapi::HIGHSCORE_SHOW_ALL_TABLES);
461  $highscore_table_other->setInfo($DIC->language()->txt('highscore_all_tables_description'));
462  $highscore_tables->addOption($highscore_table_other);
463  $highscore->addSubItem($highscore_tables);
464  $highscore_top_num = new ilNumberInputGUI($DIC->language()->txt("highscore_top_num"), "highscore_top_num");
465  $highscore_top_num->setSize(4);
466  $highscore_top_num->setRequired(true);
467  $highscore_top_num->setMinValue(1);
468  $highscore_top_num->setSuffix($DIC->language()->txt("highscore_top_num_unit"));
469  $highscore_top_num->setValue($this->object->getHighscoreTopNum(null));
470  $highscore_top_num->setInfo($DIC->language()->txt("highscore_top_num_description"));
471  $highscore->addSubItem($highscore_top_num);
472  $highscore_achieved_ts = new ilCheckboxInputGUI($DIC->language()->txt("highscore_achieved_ts"), "highscore_achieved_ts");
473  $highscore_achieved_ts->setValue(1);
474  $highscore_achieved_ts->setChecked($this->object->getHighscoreAchievedTS());
475  $highscore_achieved_ts->setInfo($DIC->language()->txt("highscore_achieved_ts_description"));
476  $highscore->addSubItem($highscore_achieved_ts);
477  $highscore_percentage = new ilCheckboxInputGUI($DIC->language()->txt("highscore_percentage"), "highscore_percentage");
478  $highscore_percentage->setValue(1);
479  $highscore_percentage->setChecked($this->object->getHighscorePercentage());
480  $highscore_percentage->setInfo($DIC->language()->txt("highscore_percentage_description"));
481  $highscore->addSubItem($highscore_percentage);
482  $highscore_wtime = new ilCheckboxInputGUI($DIC->language()->txt("highscore_wtime"), "highscore_wtime");
483  $highscore_wtime->setValue(1);
484  $highscore_wtime->setChecked($this->object->getHighscoreWTime());
485  $highscore_wtime->setInfo($DIC->language()->txt("highscore_wtime_description"));
486  $highscore->addSubItem($highscore_wtime);
487 
488 
489  $form->setTitle($DIC->language()->txt('settings'));
490  $form->addCommandButton(self::CMD_SAVE, $DIC->language()->txt("save"));
491  $form->addCommandButton(self::CMD_SHOW, $DIC->language()->txt("cancel"));
492 
493  return $form;
494  }
495 
496  protected function saveSettings(ilPropertyFormGUI $form)
497  {
498  $this->object->setTitle($form->getInput('title'));
499  $this->object->setDescription($form->getInput('description'));
500 
501  $this->object->setActivityId($form->getInput('activity_id'));
502  $this->object->setOfflineStatus(!(bool) $form->getInput('online'));
503 
504  if (!$this->object->isSourceTypeExternal()) {
505  $this->object->setLaunchMethod($form->getInput('display'));
506 
507  $this->object->setLaunchMode($form->getInput('launch_mode'));
508 
509  if ($this->object->getLaunchMode() == ilObjCmiXapi::LAUNCH_MODE_NORMAL) {
510  if ($this->object->getContentType() == ilObjCmiXapi::CONT_TYPE_CMI5) {
511  $this->object->setMasteryScorePercent($form->getInput('mastery_score'));
512  }
513  $this->object->setKeepLpStatusEnabled((bool) $form->getInput('avoid_lp_deterioration'));
514  $this->object->setSwitchToReviewEnabled((bool) $form->getInput('switch_to_review'));
515  }
516  else {
517  $this->object->setKeepLpStatusEnabled(true);
518  $this->object->setSwitchToReviewEnabled(false);
519  }
520 
521  if ($this->object->isSourceTypeRemote()) {
522  $this->object->setLaunchUrl($form->getInput('launch_url'));
523  }
524 
525  if ($this->object->getContentType() == ilObjCmiXapi::CONT_TYPE_CMI5) {
526  $this->object->setAuthFetchUrlEnabled(true);
527  } else {
528  $this->object->setAuthFetchUrlEnabled((bool) $form->getInput('use_fetch'));
529  }
530 
531  if (!$this->object->getLrsType()->isBypassProxyEnabled()) {
532  if ($this->object->getContentType() == ilObjCmiXapi::CONT_TYPE_CMI5) {
533  $this->object->setBypassProxyEnabled(false);
534  }
535  else {
536  $this->object->setBypassProxyEnabled((bool) $form->getInput('bypass_proxy'));
537  }
538  }
539 
540  if (!$this->object->getLrsType()->getForcePrivacySettings()) {
541  $this->object->setPrivacyIdent($form->getInput('privacy_ident'));
542  $this->object->setPrivacyName($form->getInput('privacy_name'));
543  $this->object->setOnlyMoveon((bool)$form->getInput("only_moveon"));
544  $this->object->setAchieved((bool)$form->getInput("achieved"));
545  $this->object->setAnswered((bool)$form->getInput("answered"));
546  $this->object->setCompleted((bool)$form->getInput("completed"));
547  $this->object->setFailed((bool)$form->getInput("failed"));
548  $this->object->setInitialized((bool)$form->getInput("initialized"));
549  $this->object->setPassed((bool)$form->getInput("passed"));
550  $this->object->setProgressed((bool)$form->getInput("progressed"));
551  if ($this->object->getContentType() == ilObjCmiXapi::CONT_TYPE_CMI5) {
552  $this->object->setSatisfied(true);
553  $this->object->setTerminated(true);
554  } else {
555  $this->object->setSatisfied((bool)$form->getInput("satisfied"));
556  $this->object->setTerminated((bool)$form->getInput("terminated"));
557  }
558  $this->object->setHideData((bool)$form->getInput("hide_data"));
559  $this->object->setTimestamp((bool)$form->getInput("timestamp"));
560  $this->object->setDuration((bool)$form->getInput("duration"));
561  $this->object->setNoSubstatements((bool)$form->getInput("no_substatements"));
562  }
563  } else { //SourceTypeExternal
564  $this->object->setBypassProxyEnabled(true);
565  $this->object->setKeepLpStatusEnabled((bool) $form->getInput('avoid_lp_deterioration'));
566  }
567 
568  $this->object->setStatementsReportEnabled((bool) $form->getInput('show_debug'));
569 
570  $this->object->setHighscoreEnabled((bool) $form->getInput('highscore_enabled'));
571  if ($this->object->getHighscoreEnabled()) {
572  // highscore settings
573  $this->object->setHighscoreEnabled((bool) $form->getInput('highscore_enabled'));
574  $this->object->setHighscoreAchievedTS((bool) $form->getInput('highscore_achieved_ts'));
575  $this->object->setHighscorePercentage((bool) $form->getInput('highscore_percentage'));
576  $this->object->setHighscoreWTime((bool) $form->getInput('highscore_wtime'));
577  $this->object->setHighscoreMode((int) $form->getInput('highscore_mode'));
578  $this->object->setHighscoreTopNum((int) $form->getInput('highscore_top_num'));
579  }
580 
581  $this->object->update();
582  }
583 
584  protected function deliverCertificateCmd()
585  {
586  global $DIC; /* @var \ILIAS\DI\Container $DIC */
587 
588  $validator = new ilCertificateDownloadValidator();
589 
590  if (!$validator->isCertificateDownloadable((int) $DIC->user()->getId(), (int) $this->object->getId())) {
591  ilUtil::sendFailure($DIC->language()->txt("permission_denied"), true);
592  $DIC->ctrl()->redirectByClass(ilObjCmiXapiGUI::class, ilObjCmiXapiGUI::CMD_INFO_SCREEN);
593  }
594 
595  $repository = new ilUserCertificateRepository();
596 
597  $certLogger = $DIC->logger()->cert();
598  $pdfGenerator = new ilPdfGenerator($repository, $certLogger);
599 
600  $pdfAction = new ilCertificatePdfAction(
601  $certLogger,
602  $pdfGenerator,
604  $DIC->language()->txt('error_creating_certificate_pdf')
605  );
606 
607  $pdfAction->downloadPdf((int) $DIC->user()->getId(), (int) $this->object->getId());
608  }
609 }
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...
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.
$DIC
Definition: xapitoken.php:46
showCmd(ilPropertyFormGUI $form=null)
setDisabled($a_disabled)
setRequired($a_required)
Set Required.
downloadPdf(int $userId, int $objectId)