ILIAS  release_7 Revision v7.30-3-g800a261c036
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 
81  public function __construct($a_course_id)
82  {
83  include_once './Modules/Course/classes/class.ilCourseObjective.php';
84 
85  global $DIC;
86 
87  $ilCtrl = $DIC['ilCtrl'];
88  $lng = $DIC['lng'];
89  $ilErr = $DIC['ilErr'];
90  $ilias = $DIC['ilias'];
91  $tpl = $DIC['tpl'];
92  $tree = $DIC['tree'];
93  $ilTabs = $DIC['ilTabs'];
94 
95  $this->ctrl = $ilCtrl;
96  $this->ctrl->saveParameter($this, array("ref_id"));
97 
98  $this->logger = $GLOBALS['DIC']->logger()->crs();
99  $this->ilErr = $ilErr;
100  $this->lng = $lng;
101  $this->lng->loadLanguageModule('crs');
102  $this->tpl = $tpl;
103  $this->tree = $tree;
104  $this->tabs_gui = $ilTabs;
105 
106  $this->course_id = $a_course_id;
107  $this->__initCourseObject();
108 
109  // begin-patch lok
110  $this->settings = ilLOSettings::getInstanceByObjId($this->course_obj->getId());
111  // end-patch lok
112  }
113 
117  public function executeCommand()
118  {
119  global $DIC;
120 
121  $ilTabs = $DIC['ilTabs'];
122 
123  $ilTabs->setTabActive('crs_objectives');
124 
125  $cmd = $this->ctrl->getCmd();
126 
127 
128  if (!$cmd = $this->ctrl->getCmd()) {
129  $cmd = "list";
130  }
131 
132  $this->$cmd();
133  }
134 
135  // begin-patch lok
140  public function getSettings()
141  {
142  return $this->settings;
143  }
144  // end-patch lok
145 
146 
154  protected function listObjectives()
155  {
156  global $DIC;
157 
158  $ilAccess = $DIC['ilAccess'];
159  $ilErr = $DIC['ilErr'];
160  $ilObjDataCache = $DIC['ilObjDataCache'];
161  $ilToolbar = $DIC['ilToolbar'];
162 
163  $_SESSION['objective_mode'] = self::MODE_UNDEFINED;
164  if (!$ilAccess->checkAccess("write", '', $this->course_obj->getRefId())) {
165  $this->ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilErr->MESSAGE);
166  }
167 
168  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.crs_objectives.html', 'Modules/Course');
169 
170  $ilToolbar->addButton(
171  $this->lng->txt('crs_add_objective'),
172  $this->ctrl->getLinkTarget($this, "'create")
173  );
174 
175  include_once('./Modules/Course/classes/class.ilCourseObjectivesTableGUI.php');
176  $table = new ilCourseObjectivesTableGUI($this, $this->course_obj);
177  $table->setTitle($this->lng->txt('crs_objectives'), '', $this->lng->txt('crs_objectives'));
178  $table->parse(ilCourseObjective::_getObjectiveIds($this->course_obj->getId(), false));
179 
180  $this->tpl->setVariable('OBJECTIVES_TABLE', $table->getHTML());
181  }
182 
189  protected function saveSorting()
190  {
191  global $DIC;
192 
193  $ilAccess = $DIC['ilAccess'];
194  $ilErr = $DIC['ilErr'];
195  $ilObjDataCache = $DIC['ilObjDataCache'];
196 
197  if (!$ilAccess->checkAccess("write", '', $this->course_obj->getRefId())) {
198  $this->ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilErr->MESSAGE);
199  }
200 
201  asort($_POST['position'], SORT_NUMERIC);
202 
203  $counter = 1;
204  foreach ($_POST['position'] as $objective_id => $position) {
205  $objective = new ilCourseObjective($this->course_obj, $objective_id);
206  $objective->writePosition($counter++);
207  }
208  ilUtil::sendSuccess($this->lng->txt('crs_objective_saved_sorting'));
209  $this->listObjectives();
210  }
211 
212  public function askDeleteObjective()
213  {
214  global $DIC;
215 
216  $rbacsystem = $DIC['rbacsystem'];
217 
218  // MINIMUM ACCESS LEVEL = 'write'
219  if (!$rbacsystem->checkAccess("write", $this->course_obj->getRefId())) {
220  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilErr->MESSAGE);
221  }
222  if (!count($_POST['objective'])) {
223  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'));
224  $this->listObjectives();
225 
226  return true;
227  }
228 
229  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives.html", 'Modules/Course');
230 
231  ilUtil::sendQuestion($this->lng->txt('crs_delete_objectve_sure'));
232 
233  $tpl = new ilTemplate("tpl.table.html", true, true);
234  $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.crs_objectives_delete_row.html", 'Modules/Course');
235 
236  $counter = 0;
237  foreach ($_POST['objective'] as $objective_id) {
238  $objective_obj = $this->__initObjectivesObject($objective_id);
239 
240  $tpl->setCurrentBlock("tbl_content");
241  $tpl->setVariable("ROWCOL", ilUtil::switchColor(++$counter, "tblrow2", "tblrow1"));
242  $tpl->setVariable("TITLE", $objective_obj->getTitle());
243  $tpl->setVariable("DESCRIPTION", $objective_obj->getDescription());
244  $tpl->parseCurrentBlock();
245  }
246 
247  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
248 
249  // Show action row
250  $tpl->setCurrentBlock("tbl_action_btn");
251  $tpl->setVariable("BTN_NAME", 'deleteObjectives');
252  $tpl->setVariable("BTN_VALUE", $this->lng->txt('delete'));
253  $tpl->parseCurrentBlock();
254 
255  $tpl->setCurrentBlock("tbl_action_btn");
256  $tpl->setVariable("BTN_NAME", 'listObjectives');
257  $tpl->setVariable("BTN_VALUE", $this->lng->txt('cancel'));
258  $tpl->parseCurrentBlock();
259 
260  $tpl->setCurrentBlock("tbl_action_row");
261  $tpl->setVariable("COLUMN_COUNTS", 1);
262  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath('arrow_downright.svg'));
263  $tpl->parseCurrentBlock();
264 
265 
266  // create table
267  $tbl = new ilTableGUI();
268  $tbl->setStyle('table', 'std');
269 
270  // title & header columns
271  $tbl->setTitle($this->lng->txt("crs_objectives"), "", $this->lng->txt("crs_objectives"));
272 
273  $tbl->setHeaderNames(array($this->lng->txt("title")));
274  $tbl->setHeaderVars(
275  array("title"),
276  array("ref_id" => $this->course_obj->getRefId(),
277  "cmdClass" => "ilcourseobjectivesgui",
278  "cmdNode" => $_GET["cmdNode"])
279  );
280  $tbl->setColumnWidth(array("50%"));
281 
282  $tbl->setLimit($_GET["limit"]);
283  $tbl->setOffset($_GET["offset"]);
284  $tbl->setMaxCount(count($_POST['objective']));
285 
286  // footer
287  $tbl->disable("footer");
288  $tbl->disable('sort');
289 
290  // render table
291  $tbl->setTemplate($tpl);
292  $tbl->render();
293 
294  $this->tpl->setVariable("OBJECTIVES_TABLE", $tpl->get());
295 
296 
297  // Save marked objectives
298  $_SESSION['crs_delete_objectives'] = $_POST['objective'];
299 
300  return true;
301  }
302 
303  public function deleteObjectives()
304  {
305  global $DIC;
306 
307  $rbacsystem = $DIC['rbacsystem'];
308 
309  // MINIMUM ACCESS LEVEL = 'write'
310  if (!$rbacsystem->checkAccess("write", $this->course_obj->getRefId())) {
311  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilErr->MESSAGE);
312  }
313  if (!count($_SESSION['crs_delete_objectives'])) {
314  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'));
315  $this->listObjectives();
316 
317  return true;
318  }
319 
320  foreach ($_SESSION['crs_delete_objectives'] as $objective_id) {
321  $objective_obj = &$this->__initObjectivesObject($objective_id);
322  $objective_obj->delete();
323  }
324 
325  ilUtil::sendSuccess($this->lng->txt('crs_objectives_deleted'));
326  $this->listObjectives();
327 
328  return true;
329  }
330 
337  protected function questionOverview()
338  {
339  global $DIC;
340 
341  $ilAccess = $DIC['ilAccess'];
342  $ilErr = $DIC['ilErr'];
343  $ilTabs = $DIC['ilTabs'];
344 
345  $ilTabs->setSubTabActive('crs_objective_overview_question_assignment');
346 
347  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
348  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
349  }
350 
351  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestionsTableGUI.php');
352  $table = new ilCourseObjectiveQuestionsTableGUI($this, $this->course_obj);
353  $table->setTitle($this->lng->txt('crs_objectives_edit_question_assignments'), '', $this->lng->txt('crs_objectives'));
354  // begin-patch lok
355  $table->parse(ilCourseObjective::_getObjectiveIds($this->course_obj->getId(), false));
356  // end-patch lok
357 
358  $this->tpl->setContent($table->getHTML());
359  }
360 
367  protected function saveQuestionOverview()
368  {
369  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
370 
371  global $DIC;
372 
373  $ilAccess = $DIC['ilAccess'];
374  $ilErr = $DIC['ilErr'];
375 
376  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
377  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
378  }
379  $error = false;
380 
381  $_POST['self'] = $_POST['self'] ? $_POST['self'] : array();
382  $_POST['final'] = $_POST['final'] ? $_POST['final'] : array();
383 
384  foreach ($_POST['self'] as $objective_id => $limit) {
385  $qst = new ilCourseObjectiveQuestion($objective_id);
386  $max_points = $qst->getSelfAssessmentPoints();
387 
388  if ($limit < 0 or $limit > $max_points) {
389  ilUtil::sendFailure($this->lng->txt('crs_objective_limit_err'));
390  $this->questionOverview();
391  return false;
392  }
393  }
394  foreach ($_POST['final'] as $objective_id => $limit) {
395  $qst = new ilCourseObjectiveQuestion($objective_id);
396  $max_points = $qst->getFinalTestPoints();
397 
398  if ($limit < 0 or $limit > $max_points) {
399  ilUtil::sendFailure($this->lng->txt('crs_objective_limit_err'));
400  $this->questionOverview();
401  return false;
402  }
403  }
404 
405  foreach ($_POST['self'] as $objective_id => $limit) {
407  }
408 
409  foreach ($_POST['final'] as $objective_id => $limit) {
411  }
412 
413  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
414  $this->questionOverview();
415  return true;
416  }
417 
418  // PRIVATE
419  public function __initCourseObject()
420  {
421  if (!$this->course_obj = &ilObjectFactory::getInstanceByRefId($this->course_id, false)) {
422  $this->ilErr->raiseError("ilCourseObjectivesGUI: cannot create course object", $this->ilErr->MESSAGE);
423  exit;
424  }
425  return true;
426  }
427 
428  public function __initObjectivesObject($a_id = 0)
429  {
430  return $this->objectives_obj = new ilCourseObjective($this->course_obj, $a_id);
431  }
432 
433  public function __initLMObject($a_objective_id = 0)
434  {
435  include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
436  $this->objectives_lm_obj = new ilCourseObjectiveMaterials($a_objective_id);
437 
438  return true;
439  }
440 
441  // begin-patch lok
447  public function __initQuestionObject($a_objective_id = 0)
448  {
449  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
450  $this->objectives_qst_obj = new ilCourseObjectiveQuestion($a_objective_id);
451 
452  return $this->objectives_qst_obj;
453  }
454  // end-patch lok
455 
459  public function setSubTabs($a_active = "")
460  {
461  global $DIC;
462 
463  $ilTabs = $DIC['ilTabs'];
464  $ilHelp = $DIC['ilHelp'];
465 
466  if ($a_active != "") {
467  $ilHelp->setScreenIdComponent("crs");
468  $ilHelp->setScreenId("crs_objective");
469  $ilHelp->setSubScreenId($a_active);
470  }
471 
472 
473  // begin-patch lok
474  // no subtabs here
475  return true;
476  // end-patch lok
477 
478 
479  $ilTabs->addSubTabTarget(
480  "crs_objective_overview_objectives",
481  $this->ctrl->getLinkTarget($this, "listObjectives"),
482  array("listObjectives", "moveObjectiveUp", "moveObjectiveDown", "listAssignedLM"),
483  array(),
484  '',
485  true
486  );
487  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
488 
489  if (ilCourseObjectiveQuestion::_hasTests($this->course_obj->getId())) {
490  $ilTabs->addSubTabTarget(
491  "crs_objective_overview_question_assignment",
492  $this->ctrl->getLinkTarget($this, "questionOverview"),
493  "editQuestionAssignment",
494  array(),
495  '',
496  false
497  );
498  }
499  }
500 
501 
509  public function create()
510  {
511  global $DIC;
512 
513  $tpl = $DIC['tpl'];
514 
515  $this->setSubTabs("create_obj");
516 
517  $_SESSION['objective_mode'] = self::MODE_CREATE;
518 
519  $this->ctrl->saveParameter($this, 'objective_id');
520 
521  if (!is_object($this->objective)) {
522  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
523  }
524  $this->__initQuestionObject((int) $_GET['objective_id']);
525  $this->initWizard(self::STEP_SETTINGS);
526 
527  $this->initFormTitle('create', 1);
528  $GLOBALS['DIC']['tpl']->setContent($this->form->getHtml());
529  #$w_tpl->setVariable('WIZ_CONTENT',$this->form->getHtml());
530  #$tpl->setContent($w_tpl->get());
531  }
532 
539  protected function edit()
540  {
541  global $DIC;
542 
543  $tpl = $DIC['tpl'];
544 
545  $_SESSION['objective_mode'] = self::MODE_UPDATE;
546 
547  $this->setSubTabs("edit_obj");
548 
549  $this->ctrl->setParameter($this, 'objective_id', (int) $_REQUEST['objective_id']);
550 
551  if (!$_REQUEST['objective_id']) {
552  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
553  $this->ctrl->redirect($this, 'listObjectives');
554  }
555 
556  if (!is_object($this->objective)) {
557  $this->objective = new ilCourseObjective($this->course_obj, (int) $_REQUEST['objective_id']);
558  }
559 
560  $this->__initQuestionObject((int) $_REQUEST['objective_id']);
561  $this->initWizard(self::STEP_SETTINGS);
562  $this->initFormTitle('create', 1);
563  $GLOBALS['DIC']['tpl']->setContent($this->form->getHtml());
564  #$w_tpl->setVariable('WIZ_CONTENT',$this->form->getHtml());
565  #$tpl->setContent($w_tpl->get());
566  }
567 
574  protected function save()
575  {
576  global $DIC;
577 
578  $ilAccess = $DIC['ilAccess'];
579  $ilErr = $DIC['ilErr'];
580 
581  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
582  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
583  }
584 
585  $this->ctrl->saveParameter($this, 'objective_id');
586 
587  $this->objective = new ilCourseObjective($this->course_obj, (int) $_REQUEST['objective_id']);
588  $this->initFormTitle('create', 1);
589  if ($this->form->checkInput()) {
590  $this->objective->setTitle($this->form->getInput('title'));
591  $this->objective->setDescription($this->form->getInput('description'));
592  $this->objective->setPasses(0);
593 
594  if (!$_GET['objective_id']) {
595  $objective_id = $this->objective->add();
596  ilUtil::sendSuccess($this->lng->txt('crs_added_objective'), true);
597  } else {
598  $this->objective->update();
599  ilUtil::sendSuccess($this->lng->txt('crs_objective_modified'), true);
600  $objective_id = $_GET['objective_id'];
601  }
602  } else {
603  if ((int) $_GET['objective_id']) {
604  $this->form->setValuesByPost();
605  return $this->edit();
606  } else {
607  $this->form->setValuesByPost();
608  return $this->create();
609  }
610  }
611 
612  if ($_SESSION['objective_mode'] != self::MODE_CREATE) {
613  $this->ctrl->returnToParent($this);
614  }
615 
616  $this->ctrl->setParameter($this, 'objective_id', $objective_id);
617  $this->ctrl->redirect($this, 'materialAssignment');
618  return true;
619  }
620 
627  protected function materialAssignment()
628  {
629  global $DIC;
630 
631  $ilAccess = $DIC['ilAccess'];
632  $ilErr = $DIC['ilErr'];
633  $tpl = $DIC['tpl'];
634 
635  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
636  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
637  }
638  if (!$_GET['objective_id']) {
639  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
640  $this->ctrl->redirect($this, 'listObjectives');
641  }
642 
643  $this->setSubTabs("materials");
644 
645  $this->ctrl->saveParameter($this, 'objective_id');
646 
647  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
648 
649  include_once('./Modules/Course/classes/class.ilCourseObjectiveMaterialAssignmentTableGUI.php');
650  $table = new ilCourseObjectiveMaterialAssignmentTableGUI($this, $this->course_obj, (int) $_GET['objective_id']);
651  $table->setTitle(
652  $this->lng->txt('crs_objective_wiz_materials'),
653  '',
654  $this->lng->txt('crs_objectives')
655  );
656 
657  include_once('Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
658  $table->parse(ilCourseObjectiveMaterials::_getAssignableMaterials($this->course_obj->getRefId()));
659 
660  $this->__initQuestionObject((int) $_GET['objective_id']);
661  $this->initWizard(self::STEP_MATERIAL_ASSIGNMENT);
662  $GLOBALS['DIC']['tpl']->setContent($table->getHTML());
663  }
664 
672  protected function updateMaterialAssignment()
673  {
674  global $DIC;
675 
676  $ilAccess = $DIC['ilAccess'];
677  $ilErr = $DIC['ilErr'];
678  $ilObjDataCache = $DIC['ilObjDataCache'];
679 
680  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
681  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
682  }
683  if (!$_GET['objective_id']) {
684  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
685  $this->ctrl->redirect($this, 'listObjectives');
686  }
687 
688  $this->__initLMObject((int) $_GET['objective_id']);
689 
690  $visibleMaterials = is_array($_POST['visible_materials']) ? $_POST['visible_materials'] : [];
691  $visibleChapters = is_array($_POST['visible_chapters']) ? $_POST['visible_chapters'] : [];
692  $materials = is_array($_POST['materials']) ? $_POST['materials'] : [];
693  $chapters = is_array($_POST['chapters']) ? $_POST['chapters'] : [];
694 
695  foreach ($visibleMaterials as $node_id) {
696  $obj_id = $ilObjDataCache->lookupObjId($node_id);
697  if (!in_array($node_id, $materials)) {
698  $this->objectives_lm_obj->deleteMaterial($node_id, $obj_id);
699  continue;
700  }
701  if ($this->objectives_lm_obj->isMaterialAssigned($node_id, $obj_id)) {
702  continue;
703  }
704  $this->objectives_lm_obj->setLMRefId($node_id);
705  $this->objectives_lm_obj->setLMObjId($obj_id);
706  $this->objectives_lm_obj->setType($ilObjDataCache->lookupType($obj_id));
707  $this->objectives_lm_obj->add();
708  }
709 
710  foreach ($visibleChapters as $chapter) {
711  list($ref_id, $chapter_id) = explode('_', $chapter);
712  if (!in_array($chapter, $chapters)) {
713  $this->objectives_lm_obj->deleteMaterial($ref_id, $chapter_id);
714  continue;
715  }
716  if ($this->objectives_lm_obj->isMaterialAssigned($ref_id, $chapter_id)) {
717  continue;
718  }
719  $this->objectives_lm_obj->setLMRefId($ref_id);
720  $this->objectives_lm_obj->setLMObjId($chapter_id);
721  $this->objectives_lm_obj->setType(ilLMObject::_lookupType($chapter_id));
722  $this->objectives_lm_obj->add();
723  }
724  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
725 
726 
727  if ($_SESSION['objective_mode'] != self::MODE_CREATE) {
728  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'), true);
729  $this->ctrl->returnToParent($this);
730  }
731 
732  // begin-patch lok
733  if ($this->getSettings()->worksWithInitialTest()) {
734  $this->selfAssessmentAssignment();
735  } else {
736  $this->finalTestAssignment();
737  }
738  // end-patch lok
739  }
740 
747  protected function selfAssessmentAssignment()
748  {
749  global $DIC;
750 
751  $ilAccess = $DIC['ilAccess'];
752  $ilErr = $DIC['ilErr'];
753  $tpl = $DIC['tpl'];
754 
755  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
756  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
757  }
758  if (!$_GET['objective_id']) {
759  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
760  $this->ctrl->redirect($this, 'listObjectives');
761  }
762 
763  $this->setSubTabs("self_ass_assign");
764 
765  $this->ctrl->saveParameter($this, 'objective_id');
766 
767  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
768 
769  // begin-patch lok
770  $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_INITIAL);
771  $this->test_type = $_REQUEST['tt'] = ilLOSettings::TYPE_TEST_INITIAL;
773  return $this->showRandomTestAssignment();
774  }
775  // end-patch lok
776 
777  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestionAssignmentTableGUI.php');
779  $this,
780  $this->course_obj,
781  (int) $_GET['objective_id'],
783  );
784  $table->setTitle(
785  $this->lng->txt('crs_objective_wiz_self'),
786  '',
787  $this->lng->txt('crs_objective')
788  );
789  $table->parse(ilCourseObjectiveQuestion::_getAssignableTests($this->course_obj->getRefId()));
790 
791  $this->__initQuestionObject((int) $_GET['objective_id']);
792  $this->initWizard(self::STEP_INITIAL_TEST_ASSIGNMENT);
793  $GLOBALS['DIC']['tpl']->setContent($table->getHTML());
794  }
795 
803  protected function updateSelfAssessmentAssignment()
804  {
805  global $DIC;
806 
807  $ilAccess = $DIC['ilAccess'];
808  $ilErr = $DIC['ilErr'];
809  $ilObjDataCache = $DIC['ilObjDataCache'];
810 
811  $checked_questions = $_POST['questions'] ? $_POST['questions'] : array();
812 
813 
814  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
815  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
816  }
817  if (!$_GET['objective_id']) {
818  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
819  $this->ctrl->redirect($this, 'listObjectives');
820  }
821 
822  $this->__initQuestionObject((int) $_GET['objective_id']);
823 
824  // Delete unchecked
825  foreach ($this->objectives_qst_obj->getSelfAssessmentQuestions() as $question) {
826  $id = $question['ref_id'] . '_' . $question['question_id'];
827  if (!in_array($id, $checked_questions)) {
828  $this->objectives_qst_obj->delete($question['qst_ass_id']);
829  }
830  }
831  // Add checked
832  foreach ($checked_questions as $question_id) {
833  list($test_ref_id, $qst_id) = explode('_', $question_id);
834  $test_obj_id = $ilObjDataCache->lookupObjId($test_ref_id);
835 
836  if ($this->objectives_qst_obj->isSelfAssessmentQuestion($qst_id)) {
837  continue;
838  }
839  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_SELF_ASSESSMENT);
840  $this->objectives_qst_obj->setTestRefId($test_ref_id);
841  $this->objectives_qst_obj->setTestObjId($test_obj_id);
842  $this->objectives_qst_obj->setQuestionId($qst_id);
843  $this->objectives_qst_obj->add();
844  }
845 
846  // TODO: not nice
847  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
848  $this->questions = new ilCourseObjectiveQuestion((int) $_GET['objective_id']);
849  // not required due to percentages
850  //$this->questions->updateLimits();
851 
852  if ($checked_questions) {
853  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
854  $this->selfAssessmentLimits();
855  return true;
856  } else {
857  switch ($_SESSION['objective_mode']) {
858  case self::MODE_CREATE:
859  $this->finalTestAssignment();
860  return true;
861 
862  case self::MODE_UPDATE:
863  $this->selfAssessmentAssignment();
864  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
865  return true;
866  }
867  }
868  }
869 
877  protected function selfAssessmentLimits()
878  {
879  global $DIC;
880 
881  $ilAccess = $DIC['ilAccess'];
882  $ilErr = $DIC['ilErr'];
883  $tpl = $DIC['tpl'];
884 
885  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
886  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
887  }
888  if (!$_GET['objective_id']) {
889  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
890  $this->ctrl->redirect($this, 'listObjectives');
891  }
892 
893  $this->setSubTabs("self_ass_limits");
894 
895  $this->ctrl->saveParameter($this, 'objective_id');
896  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
897 
898  $this->__initQuestionObject((int) $_GET['objective_id']);
899  $this->initWizard(self::STEP_INITIAL_TEST_LIMIT);
900 
901  $this->initFormLimits('selfAssessment');
902  $GLOBALS['DIC']['tpl']->setContent($this->form->getHtml());
903  #$w_tpl->setVariable('WIZ_CONTENT',$this->form->getHtml());
904  #$tpl->setContent($w_tpl->get());
905  }
906 
914  protected function updateSelfAssessmentLimits()
915  {
916  global $DIC;
917 
918  $ilAccess = $DIC['ilAccess'];
919  $ilErr = $DIC['ilErr'];
920  $ilObjDataCache = $DIC['ilObjDataCache'];
921 
922  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
923  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
924  }
925  if (!$_GET['objective_id']) {
926  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
927  $this->ctrl->redirect($this, 'listObjectives');
928  }
929 
930  $this->__initQuestionObject((int) $_GET['objective_id']);
931 
932  if ((int) $_POST['limit'] < 1 or (int) $_POST['limit'] > 100) {
933  ilUtil::sendFailure($this->lng->txt('crs_objective_err_limit'));
934  $this->selfAssessmentLimits();
935  return false;
936  }
937 
938  foreach ($this->objectives_qst_obj->getSelfAssessmentTests() as $test) {
939  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_SELF_ASSESSMENT);
940  $this->objectives_qst_obj->setTestSuggestedLimit((int) $_POST['limit']);
941  $this->objectives_qst_obj->updateTest($test['test_objective_id']);
942  }
943 
944  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
945  $this->ctrl->returnToParent($this);
946  }
947 
948 
956  protected function finalTestAssignment()
957  {
958  global $DIC;
959 
960  $ilAccess = $DIC['ilAccess'];
961  $ilErr = $DIC['ilErr'];
962  $tpl = $DIC['tpl'];
963 
964  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
965  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
966  }
967  if (!$_GET['objective_id']) {
968  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
969  $this->ctrl->redirect($this, 'listObjectives');
970  }
971 
972  $this->setSubTabs("final_test_assign");
973 
974  $this->ctrl->saveParameter($this, 'objective_id');
975  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
976 
977  // begin-patch lok
978  $this->ctrl->setParameter($this, 'tt', ilLOSettings::TYPE_TEST_QUALIFIED);
979  $this->test_type = $_REQUEST['tt'] = ilLOSettings::TYPE_TEST_QUALIFIED;
981  return $this->showRandomTestAssignment();
982  }
983  // end-patch lok
984 
985  include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestionAssignmentTableGUI.php');
987  $this,
988  $this->course_obj,
989  (int) $_GET['objective_id'],
991  );
992 
993  $table->setTitle(
994  $this->lng->txt('crs_objective_wiz_final'),
995  '',
996  $this->lng->txt('crs_objective')
997  );
998  $table->parse(ilCourseObjectiveQuestion::_getAssignableTests($this->course_obj->getRefId()));
999 
1000  $this->__initQuestionObject((int) $_GET['objective_id']);
1001  $this->initWizard(self::STEP_FINAL_TEST_ASSIGNMENT);
1002  $GLOBALS['DIC']['tpl']->setContent($table->getHTML());
1003  }
1004 
1005  // begin-patch lok
1006  protected function isRandomTestType($a_tst_type = 0)
1007  {
1008  if (!$a_tst_type) {
1009  $a_tst_type = $this->test_type;
1010  }
1011 
1012  $tst_ref_id = $this->getSettings()->getTestByType($a_tst_type);
1013  if (!$tst_ref_id) {
1014  return false;
1015  }
1016  include_once './Modules/Test/classes/class.ilObjTest.php';
1018  }
1019 
1024  protected function showRandomTestAssignment(ilPropertyFormGUI $form = null)
1025  {
1026  $this->ctrl->saveParameter($this, 'objective_id');
1027  $this->ctrl->setParameter($this, 'tt', (int) $_REQUEST['tt']);
1028  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
1029  $this->test_type = (int) $_REQUEST['tt'];
1030 
1031 
1032  $this->setSubTabs("rand_test_assign");
1033 
1034  if (!$form instanceof ilPropertyFormGUI) {
1035  $form = $this->initFormRandom();
1036  }
1037 
1038  $this->__initQuestionObject((int) $_GET['objective_id']);
1039  $this->initWizard(self::STEP_FINAL_TEST_ASSIGNMENT);
1040  $GLOBALS['DIC']['tpl']->setContent($form->getHTML());
1041  }
1042 
1046  protected function initFormRandom()
1047  {
1048  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1049  $form = new ilPropertyFormGUI();
1050  $form->setFormAction($this->ctrl->getFormAction($this));
1051 
1052  if ($this->test_type == ilLOSettings::TYPE_TEST_INITIAL) {
1053  $form->setTitle($this->lng->txt('crs_loc_form_random_limits_it'));
1054  } else {
1055  $form->setTitle($this->lng->txt('crs_loc_form_random_limits_qt'));
1056  }
1057 
1058  $form->addCommandButton('saveRandom', $this->lng->txt('save'));
1059 
1060  $options = new ilRadioGroupInputGUI($this->lng->txt('crs_loc_rand_assign_qpl'), 'type');
1061  $options->setValue(1);
1062  $options->setRequired(true);
1063 
1064  $ass_qpl = new ilRadioOption($this->lng->txt('crs_loc_rand_assign_qpl'), 1);
1065  $options->addOption($ass_qpl);
1066 
1067  $qpl = new ilSelectInputGUI($this->lng->txt('crs_loc_rand_qpl'), 'qpl');
1068  $qpl->setRequired(true);
1069  $qpl->setMulti(true, false);
1070  $qpl->setOptions($this->getRandomTestQplOptions());
1071 
1073  $this->course_obj->getId(),
1074  (int) $_REQUEST['objective_id'],
1075  ilObject::_lookupObjId($this->getSettings()->getTestByType($this->test_type)),
1076  $this->test_type
1077  );
1078 
1079  $qpl->setValue($sequences[0]);
1080  $qpl->setMultiValues($sequences);
1081  $ass_qpl->addSubItem($qpl);
1082 
1083  // points
1084  $per = new ilNumberInputGUI($this->lng->txt('crs_loc_perc'), 'per');
1085  $per->setValue(
1087  $this->course_obj->getId(),
1088  (int) $_REQUEST['objective_id'],
1089  $this->test_type
1090  )
1091  );
1092  $per->setSize(3);
1093  $per->setMinValue(1);
1094  $per->setMaxValue(100);
1095  $per->setRequired(true);
1096  $ass_qpl->addSubItem($per);
1097 
1098  $form->addItem($options);
1099  return $form;
1100  }
1101 
1102 
1103  protected function getRandomTestQplOptions()
1104  {
1105  include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionFactory.php';
1106  include_once './Modules/Test/classes/class.ilTestRandomQuestionSetSourcePoolDefinitionList.php';
1107 
1108  $tst_ref_id = $this->getSettings()->getTestByType($this->test_type);
1109  if ($tst_ref_id) {
1110  $tst = ilObjectFactory::getInstanceByRefId($tst_ref_id, false);
1111  }
1112  if (!$tst instanceof ilObjTest) {
1113  return array();
1114  }
1116  $GLOBALS['DIC']['ilDB'],
1117  $tst,
1119  $GLOBALS['DIC']['ilDB'],
1120  $tst
1121  )
1122  );
1123 
1124  $list->loadDefinitions();
1125 
1126  include_once './Modules/Test/classes/class.ilTestTaxonomyFilterLabelTranslater.php';
1127  $translater = new ilTestTaxonomyFilterLabelTranslater($GLOBALS['DIC']['ilDB']);
1128  $translater->loadLabels($list);
1129 
1130  $options[0] = $this->lng->txt('select_one');
1131  foreach ($list as $definition) {
1133  $title = $definition->getPoolTitle();
1134  // fau: taxFilter/typeFilter - get title for extended filter conditions
1135  $filterTitle = array();
1136  $filterTitle[] = $translater->getTaxonomyFilterLabel($definition->getMappedTaxonomyFilter());
1137  $filterTitle[] = $translater->getTypeFilterLabel($definition->getTypeFilter());
1138  if (!empty($filterTitle)) {
1139  $title .= ' -> ' . implode(' / ', $filterTitle);
1140  }
1141  #$tax_id = $definition->getMappedFilterTaxId();
1142  #if($tax_id)
1143  #{
1144  # $title .= (' -> '. $translater->getTaxonomyTreeLabel($tax_id));
1145  #}
1146  #$tax_node = $definition->getMappedFilterTaxNodeId();
1147  #if($tax_node)
1148  #{
1149  # $title .= (' -> ' .$translater->getTaxonomyNodeLabel($tax_node));
1150  #}
1151  // fau.
1152  $options[$definition->getId()] = $title;
1153  }
1154  return $options;
1155  }
1156 
1160  protected function saveRandom()
1161  {
1162  $this->ctrl->saveParameter($this, 'objective_id');
1163  $this->ctrl->setParameter($this, 'tt', (int) $_REQUEST['tt']);
1164  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
1165  $this->test_type = (int) $_REQUEST['tt'];
1166 
1167  $form = $this->initFormRandom();
1168 
1169 
1170 
1171 
1172  if ($form->checkInput()) {
1174  $this->course_obj->getId(),
1175  (int) $_REQUEST['objective_id'],
1176  $this->test_type
1177  );
1178 
1179  $qst = $this->__initQuestionObject((int) $_GET['objective_id']);
1180  $qst->deleteByTestType(
1181  ($this->test_type == ilLOSettings::TYPE_TEST_INITIAL) ?
1184  );
1185  $ref_id = $this->getSettings()->getTestByType($this->test_type);
1186  foreach (array_unique((array) $form->getInput('qpl')) as $qpl_id) {
1187  include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
1188  $rnd = new ilLORandomTestQuestionPools(
1189  $this->course_obj->getId(),
1190  (int) $_REQUEST['objective_id'],
1191  $this->test_type,
1192  $qpl_id
1193  );
1194  $rnd->setLimit($form->getInput('per'));
1195  $rnd->setTestId(ilObject::_lookupObjId($ref_id));
1196  $rnd->create();
1197  }
1198  } else {
1199  $form->setValuesByPost();
1200  ilUtil::sendFailure($this->lng->txt('err_check_input'));
1201  return $this->showRandomTestAssignment();
1202  }
1203 
1204  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1205  if ($this->test_type == ilLOSettings::TYPE_TEST_QUALIFIED) {
1206  $this->ctrl->returnToParent($this);
1207  } else {
1208  $this->ctrl->redirect($this, 'finalTestAssignment');
1209  }
1210  }
1211 
1219  protected function updateFinalTestAssignment()
1220  {
1221  global $DIC;
1222 
1223  $ilAccess = $DIC['ilAccess'];
1224  $ilErr = $DIC['ilErr'];
1225  $ilObjDataCache = $DIC['ilObjDataCache'];
1226 
1227  $checked_questions = $_POST['questions'] ? $_POST['questions'] : array();
1228 
1229 
1230  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
1231  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
1232  }
1233  if (!$_GET['objective_id']) {
1234  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
1235  $this->ctrl->redirect($this, 'listObjectives');
1236  }
1237 
1238  $this->__initQuestionObject((int) $_GET['objective_id']);
1239 
1240  // Delete unchecked
1241  foreach ($this->objectives_qst_obj->getFinalTestQuestions() as $question) {
1242  $id = $question['ref_id'] . '_' . $question['question_id'];
1243  if (!in_array($id, $checked_questions)) {
1244  $this->objectives_qst_obj->delete($question['qst_ass_id']);
1245  }
1246  }
1247  // Add checked
1248  foreach ($checked_questions as $question_id) {
1249  list($test_ref_id, $qst_id) = explode('_', $question_id);
1250  $test_obj_id = $ilObjDataCache->lookupObjId($test_ref_id);
1251 
1252  if ($this->objectives_qst_obj->isFinalTestQuestion($qst_id)) {
1253  continue;
1254  }
1255 
1256  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_FINAL_TEST);
1257  $this->objectives_qst_obj->setTestRefId($test_ref_id);
1258  $this->objectives_qst_obj->setTestObjId($test_obj_id);
1259  $this->objectives_qst_obj->setQuestionId($qst_id);
1260  $this->objectives_qst_obj->add();
1261  }
1262 
1263  // TODO: not nice
1264  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
1265  $this->questions = new ilCourseObjectiveQuestion((int) $_GET['objective_id']);
1266  // not required due to percentages
1267  //$this->questions->updateLimits();
1268 
1269  ilUtil::sendSuccess($this->lng->txt('crs_objectives_assigned_lm'));
1270  $this->finalTestLimits();
1271  }
1272 
1277  protected function finalSeparatedTestAssignment(ilPropertyFormGUI $form = null)
1278  {
1279  global $DIC;
1280 
1281  $ilAccess = $DIC['ilAccess'];
1282  $ilErr = $DIC['ilErr'];
1283 
1284  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
1285  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
1286  }
1287  if (!$_GET['objective_id']) {
1288  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
1289  $this->ctrl->returnToParent($this);
1290  }
1291  $this->ctrl->saveParameter($this, 'objective_id');
1292  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
1293 
1294  $this->initWizard(self::STEP_FINAL_TEST_LIMIT);
1295  $form = $this->initFormTestAssignment();
1296  $GLOBALS['DIC']['tpl']->setContent($form->getHtml());
1297  }
1298 
1306  protected function finalTestLimits()
1307  {
1308  global $DIC;
1309 
1310  $ilAccess = $DIC['ilAccess'];
1311  $ilErr = $DIC['ilErr'];
1312  $tpl = $DIC['tpl'];
1313 
1314  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
1315  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
1316  }
1317  if (!$_GET['objective_id']) {
1318  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
1319  $this->ctrl->returnToParent($this);
1320  }
1321 
1322  $this->setSubTabs("final_test_limits");
1323 
1324  $this->ctrl->saveParameter($this, 'objective_id');
1325  $this->objective = new ilCourseObjective($this->course_obj, (int) $_GET['objective_id']);
1326 
1327  $this->__initQuestionObject((int) $_GET['objective_id']);
1328  $this->initWizard(self::STEP_FINAL_TEST_LIMIT);
1329 
1330  $this->initFormLimits('final');
1331  $GLOBALS['DIC']['tpl']->setContent($this->form->getHtml());
1332  }
1333 
1341  protected function updateFinalTestLimits()
1342  {
1343  global $DIC;
1344 
1345  $ilAccess = $DIC['ilAccess'];
1346  $ilErr = $DIC['ilErr'];
1347  $ilObjDataCache = $DIC['ilObjDataCache'];
1348 
1349  if (!$ilAccess->checkAccess('write', '', $this->course_obj->getRefId())) {
1350  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
1351  }
1352  if (!$_GET['objective_id']) {
1353  ilUtil::sendFailure($this->lng->txt('crs_no_objective_selected'), true);
1354  $this->ctrl->redirect($this, 'listObjectives');
1355  }
1356 
1357  $this->__initQuestionObject((int) $_GET['objective_id']);
1358 
1359  if ((int) $_POST['limit'] < 1 or (int) $_POST['limit'] > 100) {
1360  ilUtil::sendFailure($this->lng->txt('crs_objective_err_limit'));
1361  $this->finalTestLimits();
1362  return false;
1363  }
1364 
1365  foreach ($this->objectives_qst_obj->getFinalTests() as $test) {
1366  $this->objectives_qst_obj->setTestStatus(ilCourseObjectiveQuestion::TYPE_FINAL_TEST);
1367  $this->objectives_qst_obj->setTestSuggestedLimit((int) $_POST['limit']);
1368  $this->objectives_qst_obj->updateTest($test['test_objective_id']);
1369  }
1370 
1371  if ($_SESSION['objective_mode'] != self::MODE_CREATE) {
1372  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
1373  } else {
1374  ilUtil::sendSuccess($this->lng->txt('crs_added_objective'), true);
1375  }
1376  $this->ctrl->returnToParent($this);
1377  }
1378 
1386  protected function initFormLimits($a_mode)
1387  {
1388  if (!is_object($this->form)) {
1389  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
1390  $this->form = new ilPropertyFormGUI();
1391  }
1392  $this->form->setFormAction($this->ctrl->getFormAction($this));
1393  $this->form->setTableWidth('100%');
1394  //$this->form->setTitleIcon(ilUtil::getImagePath('icon_lobj.svg'),$this->lng->txt('crs_objective'));
1395 
1396  switch ($a_mode) {
1397  case 'selfAssessment':
1398  $this->form->setTitle($this->lng->txt('crs_objective_wiz_self_limit'));
1399  $this->form->addCommandButton('updateSelfAssessmentLimits', $this->lng->txt('crs_wiz_next'));
1400 
1401  $tests = $this->objectives_qst_obj->getSelfAssessmentTests();
1402  $max_points = $this->objectives_qst_obj->getSelfAssessmentPoints();
1403 
1404  break;
1405 
1406  case 'final':
1407  $this->form->setTitle($this->lng->txt('crs_objective_wiz_final_limit'));
1408  $this->form->addCommandButton('updateFinalTestLimits', $this->lng->txt('crs_wiz_next'));
1409 
1410  $tests = $this->objectives_qst_obj->getFinalTests();
1411  $max_points = $this->objectives_qst_obj->getFinalTestPoints();
1412 
1413  break;
1414  }
1415 
1416  $over = new ilCustomInputGUI($this->lng->txt('crs_objective_qst_summary'), '');
1417 
1418  $tpl = new ilTemplate('tpl.crs_objective_qst_summary.html', true, true, 'Modules/Course');
1419 
1420 
1421  $limit = 0;
1422 
1423  foreach ($tests as $test) {
1424  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': ' . print_r($test, true));
1425 
1426  $limit = $test['limit'];
1427 
1428  foreach ($this->objectives_qst_obj->getQuestionsOfTest($test['obj_id']) as $question) {
1429  $tpl->setCurrentBlock('qst');
1430  $tpl->setVariable('QST_TITLE', $question['title']);
1431  if (strlen($question['description'])) {
1432  $tpl->setVariable('QST_DESCRIPTION', $question['description']);
1433  }
1434  $tpl->setVariable('QST_POINTS', $question['points'] . ' ' .
1435  $this->lng->txt('crs_objective_points'));
1436  $tpl->parseCurrentBlock();
1437  }
1438  $tpl->setCurrentBlock('tst');
1439  $tpl->setVariable('TST_TITLE', ilObject::_lookupTitle($test['obj_id']));
1440  if ($desc = ilObject::_lookupDescription($test['obj_id'])) {
1441  $tpl->setVariable('TST_DESC', $desc);
1442  }
1443  $tpl->setVariable('TST_TYPE_IMG', ilUtil::getTypeIconPath('tst', $test['obj_id'], 'tiny'));
1444  $tpl->setVariable('TST_ALT_IMG', $this->lng->txt('obj_tst'));
1445  $tpl->parseCurrentBlock();
1446  }
1447 
1448  $tpl->setVariable('TXT_ALL_POINTS', $this->lng->txt('crs_objective_all_points'));
1449  $tpl->setVariable('TXT_POINTS', $this->lng->txt('crs_objective_points'));
1450  $tpl->setVariable('POINTS', $max_points);
1451 
1452  $over->setHtml($tpl->get());
1453  $this->form->addItem($over);
1454 
1455  // points
1456  $req = new ilNumberInputGUI($this->lng->txt('crs_loc_perc'), 'limit');
1457  $req->setValue($limit);
1458  $req->setSize(3);
1459  $req->setMinValue(1);
1460  $req->setMaxValue(100);
1461  $req->setRequired(true);
1462  switch ($a_mode) {
1463  case 'selfAssessment':
1464  $req->setInfo($this->lng->txt('crs_obj_initial_req_info'));
1465  break;
1466 
1467  case 'final':
1468  $req->setInfo($this->lng->txt('crs_obj_final_req_info'));
1469  break;
1470  }
1471  $this->form->addItem($req);
1472  }
1473 
1474 
1481  protected function initFormTitle($a_mode, $a_step_number)
1482  {
1483  include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
1484  if ($this->form instanceof ilPropertyFormGUI) {
1485  return;
1486  }
1487 
1488  $this->form = new ilPropertyFormGUI();
1489  $this->form->setFormAction($this->ctrl->getFormAction($this));
1490  //$this->form->setTitleIcon(ilUtil::getImagePath('icon_lobj.svg'),$this->lng->txt('crs_objective'));
1491 
1492  switch ($a_mode) {
1493  case 'create':
1494  $this->form->setTitle($this->lng->txt('crs_objective_wiz_title'));
1495  $this->form->addCommandButton('save', $this->lng->txt('crs_wiz_next'));
1496  // begin-patch lok
1497  #$this->form->addCommandButton('listObjectives',$this->lng->txt('cancel'));
1498  // end-patch lok
1499  break;
1500 
1501  case 'update':
1502  break;
1503  }
1504 
1505  $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
1506  $title->setValue($this->objective->getTitle());
1507  $title->setRequired(true);
1508  $title->setSize(40);
1509  $title->setMaxLength(70);
1510  $this->form->addItem($title);
1511 
1512  $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
1513  $desc->setValue($this->objective->getDescription());
1514  $desc->setCols(40);
1515  $desc->setRows(5);
1516  $this->form->addItem($desc);
1517  }
1518 
1519 
1526  protected function initWizard(int $active_step)
1527  {
1528  global $DIC;
1529  $steps = [];
1530  $step_positions = [];
1531 
1532  $workflow = $DIC->ui()->factory()->listing()->workflow();
1533 
1534  // 1 Settings
1535  $title = $this->lng->txt('crs_objective_wiz_title');
1536  $link = $this->ctrl->getLinkTarget($this, 'edit');
1537 
1538  $steps[] = $workflow->step($title, "", $link);
1539  $step_positions[self::STEP_SETTINGS] = count($steps) - 1;
1540 
1541  // 2 Material
1542  $title = $this->lng->txt('crs_objective_wiz_materials');
1543  $link = $this->ctrl->getLinkTarget($this, 'materialAssignment');
1544  $steps[] = $workflow->step($title, "", $link);
1545  $step_positions[self::STEP_MATERIAL_ASSIGNMENT] = count($steps) - 1;
1546 
1547 
1548  if ($this->getSettings()->worksWithInitialTest() && !$this->getSettings()->hasSeparateInitialTests()) {
1549  // 3 initial
1550  $title = $this->lng->txt('crs_objective_wiz_self');
1551  $link = $this->getSettings()->worksWithInitialTest()
1552  ? $this->ctrl->getLinkTarget($this, 'selfAssessmentAssignment')
1553  : null;
1554 
1555  $steps[] = $workflow->step($title, "", $link)
1556  ->withAvailability($link == null ? Step::NOT_AVAILABLE : Step::AVAILABLE);
1557  $step_positions[self::STEP_INITIAL_TEST_ASSIGNMENT] = count($steps) - 1;
1558 
1560  // 4 initial limit
1561  $title = $this->lng->txt('crs_objective_wiz_self_limit');
1562  $link = count($this->objectives_qst_obj->getSelfAssessmentQuestions())
1563  && $this->getSettings()->worksWithInitialTest()
1564  ? $this->ctrl->getLinkTarget($this, 'selfAssessmentLimits')
1565  : null;
1566  $steps[] = $workflow->step($title, "", $link)
1567  ->withAvailability($link == null ? Step::NOT_AVAILABLE : Step::AVAILABLE);
1568  $step_positions[self::STEP_INITIAL_TEST_LIMIT] = count($steps) - 1;
1569  }
1570  }
1571 
1572  if (!$this->getSettings()->hasSeparateQualifiedTests()) {
1573  // 5 final
1574  $title = $this->lng->txt('crs_objective_wiz_final');
1575  $link = $this->ctrl->getLinkTarget($this, 'finalTestAssignment');
1576  $steps[] = $workflow->step($title, "", $link);
1577  $step_positions[self::STEP_FINAL_TEST_ASSIGNMENT] = count($steps) - 1;
1578 
1580  // 6 final limit
1581  $title = $this->lng->txt('crs_objective_wiz_final_limit');
1582  $link = count($this->objectives_qst_obj->getFinalTestQuestions())
1583  ? $this->ctrl->getLinkTarget($this, 'finalTestLimits')
1584  : null;
1585  $steps[] = $workflow->step($title, "", $link)
1586  ->withAvailability($link == null ? Step::NOT_AVAILABLE : Step::AVAILABLE);
1587  $step_positions[self::STEP_FINAL_TEST_LIMIT] = count($steps) - 1;
1588  }
1589  }
1590 
1591  $list = $workflow->linear(
1592  $this->lng->txt('crs_checklist_objective'),
1593  $steps
1594  );
1595  if (!empty($step_positions[$active_step])) {
1596  $list = $list->withActive($step_positions[$active_step]);
1597  }
1598 
1599  $renderer = $DIC->ui()->renderer();
1600 
1601  $DIC["tpl"]->setRightContent($renderer->render($list));
1602  }
1603 }
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"]
This class represents a property form user interface.
updateSelfAssessmentLimits()
update self assessment limits
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...
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)
global $DIC
Definition: goto.php:24
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.
$steps
Definition: latex.php:3
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) ...
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