ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
26 
27 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
28 // end-patch lok
29 
39 {
40  const MODE_UNDEFINED = 0;
41  const MODE_CREATE = 1;
42  const MODE_UPDATE = 2;
43 
44  protected const STEP_SETTINGS = 1;
45  protected const STEP_MATERIAL_ASSIGNMENT = 2;
46  protected const STEP_INITIAL_TEST_ASSIGNMENT = 3;
47  protected const STEP_INITIAL_TEST_LIMIT = 4;
48  protected const STEP_FINAL_TEST_ASSIGNMENT = 5;
49  protected const STEP_FINAL_TEST_LIMIT = 6;
50 
51 
52 
53  public $ctrl;
54  public $ilias;
55  public $ilErr;
56  public $lng;
57  public $tpl;
58 
59  public $course_obj;
60  public $course_id;
61 
62  // begin-patch lok
63  protected $settings;
64  protected $test_type = 0;
65  // end-patch lok
66 
70  private $logger = null;
71 
76  public function __construct($a_course_id)
77  {
78  include_once './Modules/Course/classes/class.ilCourseObjective.php';
79 
80  global $DIC;
81 
82  $ilCtrl = $DIC['ilCtrl'];
83  $lng = $DIC['lng'];
84  $ilErr = $DIC['ilErr'];
85  $ilias = $DIC['ilias'];
86  $tpl = $DIC['tpl'];
87  $tree = $DIC['tree'];
88  $ilTabs = $DIC['ilTabs'];
89 
90  $this->ctrl = $ilCtrl;
91  $this->ctrl->saveParameter($this, array("ref_id"));
92 
93  $this->logger = $GLOBALS['DIC']->logger()->crs();
94  $this->ilErr = $ilErr;
95  $this->lng = $lng;
96  $this->lng->loadLanguageModule('crs');
97  $this->tpl = $tpl;
98  $this->tree = $tree;
99  $this->tabs_gui = $ilTabs;
100 
101  $this->course_id = $a_course_id;
102  $this->__initCourseObject();
103 
104  // begin-patch lok
105  $this->settings = ilLOSettings::getInstanceByObjId($this->course_obj->getId());
106  // end-patch lok
107  }
108 
112  public function executeCommand()
113  {
114  global $DIC;
115 
116  $ilTabs = $DIC['ilTabs'];
117 
118  $ilTabs->setTabActive('crs_objectives');
119 
120  $cmd = $this->ctrl->getCmd();
121 
122 
123  if (!$cmd = $this->ctrl->getCmd()) {
124  $cmd = "list";
125  }
126 
127  $this->$cmd();
128  }
129 
130  // begin-patch lok
135  public function getSettings()
136  {
137  return $this->settings;
138  }
139  // end-patch lok
140 
141 
149  protected function listObjectives()
150  {
151  global $DIC;
152 
153  $ilAccess = $DIC['ilAccess'];
154  $ilErr = $DIC['ilErr'];
155  $ilObjDataCache = $DIC['ilObjDataCache'];
156  $ilToolbar = $DIC['ilToolbar'];
157 
158  $_SESSION['objective_mode'] = self::MODE_UNDEFINED;
159  if (!$ilAccess->checkAccess("write", '', $this->course_obj->getRefId())) {
160  $this->ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilErr->MESSAGE);
161  }
162 
163  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.crs_objectives.html', 'Modules/Course');
164 
165  $ilToolbar->addButton(
166  $this->lng->txt('crs_add_objective'),
167  $this->ctrl->getLinkTarget($this, "'create")
168  );
169 
170  include_once('./Modules/Course/classes/class.ilCourseObjectivesTableGUI.php');
171  $table = new ilCourseObjectivesTableGUI($this, $this->course_obj);
172  $table->setTitle($this->lng->txt('crs_objectives'), '', $this->lng->txt('crs_objectives'));
173  $table->parse(ilCourseObjective::_getObjectiveIds($this->course_obj->getId(), false));
174 
175  $this->tpl->setVariable('OBJECTIVES_TABLE', $table->getHTML());
176  }
177 
184  protected function saveSorting()
185  {
186  global $DIC;
187 
188  $ilAccess = $DIC['ilAccess'];
189  $ilErr = $DIC['ilErr'];
190  $ilObjDataCache = $DIC['ilObjDataCache'];
191 
192  if (!$ilAccess->checkAccess("write", '', $this->course_obj->getRefId())) {
193  $this->ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilErr->MESSAGE);
194  }
195 
196  asort($_POST['position'], SORT_NUMERIC);
197 
198  $counter = 1;
199  foreach ($_POST['position'] as $objective_id => $position) {
200  $objective = new ilCourseObjective($this->course_obj, $objective_id);
201  $objective->writePosition($counter++);
202  }
203  ilUtil::sendSuccess($this->lng->txt('crs_objective_saved_sorting'));
204  $this->listObjectives();
205  }
206 
207  public function askDeleteObjective()
208  {
209  global $DIC;
210 
211  $rbacsystem = $DIC['rbacsystem'];
212 
213  // MINIMUM ACCESS LEVEL = 'write'
214  if (!$rbacsystem->checkAccess("write", $this->course_obj->getRefId())) {
215  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilErr->MESSAGE);
216  }
217  if (!count($_POST['objective'])) {
218  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'));
219  $this->listObjectives();
220 
221  return true;
222  }
223 
224  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives.html", 'Modules/Course');
225 
226  ilUtil::sendQuestion($this->lng->txt('crs_delete_objectve_sure'));
227 
228  $tpl = new ilTemplate("tpl.table.html", true, true);
229  $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_delete_row.html", 'Modules/Course');
230 
231  $counter = 0;
232  foreach ($_POST['objective'] as $objective_id) {
233  $objective_obj = $this->__initObjectivesObject($objective_id);
234 
235  $tpl->setCurrentBlock("tbl_content");
236  $tpl->setVariable("ROWCOL", ilUtil::switchColor(++$counter, "tblrow2", "tblrow1"));
237  $tpl->setVariable("TITLE", $objective_obj->getTitle());
238  $tpl->setVariable("DESCRIPTION", $objective_obj->getDescription());
239  $tpl->parseCurrentBlock();
240  }
241 
242  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
243 
244  // Show action row
245  $tpl->setCurrentBlock("tbl_action_btn");
246  $tpl->setVariable("BTN_NAME", 'deleteObjectives');
247  $tpl->setVariable("BTN_VALUE", $this->lng->txt('delete'));
248  $tpl->parseCurrentBlock();
249 
250  $tpl->setCurrentBlock("tbl_action_btn");
251  $tpl->setVariable("BTN_NAME", 'listObjectives');
252  $tpl->setVariable("BTN_VALUE", $this->lng->txt('cancel'));
253  $tpl->parseCurrentBlock();
254 
255  $tpl->setCurrentBlock("tbl_action_row");
256  $tpl->setVariable("COLUMN_COUNTS", 1);
257  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath('arrow_downright.svg'));
258  $tpl->parseCurrentBlock();
259 
260 
261  // create table
262  $tbl = new ilTableGUI();
263  $tbl->setStyle('table', 'std');
264 
265  // title & header columns
266  $tbl->setTitle($this->lng->txt("crs_objectives"), "", $this->lng->txt("crs_objectives"));
267 
268  $tbl->setHeaderNames(array($this->lng->txt("title")));
269  $tbl->setHeaderVars(
270  array("title"),
271  array("ref_id" => $this->course_obj->getRefId(),
272  "cmdClass" => "ilcourseobjectivesgui",
273  "cmdNode" => $_GET["cmdNode"])
274  );
275  $tbl->setColumnWidth(array("50%"));
276 
277  $tbl->setLimit($_GET["limit"]);
278  $tbl->setOffset($_GET["offset"]);
279  $tbl->setMaxCount(count($_POST['objective']));
280 
281  // footer
282  $tbl->disable("footer");
283  $tbl->disable('sort');
284 
285  // render table
286  $tbl->setTemplate($tpl);
287  $tbl->render();
288 
289  $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
290 
291 
292  // Save marked objectives
293  $_SESSION['crs_delete_objectives'] = $_POST['objective'];
294 
295  return true;
296  }
297 
298  public function deleteObjectives()
299  {
300  global $DIC;
301 
302  $rbacsystem = $DIC['rbacsystem'];
303 
304  // MINIMUM ACCESS LEVEL = 'write'
305  if (!$rbacsystem->checkAccess("write", $this->course_obj->getRefId())) {
306  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilErr->MESSAGE);
307  }
308  if (!count($_SESSION['crs_delete_objectives'])) {
309  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'));
310  $this->listObjectives();
311 
312  return true;
313  }
314 
315  foreach ($_SESSION['crs_delete_objectives'] as $objective_id) {
316  $objective_obj = &$this->__initObjectivesObject($objective_id);
317  $objective_obj->delete();
318  }
319 
320  ilUtil::sendSuccess($this->lng->txt('crs_objectives_deleted'));
321  $this->listObjectives();
322 
323  return true;
324  }
325 
332  protected function questionOverview()
333  {
334  global $DIC;
335 
336  $ilAccess = $DIC['ilAccess'];
337  $ilErr = $DIC['ilErr'];
338  $ilTabs = $DIC['ilTabs'];
339 
340  $ilTabs->setSubTabActive('crs_objective_overview_question_assignment');
341 
342  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
343  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
344  }
345 
346  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestionsTableGUI.php');
347  $table = new ilCourseObjectiveQuestionsTableGUI($this, $this->course_obj);
348  $table->setTitle($this->lng->txt('crs_objectives_edit_question_assignments'), '', $this->lng->txt('crs_objectives'));
349  // begin-patch lok
350  $table->parse(ilCourseObjective::_getObjectiveIds($this->course_obj->getId(), false));
351  // end-patch lok
352 
353  $this->tpl->setContent($table->getHTML());
354  }
355 
362  protected function saveQuestionOverview()
363  {
364  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
365 
366  global $DIC;
367 
368  $ilAccess = $DIC['ilAccess'];
369  $ilErr = $DIC['ilErr'];
370 
371  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
372  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
373  }
374  $error = false;
375 
376  $_POST['self'] = $_POST['self'] ? $_POST['self'] : array();
377  $_POST['final'] = $_POST['final'] ? $_POST['final'] : array();
378 
379  foreach ($_POST['self'] as $objective_id => $limit) {
380  $qst = new ilCourseObjectiveQuestion($objective_id);
381  $max_points = $qst->getSelfAssessmentPoints();
382 
383  if ($limit < 0 or $limit > $max_points) {
384  ilUtil::sendFailure($this->lng->txt('crs_objective_limit_err'));
385  $this->questionOverview();
386  return false;
387  }
388  }
389  foreach ($_POST['final'] as $objective_id => $limit) {
390  $qst = new ilCourseObjectiveQuestion($objective_id);
391  $max_points = $qst->getFinalTestPoints();
392 
393  if ($limit < 0 or $limit > $max_points) {
394  ilUtil::sendFailure($this->lng->txt('crs_objective_limit_err'));
395  $this->questionOverview();
396  return false;
397  }
398  }
399 
400  foreach ($_POST['self'] as $objective_id => $limit) {
402  }
403 
404  foreach ($_POST['final'] as $objective_id => $limit) {
406  }
407 
408  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
409  $this->questionOverview();
410  return true;
411  }
412 
413  // PRIVATE
414  public function __initCourseObject()
415  {
416  if (!$this->course_obj = &ilObjectFactory::getInstanceByRefId($this->course_id, false)) {
417  $this->ilErr->raiseError("ilCourseObjectivesGUI: cannot create course object", $this->ilErr->MESSAGE);
418  exit;
419  }
420  return true;
421  }
422 
423  public function __initObjectivesObject($a_id = 0)
424  {
425  return $this->objectives_obj = new ilCourseObjective($this->course_obj, $a_id);
426  }
427 
428  public function __initLMObject($a_objective_id = 0)
429  {
430  include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
431  $this->objectives_lm_obj = new ilCourseObjectiveMaterials($a_objective_id);
432 
433  return true;
434  }
435 
436  // begin-patch lok
442  public function __initQuestionObject($a_objective_id = 0)
443  {
444  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
445  $this->objectives_qst_obj = new ilCourseObjectiveQuestion($a_objective_id);
446 
447  return $this->objectives_qst_obj;
448  }
449  // end-patch lok
450 
454  public function setSubTabs($a_active = "")
455  {
456  global $DIC;
457 
458  $ilTabs = $DIC['ilTabs'];
459  $ilHelp = $DIC['ilHelp'];
460 
461  if ($a_active != "") {
462  $ilHelp->setScreenIdComponent("crs");
463  $ilHelp->setScreenId("crs_objective");
464  $ilHelp->setSubScreenId($a_active);
465  }
466 
467 
468  // begin-patch lok
469  // no subtabs here
470  return true;
471  // end-patch lok
472 
473 
474  $ilTabs->addSubTabTarget(
475  "crs_objective_overview_objectives",
476  $this->ctrl->getLinkTarget($this, "listObjectives"),
477  array("listObjectives", "moveObjectiveUp", "moveObjectiveDown", "listAssignedLM"),
478  array(),
479  '',
480  true
481  );
482  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
483 
484  if (ilCourseObjectiveQuestion::_hasTests($this->course_obj->getId())) {
485  $ilTabs->addSubTabTarget(
486  "crs_objective_overview_question_assignment",
487  $this->ctrl->getLinkTarget($this, "questionOverview"),
488  "editQuestionAssignment",
489  array(),
490  '',
491  false
492  );
493  }
494  }
495 
496 
504  public function create()
505  {
506  global $DIC;
507 
508  $tpl = $DIC['tpl'];
509 
510  $this->setSubTabs("create_obj");
511 
512  $_SESSION['objective_mode'] = self::MODE_CREATE;
513 
514  $this->ctrl->saveParameter($this, 'objective_id');
515 
516  if (!is_object($this->objective)) {
517  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
518  }
519  $this->__initQuestionObject((int) $_GET['objective_id']);
520  $this->initWizard(self::STEP_SETTINGS);
521 
522  $this->initFormTitle('create', 1);
523  $GLOBALS['DIC']['tpl']->setContent($this->form->getHtml());
524  #$w_tpl->setVariable('WIZ_CONTENT',$this->form->getHtml());
525  #$tpl->setContent($w_tpl->get());
526  }
527 
534  protected function edit()
535  {
536  global $DIC;
537 
538  $tpl = $DIC['tpl'];
539 
540  $_SESSION['objective_mode'] = self::MODE_UPDATE;
541 
542  $this->setSubTabs("edit_obj");
543 
544  $this->ctrl->setParameter($this, 'objective_id', (int) $_REQUEST['objective_id']);
545 
546  if (!$_REQUEST['objective_id']) {
547  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
548  $this->ctrl->redirect($this, 'listObjectives');
549  }
550 
551  if (!is_object($this->objective)) {
552  $this->objective = new ilCourseObjective($this->course_obj, (int) $_REQUEST['objective_id']);
553  }
554 
555  $this->__initQuestionObject((int) $_REQUEST['objective_id']);
556  $this->initWizard(self::STEP_SETTINGS);
557  $this->initFormTitle('create', 1);
558  $GLOBALS['DIC']['tpl']->setContent($this->form->getHtml());
559  #$w_tpl->setVariable('WIZ_CONTENT',$this->form->getHtml());
560  #$tpl->setContent($w_tpl->get());
561  }
562 
569  protected function save()
570  {
571  global $DIC;
572 
573  $ilAccess = $DIC['ilAccess'];
574  $ilErr = $DIC['ilErr'];
575 
576  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
577  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
578  }
579 
580  $this->ctrl->saveParameter($this, 'objective_id');
581 
582  $this->objective = new ilCourseObjective($this->course_obj, (int) $_REQUEST['objective_id']);
583  $this->initFormTitle('create', 1);
584  if ($this->form->checkInput()) {
585  $this->objective->setTitle($this->form->getInput('title'));
586  $this->objective->setDescription($this->form->getInput('description'));
587  $this->objective->setPasses(0);
588 
589  if (!$_GET['objective_id']) {
590  $objective_id = $this->objective->add();
591  ilUtil::sendSuccess($this->lng->txt('crs_added_objective'), true);
592  } else {
593  $this->objective->update();
594  ilUtil::sendSuccess($this->lng->txt('crs_objective_modified'), true);
595  $objective_id = $_GET['objective_id'];
596  }
597  } else {
598  if ((int) $_GET['objective_id']) {
599  $this->form->setValuesByPost();
600  return $this->edit();
601  } else {
602  $this->form->setValuesByPost();
603  return $this->create();
604  }
605  }
606 
607  if ($_SESSION['objective_mode'] != self::MODE_CREATE) {
608  $this->ctrl->returnToParent($this);
609  }
610 
611  $this->ctrl->setParameter($this, 'objective_id', $objective_id);
612  $this->ctrl->redirect($this, 'materialAssignment');
613  return true;
614  }
615 
622  protected function materialAssignment()
623  {
624  global $DIC;
625 
626  $ilAccess = $DIC['ilAccess'];
627  $ilErr = $DIC['ilErr'];
628  $tpl = $DIC['tpl'];
629 
630  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
631  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
632  }
633  if (!$_GET['objective_id']) {
634  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
635  $this->ctrl->redirect($this, 'listObjectives');
636  }
637 
638  $this->setSubTabs("materials");
639 
640  $this->ctrl->saveParameter($this, 'objective_id');
641 
642  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
643 
644  include_once('./Modules/Course/classes/class.ilCourseObjectiveMaterialAssignmentTableGUI.php');
645  $table = new ilCourseObjectiveMaterialAssignmentTableGUI($this, $this->course_obj, (int) $_GET['objective_id']);
646  $table->setTitle(
647  $this->lng->txt('crs_objective_wiz_materials'),
648  '',
649  $this->lng->txt('crs_objectives')
650  );
651 
652  include_once('Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
653  $table->parse(ilCourseObjectiveMaterials::_getAssignableMaterials($this->course_obj->getRefId()));
654 
655  $this->__initQuestionObject((int) $_GET['objective_id']);
656  $this->initWizard(self::STEP_MATERIAL_ASSIGNMENT);
657  $GLOBALS['DIC']['tpl']->setContent($table->getHTML());
658  }
659 
667  protected function updateMaterialAssignment()
668  {
669  global $DIC;
670 
671  $ilAccess = $DIC['ilAccess'];
672  $ilErr = $DIC['ilErr'];
673  $ilObjDataCache = $DIC['ilObjDataCache'];
674 
675  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
676  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
677  }
678  if (!$_GET['objective_id']) {
679  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
680  $this->ctrl->redirect($this, 'listObjectives');
681  }
682 
683  $this->__initLMObject((int) $_GET['objective_id']);
684  $this->objectives_lm_obj->deleteAll();
685 
686  if (is_array($_POST['materials'])) {
687  foreach ($_POST['materials'] as $node_id) {
688  $obj_id = $ilObjDataCache->lookupObjId($node_id);
689  $type = $ilObjDataCache->lookupType($obj_id);
690 
691  $this->objectives_lm_obj->setLMRefId($node_id);
692  $this->objectives_lm_obj->setLMObjId($obj_id);
693  $this->objectives_lm_obj->setType($type);
694  $this->objectives_lm_obj->add();
695  }
696  }
697  if (is_array($_POST['chapters'])) {
698  foreach ($_POST['chapters'] as $chapter) {
699  include_once('./Modules/LearningModule/classes/class.ilLMObject.php');
700 
701  list($ref_id, $chapter_id) = explode('_', $chapter);
702 
703  $this->objectives_lm_obj->setLMRefId($ref_id);
704  $this->objectives_lm_obj->setLMObjId($chapter_id);
705  $this->objectives_lm_obj->setType(ilLMObject::_lookupType($chapter_id));
706  $this->objectives_lm_obj->add();
707  }
708  }
709  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
710 
711 
712  if ($_SESSION['objective_mode'] != self::MODE_CREATE) {
713  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'), true);
714  $this->ctrl->returnToParent($this);
715  }
716 
717  // begin-patch lok
718  if ($this->getSettings()->worksWithInitialTest()) {
719  $this->selfAssessmentAssignment();
720  } else {
721  $this->finalTestAssignment();
722  }
723  // end-patch lok
724  }
725 
732  protected function selfAssessmentAssignment()
733  {
734  global $DIC;
735 
736  $ilAccess = $DIC['ilAccess'];
737  $ilErr = $DIC['ilErr'];
738  $tpl = $DIC['tpl'];
739 
740  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
741  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
742  }
743  if (!$_GET['objective_id']) {
744  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
745  $this->ctrl->redirect($this, 'listObjectives');
746  }
747 
748  $this->setSubTabs("self_ass_assign");
749 
750  $this->ctrl->saveParameter($this, 'objective_id');
751 
752  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
753 
754  // begin-patch lok
755  $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_INITIAL);
756  $this->test_type = $_REQUEST['tt'] = ilLOSettings::TYPE_TEST_INITIAL;
758  return $this->showRandomTestAssignment();
759  }
760  // end-patch lok
761 
762  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestionAssignmentTableGUI.php');
764  $this,
765  $this->course_obj,
766  (int) $_GET['objective_id'],
768  );
769  $table->setTitle(
770  $this->lng->txt('crs_objective_wiz_self'),
771  '',
772  $this->lng->txt('crs_objective')
773  );
774  $table->parse(ilCourseObjectiveQuestion::_getAssignableTests($this->course_obj->getRefId()));
775 
776  $this->__initQuestionObject((int) $_GET['objective_id']);
777  $this->initWizard(self::STEP_INITIAL_TEST_ASSIGNMENT);
778  $GLOBALS['DIC']['tpl']->setContent($table->getHTML());
779  }
780 
788  protected function updateSelfAssessmentAssignment()
789  {
790  global $DIC;
791 
792  $ilAccess = $DIC['ilAccess'];
793  $ilErr = $DIC['ilErr'];
794  $ilObjDataCache = $DIC['ilObjDataCache'];
795 
796  $checked_questions = $_POST['questions'] ? $_POST['questions'] : array();
797 
798 
799  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
800  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
801  }
802  if (!$_GET['objective_id']) {
803  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
804  $this->ctrl->redirect($this, 'listObjectives');
805  }
806 
807  $this->__initQuestionObject((int) $_GET['objective_id']);
808 
809  // Delete unchecked
810  foreach ($this->objectives_qst_obj->getSelfAssessmentQuestions() as $question) {
811  $id = $question['ref_id'] . '_' . $question['question_id'];
812  if (!in_array($id, $checked_questions)) {
813  $this->objectives_qst_obj->delete($question['qst_ass_id']);
814  }
815  }
816  // Add checked
817  foreach ($checked_questions as $question_id) {
818  list($test_ref_id, $qst_id) = explode('_', $question_id);
819  $test_obj_id = $ilObjDataCache->lookupObjId($test_ref_id);
820 
821  if ($this->objectives_qst_obj->isSelfAssessmentQuestion($qst_id)) {
822  continue;
823  }
824  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_SELF_ASSESSMENT);
825  $this->objectives_qst_obj->setTestRefId($test_ref_id);
826  $this->objectives_qst_obj->setTestObjId($test_obj_id);
827  $this->objectives_qst_obj->setQuestionId($qst_id);
828  $this->objectives_qst_obj->add();
829  }
830 
831  // TODO: not nice
832  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
833  $this->questions = new ilCourseObjectiveQuestion((int) $_GET['objective_id']);
834  // not required due to percentages
835  //$this->questions->updateLimits();
836 
837  if ($checked_questions) {
838  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
839  $this->selfAssessmentLimits();
840  return true;
841  } else {
842  switch ($_SESSION['objective_mode']) {
843  case self::MODE_CREATE:
844  $this->finalTestAssignment();
845  return true;
846 
847  case self::MODE_UPDATE:
848  $this->selfAssessmentAssignment();
849  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
850  return true;
851  }
852  }
853  }
854 
862  protected function selfAssessmentLimits()
863  {
864  global $DIC;
865 
866  $ilAccess = $DIC['ilAccess'];
867  $ilErr = $DIC['ilErr'];
868  $tpl = $DIC['tpl'];
869 
870  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
871  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
872  }
873  if (!$_GET['objective_id']) {
874  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
875  $this->ctrl->redirect($this, 'listObjectives');
876  }
877 
878  $this->setSubTabs("self_ass_limits");
879 
880  $this->ctrl->saveParameter($this, 'objective_id');
881  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
882 
883  $this->__initQuestionObject((int) $_GET['objective_id']);
884  $this->initWizard(self::STEP_INITIAL_TEST_LIMIT);
885 
886  $this->initFormLimits('selfAssessment');
887  $GLOBALS['DIC']['tpl']->setContent($this->form->getHtml());
888  #$w_tpl->setVariable('WIZ_CONTENT',$this->form->getHtml());
889  #$tpl->setContent($w_tpl->get());
890  }
891 
899  protected function updateSelfAssessmentLimits()
900  {
901  global $DIC;
902 
903  $ilAccess = $DIC['ilAccess'];
904  $ilErr = $DIC['ilErr'];
905  $ilObjDataCache = $DIC['ilObjDataCache'];
906 
907  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
908  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
909  }
910  if (!$_GET['objective_id']) {
911  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
912  $this->ctrl->redirect($this, 'listObjectives');
913  }
914 
915  $this->__initQuestionObject((int) $_GET['objective_id']);
916 
917  if ((int) $_POST['limit'] < 1 or (int) $_POST['limit'] > 100) {
918  ilUtil::sendFailure($this->lng->txt('crs_objective_err_limit'));
919  $this->selfAssessmentLimits();
920  return false;
921  }
922 
923  foreach ($this->objectives_qst_obj->getSelfAssessmentTests() as $test) {
924  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_SELF_ASSESSMENT);
925  $this->objectives_qst_obj->setTestSuggestedLimit((int) $_POST['limit']);
926  $this->objectives_qst_obj->updateTest($test['test_objective_id']);
927  }
928 
929  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
930  $this->ctrl->returnToParent($this);
931  }
932 
933 
941  protected function finalTestAssignment()
942  {
943  global $DIC;
944 
945  $ilAccess = $DIC['ilAccess'];
946  $ilErr = $DIC['ilErr'];
947  $tpl = $DIC['tpl'];
948 
949  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
950  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
951  }
952  if (!$_GET['objective_id']) {
953  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
954  $this->ctrl->redirect($this, 'listObjectives');
955  }
956 
957  $this->setSubTabs("final_test_assign");
958 
959  $this->ctrl->saveParameter($this, 'objective_id');
960  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
961 
962  // begin-patch lok
963  $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_QUALIFIED);
964  $this->test_type = $_REQUEST['tt'] = ilLOSettings::TYPE_TEST_QUALIFIED;
966  return $this->showRandomTestAssignment();
967  }
968  // end-patch lok
969 
970  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestionAssignmentTableGUI.php');
972  $this,
973  $this->course_obj,
974  (int) $_GET['objective_id'],
976  );
977 
978  $table->setTitle(
979  $this->lng->txt('crs_objective_wiz_final'),
980  '',
981  $this->lng->txt('crs_objective')
982  );
983  $table->parse(ilCourseObjectiveQuestion::_getAssignableTests($this->course_obj->getRefId()));
984 
985  $this->__initQuestionObject((int) $_GET['objective_id']);
986  $this->initWizard(self::STEP_FINAL_TEST_ASSIGNMENT);
987  $GLOBALS['DIC']['tpl']->setContent($table->getHTML());
988  }
989 
990  // begin-patch lok
991  protected function isRandomTestType($a_tst_type = 0)
992  {
993  if (!$a_tst_type) {
994  $a_tst_type = $this->test_type;
995  }
996 
997  $tst_ref_id = $this->getSettings()->getTestByType($a_tst_type);
998  if (!$tst_ref_id) {
999  return false;
1000  }
1001  include_once './Modules/Test/classes/class.ilObjTest.php';
1003  }
1004 
1009  protected function showRandomTestAssignment(ilPropertyFormGUI $form = null)
1010  {
1011  $this->ctrl->saveParameter($this, 'objective_id');
1012  $this->ctrl->setParameter($this, 'tt', (int) $_REQUEST['tt']);
1013  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
1014  $this->test_type = (int) $_REQUEST['tt'];
1015 
1016 
1017  $this->setSubTabs("rand_test_assign");
1018 
1019  if (!$form instanceof ilPropertyFormGUI) {
1020  $form = $this->initFormRandom();
1021  }
1022 
1023  $this->__initQuestionObject((int) $_GET['objective_id']);
1024  $this->initWizard(self::STEP_FINAL_TEST_ASSIGNMENT);
1025  $GLOBALS['DIC']['tpl']->setContent($form->getHTML());
1026  }
1027 
1031  protected function initFormRandom()
1032  {
1033  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1034  $form = new ilPropertyFormGUI();
1035  $form->setFormAction($this->ctrl->getFormAction($this));
1036 
1037  if ($this->test_type == ilLOSettings::TYPE_TEST_INITIAL) {
1038  $form->setTitle($this->lng->txt('crs_loc_form_random_limits_it'));
1039  } else {
1040  $form->setTitle($this->lng->txt('crs_loc_form_random_limits_qt'));
1041  }
1042 
1043  $form->addCommandButton('saveRandom', $this->lng->txt('save'));
1044 
1045  $options = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_rand_assign_qpl'), 'type');
1046  $options->setValue(1);
1047  $options->setRequired(true);
1048 
1049  $ass_qpl = new ilRadioOption($this->lng->txt('crs_loc_rand_assign_qpl'), 1);
1050  $options->addOption($ass_qpl);
1051 
1052  $qpl = new ilSelectInputGUI($this->lng->txt('crs_loc_rand_qpl'), 'qpl');
1053  $qpl->setRequired(true);
1054  $qpl->setMulti(true, false);
1055  $qpl->setOptions($this->getRandomTestQplOptions());
1056 
1058  $this->course_obj->getId(),
1059  (int) $_REQUEST['objective_id'],
1060  ilObject::_lookupObjId($this->getSettings()->getTestByType($this->test_type)),
1061  $this->test_type
1062  );
1063 
1064  $qpl->setValue($sequences[0]);
1065  $qpl->setMultiValues($sequences);
1066  $ass_qpl->addSubItem($qpl);
1067 
1068  // points
1069  $per = new ilNumberInputGUI($this->lng->txt('crs_loc_perc'), 'per');
1070  $per->setValue(
1072  $this->course_obj->getId(),
1073  (int) $_REQUEST['objective_id'],
1074  $this->test_type
1075  )
1076  );
1077  $per->setSize(3);
1078  $per->setMinValue(1);
1079  $per->setMaxValue(100);
1080  $per->setRequired(true);
1081  $ass_qpl->addSubItem($per);
1082 
1083  $form->addItem($options);
1084  return $form;
1085  }
1086 
1087 
1088  protected function getRandomTestQplOptions()
1089  {
1090  include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionFactory.php';
1091  include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionList.php';
1092 
1093  $tst_ref_id = $this->getSettings()->getTestByType($this->test_type);
1094  if ($tst_ref_id) {
1095  $tst = ilObjectFactory::getInstanceByRefId($tst_ref_id, false);
1096  }
1097  if (!$tst instanceof ilObjTest) {
1098  return array();
1099  }
1101  $GLOBALS['DIC']['ilDB'],
1102  $tst,
1104  $GLOBALS['DIC']['ilDB'],
1105  $tst
1106  )
1107  );
1108 
1109  $list->loadDefinitions();
1110 
1111  include_once './Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php';
1112  $translater = new ilTestTaxonomyFilterLabelTranslater($GLOBALS['DIC']['ilDB']);
1113  $translater->loadLabels($list);
1114 
1115  $options[0] = $this->lng->txt('select_one');
1116  foreach ($list as $definition) {
1118  $title = $definition->getPoolTitle();
1119  // fau: taxFilter/typeFilter - get title for extended filter conditions
1120  $filterTitle = array();
1121  $filterTitle[] = $translater->getTaxonomyFilterLabel($definition->getMappedTaxonomyFilter());
1122  $filterTitle[] = $translater->getTypeFilterLabel($definition->getTypeFilter());
1123  if (!empty($filterTitle)) {
1124  $title .= ' -> ' . implode(' / ', $filterTitle);
1125  }
1126  #$tax_id = $definition->getMappedFilterTaxId();
1127  #if($tax_id)
1128  #{
1129  # $title .= (' -> '. $translater->getTaxonomyTreeLabel($tax_id));
1130  #}
1131  #$tax_node = $definition->getMappedFilterTaxNodeId();
1132  #if($tax_node)
1133  #{
1134  # $title .= (' -> ' .$translater->getTaxonomyNodeLabel($tax_node));
1135  #}
1136  // fau.
1137  $options[$definition->getId()] = $title;
1138  }
1139  return $options;
1140  }
1141 
1145  protected function saveRandom()
1146  {
1147  $this->ctrl->saveParameter($this, 'objective_id');
1148  $this->ctrl->setParameter($this, 'tt', (int) $_REQUEST['tt']);
1149  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
1150  $this->test_type = (int) $_REQUEST['tt'];
1151 
1152  $form = $this->initFormRandom();
1153 
1154 
1155 
1156 
1157  if ($form->checkInput()) {
1159  $this->course_obj->getId(),
1160  (int) $_REQUEST['objective_id'],
1161  $this->test_type
1162  );
1163 
1164  $qst = $this->__initQuestionObject((int) $_GET['objective_id']);
1165  $qst->deleteByTestType(
1166  ($this->test_type == ilLOSettings::TYPE_TEST_INITIAL) ?
1169  );
1170  $ref_id = $this->getSettings()->getTestByType($this->test_type);
1171  foreach (array_unique((array) $form->getInput('qpl')) as $qpl_id) {
1172  include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
1173  $rnd = new ilLORandomTestQuestionPools(
1174  $this->course_obj->getId(),
1175  (int) $_REQUEST['objective_id'],
1176  $this->test_type,
1177  $qpl_id
1178  );
1179  $rnd->setLimit($form->getInput('per'));
1180  $rnd->setTestId(ilObject::_lookupObjId($ref_id));
1181  $rnd->create();
1182  }
1183  } else {
1184  $form->setValuesByPost();
1185  ilUtil::sendFailure($this->lng->txt('err_check_input'));
1186  return $this->showRandomTestAssignment();
1187  }
1188 
1189  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1190  if ($this->test_type == ilLOSettings::TYPE_TEST_QUALIFIED) {
1191  $this->ctrl->returnToParent($this);
1192  } else {
1193  $this->ctrl->redirect($this, 'finalTestAssignment');
1194  }
1195  }
1196 
1204  protected function updateFinalTestAssignment()
1205  {
1206  global $DIC;
1207 
1208  $ilAccess = $DIC['ilAccess'];
1209  $ilErr = $DIC['ilErr'];
1210  $ilObjDataCache = $DIC['ilObjDataCache'];
1211 
1212  $checked_questions = $_POST['questions'] ? $_POST['questions'] : array();
1213 
1214 
1215  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
1216  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
1217  }
1218  if (!$_GET['objective_id']) {
1219  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
1220  $this->ctrl->redirect($this, 'listObjectives');
1221  }
1222 
1223  $this->__initQuestionObject((int) $_GET['objective_id']);
1224 
1225  // Delete unchecked
1226  foreach ($this->objectives_qst_obj->getFinalTestQuestions() as $question) {
1227  $id = $question['ref_id'] . '_' . $question['question_id'];
1228  if (!in_array($id, $checked_questions)) {
1229  $this->objectives_qst_obj->delete($question['qst_ass_id']);
1230  }
1231  }
1232  // Add checked
1233  foreach ($checked_questions as $question_id) {
1234  list($test_ref_id, $qst_id) = explode('_', $question_id);
1235  $test_obj_id = $ilObjDataCache->lookupObjId($test_ref_id);
1236 
1237  if ($this->objectives_qst_obj->isFinalTestQuestion($qst_id)) {
1238  continue;
1239  }
1240 
1241  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_FINAL_TEST);
1242  $this->objectives_qst_obj->setTestRefId($test_ref_id);
1243  $this->objectives_qst_obj->setTestObjId($test_obj_id);
1244  $this->objectives_qst_obj->setQuestionId($qst_id);
1245  $this->objectives_qst_obj->add();
1246  }
1247 
1248  // TODO: not nice
1249  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
1250  $this->questions = new ilCourseObjectiveQuestion((int) $_GET['objective_id']);
1251  // not required due to percentages
1252  //$this->questions->updateLimits();
1253 
1254  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
1255  $this->finalTestLimits();
1256  }
1257 
1262  protected function finalSeparatedTestAssignment(ilPropertyFormGUI $form = null)
1263  {
1264  global $DIC;
1265 
1266  $ilAccess = $DIC['ilAccess'];
1267  $ilErr = $DIC['ilErr'];
1268 
1269  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
1270  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
1271  }
1272  if (!$_GET['objective_id']) {
1273  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
1274  $this->ctrl->returnToParent($this);
1275  }
1276  $this->ctrl->saveParameter($this, 'objective_id');
1277  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
1278 
1279  $this->initWizard(self::STEP_FINAL_TEST_LIMIT);
1280  $form = $this->initFormTestAssignment();
1281  $GLOBALS['DIC']['tpl']->setContent($form->getHtml());
1282  }
1283 
1291  protected function finalTestLimits()
1292  {
1293  global $DIC;
1294 
1295  $ilAccess = $DIC['ilAccess'];
1296  $ilErr = $DIC['ilErr'];
1297  $tpl = $DIC['tpl'];
1298 
1299  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
1300  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
1301  }
1302  if (!$_GET['objective_id']) {
1303  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
1304  $this->ctrl->returnToParent($this);
1305  }
1306 
1307  $this->setSubTabs("final_test_limits");
1308 
1309  $this->ctrl->saveParameter($this, 'objective_id');
1310  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
1311 
1312  $this->__initQuestionObject((int) $_GET['objective_id']);
1313  $this->initWizard(self::STEP_FINAL_TEST_LIMIT);
1314 
1315  $this->initFormLimits('final');
1316  $GLOBALS['DIC']['tpl']->setContent($this->form->getHtml());
1317  }
1318 
1326  protected function updateFinalTestLimits()
1327  {
1328  global $DIC;
1329 
1330  $ilAccess = $DIC['ilAccess'];
1331  $ilErr = $DIC['ilErr'];
1332  $ilObjDataCache = $DIC['ilObjDataCache'];
1333 
1334  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
1335  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
1336  }
1337  if (!$_GET['objective_id']) {
1338  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
1339  $this->ctrl->redirect($this, 'listObjectives');
1340  }
1341 
1342  $this->__initQuestionObject((int) $_GET['objective_id']);
1343 
1344  if ((int) $_POST['limit'] < 1 or (int) $_POST['limit'] > 100) {
1345  ilUtil::sendFailure($this->lng->txt('crs_objective_err_limit'));
1346  $this->finalTestLimits();
1347  return false;
1348  }
1349 
1350  foreach ($this->objectives_qst_obj->getFinalTests() as $test) {
1351  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_FINAL_TEST);
1352  $this->objectives_qst_obj->setTestSuggestedLimit((int) $_POST['limit']);
1353  $this->objectives_qst_obj->updateTest($test['test_objective_id']);
1354  }
1355 
1356  if ($_SESSION['objective_mode'] != self::MODE_CREATE) {
1357  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1358  } else {
1359  ilUtil::sendSuccess($this->lng->txt('crs_added_objective'), true);
1360  }
1361  $this->ctrl->returnToParent($this);
1362  }
1363 
1371  protected function initFormLimits($a_mode)
1372  {
1373  if (!is_object($this->form)) {
1374  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
1375  $this->form = new ilPropertyFormGUI();
1376  }
1377  $this->form->setFormAction($this->ctrl->getFormAction($this));
1378  $this->form->setTableWidth('100%');
1379  //$this->form->setTitleIcon(ilUtil::getImagePath('icon_lobj.svg'),$this->lng->txt('crs_objective'));
1380 
1381  switch ($a_mode) {
1382  case 'selfAssessment':
1383  $this->form->setTitle($this->lng->txt('crs_objective_wiz_self_limit'));
1384  $this->form->addCommandButton('updateSelfAssessmentLimits', $this->lng->txt('crs_wiz_next'));
1385 
1386  $tests = $this->objectives_qst_obj->getSelfAssessmentTests();
1387  $max_points = $this->objectives_qst_obj->getSelfAssessmentPoints();
1388 
1389  break;
1390 
1391  case 'final':
1392  $this->form->setTitle($this->lng->txt('crs_objective_wiz_final_limit'));
1393  $this->form->addCommandButton('updateFinalTestLimits', $this->lng->txt('crs_wiz_next'));
1394 
1395  $tests = $this->objectives_qst_obj->getFinalTests();
1396  $max_points = $this->objectives_qst_obj->getFinalTestPoints();
1397 
1398  break;
1399  }
1400 
1401  $over = new ilCustomInputGUI($this->lng->txt('crs_objective_qst_summary'), '');
1402 
1403  $tpl = new ilTemplate('tpl.crs_objective_qst_summary.html', true, true, 'Modules/Course');
1404 
1405 
1406  $limit = 0;
1407 
1408  foreach ($tests as $test) {
1409  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': ' . print_r($test, true));
1410 
1411  $limit = $test['limit'];
1412 
1413  foreach ($this->objectives_qst_obj->getQuestionsOfTest($test['obj_id']) as $question) {
1414  $tpl->setCurrentBlock('qst');
1415  $tpl->setVariable('QST_TITLE', $question['title']);
1416  if (strlen($question['description'])) {
1417  $tpl->setVariable('QST_DESCRIPTION', $question['description']);
1418  }
1419  $tpl->setVariable('QST_POINTS', $question['points'] . ' ' .
1420  $this->lng->txt('crs_objective_points'));
1421  $tpl->parseCurrentBlock();
1422  }
1423  $tpl->setCurrentBlock('tst');
1424  $tpl->setVariable('TST_TITLE', ilObject::_lookupTitle($test['obj_id']));
1425  if ($desc = ilObject::_lookupDescription($test['obj_id'])) {
1426  $tpl->setVariable('TST_DESC', $desc);
1427  }
1428  $tpl->setVariable('TST_TYPE_IMG', ilUtil::getTypeIconPath('tst', $test['obj_id'], 'tiny'));
1429  $tpl->setVariable('TST_ALT_IMG', $this->lng->txt('obj_tst'));
1430  $tpl->parseCurrentBlock();
1431  }
1432 
1433  $tpl->setVariable('TXT_ALL_POINTS', $this->lng->txt('crs_objective_all_points'));
1434  $tpl->setVariable('TXT_POINTS', $this->lng->txt('crs_objective_points'));
1435  $tpl->setVariable('POINTS', $max_points);
1436 
1437  $over->setHtml($tpl->get());
1438  $this->form->addItem($over);
1439 
1440  // points
1441  $req = new ilNumberInputGUI($this->lng->txt('crs_loc_perc'), 'limit');
1442  $req->setValue($limit);
1443  $req->setSize(3);
1444  $req->setMinValue(1);
1445  $req->setMaxValue(100);
1446  $req->setRequired(true);
1447  switch ($a_mode) {
1448  case 'selfAssessment':
1449  $req->setInfo($this->lng->txt('crs_obj_initial_req_info'));
1450  break;
1451 
1452  case 'final':
1453  $req->setInfo($this->lng->txt('crs_obj_final_req_info'));
1454  break;
1455  }
1456  $this->form->addItem($req);
1457  }
1458 
1459 
1466  protected function initFormTitle($a_mode, $a_step_number)
1467  {
1468  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
1469  if ($this->form instanceof ilPropertyFormGUI) {
1470  return;
1471  }
1472 
1473  $this->form = new ilPropertyFormGUI();
1474  $this->form->setFormAction($this->ctrl->getFormAction($this));
1475  //$this->form->setTitleIcon(ilUtil::getImagePath('icon_lobj.svg'),$this->lng->txt('crs_objective'));
1476 
1477  switch ($a_mode) {
1478  case 'create':
1479  $this->form->setTitle($this->lng->txt('crs_objective_wiz_title'));
1480  $this->form->addCommandButton('save', $this->lng->txt('crs_wiz_next'));
1481  // begin-patch lok
1482  #$this->form->addCommandButton('listObjectives',$this->lng->txt('cancel'));
1483  // end-patch lok
1484  break;
1485 
1486  case 'update':
1487  break;
1488  }
1489 
1490  $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
1491  $title->setValue($this->objective->getTitle());
1492  $title->setRequired(true);
1493  $title->setSize(40);
1494  $title->setMaxLength(70);
1495  $this->form->addItem($title);
1496 
1497  $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
1498  $desc->setValue($this->objective->getDescription());
1499  $desc->setCols(40);
1500  $desc->setRows(5);
1501  $this->form->addItem($desc);
1502  }
1503 
1504 
1511  protected function initWizard(int $active_step)
1512  {
1513  global $DIC;
1514  $steps = [];
1515  $step_positions = [];
1516 
1517  $workflow = $DIC->ui()->factory()->listing()->workflow();
1518 
1519  // 1 Settings
1520  $title = $this->lng->txt('crs_objective_wiz_title');
1521  $link = $this->ctrl->getLinkTarget($this, 'edit');
1522 
1523  $steps[] = $workflow->step($title, "", $link);
1524  $step_positions[self::STEP_SETTINGS] = count($steps) - 1;
1525 
1526  // 2 Material
1527  $title = $this->lng->txt('crs_objective_wiz_materials');
1528  $link = $this->ctrl->getLinkTarget($this, 'materialAssignment');
1529  $steps[] = $workflow->step($title, "", $link);
1530  $step_positions[self::STEP_MATERIAL_ASSIGNMENT] = count($steps) - 1;
1531 
1532 
1533  if ($this->getSettings()->worksWithInitialTest() && !$this->getSettings()->hasSeparateInitialTests()) {
1534  // 3 initial
1535  $title = $this->lng->txt('crs_objective_wiz_self');
1536  $link = $this->getSettings()->worksWithInitialTest()
1537  ? $this->ctrl->getLinkTarget($this, 'selfAssessmentAssignment')
1538  : null;
1539 
1540  $steps[] = $workflow->step($title, "", $link)
1541  ->withAvailability($link == null ? Step::NOT_AVAILABLE : Step::AVAILABLE);
1542  $step_positions[self::STEP_INITIAL_TEST_ASSIGNMENT] = count($steps) - 1;
1543 
1545  // 4 initial limit
1546  $title = $this->lng->txt('crs_objective_wiz_self_limit');
1547  $link = count($this->objectives_qst_obj->getSelfAssessmentQuestions())
1548  && $this->getSettings()->worksWithInitialTest()
1549  ? $this->ctrl->getLinkTarget($this, 'selfAssessmentLimits')
1550  : null;
1551  $steps[] = $workflow->step($title, "", $link)
1552  ->withAvailability($link == null ? Step::NOT_AVAILABLE : Step::AVAILABLE);
1553  $step_positions[self::STEP_INITIAL_TEST_LIMIT] = count($steps) - 1;
1554  }
1555  }
1556 
1557  if (!$this->getSettings()->hasSeparateQualifiedTests()) {
1558  // 5 final
1559  $title = $this->lng->txt('crs_objective_wiz_final');
1560  $link = $this->ctrl->getLinkTarget($this, 'finalTestAssignment');
1561  $steps[] = $workflow->step($title, "", $link);
1562  $step_positions[self::STEP_FINAL_TEST_ASSIGNMENT] = count($steps) - 1;
1563 
1565  // 6 final limit
1566  $title = $this->lng->txt('crs_objective_wiz_final_limit');
1567  $link = count($this->objectives_qst_obj->getFinalTestQuestions())
1568  ? $this->ctrl->getLinkTarget($this, 'finalTestLimits')
1569  : null;
1570  $steps[] = $workflow->step($title, "", $link)
1571  ->withAvailability($link == null ? Step::NOT_AVAILABLE : Step::AVAILABLE);
1572  $step_positions[self::STEP_FINAL_TEST_LIMIT] = count($steps) - 1;
1573  }
1574  }
1575 
1576  $list = $workflow->linear(
1577  $this->lng->txt('crs_checklist_objective'),
1578  $steps
1579  );
1580  if(!empty($step_positions[$active_step])) {
1581  $list = $list->withActive($step_positions[$active_step]);
1582  }
1583 
1584  $renderer = $DIC->ui()->renderer();
1585 
1586  $DIC["tpl"]->setRightContent($renderer->render($list));
1587  }
1588 }
saveQuestionOverview()
update question overview
materialAssignment()
material assignment
static getInstanceByObjId($a_obj_id)
get singleton instance
selfAssessmentAssignment()
self assessment assignemnt
This class represents an option in a radio group.
initWizard(int $active_step)
init wizard protected
__construct($a_course_id)
Constructor.
exit
Definition: login.php:29
initFormTitle($a_mode, $a_step_number)
init form title
settings()
Definition: settings.php:2
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"]
$steps
Definition: latex.php:3
This class represents a property form user interface.
updateSelfAssessmentLimits()
update self assessment limits
$type
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"]
static deleteForObjectiveAndTestType($a_course_id, $a_objective_id, $a_tst_type)
Delete assignment for objective id and test type.
saveRandom()
Save random test settings.
updateFinalTestLimits()
update self assessment limits
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)
finalTestAssignment()
final test assignment
updateFinalTestAssignment()
update self assessment assignment
class ilCourseObjectiveMaterials
updateSelfAssessmentAssignment()
update self assessment assignment
This class represents a property in a property form.
class ilobjcourseobjectivesgui
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)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
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.
initFormLimits($a_mode)
init limit form
static lookupSequencesByType($a_container_id, $a_objective_id, $a_test_id, $a_test_type)
Lookup sequence ids type $ilDB.
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...
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) ...
$DIC
Definition: xapitoken.php:46
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
static lookupLimit($a_container_id, $a_objective_id, $a_test_type)
lookup limit type $ilDB
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