ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
61  public function __construct($a_course_id)
62  {
63  include_once './Modules/Course/classes/class.ilCourseObjective.php';
64 
65  global $ilCtrl,$lng,$ilErr,$ilias,$tpl,$tree,$ilTabs;
66 
67  $this->ctrl = $ilCtrl;
68  $this->ctrl->saveParameter($this,array("ref_id"));
69 
70  $this->ilErr = $ilErr;
71  $this->lng = $lng;
72  $this->lng->loadLanguageModule('crs');
73  $this->tpl = $tpl;
74  $this->tree = $tree;
75  $this->tabs_gui = $ilTabs;
76 
77  $this->course_id = $a_course_id;
78  $this->__initCourseObject();
79 
80  // begin-patch lok
81  $this->settings = ilLOSettings::getInstanceByObjId($this->course_obj->getId());
82  // end-patch lok
83 
84  }
85 
89  function executeCommand()
90  {
91  global $ilTabs;
92 
93  $ilTabs->setTabActive('crs_objectives');
94 
95  $cmd = $this->ctrl->getCmd();
96 
97 
98  if (!$cmd = $this->ctrl->getCmd())
99  {
100  $cmd = "list";
101  }
102 
103  $this->$cmd();
104  }
105 
106  // begin-patch lok
111  public function getSettings()
112  {
113  return $this->settings;
114  }
115  // end-patch lok
116 
117 
125  protected function listObjectives()
126  {
127  global $ilAccess,$ilErr,$ilObjDataCache,$ilToolbar;
128 
129  $_SESSION['objective_mode'] = self::MODE_UNDEFINED;
130  if(!$ilAccess->checkAccess("write",'',$this->course_obj->getRefId()))
131  {
132  $this->ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
133  }
134 
135  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.crs_objectives.html','Modules/Course');
136 
137  $ilToolbar->addButton($this->lng->txt('crs_add_objective'),
138  $this->ctrl->getLinkTarget($this, "'create"));
139 
140  include_once('./Modules/Course/classes/class.ilCourseObjectivesTableGUI.php');
141  $table = new ilCourseObjectivesTableGUI($this,$this->course_obj);
142  $table->setTitle($this->lng->txt('crs_objectives'),'',$this->lng->txt('crs_objectives'));
143  $table->parse(ilCourseObjective::_getObjectiveIds($this->course_obj->getId(),false));
144 
145  $this->tpl->setVariable('OBJECTIVES_TABLE',$table->getHTML());
146  }
147 
154  protected function saveSorting()
155  {
156  global $ilAccess,$ilErr,$ilObjDataCache;
157 
158  if(!$ilAccess->checkAccess("write",'',$this->course_obj->getRefId()))
159  {
160  $this->ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
161  }
162 
163  asort($_POST['position'],SORT_NUMERIC);
164 
165  $counter = 1;
166  foreach($_POST['position'] as $objective_id => $position)
167  {
168  $objective = new ilCourseObjective($this->course_obj,$objective_id);
169  $objective->writePosition($counter++);
170  }
171  ilUtil::sendSuccess($this->lng->txt('crs_objective_saved_sorting'));
172  $this->listObjectives();
173  }
174 
176  {
177  global $rbacsystem;
178 
179  // MINIMUM ACCESS LEVEL = 'write'
180  if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
181  {
182  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
183  }
184  if(!count($_POST['objective']))
185  {
186  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'));
187  $this->listObjectives();
188 
189  return true;
190  }
191 
192  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives.html",'Modules/Course');
193 
194  ilUtil::sendQuestion($this->lng->txt('crs_delete_objectve_sure'));
195 
196  $tpl = new ilTemplate("tpl.table.html", true, true);
197  $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_delete_row.html",'Modules/Course');
198 
199  $counter = 0;
200  foreach($_POST['objective'] as $objective_id)
201  {
202  $objective_obj = $this->__initObjectivesObject($objective_id);
203 
204  $tpl->setCurrentBlock("tbl_content");
205  $tpl->setVariable("ROWCOL",ilUtil::switchColor(++$counter,"tblrow2","tblrow1"));
206  $tpl->setVariable("TITLE",$objective_obj->getTitle());
207  $tpl->setVariable("DESCRIPTION",$objective_obj->getDescription());
208  $tpl->parseCurrentBlock();
209  }
210 
211  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
212 
213  // Show action row
214  $tpl->setCurrentBlock("tbl_action_btn");
215  $tpl->setVariable("BTN_NAME",'deleteObjectives');
216  $tpl->setVariable("BTN_VALUE",$this->lng->txt('delete'));
217  $tpl->parseCurrentBlock();
218 
219  $tpl->setCurrentBlock("tbl_action_btn");
220  $tpl->setVariable("BTN_NAME",'listObjectives');
221  $tpl->setVariable("BTN_VALUE",$this->lng->txt('cancel'));
222  $tpl->parseCurrentBlock();
223 
224  $tpl->setCurrentBlock("tbl_action_row");
225  $tpl->setVariable("COLUMN_COUNTS",1);
226  $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.svg'));
227  $tpl->parseCurrentBlock();
228 
229 
230  // create table
231  $tbl = new ilTableGUI();
232  $tbl->setStyle('table','std');
233 
234  // title & header columns
235  $tbl->setTitle($this->lng->txt("crs_objectives"),"",$this->lng->txt("crs_objectives"));
236 
237  $tbl->setHeaderNames(array($this->lng->txt("title")));
238  $tbl->setHeaderVars(array("title"),
239  array("ref_id" => $this->course_obj->getRefId(),
240  "cmdClass" => "ilcourseobjectivesgui",
241  "cmdNode" => $_GET["cmdNode"]));
242  $tbl->setColumnWidth(array("50%"));
243 
244  $tbl->setLimit($_GET["limit"]);
245  $tbl->setOffset($_GET["offset"]);
246  $tbl->setMaxCount(count($_POST['objective']));
247 
248  // footer
249  $tbl->disable("footer");
250  $tbl->disable('sort');
251 
252  // render table
253  $tbl->setTemplate($tpl);
254  $tbl->render();
255 
256  $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
257 
258 
259  // Save marked objectives
260  $_SESSION['crs_delete_objectives'] = $_POST['objective'];
261 
262  return true;
263  }
264 
265  function deleteObjectives()
266  {
267  global $rbacsystem;
268 
269  // MINIMUM ACCESS LEVEL = 'write'
270  if(!$rbacsystem->checkAccess("write", $this->course_obj->getRefId()))
271  {
272  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilErr->MESSAGE);
273  }
274  if(!count($_SESSION['crs_delete_objectives']))
275  {
276  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'));
277  $this->listObjectives();
278 
279  return true;
280  }
281 
282  foreach($_SESSION['crs_delete_objectives'] as $objective_id)
283  {
284  $objective_obj =& $this->__initObjectivesObject($objective_id);
285  $objective_obj->delete();
286  }
287 
288  ilUtil::sendSuccess($this->lng->txt('crs_objectives_deleted'));
289  $this->listObjectives();
290 
291  return true;
292  }
293 
300  protected function questionOverview()
301  {
302  global $ilAccess,$ilErr,$ilTabs;
303 
304  $ilTabs->setSubTabActive('crs_objective_overview_question_assignment');
305 
306  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
307  {
308  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
309  }
310 
311  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestionsTableGUI.php');
312  $table = new ilCourseObjectiveQuestionsTableGUI($this,$this->course_obj);
313  $table->setTitle($this->lng->txt('crs_objectives_edit_question_assignments'),'',$this->lng->txt('crs_objectives'));
314  // begin-patch lok
315  $table->parse(ilCourseObjective::_getObjectiveIds($this->course_obj->getId(),false));
316  // end-patch lok
317 
318  $this->tpl->setContent($table->getHTML());
319  }
320 
327  protected function saveQuestionOverview()
328  {
329  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
330 
331  global $ilAccess,$ilErr;
332 
333  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
334  {
335  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
336  }
337  $error = false;
338 
339  $_POST['self'] = $_POST['self'] ? $_POST['self'] : array();
340  $_POST['final'] = $_POST['final'] ? $_POST['final'] : array();
341 
342  foreach($_POST['self'] as $objective_id => $limit)
343  {
344  $qst = new ilCourseObjectiveQuestion($objective_id);
345  $max_points = $qst->getSelfAssessmentPoints();
346 
347  if($limit < 0 or $limit > $max_points)
348  {
349  ilUtil::sendFailure($this->lng->txt('crs_objective_limit_err'));
350  $this->questionOverview();
351  return false;
352  }
353  }
354  foreach($_POST['final'] as $objective_id => $limit)
355  {
356  $qst = new ilCourseObjectiveQuestion($objective_id);
357  $max_points = $qst->getFinalTestPoints();
358 
359  if($limit < 0 or $limit > $max_points)
360  {
361  ilUtil::sendFailure($this->lng->txt('crs_objective_limit_err'));
362  $this->questionOverview();
363  return false;
364  }
365  }
366 
367  foreach($_POST['self'] as $objective_id => $limit)
368  {
370  }
371 
372  foreach($_POST['final'] as $objective_id => $limit)
373  {
375  }
376 
377  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
378  $this->questionOverview();
379  return true;
380  }
381 
382  // PRIVATE
384  {
385  if(!$this->course_obj =& ilObjectFactory::getInstanceByRefId($this->course_id,false))
386  {
387  $this->ilErr->raiseError("ilCourseObjectivesGUI: cannot create course object",$this->ilErr->MESSAGE);
388  exit;
389  }
390  return true;
391  }
392 
393  function __initObjectivesObject($a_id = 0)
394  {
395  return $this->objectives_obj = new ilCourseObjective($this->course_obj,$a_id);
396  }
397 
398  function __initLMObject($a_objective_id = 0)
399  {
400  include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
401  $this->objectives_lm_obj = new ilCourseObjectiveMaterials($a_objective_id);
402 
403  return true;
404  }
405 
406  // begin-patch lok
412  function __initQuestionObject($a_objective_id = 0)
413  {
414  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
415  $this->objectives_qst_obj = new ilCourseObjectiveQuestion($a_objective_id);
416 
417  return $this->objectives_qst_obj;
418  }
419  // end-patch lok
420 
424  function setSubTabs($a_active = "")
425  {
426  global $ilTabs, $ilHelp;
427 
428  if ($a_active != "")
429  {
430  $ilHelp->setScreenIdComponent("crs");
431  $ilHelp->setScreenId("crs_objective");
432  $ilHelp->setSubScreenId($a_active);
433  }
434 
435 
436  // begin-patch lok
437  // no subtabs here
438  return true;
439  // end-patch lok
440 
441 
442  $ilTabs->addSubTabTarget("crs_objective_overview_objectives",
443  $this->ctrl->getLinkTarget($this, "listObjectives"),
444  array("listObjectives", "moveObjectiveUp", "moveObjectiveDown", "listAssignedLM"),
445  array(),
446  '',
447  true);
448  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
449 
450  if(ilCourseObjectiveQuestion::_hasTests($this->course_obj->getId()))
451  {
452  $ilTabs->addSubTabTarget("crs_objective_overview_question_assignment",
453  $this->ctrl->getLinkTarget($this, "questionOverview"),
454  "editQuestionAssignment",
455  array(),
456  '',
457  false);
458  }
459  }
460 
461 
469  public function create()
470  {
471  global $tpl;
472 
473  $this->setSubTabs("create_obj");
474 
475  $_SESSION['objective_mode'] = self::MODE_CREATE;
476 
477  $this->ctrl->saveParameter($this,'objective_id');
478 
479  if(!is_object($this->objective))
480  {
481  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
482  }
483  $this->__initQuestionObject((int) $_GET['objective_id']);
484  $this->initWizard(1);
485 
486  $this->initFormTitle('create',1);
487  $GLOBALS['tpl']->setContent($this->form->getHtml());
488  #$w_tpl->setVariable('WIZ_CONTENT',$this->form->getHtml());
489  #$tpl->setContent($w_tpl->get());
490  }
491 
498  protected function edit()
499  {
500  global $tpl;
501 
502  $_SESSION['objective_mode'] = self::MODE_UPDATE;
503 
504  $this->setSubTabs("edit_obj");
505 
506  $this->ctrl->setParameter($this,'objective_id',(int) $_REQUEST['objective_id']);
507 
508  if(!$_REQUEST['objective_id'])
509  {
510  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
511  $this->ctrl->redirect($this,'listObjectives');
512  }
513 
514  if(!is_object($this->objective))
515  {
516  $this->objective = new ilCourseObjective($this->course_obj,(int) $_REQUEST['objective_id']);
517  }
518 
519  $this->__initQuestionObject((int) $_REQUEST['objective_id']);
520  $this->initWizard(1);
521  $this->initFormTitle('create',1);
522  $GLOBALS['tpl']->setContent($this->form->getHtml());
523  #$w_tpl->setVariable('WIZ_CONTENT',$this->form->getHtml());
524  #$tpl->setContent($w_tpl->get());
525  }
526 
533  protected function save()
534  {
535  global $ilAccess,$ilErr;
536 
537  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
538  {
539  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
540  }
541 
542  $this->ctrl->saveParameter($this,'objective_id');
543 
544  $this->objective = new ilCourseObjective($this->course_obj,(int) $_REQUEST['objective_id']);
545  $this->initFormTitle('create', 1);
546  if($this->form->checkInput())
547  {
548  $this->objective->setTitle($this->form->getInput('title'));
549  $this->objective->setDescription($this->form->getInput('description'));
550  $this->objective->setPasses(0);
551 
552  if(!$_GET['objective_id'])
553  {
554  $objective_id = $this->objective->add();
555  ilUtil::sendSuccess($this->lng->txt('crs_added_objective'),true);
556  }
557  else
558  {
559  $this->objective->update();
560  ilUtil::sendSuccess($this->lng->txt('crs_objective_modified'),true);
561  $objective_id = $_GET['objective_id'];
562  }
563  }
564  else
565  {
566  $this->form->setValuesByPost();
567  return $this->edit();
568  }
569 
570  if($_SESSION['objective_mode'] != self::MODE_CREATE)
571  {
572  $this->ctrl->returnToParent($this);
573  }
574 
575  $this->ctrl->setParameter($this,'objective_id',$objective_id);
576  $this->ctrl->redirect($this,'materialAssignment');
577  return true;
578  }
579 
586  protected function materialAssignment()
587  {
588  global $ilAccess,$ilErr,$tpl;
589 
590  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
591  {
592  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
593  }
594  if(!$_GET['objective_id'])
595  {
596  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
597  $this->ctrl->redirect($this,'listObjectives');
598  }
599 
600  $this->setSubTabs("materials");
601 
602  $this->ctrl->saveParameter($this,'objective_id');
603 
604  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
605 
606  include_once('./Modules/Course/classes/class.ilCourseObjectiveMaterialAssignmentTableGUI.php');
607  $table = new ilCourseObjectiveMaterialAssignmentTableGUI($this,$this->course_obj,(int) $_GET['objective_id']);
608  $table->setTitle($this->lng->txt('crs_objective_wiz_materials'),
609  '',$this->lng->txt('crs_objectives'));
610 
611  include_once('Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
612  $table->parse(ilCourseObjectiveMaterials::_getAssignableMaterials($this->course_obj->getRefId()));
613 
614  $this->__initQuestionObject((int) $_GET['objective_id']);
615  $this->initWizard(2);
616  #$w_tpl->setVariable('WIZ_CONTENT',$table->getHTML());
617  $GLOBALS['tpl']->setContent($table->getHTML());
618  #$tpl->setContent($w_tpl->get());
619  }
620 
628  protected function updateMaterialAssignment()
629  {
630  global $ilAccess,$ilErr,$ilObjDataCache;
631 
632  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
633  {
634  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
635  }
636  if(!$_GET['objective_id'])
637  {
638  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
639  $this->ctrl->redirect($this,'listObjectives');
640  }
641 
642  $this->__initLMObject((int) $_GET['objective_id']);
643  $this->objectives_lm_obj->deleteAll();
644 
645  if(is_array($_POST['materials']))
646  {
647  foreach($_POST['materials'] as $node_id)
648  {
649  $obj_id = $ilObjDataCache->lookupObjId($node_id);
650  $type = $ilObjDataCache->lookupType($obj_id);
651 
652  $this->objectives_lm_obj->setLMRefId($node_id);
653  $this->objectives_lm_obj->setLMObjId($obj_id);
654  $this->objectives_lm_obj->setType($type);
655  $this->objectives_lm_obj->add();
656  }
657  }
658  if(is_array($_POST['chapters']))
659  {
660  foreach($_POST['chapters'] as $chapter)
661  {
662  include_once('./Modules/LearningModule/classes/class.ilLMObject.php');
663 
664  list($ref_id,$chapter_id) = explode('_',$chapter);
665 
666  $this->objectives_lm_obj->setLMRefId($ref_id);
667  $this->objectives_lm_obj->setLMObjId($chapter_id);
668  $this->objectives_lm_obj->setType(ilLMObject::_lookupType($chapter_id));
669  $this->objectives_lm_obj->add();
670  }
671  }
672  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
673 
674 
675  if($_SESSION['objective_mode'] != self::MODE_CREATE)
676  {
677  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'),true);
678  $this->ctrl->returnToParent($this);
679  }
680 
681  // begin-patch lok
682  if($this->getSettings()->worksWithInitialTest())
683  {
684  $this->selfAssessmentAssignment();
685  }
686  else
687  {
688  $this->finalTestAssignment();
689  }
690  // end-patch lok
691  }
692 
699  protected function selfAssessmentAssignment()
700  {
701  global $ilAccess,$ilErr,$tpl;
702 
703  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
704  {
705  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
706  }
707  if(!$_GET['objective_id'])
708  {
709  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
710  $this->ctrl->redirect($this,'listObjectives');
711  }
712 
713  $this->setSubTabs("self_ass_assign");
714 
715  $this->ctrl->saveParameter($this,'objective_id');
716 
717  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
718 
719  // begin-patch lok
720  $this->ctrl->setParameter($this,'tt',ilLOSettings::TYPE_TEST_INITIAL);
721  $this->test_type = $_REQUEST['tt'] = ilLOSettings::TYPE_TEST_INITIAL;
723  {
724  return $this->showRandomTestAssignment();
725  }
726  // end-patch lok
727 
728  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestionAssignmentTableGUI.php');
730  $this->course_obj,
731  (int) $_GET['objective_id'],
733  $table->setTitle($this->lng->txt('crs_objective_wiz_self'),
734  '',$this->lng->txt('crs_objective'));
735  $table->parse(ilCourseObjectiveQuestion::_getAssignableTests($this->course_obj->getRefId()));
736 
737  $this->__initQuestionObject((int) $_GET['objective_id']);
738  $this->initWizard(3);
739  $GLOBALS['tpl']->setContent($table->getHTML());
740  #$w_tpl->setVariable('WIZ_CONTENT',$table->getHTML());
741  #$tpl->setContent($w_tpl->get());
742  }
743 
751  protected function updateSelfAssessmentAssignment()
752  {
753  global $ilAccess,$ilErr,$ilObjDataCache;
754 
755  $checked_questions = $_POST['questions'] ? $_POST['questions'] : array();
756 
757 
758  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
759  {
760  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
761  }
762  if(!$_GET['objective_id'])
763  {
764  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
765  $this->ctrl->redirect($this,'listObjectives');
766  }
767 
768  $this->__initQuestionObject((int) $_GET['objective_id']);
769 
770  // Delete unchecked
771  foreach($this->objectives_qst_obj->getSelfAssessmentQuestions() as $question)
772  {
773  $id = $question['ref_id'].'_'.$question['question_id'];
774  if(!in_array($id,$checked_questions))
775  {
776  $this->objectives_qst_obj->delete($question['qst_ass_id']);
777  }
778  }
779  // Add checked
780  foreach($checked_questions as $question_id)
781  {
782  list($test_ref_id,$qst_id) = explode('_',$question_id);
783  $test_obj_id = $ilObjDataCache->lookupObjId($test_ref_id);
784 
785  if($this->objectives_qst_obj->isSelfAssessmentQuestion($qst_id))
786  {
787  continue;
788  }
789  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_SELF_ASSESSMENT);
790  $this->objectives_qst_obj->setTestRefId($test_ref_id);
791  $this->objectives_qst_obj->setTestObjId($test_obj_id);
792  $this->objectives_qst_obj->setQuestionId($qst_id);
793  $this->objectives_qst_obj->add();
794  }
795 
796  // TODO: not nice
797  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
798  $this->questions = new ilCourseObjectiveQuestion((int) $_GET['objective_id']);
799  // not required due to percentages
800  //$this->questions->updateLimits();
801 
802  if($checked_questions)
803  {
804  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
805  $this->selfAssessmentLimits();
806  return true;
807  }
808  else
809  {
810  switch($_SESSION['objective_mode'])
811  {
812  case self::MODE_CREATE:
813  $this->finalTestAssignment();
814  return true;
815 
816  case self::MODE_UPDATE:
817  $this->selfAssessmentAssignment();
818  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
819  return true;
820  }
821  }
822  }
823 
831  protected function selfAssessmentLimits()
832  {
833  global $ilAccess,$ilErr,$tpl;
834 
835  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
836  {
837  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
838  }
839  if(!$_GET['objective_id'])
840  {
841  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
842  $this->ctrl->redirect($this,'listObjectives');
843  }
844 
845  $this->setSubTabs("self_ass_limits");
846 
847  $this->ctrl->saveParameter($this,'objective_id');
848  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
849 
850  $this->__initQuestionObject((int) $_GET['objective_id']);
851  $this->initWizard(4);
852 
853  $this->initFormLimits('selfAssessment');
854  $GLOBALS['tpl']->setContent($this->form->getHtml());
855  #$w_tpl->setVariable('WIZ_CONTENT',$this->form->getHtml());
856  #$tpl->setContent($w_tpl->get());
857  }
858 
866  protected function updateSelfAssessmentLimits()
867  {
868  global $ilAccess,$ilErr,$ilObjDataCache;
869 
870  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
871  {
872  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
873  }
874  if(!$_GET['objective_id'])
875  {
876  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
877  $this->ctrl->redirect($this,'listObjectives');
878  }
879 
880  $this->__initQuestionObject((int) $_GET['objective_id']);
881 
882  if((int) $_POST['limit'] < 1 or (int) $_POST['limit'] > 100)
883  {
884  ilUtil::sendFailure($this->lng->txt('crs_objective_err_limit'));
885  $this->selfAssessmentLimits();
886  return false;
887  }
888 
889  foreach($this->objectives_qst_obj->getSelfAssessmentTests() as $test)
890  {
891  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_SELF_ASSESSMENT);
892  $this->objectives_qst_obj->setTestSuggestedLimit((int) $_POST['limit']);
893  $this->objectives_qst_obj->updateTest($test['test_objective_id']);
894  }
895 
896  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
897  $this->ctrl->returnToParent($this);
898  }
899 
900 
908  protected function finalTestAssignment()
909  {
910  global $ilAccess,$ilErr,$tpl;
911 
912  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
913  {
914  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
915  }
916  if(!$_GET['objective_id'])
917  {
918  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
919  $this->ctrl->redirect($this,'listObjectives');
920  }
921 
922  $this->setSubTabs("final_test_assign");
923 
924  $this->ctrl->saveParameter($this,'objective_id');
925  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
926 
927  // begin-patch lok
928  $this->ctrl->setParameter($this,'tt',ilLOSettings::TYPE_TEST_QUALIFIED);
929  $this->test_type = $_REQUEST['tt'] = ilLOSettings::TYPE_TEST_QUALIFIED;
931  {
932  return $this->showRandomTestAssignment();
933  }
934  // end-patch lok
935 
936  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestionAssignmentTableGUI.php');
938  $this->course_obj,
939  (int) $_GET['objective_id'],
941 
942  $table->setTitle($this->lng->txt('crs_objective_wiz_final'),
943  '',$this->lng->txt('crs_objective'));
944  $table->parse(ilCourseObjectiveQuestion::_getAssignableTests($this->course_obj->getRefId()));
945 
946  $this->__initQuestionObject((int) $_GET['objective_id']);
947  $this->initWizard(5);
948  $GLOBALS['tpl']->setContent($table->getHTML());
949  #$w_tpl->setVariable('WIZ_CONTENT',$table->getHTML());
950  #$tpl->setContent($w_tpl->get());
951  }
952 
953  // begin-patch lok
954  protected function isRandomTestType($a_tst_type = 0)
955  {
956  if(!$a_tst_type)
957  {
958  $a_tst_type = $this->test_type;
959  }
960 
961  $tst_ref_id = $this->getSettings()->getTestByType($a_tst_type);
962  if(!$tst_ref_id)
963  {
964  return false;
965  }
966  include_once './Modules/Test/classes/class.ilObjTest.php';
968  }
969 
974  protected function showRandomTestAssignment(ilPropertyFormGUI $form = null)
975  {
976  $this->ctrl->saveParameter($this,'objective_id');
977  $this->ctrl->setParameter($this,'tt', (int) $_REQUEST['tt']);
978  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
979  $this->test_type = (int) $_REQUEST['tt'];
980 
981 
982  $this->setSubTabs("rand_test_assign");
983 
984  if(!$form instanceof ilPropertyFormGUI)
985  {
986  $form = $this->initFormRandom();
987  }
988 
989  $this->__initQuestionObject((int) $_GET['objective_id']);
990  $this->initWizard(5);
991  $GLOBALS['tpl']->setContent($form->getHTML());
992  #$w_tpl->setVariable('WIZ_CONTENT',$form->getHTML());
993 
994  #$GLOBALS['tpl']->setContent($w_tpl->get());
995  }
996 
1000  protected function initFormRandom()
1001  {
1002  include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
1003  $rnd = new ilLORandomTestQuestionPools(
1004  $this->course_obj->getId(),
1005  (int) $_REQUEST['objective_id'],
1006  $this->test_type
1007  );
1008 
1009  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1010  $form = new ilPropertyFormGUI();
1011  $form->setFormAction($this->ctrl->getFormAction($this));
1012 
1013  if($this->test_type == ilLOSettings::TYPE_TEST_INITIAL)
1014  {
1015  $form->setTitle($this->lng->txt('crs_loc_form_random_limits_it'));
1016  }
1017  else
1018  {
1019  $form->setTitle($this->lng->txt('crs_loc_form_random_limits_qt'));
1020  }
1021 
1022  $form->addCommandButton('saveRandom', $this->lng->txt('save'));
1023 
1024  $options = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_rand_assign_qpl'),'type');
1025  $options->setValue(1);
1026  $options->setRequired(true);
1027 
1028  $ass_qpl = new ilRadioOption($this->lng->txt('crs_loc_rand_assign_qpl'),1);
1029  $options->addOption($ass_qpl);
1030 
1031  $qpl = new ilSelectInputGUI($this->lng->txt('crs_loc_rand_qpl'),'qpl');
1032  $qpl->setOptions($this->getRandomTestQplOptions());
1033  $qpl->setValue($rnd->getQplSequence());
1034  $ass_qpl->addSubItem($qpl);
1035 
1036  #$num = new ilNumberInputGUI($this->lng->txt('crs_loc_num_qst'),'num_qst');
1037  #$num->setSize(3);
1038  #$num->setMinValue(1);
1039  #$num->setRequired(true);
1040  #$ass_qpl->addSubItem($num);
1041 
1042  // points
1043  $per = new ilNumberInputGUI($this->lng->txt('crs_loc_perc'),'per');
1044  $per->setValue($rnd->getLimit());
1045  $per->setSize(3);
1046  $per->setMinValue(1);
1047  $per->setMaxValue(100);
1048  $per->setRequired(true);
1049  $ass_qpl->addSubItem($per);
1050 
1051  $form->addItem($options);
1052  return $form;
1053  }
1054 
1055 
1056  protected function getRandomTestQplOptions()
1057  {
1058  include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionFactory.php';
1059  include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionList.php';
1060 
1061  $tst_ref_id = $this->getSettings()->getTestByType($this->test_type);
1062  if($tst_ref_id)
1063  {
1064  $tst = ilObjectFactory::getInstanceByRefId($tst_ref_id,false);
1065  }
1066  if(!$tst instanceof ilObjTest)
1067  {
1068  return array();
1069  }
1071  $GLOBALS['ilDB'],
1072  $tst,
1074  $GLOBALS['ilDB'],
1075  $tst
1076  )
1077  );
1078 
1079  $list->loadDefinitions();
1080 
1081  include_once './Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php';
1082  $translater = new ilTestTaxonomyFilterLabelTranslater($GLOBALS['ilDB']);
1083  $translater->loadLabels($list);
1084 
1085  $options[0] = $this->lng->txt('select_one');
1086  foreach ($list as $definition)
1087  {
1088  $title = $definition->getPoolTitle();
1089  $tax_id = $definition->getMappedFilterTaxId();
1090  if($tax_id)
1091  {
1092  $title .= (' -> '. $translater->getTaxonomyTreeLabel($tax_id));
1093  }
1094  $tax_node = $definition->getMappedFilterTaxNodeId();
1095  if($tax_node)
1096  {
1097  $title .= (' -> ' .$translater->getTaxonomyNodeLabel($tax_node));
1098  }
1099  $options[$definition->getId()] = $title;
1100  }
1101  return $options;
1102  }
1103 
1107  protected function saveRandom()
1108  {
1109  $this->ctrl->saveParameter($this,'objective_id');
1110  $this->ctrl->setParameter($this,'tt',(int) $_REQUEST['tt']);
1111  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
1112  $this->test_type = (int) $_REQUEST['tt'];
1113 
1114  $form = $this->initFormRandom();
1115  if($form->checkInput())
1116  {
1117  $qst = $this->__initQuestionObject((int) $_GET['objective_id']);
1118  $qst->deleteByTestType(
1119  ($this->test_type == ilLOSettings::TYPE_TEST_INITIAL) ?
1122  );
1123  $ref_id = $this->getSettings()->getTestByType($this->test_type);
1124 
1125  include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
1126  $rnd = new ilLORandomTestQuestionPools(
1127  $this->course_obj->getId(),
1128  (int) $_REQUEST['objective_id'],
1129  $this->test_type
1130  );
1131  $rnd->delete();
1132  $rnd->setLimit($form->getInput('per'));
1133  $rnd->setQplSequence($form->getInput('qpl'));
1134  $rnd->setTestId(ilObject::_lookupObjId($ref_id));
1135  $rnd->create();
1136  }
1137  else
1138  {
1139  $form->setValuesByPost();
1140  ilUtil::sendFailure($this->lng->txt('err_check_input'));
1141  return $this->showRandomTestAssignment();
1142  }
1143 
1144  ilUtil::sendSuccess($this->lng->txt('settings_saved'),true);
1145  if($this->test_type == ilLOSettings::TYPE_TEST_QUALIFIED)
1146  {
1147  $this->ctrl->returnToParent($this);
1148  }
1149  else
1150  {
1151  $this->ctrl->redirect($this,'finalTestAssignment');
1152  }
1153  }
1154 
1162  protected function updateFinalTestAssignment()
1163  {
1164  global $ilAccess,$ilErr,$ilObjDataCache;
1165 
1166  $checked_questions = $_POST['questions'] ? $_POST['questions'] : array();
1167 
1168 
1169  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
1170  {
1171  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
1172  }
1173  if(!$_GET['objective_id'])
1174  {
1175  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
1176  $this->ctrl->redirect($this,'listObjectives');
1177  }
1178 
1179  $this->__initQuestionObject((int) $_GET['objective_id']);
1180 
1181  // Delete unchecked
1182  foreach($this->objectives_qst_obj->getFinalTestQuestions() as $question)
1183  {
1184  $id = $question['ref_id'].'_'.$question['question_id'];
1185  if(!in_array($id,$checked_questions))
1186  {
1187  $this->objectives_qst_obj->delete($question['qst_ass_id']);
1188  }
1189  }
1190  // Add checked
1191  foreach($checked_questions as $question_id)
1192  {
1193  list($test_ref_id,$qst_id) = explode('_',$question_id);
1194  $test_obj_id = $ilObjDataCache->lookupObjId($test_ref_id);
1195 
1196  if($this->objectives_qst_obj->isFinalTestQuestion($qst_id))
1197  {
1198  continue;
1199  }
1200 
1201  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_FINAL_TEST);
1202  $this->objectives_qst_obj->setTestRefId($test_ref_id);
1203  $this->objectives_qst_obj->setTestObjId($test_obj_id);
1204  $this->objectives_qst_obj->setQuestionId($qst_id);
1205  $this->objectives_qst_obj->add();
1206  }
1207 
1208  // TODO: not nice
1209  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
1210  $this->questions = new ilCourseObjectiveQuestion((int) $_GET['objective_id']);
1211  // not required due to percentages
1212  //$this->questions->updateLimits();
1213 
1214  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
1215  $this->finalTestLimits();
1216  }
1217 
1222  protected function finalSeparatedTestAssignment(ilPropertyFormGUI $form = null)
1223  {
1224  global $ilAccess, $ilErr;
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->returnToParent($this);
1234  }
1235  $this->ctrl->saveParameter($this,'objective_id');
1236  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
1237 
1238  $this->initWizard(6);
1239  $form = $this->initFormTestAssignment();
1240  $GLOBALS['tpl']->setContent($form->getHtml());
1241  }
1242 
1250  protected function finalTestLimits()
1251  {
1252  global $ilAccess,$ilErr,$tpl;
1253 
1254  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
1255  {
1256  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
1257  }
1258  if(!$_GET['objective_id'])
1259  {
1260  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
1261  $this->ctrl->returnToParent($this);
1262  }
1263 
1264  $this->setSubTabs("final_test_limits");
1265 
1266  $this->ctrl->saveParameter($this,'objective_id');
1267  $this->objective = new ilCourseObjective($this->course_obj,(int) $_GET['objective_id']);
1268 
1269  $this->__initQuestionObject((int) $_GET['objective_id']);
1270  $this->initWizard(6);
1271 
1272  $this->initFormLimits('final');
1273  $GLOBALS['tpl']->setContent($this->form->getHtml());
1274 
1275  #$w_tpl->setVariable('WIZ_CONTENT',$this->form->getHtml());
1276  #$tpl->setContent($w_tpl->get());
1277  }
1278 
1286  protected function updateFinalTestLimits()
1287  {
1288  global $ilAccess,$ilErr,$ilObjDataCache;
1289 
1290  if(!$ilAccess->checkAccess('write','',$this->course_obj->getRefId()))
1291  {
1292  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
1293  }
1294  if(!$_GET['objective_id'])
1295  {
1296  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'),true);
1297  $this->ctrl->redirect($this,'listObjectives');
1298  }
1299 
1300  $this->__initQuestionObject((int) $_GET['objective_id']);
1301 
1302  if((int) $_POST['limit'] < 1 or (int) $_POST['limit'] > 100)
1303  {
1304  ilUtil::sendFailure($this->lng->txt('crs_objective_err_limit'));
1305  $this->finalTestLimits();
1306  return false;
1307  }
1308 
1309  foreach($this->objectives_qst_obj->getFinalTests() as $test)
1310  {
1311  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_FINAL_TEST);
1312  $this->objectives_qst_obj->setTestSuggestedLimit((int) $_POST['limit']);
1313  $this->objectives_qst_obj->updateTest($test['test_objective_id']);
1314  }
1315 
1316  if($_SESSION['objective_mode'] != self::MODE_CREATE)
1317  {
1318  ilUtil::sendSuccess($this->lng->txt('settings_saved'), TRUE);
1319  }
1320  else
1321  {
1322  ilUtil::sendSuccess($this->lng->txt('crs_added_objective'),TRUE);
1323  }
1324  $this->ctrl->returnToParent($this);
1325  }
1326 
1334  protected function initFormLimits($a_mode)
1335  {
1336  if(!is_object($this->form))
1337  {
1338  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
1339  $this->form = new ilPropertyFormGUI();
1340  }
1341  $this->form->setFormAction($this->ctrl->getFormAction($this));
1342  $this->form->setTableWidth('100%');
1343  //$this->form->setTitleIcon(ilUtil::getImagePath('icon_lobj.svg'),$this->lng->txt('crs_objective'));
1344 
1345  switch($a_mode)
1346  {
1347  case 'selfAssessment':
1348  $this->form->setTitle($this->lng->txt('crs_objective_wiz_self_limit'));
1349  $this->form->addCommandButton('updateSelfAssessmentLimits',$this->lng->txt('crs_wiz_next'));
1350  $this->form->addCommandButton('selfAssessmentAssignment',$this->lng->txt('crs_wiz_back'));
1351 
1352  $tests = $this->objectives_qst_obj->getSelfAssessmentTests();
1353  $max_points = $this->objectives_qst_obj->getSelfAssessmentPoints();
1354 
1355  break;
1356 
1357  case 'final':
1358  $this->form->setTitle($this->lng->txt('crs_objective_wiz_final_limit'));
1359  $this->form->addCommandButton('updateFinalTestLimits',$this->lng->txt('crs_wiz_next'));
1360  $this->form->addCommandButton('finalTestAssignment',$this->lng->txt('crs_wiz_back'));
1361 
1362  $tests = $this->objectives_qst_obj->getFinalTests();
1363  $max_points = $this->objectives_qst_obj->getFinalTestPoints();
1364 
1365  break;
1366  }
1367 
1368  $over = new ilCustomInputGUI($this->lng->txt('crs_objective_qst_summary'),'');
1369 
1370  $tpl = new ilTemplate('tpl.crs_objective_qst_summary.html',true,true,'Modules/Course');
1371 
1372 
1373  $limit = 0;
1374 
1375  foreach($tests as $test)
1376  {
1377  $GLOBALS['ilLog']->write(__METHOD__.': '.print_r($test,TRUE));
1378 
1379  $limit = $test['limit'];
1380 
1381  foreach($this->objectives_qst_obj->getQuestionsOfTest($test['obj_id']) as $question)
1382  {
1383  $tpl->setCurrentBlock('qst');
1384  $tpl->setVariable('QST_TITLE',$question['title']);
1385  if(strlen($question['description']))
1386  {
1387  $tpl->setVariable('QST_DESCRIPTION',$question['description']);
1388  }
1389  $tpl->setVariable('QST_POINTS',$question['points'].' '.
1390  $this->lng->txt('crs_objective_points'));
1391  $tpl->parseCurrentBlock();
1392  }
1393  $tpl->setCurrentBlock('tst');
1394  $tpl->setVariable('TST_TITLE',ilObject::_lookupTitle($test['obj_id']));
1395  if($desc = ilObject::_lookupDescription($test['obj_id']))
1396  {
1397  $tpl->setVariable('TST_DESC',$desc);
1398  }
1399  $tpl->setVariable('TST_TYPE_IMG',ilUtil::getTypeIconPath('tst',$test['obj_id'],'tiny'));
1400  $tpl->setVariable('TST_ALT_IMG',$this->lng->txt('obj_tst'));
1401  $tpl->parseCurrentBlock();
1402  }
1403 
1404  $tpl->setVariable('TXT_ALL_POINTS',$this->lng->txt('crs_objective_all_points'));
1405  $tpl->setVariable('TXT_POINTS',$this->lng->txt('crs_objective_points'));
1406  $tpl->setVariable('POINTS',$max_points);
1407 
1408  $over->setHtml($tpl->get());
1409  $this->form->addItem($over);
1410 
1411  // points
1412  $req = new ilNumberInputGUI($this->lng->txt('crs_loc_perc'),'limit');
1413  $req->setValue($limit);
1414  $req->setSize(3);
1415  $req->setMinValue(1);
1416  $req->setMaxValue(100);
1417  $req->setRequired(true);
1418  switch($a_mode)
1419  {
1420  case 'selfAssessment':
1421  $req->setInfo($this->lng->txt('crs_obj_initial_req_info'));
1422  break;
1423 
1424  case 'final':
1425  $req->setInfo($this->lng->txt('crs_obj_final_req_info'));
1426  break;
1427  }
1428  $this->form->addItem($req);
1429  }
1430 
1431 
1438  protected function initFormTitle($a_mode,$a_step_number)
1439  {
1440  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
1441  if($this->form instanceof ilPropertyFormGUI)
1442  {
1443  return;
1444  }
1445 
1446  $this->form = new ilPropertyFormGUI();
1447  $this->form->setFormAction($this->ctrl->getFormAction($this));
1448  //$this->form->setTitleIcon(ilUtil::getImagePath('icon_lobj.svg'),$this->lng->txt('crs_objective'));
1449 
1450  switch($a_mode)
1451  {
1452  case 'create':
1453  $this->form->setTitle($this->lng->txt('crs_objective_wiz_title'));
1454  $this->form->addCommandButton('save',$this->lng->txt('crs_wiz_next'));
1455  // begin-patch lok
1456  #$this->form->addCommandButton('listObjectives',$this->lng->txt('cancel'));
1457  // end-patch lok
1458  break;
1459 
1460  case 'update':
1461  break;
1462  }
1463 
1464  $title = new ilTextInputGUI($this->lng->txt('title'),'title');
1465  $title->setValue($this->objective->getTitle());
1466  $title->setRequired(true);
1467  $title->setSize(40);
1468  $title->setMaxLength(70);
1469  $this->form->addItem($title);
1470 
1471  $desc = new ilTextAreaInputGUI($this->lng->txt('description'),'description');
1472  $desc->setValue($this->objective->getDescription());
1473  $desc->setCols(40);
1474  $desc->setRows(5);
1475  $this->form->addItem($desc);
1476 
1477  }
1478 
1479 
1487  protected function initWizard($a_step_number)
1488  {
1489  $options = array(
1490  1 => $this->lng->txt('crs_objective_wiz_title'),
1491  2 => $this->lng->txt('crs_objective_wiz_materials'),
1492  3 => $this->lng->txt('crs_objective_wiz_self'),
1493  4 => $this->lng->txt('crs_objective_wiz_self_limit'),
1494  5 => $this->lng->txt('crs_objective_wiz_final'),
1495  6 => $this->lng->txt('crs_objective_wiz_final_limit'));
1496 
1497  $info = array(
1498  1 => $this->lng->txt('crs_objective_wiz_title_info'),
1499  2 => $this->lng->txt('crs_objective_wiz_materials_info'),
1500  3 => $this->lng->txt('crs_objective_wiz_self_info'),
1501  4 => $this->lng->txt('crs_objective_wiz_self_limit_info'),
1502  5 => $this->lng->txt('crs_objective_wiz_final_info'),
1503  6 => $this->lng->txt('crs_objective_wiz_final_limit_info'));
1504 
1505  $links = array(
1506  1 => $this->ctrl->getLinkTarget($this,'edit'),
1507  2 => $this->ctrl->getLinkTarget($this,'materialAssignment'),
1508  3 => $this->ctrl->getLinkTarget($this,'selfAssessmentAssignment'),
1509  4 => $this->ctrl->getLinkTarget($this,'selfAssessmentLimits'),
1510  5 => $this->ctrl->getLinkTarget($this,'finalTestAssignment'),
1511  6 => $this->ctrl->getLinkTarget($this,'finalTestLimits'));
1512 
1513 
1514 
1515 
1516  // checklist gui start
1517  include_once("./Services/UIComponent/Checklist/classes/class.ilChecklistGUI.php");
1518  $check_list = new ilChecklistGUI();
1519  // checklist gui end
1520 
1521  if($_SESSION['objective_mode'] == self::MODE_CREATE)
1522  {
1523  // checklist gui start
1524  $check_list->setHeading($this->lng->txt('crs_checklist_objective'));
1525  // checklist gui end
1526  }
1527  else
1528  {
1529  // checklist gui start
1530  $check_list->setHeading($this->lng->txt('crs_checklist_objective'));
1531  // checklist gui end
1532  }
1533 
1534  // end-patch lok
1535  $num = 0;
1536  foreach($options as $step => $title)
1537  {
1538  // checklist gui start
1539  $item_link = "";
1540  // checklist gui end
1541 
1542  // begin-patch lok
1543  if($step == 3 and (!$this->getSettings()->worksWithInitialTest() or $this->getSettings()->hasSeparateInitialTests()))
1544  {
1545  continue;
1546  }
1547  if($step == 4 and (!$this->getSettings()->worksWithInitialTest() or $this->getSettings()->hasSeparateInitialTests()))
1548  {
1549  continue;
1550  }
1551  if($step == 5 and $this->getSettings()->hasSeparateQualifiedTests())
1552  {
1553  continue;
1554  }
1555  if($step == 6 and $this->getSettings()->hasSeparateQualifiedTests())
1556  {
1557  continue;
1558  }
1560  {
1561  continue;
1562  }
1564  {
1565  continue;
1566  }
1567  $num++;
1568  // end-patch lok
1569 
1570  if($_SESSION['objective_mode'] == self::MODE_UPDATE)
1571  {
1572  $hide_link = false;
1573  if($step == 4 and !count($this->objectives_qst_obj->getSelfAssessmentQuestions()))
1574  {
1575  $hide_link = true;
1576  }
1577  if($step == 6 and !count($this->objectives_qst_obj->getFinalTestQuestions()))
1578  {
1579  $hide_link = true;
1580  }
1581  // begin-patch lok
1582  if($step == 3 and !$this->getSettings()->worksWithInitialTest())
1583  {
1584  $hide_link = true;
1585  }
1586  if($step == 4 and !$this->getSettings()->worksWithInitialTest())
1587  {
1588  $hide_link = true;
1589  }
1590  if(!$hide_link)
1591  {
1592  // checklist gui start
1593  $item_link = $links[$step];
1594  // checklist gui end
1595  }
1596  }
1597 
1598  // checklist gui start
1599  $check_list->addEntry($title, $item_link, ilChecklistGUI::STATUS_NO_STATUS, ($step == $a_step_number));
1600  // checklist gui end
1601  }
1602 
1603  // checklist gui start
1604  $GLOBALS["tpl"]->setRightContent($check_list->getHTML());
1605  // checklist gui end
1606 
1607  }
1608 
1609 }
1610 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
saveQuestionOverview()
update question overview
materialAssignment()
material assignment
static getInstanceByObjId($a_obj_id)
get singleton instance
selfAssessmentAssignment()
self assessment assignemnt
$error
Definition: Error.php:17
This class represents an option in a radio group.
__construct($a_course_id)
Constructor.
initFormTitle($a_mode, $a_step_number)
init form title
setHtml($a_html)
Set Html.
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
setValue($a_value)
Set Value.
updateMaterialAssignment()
update material assignment
$_SESSION["AccountId"]
This class represents a selection list property in a property form.
This class represents a property form user interface.
updateSelfAssessmentLimits()
update self assessment limits
initWizard($a_step_number)
init wizard
static _lookupRandomTest($a_obj_id)
Returns the fact wether the test with passed obj id is a random questions test or not...
$_GET["client_id"]
$tbl
Definition: example_048.php:81
saveRandom()
Save random test settings.
updateFinalTestLimits()
update self assessment limits
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$cmd
Definition: sahs_server.php:35
setValue($a_value)
Set Value.
static _getObjectiveIds($course_id, $a_activated_only=false)
finalTestLimits()
self assessment limits
static _lookupTitle($a_id)
lookup object title
Class ilTableGUI.
TableGUI for material assignments of course objectives.
static getTypeIconPath($a_type, $a_obj_id, $a_size='small')
Get type icon path path Return image path for icon_xxx.pngs Or (if enabled) path to custom icon Depre...
global $ilCtrl
Definition: ilias.php:18
showRandomTestAssignment(ilPropertyFormGUI $form=null)
$counter
finalTestAssignment()
final test assignment
updateFinalTestAssignment()
update self assessment assignment
$info
Definition: example_052.php:80
class ilCourseObjectiveMaterials
updateSelfAssessmentAssignment()
update self assessment assignment
This class represents a property in a property form.
class ilobjcourseobjectivesgui
if(!is_array($argv)) $options
finalSeparatedTestAssignment(ilPropertyFormGUI $form=null)
Show test assignment form.
class ilcourseobjective
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class represents a number property in a property form.
static _lookupDescription($a_id)
lookup object description
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
foreach( $_REQUEST as $var) foreach(array('_POST'=> 'HTTP_POST_VARS', '_GET'=> 'HTTP_GET_VARS', '_COOKIE'=> 'HTTP_COOKIE_VARS', '_SERVER'=> 'HTTP_SERVER_VARS', '_ENV'=> 'HTTP_ENV_VARS', '_FILES'=> 'HTTP_POST_FILES') as $array=> $other) $step
Definition: cssgen.php:155
redirection script todo: (a better solution should control the processing via a xml file) ...
setSubTabs($a_active="")
set sub tabs
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
setOptions($a_options)
Set Options.
initFormLimits($a_mode)
init limit form
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
This class represents a custom property in a property form.
static _getAssignableMaterials($a_container_id)
Get an array of course material ids that can be assigned to learning objectives No tst...
settings()
Definition: settings.php:2
$ref_id
Definition: sahs_server.php:39
This class represents a text area property in a property form.
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows) ...
static _updateTestLimits($a_objective_id, $a_status, $a_limit)
update test limits
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
TableGUI for question assignments of course objectives.
class ilcourseobjectiveQuestion
$_POST["username"]
selfAssessmentLimits()
self assessment limits
static _getAssignableTests($a_container_ref_id)
Get assignable tests.
$test
Definition: Utf8Test.php:84