ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCourseObjectivesGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 // begin-patch lok
25 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
26 // end-patch lok
27 
37 {
38  const MODE_UNDEFINED = 0;
39  const MODE_CREATE = 1;
40  const MODE_UPDATE = 2;
41 
42 
43  var $ctrl;
44  var $ilias;
45  var $ilErr;
46  var $lng;
47  var $tpl;
48 
51 
52  // begin-patch lok
53  protected $settings;
54  protected $test_type = 0;
55  // end-patch lok
56 
57  function ilCourseObjectivesGUI($a_course_id)
58  {
59  include_once './Modules/Course/classes/class.ilCourseObjective.php';
60 
61  global $ilCtrl,$lng,$ilErr,$ilias,$tpl,$tree,$ilTabs;
62 
63  $this->ctrl =& $ilCtrl;
64  $this->ctrl->saveParameter($this,array("ref_id"));
65 
66  $this->ilErr =& $ilErr;
67  $this->lng =& $lng;
68  $this->lng->loadLanguageModule('crs');
69  $this->tpl =& $tpl;
70  $this->tree =& $tree;
71  $this->tabs_gui =& $ilTabs;
72 
73  $this->course_id = $a_course_id;
74  $this->__initCourseObject();
75 
76  // begin-patch lok
77  $this->settings = ilLOSettings::getInstanceByObjId($this->course_obj->getId());
78  // end-patch lok
79 
80  }
81 
85  function &executeCommand()
86  {
87  global $ilTabs;
88 
89  $ilTabs->setTabActive('crs_objectives');
90 
91  $cmd = $this->ctrl->getCmd();
92 
93 
94  if (!$cmd = $this->ctrl->getCmd())
95  {
96  $cmd = "list";
97  }
98 
99  $this->$cmd();
100  }
101 
102  // begin-patch lok
107  public function getSettings()
108  {
109  return $this->settings;
110  }
111  // end-patch lok
112 
113 
121  protected function listObjectives()
122  {
123  global $ilAccess,$ilErr,$ilObjDataCache,$ilToolbar;
124 
125  $_SESSION['objective_mode'] = self::MODE_UNDEFINED;
126  if(!$ilAccess->checkAccess("write",'',$this->course_obj->getRefId()))
127  {
128  $this->ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
129  }
130 
131  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.crs_objectives.html','Modules/Course');
132 
133  $ilToolbar->addButton($this->lng->txt('crs_add_objective'),
134  $this->ctrl->getLinkTarget($this, "'create"));
135 
136  include_once('./Modules/Course/classes/class.ilCourseObjectivesTableGUI.php');
137  $table = new ilCourseObjectivesTableGUI($this,$this->course_obj);
138  $table->setTitle($this->lng->txt('crs_objectives'),'',$this->lng->txt('crs_objectives'));
139  $table->parse(ilCourseObjective::_getObjectiveIds($this->course_obj->getId(),false));
140 
141  $this->tpl->setVariable('OBJECTIVES_TABLE',$table->getHTML());
142  }
143 
150  protected function saveSorting()
151  {
152  global $ilAccess,$ilErr,$ilObjDataCache;
153 
154  if(!$ilAccess->checkAccess("write",'',$this->course_obj->getRefId()))
155  {
156  $this->ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
157  }
158 
159  asort($_POST['position'],SORT_NUMERIC);
160 
161  $counter = 1;
162  foreach($_POST['position'] as $objective_id => $position)
163  {
164  $objective = new ilCourseObjective($this->course_obj,$objective_id);
165  $objective->writePosition($counter++);
166  }
167  ilUtil::sendSuccess($this->lng->txt('crs_objective_saved_sorting'));
168  $this->listObjectives();
169  }
170 
172  {
173  global $rbacsystem;
174 
175  // MINIMUM ACCESS LEVEL = 'write'
176  if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
177  {
178  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
179  }
180  if(!count($_POST['objective']))
181  {
182  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'));
183  $this->listObjectives();
184 
185  return true;
186  }
187 
188  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives.html",'Modules/Course');
189 
190  ilUtil::sendQuestion($this->lng->txt('crs_delete_objectve_sure'));
191 
192  $tpl =& new ilTemplate("tpl.table.html", true, true);
193  $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_delete_row.html",'Modules/Course');
194 
195  $counter = 0;
196  foreach($_POST['objective'] as $objective_id)
197  {
198  $objective_obj = $this->__initObjectivesObject($objective_id);
199 
200  $tpl->setCurrentBlock("tbl_content");
201  $tpl->setVariable("ROWCOL",ilUtil::switchColor(++$counter,"tblrow2","tblrow1"));
202  $tpl->setVariable("TITLE",$objective_obj->getTitle());
203  $tpl->setVariable("DESCRIPTION",$objective_obj->getDescription());
204  $tpl->parseCurrentBlock();
205  }
206 
207  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
208 
209  // Show action row
210  $tpl->setCurrentBlock("tbl_action_btn");
211  $tpl->setVariable("BTN_NAME",'deleteObjectives');
212  $tpl->setVariable("BTN_VALUE",$this->lng->txt('delete'));
213  $tpl->parseCurrentBlock();
214 
215  $tpl->setCurrentBlock("tbl_action_btn");
216  $tpl->setVariable("BTN_NAME",'listObjectives');
217  $tpl->setVariable("BTN_VALUE",$this->lng->txt('cancel'));
218  $tpl->parseCurrentBlock();
219 
220  $tpl->setCurrentBlock("tbl_action_row");
221  $tpl->setVariable("COLUMN_COUNTS",1);
222  $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.svg'));
223  $tpl->parseCurrentBlock();
224 
225 
226  // create table
227  $tbl = new ilTableGUI();
228  $tbl->setStyle('table','std');
229 
230  // title & header columns
231  $tbl->setTitle($this->lng->txt("crs_objectives"),"",$this->lng->txt("crs_objectives"));
232 
233  $tbl->setHeaderNames(array($this->lng->txt("title")));
234  $tbl->setHeaderVars(array("title"),
235  array("ref_id" => $this->course_obj->getRefId(),
236  "cmdClass" => "ilcourseobjectivesgui",
237  "cmdNode" => $_GET["cmdNode"]));
238  $tbl->setColumnWidth(array("50%"));
239 
240  $tbl->setLimit($_GET["limit"]);
241  $tbl->setOffset($_GET["offset"]);
242  $tbl->setMaxCount(count($_POST['objective']));
243 
244  // footer
245  $tbl->disable("footer");
246  $tbl->disable('sort');
247 
248  // render table
249  $tbl->setTemplate($tpl);
250  $tbl->render();
251 
252  $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
253 
254 
255  // Save marked objectives
256  $_SESSION['crs_delete_objectives'] = $_POST['objective'];
257 
258  return true;
259  }
260 
261  function deleteObjectives()
262  {
263  global $rbacsystem;
264 
265  // MINIMUM ACCESS LEVEL = 'write'
266  if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
267  {
268  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
269  }
270  if(!count($_SESSION['crs_delete_objectives']))
271  {
272  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'));
273  $this->listObjectives();
274 
275  return true;
276  }
277 
278  foreach($_SESSION['crs_delete_objectives'] as $objective_id)
279  {
280  $objective_obj =& $this->__initObjectivesObject($objective_id);
281  $objective_obj->delete();
282  }
283 
284  ilUtil::sendSuccess($this->lng->txt('crs_objectives_deleted'));
285  $this->listObjectives();
286 
287  return true;
288  }
289 
296  protected function questionOverview()
297  {
298  global $ilAccess,$ilErr,$ilTabs;
299 
300  $ilTabs->setSubTabActive('crs_objective_overview_question_assignment');
301 
302  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
303  {
304  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
305  }
306 
307  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestionsTableGUI.php');
308  $table = new ilCourseObjectiveQuestionsTableGUI($this,$this->course_obj);
309  $table->setTitle($this->lng->txt('crs_objectives_edit_question_assignments'),'',$this->lng->txt('crs_objectives'));
310  // begin-patch lok
311  $table->parse(ilCourseObjective::_getObjectiveIds($this->course_obj->getId(),false));
312  // end-patch lok
313 
314  $this->tpl->setContent($table->getHTML());
315  }
316 
323  protected function saveQuestionOverview()
324  {
325  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
326 
327  global $ilAccess,$ilErr;
328 
329  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
330  {
331  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
332  }
333  $error = false;
334 
335  $_POST['self'] = $_POST['self'] ? $_POST['self'] : array();
336  $_POST['final'] = $_POST['final'] ? $_POST['final'] : array();
337 
338  foreach($_POST['self'] as $objective_id => $limit)
339  {
340  $qst = new ilCourseObjectiveQuestion($objective_id);
341  $max_points = $qst->getSelfAssessmentPoints();
342 
343  if($limit < 0 or $limit > $max_points)
344  {
345  ilUtil::sendFailure($this->lng->txt('crs_objective_limit_err'));
346  $this->questionOverview();
347  return false;
348  }
349  }
350  foreach($_POST['final'] as $objective_id => $limit)
351  {
352  $qst = new ilCourseObjectiveQuestion($objective_id);
353  $max_points = $qst->getFinalTestPoints();
354 
355  if($limit < 0 or $limit > $max_points)
356  {
357  ilUtil::sendFailure($this->lng->txt('crs_objective_limit_err'));
358  $this->questionOverview();
359  return false;
360  }
361  }
362 
363  foreach($_POST['self'] as $objective_id => $limit)
364  {
366  }
367 
368  foreach($_POST['final'] as $objective_id => $limit)
369  {
371  }
372 
373  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
374  $this->questionOverview();
375  return true;
376  }
377 
378  // PRIVATE
380  {
381  if(!$this->course_obj =& ilObjectFactory::getInstanceByRefId($this->course_id,false))
382  {
383  $this->ilErr->raiseError("ilCourseObjectivesGUI: cannot create course object",$this->ilErr->MESSAGE);
384  exit;
385  }
386  return true;
387  }
388 
389  function __initObjectivesObject($a_id = 0)
390  {
391  return $this->objectives_obj = new ilCourseObjective($this->course_obj,$a_id);
392  }
393 
394  function __initLMObject($a_objective_id = 0)
395  {
396  include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
397  $this->objectives_lm_obj =& new ilCourseObjectiveMaterials($a_objective_id);
398 
399  return true;
400  }
401 
402  // begin-patch lok
408  function __initQuestionObject($a_objective_id = 0)
409  {
410  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
411  $this->objectives_qst_obj =& new ilCourseObjectiveQuestion($a_objective_id);
412 
413  return $this->objectives_qst_obj;
414  }
415  // end-patch lok
416 
420  function setSubTabs($a_active = "")
421  {
422  global $ilTabs, $ilHelp;
423 
424  if ($a_active != "")
425  {
426  $ilHelp->setScreenIdComponent("crs");
427  $ilHelp->setScreenId("crs_objective");
428  $ilHelp->setSubScreenId($a_active);
429  }
430 
431 
432  // begin-patch lok
433  // no subtabs here
434  return true;
435  // end-patch lok
436 
437 
438  $ilTabs->addSubTabTarget("crs_objective_overview_objectives",
439  $this->ctrl->getLinkTarget($this, "listObjectives"),
440  array("listObjectives", "moveObjectiveUp", "moveObjectiveDown", "listAssignedLM"),
441  array(),
442  '',
443  true);
444  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
445 
446  if(ilCourseObjectiveQuestion::_hasTests($this->course_obj->getId()))
447  {
448  $ilTabs->addSubTabTarget("crs_objective_overview_question_assignment",
449  $this->ctrl->getLinkTarget($this, "questionOverview"),
450  "editQuestionAssignment",
451  array(),
452  '',
453  false);
454  }
455  }
456 
457 
465  public function create()
466  {
467  global $tpl;
468 
469  $this->setSubTabs("create_obj");
470 
471  $_SESSION['objective_mode'] = self::MODE_CREATE;
472 
473  $this->ctrl->saveParameter($this,'objective_id');
474 
475  if(!is_object($this->objective))
476  {
477  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
478  }
479  $this->__initQuestionObject((int) $_GET['objective_id']);
480  $this->initWizard(1);
481 
482  $this->initFormTitle('create',1);
483  $GLOBALS['tpl']->setContent($this->form->getHtml());
484  #$w_tpl->setVariable('WIZ_CONTENT',$this->form->getHtml());
485  #$tpl->setContent($w_tpl->get());
486  }
487 
494  protected function edit()
495  {
496  global $tpl;
497 
498  $_SESSION['objective_mode'] = self::MODE_UPDATE;
499 
500  $this->setSubTabs("edit_obj");
501 
502  $this->ctrl->setParameter($this,'objective_id',(int) $_REQUEST['objective_id']);
503 
504  if(!$_REQUEST['objective_id'])
505  {
506  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
507  $this->ctrl->redirect($this,'listObjectives');
508  }
509 
510  if(!is_object($this->objective))
511  {
512  $this->objective = new ilCourseObjective($this->course_obj,(int) $_REQUEST['objective_id']);
513  }
514 
515  $this->__initQuestionObject((int) $_REQUEST['objective_id']);
516  $this->initWizard(1);
517  $this->initFormTitle('create',1);
518  $GLOBALS['tpl']->setContent($this->form->getHtml());
519  #$w_tpl->setVariable('WIZ_CONTENT',$this->form->getHtml());
520  #$tpl->setContent($w_tpl->get());
521  }
522 
529  protected function save()
530  {
531  global $ilAccess,$ilErr;
532 
533  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
534  {
535  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
536  }
537 
538  $this->ctrl->saveParameter($this,'objective_id');
539 
540  $this->objective = new ilCourseObjective($this->course_obj,(int) $_REQUEST['objective_id']);
541  $this->initFormTitle('create', 1);
542  if($this->form->checkInput())
543  {
544  $this->objective->setTitle($this->form->getInput('title'));
545  $this->objective->setDescription($this->form->getInput('description'));
546  $this->objective->setPasses(0);
547 
548  if(!$_GET['objective_id'])
549  {
550  $objective_id = $this->objective->add();
551  ilUtil::sendSuccess($this->lng->txt('crs_added_objective'),true);
552  }
553  else
554  {
555  $this->objective->update();
556  ilUtil::sendSuccess($this->lng->txt('crs_objective_modified'),true);
557  $objective_id = $_GET['objective_id'];
558  }
559  }
560  else
561  {
562  $this->form->setValuesByPost();
563  return $this->edit();
564  }
565 
566  if($_SESSION['objective_mode'] != self::MODE_CREATE)
567  {
568  $this->ctrl->returnToParent($this);
569  }
570 
571  $this->ctrl->setParameter($this,'objective_id',$objective_id);
572  $this->ctrl->redirect($this,'materialAssignment');
573  return true;
574  }
575 
582  protected function materialAssignment()
583  {
584  global $ilAccess,$ilErr,$tpl;
585 
586  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
587  {
588  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
589  }
590  if(!$_GET['objective_id'])
591  {
592  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
593  $this->ctrl->redirect($this,'listObjectives');
594  }
595 
596  $this->setSubTabs("materials");
597 
598  $this->ctrl->saveParameter($this,'objective_id');
599 
600  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
601 
602  include_once('./Modules/Course/classes/class.ilCourseObjectiveMaterialAssignmentTableGUI.php');
603  $table = new ilCourseObjectiveMaterialAssignmentTableGUI($this,$this->course_obj,(int) $_GET['objective_id']);
604  $table->setTitle($this->lng->txt('crs_objective_wiz_materials'),
605  '',$this->lng->txt('crs_objectives'));
606 
607  include_once('Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
608  $table->parse(ilCourseObjectiveMaterials::_getAssignableMaterials($this->course_obj->getRefId()));
609 
610  $this->__initQuestionObject((int) $_GET['objective_id']);
611  $this->initWizard(2);
612  #$w_tpl->setVariable('WIZ_CONTENT',$table->getHTML());
613  $GLOBALS['tpl']->setContent($table->getHTML());
614  #$tpl->setContent($w_tpl->get());
615  }
616 
624  protected function updateMaterialAssignment()
625  {
626  global $ilAccess,$ilErr,$ilObjDataCache;
627 
628  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
629  {
630  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
631  }
632  if(!$_GET['objective_id'])
633  {
634  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
635  $this->ctrl->redirect($this,'listObjectives');
636  }
637 
638  $this->__initLMObject((int) $_GET['objective_id']);
639  $this->objectives_lm_obj->deleteAll();
640 
641  if(is_array($_POST['materials']))
642  {
643  foreach($_POST['materials'] as $node_id)
644  {
645  $obj_id = $ilObjDataCache->lookupObjId($node_id);
646  $type = $ilObjDataCache->lookupType($obj_id);
647 
648  $this->objectives_lm_obj->setLMRefId($node_id);
649  $this->objectives_lm_obj->setLMObjId($obj_id);
650  $this->objectives_lm_obj->setType($type);
651  $this->objectives_lm_obj->add();
652  }
653  }
654  if(is_array($_POST['chapters']))
655  {
656  foreach($_POST['chapters'] as $chapter)
657  {
658  include_once('./Modules/LearningModule/classes/class.ilLMObject.php');
659 
660  list($ref_id,$chapter_id) = explode('_',$chapter);
661 
662  $this->objectives_lm_obj->setLMRefId($ref_id);
663  $this->objectives_lm_obj->setLMObjId($chapter_id);
664  $this->objectives_lm_obj->setType(ilLMObject::_lookupType($chapter_id));
665  $this->objectives_lm_obj->add();
666  }
667  }
668  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
669 
670 
671  if($_SESSION['objective_mode'] != self::MODE_CREATE)
672  {
673  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'),true);
674  $this->ctrl->returnToParent($this);
675  }
676 
677  // begin-patch lok
678  if($this->getSettings()->worksWithInitialTest())
679  {
680  $this->selfAssessmentAssignment();
681  }
682  else
683  {
684  $this->finalTestAssignment();
685  }
686  // end-patch lok
687  }
688 
695  protected function selfAssessmentAssignment()
696  {
697  global $ilAccess,$ilErr,$tpl;
698 
699  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
700  {
701  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
702  }
703  if(!$_GET['objective_id'])
704  {
705  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
706  $this->ctrl->redirect($this,'listObjectives');
707  }
708 
709  $this->setSubTabs("self_ass_assign");
710 
711  $this->ctrl->saveParameter($this,'objective_id');
712 
713  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
714 
715  // begin-patch lok
716  $this->ctrl->setParameter($this,'tt',ilLOSettings::TYPE_TEST_INITIAL);
717  $this->test_type = $_REQUEST['tt'] = ilLOSettings::TYPE_TEST_INITIAL;
719  {
720  return $this->showRandomTestAssignment();
721  }
722  // end-patch lok
723 
724  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestionAssignmentTableGUI.php');
726  $this->course_obj,
727  (int) $_GET['objective_id'],
729  $table->setTitle($this->lng->txt('crs_objective_wiz_self'),
730  '',$this->lng->txt('crs_objective'));
731  $table->parse(ilCourseObjectiveQuestion::_getAssignableTests($this->course_obj->getRefId()));
732 
733  $this->__initQuestionObject((int) $_GET['objective_id']);
734  $this->initWizard(3);
735  $GLOBALS['tpl']->setContent($table->getHTML());
736  #$w_tpl->setVariable('WIZ_CONTENT',$table->getHTML());
737  #$tpl->setContent($w_tpl->get());
738  }
739 
747  protected function updateSelfAssessmentAssignment()
748  {
749  global $ilAccess,$ilErr,$ilObjDataCache;
750 
751  $checked_questions = $_POST['questions'] ? $_POST['questions'] : array();
752 
753 
754  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
755  {
756  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
757  }
758  if(!$_GET['objective_id'])
759  {
760  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
761  $this->ctrl->redirect($this,'listObjectives');
762  }
763 
764  $this->__initQuestionObject((int) $_GET['objective_id']);
765 
766  // Delete unchecked
767  foreach($this->objectives_qst_obj->getSelfAssessmentQuestions() as $question)
768  {
769  $id = $question['ref_id'].'_'.$question['question_id'];
770  if(!in_array($id,$checked_questions))
771  {
772  $this->objectives_qst_obj->delete($question['qst_ass_id']);
773  }
774  }
775  // Add checked
776  foreach($checked_questions as $question_id)
777  {
778  list($test_ref_id,$qst_id) = explode('_',$question_id);
779  $test_obj_id = $ilObjDataCache->lookupObjId($test_ref_id);
780 
781  if($this->objectives_qst_obj->isSelfAssessmentQuestion($qst_id))
782  {
783  continue;
784  }
785  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_SELF_ASSESSMENT);
786  $this->objectives_qst_obj->setTestRefId($test_ref_id);
787  $this->objectives_qst_obj->setTestObjId($test_obj_id);
788  $this->objectives_qst_obj->setQuestionId($qst_id);
789  $this->objectives_qst_obj->add();
790  }
791 
792  // TODO: not nice
793  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
794  $this->questions = new ilCourseObjectiveQuestion((int) $_GET['objective_id']);
795  // not required due to percentages
796  //$this->questions->updateLimits();
797 
798  if($checked_questions)
799  {
800  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
801  $this->selfAssessmentLimits();
802  return true;
803  }
804  else
805  {
806  switch($_SESSION['objective_mode'])
807  {
808  case self::MODE_CREATE:
809  $this->finalTestAssignment();
810  return true;
811 
812  case self::MODE_UPDATE:
813  $this->selfAssessmentAssignment();
814  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
815  return true;
816  }
817  }
818  }
819 
827  protected function selfAssessmentLimits()
828  {
829  global $ilAccess,$ilErr,$tpl;
830 
831  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
832  {
833  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
834  }
835  if(!$_GET['objective_id'])
836  {
837  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
838  $this->ctrl->redirect($this,'listObjectives');
839  }
840 
841  $this->setSubTabs("self_ass_limits");
842 
843  $this->ctrl->saveParameter($this,'objective_id');
844  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
845 
846  $this->__initQuestionObject((int) $_GET['objective_id']);
847  $this->initWizard(4);
848 
849  $this->initFormLimits('selfAssessment');
850  $GLOBALS['tpl']->setContent($this->form->getHtml());
851  #$w_tpl->setVariable('WIZ_CONTENT',$this->form->getHtml());
852  #$tpl->setContent($w_tpl->get());
853  }
854 
862  protected function updateSelfAssessmentLimits()
863  {
864  global $ilAccess,$ilErr,$ilObjDataCache;
865 
866  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
867  {
868  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
869  }
870  if(!$_GET['objective_id'])
871  {
872  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
873  $this->ctrl->redirect($this,'listObjectives');
874  }
875 
876  $this->__initQuestionObject((int) $_GET['objective_id']);
877 
878  if((int) $_POST['limit'] < 1 or (int) $_POST['limit'] > 100)
879  {
880  ilUtil::sendFailure($this->lng->txt('crs_objective_err_limit'));
881  $this->selfAssessmentLimits();
882  return false;
883  }
884 
885  foreach($this->objectives_qst_obj->getSelfAssessmentTests() as $test)
886  {
887  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_SELF_ASSESSMENT);
888  $this->objectives_qst_obj->setTestSuggestedLimit((int) $_POST['limit']);
889  $this->objectives_qst_obj->updateTest($test['test_objective_id']);
890  }
891 
892  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
893  $this->finalTestAssignment();
894 
895  }
896 
897 
905  protected function finalTestAssignment()
906  {
907  global $ilAccess,$ilErr,$tpl;
908 
909  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
910  {
911  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
912  }
913  if(!$_GET['objective_id'])
914  {
915  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
916  $this->ctrl->redirect($this,'listObjectives');
917  }
918 
919  $this->setSubTabs("final_test_assign");
920 
921  $this->ctrl->saveParameter($this,'objective_id');
922  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
923 
924  // begin-patch lok
925  $this->ctrl->setParameter($this,'tt',ilLOSettings::TYPE_TEST_QUALIFIED);
926  $this->test_type = $_REQUEST['tt'] = ilLOSettings::TYPE_TEST_QUALIFIED;
928  {
929  return $this->showRandomTestAssignment();
930  }
931  // end-patch lok
932 
933  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestionAssignmentTableGUI.php');
935  $this->course_obj,
936  (int) $_GET['objective_id'],
938 
939  $table->setTitle($this->lng->txt('crs_objective_wiz_final'),
940  '',$this->lng->txt('crs_objective'));
941  $table->parse(ilCourseObjectiveQuestion::_getAssignableTests($this->course_obj->getRefId()));
942 
943  $this->__initQuestionObject((int) $_GET['objective_id']);
944  $this->initWizard(5);
945  $GLOBALS['tpl']->setContent($table->getHTML());
946  #$w_tpl->setVariable('WIZ_CONTENT',$table->getHTML());
947  #$tpl->setContent($w_tpl->get());
948  }
949 
950  // begin-patch lok
951  protected function isRandomTestType($a_tst_type = 0)
952  {
953  if(!$a_tst_type)
954  {
955  $a_tst_type = $this->test_type;
956  }
957 
958  $tst_ref_id = $this->getSettings()->getTestByType($a_tst_type);
959  if(!$tst_ref_id)
960  {
961  return false;
962  }
963  include_once './Modules/Test/classes/class.ilObjTest.php';
965  }
966 
971  protected function showRandomTestAssignment(ilPropertyFormGUI $form = null)
972  {
973  $this->ctrl->saveParameter($this,'objective_id');
974  $this->ctrl->setParameter($this,'tt', (int) $_REQUEST['tt']);
975  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
976  $this->test_type = (int) $_REQUEST['tt'];
977 
978 
979  $this->setSubTabs("rand_test_assign");
980 
981  if(!$form instanceof ilPropertyFormGUI)
982  {
983  $form = $this->initFormRandom();
984  }
985 
986  $this->__initQuestionObject((int) $_GET['objective_id']);
987  $this->initWizard(5);
988  $GLOBALS['tpl']->setContent($form->getHTML());
989  #$w_tpl->setVariable('WIZ_CONTENT',$form->getHTML());
990 
991  #$GLOBALS['tpl']->setContent($w_tpl->get());
992  }
993 
997  protected function initFormRandom()
998  {
999  include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
1000  $rnd = new ilLORandomTestQuestionPools(
1001  $this->course_obj->getId(),
1002  (int) $_REQUEST['objective_id'],
1003  $this->test_type
1004  );
1005 
1006  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1007  $form = new ilPropertyFormGUI();
1008  $form->setFormAction($this->ctrl->getFormAction($this));
1009 
1010  if($this->test_type == ilLOSettings::TYPE_TEST_INITIAL)
1011  {
1012  $form->setTitle($this->lng->txt('crs_loc_form_random_limits_it'));
1013  }
1014  else
1015  {
1016  $form->setTitle($this->lng->txt('crs_loc_form_random_limits_qt'));
1017  }
1018 
1019  $form->addCommandButton('saveRandom', $this->lng->txt('save'));
1020 
1021  $options = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_rand_assign_qpl'),'type');
1022  $options->setValue(1);
1023  $options->setRequired(true);
1024 
1025  $ass_qpl = new ilRadioOption($this->lng->txt('crs_loc_rand_assign_qpl'),1);
1026  $options->addOption($ass_qpl);
1027 
1028  $qpl = new ilSelectInputGUI($this->lng->txt('crs_loc_rand_qpl'),'qpl');
1029  $qpl->setOptions($this->getRandomTestQplOptions());
1030  $qpl->setValue($rnd->getQplSequence());
1031  $ass_qpl->addSubItem($qpl);
1032 
1033  #$num = new ilNumberInputGUI($this->lng->txt('crs_loc_num_qst'),'num_qst');
1034  #$num->setSize(3);
1035  #$num->setMinValue(1);
1036  #$num->setRequired(true);
1037  #$ass_qpl->addSubItem($num);
1038 
1039  // points
1040  $per = new ilNumberInputGUI($this->lng->txt('crs_loc_perc'),'per');
1041  $per->setValue($rnd->getLimit());
1042  $per->setSize(3);
1043  $per->setMinValue(1);
1044  $per->setMaxValue(100);
1045  $per->setRequired(true);
1046  $ass_qpl->addSubItem($per);
1047 
1048  $form->addItem($options);
1049  return $form;
1050  }
1051 
1052 
1053  protected function getRandomTestQplOptions()
1054  {
1055  include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionFactory.php';
1056  include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionList.php';
1057 
1058  $tst_ref_id = $this->getSettings()->getTestByType($this->test_type);
1059  if($tst_ref_id)
1060  {
1061  $tst = ilObjectFactory::getInstanceByRefId($tst_ref_id,false);
1062  }
1063  if(!$tst instanceof ilObjTest)
1064  {
1065  return array();
1066  }
1068  $GLOBALS['ilDB'],
1069  $tst,
1071  $GLOBALS['ilDB'],
1072  $tst
1073  )
1074  );
1075 
1076  $list->loadDefinitions();
1077 
1078  include_once './Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php';
1079  $translater = new ilTestTaxonomyFilterLabelTranslater($GLOBALS['ilDB']);
1080  $translater->loadLabels($list);
1081 
1082  $options[0] = $this->lng->txt('select_one');
1083  foreach ($list as $definition)
1084  {
1085  $title = $definition->getPoolTitle();
1086  $tax_id = $definition->getMappedFilterTaxId();
1087  if($tax_id)
1088  {
1089  $title .= (' -> '. $translater->getTaxonomyTreeLabel($tax_id));
1090  }
1091  $tax_node = $definition->getMappedFilterTaxNodeId();
1092  if($tax_node)
1093  {
1094  $title .= (' -> ' .$translater->getTaxonomyNodeLabel($tax_node));
1095  }
1096  $options[$definition->getId()] = $title;
1097  }
1098  return $options;
1099  }
1100 
1104  protected function saveRandom()
1105  {
1106  $this->ctrl->saveParameter($this,'objective_id');
1107  $this->ctrl->setParameter($this,'tt',(int) $_REQUEST['tt']);
1108  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
1109  $this->test_type = (int) $_REQUEST['tt'];
1110 
1111  $form = $this->initFormRandom();
1112  if($form->checkInput())
1113  {
1114  $qst = $this->__initQuestionObject((int) $_GET['objective_id']);
1115  $qst->deleteByTestType(
1116  ($this->test_type == ilLOSettings::TYPE_TEST_INITIAL) ?
1119  );
1120  $ref_id = $this->getSettings()->getTestByType($this->test_type);
1121 
1122  include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
1123  $rnd = new ilLORandomTestQuestionPools(
1124  $this->course_obj->getId(),
1125  (int) $_REQUEST['objective_id'],
1126  $this->test_type
1127  );
1128  $rnd->delete();
1129  $rnd->setLimit($form->getInput('per'));
1130  $rnd->setQplSequence($form->getInput('qpl'));
1131  $rnd->setTestId(ilObject::_lookupObjId($ref_id));
1132  $rnd->create();
1133  }
1134  else
1135  {
1136  $form->setValuesByPost();
1137  ilUtil::sendFailure($this->lng->txt('err_check_input'));
1138  return $this->showRandomTestAssignment();
1139  }
1140 
1141  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
1142  if($this->test_type == ilLOSettings::TYPE_TEST_QUALIFIED)
1143  {
1144  $this->ctrl->returnToParent($this);
1145  }
1146  else
1147  {
1148  $this->ctrl->redirect($this,'finalTestAssignment');
1149  }
1150  }
1151 
1159  protected function updateFinalTestAssignment()
1160  {
1161  global $ilAccess,$ilErr,$ilObjDataCache;
1162 
1163  $checked_questions = $_POST['questions'] ? $_POST['questions'] : array();
1164 
1165 
1166  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
1167  {
1168  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
1169  }
1170  if(!$_GET['objective_id'])
1171  {
1172  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
1173  $this->ctrl->redirect($this,'listObjectives');
1174  }
1175 
1176  $this->__initQuestionObject((int) $_GET['objective_id']);
1177 
1178  // Delete unchecked
1179  foreach($this->objectives_qst_obj->getFinalTestQuestions() as $question)
1180  {
1181  $id = $question['ref_id'].'_'.$question['question_id'];
1182  if(!in_array($id,$checked_questions))
1183  {
1184  $this->objectives_qst_obj->delete($question['qst_ass_id']);
1185  }
1186  }
1187  // Add checked
1188  foreach($checked_questions as $question_id)
1189  {
1190  list($test_ref_id,$qst_id) = explode('_',$question_id);
1191  $test_obj_id = $ilObjDataCache->lookupObjId($test_ref_id);
1192 
1193  if($this->objectives_qst_obj->isFinalTestQuestion($qst_id))
1194  {
1195  continue;
1196  }
1197 
1198  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_FINAL_TEST);
1199  $this->objectives_qst_obj->setTestRefId($test_ref_id);
1200  $this->objectives_qst_obj->setTestObjId($test_obj_id);
1201  $this->objectives_qst_obj->setQuestionId($qst_id);
1202  $this->objectives_qst_obj->add();
1203  }
1204 
1205  // TODO: not nice
1206  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
1207  $this->questions = new ilCourseObjectiveQuestion((int) $_GET['objective_id']);
1208  // not required due to percentages
1209  //$this->questions->updateLimits();
1210 
1211  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
1212  $this->finalTestLimits();
1213  }
1214 
1222  protected function finalTestLimits()
1223  {
1224  global $ilAccess,$ilErr,$tpl;
1225 
1226  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
1227  {
1228  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
1229  }
1230  if(!$_GET['objective_id'])
1231  {
1232  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
1233  $this->ctrl->redirect($this,'listObjectives');
1234  }
1235 
1236  $this->setSubTabs("final_test_limits");
1237 
1238  $this->ctrl->saveParameter($this,'objective_id');
1239  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
1240 
1241  $this->__initQuestionObject((int) $_GET['objective_id']);
1242  $this->initWizard(6);
1243 
1244  $this->initFormLimits('final');
1245  $GLOBALS['tpl']->setContent($this->form->getHtml());
1246 
1247  #$w_tpl->setVariable('WIZ_CONTENT',$this->form->getHtml());
1248  #$tpl->setContent($w_tpl->get());
1249  }
1250 
1258  protected function updateFinalTestLimits()
1259  {
1260  global $ilAccess,$ilErr,$ilObjDataCache;
1261 
1262  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
1263  {
1264  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
1265  }
1266  if(!$_GET['objective_id'])
1267  {
1268  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
1269  $this->ctrl->redirect($this,'listObjectives');
1270  }
1271 
1272  $this->__initQuestionObject((int) $_GET['objective_id']);
1273 
1274  if((int) $_POST['limit'] < 1 or (int) $_POST['limit'] > 100)
1275  {
1276  ilUtil::sendFailure($this->lng->txt('crs_objective_err_limit'));
1277  $this->finalTestLimits();
1278  return false;
1279  }
1280 
1281  foreach($this->objectives_qst_obj->getFinalTests() as $test)
1282  {
1283  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_FINAL_TEST);
1284  $this->objectives_qst_obj->setTestSuggestedLimit((int) $_POST['limit']);
1285  $this->objectives_qst_obj->updateTest($test['test_objective_id']);
1286  }
1287 
1288  if($_SESSION['objective_mode'] != self::MODE_CREATE)
1289  {
1290  ilUtil::sendSuccess($this->lng->txt('settings_saved'), TRUE);
1291  }
1292  else
1293  {
1294  ilUtil::sendSuccess($this->lng->txt('crs_added_objective'),TRUE);
1295  }
1296  $this->ctrl->returnToParent($this);
1297  }
1298 
1306  protected function initFormLimits($a_mode)
1307  {
1308  if(!is_object($this->form))
1309  {
1310  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
1311  $this->form = new ilPropertyFormGUI();
1312  }
1313  $this->form->setFormAction($this->ctrl->getFormAction($this));
1314  $this->form->setTableWidth('100%');
1315  //$this->form->setTitleIcon(ilUtil::getImagePath('icon_lobj.svg'),$this->lng->txt('crs_objective'));
1316 
1317  switch($a_mode)
1318  {
1319  case 'selfAssessment':
1320  $this->form->setTitle($this->lng->txt('crs_objective_wiz_self_limit'));
1321  $this->form->addCommandButton('updateSelfAssessmentLimits',$this->lng->txt('crs_wiz_next'));
1322  $this->form->addCommandButton('selfAssessmentAssignment',$this->lng->txt('crs_wiz_back'));
1323 
1324  $tests = $this->objectives_qst_obj->getSelfAssessmentTests();
1325  $max_points = $this->objectives_qst_obj->getSelfAssessmentPoints();
1326 
1327  break;
1328 
1329  case 'final':
1330  $this->form->setTitle($this->lng->txt('crs_objective_wiz_final_limit'));
1331  $this->form->addCommandButton('updateFinalTestLimits',$this->lng->txt('crs_wiz_next'));
1332  $this->form->addCommandButton('finalTestAssignment',$this->lng->txt('crs_wiz_back'));
1333 
1334  $tests = $this->objectives_qst_obj->getFinalTests();
1335  $max_points = $this->objectives_qst_obj->getFinalTestPoints();
1336 
1337  break;
1338  }
1339 
1340  $over = new ilCustomInputGUI($this->lng->txt('crs_objective_qst_summary'),'');
1341 
1342  $tpl = new ilTemplate('tpl.crs_objective_qst_summary.html',true,true,'Modules/Course');
1343 
1344 
1345  $limit = 0;
1346 
1347  foreach($tests as $test)
1348  {
1349  $GLOBALS['ilLog']->write(__METHOD__.': '.print_r($test,TRUE));
1350 
1351  $limit = $test['limit'];
1352 
1353  foreach($this->objectives_qst_obj->getQuestionsOfTest($test['obj_id']) as $question)
1354  {
1355  $tpl->setCurrentBlock('qst');
1356  $tpl->setVariable('QST_TITLE',$question['title']);
1357  if(strlen($question['description']))
1358  {
1359  $tpl->setVariable('QST_DESCRIPTION',$question['description']);
1360  }
1361  $tpl->setVariable('QST_POINTS',$question['points'].' '.
1362  $this->lng->txt('crs_objective_points'));
1363  $tpl->parseCurrentBlock();
1364  }
1365  $tpl->setCurrentBlock('tst');
1366  $tpl->setVariable('TST_TITLE',ilObject::_lookupTitle($test['obj_id']));
1367  if($desc = ilObject::_lookupDescription($test['obj_id']))
1368  {
1369  $tpl->setVariable('TST_DESC',$desc);
1370  }
1371  $tpl->setVariable('TST_TYPE_IMG',ilUtil::getTypeIconPath('tst',$test['obj_id'],'tiny'));
1372  $tpl->setVariable('TST_ALT_IMG',$this->lng->txt('obj_tst'));
1373  $tpl->parseCurrentBlock();
1374  }
1375 
1376  $tpl->setVariable('TXT_ALL_POINTS',$this->lng->txt('crs_objective_all_points'));
1377  $tpl->setVariable('TXT_POINTS',$this->lng->txt('crs_objective_points'));
1378  $tpl->setVariable('POINTS',$max_points);
1379 
1380  $over->setHtml($tpl->get());
1381  $this->form->addItem($over);
1382 
1383  // points
1384  $req = new ilNumberInputGUI($this->lng->txt('crs_loc_perc'),'limit');
1385  $req->setValue($limit);
1386  $req->setSize(3);
1387  $req->setMinValue(1);
1388  $req->setMaxValue(100);
1389  $req->setRequired(true);
1390  switch($a_mode)
1391  {
1392  case 'selfAssessment':
1393  $req->setInfo($this->lng->txt('crs_obj_initial_req_info'));
1394  break;
1395 
1396  case 'final':
1397  $req->setInfo($this->lng->txt('crs_obj_final_req_info'));
1398  break;
1399  }
1400  $this->form->addItem($req);
1401  }
1402 
1403 
1410  protected function initFormTitle($a_mode,$a_step_number)
1411  {
1412  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
1413  if($this->form instanceof ilPropertyFormGUI)
1414  {
1415  return;
1416  }
1417 
1418  $this->form = new ilPropertyFormGUI();
1419  $this->form->setFormAction($this->ctrl->getFormAction($this));
1420  //$this->form->setTitleIcon(ilUtil::getImagePath('icon_lobj.svg'),$this->lng->txt('crs_objective'));
1421 
1422  switch($a_mode)
1423  {
1424  case 'create':
1425  $this->form->setTitle($this->lng->txt('crs_objective_wiz_title'));
1426  $this->form->addCommandButton('save',$this->lng->txt('crs_wiz_next'));
1427  // begin-patch lok
1428  #$this->form->addCommandButton('listObjectives',$this->lng->txt('cancel'));
1429  // end-patch lok
1430  break;
1431 
1432  case 'update':
1433  break;
1434  }
1435 
1436  $title = new ilTextInputGUI($this->lng->txt('title'),'title');
1437  $title->setValue($this->objective->getTitle());
1438  $title->setRequired(true);
1439  $title->setSize(40);
1440  $title->setMaxLength(70);
1441  $this->form->addItem($title);
1442 
1443  $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'description');
1444  $desc->setValue($this->objective->getDescription());
1445  $desc->setCols(40);
1446  $desc->setRows(5);
1447  $this->form->addItem($desc);
1448 
1449  }
1450 
1451 
1459  protected function initWizard($a_step_number)
1460  {
1461  $options = array(
1462  1 => $this->lng->txt('crs_objective_wiz_title'),
1463  2 => $this->lng->txt('crs_objective_wiz_materials'),
1464  3 => $this->lng->txt('crs_objective_wiz_self'),
1465  4 => $this->lng->txt('crs_objective_wiz_self_limit'),
1466  5 => $this->lng->txt('crs_objective_wiz_final'),
1467  6 => $this->lng->txt('crs_objective_wiz_final_limit'));
1468 
1469  $info = array(
1470  1 => $this->lng->txt('crs_objective_wiz_title_info'),
1471  2 => $this->lng->txt('crs_objective_wiz_materials_info'),
1472  3 => $this->lng->txt('crs_objective_wiz_self_info'),
1473  4 => $this->lng->txt('crs_objective_wiz_self_limit_info'),
1474  5 => $this->lng->txt('crs_objective_wiz_final_info'),
1475  6 => $this->lng->txt('crs_objective_wiz_final_limit_info'));
1476 
1477  $links = array(
1478  1 => $this->ctrl->getLinkTarget($this,'edit'),
1479  2 => $this->ctrl->getLinkTarget($this,'materialAssignment'),
1480  3 => $this->ctrl->getLinkTarget($this,'selfAssessmentAssignment'),
1481  4 => $this->ctrl->getLinkTarget($this,'selfAssessmentLimits'),
1482  5 => $this->ctrl->getLinkTarget($this,'finalTestAssignment'),
1483  6 => $this->ctrl->getLinkTarget($this,'finalTestLimits'));
1484 
1485 
1486 
1487 
1488  // checklist gui start
1489  include_once("./Services/UIComponent/Checklist/classes/class.ilChecklistGUI.php");
1490  $check_list = new ilChecklistGUI();
1491  // checklist gui end
1492 
1493  if($_SESSION['objective_mode'] == self::MODE_CREATE)
1494  {
1495  // checklist gui start
1496  $check_list->setHeading($this->lng->txt('crs_add_objective'));
1497  // checklist gui end
1498  }
1499  else
1500  {
1501  // checklist gui start
1502  $check_list->setHeading($this->lng->txt('crs_update_objective'));
1503  // checklist gui end
1504  }
1505 
1506  // end-patch lok
1507  $num = 0;
1508  foreach($options as $step => $title)
1509  {
1510  // checklist gui start
1511  $item_link = "";
1512  // checklist gui end
1513 
1514  // begin-patch lok
1515  if($step == 3 and !$this->getSettings()->worksWithInitialTest())
1516  {
1517  continue;
1518  }
1519  if($step == 4 and !$this->getSettings()->worksWithInitialTest())
1520  {
1521  continue;
1522  }
1523  if($step == 4 and $this->isRandomTestType(ilLOSettings::TYPE_TEST_INITIAL))
1524  {
1525  continue;
1526  }
1527  if($step == 6 and $this->isRandomTestType(ilLOSettings::TYPE_TEST_QUALIFIED))
1528  {
1529  continue;
1530  }
1531  $num++;
1532  // end-patch lok
1533 
1534  if($_SESSION['objective_mode'] == self::MODE_UPDATE)
1535  {
1536  $hide_link = false;
1537  if($step == 4 and !count($this->objectives_qst_obj->getSelfAssessmentQuestions()))
1538  {
1539  $hide_link = true;
1540  }
1541  if($step == 6 and !count($this->objectives_qst_obj->getFinalTestQuestions()))
1542  {
1543  $hide_link = true;
1544  }
1545  // begin-patch lok
1546  if($step == 3 and !$this->getSettings()->worksWithInitialTest())
1547  {
1548  $hide_link = true;
1549  }
1550  if($step == 4 and !$this->getSettings()->worksWithInitialTest())
1551  {
1552  $hide_link = true;
1553  }
1554  if(!$hide_link)
1555  {
1556  // checklist gui start
1557  $item_link = $links[$step];
1558  // checklist gui end
1559  }
1560  }
1561 
1562  // checklist gui start
1563  $check_list->addEntry($title, $item_link, ilChecklistGUI::STATUS_NO_STATUS, ($step == $a_step_number));
1564  // checklist gui end
1565  }
1566 
1567  // checklist gui start
1568  $GLOBALS["tpl"]->setRightContent($check_list->getHTML());
1569  // checklist gui end
1570 
1571  }
1572 
1573 }
1574 ?>