ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilLOEditorGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24use ILIAS\DI\UIServices as ilUIServices;
25
34{
35 public const int TEST_TYPE_UNDEFINED = 0;
36 public const int TEST_TYPE_IT = 1;
37 public const int TEST_TYPE_QT = 2;
38
39 public const int TEST_NEW = 1;
40 public const int TEST_ASSIGN = 2;
41
43
55 protected Factory $refinery;
56 protected ilUIServices $ui_services;
57 protected ilDBInterface $db;
58
60
62 {
63 global $DIC;
64
65 $this->main_tpl = $DIC->ui()->mainTemplate();
66 $this->parent_obj = $parent_gui->getObject();
67 $this->parent_gui = $parent_gui;
69
70 $cs = $DIC->contentStyle();
71 $this->content_style_domain = $cs->domain()->styleForRefId($this->parent_obj->getRefId());
72
73 $this->lng = $DIC->language();
74 $this->ctrl = $DIC->ctrl();
75 $this->tpl = $DIC->ui()->mainTemplate();
76 $this->tabs = $DIC->tabs();
77 $this->toolbar = $DIC->toolbar();
78 $this->logger = $DIC->logger()->crs();
79 $this->http = $DIC->http();
80 $this->refinery = $DIC->refinery();
81 $this->ui_services = $DIC->ui();
82 $this->db = $DIC->database();
83 }
84
85 public function executeCommand(): void
86 {
87 $next_class = $this->ctrl->getNextClass($this);
88 $cmd = $this->ctrl->getCmd();
89
90
91
92 $this->setTabs();
93 switch ($next_class) {
94 case 'ilcourseobjectivesgui':
95
96 $this->ctrl->setReturn($this, 'returnFromObjectives');
97 $this->tabs->clearTargets();
98 $this->tabs->setBackTarget(
99 $this->lng->txt('back'),
100 $this->ctrl->getLinkTarget($this, 'listObjectives')
101 );
102
103 $reg_gui = new ilCourseObjectivesGUI($this->getParentObject()->getRefId());
104 $this->ctrl->forwardCommand($reg_gui);
105 break;
106
107 case 'ilcontainerstartobjectsgui':
108
109 $stgui = new ilContainerStartObjectsGUI($this->getParentObject());
110 $ret = $this->ctrl->forwardCommand($stgui);
111
112 $this->tabs->activateSubTab('start');
113 $this->tabs->removeSubTab('manage');
114 break;
115
116 case 'ilconditionhandlergui':
117
118 $this->ctrl->saveParameterByClass('ilconditionhandlergui', 'objective_id');
119
120 $this->tabs->clearTargets();
121 $this->tabs->setBackTarget(
122 $this->lng->txt('back'),
123 $this->ctrl->getLinkTarget($this, 'listObjectives')
124 );
125
126 $cond = new ilConditionHandlerGUI();
127 $cond->setBackButtons(array());
128 $cond->setAutomaticValidation(false);
129 $cond->setTargetType("lobj");
130 $cond->setTargetRefId($this->getParentObject()->getRefId());
131 $cond->setTargetId($this->initObjectiveIdFromQuery());
132
133 // objective
134 $obj = new ilCourseObjective($this->getParentObject(), $this->initObjectiveIdFromQuery());
135 $cond->setTargetTitle($obj->getTitle());
136 $this->ctrl->forwardCommand($cond);
137 break;
138
139 case 'illopagegui':
140 $this->ctrl->saveParameterByClass('illopagegui', 'objective_id');
141
142 $this->tabs->clearTargets();
143 $this->tabs->setBackTarget(
144 $this->lng->txt('back'),
145 $this->ctrl->getLinkTarget($this, 'listObjectives')
146 );
147
148 $objtv_id = $this->initObjectiveIdFromQuery();
149
150 if (!ilLOPage::_exists('lobj', $objtv_id)) {
151 // doesn't exist -> create new one
152 $new_page_object = new ilLOPage();
153 $new_page_object->setParentId($objtv_id);
154 $new_page_object->setId($objtv_id);
155 $new_page_object->createFromXML();
156 unset($new_page_object);
157 }
158
159 $this->ctrl->setReturn($this, 'listObjectives');
160 $pgui = new ilLOPageGUI($objtv_id);
161 $pgui->setPresentationTitle(ilCourseObjective::lookupObjectiveTitle($objtv_id));
162
163 $pgui->setStyleId($this->content_style_domain->getEffectiveStyleId());
164
165 // #14895
166 $this->tpl->setCurrentBlock("ContentStyle");
167 $this->tpl->setVariable(
168 "LOCATION_CONTENT_STYLESHEET",
169 ilObjStyleSheet::getContentStylePath($this->content_style_domain->getEffectiveStyleId())
170 );
171 $this->tpl->parseCurrentBlock();
172
173 $ret = $this->ctrl->forwardCommand($pgui);
174 if ($ret) {
175 $this->tpl->setContent($ret);
176 }
177 break;
178
179 default:
180 if (!$cmd) {
181 // get first unaccomplished step
182 $cmd = ilLOEditorStatus::getInstance($this->getParentObject())->getFirstFailedStep();
183 }
184 $this->$cmd();
185
186 break;
187 }
188 }
189
190 protected function initObjectiveIdFromQuery(): int
191 {
192 if ($this->http->wrapper()->query()->has('objective_id')) {
193 return $this->http->wrapper()->query()->retrieve(
194 'objective_id',
195 $this->refinery->kindlyTo()->int()
196 );
197 }
198 return 0;
199 }
200
201 protected function initObjectiveIdsFromPost(): array
202 {
203 if ($this->http->wrapper()->post()->has('objective')) {
204 return $this->http->wrapper()->post()->retrieve(
205 'objective',
206 $this->refinery->kindlyTo()->listOf(
207 $this->refinery->kindlyTo()->int()
208 )
209 );
210 }
211 return [];
212 }
213
214 protected function initTestTypeFromQuery(): int
215 {
216 if ($this->http->wrapper()->query()->has('tt')) {
217 return $this->http->wrapper()->query()->retrieve(
218 'tt',
219 $this->refinery->kindlyTo()->int()
220 );
221 }
222 return 0;
223 }
224
225 protected function returnFromObjectives(): void
226 {
228 $this->listObjectives();
229 }
230
231 public function getParentObject(): ilObject
232 {
233 return $this->parent_obj;
234 }
235
236 public function getParentGUI(): ilObjCourseGUI
237 {
238 return $this->parent_gui;
239 }
240
241 public function getSettings(): ilLOSettings
242 {
243 return $this->settings;
244 }
245
246 public function setTestType(int $a_type): void
247 {
248 $this->test_type = $a_type;
249 }
250
251 public function getTestType(): int
252 {
253 return $this->test_type;
254 }
255
256 protected function settings(?ilPropertyFormGUI $form = null): void
257 {
258 if (!$form instanceof ilPropertyFormGUI) {
259 $form = $this->initSettingsForm();
260 }
261 $this->tabs->activateSubTab('settings');
262 $this->tpl->setContent($form->getHTML());
264 }
265
266 protected function deleteAssignments(int $a_type): void
267 {
268 $assignments = ilLOTestAssignments::getInstance($this->getParentObject()->getId());
269 foreach ($assignments->getAssignmentsByType($a_type) as $assignment) {
270 $assignment->delete();
271 }
272 }
273
275 {
276 switch ($settings->getInitialTestType()) {
280
281 // no break
285
286 break;
287
290 $settings->setInitialTest(0);
291 break;
292 }
293
294 switch ($settings->getQualifyingTestType()) {
297 break;
298
300 $settings->setQualifiedTest(0);
301 break;
302 }
303 $settings->update();
304 }
305
306 protected function saveSettings(): void
307 {
308 $form = $this->initSettingsForm();
309 if ($form->checkInput()) {
311 $settings->setInitialTestType((int) $form->getInput('ittype'));
312 switch ($settings->getInitialTestType()) {
314 $settings->setInitialTestAsStart((bool) $form->getInput('start_ip'));
315 break;
316
319 break;
320
322 $settings->setInitialTestAsStart((bool) $form->getInput('start_iq'));
323 break;
324
327 break;
328
331 break;
332 }
333
334 $settings->setQualifyingTestType((int) $form->getInput('qttype'));
335 switch ($settings->getQualifyingTestType()) {
337 $settings->setQualifyingTestAsStart((bool) $form->getInput('start_q'));
338 break;
339
342 break;
343 }
344
345 $settings->resetResults((bool) $form->getInput('reset'));
346 $settings->setPassedObjectiveMode((int) $form->getInput('passed_mode'));
347
348 if (
351 ) {
353 $this->main_tpl->setOnScreenMessage('info', $this->lng->txt('crs_loc_settings_err_qstart'), true);
354 }
355
356 $settings->update();
357 $this->updateStartObjects();
358 $this->updateTestAssignments($settings);
359
361
362 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
363 $this->ctrl->redirect($this, 'settings');
364 }
365
366 // Error
367 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
368 $form->setValuesByPost();
369 $this->settings($form);
370 }
371
376 {
377 $form = new ilPropertyFormGUI();
378 $form->setFormAction($this->ctrl->getFormAction($this));
379 $form->setTitle($this->lng->txt('crs_loc_settings_tbl'));
380
381 // initial test
382 $type_selector = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_it_type'), 'ittype');
383 $type_selector->setRequired(true);
384 $type_selector->setValue((string) $this->getSettings()->getInitialTestType());
385
386 $type_ipa = new ilRadioOption(
387 $this->lng->txt('crs_loc_settings_type_it_placement_all'),
389 );
390 $type_ipa->setInfo($this->lng->txt('crs_loc_settings_type_it_placement_all_info'));
391 $type_selector->addOption($type_ipa);
392
393 $start_ip = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_it_start_object'), 'start_ip');
394 $start_ip->setValue((string) 1);
395 $start_ip->setChecked($this->getSettings()->isInitialTestStart());
396 $type_ipa->addSubItem($start_ip);
397
398 $type_ips = new ilRadioOption(
399 $this->lng->txt('crs_loc_settings_type_it_placement_sel'),
401 );
402 $type_ips->setInfo($this->lng->txt('crs_loc_settings_type_it_placement_sel_info'));
403 $type_selector->addOption($type_ips);
404
405 $type_iqa = new ilRadioOption(
406 $this->lng->txt('crs_loc_settings_type_it_qualifying_all'),
408 );
409 $type_iqa->setInfo($this->lng->txt('crs_loc_settings_type_it_qualifying_all_info'));
410 $type_selector->addOption($type_iqa);
411
412 $start_iq = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_it_start_object'), 'start_iq');
413 $start_iq->setValue('1');
414 $start_iq->setChecked($this->getSettings()->isInitialTestStart());
415 $type_iqa->addSubItem($start_iq);
416
417 $type_iqs = new ilRadioOption(
418 $this->lng->txt('crs_loc_settings_type_it_qualifying_sel'),
420 );
421 $type_iqs->setInfo($this->lng->txt('crs_loc_settings_type_it_qualifying_sel_info'));
422 $type_selector->addOption($type_iqs);
423
424 $type_ino = new ilRadioOption(
425 $this->lng->txt('crs_loc_settings_type_it_none'),
427 );
428 $type_ino->setInfo($this->lng->txt('crs_loc_settings_type_it_none_info'));
429 $type_selector->addOption($type_ino);
430
431 $form->addItem($type_selector);
432
433 // qualifying test
434 $qt_selector = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_qt_all'), 'qttype');
435 $qt_selector->setRequired(true);
436 $qt_selector->setValue((string) $this->getSettings()->getQualifyingTestType());
437
438 $type_qa = new ilRadioOption(
439 $this->lng->txt('crs_loc_settings_type_q_all'),
441 );
442 $type_qa->setInfo($this->lng->txt('crs_loc_settings_type_q_all_info'));
443 $qt_selector->addOption($type_qa);
444
445 $start_q = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_qt_start_object'), 'start_q');
446 $start_q->setValue('1');
447 $start_q->setChecked($this->getSettings()->isQualifyingTestStart());
448 $type_qa->addSubItem($start_q);
449
450 $passed_mode = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_passed_mode'), 'passed_mode');
451 $passed_mode->setValue(
452 (string) ($this->getSettings()->getPassedObjectiveMode() ?: ilLOSettings::HIDE_PASSED_OBJECTIVE_QST)
453 );
454
455 $passed_mode->addOption(
456 new ilRadioOption(
457 $this->lng->txt('crs_loc_settings_passed_mode_hide'),
459 )
460 );
461 $passed_mode->addOption(
462 new ilRadioOption(
463 $this->lng->txt('crs_loc_settings_passed_mode_mark'),
465 )
466 );
467 $type_qa->addSubItem($passed_mode);
468
469 $type_qs = new ilRadioOption(
470 $this->lng->txt('crs_loc_settings_type_q_selected'),
472 );
473 $type_qs->setInfo($this->lng->txt('crs_loc_settings_type_q_selected_info'));
474 $qt_selector->addOption($type_qs);
475
476 $form->addItem($qt_selector);
477
478 // reset results
479 $reset = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_reset'), 'reset');
480 $reset->setValue('1');
481 $reset->setChecked($this->getSettings()->isResetResultsEnabled());
482 $reset->setOptionTitle($this->lng->txt('crs_loc_settings_reset_enable'));
483 $reset->setInfo($this->lng->txt('crs_loc_settings_reset_enable_info'));
484 $form->addItem($reset);
485
486 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
487 return $form;
488 }
489
490 protected function materials(): void
491 {
492 $this->tabs->activateSubTab('materials');
493
494 $this->parent_gui->renderAddNewItem('itgr');
495
496 $this->tpl->setOnScreenMessage(
497 'info',
498 $this->lng->txt('crs_objective_status_materials_info')
499 );
500
502 }
503
504 protected function testsOverview(): void
505 {
507 $this->setTestType($this->initTestTypeFromQuery());
508 }
509 $this->ctrl->setParameter($this, 'tt', $this->getTestType());
510
511 $this->toolbar->setFormAction($this->ctrl->getFormAction($this));
512 $this->toolbar->addButton(
513 $this->lng->txt('crs_loc_btn_new_assignment'),
514 $this->ctrl->getLinkTarget($this, 'testAssignment')
515 );
516
518 switch ($this->getTestType()) {
520 $this->tabs->activateSubTab('itests');
521 break;
522
524 $this->tabs->activateSubTab('qtests');
525 break;
526 }
527
528 try {
529 $data_retrieval = new ilLOTestAssignmentTableDataRetrieval(
530 $this->lng,
531 $this->db,
532 $this->ui_services,
533 $this->ctrl,
535 );
536 $data_retrieval->parseMultipleAssignments(
537 $this->getParentObject()->getId(),
538 $this->getTestType()
539 );
540 $table = new ilLOTestAssignmentTableGUI(
542 $this->getTestType(),
543 $this->getParentObject()->getId(),
544 $this->lng,
545 $this->ui_services,
546 $this->http,
547 $data_retrieval,
548 $this->refinery,
549 $this->ctrl,
550 $this->getParentObject()
551 );
552 $table->handleCommands();
553 $this->tpl->setContent($table->getHTML());
554 $this->showStatus(
558 );
560 $this->logger->debug(': Show new assignment screen because of : ' . $ex->getMessage());
561 $this->testSettings();
562 }
563 }
564
565 protected function testsOverviewInitial(): void
566 {
568 $this->testsOverview();
569 }
570
571 protected function testsOverviewQualified(): void
572 {
574 $this->testsOverview();
575 }
576
580 protected function testOverview(): void
581 {
583 $this->setTestType($this->initTestTypeFromQuery());
584 }
585 $this->ctrl->setParameter($this, 'tt', $this->getTestType());
586
588 switch ($this->getTestType()) {
590 $this->tabs->activateSubTab('itest');
591 break;
592
594 $this->tabs->activateSubTab('qtest');
595 break;
596 }
597
598 // Check if test is assigned
599 if (!$settings->getTestByType($this->getTestType())) {
600 $this->testSettings();
601 return;
602 }
603
604 try {
605 $data_retrieval = new ilLOTestAssignmentTableDataRetrieval(
606 $this->lng,
607 $this->db,
608 $this->ui_services,
609 $this->ctrl,
611 );
612 $data_retrieval->parseSingleAssignment(
613 ilLOSettings::getInstanceByObjId($this->getParentObject()->getId())->getTestByType($this->getTestType())
614 );
615 $table = new ilLOTestAssignmentTableGUI(
617 $this->getTestType(),
618 $this->getParentObject()->getId(),
619 $this->lng,
620 $this->ui_services,
621 $this->http,
622 $data_retrieval,
623 $this->refinery,
624 $this->ctrl,
625 $this->getParentObject()
626 );
627 $table->handleCommands();
628 $this->tpl->setContent($table->getHTML());
629 $this->showStatus(
633 );
635 $this->logger->debug(': Show new assignment screen because of : ' . $ex->getMessage());
636 $this->testSettings();
637 }
638 }
639
640 protected function testOverviewInitial(): void
641 {
643 $this->testOverview();
644 }
645
646 protected function testOverviewQualified(): void
647 {
649 $this->testOverview();
650 }
651
652 protected function testAssignment(?ilPropertyFormGUI $form = null): void
653 {
655 $this->setTestType($this->initTestTypeFromQuery());
656 }
657 $this->ctrl->setParameter($this, 'tt', $this->getTestType());
658
659 switch ($this->getTestType()) {
661 $this->tabs->activateSubTab('itests');
662 break;
663
665 $this->tabs->activateSubTab('qtests');
666 break;
667 }
668 if (!$form instanceof ilPropertyFormGUI) {
669 $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(), $this->getTestType());
670 $form = $form_helper->initForm(true);
671 }
672 $this->tpl->setContent($form->getHTML());
673
674 $this->showStatus(
675 ($this->getTestType() == self::TEST_TYPE_IT) ?
678 );
679 }
680
681 protected function testSettings(?ilPropertyFormGUI $form = null): void
682 {
683 $this->ctrl->setParameter($this, 'tt', $this->getTestType());
684 switch ($this->getTestType()) {
686 $this->tabs->activateSubTab('itest');
687 break;
688
690 $this->tabs->activateSubTab('qtest');
691 break;
692 }
693
694 if (!$form instanceof ilPropertyFormGUI) {
695 $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(), $this->getTestType());
696 $form = $form_helper->initForm(false);
697 }
698 $this->tpl->setContent($form->getHTML());
699
700 $this->showStatus(
701 ($this->getTestType() == self::TEST_TYPE_IT) ?
704 );
705 }
706
707 protected function updateStartObjects(): void
708 {
709 $start = new ilContainerStartObjects(0, $this->getParentObject()->getId());
710 $this->getSettings()->updateStartObjects($start);
711 }
712
713 protected function saveMultiTestAssignment(): void
714 {
715 $this->ctrl->setParameter($this, 'tt', $this->initTestTypeFromQuery());
716 $this->setTestType($this->initTestTypeFromQuery());
717
719
720 $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(), $this->getTestType());
721 $form = $form_helper->initForm(true);
722
723 if ($form->checkInput()) {
724 $mode = $form->getInput('mode');
725
726 if ($mode == self::TEST_NEW) {
727 $tst = new ilObjTest();
728 $tst->setType('tst');
729 $tst->setTitle($form->getInput('title'));
730 $tst->setDescription($form->getInput('desc'));
731 $tst->create();
732 $tst->saveToDb();
733 $tst->createReference();
734 $tst->putInTree($this->getParentObject()->getRefId());
735 $tst->setPermissions($this->getParentObject()->getRefId());
736 $general_settings = $tst->getMainSettings()->getGeneralSettings()->withQuestionSetType($form->getInput('qtype'));
737 $tst->getMainSettingsRepository()->store(
738 $tst->getMainSettings()->withGeneralSettings($general_settings)
739 );
740
741 $assignment = new ilLOTestAssignment();
742 $assignment->setContainerId($this->getParentObject()->getId());
743 $assignment->setAssignmentType($this->getTestType());
744 $assignment->setObjectiveId((int) $form->getInput('objective'));
745 $assignment->setTestRefId($tst->getRefId());
746 $assignment->save();
747 } else {
748 $assignment = new ilLOTestAssignment();
749 $assignment->setContainerId($this->getParentObject()->getId());
750 $assignment->setAssignmentType($this->getTestType());
751 $assignment->setObjectiveId((int) $form->getInput('objective'));
752 $assignment->setTestRefId((int) $form->getInput('tst'));
753 $assignment->save();
754
755 $tst = new ilObjTest((int) $form->getInput('tst'), true);
756 $tst->saveToDb();
757 }
758
759 // deassign as objective material
760 if ($tst instanceof ilObjTest) {
761 $this->updateMaterialAssignments($tst);
762 }
763 $this->updateStartObjects();
764
765 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'));
766 $this->ctrl->redirect($this, 'testsOverview');
767 }
768
769 // Error
770 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
771 $form->setValuesByPost();
772 $this->testAssignment($form);
773 }
774
775 protected function updateMaterialAssignments(ilObjTest $test): void
776 {
777 foreach (ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId()) as $objective_id) {
778 $materials = new ilCourseObjectiveMaterials($objective_id);
779 foreach ($materials->getMaterials() as $material) {
780 if ($material['ref_id'] == $test->getRefId()) {
781 $materials->delete($material['lm_ass_id']);
782 }
783 }
784 }
785 }
786
787 protected function saveTest(): void
788 {
789 $this->ctrl->setParameter($this, 'tt', $this->initTestTypeFromQuery());
790 $this->setTestType($this->initTestTypeFromQuery());
791
793
794 $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(), $this->getTestType());
795 $form = $form_helper->initForm(false);
796
797 if ($form->checkInput()) {
798 $mode = $form->getInput('mode');
799
800 if ($mode == self::TEST_NEW) {
801 $tst = new ilObjTest();
802 $tst->setType('tst');
803 $tst->setTitle($form->getInput('title'));
804 $tst->setDescription($form->getInput('desc'));
805 $tst->create();
806 $tst->saveToDb();
807 $tst->createReference();
808 $tst->putInTree($this->getParentObject()->getRefId());
809 $tst->setPermissions($this->getParentObject()->getRefId());
810 $general_settings = $tst->getMainSettings()->getGeneralSettings()->withQuestionSetType($form->getInput('qtype'));
811 $tst->getMainSettingsRepository()->store(
812 $tst->getMainSettings()->withGeneralSettings($general_settings)
813 );
814
815 if ($this->getTestType() == self::TEST_TYPE_IT) {
816 $this->getSettings()->setInitialTest($tst->getRefId());
817 } else {
818 $this->getSettings()->setQualifiedTest($tst->getRefId());
819 }
820 $this->getSettings()->update();
821 } else {
822 if ($this->getTestType() == self::TEST_TYPE_IT) {
823 $this->getSettings()->setInitialTest((int) $form->getInput('tst'));
824 } else {
825 $this->getSettings()->setQualifiedTest((int) $form->getInput('tst'));
826 }
827
828 $this->getSettings()->update();
829 $tst = new ilObjTest($settings->getTestByType($this->getTestType()), true);
830 $tst->saveToDb();
831 }
832
833 // deassign as objective material
834 if ($tst instanceof ilObjTest) {
835 $this->updateMaterialAssignments($tst);
836 }
837 $this->updateStartObjects();
838
839 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'));
840 $this->ctrl->redirect($this, 'testOverview');
841 }
842
843 // Error
844 $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
845 $form->setValuesByPost();
846 $this->testSettings($form);
847 }
848
849 protected function listObjectives(): void
850 {
852 $this->tabs->activateSubTab('objectives');
853
855 $this->getParentObject()->getId(),
856 false
857 );
858
859 if ($objectives === []) {
860 $this->showObjectiveCreation();
861 return;
862 }
863
864 $this->toolbar->addButton(
865 $this->lng->txt('crs_add_objective'),
866 $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', "create")
867 );
868
869 $table = new ilCourseObjectivesTableGUI($this, $this->getParentObject());
870 $table->setTitle($this->lng->txt('crs_objectives'), '', $this->lng->txt('crs_objectives'));
871 $table->parse($objectives);
872 $this->tpl->setContent($table->getHTML());
873
875 }
876
877 protected function showObjectiveCreation(?ilPropertyFormGUI $form = null): void
878 {
879 $this->tabs->activateSubTab('objectives');
880 if (!$form instanceof ilPropertyFormGUI) {
881 $form = $this->initSimpleObjectiveForm();
882 }
883 $this->tpl->setContent($form->getHTML());
885 }
886
888 {
889 $form = new ilPropertyFormGUI();
890 $form->setTitle($this->lng->txt('crs_loc_form_create_objectives'));
891 $form->setFormAction($this->ctrl->getFormAction($this));
892
893 $txt = new ilTextWizardInputGUI($this->lng->txt('crs_objectives'), 'objectives');
894 $txt->setValues(array(0 => ''));
895 $txt->setRequired(true);
896 $form->addItem($txt);
897
898 $form->addCommandButton('saveObjectiveCreation', $this->lng->txt('save'));
899 return $form;
900 }
901
902 protected function saveObjectiveCreation(): void
903 {
904 $form = $this->initSimpleObjectiveForm();
905 if ($form->checkInput()) {
906 foreach ((array) $form->getInput('objectives') as $title) {
907 $obj = new ilCourseObjective($this->getParentObject());
908 $obj->setActive(true);
909 $obj->setTitle($title);
910 $obj->add();
911 }
912 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
913 $this->ctrl->redirect($this, '');
914 }
915
916 $form->setValuesByPost();
917 $this->tabs->activateSubTab('objectives');
919 $this->showObjectiveCreation($form);
920 }
921
922 protected function saveSorting(): void
923 {
924 $post_position = $this->http->wrapper()->post()->retrieve(
925 'position',
926 $this->refinery->kindlyTo()->dictOf(
927 $this->refinery->kindlyTo()->string()
928 )
929 );
930 asort($post_position, SORT_NUMERIC);
931 $counter = 1;
932 foreach ($post_position as $objective_id => $position) {
933 $objective = new ilCourseObjective($this->getParentObject(), $objective_id);
934 $objective->writePosition($counter++);
935 }
936 $this->main_tpl->setOnScreenMessage('success', $this->lng->txt('crs_objective_saved_sorting'));
937 $this->listObjectives();
938 }
939
940 protected function askDeleteObjectives(): void
941 {
942 $this->tabs->activateSubTab('objectives');
943
944 $confirm = new ilConfirmationGUI();
945 $confirm->setFormAction($this->ctrl->getFormAction($this));
946 $confirm->setHeaderText($this->lng->txt('crs_delete_objectve_sure'));
947 $confirm->setConfirm($this->lng->txt('delete'), 'deleteObjectives');
948 $confirm->setCancel($this->lng->txt('cancel'), 'listObjectives');
949
950 $objective_ids = [];
951 if ($this->http->wrapper()->post()->has('objective')) {
952 $objective_ids = $this->http->wrapper()->post()->retrieve(
953 'objective',
954 $this->refinery->kindlyTo()->dictOf(
955 $this->refinery->kindlyTo()->int()
956 )
957 );
958 }
959 foreach ($objective_ids as $objective_id) {
960 $obj = new ilCourseObjective($this->getParentObject(), $objective_id);
961 $name = $obj->getTitle();
962
963 $confirm->addItem(
964 'objective_ids[]',
965 (string) $objective_id,
966 $name
967 );
968 }
969 $this->tpl->setContent($confirm->getHTML());
971 }
972
973 protected function activateObjectives(): void
974 {
975 $enabled = $this->initObjectiveIdsFromPost();
977 foreach ($objectives as $objective_id) {
978 $objective = new ilCourseObjective($this->getParentObject(), $objective_id);
979 if (in_array($objective_id, $enabled)) {
980 $objective->setActive(true);
981 $objective->update();
982 }
983 }
985 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
986 $this->ctrl->redirect($this, 'listObjectives');
987 }
988
989 protected function deactivateObjectives(): void
990 {
991 $disabled = $this->initObjectiveIdsFromPost();
993 foreach ($objectives as $objective_id) {
994 $objective = new ilCourseObjective($this->getParentObject(), $objective_id);
995 if (in_array($objective_id, $disabled)) {
996 $objective->setActive(false);
997 $objective->update();
998 }
999 }
1001 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
1002 $this->ctrl->redirect($this, 'listObjectives');
1003 }
1004
1005 protected function deleteObjectives(): void
1006 {
1007 $objective_ids = [];
1008 if ($this->http->wrapper()->post()->has('objective_ids')) {
1009 $objective_ids = $this->http->wrapper()->post()->retrieve(
1010 'objective_ids',
1011 $this->refinery->kindlyTo()->dictOf(
1012 $this->refinery->kindlyTo()->int()
1013 )
1014 );
1015 }
1016 foreach ($objective_ids as $objective_id) {
1017 $objective_obj = new ilCourseObjective($this->getParentObject(), $objective_id);
1018 $objective_obj->delete();
1019 }
1021 $this->tpl->setOnScreenMessage('success', $this->lng->txt('crs_objectives_deleted'), true);
1022 $this->ctrl->redirect($this, 'listObjectives');
1023 }
1024
1025 protected function showStatus(int $a_section): void
1026 {
1027 $status = new ilLOEditorStatus($this->getParentObject());
1028 $status->setSection($a_section);
1029 $status->setCmdClass($this);
1030 $this->tpl->setRightContent($status->getHTML());
1031 }
1032
1033 protected function setTabs(string $a_section = ''): void
1034 {
1035 // objective settings
1036 $this->tabs->addSubTab(
1037 'settings',
1038 $this->lng->txt('settings'),
1039 $this->ctrl->getLinkTarget($this, 'settings')
1040 );
1041 // learning objectives
1042 $this->tabs->addSubTab(
1043 'objectives',
1044 $this->lng->txt('crs_loc_tab_objectives'),
1045 $this->ctrl->getLinkTarget($this, 'listObjectives')
1046 );
1047 // materials
1048 // tests
1050 if ($settings->worksWithInitialTest()) {
1051 if (
1054 ) {
1055 $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_INITIAL);
1056 $this->tabs->addSubTab(
1057 'itest',
1058 $this->lng->txt('crs_loc_tab_itest'),
1059 $this->ctrl->getLinkTarget($this, 'testOverview')
1060 );
1061 } else {
1062 $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_INITIAL);
1063 $this->tabs->addSubTab(
1064 'itests',
1065 $this->lng->txt('crs_loc_tab_itests'),
1066 $this->ctrl->getLinkTarget($this, 'testsOverview')
1067 );
1068 }
1069 }
1070
1072 $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_QUALIFIED);
1073 $this->tabs->addSubTab(
1074 'qtest',
1075 $this->lng->txt('crs_loc_tab_qtest'),
1076 $this->ctrl->getLinkTarget($this, 'testOverview')
1077 );
1078 } else {
1079 $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_QUALIFIED);
1080 $this->tabs->addSubTab(
1081 'qtests',
1082 $this->lng->txt('crs_loc_tab_qtests'),
1083 $this->ctrl->getLinkTarget($this, 'testsOverview')
1084 );
1085 }
1086
1088 $this->tabs->addSubTab(
1089 'start',
1090 $this->lng->txt('crs_loc_tab_start'),
1091 $this->ctrl->getLinkTargetByClass('ilcontainerstartobjectsgui', '')
1092 );
1093 }
1094
1095 // Member view
1096 #ilMemberViewGUI::showMemberViewSwitch($this->getParentObject()->getRefId());
1097 }
1098}
Provides fluid interface to RBAC services.
Definition: UIServices.php:25
Builds data types.
Definition: Factory.php:36
External facade for object content styles.
This class represents a checkbox property in a property form.
class ilConditionHandlerGUI
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilContainerStartObjectsGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
class ilCourseObjectiveMaterials
class ilcourseobjective
static lookupObjectiveTitle(int $a_objective_id, bool $a_add_description=false)
static _getObjectiveIds(int $course_id, bool $a_activated_only=false)
class ilobjcourseobjectivesgui
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilLOEditorGUI.
ilCtrlInterface $ctrl
testOverview()
Show test overview.
ilLOSettings $settings
showObjectiveCreation(?ilPropertyFormGUI $form=null)
ilToolbarGUI $toolbar
showStatus(int $a_section)
updateTestAssignments(ilLOSettings $settings)
ilGlobalTemplateInterface $tpl
const int TEST_TYPE_UNDEFINED
ilUIServices $ui_services
settings(?ilPropertyFormGUI $form=null)
ObjectFacade $content_style_domain
__construct(ilObjCourseGUI $parent_gui)
initSettingsForm()
Init settings form.
testSettings(?ilPropertyFormGUI $form=null)
updateMaterialAssignments(ilObjTest $test)
setTestType(int $a_type)
ilGlobalTemplateInterface $main_tpl
GlobalHttpState $http
ilObjCourseGUI $parent_gui
deleteAssignments(int $a_type)
testAssignment(?ilPropertyFormGUI $form=null)
ilDBInterface $db
setTabs(string $a_section='')
Presentation of the status of single steps during the configuration process.
static getInstance(ilObject $a_parent)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
(Course) learning objective page GUI class
(Course) learning objective page object
Settings for LO courses.
const TYPE_INITIAL_QUALIFYING_ALL
const TYPE_INITIAL_PLACEMENT_SELECTED
static getInstanceByObjId(int $a_obj_id)
const HIDE_PASSED_OBJECTIVE_QST
setQualifyingTestAsStart(bool $a_type)
setQualifyingTestType(int $a_type)
const TYPE_INITIAL_PLACEMENT_ALL
worksWithStartObjects()
Check if start objects are enabled.
getTestByType(int $a_type)
const MARK_PASSED_OBJECTIVE_QST
resetResults(bool $a_status)
worksWithInitialTest()
Check if the loc is configured for initial tests.
setInitialTest(int $a_id)
setQualifiedTest(int $a_id)
const TYPE_QUALIFYING_SELECTED
const TYPE_INITIAL_QUALIFYING_SELECTED
setInitialTestType(int $a_type)
setInitialTestAsStart(bool $a_type)
setPassedObjectiveMode(int $a_mode)
Class ilLOTestAssignmentTableGUI.
Settings for LO courses.
static getInstance(int $a_container_id)
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
language handling
Component logger with individual log levels by component id.
Class ilObjCourseGUI.
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
Class ilObject Basic functions for all objects.
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
static set(string $a_var, $a_val)
Set a value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text wizard property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface GlobalHttpState.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilDBInterface.
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26
$counter
$objectives