ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
5 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
6 include_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;
52  $this->settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId());
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  {
73  case 'ilcourseobjectivesgui':
74 
75  $this->ctrl->setReturn($this,'returnFromObjectives');
76  $GLOBALS['ilTabs']->clearTargets();
77  $GLOBALS['ilTabs']->setBackTarget(
78  $this->lng->txt('back'),
79  $this->ctrl->getLinkTarget($this,'listObjectives'));
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  include_once './Services/AccessControl/classes/class.ilConditionHandlerInterface.php';
108  $cond = new ilConditionHandlerGUI($this);
109  $cond->setBackButtons(array());
110  $cond->setAutomaticValidation(false);
111  $cond->setTargetType("lobj");
112  $cond->setTargetRefId($this->getParentObject()->getRefId());
113 
114  $cond->setTargetId((int) $_REQUEST['objective_id']);
115 
116  // objecitve
117  include_once './Modules/Course/classes/class.ilCourseObjective.php';
118  $obj = new ilCourseObjective($this->getParentObject(),(int) $_REQUEST['objective_id']);
119  $cond->setTargetTitle($obj->getTitle());
120  $this->ctrl->forwardCommand($cond);
121  break;
122 
123  case 'illopagegui':
124  $this->ctrl->saveParameterByClass('illopagegui','objective_id');
125 
126  $GLOBALS['ilTabs']->clearTargets();
127  $GLOBALS['ilTabs']->setBackTarget(
128  $this->lng->txt('back'),
129  $this->ctrl->getLinkTarget($this,'listObjectives'));
130 
131  $objtv_id = (int)$_REQUEST['objective_id'];
132 
133  include_once 'Modules/Course/classes/Objectives/class.ilLOPage.php';
134  if(!ilLOPage::_exists('lobj', $objtv_id))
135  {
136  // doesn't exist -> create new one
137  $new_page_object = new ilLOPage();
138  $new_page_object->setParentId($objtv_id);
139  $new_page_object->setId($objtv_id);
140  $new_page_object->createFromXML();
141  unset($new_page_object);
142  }
143 
144  $this->ctrl->setReturn($this, 'listObjectives');
145  include_once 'Modules/Course/classes/Objectives/class.ilLOPageGUI.php';
146  $pgui = new ilLOPageGUI($objtv_id);
147  $pgui->setPresentationTitle(ilCourseObjective::lookupObjectiveTitle($objtv_id));
148 
149  include_once('./Services/Style/Content/classes/class.ilObjStyleSheet.php');
151  $this->parent_obj->getStyleSheetId(), $this->parent_obj->getType()));
152 
153  // #14895
154  $GLOBALS['tpl']->setCurrentBlock("ContentStyle");
155  $GLOBALS['tpl']->setVariable("LOCATION_CONTENT_STYLESHEET",
157  $this->parent_obj->getStyleSheetId(), $this->parent_obj->getType())));
158  $GLOBALS['tpl']->parseCurrentBlock();
159 
160  $ret = $this->ctrl->forwardCommand($pgui);
161  if($ret)
162  {
163  $GLOBALS['tpl']->setContent($ret);
164  }
165  break;
166 
167  default:
168  if(!$cmd)
169  {
170  // get first unaccomplished step
171  include_once './Modules/Course/classes/Objectives/class.ilLOEditorStatus.php';
172  $cmd = ilLOEditorStatus::getInstance($this->getParentObject())->getFirstFailedStep();
173  }
174  $this->$cmd();
175 
176  break;
177  }
178  return true;
179  }
180 
185  protected function returnFromObjectives()
186  {
187  include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php';
189  return $this->listObjectives();
190  }
191 
195  public function getParentObject()
196  {
197  return $this->parent_obj;
198  }
199 
204  public function getSettings()
205  {
206  return $this->settings;
207  }
208 
209  public function setTestType($a_type)
210  {
211  $this->test_type = $a_type;
212  }
213 
214  public function getTestType()
215  {
216  return $this->test_type;
217  }
218 
219 
223  protected function settings(ilPropertyFormGUI $form = NULL)
224  {
225  if(!$form instanceof ilPropertyFormGUI)
226  {
227  $form = $this->initSettingsForm();
228  }
229 
230  $GLOBALS['ilTabs']->activateSubTab('settings');
231  $GLOBALS['tpl']->setContent($form->getHTML());
232 
234  }
235 
240  protected function deleteAssignments($a_type)
241  {
242 
243 
244  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
245  $assignments = ilLOTestAssignments::getInstance($this->getParentObject()->getId());
246  foreach($assignments->getAssignmentsByType($a_type) as $assignment)
247  {
248  $assignment->delete();
249  }
250  return;
251  }
252 
258  {
259  switch($settings->getInitialTestType())
260  {
262  $settings->setInitialTest(0);
264 
268 
269  break;
270 
273  $settings->setInitialTest(0);
274  break;
275  }
276 
277  switch($settings->getQualifyingTestType())
278  {
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())
298  {
300  $settings->setInitialTestType($form->getInput('ittype'));
301  switch($settings->getInitialTestType())
302  {
304  $settings->setInitialTestAsStart($form->getInput('start_ip'));
305  break;
306 
308  $settings->setInitialTestAsStart(FALSE);
309  break;
310 
312  $settings->setInitialTestAsStart($form->getInput('start_iq'));
313  break;
314 
316  $settings->setInitialTestAsStart(FALSE);
317  break;
318 
320  $settings->setInitialTestAsStart(FALSE);
321  break;
322  }
323 
324  $settings->setQualifyingTestType($form->getInput('qttype'));
325  switch($settings->getQualifyingTestType())
326  {
328  $settings->setQualifyingTestAsStart($form->getInput('start_q'));
329  break;
330 
332  $settings->setQualifyingTestAsStart(false);
333  break;
334  }
335 
336 
337  $settings->resetResults($form->getInput('reset'));
338  $settings->setPassedObjectiveMode($form->getInput('passed_mode'));
339 
340  if(
341  ($settings->getInitialTestType() != ilLOSettings::TYPE_INITIAL_NONE) &&
342  ($settings->isQualifyingTestStart())
343  )
344  {
345  $settings->setQualifyingTestAsStart(FALSE);
346  ilUtil::sendInfo($this->lng->txt('crs_loc_settings_err_qstart'),TRUE);
347  }
348 
349  $settings->update();
350  $this->updateStartObjects();
352 
353  include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
355 
356  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
357  $this->ctrl->redirect($this,'settings');
358  }
359 
360  // Error
361  ilUtil::sendFailure($this->lng->txt('err_check_input'));
362  $form->setValuesByPost();
363  $this->settings($form);
364  }
365 
369  protected function initSettingsForm()
370  {
371  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
372  $form = new ilPropertyFormGUI();
373  $form->setFormAction($this->ctrl->getFormAction($this));
374  $form->setTitle($this->lng->txt('crs_loc_settings_tbl'));
375 
376  // initial test
377  $type_selector = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_it_type'), 'ittype');
378  $type_selector->setRequired(TRUE);
379  $type_selector->setValue($this->getSettings()->getInitialTestType());
380 
381  $type_ipa = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_placement_all'), ilLOSettings::TYPE_INITIAL_PLACEMENT_ALL);
382  $type_ipa->setInfo($this->lng->txt('crs_loc_settings_type_it_placement_all_info'));
383  $type_selector->addOption($type_ipa);
384 
385  $start_ip = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_it_start_object'),'start_ip');
386  $start_ip->setValue(1);
387  $start_ip->setChecked($this->getSettings()->isInitialTestStart());
388  $type_ipa->addSubItem($start_ip);
389 
390  $type_ips = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_placement_sel'), ilLOSettings::TYPE_INITIAL_PLACEMENT_SELECTED);
391  $type_ips->setInfo($this->lng->txt('crs_loc_settings_type_it_placement_sel_info'));
392  $type_selector->addOption($type_ips);
393 
394  $type_iqa = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_qualifying_all'), ilLOSettings::TYPE_INITIAL_QUALIFYING_ALL);
395  $type_iqa->setInfo($this->lng->txt('crs_loc_settings_type_it_qualifying_all_info'));
396  $type_selector->addOption($type_iqa);
397 
398  $start_iq = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_it_start_object'),'start_iq');
399  $start_iq->setValue(1);
400  $start_iq->setChecked($this->getSettings()->isInitialTestStart());
401  $type_iqa->addSubItem($start_iq);
402 
403  $type_iqs = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_qualifying_sel'), ilLOSettings::TYPE_INITIAL_QUALIFYING_SELECTED);
404  $type_iqs->setInfo($this->lng->txt('crs_loc_settings_type_it_qualifying_sel_info'));
405  $type_selector->addOption($type_iqs);
406 
407  $type_ino = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_none'), ilLOSettings::TYPE_INITIAL_NONE);
408  $type_ino->setInfo($this->lng->txt('crs_loc_settings_type_it_none_info'));
409  $type_selector->addOption($type_ino);
410 
411  $form->addItem($type_selector);
412 
413  // qualifying test
414  $qt_selector = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_qt_all'),'qttype');
415  $qt_selector->setRequired(TRUE);
416  $qt_selector->setValue($this->getSettings()->getQualifyingTestType());
417 
418  $type_qa = new ilRadioOption($this->lng->txt('crs_loc_settings_type_q_all'), ilLOSettings::TYPE_QUALIFYING_ALL);
419  $type_qa->setInfo($this->lng->txt('crs_loc_settings_type_q_all_info'));
420  $qt_selector->addOption($type_qa);
421 
422  $start_q = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_qt_start_object'),'start_q');
423  $start_q->setValue(1);
424  $start_q->setChecked($this->getSettings()->isQualifyingTestStart());
425  $type_qa->addSubItem($start_q);
426 
427  $passed_mode = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_passed_mode'),'passed_mode');
428  $passed_mode->setValue($this->getSettings()->getPassedObjectiveMode());
429 
430  $passed_mode->addOption(
431  new ilRadioOption(
432  $this->lng->txt('crs_loc_settings_passed_mode_hide'),
434  );
435  $passed_mode->addOption(
436  new ilRadioOption(
437  $this->lng->txt('crs_loc_settings_passed_mode_mark'),
439  );
440  $type_qa->addSubItem($passed_mode);
441 
442  $type_qs = new ilRadioOption($this->lng->txt('crs_loc_settings_type_q_selected'), ilLOSettings::TYPE_QUALIFYING_SELECTED);
443  $type_qs->setInfo($this->lng->txt('crs_loc_settings_type_q_selected_info'));
444  $qt_selector->addOption($type_qs);
445 
446  $form->addItem($qt_selector);
447 
448  // reset results
449  $reset = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_reset'),'reset');
450  $reset->setValue(1);
451  $reset->setChecked($this->getSettings()->isResetResultsEnabled());
452  $reset->setOptionTitle($this->lng->txt('crs_loc_settings_reset_enable'));
453  $reset->setInfo($this->lng->txt('crs_loc_settings_reset_enable_info'));
454  $form->addItem($reset);
455 
456  $form->addCommandButton('saveSettings', $this->lng->txt('save'));
457 
458 
459  return $form;
460  }
461 
462  protected function materials()
463  {
464  $GLOBALS['ilTabs']->activateSubTab('materials');
465 
466  include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php";
467  $gui = new ilObjectAddNewItemGUI($this->getParentObject()->getRefId());
468  $gui->setDisabledObjectTypes(array("itgr"));
469  #$gui->setAfterCreationCallback($this->getParentObject()->getRefId());
470  $gui->render();
471 
472  include_once './Services/Object/classes/class.ilObjectTableGUI.php';
473  $obj_table = new ilObjectTableGUI(
474  $this,
475  'materials',
476  $this->getParentObject()->getRefId()
477  );
478  $obj_table->init();
479  $obj_table->setObjects($GLOBALS['tree']->getChildIds($this->getParentObject()->getRefId()));
480  $obj_table->parse();
481  $GLOBALS['tpl']->setContent($obj_table->getHTML());
482 
484  }
485 
489  protected function testsOverview()
490  {
491  $this->setTestType((int) $_REQUEST['tt']);
492  $this->ctrl->setParameter($this,'tt',$this->getTestType());
493 
494  $GLOBALS['ilToolbar']->setFormAction($this->ctrl->getFormAction($this));
495  $GLOBALS['ilToolbar']->addButton(
496  $this->lng->txt('crs_loc_btn_new_assignment'),
497  $this->ctrl->getLinkTarget($this,'testAssignment')
498  );
499 
500 
502  switch($this->getTestType())
503  {
505  $GLOBALS['ilTabs']->activateSubTab('itests');
506  break;
507 
509  $GLOBALS['ilTabs']->activateSubTab('qtests');
510  break;
511  }
512 
513  try {
514  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentTableGUI.php';
515  $table = new ilLOTestAssignmentTableGUI(
516  $this,
517  'testsOverview',
518  $this->getParentObject()->getId(),
519  $this->getTestType(),
521  );
522  $table->init();
523  $table->parseMultipleAssignments();
524  $GLOBALS['tpl']->setContent($table->getHTML());
525 
526  $this->showStatus(
530  );
531  }
533  {
534  $GLOBALS['ilLog']->write(__METHOD__.': Show new assignment screen because of : '. $ex->getMessage());
535  $this->testSettings();
536  }
537 
538 
539 
540  }
541 
542 
546  protected function testOverview()
547  {
548  $this->setTestType((int) $_REQUEST['tt']);
549  $this->ctrl->setParameter($this,'tt',$this->getTestType());
550 
552  switch($this->getTestType())
553  {
555  $GLOBALS['ilTabs']->activateSubTab('itest');
556  break;
557 
559  $GLOBALS['ilTabs']->activateSubTab('qtest');
560  break;
561  }
562 
563 
564  // Check if test is assigned
565  if(!$settings->getTestByType($this->getTestType()))
566  {
567  return $this->testSettings();
568  }
569 
570  try {
571  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentTableGUI.php';
572  $table = new ilLOTestAssignmentTableGUI(
573  $this,
574  'testOverview',
575  $this->getParentObject()->getId(),
576  $this->getTestType()
577  );
578  $table->init();
579  $table->parse(ilLOSettings::getInstanceByObjId($this->getParentObject()->getId())->getTestByType($this->getTestType()));
580  $GLOBALS['tpl']->setContent($table->getHTML());
581 
582  $this->showStatus(
586  );
587  }
589  {
590  $GLOBALS['ilLog']->write(__METHOD__.': Show new assignment screen because of : '. $ex->getMessage());
591  $this->testSettings();
592  }
593  }
594 
598  protected function confirmDeleteTests()
599  {
600  $this->setTestType((int) $_REQUEST['tt']);
601  $this->ctrl->setParameter($this,'tt',$this->getTestType());
602 
604  switch($this->getTestType())
605  {
607  $GLOBALS['ilTabs']->activateSubTab('itests');
608  break;
609 
611  $GLOBALS['ilTabs']->activateSubTab('qtests');
612  break;
613  }
614 
615  if(!(int) $_REQUEST['tst'])
616  {
617  ilUtil::sendFailure($this->lng->txt('select_one'),true);
618  $this->ctrl->redirect($this,'testsOverview');
619  }
620 
621  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
622  $confirm = new ilConfirmationGUI();
623  $confirm->setHeaderText($this->lng->txt('crs_loc_confirm_delete_tst'));
624  $confirm->setFormAction($this->ctrl->getFormAction($this));
625  $confirm->setConfirm($this->lng->txt('crs_loc_delete_assignment'), 'deleteTests');
626  $confirm->setCancel($this->lng->txt('cancel'), 'testsOverview');
627 
628  foreach((array) $_REQUEST['tst'] as $assign_id)
629  {
630  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
631  $assignment = new ilLOTestAssignment($assign_id);
632 
633 
634  $obj_id = ilObject::_lookupObjId($assignment->getTestRefId());
635  $confirm->addItem('tst[]', $assign_id, ilObject::_lookupTitle($obj_id));
636  }
637 
638  $GLOBALS['tpl']->setContent($confirm->getHTML());
639 
640  $this->showStatus(
644  );
645  }
646 
650  protected function confirmDeleteTest()
651  {
652  $this->setTestType((int) $_REQUEST['tt']);
653  $this->ctrl->setParameter($this,'tt',$this->getTestType());
654 
656  switch($this->getTestType())
657  {
659  $GLOBALS['ilTabs']->activateSubTab('itest');
660  break;
661 
663  $GLOBALS['ilTabs']->activateSubTab('qtest');
664  break;
665  }
666 
667  if(!(int) $_REQUEST['tst'])
668  {
669  ilUtil::sendFailure($this->lng->txt('select_one'),true);
670  $this->ctrl->redirect($this,'testOverview');
671  }
672 
673  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
674  $confirm = new ilConfirmationGUI();
675  $confirm->setHeaderText($this->lng->txt('crs_loc_confirm_delete_tst'));
676  $confirm->setFormAction($this->ctrl->getFormAction($this));
677  $confirm->setConfirm($this->lng->txt('crs_loc_delete_assignment'), 'deleteTest');
678  $confirm->setCancel($this->lng->txt('cancel'), 'testOverview');
679 
680  foreach((array) $_REQUEST['tst'] as $tst_id)
681  {
682  $obj_id = ilObject::_lookupObjId($tst_id);
683  $confirm->addItem('tst[]', $tst_id, ilObject::_lookupTitle($obj_id));
684  }
685 
686  $GLOBALS['tpl']->setContent($confirm->getHTML());
687 
688  $this->showStatus(
692  );
693  }
694 
698  protected function deleteTests()
699  {
700  $this->setTestType((int) $_REQUEST['tt']);
701  $this->ctrl->setParameter($this,'tt',$this->getTestType());
702 
704  switch($this->getTestType())
705  {
707  $GLOBALS['ilTabs']->activateSubTab('itests');
708  break;
709 
711  $GLOBALS['ilTabs']->activateSubTab('qtests');
712  break;
713  }
714 
715  foreach((array) $_REQUEST['tst'] as $assign_id)
716  {
717  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
718  $assignment = new ilLOTestAssignment($assign_id);
719  $assignment->delete();
720 
721  // finally delete start object assignment
722  include_once './Services/Container/classes/class.ilContainerStartObjects.php';
724  $this->getParentObject()->getRefId(),
725  $this->getParentObject()->getId()
726  );
727  $start->deleteItem($assignment->getTestRefId());
728 
729  // ... and assigned questions
730  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
731  ilCourseObjectiveQuestion::deleteTest($assignment->getTestRefId());
732  }
733 
734 
735  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
736  $this->ctrl->redirect($this,'testsOverview');
737  }
738 
742  protected function deleteTest()
743  {
744  $this->setTestType((int) $_REQUEST['tt']);
745  $this->ctrl->setParameter($this,'tt',$this->getTestType());
746 
748  switch($this->getTestType())
749  {
751  $GLOBALS['ilTabs']->activateSubTab('itest');
752  break;
753 
755  $GLOBALS['ilTabs']->activateSubTab('qtest');
756  break;
757  }
758 
759  foreach((array) $_REQUEST['tst'] as $tst_id)
760  {
761  switch($this->getTestType())
762  {
764  $settings->setInitialTest(0);
765  break;
766 
768  $settings->setQualifiedTest(0);
769  break;
770  }
771  $settings->update();
772 
773  // finally delete start object assignment
774  include_once './Services/Container/classes/class.ilContainerStartObjects.php';
776  $this->getParentObject()->getRefId(),
777  $this->getParentObject()->getId()
778  );
779  $start->deleteItem($tst_id);
780 
781  // ... and assigned questions
782  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
784  }
785 
786 
787  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
788  $this->ctrl->redirect($this,'testOverview');
789  }
790 
794  protected function testAssignment(ilPropertyFormGUI $form = null)
795  {
796  $this->setTestType((int) $_REQUEST['tt']);
797  $this->ctrl->setParameter($this,'tt',$this->getTestType());
798 
799  switch($this->getTestType())
800  {
802  $GLOBALS['ilTabs']->activateSubTab('itests');
803  break;
804 
806  $GLOBALS['ilTabs']->activateSubTab('qtests');
807  break;
808  }
809  if(!$form instanceof ilPropertyFormGUI)
810  {
811  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php';
812  $form_helper = new ilLOTestAssignmentForm($this,$this->getParentObject(), $this->getTestType());
813  $form = $form_helper->initForm(TRUE);
814  }
815  $GLOBALS['tpl']->setContent($form->getHTML());
816 
817  $this->showStatus(
818  ($this->getTestType() == self::TEST_TYPE_IT) ?
821  );
822  }
823 
828  protected function testSettings(ilPropertyFormGUI $form = NULL)
829  {
830  $this->ctrl->setParameter($this,'tt',(int) $_REQUEST['tt']);
831  switch($this->getTestType())
832  {
834  $GLOBALS['ilTabs']->activateSubTab('itest');
835  break;
836 
838  $GLOBALS['ilTabs']->activateSubTab('qtest');
839  break;
840  }
841 
842  if(!$form instanceof ilPropertyFormGUI)
843  {
844  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php';
845  $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(),$this->getTestType());
846  $form = $form_helper->initForm(FALSE);
847  }
848  $GLOBALS['tpl']->setContent($form->getHTML());
849 
850  $this->showStatus(
851  ($this->getTestType() == self::TEST_TYPE_IT) ?
854  );
855  }
856 
861  protected function applySettingsTemplate(ilObjTest $tst)
862  {
863  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
864  include_once './Modules/Test/classes/class.ilObjAssessmentFolderGUI.php';
865 
866  $tpl_id = 0;
867  foreach(ilSettingsTemplate::getAllSettingsTemplates('tst', true) as $nr => $template)
868  {
869  switch($this->getTestType())
870  {
871  case self::TEST_TYPE_IT:
872  if($template['title'] == self::SETTINGS_TEMPLATE_IT)
873  {
874  $tpl_id = $template['id'];
875  }
876  break;
877  case self::TEST_TYPE_QT:
878  if($template['title'] == self::SETTINGS_TEMPLATE_QT)
879  {
880  $tpl_id = $template['id'];
881  }
882  break;
883  }
884  if($tpl_id)
885  {
886  break;
887  }
888  }
889 
890  if(!$tpl_id)
891  {
892  return false;
893  }
894 
895  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
896  include_once './Modules/Test/classes/class.ilObjAssessmentFolderGUI.php';
898  $template_settings = $template->getSettings();
899  if($template_settings)
900  {
901  include_once './Modules/Test/classes/class.ilObjTestGUI.php';
902  $tst_gui = new ilObjTestGUI();
903  $tst_gui->applyTemplate($template_settings, $tst);
904  }
905  $tst->setTemplate($tpl_id);
906  return true;
907  }
908 
913  protected function updateStartObjects()
914  {
915  include_once './Services/Container/classes/class.ilContainerStartObjects.php';
916  $start = new ilContainerStartObjects(0, $this->getParentObject()->getId());
917  $this->getSettings()->updateStartObjects($start);
918  return true;
919  }
920 
921  protected function saveMultiTestAssignment()
922  {
923 
924  $this->ctrl->setParameter($this,'tt',(int) $_REQUEST['tt']);
925  $this->setTestType((int) $_REQUEST['tt']);
926 
928 
929  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php';
930  $form_helper = new ilLOTestAssignmentForm($this,$this->getParentObject(), $this->getTestType());
931  $form = $form_helper->initForm(TRUE);
932 
933  if($form->checkInput())
934  {
935  $mode = $form->getInput('mode');
936 
937  if($mode == self::TEST_NEW)
938  {
939  $tst = new ilObjTest();
940  $tst->setType('tst');
941  $tst->setTitle($form->getInput('title'));
942  $tst->setDescription($form->getInput('desc'));
943  $tst->create();
944  $tst->createReference();
945  $tst->putInTree($this->getParentObject()->getRefId());
946  $tst->setPermissions($this->getParentObject()->getRefId());
947 
948  // apply settings template
949  $this->applySettingsTemplate($tst);
950 
951  $tst->setQuestionSetType($form->getInput('qtype'));
952 
953  $tst->saveToDb();
954 
955  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
956  $assignment = new ilLOTestAssignment();
957  $assignment->setContainerId($this->getParentObject()->getId());
958  $assignment->setAssignmentType($this->getTestType());
959  $assignment->setObjectiveId($form->getInput('objective'));
960  $assignment->setTestRefId($tst->getRefId());
961  $assignment->save();
962  }
963  else
964  {
965  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
966  $assignment = new ilLOTestAssignment();
967  $assignment->setContainerId($this->getParentObject()->getId());
968  $assignment->setAssignmentType($this->getTestType());
969  $assignment->setObjectiveId($form->getInput('objective'));
970  $assignment->setTestRefId($form->getInput('tst'));
971  $assignment->save();
972 
973  $tst = new ilObjTest($form->getInput('tst'),true);
974  $this->applySettingsTemplate($tst);
975  $tst->saveToDb();
976  }
977 
978  // deassign as objective material
979  if($tst instanceof ilObjTest)
980  {
981  $this->updateMaterialAssignments($tst);
982  }
983  $this->updateStartObjects();
984 
985  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
986  $this->ctrl->redirect($this,'testsOverview');
987  }
988 
989  // Error
990  ilUtil::sendFailure($this->lng->txt('err_check_input'));
991  $form->setValuesByPost();
992  $this->testAssignment($form);
993  }
994 
999  {
1000  include_once './Modules/Course/classes/class.ilCourseObjective.php';
1001  foreach(ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId()) as $objective_id)
1002  {
1003  include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
1004  $materials = new ilCourseObjectiveMaterials($objective_id);
1005  foreach($materials->getMaterials() as $key => $material)
1006  {
1007  if($material['ref_id'] == $test->getRefId())
1008  {
1009  $materials->delete($material['lm_ass_id']);
1010  }
1011  }
1012  }
1013  }
1014 
1018  protected function saveTest()
1019  {
1020  $this->ctrl->setParameter($this,'tt',(int) $_REQUEST['tt']);
1021  $this->setTestType((int) $_REQUEST['tt']);
1022 
1024 
1025  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php';
1026  $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(),$this->getTestType());
1027  $form = $form_helper->initForm(FALSE);
1028 
1029  if($form->checkInput())
1030  {
1031  $mode = $form->getInput('mode');
1032 
1033  if($mode == self::TEST_NEW)
1034  {
1035  $tst = new ilObjTest();
1036  $tst->setType('tst');
1037  $tst->setTitle($form->getInput('title'));
1038  $tst->setDescription($form->getInput('desc'));
1039  $tst->create();
1040  $tst->createReference();
1041  $tst->putInTree($this->getParentObject()->getRefId());
1042  $tst->setPermissions($this->getParentObject()->getRefId());
1043 
1044  // apply settings template
1045  $this->applySettingsTemplate($tst);
1046 
1047  $tst->setQuestionSetType($form->getInput('qtype'));
1048 
1049  $tst->saveToDb();
1050 
1051  if($this->getTestType() == self::TEST_TYPE_IT)
1052  {
1053  $this->getSettings()->setInitialTest($tst->getRefId());
1054  }
1055  else
1056  {
1057  $this->getSettings()->setQualifiedTest($tst->getRefId());
1058  }
1059  $this->getSettings()->update();
1060  }
1061  else
1062  {
1063  if($this->getTestType() == self::TEST_TYPE_IT)
1064  {
1065  $this->getSettings()->setInitialTest($form->getInput('tst'));
1066  }
1067  else
1068  {
1069  $this->getSettings()->setQualifiedTest($form->getInput('tst'));
1070  }
1071 
1072  $this->getSettings()->update();
1073  $tst = new ilObjTest($settings->getTestByType($this->getTestType()),true);
1074  $this->applySettingsTemplate($tst);
1075  $tst->saveToDb();
1076  }
1077 
1078  // deassign as objective material
1079  if($tst instanceof ilObjTest)
1080  {
1081  $this->updateMaterialAssignments($tst);
1082  }
1083  $this->updateStartObjects();
1084 
1085  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1086  $this->ctrl->redirect($this,'testOverview');
1087  }
1088 
1089  // Error
1090  ilUtil::sendFailure($this->lng->txt('err_check_input'));
1091  $form->setValuesByPost();
1092  $this->testSettings($form);
1093  }
1094 
1098  protected function listObjectives()
1099  {
1100  global $ilToolbar;
1101 
1102  include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php';
1104 
1105 
1106  $GLOBALS['ilTabs']->activateSubTab('objectives');
1107 
1109  $this->getParentObject()->getId(),
1110  FALSE
1111  );
1112 
1113  if(!count($objectives))
1114  {
1115  return $this->showObjectiveCreation();
1116  }
1117 
1118  $ilToolbar->addButton(
1119  $this->lng->txt('crs_add_objective'),
1120  $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', "create"));
1121 
1122  include_once('./Modules/Course/classes/class.ilCourseObjectivesTableGUI.php');
1123  $table = new ilCourseObjectivesTableGUI($this,$this->getParentObject());
1124  $table->setTitle($this->lng->txt('crs_objectives'),'',$this->lng->txt('crs_objectives'));
1125  $table->parse($objectives);
1126  $GLOBALS['tpl']->setContent($table->getHTML());
1127 
1129  }
1130 
1135  protected function showObjectiveCreation(ilPropertyFormGUI $form = NULL)
1136  {
1137  $GLOBALS['ilTabs']->activateSubTab('objectives');
1138 
1139  if(!$form instanceof ilPropertyFormGUI)
1140  {
1141  $form = $this->initSimpleObjectiveForm();
1142  }
1143 
1144  $GLOBALS['tpl']->setContent($form->getHTML());
1145 
1147  }
1148 
1152  protected function initSimpleObjectiveForm()
1153  {
1154  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1155  $form = new ilPropertyFormGUI();
1156  $form->setTitle($this->lng->txt('crs_loc_form_create_objectives'));
1157  $form->setFormAction($this->ctrl->getFormAction($this));
1158 
1159  $txt = new ilTextWizardInputGUI($this->lng->txt('crs_objectives'), 'objectives');
1160  $txt->setValues(array(0 => ''));
1161  $txt->setRequired(true);
1162  $form->addItem($txt);
1163 
1164  $form->addCommandButton('saveObjectiveCreation', $this->lng->txt('save'));
1165 
1166  return $form;
1167  }
1168 
1169  protected function saveObjectiveCreation()
1170  {
1171  $form = $this->initSimpleObjectiveForm();
1172  if($form->checkInput())
1173  {
1174  foreach((array) $form->getInput('objectives') as $idx => $title)
1175  {
1176  include_once './Modules/Course/classes/class.ilCourseObjective.php';
1177  $obj = new ilCourseObjective($this->getParentObject());
1178  $obj->setActive(TRUE);
1179  $obj->setTitle($title);
1180  $obj->add();
1181  }
1182  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
1183  $this->ctrl->redirect($this,'');
1184  }
1185 
1186  $form->setValuesByPost();
1187  $GLOBALS['ilTabs']->activateSubTab('objectives');
1189  $this->showObjectiveCreation($form);
1190  }
1191 
1198  protected function saveSorting()
1199  {
1200  global $ilAccess,$ilErr,$ilObjDataCache;
1201 
1202  asort($_POST['position'],SORT_NUMERIC);
1203 
1204  $counter = 1;
1205  foreach($_POST['position'] as $objective_id => $position)
1206  {
1207  include_once './Modules/Course/classes/class.ilCourseObjective.php';
1208  $objective = new ilCourseObjective($this->getParentObject(),$objective_id);
1209  $objective->writePosition($counter++);
1210  }
1211  ilUtil::sendSuccess($this->lng->txt('crs_objective_saved_sorting'));
1212  $this->listObjectives();
1213  }
1214 
1218  protected function askDeleteObjectives()
1219  {
1220  $GLOBALS['ilTabs']->activateSubTab('objectives');
1221 
1222  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
1223  $confirm = new ilConfirmationGUI();
1224  $confirm->setFormAction($this->ctrl->getFormAction($this));
1225  $confirm->setHeaderText($this->lng->txt('crs_delete_objectve_sure'));
1226  $confirm->setConfirm($this->lng->txt('delete'), 'deleteObjectives');
1227  $confirm->setCancel($this->lng->txt('cancel'), 'listObjectives');
1228 
1229  foreach($_POST['objective'] as $objective_id)
1230  {
1231  include_once './Modules/Course/classes/class.ilCourseObjective.php';
1232  $obj = new ilCourseObjective($this->getParentObject(),$objective_id);
1233  $name = $obj->getTitle();
1234 
1235  $confirm->addItem(
1236  'objective_ids[]',
1237  $objective_id,
1238  $name
1239  );
1240  }
1241  $GLOBALS['tpl']->setContent($confirm->getHTML());
1243  }
1244 
1248  protected function activateObjectives()
1249  {
1250  $enabled = (array) $_REQUEST['objective'];
1251 
1252  include_once './Modules/Course/classes/class.ilCourseObjective.php';
1253  $objectives = ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId(),false);
1254  foreach((array) $objectives as $objective_id)
1255  {
1256  $objective = new ilCourseObjective($this->getParentObject(),$objective_id);
1257  if(in_array($objective_id, $enabled))
1258  {
1259  $objective->setActive(true);
1260  $objective->update();
1261  }
1262  }
1263 
1264  include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
1266 
1267  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
1268  $this->ctrl->redirect($this,'listObjectives');
1269  }
1270 
1274  protected function deactivateObjectives()
1275  {
1276  $disabled = (array) $_REQUEST['objective'];
1277 
1278  include_once './Modules/Course/classes/class.ilCourseObjective.php';
1279  $objectives = ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId(),false);
1280  foreach((array) $objectives as $objective_id)
1281  {
1282  $objective = new ilCourseObjective($this->getParentObject(),$objective_id);
1283  if(in_array($objective_id, $disabled))
1284  {
1285  $objective->setActive(false);
1286  $objective->update();
1287  }
1288  }
1289 
1290  include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
1292 
1293  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
1294  $this->ctrl->redirect($this,'listObjectives');
1295  }
1296 
1302  protected function deleteObjectives()
1303  {
1304  global $rbacsystem;
1305 
1306  foreach($_POST['objective_ids'] as $objective_id)
1307  {
1308  include_once './Modules/Course/classes/class.ilCourseObjective.php';
1309  $objective_obj = new ilCourseObjective($this->getParentObject(),$objective_id);
1310  $objective_obj->delete();
1311  }
1312 
1313  include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
1315 
1316  ilUtil::sendSuccess($this->lng->txt('crs_objectives_deleted'),true);
1317  $this->ctrl->redirect($this,'listObjectives');
1318 
1319  return true;
1320  }
1321 
1325  protected function showStatus($a_section)
1326  {
1327  include_once './Modules/Course/classes/Objectives/class.ilLOEditorStatus.php';
1328  $status = new ilLOEditorStatus($this->getParentObject());
1329  $status->setSection($a_section);
1330  $status->setCmdClass($this);
1331  $GLOBALS['tpl']->setRightContent($status->getHTML());
1332  }
1333 
1334 
1335 
1340  protected function setTabs($a_section = '')
1341  {
1342  // objective settings
1343  $GLOBALS['ilTabs']->addSubTab(
1344  'settings',
1345  $this->lng->txt('settings'),
1346  $this->ctrl->getLinkTarget($this,'settings')
1347  );
1348  // learning objectives
1349  $GLOBALS['ilTabs']->addSubTab(
1350  'objectives',
1351  $this->lng->txt('crs_loc_tab_objectives'),
1352  $this->ctrl->getLinkTarget($this,'listObjectives')
1353  );
1354  // materials
1355  /*
1356  $GLOBALS['ilTabs']->addTab(
1357  'materials',
1358  $this->lng->txt('crs_loc_tab_materials'),
1359  $this->ctrl->getLinkTarget($this,'materials')
1360  );
1361  */
1362  // tests
1364  if($settings->worksWithInitialTest())
1365  {
1366  if(
1367  $settings->getInitialTestType() == ilLOSettings::TYPE_INITIAL_PLACEMENT_ALL ||
1368  $settings->getInitialTestType() == ilLOSettings::TYPE_INITIAL_QUALIFYING_ALL
1369  )
1370  {
1371  $this->ctrl->setParameter($this,'tt', ilLOSettings::TYPE_TEST_INITIAL);
1372  $GLOBALS['ilTabs']->addSubTab(
1373  'itest',
1374  $this->lng->txt('crs_loc_tab_itest'),
1375  $this->ctrl->getLinkTarget($this,'testOverview')
1376  );
1377  }
1378  else
1379  {
1380  $this->ctrl->setParameter($this,'tt', ilLOSettings::TYPE_TEST_INITIAL);
1381  $GLOBALS['ilTabs']->addSubTab(
1382  'itests',
1383  $this->lng->txt('crs_loc_tab_itests'),
1384  $this->ctrl->getLinkTarget($this,'testsOverview')
1385  );
1386  }
1387 
1388 
1389 
1390  }
1391 
1392  if($settings->getQualifyingTestType() == ilLOSettings::TYPE_QUALIFYING_ALL)
1393  {
1394  $this->ctrl->setParameter($this,'tt', ilLOSettings::TYPE_TEST_QUALIFIED);
1395  $GLOBALS['ilTabs']->addSubTab(
1396  'qtest',
1397  $this->lng->txt('crs_loc_tab_qtest'),
1398  $this->ctrl->getLinkTarget($this,'testOverview')
1399  );
1400  }
1401  else
1402  {
1403  $this->ctrl->setParameter($this,'tt', ilLOSettings::TYPE_TEST_QUALIFIED);
1404  $GLOBALS['ilTabs']->addSubTab(
1405  'qtests',
1406  $this->lng->txt('crs_loc_tab_qtests'),
1407  $this->ctrl->getLinkTarget($this,'testsOverview')
1408  );
1409  }
1410 
1411  if($settings->worksWithStartObjects())
1412  {
1413  $GLOBALS['ilTabs']->addSubTab(
1414  'start',
1415  $this->lng->txt('crs_loc_tab_start'),
1416  $this->ctrl->getLinkTargetByClass('ilcontainerstartobjectsgui','')
1417  );
1418  }
1419 
1420  // Member view
1421  #include_once './Services/Container/classes/class.ilMemberViewGUI.php';
1422  #ilMemberViewGUI::showMemberViewSwitch($this->getParentObject()->getRefId());
1423  }
1424 }
1425 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
static getInstanceByObjId($a_obj_id)
get singleton instance
update()
update settings type $ilDB
global $ilErr
Definition: raiseError.php:16
This class represents an option in a radio group.
testOverview()
Show test overview.
static getAllSettingsTemplates($a_type, $a_include_auto_generated=false)
Get all settings templates of type.
class ilConditionHandlerGUI
static getInstance($a_container_id)
Get instance by container id.
static lookupObjectiveTitle($a_objective_id, $a_add_description=false)
setTabs($a_section='')
Set tabs.
testsOverview()
View test assignments ()
const TYPE_INITIAL_QUALIFYING_SELECTED
Class ilObjTestGUI.
$_SESSION["AccountId"]
(Course) learning objective page object
getSettings()
Settings.
This class represents a property form user interface.
confirmDeleteTest()
Show delete confirmation screen.
setInitialTest($a_id)
set initial test id
saveSorting()
save position
Presentation of the status of single steps during the configuration process.
getInitialTestType()
Get initial test type.
showObjectiveCreation(ilPropertyFormGUI $form=NULL)
Show objective creation form.
Class ilLOEditorGUI.
deleteAssignments($a_type)
Delete assignments.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$cmd
Definition: sahs_server.php:35
static _getObjectiveIds($course_id, $a_activated_only=false)
Settings for LO courses.
This class represents a checkbox property in a property form.
static _lookupTitle($a_id)
lookup object title
initSettingsForm()
Init settings form.
askDeleteObjectives()
Confirm delete objectives.
setQualifiedTest($a_id)
set qualified test
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
initSimpleObjectiveForm()
Show objective creation form.
setInfo($a_info)
Set Info.
const HIDE_PASSED_OBJECTIVE_QST
deleteObjectives()
Delete objectives type $rbacsystem.
updateStartObjects()
Add Test as start object.
global $ilCtrl
Definition: ilias.php:18
executeCommand()
Execute command.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$counter
$a_type
Definition: workflow.php:93
class ilCourseObjectiveMaterials
This class represents a property in a property form.
class ilobjcourseobjectivesgui
updateTestAssignments(ilLOSettings $settings)
Update Test assignments.
deleteTest()
Delete test assignment.
class ilcourseobjective
Class ilLOTestAssignmentTableGUI.
static getInstance(ilObject $a_parent)
Get instance.
setTemplate($template_id)
static _lookupObjId($a_id)
const MARK_PASSED_OBJECTIVE_QST
setValue($a_value)
Set Value.
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
Class ilLOInvalidConfigurationException.
updateMaterialAssignments(ilObjTest $test)
activateObjectives()
activate chosen objectives
__construct($a_parent_obj)
Constructor.
$txt
Definition: error.php:12
(Course) learning objective page GUI class
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
deactivateObjectives()
activate chosen objectives
deleteTests()
Delete test assignments.
Settings for LO courses.
static getContentStylePath($a_style_id)
get content style path
settings(ilPropertyFormGUI $form=NULL)
Objective Settings.
getQualifyingTestType()
Get qualifying test type.
Render add new item selector.
Settings for LO courses.
$ret
Definition: parser.php:6
showStatus($a_section)
Show status panel.
getRefId()
get reference id public
listObjectives()
List all abvailable objectives.
const TYPE_INITIAL_QUALIFYING_ALL
const TYPE_INITIAL_PLACEMENT_ALL
static getLogger($a_component_id)
Get component logger.
testSettings(ilPropertyFormGUI $form=NULL)
Show test settings.
const TYPE_QUALIFYING_SELECTED
This class represents a text wizard property in a property form.
confirmDeleteTests()
Show delete test confirmation.
testAssignment(ilPropertyFormGUI $form=null)
new test assignment
returnFromObjectives()
Return from objectives.
applySettingsTemplate(ilObjTest $tst)
Apply auto generated setttings template.
$_POST["username"]
Settings template application class.
setRequired($a_required)
Set Required.
Class ilContainerStartObjectsGUI.
$test
Definition: Utf8Test.php:84
Confirmation screen class.
const TYPE_INITIAL_PLACEMENT_SELECTED