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