ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLOEditorGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
5include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
6include_once './Modules/Course/classes/Objectives/class.ilLOEditorStatus.php';
7
20{
21 const TEST_TYPE_IT = 1;
22 const TEST_TYPE_QT = 2;
23
24 const TEST_NEW = 1;
25 const TEST_ASSIGN = 2;
26
27 const SETTINGS_TEMPLATE_IT = 'il_astpl_loc_initial';
28 const SETTINGS_TEMPLATE_QT = 'il_astpl_loc_qualified';
29
30
34 private $logger = null;
35
36
37 private $parent_obj;
38 private $settings = null;
39 private $lng = null;
40 private $ctrl = null;
41
42 private $test_type = 0;
43
44
49 public function __construct($a_parent_obj)
50 {
51 $this->parent_obj = $a_parent_obj;
53 $this->lng = $GLOBALS['lng'];
54 $this->ctrl = $GLOBALS['ilCtrl'];
55
56 $this->logger = ilLoggerFactory::getLogger('crs');
57 }
58
63 public function executeCommand()
64 {
65 global $ilCtrl;
66
67 $next_class = $ilCtrl->getNextClass($this);
68 $cmd = $ilCtrl->getCmd();
69
70 $this->setTabs();
71 switch ($next_class) {
72 case 'ilcourseobjectivesgui':
73
74 $this->ctrl->setReturn($this, 'returnFromObjectives');
75 $GLOBALS['ilTabs']->clearTargets();
76 $GLOBALS['ilTabs']->setBackTarget(
77 $this->lng->txt('back'),
78 $this->ctrl->getLinkTarget($this, 'listObjectives')
79 );
80
81 include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php';
82 $reg_gui = new ilCourseObjectivesGUI($this->getParentObject()->getRefId());
83 $this->ctrl->forwardCommand($reg_gui);
84 break;
85
86 case 'ilcontainerstartobjectsgui':
87
88 include_once './Services/Container/classes/class.ilContainerStartObjectsGUI.php';
89 $stgui = new ilContainerStartObjectsGUI($this->getParentObject());
90 $ret = $this->ctrl->forwardCommand($stgui);
91
92 $GLOBALS['ilTabs']->activateSubTab('start');
93 $GLOBALS['ilTabs']->removeSubTab('manage');
94
95 #$GLOBALS['tpl']->setContent($this->ctrl->getHTML($stgui));
96 break;
97
98 case 'ilconditionhandlergui':
99
100 $this->ctrl->saveParameterByClass('ilconditionhandlergui', 'objective_id');
101
102 $GLOBALS['ilTabs']->clearTargets();
103 $GLOBALS['ilTabs']->setBackTarget(
104 $this->lng->txt('back'),
105 $this->ctrl->getLinkTarget($this, 'listObjectives')
106 );
107
108 include_once './Services/AccessControl/classes/class.ilConditionHandlerInterface.php';
109 $cond = new ilConditionHandlerGUI($this);
110 $cond->setBackButtons(array());
111 $cond->setAutomaticValidation(false);
112 $cond->setTargetType("lobj");
113 $cond->setTargetRefId($this->getParentObject()->getRefId());
114
115 $cond->setTargetId((int) $_REQUEST['objective_id']);
116
117 // objecitve
118 include_once './Modules/Course/classes/class.ilCourseObjective.php';
119 $obj = new ilCourseObjective($this->getParentObject(), (int) $_REQUEST['objective_id']);
120 $cond->setTargetTitle($obj->getTitle());
121 $this->ctrl->forwardCommand($cond);
122 break;
123
124 case 'illopagegui':
125 $this->ctrl->saveParameterByClass('illopagegui', 'objective_id');
126
127 $GLOBALS['ilTabs']->clearTargets();
128 $GLOBALS['ilTabs']->setBackTarget(
129 $this->lng->txt('back'),
130 $this->ctrl->getLinkTarget($this, 'listObjectives')
131 );
132
133 $objtv_id = (int) $_REQUEST['objective_id'];
134
135 include_once 'Modules/Course/classes/Objectives/class.ilLOPage.php';
136 if (!ilLOPage::_exists('lobj', $objtv_id)) {
137 // doesn't exist -> create new one
138 $new_page_object = new ilLOPage();
139 $new_page_object->setParentId($objtv_id);
140 $new_page_object->setId($objtv_id);
141 $new_page_object->createFromXML();
142 unset($new_page_object);
143 }
144
145 $this->ctrl->setReturn($this, 'listObjectives');
146 include_once 'Modules/Course/classes/Objectives/class.ilLOPageGUI.php';
147 $pgui = new ilLOPageGUI($objtv_id);
148 $pgui->setPresentationTitle(ilCourseObjective::lookupObjectiveTitle($objtv_id));
149
150 include_once('./Services/Style/Content/classes/class.ilObjStyleSheet.php');
152 $this->parent_obj->getStyleSheetId(),
153 $this->parent_obj->getType()
154 ));
155
156 // #14895
157 $GLOBALS['tpl']->setCurrentBlock("ContentStyle");
158 $GLOBALS['tpl']->setVariable(
159 "LOCATION_CONTENT_STYLESHEET",
161 $this->parent_obj->getStyleSheetId(),
162 $this->parent_obj->getType()
163 ))
164 );
165 $GLOBALS['tpl']->parseCurrentBlock();
166
167 $ret = $this->ctrl->forwardCommand($pgui);
168 if ($ret) {
169 $GLOBALS['tpl']->setContent($ret);
170 }
171 break;
172
173 default:
174 if (!$cmd) {
175 // get first unaccomplished step
176 include_once './Modules/Course/classes/Objectives/class.ilLOEditorStatus.php';
177 $cmd = ilLOEditorStatus::getInstance($this->getParentObject())->getFirstFailedStep();
178 }
179 $this->$cmd();
180
181 break;
182 }
183 return true;
184 }
185
190 protected function returnFromObjectives()
191 {
192 include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php';
194 return $this->listObjectives();
195 }
196
200 public function getParentObject()
201 {
202 return $this->parent_obj;
203 }
204
209 public function getSettings()
210 {
211 return $this->settings;
212 }
213
214 public function setTestType($a_type)
215 {
216 $this->test_type = $a_type;
217 }
218
219 public function getTestType()
220 {
221 return $this->test_type;
222 }
223
224
228 protected function settings(ilPropertyFormGUI $form = null)
229 {
230 if (!$form instanceof ilPropertyFormGUI) {
231 $form = $this->initSettingsForm();
232 }
233
234 $GLOBALS['ilTabs']->activateSubTab('settings');
235 $GLOBALS['tpl']->setContent($form->getHTML());
236
238 }
239
244 protected function deleteAssignments($a_type)
245 {
246 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
247 $assignments = ilLOTestAssignments::getInstance($this->getParentObject()->getId());
248 foreach ($assignments->getAssignmentsByType($a_type) as $assignment) {
249 $assignment->delete();
250 }
251 return;
252 }
253
259 {
260 switch ($settings->getInitialTestType()) {
262 $settings->setInitialTest(0);
264
265 // no break
269
270 break;
271
274 $settings->setInitialTest(0);
275 break;
276 }
277
278 switch ($settings->getQualifyingTestType()) {
281 break;
282
284 $settings->setQualifiedTest(0);
285 break;
286 }
287 $settings->update();
288 }
289
290
294 protected function saveSettings()
295 {
296 $form = $this->initSettingsForm();
297 if ($form->checkInput()) {
299 $settings->setInitialTestType($form->getInput('ittype'));
300 switch ($settings->getInitialTestType()) {
302 $settings->setInitialTestAsStart($form->getInput('start_ip'));
303 break;
304
306 $settings->setInitialTestAsStart(false);
307 break;
308
310 $settings->setInitialTestAsStart($form->getInput('start_iq'));
311 break;
312
314 $settings->setInitialTestAsStart(false);
315 break;
316
318 $settings->setInitialTestAsStart(false);
319 break;
320 }
321
322 $settings->setQualifyingTestType($form->getInput('qttype'));
323 switch ($settings->getQualifyingTestType()) {
325 $settings->setQualifyingTestAsStart($form->getInput('start_q'));
326 break;
327
329 $settings->setQualifyingTestAsStart(false);
330 break;
331 }
332
333
334 $settings->resetResults($form->getInput('reset'));
335 $settings->setPassedObjectiveMode($form->getInput('passed_mode'));
336
337 if (
338 ($settings->getInitialTestType() != ilLOSettings::TYPE_INITIAL_NONE) &&
339 ($settings->isQualifyingTestStart())
340 ) {
341 $settings->setQualifyingTestAsStart(false);
342 ilUtil::sendInfo($this->lng->txt('crs_loc_settings_err_qstart'), true);
343 }
344
345 $settings->update();
346 $this->updateStartObjects();
348
349 include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
351
352 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
353 $this->ctrl->redirect($this, 'settings');
354 }
355
356 // Error
357 ilUtil::sendFailure($this->lng->txt('err_check_input'));
358 $form->setValuesByPost();
359 $this->settings($form);
360 }
361
365 protected function initSettingsForm()
366 {
367 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
368 $form = new ilPropertyFormGUI();
369 $form->setFormAction($this->ctrl->getFormAction($this));
370 $form->setTitle($this->lng->txt('crs_loc_settings_tbl'));
371
372 // initial test
373 $type_selector = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_it_type'), 'ittype');
374 $type_selector->setRequired(true);
375 $type_selector->setValue($this->getSettings()->getInitialTestType());
376
377 $type_ipa = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_placement_all'), ilLOSettings::TYPE_INITIAL_PLACEMENT_ALL);
378 $type_ipa->setInfo($this->lng->txt('crs_loc_settings_type_it_placement_all_info'));
379 $type_selector->addOption($type_ipa);
380
381 $start_ip = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_it_start_object'), 'start_ip');
382 $start_ip->setValue(1);
383 $start_ip->setChecked($this->getSettings()->isInitialTestStart());
384 $type_ipa->addSubItem($start_ip);
385
386 $type_ips = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_placement_sel'), ilLOSettings::TYPE_INITIAL_PLACEMENT_SELECTED);
387 $type_ips->setInfo($this->lng->txt('crs_loc_settings_type_it_placement_sel_info'));
388 $type_selector->addOption($type_ips);
389
390 $type_iqa = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_qualifying_all'), ilLOSettings::TYPE_INITIAL_QUALIFYING_ALL);
391 $type_iqa->setInfo($this->lng->txt('crs_loc_settings_type_it_qualifying_all_info'));
392 $type_selector->addOption($type_iqa);
393
394 $start_iq = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_it_start_object'), 'start_iq');
395 $start_iq->setValue(1);
396 $start_iq->setChecked($this->getSettings()->isInitialTestStart());
397 $type_iqa->addSubItem($start_iq);
398
399 $type_iqs = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_qualifying_sel'), ilLOSettings::TYPE_INITIAL_QUALIFYING_SELECTED);
400 $type_iqs->setInfo($this->lng->txt('crs_loc_settings_type_it_qualifying_sel_info'));
401 $type_selector->addOption($type_iqs);
402
403 $type_ino = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_none'), ilLOSettings::TYPE_INITIAL_NONE);
404 $type_ino->setInfo($this->lng->txt('crs_loc_settings_type_it_none_info'));
405 $type_selector->addOption($type_ino);
406
407 $form->addItem($type_selector);
408
409 // qualifying test
410 $qt_selector = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_qt_all'), 'qttype');
411 $qt_selector->setRequired(true);
412 $qt_selector->setValue($this->getSettings()->getQualifyingTestType());
413
414 $type_qa = new ilRadioOption($this->lng->txt('crs_loc_settings_type_q_all'), ilLOSettings::TYPE_QUALIFYING_ALL);
415 $type_qa->setInfo($this->lng->txt('crs_loc_settings_type_q_all_info'));
416 $qt_selector->addOption($type_qa);
417
418 $start_q = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_qt_start_object'), 'start_q');
419 $start_q->setValue(1);
420 $start_q->setChecked($this->getSettings()->isQualifyingTestStart());
421 $type_qa->addSubItem($start_q);
422
423 $passed_mode = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_passed_mode'), 'passed_mode');
424 $passed_mode->setValue($this->getSettings()->getPassedObjectiveMode());
425
426 $passed_mode->addOption(
427 new ilRadioOption(
428 $this->lng->txt('crs_loc_settings_passed_mode_hide'),
430 )
431 );
432 $passed_mode->addOption(
433 new ilRadioOption(
434 $this->lng->txt('crs_loc_settings_passed_mode_mark'),
436 )
437 );
438 $type_qa->addSubItem($passed_mode);
439
440 $type_qs = new ilRadioOption($this->lng->txt('crs_loc_settings_type_q_selected'), ilLOSettings::TYPE_QUALIFYING_SELECTED);
441 $type_qs->setInfo($this->lng->txt('crs_loc_settings_type_q_selected_info'));
442 $qt_selector->addOption($type_qs);
443
444 $form->addItem($qt_selector);
445
446 // reset results
447 $reset = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_reset'), 'reset');
448 $reset->setValue(1);
449 $reset->setChecked($this->getSettings()->isResetResultsEnabled());
450 $reset->setOptionTitle($this->lng->txt('crs_loc_settings_reset_enable'));
451 $reset->setInfo($this->lng->txt('crs_loc_settings_reset_enable_info'));
452 $form->addItem($reset);
453
454 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
455
456
457 return $form;
458 }
459
460 protected function materials()
461 {
462 $GLOBALS['ilTabs']->activateSubTab('materials');
463
464 include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php";
465 $gui = new ilObjectAddNewItemGUI($this->getParentObject()->getRefId());
466 $gui->setDisabledObjectTypes(array("itgr"));
467 #$gui->setAfterCreationCallback($this->getParentObject()->getRefId());
468 $gui->render();
469
470 include_once './Services/Object/classes/class.ilObjectTableGUI.php';
471 $obj_table = new ilObjectTableGUI(
472 $this,
473 'materials',
474 $this->getParentObject()->getRefId()
475 );
476 $obj_table->init();
477 $obj_table->setObjects($GLOBALS['tree']->getChildIds($this->getParentObject()->getRefId()));
478 $obj_table->parse();
479 $GLOBALS['tpl']->setContent($obj_table->getHTML());
480
482 }
483
487 protected function testsOverview()
488 {
489 $this->setTestType((int) $_REQUEST['tt']);
490 $this->ctrl->setParameter($this, 'tt', $this->getTestType());
491
492 $GLOBALS['ilToolbar']->setFormAction($this->ctrl->getFormAction($this));
493 $GLOBALS['ilToolbar']->addButton(
494 $this->lng->txt('crs_loc_btn_new_assignment'),
495 $this->ctrl->getLinkTarget($this, 'testAssignment')
496 );
497
498
500 switch ($this->getTestType()) {
502 $GLOBALS['ilTabs']->activateSubTab('itests');
503 break;
504
506 $GLOBALS['ilTabs']->activateSubTab('qtests');
507 break;
508 }
509
510 try {
511 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentTableGUI.php';
513 $this,
514 'testsOverview',
515 $this->getParentObject()->getId(),
516 $this->getTestType(),
518 );
519 $table->init();
520 $table->parseMultipleAssignments();
521 $GLOBALS['tpl']->setContent($table->getHTML());
522
523 $this->showStatus(
527 );
529 $GLOBALS['ilLog']->write(__METHOD__ . ': Show new assignment screen because of : ' . $ex->getMessage());
530 $this->testSettings();
531 }
532 }
533
534
538 protected function testOverview()
539 {
540 $this->setTestType((int) $_REQUEST['tt']);
541 $this->ctrl->setParameter($this, 'tt', $this->getTestType());
542
544 switch ($this->getTestType()) {
546 $GLOBALS['ilTabs']->activateSubTab('itest');
547 break;
548
550 $GLOBALS['ilTabs']->activateSubTab('qtest');
551 break;
552 }
553
554
555 // Check if test is assigned
556 if (!$settings->getTestByType($this->getTestType())) {
557 return $this->testSettings();
558 }
559
560 try {
561 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentTableGUI.php';
563 $this,
564 'testOverview',
565 $this->getParentObject()->getId(),
566 $this->getTestType()
567 );
568 $table->init();
569 $table->parse(ilLOSettings::getInstanceByObjId($this->getParentObject()->getId())->getTestByType($this->getTestType()));
570 $GLOBALS['tpl']->setContent($table->getHTML());
571
572 $this->showStatus(
576 );
578 $GLOBALS['ilLog']->write(__METHOD__ . ': Show new assignment screen because of : ' . $ex->getMessage());
579 $this->testSettings();
580 }
581 }
582
586 protected function confirmDeleteTests()
587 {
588 $this->setTestType((int) $_REQUEST['tt']);
589 $this->ctrl->setParameter($this, 'tt', $this->getTestType());
590
592 switch ($this->getTestType()) {
594 $GLOBALS['ilTabs']->activateSubTab('itests');
595 break;
596
598 $GLOBALS['ilTabs']->activateSubTab('qtests');
599 break;
600 }
601
602 if (!(int) $_REQUEST['tst']) {
603 ilUtil::sendFailure($this->lng->txt('select_one'), true);
604 $this->ctrl->redirect($this, 'testsOverview');
605 }
606
607 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
608 $confirm = new ilConfirmationGUI();
609 $confirm->setHeaderText($this->lng->txt('crs_loc_confirm_delete_tst'));
610 $confirm->setFormAction($this->ctrl->getFormAction($this));
611 $confirm->setConfirm($this->lng->txt('crs_loc_delete_assignment'), 'deleteTests');
612 $confirm->setCancel($this->lng->txt('cancel'), 'testsOverview');
613
614 foreach ((array) $_REQUEST['tst'] as $assign_id) {
615 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
616 $assignment = new ilLOTestAssignment($assign_id);
617
618
619 $obj_id = ilObject::_lookupObjId($assignment->getTestRefId());
620 $confirm->addItem('tst[]', $assign_id, ilObject::_lookupTitle($obj_id));
621 }
622
623 $GLOBALS['tpl']->setContent($confirm->getHTML());
624
625 $this->showStatus(
629 );
630 }
631
635 protected function confirmDeleteTest()
636 {
637 $this->setTestType((int) $_REQUEST['tt']);
638 $this->ctrl->setParameter($this, 'tt', $this->getTestType());
639
641 switch ($this->getTestType()) {
643 $GLOBALS['ilTabs']->activateSubTab('itest');
644 break;
645
647 $GLOBALS['ilTabs']->activateSubTab('qtest');
648 break;
649 }
650
651 if (!(int) $_REQUEST['tst']) {
652 ilUtil::sendFailure($this->lng->txt('select_one'), true);
653 $this->ctrl->redirect($this, 'testOverview');
654 }
655
656 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
657 $confirm = new ilConfirmationGUI();
658 $confirm->setHeaderText($this->lng->txt('crs_loc_confirm_delete_tst'));
659 $confirm->setFormAction($this->ctrl->getFormAction($this));
660 $confirm->setConfirm($this->lng->txt('crs_loc_delete_assignment'), 'deleteTest');
661 $confirm->setCancel($this->lng->txt('cancel'), 'testOverview');
662
663 foreach ((array) $_REQUEST['tst'] as $tst_id) {
664 $obj_id = ilObject::_lookupObjId($tst_id);
665 $confirm->addItem('tst[]', $tst_id, ilObject::_lookupTitle($obj_id));
666 }
667
668 $GLOBALS['tpl']->setContent($confirm->getHTML());
669
670 $this->showStatus(
674 );
675 }
676
680 protected function deleteTests()
681 {
682 $this->setTestType((int) $_REQUEST['tt']);
683 $this->ctrl->setParameter($this, 'tt', $this->getTestType());
684
686 switch ($this->getTestType()) {
688 $GLOBALS['ilTabs']->activateSubTab('itests');
689 break;
690
692 $GLOBALS['ilTabs']->activateSubTab('qtests');
693 break;
694 }
695
696 foreach ((array) $_REQUEST['tst'] as $assign_id) {
697 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
698 $assignment = new ilLOTestAssignment($assign_id);
699 $assignment->delete();
700
701 // finally delete start object assignment
702 include_once './Services/Container/classes/class.ilContainerStartObjects.php';
703 $start = new ilContainerStartObjects(
704 $this->getParentObject()->getRefId(),
705 $this->getParentObject()->getId()
706 );
707 $start->deleteItem($assignment->getTestRefId());
708
709 // ... and assigned questions
710 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
711 ilCourseObjectiveQuestion::deleteTest($assignment->getTestRefId());
712 }
713
714
715 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
716 $this->ctrl->redirect($this, 'testsOverview');
717 }
718
722 protected function deleteTest()
723 {
724 $this->setTestType((int) $_REQUEST['tt']);
725 $this->ctrl->setParameter($this, 'tt', $this->getTestType());
726
728 switch ($this->getTestType()) {
730 $GLOBALS['ilTabs']->activateSubTab('itest');
731 break;
732
734 $GLOBALS['ilTabs']->activateSubTab('qtest');
735 break;
736 }
737
738 foreach ((array) $_REQUEST['tst'] as $tst_id) {
739 switch ($this->getTestType()) {
741 $settings->setInitialTest(0);
742 break;
743
745 $settings->setQualifiedTest(0);
746 break;
747 }
748 $settings->update();
749
750 // finally delete start object assignment
751 include_once './Services/Container/classes/class.ilContainerStartObjects.php';
752 $start = new ilContainerStartObjects(
753 $this->getParentObject()->getRefId(),
754 $this->getParentObject()->getId()
755 );
756 $start->deleteItem($tst_id);
757
758 // ... and assigned questions
759 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
761 }
762
763
764 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
765 $this->ctrl->redirect($this, 'testOverview');
766 }
767
771 protected function testAssignment(ilPropertyFormGUI $form = null)
772 {
773 $this->setTestType((int) $_REQUEST['tt']);
774 $this->ctrl->setParameter($this, 'tt', $this->getTestType());
775
776 switch ($this->getTestType()) {
778 $GLOBALS['ilTabs']->activateSubTab('itests');
779 break;
780
782 $GLOBALS['ilTabs']->activateSubTab('qtests');
783 break;
784 }
785 if (!$form instanceof ilPropertyFormGUI) {
786 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php';
787 $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(), $this->getTestType());
788 $form = $form_helper->initForm(true);
789 }
790 $GLOBALS['tpl']->setContent($form->getHTML());
791
792 $this->showStatus(
793 ($this->getTestType() == self::TEST_TYPE_IT) ?
796 );
797 }
798
803 protected function testSettings(ilPropertyFormGUI $form = null)
804 {
805 $this->ctrl->setParameter($this, 'tt', (int) $_REQUEST['tt']);
806 switch ($this->getTestType()) {
808 $GLOBALS['ilTabs']->activateSubTab('itest');
809 break;
810
812 $GLOBALS['ilTabs']->activateSubTab('qtest');
813 break;
814 }
815
816 if (!$form instanceof ilPropertyFormGUI) {
817 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php';
818 $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(), $this->getTestType());
819 $form = $form_helper->initForm(false);
820 }
821 $GLOBALS['tpl']->setContent($form->getHTML());
822
823 $this->showStatus(
824 ($this->getTestType() == self::TEST_TYPE_IT) ?
827 );
828 }
829
834 protected function applySettingsTemplate(ilObjTest $tst)
835 {
836 include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
837 include_once './Modules/Test/classes/class.ilObjAssessmentFolderGUI.php';
838
839 $tpl_id = 0;
840 foreach (ilSettingsTemplate::getAllSettingsTemplates('tst', true) as $nr => $template) {
841 switch ($this->getTestType()) {
843 if ($template['title'] == self::SETTINGS_TEMPLATE_IT) {
844 $tpl_id = $template['id'];
845 }
846 break;
848 if ($template['title'] == self::SETTINGS_TEMPLATE_QT) {
849 $tpl_id = $template['id'];
850 }
851 break;
852 }
853 if ($tpl_id) {
854 break;
855 }
856 }
857
858 if (!$tpl_id) {
859 return false;
860 }
861
862 include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
863 include_once './Modules/Test/classes/class.ilObjAssessmentFolderGUI.php';
865 $template_settings = $template->getSettings();
866 if ($template_settings) {
867 include_once './Modules/Test/classes/class.ilObjTestGUI.php';
868 $tst_gui = new ilObjTestGUI();
869 $tst_gui->applyTemplate($template_settings, $tst);
870 }
871 $tst->setTemplate($tpl_id);
872 return true;
873 }
874
879 protected function updateStartObjects()
880 {
881 include_once './Services/Container/classes/class.ilContainerStartObjects.php';
882 $start = new ilContainerStartObjects(0, $this->getParentObject()->getId());
883 $this->getSettings()->updateStartObjects($start);
884 return true;
885 }
886
887 protected function saveMultiTestAssignment()
888 {
889 $this->ctrl->setParameter($this, 'tt', (int) $_REQUEST['tt']);
890 $this->setTestType((int) $_REQUEST['tt']);
891
893
894 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php';
895 $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(), $this->getTestType());
896 $form = $form_helper->initForm(true);
897
898 if ($form->checkInput()) {
899 $mode = $form->getInput('mode');
900
901 if ($mode == self::TEST_NEW) {
902 $tst = new ilObjTest();
903 $tst->setType('tst');
904 $tst->setTitle($form->getInput('title'));
905 $tst->setDescription($form->getInput('desc'));
906 $tst->create();
907 $tst->createReference();
908 $tst->putInTree($this->getParentObject()->getRefId());
909 $tst->setPermissions($this->getParentObject()->getRefId());
910
911 // apply settings template
912 $this->applySettingsTemplate($tst);
913
914 $tst->setQuestionSetType($form->getInput('qtype'));
915
916 $tst->saveToDb();
917
918 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
919 $assignment = new ilLOTestAssignment();
920 $assignment->setContainerId($this->getParentObject()->getId());
921 $assignment->setAssignmentType($this->getTestType());
922 $assignment->setObjectiveId($form->getInput('objective'));
923 $assignment->setTestRefId($tst->getRefId());
924 $assignment->save();
925 } else {
926 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
927 $assignment = new ilLOTestAssignment();
928 $assignment->setContainerId($this->getParentObject()->getId());
929 $assignment->setAssignmentType($this->getTestType());
930 $assignment->setObjectiveId($form->getInput('objective'));
931 $assignment->setTestRefId($form->getInput('tst'));
932 $assignment->save();
933
934 $tst = new ilObjTest($form->getInput('tst'), true);
935 $this->applySettingsTemplate($tst);
936 $tst->saveToDb();
937 }
938
939 // deassign as objective material
940 if ($tst instanceof ilObjTest) {
941 $this->updateMaterialAssignments($tst);
942 }
943 $this->updateStartObjects();
944
945 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
946 $this->ctrl->redirect($this, 'testsOverview');
947 }
948
949 // Error
950 ilUtil::sendFailure($this->lng->txt('err_check_input'));
951 $form->setValuesByPost();
952 $this->testAssignment($form);
953 }
954
959 {
960 include_once './Modules/Course/classes/class.ilCourseObjective.php';
961 foreach (ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId()) as $objective_id) {
962 include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
963 $materials = new ilCourseObjectiveMaterials($objective_id);
964 foreach ($materials->getMaterials() as $key => $material) {
965 if ($material['ref_id'] == $test->getRefId()) {
966 $materials->delete($material['lm_ass_id']);
967 }
968 }
969 }
970 }
971
975 protected function saveTest()
976 {
977 $this->ctrl->setParameter($this, 'tt', (int) $_REQUEST['tt']);
978 $this->setTestType((int) $_REQUEST['tt']);
979
981
982 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php';
983 $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(), $this->getTestType());
984 $form = $form_helper->initForm(false);
985
986 if ($form->checkInput()) {
987 $mode = $form->getInput('mode');
988
989 if ($mode == self::TEST_NEW) {
990 $tst = new ilObjTest();
991 $tst->setType('tst');
992 $tst->setTitle($form->getInput('title'));
993 $tst->setDescription($form->getInput('desc'));
994 $tst->create();
995 $tst->createReference();
996 $tst->putInTree($this->getParentObject()->getRefId());
997 $tst->setPermissions($this->getParentObject()->getRefId());
998
999 // apply settings template
1000 $this->applySettingsTemplate($tst);
1001
1002 $tst->setQuestionSetType($form->getInput('qtype'));
1003
1004 $tst->saveToDb();
1005
1006 if ($this->getTestType() == self::TEST_TYPE_IT) {
1007 $this->getSettings()->setInitialTest($tst->getRefId());
1008 } else {
1009 $this->getSettings()->setQualifiedTest($tst->getRefId());
1010 }
1011 $this->getSettings()->update();
1012 } else {
1013 if ($this->getTestType() == self::TEST_TYPE_IT) {
1014 $this->getSettings()->setInitialTest($form->getInput('tst'));
1015 } else {
1016 $this->getSettings()->setQualifiedTest($form->getInput('tst'));
1017 }
1018
1019 $this->getSettings()->update();
1020 $tst = new ilObjTest($settings->getTestByType($this->getTestType()), true);
1021 $this->applySettingsTemplate($tst);
1022 $tst->saveToDb();
1023 }
1024
1025 // deassign as objective material
1026 if ($tst instanceof ilObjTest) {
1027 $this->updateMaterialAssignments($tst);
1028 }
1029 $this->updateStartObjects();
1030
1031 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1032 $this->ctrl->redirect($this, 'testOverview');
1033 }
1034
1035 // Error
1036 ilUtil::sendFailure($this->lng->txt('err_check_input'));
1037 $form->setValuesByPost();
1038 $this->testSettings($form);
1039 }
1040
1044 protected function listObjectives()
1045 {
1046 global $ilToolbar;
1047
1048 include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php';
1050
1051
1052 $GLOBALS['ilTabs']->activateSubTab('objectives');
1053
1055 $this->getParentObject()->getId(),
1056 false
1057 );
1058
1059 if (!count($objectives)) {
1060 return $this->showObjectiveCreation();
1061 }
1062
1063 $ilToolbar->addButton(
1064 $this->lng->txt('crs_add_objective'),
1065 $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', "create")
1066 );
1067
1068 include_once('./Modules/Course/classes/class.ilCourseObjectivesTableGUI.php');
1069 $table = new ilCourseObjectivesTableGUI($this, $this->getParentObject());
1070 $table->setTitle($this->lng->txt('crs_objectives'), '', $this->lng->txt('crs_objectives'));
1071 $table->parse($objectives);
1072 $GLOBALS['tpl']->setContent($table->getHTML());
1073
1075 }
1076
1082 {
1083 $GLOBALS['ilTabs']->activateSubTab('objectives');
1084
1085 if (!$form instanceof ilPropertyFormGUI) {
1086 $form = $this->initSimpleObjectiveForm();
1087 }
1088
1089 $GLOBALS['tpl']->setContent($form->getHTML());
1090
1092 }
1093
1097 protected function initSimpleObjectiveForm()
1098 {
1099 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1100 $form = new ilPropertyFormGUI();
1101 $form->setTitle($this->lng->txt('crs_loc_form_create_objectives'));
1102 $form->setFormAction($this->ctrl->getFormAction($this));
1103
1104 $txt = new ilTextWizardInputGUI($this->lng->txt('crs_objectives'), 'objectives');
1105 $txt->setValues(array(0 => ''));
1106 $txt->setRequired(true);
1107 $form->addItem($txt);
1108
1109 $form->addCommandButton('saveObjectiveCreation', $this->lng->txt('save'));
1110
1111 return $form;
1112 }
1113
1114 protected function saveObjectiveCreation()
1115 {
1116 $form = $this->initSimpleObjectiveForm();
1117 if ($form->checkInput()) {
1118 foreach ((array) $form->getInput('objectives') as $idx => $title) {
1119 include_once './Modules/Course/classes/class.ilCourseObjective.php';
1120 $obj = new ilCourseObjective($this->getParentObject());
1121 $obj->setActive(true);
1122 $obj->setTitle($title);
1123 $obj->add();
1124 }
1125 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1126 $this->ctrl->redirect($this, '');
1127 }
1128
1129 $form->setValuesByPost();
1130 $GLOBALS['ilTabs']->activateSubTab('objectives');
1133 }
1134
1141 protected function saveSorting()
1142 {
1143 global $ilAccess,$ilErr,$ilObjDataCache;
1144
1145 asort($_POST['position'], SORT_NUMERIC);
1146
1147 $counter = 1;
1148 foreach ($_POST['position'] as $objective_id => $position) {
1149 include_once './Modules/Course/classes/class.ilCourseObjective.php';
1150 $objective = new ilCourseObjective($this->getParentObject(), $objective_id);
1151 $objective->writePosition($counter++);
1152 }
1153 ilUtil::sendSuccess($this->lng->txt('crs_objective_saved_sorting'));
1154 $this->listObjectives();
1155 }
1156
1160 protected function askDeleteObjectives()
1161 {
1162 $GLOBALS['ilTabs']->activateSubTab('objectives');
1163
1164 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
1165 $confirm = new ilConfirmationGUI();
1166 $confirm->setFormAction($this->ctrl->getFormAction($this));
1167 $confirm->setHeaderText($this->lng->txt('crs_delete_objectve_sure'));
1168 $confirm->setConfirm($this->lng->txt('delete'), 'deleteObjectives');
1169 $confirm->setCancel($this->lng->txt('cancel'), 'listObjectives');
1170
1171 foreach ($_POST['objective'] as $objective_id) {
1172 include_once './Modules/Course/classes/class.ilCourseObjective.php';
1173 $obj = new ilCourseObjective($this->getParentObject(), $objective_id);
1174 $name = $obj->getTitle();
1175
1176 $confirm->addItem(
1177 'objective_ids[]',
1178 $objective_id,
1179 $name
1180 );
1181 }
1182 $GLOBALS['tpl']->setContent($confirm->getHTML());
1184 }
1185
1189 protected function activateObjectives()
1190 {
1191 $enabled = (array) $_REQUEST['objective'];
1192
1193 include_once './Modules/Course/classes/class.ilCourseObjective.php';
1194 $objectives = ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId(), false);
1195 foreach ((array) $objectives as $objective_id) {
1196 $objective = new ilCourseObjective($this->getParentObject(), $objective_id);
1197 if (in_array($objective_id, $enabled)) {
1198 $objective->setActive(true);
1199 $objective->update();
1200 }
1201 }
1202
1203 include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
1205
1206 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1207 $this->ctrl->redirect($this, 'listObjectives');
1208 }
1209
1213 protected function deactivateObjectives()
1214 {
1215 $disabled = (array) $_REQUEST['objective'];
1216
1217 include_once './Modules/Course/classes/class.ilCourseObjective.php';
1218 $objectives = ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId(), false);
1219 foreach ((array) $objectives as $objective_id) {
1220 $objective = new ilCourseObjective($this->getParentObject(), $objective_id);
1221 if (in_array($objective_id, $disabled)) {
1222 $objective->setActive(false);
1223 $objective->update();
1224 }
1225 }
1226
1227 include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
1229
1230 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1231 $this->ctrl->redirect($this, 'listObjectives');
1232 }
1233
1239 protected function deleteObjectives()
1240 {
1241 global $rbacsystem;
1242
1243 foreach ($_POST['objective_ids'] as $objective_id) {
1244 include_once './Modules/Course/classes/class.ilCourseObjective.php';
1245 $objective_obj = new ilCourseObjective($this->getParentObject(), $objective_id);
1246 $objective_obj->delete();
1247 }
1248
1249 include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
1251
1252 ilUtil::sendSuccess($this->lng->txt('crs_objectives_deleted'), true);
1253 $this->ctrl->redirect($this, 'listObjectives');
1254
1255 return true;
1256 }
1257
1261 protected function showStatus($a_section)
1262 {
1263 include_once './Modules/Course/classes/Objectives/class.ilLOEditorStatus.php';
1264 $status = new ilLOEditorStatus($this->getParentObject());
1265 $status->setSection($a_section);
1266 $status->setCmdClass($this);
1267 $GLOBALS['tpl']->setRightContent($status->getHTML());
1268 }
1269
1270
1271
1276 protected function setTabs($a_section = '')
1277 {
1278 // objective settings
1279 $GLOBALS['ilTabs']->addSubTab(
1280 'settings',
1281 $this->lng->txt('settings'),
1282 $this->ctrl->getLinkTarget($this, 'settings')
1283 );
1284 // learning objectives
1285 $GLOBALS['ilTabs']->addSubTab(
1286 'objectives',
1287 $this->lng->txt('crs_loc_tab_objectives'),
1288 $this->ctrl->getLinkTarget($this, 'listObjectives')
1289 );
1290 // materials
1291 /*
1292 $GLOBALS['ilTabs']->addTab(
1293 'materials',
1294 $this->lng->txt('crs_loc_tab_materials'),
1295 $this->ctrl->getLinkTarget($this,'materials')
1296 );
1297 */
1298 // tests
1300 if ($settings->worksWithInitialTest()) {
1301 if (
1302 $settings->getInitialTestType() == ilLOSettings::TYPE_INITIAL_PLACEMENT_ALL ||
1304 ) {
1305 $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_INITIAL);
1306 $GLOBALS['ilTabs']->addSubTab(
1307 'itest',
1308 $this->lng->txt('crs_loc_tab_itest'),
1309 $this->ctrl->getLinkTarget($this, 'testOverview')
1310 );
1311 } else {
1312 $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_INITIAL);
1313 $GLOBALS['ilTabs']->addSubTab(
1314 'itests',
1315 $this->lng->txt('crs_loc_tab_itests'),
1316 $this->ctrl->getLinkTarget($this, 'testsOverview')
1317 );
1318 }
1319 }
1320
1321 if ($settings->getQualifyingTestType() == ilLOSettings::TYPE_QUALIFYING_ALL) {
1322 $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_QUALIFIED);
1323 $GLOBALS['ilTabs']->addSubTab(
1324 'qtest',
1325 $this->lng->txt('crs_loc_tab_qtest'),
1326 $this->ctrl->getLinkTarget($this, 'testOverview')
1327 );
1328 } else {
1329 $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_QUALIFIED);
1330 $GLOBALS['ilTabs']->addSubTab(
1331 'qtests',
1332 $this->lng->txt('crs_loc_tab_qtests'),
1333 $this->ctrl->getLinkTarget($this, 'testsOverview')
1334 );
1335 }
1336
1337 if ($settings->worksWithStartObjects()) {
1338 $GLOBALS['ilTabs']->addSubTab(
1339 'start',
1340 $this->lng->txt('crs_loc_tab_start'),
1341 $this->ctrl->getLinkTargetByClass('ilcontainerstartobjectsgui', '')
1342 );
1343 }
1344
1345 // Member view
1346 #include_once './Services/Container/classes/class.ilMemberViewGUI.php';
1347 #ilMemberViewGUI::showMemberViewSwitch($this->getParentObject()->getRefId());
1348 }
1349}
$test
Definition: Utf8Test.php:84
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
class ilConditionHandlerGUI
Confirmation screen class.
Class ilContainerStartObjectsGUI.
class ilCourseObjectiveMaterials
class ilcourseobjective
static lookupObjectiveTitle($a_objective_id, $a_add_description=false)
static _getObjectiveIds($course_id, $a_activated_only=false)
class ilobjcourseobjectivesgui
Class ilLOEditorGUI.
saveSorting()
save position
testOverview()
Show test overview.
deleteTest()
Delete test assignment.
updateTestAssignments(ilLOSettings $settings)
Update Test assignments.
deleteTests()
Delete test assignments.
updateStartObjects()
Add Test as start object.
askDeleteObjectives()
Confirm delete objectives.
deleteAssignments($a_type)
Delete assignments.
listObjectives()
List all abvailable objectives.
initSimpleObjectiveForm()
Show objective creation form.
testSettings(ilPropertyFormGUI $form=null)
Show test settings.
showStatus($a_section)
Show status panel.
executeCommand()
Execute command.
initSettingsForm()
Init settings form.
showObjectiveCreation(ilPropertyFormGUI $form=null)
Show objective creation form.
confirmDeleteTests()
Show delete test confirmation.
deactivateObjectives()
activate chosen objectives
activateObjectives()
activate chosen objectives
testsOverview()
View test assignments ()
updateMaterialAssignments(ilObjTest $test)
settings(ilPropertyFormGUI $form=null)
Objective Settings.
returnFromObjectives()
Return from objectives.
setTabs($a_section='')
Set tabs.
confirmDeleteTest()
Show delete confirmation screen.
testAssignment(ilPropertyFormGUI $form=null)
new test assignment
__construct($a_parent_obj)
Constructor.
deleteObjectives()
Delete objectives @global type $rbacsystem.
applySettingsTemplate(ilObjTest $tst)
Apply auto generated setttings template.
Presentation of the status of single steps during the configuration process.
static getInstance(ilObject $a_parent)
Get instance.
Class ilLOInvalidConfigurationException.
(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
const HIDE_PASSED_OBJECTIVE_QST
const TYPE_INITIAL_PLACEMENT_ALL
const MARK_PASSED_OBJECTIVE_QST
setInitialTest($a_id)
set initial test id
const TYPE_QUALIFYING_SELECTED
const TYPE_INITIAL_QUALIFYING_SELECTED
static getInstanceByObjId($a_obj_id)
get singleton instance
setQualifiedTest($a_id)
set qualified test
Class ilLOTestAssignmentTableGUI.
Settings for LO courses.
static getInstance($a_container_id)
Get instance by container id.
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
static getLogger($a_component_id)
Get component logger.
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
static getContentStylePath($a_style_id, $add_random=true)
get content style path
Class ilObjTestGUI.
setTemplate($template_id)
Render add new item selector.
Settings for LO courses.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _exists($a_parent_type, $a_id, $a_lang="", $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.
Settings template application class.
static getAllSettingsTemplates($a_type, $a_include_auto_generated=false)
Get all settings templates of type.
This class represents a text wizard property in a property form.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$counter
$template
$key
Definition: croninfo.php:18
$txt
Definition: error.php:11
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18
if($format !==null) $name
Definition: metadata.php:146
$ret
Definition: parser.php:6
if(empty($password)) $table
Definition: pwgen.php:24
global $ilErr
Definition: raiseError.php:16
if(isset($_POST['submit'])) $form
$a_type
Definition: workflow.php:92