ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
31 private $parent_obj;
32 private $settings = NULL;
33 private $lng = NULL;
34 private $ctrl = NULL;
35
36 private $test_type = 0;
37
38
43 public function __construct($a_parent_obj)
44 {
45 $this->parent_obj = $a_parent_obj;
47 $this->lng = $GLOBALS['lng'];
48 $this->ctrl = $GLOBALS['ilCtrl'];
49 }
50
55 public function executeCommand()
56 {
57 global $ilCtrl;
58
59 $next_class = $ilCtrl->getNextClass($this);
60 $cmd = $ilCtrl->getCmd();
61
62 $this->setTabs();
63 switch($next_class)
64 {
65 case 'ilcourseobjectivesgui':
66
67 $this->ctrl->setReturn($this,'listObjectives');
68 $GLOBALS['ilTabs']->clearTargets();
69 $GLOBALS['ilTabs']->setBackTarget(
70 $this->lng->txt('back'),
71 $this->ctrl->getLinkTarget($this,'listObjectives'));
72
73 include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php';
74 $reg_gui =& new ilCourseObjectivesGUI($this->getParentObject()->getRefId());
75 $this->ctrl->forwardCommand($reg_gui);
76 break;
77
78 case 'ilcontainerstartobjectsgui':
79
80 include_once './Services/Container/classes/class.ilContainerStartObjectsGUI.php';
81 $stgui = new ilContainerStartObjectsGUI($this->getParentObject());
82 $ret = $this->ctrl->forwardCommand($stgui);
83
84 $GLOBALS['ilTabs']->activateSubTab('start');
85 $GLOBALS['ilTabs']->removeSubTab('manage');
86
87 #$GLOBALS['tpl']->setContent($this->ctrl->getHTML($stgui));
88 break;
89
90 case 'ilconditionhandlergui':
91
92 $this->ctrl->saveParameterByClass('ilconditionhandlergui','objective_id');
93
94 $GLOBALS['ilTabs']->clearTargets();
95 $GLOBALS['ilTabs']->setBackTarget(
96 $this->lng->txt('back'),
97 $this->ctrl->getLinkTarget($this,'listObjectives'));
98
99 include_once './Services/AccessControl/classes/class.ilConditionHandlerInterface.php';
100 $cond = new ilConditionHandlerGUI($this);
101 $cond->setBackButtons(array());
102 $cond->setAutomaticValidation(false);
103 $cond->setTargetType("lobj");
104 $cond->setTargetRefId($this->getParentObject()->getRefId());
105
106 $cond->setTargetId((int) $_REQUEST['objective_id']);
107
108 // objecitve
109 include_once './Modules/Course/classes/class.ilCourseObjective.php';
110 $obj = new ilCourseObjective($this->getParentObject(),(int) $_REQUEST['objective_id']);
111 $cond->setTargetTitle($obj->getTitle());
112 $this->ctrl->forwardCommand($cond);
113 break;
114
115 case 'illopagegui':
116 $this->ctrl->saveParameterByClass('illopagegui','objective_id');
117
118 $GLOBALS['ilTabs']->clearTargets();
119 $GLOBALS['ilTabs']->setBackTarget(
120 $this->lng->txt('back'),
121 $this->ctrl->getLinkTarget($this,'listObjectives'));
122
123 $objtv_id = (int)$_REQUEST['objective_id'];
124
125 include_once 'Modules/Course/classes/Objectives/class.ilLOPage.php';
126 if(!ilLOPage::_exists('lobj', $objtv_id))
127 {
128 // doesn't exist -> create new one
129 $new_page_object = new ilLOPage();
130 $new_page_object->setParentId($objtv_id);
131 $new_page_object->setId($objtv_id);
132 $new_page_object->createFromXML();
133 unset($new_page_object);
134 }
135
136 $this->ctrl->setReturn($this, 'listObjectives');
137 include_once 'Modules/Course/classes/Objectives/class.ilLOPageGUI.php';
138 $pgui = new ilLOPageGUI($objtv_id);
139 $pgui->setPresentationTitle(ilCourseObjective::lookupObjectiveTitle($objtv_id));
140
141 // needed for editor?
142 include_once('./Services/Style/classes/class.ilObjStyleSheet.php');
143 $pgui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(0));
144
145 // #14895
146 $GLOBALS['tpl']->setCurrentBlock("ContentStyle");
147 $GLOBALS['tpl']->setVariable("LOCATION_CONTENT_STYLESHEET",
149 $GLOBALS['tpl']->parseCurrentBlock();
150
151 $ret = $this->ctrl->forwardCommand($pgui);
152 if($ret)
153 {
154 $GLOBALS['tpl']->setContent($ret);
155 }
156 break;
157
158 default:
159 if(!$cmd)
160 {
161 // get first unaccomplished step
162 include_once './Modules/Course/classes/Objectives/class.ilLOEditorStatus.php';
163 $cmd = ilLOEditorStatus::getInstance($this->getParentObject())->getFirstFailedStep();
164 }
165 $this->$cmd();
166
167 break;
168 }
169 return true;
170 }
171
175 public function getParentObject()
176 {
177 return $this->parent_obj;
178 }
179
184 public function getSettings()
185 {
186 return $this->settings;
187 }
188
189 public function setTestType($a_type)
190 {
191 $this->test_type = $a_type;
192 }
193
194 public function getTestType()
195 {
196 return $this->test_type;
197 }
198
199
203 protected function settings(ilPropertyFormGUI $form = NULL)
204 {
205 if(!$form instanceof ilPropertyFormGUI)
206 {
207 $form = $this->initSettingsForm();
208 }
209
210 $GLOBALS['ilTabs']->activateSubTab('settings');
211 $GLOBALS['tpl']->setContent($form->getHTML());
212
214 }
215
219 protected function saveSettings()
220 {
221 $form = $this->initSettingsForm();
222 if($form->checkInput())
223 {
225 $settings->setType($form->getInput('type'));
226
227 $qtv_values = (array) $form->getInput('qtv');
228 $settings->setGeneralQualifiedTestVisibility(in_array(ilLOSettings::QT_VISIBLE_ALL, $qtv_values));
229 $settings->setQualifiedTestPerObjectiveVisibility(in_array(ilLOSettings::QT_VISIBLE_OBJECTIVE, $qtv_values));
230 $settings->resetResults($form->getInput('reset'));
231 $settings->update();
232
233
234
235 $this->updateStartObjects();
236
237 ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
238 $this->ctrl->redirect($this,'settings');
239 }
240
241 // Error
242 ilUtil::sendFailure($this->lng->txt('err_check_input'));
243 $form->setValuesByPost();
244 $this->settings($form);
245 }
246
247
251 protected function initSettingsForm()
252 {
253 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
254 $form = new ilPropertyFormGUI();
255 $form->setFormAction($this->ctrl->getFormAction($this));
256 $form->setTitle($this->lng->txt('crs_loc_settings_tbl'));
257
258 $type = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_type'), 'type');
259 $type->setRequired(true);
260 $type->setValue(ilLOSettings::getInstanceByObjId($this->getParentObject()->getId())->getType());
261
262 $type_1 = new ilRadioOption($this->lng->txt('crs_loc_type_initial_all'), ilLOSettings::LOC_INITIAL_ALL);
263 $type_1->setInfo($this->lng->txt('crs_loc_type_initial_all_info'));
264 $type->addOption($type_1);
265
266 $type_2 = new ilRadioOption($this->lng->txt('crs_loc_type_initial_sel'), ilLOSettings::LOC_INITIAL_SEL);
267 #$type->addOption($type_2);
268
269 $type_3 = new ilRadioOption($this->lng->txt('crs_loc_type_qualified'), ilLOSettings::LOC_QUALIFIED);
270 $type_3->setInfo($this->lng->txt('crs_loc_type_qualified_info'));
271 $type->addOption($type_3);
272
273 $type_4 = new ilRadioOption($this->lng->txt('crs_loc_type_practise'), ilLOSettings::LOC_PRACTISE);
274 $type_4->setInfo($this->lng->txt('crs_loc_type_practise_info'));
275 $type->addOption($type_4);
276 $form->addItem($type);
277
278 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
279
280 // qualified test visibility
281 $qtv = new ilCheckboxGroupInputGUI($this->lng->txt('crs_loc_qt_visibility'),'qtv');
282
283 $qtv_values = array();
284 if($this->getSettings()->isGeneralQualifiedTestVisible())
285 {
286 $qtv_values[] = ilLOSettings::QT_VISIBLE_ALL;
287 }
288 if($this->getSettings()->isQualifiedTestPerObjectiveVisible())
289 {
291 }
292 $qtv->setValue($qtv_values);
293 $qtv->setRequired(true);
294
295 $qtv->addOption(new ilCheckboxOption(
296 $this->lng->txt('crs_loc_qt_visibility_all'),
298 );
299
300 $qtv->addOption(new ilCheckboxOption(
301 $this->lng->txt('crs_loc_qt_visibility_lo'),
303 );
304 #$form->addItem($qtv);
305
306 // reset results
307 $reset = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_reset'),'reset');
308 $reset->setValue(1);
309 $reset->setChecked($this->getSettings()->isResetResultsEnabled());
310 $reset->setOptionTitle($this->lng->txt('crs_loc_settings_reset_enable'));
311 $reset->setInfo($this->lng->txt('crs_loc_settings_reset_enable_info'));
312 $form->addItem($reset);
313
314
315
316 return $form;
317 }
318
319 protected function materials()
320 {
321 $GLOBALS['ilTabs']->activateSubTab('materials');
322
323 include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php";
324 $gui = new ilObjectAddNewItemGUI($this->getParentObject()->getRefId());
325 $gui->setDisabledObjectTypes(array("itgr"));
326 #$gui->setAfterCreationCallback($this->getParentObject()->getRefId());
327 $gui->render();
328
329 include_once './Services/Object/classes/class.ilObjectTableGUI.php';
330 $obj_table = new ilObjectTableGUI(
331 $this,
332 'materials',
333 $this->getParentObject()->getRefId()
334 );
335 $obj_table->init();
336 $obj_table->setObjects($GLOBALS['tree']->getChildIds($this->getParentObject()->getRefId()));
337 $obj_table->parse();
338 $GLOBALS['tpl']->setContent($obj_table->getHTML());
339
341 }
342
343
347 protected function testOverview()
348 {
349 $this->setTestType((int) $_REQUEST['tt']);
350 $this->ctrl->setParameter($this,'tt',$this->getTestType());
351
353 switch($this->getTestType())
354 {
356 $GLOBALS['ilTabs']->activateSubTab('itest');
357 break;
358
360 $GLOBALS['ilTabs']->activateSubTab('qtest');
361 break;
362 }
363
364
365 // Check if test is assigned
366 if(!$settings->getTestByType($this->getTestType()))
367 {
368 return $this->testSettings();
369 }
370
371 try {
372 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentTableGUI.php';
373 $table = new ilLOTestAssignmentTableGUI(
374 $this,
375 'testOverview',
376 $this->getParentObject()->getId(),
377 $this->getTestType()
378 );
379 $table->setTitle($this->lng->txt('crs_loc_tst_assignment'));
380 $table->init();
381 $table->parse(ilLOSettings::getInstanceByObjId($this->getParentObject()->getId())->getTestByType($this->getTestType()));
382 $GLOBALS['tpl']->setContent($table->getHTML());
383
384 $this->showStatus(
388 );
389 }
391 {
392 $GLOBALS['ilLog']->write(__METHOD__.': Show new assignment sceen because of : '. $ex->getMessage());
393 $this->testSettings();
394 }
395 }
396
400 protected function confirmDeleteTest()
401 {
402 $this->setTestType((int) $_REQUEST['tt']);
403 $this->ctrl->setParameter($this,'tt',$this->getTestType());
404
406 switch($this->getTestType())
407 {
409 $GLOBALS['ilTabs']->activateSubTab('itest');
410 break;
411
413 $GLOBALS['ilTabs']->activateSubTab('qtest');
414 break;
415 }
416
417 if(!(int) $_REQUEST['tst'])
418 {
419 ilUtil::sendFailure($this->lng->txt('select_one'),true);
420 $this->ctrl->redirect($this,'testOverview');
421 }
422
423 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
424 $confirm = new ilConfirmationGUI();
425 $confirm->setHeaderText($this->lng->txt('crs_loc_confirm_delete_tst'));
426 $confirm->setFormAction($this->ctrl->getFormAction($this));
427 $confirm->setConfirm($this->lng->txt('delete'), 'deleteTest');
428 $confirm->setCancel($this->lng->txt('cancel'), 'testOverview');
429
430 foreach((array) $_REQUEST['tst'] as $tst_id)
431 {
432 $obj_id = ilObject::_lookupObjId($tst_id);
433 $confirm->addItem('tst[]', $tst_id, ilObject::_lookupTitle($obj_id));
434 }
435
436 $GLOBALS['tpl']->setContent($confirm->getHTML());
437
438 $this->showStatus(
442 );
443 }
444
448 protected function deleteTest()
449 {
450 $this->setTestType((int) $_REQUEST['tt']);
451 $this->ctrl->setParameter($this,'tt',$this->getTestType());
452
454 switch($this->getTestType())
455 {
457 $GLOBALS['ilTabs']->activateSubTab('itest');
458 break;
459
461 $GLOBALS['ilTabs']->activateSubTab('qtest');
462 break;
463 }
464
465 foreach((array) $_REQUEST['tst'] as $tst_id)
466 {
467 switch($this->getTestType())
468 {
470 $settings->setInitialTest(0);
471 break;
472
474 $settings->setQualifiedTest(0);
475 break;
476 }
477 $settings->update();
478
479 // finally delete start object assignment
480 include_once './Services/Container/classes/class.ilContainerStartObjects.php';
481 $start = new ilContainerStartObjects(
482 $this->getParentObject()->getRefId(),
483 $this->getParentObject()->getId()
484 );
485 $start->deleteItem($tst_id);
486
487 // ... and assigned questions
488 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
490 }
491
492
493 ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
494 $this->ctrl->redirect($this,'testOverview');
495 }
496
501 protected function testSettings(ilPropertyFormGUI $form = NULL)
502 {
503 $this->ctrl->setParameter($this,'tt',(int) $_REQUEST['tt']);
504 switch($this->getTestType())
505 {
507 $GLOBALS['ilTabs']->activateSubTab('itest');
508 break;
509
511 $GLOBALS['ilTabs']->activateSubTab('qtest');
512 break;
513 }
514
515 if(!$form instanceof ilPropertyFormGUI)
516 {
517 $form = $this->initTestForm();
518 }
519 $GLOBALS['tpl']->setContent($form->getHTML());
520
521 $this->showStatus(
522 ($this->getTestType() == self::TEST_TYPE_IT) ?
525 );
526 }
527
531 protected function getAssignableTests()
532 {
533 $tests = array();
534 foreach($GLOBALS['tree']->getChildsByType($this->getParentObject()->getRefId(),'tst') as $tree_node)
535 {
536 if(!in_array($tree_node['child'], $this->getSettings()->getTests()))
537 {
538 $tests[] = $tree_node['child'];
539 }
540 }
541 return $tests;
542 }
543
548 protected function initTestForm()
549 {
550 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
551 $form = new ilPropertyFormGUI();
552 $form->setFormAction($this->ctrl->getFormAction($this));
553 $form->addCommandButton('saveTest', $this->lng->txt('save'));
554
555 switch($this->getTestType())
556 {
558 $form->setTitle($this->lng->txt('crs_loc_settings_itest_tbl'));
559 break;
560
562 $form->setTitle($this->lng->txt('crs_loc_settings_qtest_tbl'));
563 break;
564
565 }
566
567 $assignable = $this->getAssignableTests();
568
569 $cr_mode = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_form_assign_it'),'mode');
570 $cr_mode->setRequired(true);
571 $cr_mode->setValue(self::TEST_NEW);
572
573 $new = new ilRadioOption($this->lng->txt('crs_loc_form_tst_new'),self::TEST_NEW);
574
575 switch($this->getTestType())
576 {
578 $new->setInfo($this->lng->txt("crs_loc_form_tst_new_initial_info"));
579 break;
580
582 $new->setInfo($this->lng->txt("crs_loc_form_tst_new_qualified_info"));
583 break;
584 }
585
586 // title
587 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
588 $ti->setValue(
589 ilObject::_lookupTitle(ilObject::_lookupObjId($this->getSettings()->getTestByType($this->getTestType())))
590 );
591 $ti->setMaxLength(128);
592 $ti->setSize(40);
593 $ti->setRequired(true);
594 $new->addSubItem($ti);
595
596 // description
597 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
598 $ta->setValue(
600 );
601 $ta->setCols(40);
602 $ta->setRows(2);
603 $new->addSubItem($ta);
604
605 // Question assignment type
606 include_once './Modules/Test/classes/class.ilObjTest.php';
607 $this->lng->loadLanguageModule('assessment');
608 $qst = new ilRadioGroupInputGUI($this->lng->txt('tst_question_set_type'),'qtype');
609 $qst->setRequired(true);
610 $qst->setValue(
611 $this->getSettings()->isRandomTestType($this->getTestType()) ?
614 );
615
616 $random = new ilRadioOption(
617 $this->lng->txt('tst_question_set_type_random'),
619 );
620 $qst->addOption($random);
621
622 $fixed = new ilRadioOption(
623 $this->lng->txt('tst_question_set_type_fixed'),
625 );
626 $qst->addOption($fixed);
627 $new->addSubItem($qst);
628 $cr_mode->addOption($new);
629
630 // assign existing
631 $existing = new ilRadioOption($this->lng->txt('crs_loc_form_assign'),self::TEST_ASSIGN);
632
633 switch($this->getTestType())
634 {
636 $existing->setInfo($this->lng->txt("crs_loc_form_assign_initial_info"));
637 break;
638
640 $existing->setInfo($this->lng->txt("crs_loc_form_assign_qualified_info"));
641 break;
642 }
643
644 if(!$assignable)
645 {
646 $existing->setDisabled(true);
647 }
648 $cr_mode->addOption($existing);
649
650 $options = array();
651 $options[0] = $this->lng->txt('select_one');
652 foreach((array) $assignable as $tst_ref_id)
653 {
654 $tst_obj_id = ilObject::_lookupObjId($tst_ref_id);
655 $options[$tst_ref_id] = ilObject::_lookupTitle($tst_obj_id);
656 }
657 $selectable = new ilSelectInputGUI($this->lng->txt('crs_loc_form_available_tsts'),'tst');
658 $selectable->setRequired(true);
659 $selectable->setOptions($options);
660 $existing->addSubItem($selectable);
661
662 $form->addItem($cr_mode);
663 return $form;
664 }
665
670 protected function applySettingsTemplate(ilObjTest $tst)
671 {
672 include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
673 include_once './Modules/Test/classes/class.ilObjAssessmentFolderGUI.php';
674
675 $tpl_id = 0;
676 foreach(ilSettingsTemplate::getAllSettingsTemplates('tst', true) as $nr => $template)
677 {
678 switch($this->getTestType())
679 {
681 if($template['title'] == self::SETTINGS_TEMPLATE_IT)
682 {
683 $tpl_id = $template['id'];
684 }
685 break;
687 if($template['title'] == self::SETTINGS_TEMPLATE_QT)
688 {
689 $tpl_id = $template['id'];
690 }
691 break;
692 }
693 if($tpl_id)
694 {
695 break;
696 }
697 }
698
699 if(!$tpl_id)
700 {
701 return false;
702 }
703
704 include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
705 include_once './Modules/Test/classes/class.ilObjAssessmentFolderGUI.php';
707 $template_settings = $template->getSettings();
708 if($template_settings)
709 {
710 include_once './Modules/Test/classes/class.ilObjTestGUI.php';
711 $tst_gui = new ilObjTestGUI();
712 $tst_gui->applyTemplate($template_settings, $tst);
713 }
714 $tst->setTemplate($tpl_id);
715 return true;
716 }
717
722 protected function updateStartObjects()
723 {
724 include_once './Services/Container/classes/class.ilContainerStartObjects.php';
725 $start = new ilContainerStartObjects(0, $this->getParentObject()->getId());
726 $this->getSettings()->updateStartObjects($start);
727 return true;
728 }
729
733 protected function saveTest()
734 {
735 $this->ctrl->setParameter($this,'tt',(int) $_REQUEST['tt']);
736 $this->setTestType((int) $_REQUEST['tt']);
737
739
740 $form = $this->initTestForm();
741 if($form->checkInput())
742 {
743 $mode = $form->getInput('mode');
744
745 if($mode == self::TEST_NEW)
746 {
747 $tst = new ilObjTest();
748 $tst->setType('tst');
749 $tst->setTitle($form->getInput('title'));
750 $tst->setDescription($form->getInput('desc'));
751 $tst->create();
752 $tst->createReference();
753 $tst->putInTree($this->getParentObject()->getRefId());
754 $tst->setPermissions($this->getParentObject()->getRefId());
755
756 // apply settings template
757 $this->applySettingsTemplate($tst);
758
759 $tst->setQuestionSetType($form->getInput('qtype'));
760
761 $tst->saveToDb();
762
763 if($this->getTestType() == self::TEST_TYPE_IT)
764 {
765 $this->getSettings()->setInitialTest($tst->getRefId());
766 }
767 else
768 {
769 $this->getSettings()->setQualifiedTest($tst->getRefId());
770 }
771 $this->getSettings()->update();
772 }
773 else
774 {
775 if($this->getTestType() == self::TEST_TYPE_IT)
776 {
777 $this->getSettings()->setInitialTest($form->getInput('tst'));
778 }
779 else
780 {
781 $this->getSettings()->setQualifiedTest($form->getInput('tst'));
782 }
783
784 $this->getSettings()->update();
785 $tst = new ilObjTest($settings->getTestByType($this->getTestType()),true);
786 $this->applySettingsTemplate($tst);
787 $tst->saveToDb();
788 }
789
790 $this->updateStartObjects();
791
792 ilUtil::sendSuccess($this->lng->txt('settings_saved'));
793 $this->ctrl->redirect($this,'testOverview');
794 }
795
796 // Error
797 ilUtil::sendFailure($this->lng->txt('err_check_input'));
798 $form->setValuesByPost();
799 $this->testSettings($form);
800 }
801
805 protected function listObjectives()
806 {
807 global $ilToolbar;
808
809 $GLOBALS['ilTabs']->activateSubTab('objectives');
810
811 $ilToolbar->addButton(
812 $this->lng->txt('crs_add_objective'),
813 $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', "create"));
814
815 include_once('./Modules/Course/classes/class.ilCourseObjectivesTableGUI.php');
816 $table = new ilCourseObjectivesTableGUI($this,$this->getParentObject());
817 $table->setTitle($this->lng->txt('crs_objectives'),'',$this->lng->txt('crs_objectives'));
818 $table->parse(ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId(),false));
819 $GLOBALS['tpl']->setContent($table->getHTML());
820
822 }
823
828 protected function showObjectiveCreation(ilPropertyFormGUI $form = NULL)
829 {
830 $GLOBALS['ilTabs']->activateSubTab('objectives');
831
832 if(!$form instanceof ilPropertyFormGUI)
833 {
834 $form = $this->initSimpleObjectiveForm();
835 }
836
837 $GLOBALS['tpl']->setContent($form->getHTML());
838
840 }
841
845 protected function initSimpleObjectiveForm()
846 {
847 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
848 $form = new ilPropertyFormGUI();
849 $form->setTitle($this->lng->txt('crs_loc_form_create_objectives'));
850 $form->setFormAction($this->ctrl->getFormAction($this));
851
852 $txt = new ilTextWizardInputGUI($this->lng->txt('crs_objectives'), 'objectives');
853 $txt->setValues(array(0 => ''));
854 $txt->setRequired(true);
855 $form->addItem($txt);
856
857 $form->addCommandButton('saveObjectiveCreation', $this->lng->txt('save'));
858
859 return $form;
860 }
861
862 protected function saveObjectiveCreation()
863 {
864 $form = $this->initSimpleObjectiveForm();
865 if($form->checkInput())
866 {
867 foreach((array) $form->getInput('objectives') as $idx => $title)
868 {
869 include_once './Modules/Course/classes/class.ilCourseObjective.php';
870 $obj = new ilCourseObjective($this->getParentObject());
871 $obj->setActive(false);
872 $obj->setTitle($title);
873 $obj->add();
874 }
875 ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
876 $this->ctrl->redirect($this,'');
877 }
878
879 $form->setValuesByPost();
880 $GLOBALS['ilTabs']->activateSubTab('objectives');
882 }
883
890 protected function saveSorting()
891 {
892 global $ilAccess,$ilErr,$ilObjDataCache;
893
894 asort($_POST['position'],SORT_NUMERIC);
895
896 $counter = 1;
897 foreach($_POST['position'] as $objective_id => $position)
898 {
899 include_once './Modules/Course/classes/class.ilCourseObjective.php';
900 $objective = new ilCourseObjective($this->getParentObject(),$objective_id);
901 $objective->writePosition($counter++);
902 }
903 ilUtil::sendSuccess($this->lng->txt('crs_objective_saved_sorting'));
904 $this->listObjectives();
905 }
906
910 protected function askDeleteObjectives()
911 {
912 $GLOBALS['ilTabs']->activateSubTab('objectives');
913
914 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
915 $confirm = new ilConfirmationGUI();
916 $confirm->setFormAction($this->ctrl->getFormAction($this));
917 $confirm->setHeaderText($this->lng->txt('crs_delete_objectve_sure'));
918 $confirm->setConfirm($this->lng->txt('delete'), 'deleteObjectives');
919 $confirm->setCancel($this->lng->txt('cancel'), 'listObjectives');
920
921 foreach($_POST['objective'] as $objective_id)
922 {
923 include_once './Modules/Course/classes/class.ilCourseObjective.php';
924 $obj = new ilCourseObjective($this->getParentObject(),$objective_id);
925 $name = $obj->getTitle();
926
927 $confirm->addItem(
928 'objective_ids[]',
929 $objective_id,
930 $name
931 );
932 }
933 $GLOBALS['tpl']->setContent($confirm->getHTML());
935 }
936
940 protected function activateObjectives()
941 {
942 $enabled = (array) $_REQUEST['objective'];
943
944 include_once './Modules/Course/classes/class.ilCourseObjective.php';
945 $objectives = ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId(),false);
946 foreach((array) $objectives as $objective_id)
947 {
948 $objective = new ilCourseObjective($this->getParentObject(),$objective_id);
949 if(in_array($objective_id, $enabled))
950 {
951 $objective->setActive(true);
952 $objective->update();
953 }
954 }
955
956 include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
958
959 ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
960 $this->ctrl->redirect($this,'listObjectives');
961 }
962
966 protected function deactivateObjectives()
967 {
968 $disabled = (array) $_REQUEST['objective'];
969
970 include_once './Modules/Course/classes/class.ilCourseObjective.php';
971 $objectives = ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId(),false);
972 foreach((array) $objectives as $objective_id)
973 {
974 $objective = new ilCourseObjective($this->getParentObject(),$objective_id);
975 if(in_array($objective_id, $disabled))
976 {
977 $objective->setActive(false);
978 $objective->update();
979 }
980 }
981
982 include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
984
985 ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
986 $this->ctrl->redirect($this,'listObjectives');
987 }
988
994 protected function deleteObjectives()
995 {
996 global $rbacsystem;
997
998 foreach($_POST['objective_ids'] as $objective_id)
999 {
1000 include_once './Modules/Course/classes/class.ilCourseObjective.php';
1001 $objective_obj = new ilCourseObjective($this->getParentObject(),$objective_id);
1002 $objective_obj->delete();
1003 }
1004
1005 include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
1007
1008 ilUtil::sendSuccess($this->lng->txt('crs_objectives_deleted'),true);
1009 $this->ctrl->redirect($this,'listObjectives');
1010
1011 return true;
1012 }
1013
1017 protected function showStatus($a_section)
1018 {
1019 include_once './Modules/Course/classes/Objectives/class.ilLOEditorStatus.php';
1020 $status = new ilLOEditorStatus($this->getParentObject());
1021 $status->setSection($a_section);
1022 $status->setCmdClass($this);
1023 $GLOBALS['tpl']->setRightContent($status->getHTML());
1024 }
1025
1026
1027
1032 protected function setTabs($a_section = '')
1033 {
1034 // objective settings
1035 $GLOBALS['ilTabs']->addSubTab(
1036 'settings',
1037 $this->lng->txt('settings'),
1038 $this->ctrl->getLinkTarget($this,'settings')
1039 );
1040 // learning objectives
1041 $GLOBALS['ilTabs']->addSubTab(
1042 'objectives',
1043 $this->lng->txt('crs_loc_tab_objectives'),
1044 $this->ctrl->getLinkTarget($this,'listObjectives')
1045 );
1046 // materials
1047 /*
1048 $GLOBALS['ilTabs']->addTab(
1049 'materials',
1050 $this->lng->txt('crs_loc_tab_materials'),
1051 $this->ctrl->getLinkTarget($this,'materials')
1052 );
1053 */
1054 // tests
1056 if($settings->worksWithInitialTest())
1057 {
1058 $this->ctrl->setParameter($this,'tt',self::TEST_TYPE_IT);
1059 $GLOBALS['ilTabs']->addSubTab(
1060 'itest',
1061 $this->lng->txt('crs_loc_tab_itest'),
1062 $this->ctrl->getLinkTarget($this,'testOverview')
1063 );
1064
1065 }
1066 $this->ctrl->setParameter($this,'tt',self::TEST_TYPE_QT);
1067 $GLOBALS['ilTabs']->addSubTab(
1068 'qtest',
1069 $this->lng->txt('crs_loc_tab_qtest'),
1070 $this->ctrl->getLinkTarget($this,'testOverview')
1071 );
1072 // start objects
1073 $GLOBALS['ilTabs']->addSubTab(
1074 'start',
1075 $this->lng->txt('crs_loc_tab_start'),
1076 $this->ctrl->getLinkTargetByClass('ilcontainerstartobjectsgui','')
1077 );
1078
1079 // Member view
1080 #include_once './Services/Container/classes/class.ilMemberViewGUI.php';
1081 #ilMemberViewGUI::showMemberViewSwitch($this->getParentObject()->getRefId());
1082 }
1083}
1084?>
This class represents a property in a property form.
This class represents a checkbox property in a property form.
This class represents an option in a checkbox group.
class ilConditionHandlerGUI
Confirmation screen class.
Class ilContainerStartObjectsGUI.
class ilcourseobjective
static lookupObjectiveTitle($a_objective_id)
static _getObjectiveIds($course_id, $a_activated_only=false)
class ilobjcourseobjectivesgui
Class ilLOEditorGUI.
saveSorting()
save position
testOverview()
Show test overview.
deleteTest()
Delete test assignment.
updateStartObjects()
Add Test as start object.
askDeleteObjectives()
Confirm delete objectives.
listObjectives()
List all abvailable objectives.
getAssignableTests()
Get assignable tests.
initSimpleObjectiveForm()
Show objective creation form.
showStatus($a_section)
Show status panel.
executeCommand()
Execute command.
initSettingsForm()
Init settings form.
deactivateObjectives()
activate chosen objectives
activateObjectives()
activate chosen objectives
initTestForm()
Show test config form.
settings(ilPropertyFormGUI $form=NULL)
Objective Settings.
setTabs($a_section='')
Set tabs.
showObjectiveCreation(ilPropertyFormGUI $form=NULL)
Show objective creation form.
confirmDeleteTest()
Show delete confirmation screen.
testSettings(ilPropertyFormGUI $form=NULL)
Show test settings.
__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
static getInstanceByObjId($a_obj_id)
get singleton instance
Class ilLOTestAssignmentTableGUI.
_refreshStatus($a_obj_id, $a_users=null)
Set dirty.
getContentStylePath($a_style_id)
get content style path
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
Class ilObjTestGUI.
setTemplate($template_id)
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
const QUESTION_SET_TYPE_FIXED
type setting value for fixed question set
Render add new item selector.
Settings for LO courses.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _lookupDescription($a_id)
lookup object description
static _exists($a_parent_type, $a_id, $a_lang="")
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.
This class represents a selection list property in a property form.
Settings template application class.
static getAllSettingsTemplates($a_type, $a_include_auto_generated=false)
Get all settings templates of type.
This class represents a text area property in a property form.
This class represents a text property in a property form.
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.
$_POST['username']
Definition: cron.php:12
$txt
Definition: error.php:10
$GLOBALS['ct_recipient']
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
if(!is_array($argv)) $options