ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 
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;
46  $this->settings = ilLOSettings::getInstanceByObjId($this->getParentObject()->getId());
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,'returnFromObjectives');
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  include_once('./Services/Style/classes/class.ilObjStyleSheet.php');
143  $this->parent_obj->getStyleSheetId(), $this->parent_obj->getType()));
144 
145  // #14895
146  $GLOBALS['tpl']->setCurrentBlock("ContentStyle");
147  $GLOBALS['tpl']->setVariable("LOCATION_CONTENT_STYLESHEET",
149  $this->parent_obj->getStyleSheetId(), $this->parent_obj->getType())));
150  $GLOBALS['tpl']->parseCurrentBlock();
151 
152  $ret = $this->ctrl->forwardCommand($pgui);
153  if($ret)
154  {
155  $GLOBALS['tpl']->setContent($ret);
156  }
157  break;
158 
159  default:
160  if(!$cmd)
161  {
162  // get first unaccomplished step
163  include_once './Modules/Course/classes/Objectives/class.ilLOEditorStatus.php';
164  $cmd = ilLOEditorStatus::getInstance($this->getParentObject())->getFirstFailedStep();
165  }
166  $this->$cmd();
167 
168  break;
169  }
170  return true;
171  }
172 
177  protected function returnFromObjectives()
178  {
179  include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php';
181  return $this->listObjectives();
182  }
183 
187  public function getParentObject()
188  {
189  return $this->parent_obj;
190  }
191 
196  public function getSettings()
197  {
198  return $this->settings;
199  }
200 
201  public function setTestType($a_type)
202  {
203  $this->test_type = $a_type;
204  }
205 
206  public function getTestType()
207  {
208  return $this->test_type;
209  }
210 
211 
215  protected function settings(ilPropertyFormGUI $form = NULL)
216  {
217  if(!$form instanceof ilPropertyFormGUI)
218  {
219  $form = $this->initSettingsForm();
220  }
221 
222  $GLOBALS['ilTabs']->activateSubTab('settings');
223  $GLOBALS['tpl']->setContent($form->getHTML());
224 
226  }
227 
232  protected function deleteAssignments($a_type)
233  {
234  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
235  $assignments = ilLOTestAssignments::getInstance($this->getParentObject()->getId());
236  foreach($assignments->getAssignmentsByType($a_type) as $assignment)
237  {
238  $assignment->delete();
239  }
240  return;
241  }
242 
243 
247  protected function saveSettings()
248  {
249  $form = $this->initSettingsForm();
250  if($form->checkInput())
251  {
253  $settings->setInitialTestType($form->getInput('ittype'));
254  switch($settings->getInitialTestType())
255  {
257  $settings->setInitialTestAsStart($form->getInput('start_ip'));
259  break;
260 
262  $settings->setInitialTestAsStart(FALSE);
263  $settings->setInitialTest(0);
264  break;
265 
267  $settings->setInitialTestAsStart($form->getInput('start_iq'));
269  break;
270 
272  $settings->setInitialTestAsStart(FALSE);
273  $settings->setInitialTest(0);
274  break;
275 
277  $settings->setInitialTestAsStart(FALSE);
278  $settings->setInitialTest(0);
280  break;
281  }
282 
283  $settings->setQualifyingTestType($form->getInput('qttype'));
284  $settings->resetResults($form->getInput('reset'));
285  $settings->setPassedObjectiveMode($form->getInput('passed_mode'));
286 
287  if($form->getInput('qttype') == ilLOSettings::TYPE_QUALIFYING_ALL)
288  {
289  $settings->setQualifyingTestAsStart($form->getInput('start_q'));
290  }
291  if($form->getInput('qttype') == ilLOSettings::TYPE_QUALIFYING_SELECTED)
292  {
293  $settings->setQualifiedTest(0);
294  }
295 
296  if(
297  ($settings->getInitialTestType() != ilLOSettings::TYPE_INITIAL_NONE) &&
298  ($settings->isQualifyingTestStart())
299  )
300  {
301  $settings->setQualifyingTestAsStart(FALSE);
302  ilUtil::sendInfo($this->lng->txt('crs_loc_settings_err_qstart'),TRUE);
303  }
304 
305  $settings->update();
306  $this->updateStartObjects();
307 
308  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
309  $this->ctrl->redirect($this,'settings');
310  }
311 
312  // Error
313  ilUtil::sendFailure($this->lng->txt('err_check_input'));
314  $form->setValuesByPost();
315  $this->settings($form);
316  }
317 
321  protected function initSettingsForm()
322  {
323  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
324  $form = new ilPropertyFormGUI();
325  $form->setFormAction($this->ctrl->getFormAction($this));
326  $form->setTitle($this->lng->txt('crs_loc_settings_tbl'));
327 
328  // initial test
329  $type_selector = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_it_type'), 'ittype');
330  $type_selector->setRequired(TRUE);
331  $type_selector->setValue($this->getSettings()->getInitialTestType());
332 
333  $type_ipa = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_placement_all'), ilLOSettings::TYPE_INITIAL_PLACEMENT_ALL);
334  $type_ipa->setInfo($this->lng->txt('crs_loc_settings_type_it_placement_all_info'));
335  $type_selector->addOption($type_ipa);
336 
337  $start_ip = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_it_start_object'),'start_ip');
338  $start_ip->setValue(1);
339  $start_ip->setChecked($this->getSettings()->isInitialTestStart());
340  $type_ipa->addSubItem($start_ip);
341 
342  $type_ips = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_placement_sel'), ilLOSettings::TYPE_INITIAL_PLACEMENT_SELECTED);
343  $type_ips->setInfo($this->lng->txt('crs_loc_settings_type_it_placement_sel_info'));
344  $type_selector->addOption($type_ips);
345 
346  $type_iqa = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_qualifying_all'), ilLOSettings::TYPE_INITIAL_QUALIFYING_ALL);
347  $type_iqa->setInfo($this->lng->txt('crs_loc_settings_type_it_qualifying_all_info'));
348  $type_selector->addOption($type_iqa);
349 
350  $start_iq = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_it_start_object'),'start_iq');
351  $start_iq->setValue(1);
352  $start_iq->setChecked($this->getSettings()->isInitialTestStart());
353  $type_iqa->addSubItem($start_iq);
354 
355  $type_iqs = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_qualifying_sel'), ilLOSettings::TYPE_INITIAL_QUALIFYING_SELECTED);
356  $type_iqs->setInfo($this->lng->txt('crs_loc_settings_type_it_qualifying_sel_info'));
357  $type_selector->addOption($type_iqs);
358 
359  $type_ino = new ilRadioOption($this->lng->txt('crs_loc_settings_type_it_none'), ilLOSettings::TYPE_INITIAL_NONE);
360  $type_ino->setInfo($this->lng->txt('crs_loc_settings_type_it_none_info'));
361  $type_selector->addOption($type_ino);
362 
363  $form->addItem($type_selector);
364 
365  // qualifying test
366  $qt_selector = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_qt_all'),'qttype');
367  $qt_selector->setRequired(TRUE);
368  $qt_selector->setValue($this->getSettings()->getQualifyingTestType());
369 
370  $type_qa = new ilRadioOption($this->lng->txt('crs_loc_settings_type_q_all'), ilLOSettings::TYPE_QUALIFYING_ALL);
371  $type_qa->setInfo($this->lng->txt('crs_loc_settings_type_q_all_info'));
372  $qt_selector->addOption($type_qa);
373 
374  $start_q = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_qt_start_object'),'start_q');
375  $start_q->setValue(1);
376  $start_q->setChecked($this->getSettings()->isQualifyingTestStart());
377  $type_qa->addSubItem($start_q);
378 
379  $passed_mode = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_settings_passed_mode'),'passed_mode');
380  $passed_mode->setValue($this->getSettings()->getPassedObjectiveMode());
381 
382  $passed_mode->addOption(
383  new ilRadioOption(
384  $this->lng->txt('crs_loc_settings_passed_mode_hide'),
386  );
387  $passed_mode->addOption(
388  new ilRadioOption(
389  $this->lng->txt('crs_loc_settings_passed_mode_mark'),
391  );
392  $type_qa->addSubItem($passed_mode);
393 
394  $type_qs = new ilRadioOption($this->lng->txt('crs_loc_settings_type_q_selected'), ilLOSettings::TYPE_QUALIFYING_SELECTED);
395  $type_qs->setInfo($this->lng->txt('crs_loc_settings_type_q_selected_info'));
396  $qt_selector->addOption($type_qs);
397 
398  $form->addItem($qt_selector);
399 
400  // reset results
401  $reset = new ilCheckboxInputGUI($this->lng->txt('crs_loc_settings_reset'),'reset');
402  $reset->setValue(1);
403  $reset->setChecked($this->getSettings()->isResetResultsEnabled());
404  $reset->setOptionTitle($this->lng->txt('crs_loc_settings_reset_enable'));
405  $reset->setInfo($this->lng->txt('crs_loc_settings_reset_enable_info'));
406  $form->addItem($reset);
407 
408  $form->addCommandButton('saveSettings', $this->lng->txt('save'));
409 
410 
411  return $form;
412  }
413 
414  protected function materials()
415  {
416  $GLOBALS['ilTabs']->activateSubTab('materials');
417 
418  include_once "Services/Object/classes/class.ilObjectAddNewItemGUI.php";
419  $gui = new ilObjectAddNewItemGUI($this->getParentObject()->getRefId());
420  $gui->setDisabledObjectTypes(array("itgr"));
421  #$gui->setAfterCreationCallback($this->getParentObject()->getRefId());
422  $gui->render();
423 
424  include_once './Services/Object/classes/class.ilObjectTableGUI.php';
425  $obj_table = new ilObjectTableGUI(
426  $this,
427  'materials',
428  $this->getParentObject()->getRefId()
429  );
430  $obj_table->init();
431  $obj_table->setObjects($GLOBALS['tree']->getChildIds($this->getParentObject()->getRefId()));
432  $obj_table->parse();
433  $GLOBALS['tpl']->setContent($obj_table->getHTML());
434 
436  }
437 
441  protected function testsOverview()
442  {
443  $this->setTestType((int) $_REQUEST['tt']);
444  $this->ctrl->setParameter($this,'tt',$this->getTestType());
445 
446  $GLOBALS['ilToolbar']->setFormAction($this->ctrl->getFormAction($this));
447  $GLOBALS['ilToolbar']->addButton(
448  $this->lng->txt('crs_loc_btn_new_assignment'),
449  $this->ctrl->getLinkTarget($this,'testAssignment')
450  );
451 
452 
454  switch($this->getTestType())
455  {
457  $GLOBALS['ilTabs']->activateSubTab('itests');
458  break;
459 
461  $GLOBALS['ilTabs']->activateSubTab('qtests');
462  break;
463  }
464 
465  try {
466  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentTableGUI.php';
467  $table = new ilLOTestAssignmentTableGUI(
468  $this,
469  'testsOverview',
470  $this->getParentObject()->getId(),
471  $this->getTestType(),
473  );
474  $table->init();
475  $table->parseMultipleAssignments();
476  $GLOBALS['tpl']->setContent($table->getHTML());
477 
478  $this->showStatus(
482  );
483  }
485  {
486  $GLOBALS['ilLog']->write(__METHOD__.': Show new assignment screen because of : '. $ex->getMessage());
487  $this->testSettings();
488  }
489 
490 
491 
492  }
493 
494 
498  protected function testOverview()
499  {
500  $this->setTestType((int) $_REQUEST['tt']);
501  $this->ctrl->setParameter($this,'tt',$this->getTestType());
502 
504  switch($this->getTestType())
505  {
507  $GLOBALS['ilTabs']->activateSubTab('itest');
508  break;
509 
511  $GLOBALS['ilTabs']->activateSubTab('qtest');
512  break;
513  }
514 
515 
516  // Check if test is assigned
517  if(!$settings->getTestByType($this->getTestType()))
518  {
519  return $this->testSettings();
520  }
521 
522  try {
523  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentTableGUI.php';
524  $table = new ilLOTestAssignmentTableGUI(
525  $this,
526  'testOverview',
527  $this->getParentObject()->getId(),
528  $this->getTestType()
529  );
530  $table->init();
531  $table->parse(ilLOSettings::getInstanceByObjId($this->getParentObject()->getId())->getTestByType($this->getTestType()));
532  $GLOBALS['tpl']->setContent($table->getHTML());
533 
534  $this->showStatus(
538  );
539  }
541  {
542  $GLOBALS['ilLog']->write(__METHOD__.': Show new assignment screen because of : '. $ex->getMessage());
543  $this->testSettings();
544  }
545  }
546 
550  protected function confirmDeleteTests()
551  {
552  $this->setTestType((int) $_REQUEST['tt']);
553  $this->ctrl->setParameter($this,'tt',$this->getTestType());
554 
556  switch($this->getTestType())
557  {
559  $GLOBALS['ilTabs']->activateSubTab('itests');
560  break;
561 
563  $GLOBALS['ilTabs']->activateSubTab('qtests');
564  break;
565  }
566 
567  if(!(int) $_REQUEST['tst'])
568  {
569  ilUtil::sendFailure($this->lng->txt('select_one'),true);
570  $this->ctrl->redirect($this,'testsOverview');
571  }
572 
573  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
574  $confirm = new ilConfirmationGUI();
575  $confirm->setHeaderText($this->lng->txt('crs_loc_confirm_delete_tst'));
576  $confirm->setFormAction($this->ctrl->getFormAction($this));
577  $confirm->setConfirm($this->lng->txt('crs_loc_delete_assignment'), 'deleteTests');
578  $confirm->setCancel($this->lng->txt('cancel'), 'testsOverview');
579 
580  foreach((array) $_REQUEST['tst'] as $assign_id)
581  {
582  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
583  $assignment = new ilLOTestAssignment($assign_id);
584 
585 
586  $obj_id = ilObject::_lookupObjId($assignment->getTestRefId());
587  $confirm->addItem('tst[]', $assign_id, ilObject::_lookupTitle($obj_id));
588  }
589 
590  $GLOBALS['tpl']->setContent($confirm->getHTML());
591 
592  $this->showStatus(
596  );
597  }
598 
602  protected function confirmDeleteTest()
603  {
604  $this->setTestType((int) $_REQUEST['tt']);
605  $this->ctrl->setParameter($this,'tt',$this->getTestType());
606 
608  switch($this->getTestType())
609  {
611  $GLOBALS['ilTabs']->activateSubTab('itest');
612  break;
613 
615  $GLOBALS['ilTabs']->activateSubTab('qtest');
616  break;
617  }
618 
619  if(!(int) $_REQUEST['tst'])
620  {
621  ilUtil::sendFailure($this->lng->txt('select_one'),true);
622  $this->ctrl->redirect($this,'testOverview');
623  }
624 
625  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
626  $confirm = new ilConfirmationGUI();
627  $confirm->setHeaderText($this->lng->txt('crs_loc_confirm_delete_tst'));
628  $confirm->setFormAction($this->ctrl->getFormAction($this));
629  $confirm->setConfirm($this->lng->txt('crs_loc_delete_assignment'), 'deleteTest');
630  $confirm->setCancel($this->lng->txt('cancel'), 'testOverview');
631 
632  foreach((array) $_REQUEST['tst'] as $tst_id)
633  {
634  $obj_id = ilObject::_lookupObjId($tst_id);
635  $confirm->addItem('tst[]', $tst_id, ilObject::_lookupTitle($obj_id));
636  }
637 
638  $GLOBALS['tpl']->setContent($confirm->getHTML());
639 
640  $this->showStatus(
644  );
645  }
646 
650  protected function deleteTests()
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('itests');
660  break;
661 
663  $GLOBALS['ilTabs']->activateSubTab('qtests');
664  break;
665  }
666 
667  foreach((array) $_REQUEST['tst'] as $assign_id)
668  {
669  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
670  $assignment = new ilLOTestAssignment($assign_id);
671  $assignment->delete();
672 
673  // finally delete start object assignment
674  include_once './Services/Container/classes/class.ilContainerStartObjects.php';
675  $start = new ilContainerStartObjects(
676  $this->getParentObject()->getRefId(),
677  $this->getParentObject()->getId()
678  );
679  $start->deleteItem($assignment->getTestRefId());
680 
681  // ... and assigned questions
682  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
683  ilCourseObjectiveQuestion::deleteTest($assignment->getTestRefId());
684  }
685 
686 
687  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
688  $this->ctrl->redirect($this,'testsOverview');
689  }
690 
694  protected function deleteTest()
695  {
696  $this->setTestType((int) $_REQUEST['tt']);
697  $this->ctrl->setParameter($this,'tt',$this->getTestType());
698 
700  switch($this->getTestType())
701  {
703  $GLOBALS['ilTabs']->activateSubTab('itest');
704  break;
705 
707  $GLOBALS['ilTabs']->activateSubTab('qtest');
708  break;
709  }
710 
711  foreach((array) $_REQUEST['tst'] as $tst_id)
712  {
713  switch($this->getTestType())
714  {
716  $settings->setInitialTest(0);
717  break;
718 
720  $settings->setQualifiedTest(0);
721  break;
722  }
723  $settings->update();
724 
725  // finally delete start object assignment
726  include_once './Services/Container/classes/class.ilContainerStartObjects.php';
727  $start = new ilContainerStartObjects(
728  $this->getParentObject()->getRefId(),
729  $this->getParentObject()->getId()
730  );
731  $start->deleteItem($tst_id);
732 
733  // ... and assigned questions
734  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
736  }
737 
738 
739  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
740  $this->ctrl->redirect($this,'testOverview');
741  }
742 
746  protected function testAssignment(ilPropertyFormGUI $form = null)
747  {
748  $this->setTestType((int) $_REQUEST['tt']);
749  $this->ctrl->setParameter($this,'tt',$this->getTestType());
750 
751  switch($this->getTestType())
752  {
754  $GLOBALS['ilTabs']->activateSubTab('itests');
755  break;
756 
758  $GLOBALS['ilTabs']->activateSubTab('qtests');
759  break;
760  }
761  if(!$form instanceof ilPropertyFormGUI)
762  {
763  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php';
764  $form_helper = new ilLOTestAssignmentForm($this,$this->getParentObject(), $this->getTestType());
765  $form = $form_helper->initForm(TRUE);
766  }
767  $GLOBALS['tpl']->setContent($form->getHTML());
768 
769  $this->showStatus(
770  ($this->getTestType() == self::TEST_TYPE_IT) ?
773  );
774  }
775 
780  protected function testSettings(ilPropertyFormGUI $form = NULL)
781  {
782  $this->ctrl->setParameter($this,'tt',(int) $_REQUEST['tt']);
783  switch($this->getTestType())
784  {
786  $GLOBALS['ilTabs']->activateSubTab('itest');
787  break;
788 
790  $GLOBALS['ilTabs']->activateSubTab('qtest');
791  break;
792  }
793 
794  if(!$form instanceof ilPropertyFormGUI)
795  {
796  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php';
797  $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(),$this->getTestType());
798  $form = $form_helper->initForm(FALSE);
799  }
800  $GLOBALS['tpl']->setContent($form->getHTML());
801 
802  $this->showStatus(
803  ($this->getTestType() == self::TEST_TYPE_IT) ?
806  );
807  }
808 
813  protected function applySettingsTemplate(ilObjTest $tst)
814  {
815  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
816  include_once './Modules/Test/classes/class.ilObjAssessmentFolderGUI.php';
817 
818  $tpl_id = 0;
819  foreach(ilSettingsTemplate::getAllSettingsTemplates('tst', true) as $nr => $template)
820  {
821  switch($this->getTestType())
822  {
823  case self::TEST_TYPE_IT:
824  if($template['title'] == self::SETTINGS_TEMPLATE_IT)
825  {
826  $tpl_id = $template['id'];
827  }
828  break;
829  case self::TEST_TYPE_QT:
830  if($template['title'] == self::SETTINGS_TEMPLATE_QT)
831  {
832  $tpl_id = $template['id'];
833  }
834  break;
835  }
836  if($tpl_id)
837  {
838  break;
839  }
840  }
841 
842  if(!$tpl_id)
843  {
844  return false;
845  }
846 
847  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
848  include_once './Modules/Test/classes/class.ilObjAssessmentFolderGUI.php';
850  $template_settings = $template->getSettings();
851  if($template_settings)
852  {
853  include_once './Modules/Test/classes/class.ilObjTestGUI.php';
854  $tst_gui = new ilObjTestGUI();
855  $tst_gui->applyTemplate($template_settings, $tst);
856  }
857  $tst->setTemplate($tpl_id);
858  return true;
859  }
860 
865  protected function updateStartObjects()
866  {
867  include_once './Services/Container/classes/class.ilContainerStartObjects.php';
868  $start = new ilContainerStartObjects(0, $this->getParentObject()->getId());
869  $this->getSettings()->updateStartObjects($start);
870  return true;
871  }
872 
873  protected function saveMultiTestAssignment()
874  {
875 
876  $this->ctrl->setParameter($this,'tt',(int) $_REQUEST['tt']);
877  $this->setTestType((int) $_REQUEST['tt']);
878 
880 
881  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php';
882  $form_helper = new ilLOTestAssignmentForm($this,$this->getParentObject(), $this->getTestType());
883  $form = $form_helper->initForm(TRUE);
884 
885  if($form->checkInput())
886  {
887  $mode = $form->getInput('mode');
888 
889  if($mode == self::TEST_NEW)
890  {
891  $tst = new ilObjTest();
892  $tst->setType('tst');
893  $tst->setTitle($form->getInput('title'));
894  $tst->setDescription($form->getInput('desc'));
895  $tst->create();
896  $tst->createReference();
897  $tst->putInTree($this->getParentObject()->getRefId());
898  $tst->setPermissions($this->getParentObject()->getRefId());
899 
900  // apply settings template
901  $this->applySettingsTemplate($tst);
902 
903  $tst->setQuestionSetType($form->getInput('qtype'));
904 
905  $tst->saveToDb();
906 
907  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
908  $assignment = new ilLOTestAssignment();
909  $assignment->setContainerId($this->getParentObject()->getId());
910  $assignment->setAssignmentType($this->getTestType());
911  $assignment->setObjectiveId($form->getInput('objective'));
912  $assignment->setTestRefId($tst->getRefId());
913  $assignment->save();
914  }
915  else
916  {
917  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignment.php';
918  $assignment = new ilLOTestAssignment();
919  $assignment->setContainerId($this->getParentObject()->getId());
920  $assignment->setAssignmentType($this->getTestType());
921  $assignment->setObjectiveId($form->getInput('objective'));
922  $assignment->setTestRefId($form->getInput('tst'));
923  $assignment->save();
924 
925  $tst = new ilObjTest($form->getInput('tst'),true);
926  $this->applySettingsTemplate($tst);
927  $tst->saveToDb();
928  }
929 
930  $this->updateStartObjects();
931 
932  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
933  $this->ctrl->redirect($this,'testsOverview');
934  }
935 
936  // Error
937  ilUtil::sendFailure($this->lng->txt('err_check_input'));
938  $form->setValuesByPost();
939  $this->testAssignment($form);
940  }
941 
945  protected function saveTest()
946  {
947  $this->ctrl->setParameter($this,'tt',(int) $_REQUEST['tt']);
948  $this->setTestType((int) $_REQUEST['tt']);
949 
951 
952  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignmentForm.php';
953  $form_helper = new ilLOTestAssignmentForm($this, $this->getParentObject(),$this->getTestType());
954  $form = $form_helper->initForm(FALSE);
955 
956  if($form->checkInput())
957  {
958  $mode = $form->getInput('mode');
959 
960  if($mode == self::TEST_NEW)
961  {
962  $tst = new ilObjTest();
963  $tst->setType('tst');
964  $tst->setTitle($form->getInput('title'));
965  $tst->setDescription($form->getInput('desc'));
966  $tst->create();
967  $tst->createReference();
968  $tst->putInTree($this->getParentObject()->getRefId());
969  $tst->setPermissions($this->getParentObject()->getRefId());
970 
971  // apply settings template
972  $this->applySettingsTemplate($tst);
973 
974  $tst->setQuestionSetType($form->getInput('qtype'));
975 
976  $tst->saveToDb();
977 
978  if($this->getTestType() == self::TEST_TYPE_IT)
979  {
980  $this->getSettings()->setInitialTest($tst->getRefId());
981  }
982  else
983  {
984  $this->getSettings()->setQualifiedTest($tst->getRefId());
985  }
986  $this->getSettings()->update();
987  }
988  else
989  {
990  if($this->getTestType() == self::TEST_TYPE_IT)
991  {
992  $this->getSettings()->setInitialTest($form->getInput('tst'));
993  }
994  else
995  {
996  $this->getSettings()->setQualifiedTest($form->getInput('tst'));
997  }
998 
999  $this->getSettings()->update();
1000  $tst = new ilObjTest($settings->getTestByType($this->getTestType()),true);
1001  $this->applySettingsTemplate($tst);
1002  $tst->saveToDb();
1003  }
1004 
1005  $this->updateStartObjects();
1006 
1007  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
1008  $this->ctrl->redirect($this,'testOverview');
1009  }
1010 
1011  // Error
1012  ilUtil::sendFailure($this->lng->txt('err_check_input'));
1013  $form->setValuesByPost();
1014  $this->testSettings($form);
1015  }
1016 
1020  protected function listObjectives()
1021  {
1022  global $ilToolbar;
1023 
1024  include_once './Modules/Course/classes/class.ilCourseObjectivesGUI.php';
1026 
1027 
1028  $GLOBALS['ilTabs']->activateSubTab('objectives');
1029 
1031  $this->getParentObject()->getId(),
1032  FALSE
1033  );
1034 
1035  if(!count($objectives))
1036  {
1037  return $this->showObjectiveCreation();
1038  }
1039 
1040  $ilToolbar->addButton(
1041  $this->lng->txt('crs_add_objective'),
1042  $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', "create"));
1043 
1044  include_once('./Modules/Course/classes/class.ilCourseObjectivesTableGUI.php');
1045  $table = new ilCourseObjectivesTableGUI($this,$this->getParentObject());
1046  $table->setTitle($this->lng->txt('crs_objectives'),'',$this->lng->txt('crs_objectives'));
1047  $table->parse($objectives);
1048  $GLOBALS['tpl']->setContent($table->getHTML());
1049 
1051  }
1052 
1057  protected function showObjectiveCreation(ilPropertyFormGUI $form = NULL)
1058  {
1059  $GLOBALS['ilTabs']->activateSubTab('objectives');
1060 
1061  if(!$form instanceof ilPropertyFormGUI)
1062  {
1063  $form = $this->initSimpleObjectiveForm();
1064  }
1065 
1066  $GLOBALS['tpl']->setContent($form->getHTML());
1067 
1069  }
1070 
1074  protected function initSimpleObjectiveForm()
1075  {
1076  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1077  $form = new ilPropertyFormGUI();
1078  $form->setTitle($this->lng->txt('crs_loc_form_create_objectives'));
1079  $form->setFormAction($this->ctrl->getFormAction($this));
1080 
1081  $txt = new ilTextWizardInputGUI($this->lng->txt('crs_objectives'), 'objectives');
1082  $txt->setValues(array(0 => ''));
1083  $txt->setRequired(true);
1084  $form->addItem($txt);
1085 
1086  $form->addCommandButton('saveObjectiveCreation', $this->lng->txt('save'));
1087 
1088  return $form;
1089  }
1090 
1091  protected function saveObjectiveCreation()
1092  {
1093  $form = $this->initSimpleObjectiveForm();
1094  if($form->checkInput())
1095  {
1096  foreach((array) $form->getInput('objectives') as $idx => $title)
1097  {
1098  include_once './Modules/Course/classes/class.ilCourseObjective.php';
1099  $obj = new ilCourseObjective($this->getParentObject());
1100  $obj->setActive(TRUE);
1101  $obj->setTitle($title);
1102  $obj->add();
1103  }
1104  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
1105  $this->ctrl->redirect($this,'');
1106  }
1107 
1108  $form->setValuesByPost();
1109  $GLOBALS['ilTabs']->activateSubTab('objectives');
1111  }
1112 
1119  protected function saveSorting()
1120  {
1121  global $ilAccess,$ilErr,$ilObjDataCache;
1122 
1123  asort($_POST['position'],SORT_NUMERIC);
1124 
1125  $counter = 1;
1126  foreach($_POST['position'] as $objective_id => $position)
1127  {
1128  include_once './Modules/Course/classes/class.ilCourseObjective.php';
1129  $objective = new ilCourseObjective($this->getParentObject(),$objective_id);
1130  $objective->writePosition($counter++);
1131  }
1132  ilUtil::sendSuccess($this->lng->txt('crs_objective_saved_sorting'));
1133  $this->listObjectives();
1134  }
1135 
1139  protected function askDeleteObjectives()
1140  {
1141  $GLOBALS['ilTabs']->activateSubTab('objectives');
1142 
1143  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
1144  $confirm = new ilConfirmationGUI();
1145  $confirm->setFormAction($this->ctrl->getFormAction($this));
1146  $confirm->setHeaderText($this->lng->txt('crs_delete_objectve_sure'));
1147  $confirm->setConfirm($this->lng->txt('delete'), 'deleteObjectives');
1148  $confirm->setCancel($this->lng->txt('cancel'), 'listObjectives');
1149 
1150  foreach($_POST['objective'] as $objective_id)
1151  {
1152  include_once './Modules/Course/classes/class.ilCourseObjective.php';
1153  $obj = new ilCourseObjective($this->getParentObject(),$objective_id);
1154  $name = $obj->getTitle();
1155 
1156  $confirm->addItem(
1157  'objective_ids[]',
1158  $objective_id,
1159  $name
1160  );
1161  }
1162  $GLOBALS['tpl']->setContent($confirm->getHTML());
1164  }
1165 
1169  protected function activateObjectives()
1170  {
1171  $enabled = (array) $_REQUEST['objective'];
1172 
1173  include_once './Modules/Course/classes/class.ilCourseObjective.php';
1174  $objectives = ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId(),false);
1175  foreach((array) $objectives as $objective_id)
1176  {
1177  $objective = new ilCourseObjective($this->getParentObject(),$objective_id);
1178  if(in_array($objective_id, $enabled))
1179  {
1180  $objective->setActive(true);
1181  $objective->update();
1182  }
1183  }
1184 
1185  include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
1187 
1188  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
1189  $this->ctrl->redirect($this,'listObjectives');
1190  }
1191 
1195  protected function deactivateObjectives()
1196  {
1197  $disabled = (array) $_REQUEST['objective'];
1198 
1199  include_once './Modules/Course/classes/class.ilCourseObjective.php';
1200  $objectives = ilCourseObjective::_getObjectiveIds($this->getParentObject()->getId(),false);
1201  foreach((array) $objectives as $objective_id)
1202  {
1203  $objective = new ilCourseObjective($this->getParentObject(),$objective_id);
1204  if(in_array($objective_id, $disabled))
1205  {
1206  $objective->setActive(false);
1207  $objective->update();
1208  }
1209  }
1210 
1211  include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
1213 
1214  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
1215  $this->ctrl->redirect($this,'listObjectives');
1216  }
1217 
1223  protected function deleteObjectives()
1224  {
1225  global $rbacsystem;
1226 
1227  foreach($_POST['objective_ids'] as $objective_id)
1228  {
1229  include_once './Modules/Course/classes/class.ilCourseObjective.php';
1230  $objective_obj = new ilCourseObjective($this->getParentObject(),$objective_id);
1231  $objective_obj->delete();
1232  }
1233 
1234  include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
1236 
1237  ilUtil::sendSuccess($this->lng->txt('crs_objectives_deleted'),true);
1238  $this->ctrl->redirect($this,'listObjectives');
1239 
1240  return true;
1241  }
1242 
1246  protected function showStatus($a_section)
1247  {
1248  include_once './Modules/Course/classes/Objectives/class.ilLOEditorStatus.php';
1249  $status = new ilLOEditorStatus($this->getParentObject());
1250  $status->setSection($a_section);
1251  $status->setCmdClass($this);
1252  $GLOBALS['tpl']->setRightContent($status->getHTML());
1253  }
1254 
1255 
1256 
1261  protected function setTabs($a_section = '')
1262  {
1263  // objective settings
1264  $GLOBALS['ilTabs']->addSubTab(
1265  'settings',
1266  $this->lng->txt('settings'),
1267  $this->ctrl->getLinkTarget($this,'settings')
1268  );
1269  // learning objectives
1270  $GLOBALS['ilTabs']->addSubTab(
1271  'objectives',
1272  $this->lng->txt('crs_loc_tab_objectives'),
1273  $this->ctrl->getLinkTarget($this,'listObjectives')
1274  );
1275  // materials
1276  /*
1277  $GLOBALS['ilTabs']->addTab(
1278  'materials',
1279  $this->lng->txt('crs_loc_tab_materials'),
1280  $this->ctrl->getLinkTarget($this,'materials')
1281  );
1282  */
1283  // tests
1285  if($settings->worksWithInitialTest())
1286  {
1287  if(
1288  $settings->getInitialTestType() == ilLOSettings::TYPE_INITIAL_PLACEMENT_ALL ||
1289  $settings->getInitialTestType() == ilLOSettings::TYPE_INITIAL_QUALIFYING_ALL
1290  )
1291  {
1292  $this->ctrl->setParameter($this,'tt', ilLOSettings::TYPE_TEST_INITIAL);
1293  $GLOBALS['ilTabs']->addSubTab(
1294  'itest',
1295  $this->lng->txt('crs_loc_tab_itest'),
1296  $this->ctrl->getLinkTarget($this,'testOverview')
1297  );
1298  }
1299  else
1300  {
1301  $this->ctrl->setParameter($this,'tt', ilLOSettings::TYPE_TEST_INITIAL);
1302  $GLOBALS['ilTabs']->addSubTab(
1303  'itests',
1304  $this->lng->txt('crs_loc_tab_itests'),
1305  $this->ctrl->getLinkTarget($this,'testsOverview')
1306  );
1307  }
1308 
1309 
1310 
1311  }
1312 
1313  if($settings->getQualifyingTestType() == ilLOSettings::TYPE_QUALIFYING_ALL)
1314  {
1315  $this->ctrl->setParameter($this,'tt', ilLOSettings::TYPE_TEST_QUALIFIED);
1316  $GLOBALS['ilTabs']->addSubTab(
1317  'qtest',
1318  $this->lng->txt('crs_loc_tab_qtest'),
1319  $this->ctrl->getLinkTarget($this,'testOverview')
1320  );
1321  }
1322  else
1323  {
1324  $this->ctrl->setParameter($this,'tt', ilLOSettings::TYPE_TEST_QUALIFIED);
1325  $GLOBALS['ilTabs']->addSubTab(
1326  'qtests',
1327  $this->lng->txt('crs_loc_tab_qtests'),
1328  $this->ctrl->getLinkTarget($this,'testsOverview')
1329  );
1330  }
1331 
1332  if($settings->worksWithStartObjects())
1333  {
1334  $GLOBALS['ilTabs']->addSubTab(
1335  'start',
1336  $this->lng->txt('crs_loc_tab_start'),
1337  $this->ctrl->getLinkTargetByClass('ilcontainerstartobjectsgui','')
1338  );
1339  }
1340 
1341  // Member view
1342  #include_once './Services/Container/classes/class.ilMemberViewGUI.php';
1343  #ilMemberViewGUI::showMemberViewSwitch($this->getParentObject()->getRefId());
1344  }
1345 }
1346 ?>
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
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.
$_POST['username']
Definition: cron.php:12
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.
saveSorting()
save position
Presentation of the status of single steps during the configuration process.
showObjectiveCreation(ilPropertyFormGUI $form=NULL)
Show objective creation form.
Class ilLOEditorGUI.
deleteAssignments($a_type)
Delete assignments.
$cmd
Definition: sahs_server.php:35
static _getObjectiveIds($course_id, $a_activated_only=false)
saveTest()
Save Test.
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.
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.
This class represents a property in a property form.
class ilobjcourseobjectivesgui
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.
activateObjectives()
activate chosen objectives
__construct($a_parent_obj)
Constructor.
$txt
Definition: error.php:12
(Course) learning objective page GUI class
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
deactivateObjectives()
activate chosen objectives
deleteTests()
Delete test assignments.
Settings for LO courses.
settings(ilPropertyFormGUI $form=NULL)
Objective Settings.
_refreshStatus($a_obj_id, $a_users=null)
Set dirty.
getContentStylePath($a_style_id)
get content style path
Render add new item selector.
Settings for LO courses.
showStatus($a_section)
Show status panel.
listObjectives()
List all abvailable objectives.
const TYPE_INITIAL_QUALIFYING_ALL
const TYPE_INITIAL_PLACEMENT_ALL
testSettings(ilPropertyFormGUI $form=NULL)
Show test settings.
const TYPE_QUALIFYING_SELECTED
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
This class represents a text wizard property in a property form.
confirmDeleteTests()
Show delete test confirmation.
testAssignment(ilPropertyFormGUI $form=null)
new test assignment
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
returnFromObjectives()
Return from objectives.
applySettingsTemplate(ilObjTest $tst)
Apply auto generated setttings template.
Settings template application class.
setRequired($a_required)
Set Required.
Class ilContainerStartObjectsGUI.
Confirmation screen class.
const TYPE_INITIAL_PLACEMENT_SELECTED