ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCourseObjectivesTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 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 include_once('./Services/Table/classes/class.ilTable2GUI.php');
25 include_once './Modules/Course/classes/class.ilCourseObjective.php';
26 include_once('./Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
27 include_once('./Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
28 include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
29 
30 // begin-patch lok
31 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
32 // end-patch lok
33 
42 {
43  protected $course_obj = null;
44 
45  // begin-patch lok
46  protected $settings = null;
47  // end-patch lok
48 
56  public function __construct($a_parent_obj, $a_course_obj)
57  {
58  global $lng,$ilCtrl;
59 
60  $this->course_obj = $a_course_obj;
61 
62  // begin-patch lok
63  $this->settings = ilLOSettings::getInstanceByObjId($this->course_obj->getId());
64  // end-patch lok
65 
66  $this->lng = $lng;
67  $this->lng->loadLanguageModule('crs');
68  $this->ctrl = $ilCtrl;
69 
70  parent::__construct($a_parent_obj, 'listObjectives');
71  $this->setFormName('objectives');
72  $this->addColumn('', 'f', "1px");
73  $this->addColumn($this->lng->txt('position'), 'position', '10em');
74  $this->addColumn($this->lng->txt('title'), 'title', '20%');
75  $this->addColumn($this->lng->txt('crs_objective_assigned_materials'), 'materials');
76  // begin-patch lok
77  if ($this->getSettings()->worksWithInitialTest()) {
78  $this->addColumn($this->lng->txt('crs_objective_self_assessment'), 'self');
79  }
80  // end-patch lok
81  if ($this->getSettings()->getQualifyingTestType() == ilLOSettings::TYPE_QUALIFYING_SELECTED) {
82  $this->addColumn($this->lng->txt('crs_objective_tbl_col_final_tsts'), 'final');
83  } else {
84  $this->addColumn($this->lng->txt('crs_objective_final_test'), 'final');
85  }
86  $this->addColumn($this->lng->txt('actions'), '5em');
87 
88  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
89  $this->setRowTemplate("tpl.crs_objectives_table_row.html", "Modules/Course");
90  $this->disable('sort');
91  $this->enable('header');
92  $this->disable('numinfo');
93  $this->enable('select_all');
94  // begin-patch lok
95  $this->setSelectAllCheckbox('objective');
96  // end-patch lok
97  $this->setLimit(200);
98 
99  // begin-patch lo
100  $this->addMultiCommand('activateObjectives', $this->lng->txt('set_online'));
101  $this->addMultiCommand('deactivateObjectives', $this->lng->txt('set_offline'));
102  $this->addMultiCommand('askDeleteObjectives', $this->lng->txt('delete'));
103  // end-patch lok
104  $this->addCommandButton('saveSorting', $this->lng->txt('sorting_save'));
105  // $this->addCommandButton('create',$this->lng->txt('crs_add_objective'));
106  }
107 
108  // begin-patch lok
113  public function getSettings()
114  {
115  return $this->settings;
116  }
117  // end-patch lok
118 
119 
127  protected function fillRow($a_set)
128  {
129  $this->tpl->setVariable('VAL_ID', $a_set['id']);
130  $this->tpl->setVariable('VAL_POSITION', $a_set['position']);
131 
132  // begin-patch lok
133  if ($a_set['online']) {
134  $this->tpl->setVariable('VAL_ONOFFLINE', $this->lng->txt('online'));
135  $this->tpl->setVariable('ONOFFLINE_CLASS', 'smallgreen');
136  } else {
137  $this->tpl->setVariable('VAL_ONOFFLINE', $this->lng->txt('offline'));
138  $this->tpl->setVariable('ONOFFLINE_CLASS', 'smallred');
139  }
140 
141  if ($a_set['passes']) {
142  $this->tpl->setVariable('PASSES_TXT', $this->lng->txt('crs_loc_passes_info'));
143  $this->tpl->setVariable('PASSES_VAL', $a_set['passes']);
144  }
145 
146 
147  // begin-patch lok
148  $this->ctrl->setParameterByClass('ilcourseobjectivesgui', 'objective_id', $a_set['id']);
149  $this->tpl->setVariable('VAL_TITLE_LINKED', $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', 'edit'));
150  // end-patch lok
151 
152  $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
153  if (strlen($a_set['description'])) {
154  $this->tpl->setVariable('VAL_DESC', $a_set['description']);
155  }
156 
157  // materials
158  foreach ($a_set['materials'] as $ref_id => $data) {
159  if ($data['items']) {
160  $this->tpl->touchBlock('ul_begin');
161  foreach ($data['items'] as $pg_st) {
162  $this->tpl->setCurrentBlock('st_pg');
163  $this->tpl->setVariable('MAT_IMG', ilObject::_getIcon($pg_st['obj_id'], "tiny", $pg_st['type']));
164  $this->tpl->setVariable('MAT_ALT', $this->lng->txt('obj_' . $pg_st['type']));
165  include_once('Modules/LearningModule/classes/class.ilLMObject.php');
166  $title = ilLMObject::_lookupTitle($pg_st['obj_id']);
167  $this->tpl->setVariable('MAT_TITLE', $title);
168  $this->tpl->parseCurrentBlock();
169  }
170  $this->tpl->touchBlock('ul_end');
171  } else {
172  $this->tpl->touchBlock('new_line');
173  }
174  $this->tpl->setCurrentBlock('mat_row');
175  $this->tpl->setVariable('LM_IMG', ilObject::_getIcon($data['obj_id'], "tiny", $data['type']));
176  $this->tpl->setVariable('LM_ALT', $this->lng->txt('obj_' . $data['type']));
177 
178  if ($data['type'] == 'catr' or $data['type'] == 'crsr' or $data['type'] == 'grpr') {
179  include_once './Services/ContainerReference/classes/class.ilContainerReference.php';
180  $this->tpl->setVariable(
181  'LM_TITLE',
183  );
184  } else {
185  $this->tpl->setVariable('LM_TITLE', ilObject::_lookupTitle($data['obj_id']));
186  }
187  $this->tpl->parseCurrentBlock();
188  }
189 
190  // self assessment
191  // begin-patch lok
192  if ($this->getSettings()->worksWithInitialTest()) {
193  if ($this->getSettings()->hasSeparateInitialTests()) {
194  if ($a_set['initial']) {
195  include_once './Services/Link/classes/class.ilLink.php';
196  $obj_id = ilObject::_lookupObjId($a_set['initial']);
197  $this->tpl->setCurrentBlock('initial_test_per_objective');
198  $this->tpl->setVariable('IT_IMG', ilObject::_getIcon($obj_id, 'tiny'));
199  $this->tpl->setVariable('IT_ALT', $this->lng->txt('obj_tst'));
200  $this->tpl->setVariable('IT_TITLE', ilObject::_lookupTitle($obj_id));
201  $this->tpl->setVariable('IT_TITLE_LINK', ilLink::_getLink($a_set['initial']));
202 
203  include_once './Services/Link/classes/class.ilLink.php';
204  $this->ctrl->setParameterByClass('ilobjtestgui', 'ref_id', $a_set['initial']);
205  $this->ctrl->setParameterByClass('ilobjtestgui', 'cmd', 'questionsTabGateway');
206  $this->tpl->setVariable(
207  'IT_TITLE_LINK',
208  $this->ctrl->getLinkTargetByClass('ilobjtestgui')
209  );
210 
211  $this->tpl->parseCurrentBlock();
212  } else {
213  $this->tpl->touchBlock('initial_test_per_objective');
214  }
215  } else {
216  foreach ($a_set['self'] as $test) {
217  // begin-patch lok
218  foreach ((array) $test['questions'] as $question) {
219  $this->tpl->setCurrentBlock('self_qst_row');
220  $this->tpl->setVariable('SELF_QST_TITLE', $question['title']);
221  $this->tpl->parseCurrentBlock();
222  }
223  // end-patch lok
224  }
225  // begin-patch lok
226  if (!count($a_set['self'])) {
227  $this->tpl->touchBlock('self_qst_row');
228  }
229  }
230 
231  // end-patch lok
232  }
233  // end-patch lok
234 
235  // final test questions
236  if ($this->getSettings()->getQualifyingTestType() == ilLOSettings::TYPE_QUALIFYING_SELECTED) {
237  if ($a_set['final']) {
238  $obj_id = ilObject::_lookupObjId($a_set['final']);
239  $this->tpl->setCurrentBlock('final_test_per_objective');
240  $this->tpl->setVariable('FT_IMG', ilObject::_getIcon($obj_id, 'tiny'));
241  $this->tpl->setVariable('FT_ALT', $this->lng->txt('obj_tst'));
242  $this->tpl->setVariable('FT_TITLE', ilObject::_lookupTitle($obj_id));
243 
244  include_once './Services/Link/classes/class.ilLink.php';
245  $this->ctrl->setParameterByClass('ilobjtestgui', 'ref_id', $a_set['final']);
246  $this->ctrl->setParameterByClass('ilobjtestgui', 'cmd', 'questionsTabGateway');
247  $this->tpl->setVariable(
248  'FT_TITLE_LINK',
249  $this->ctrl->getLinkTargetByClass('ilobjtestgui')
250  );
251 
252 
253  $this->tpl->parseCurrentBlock();
254  } else {
255  $this->tpl->touchBlock('final_test_per_objective');
256  }
257  } else {
258  foreach ((array) $a_set['final'] as $test) {
259  foreach ((array) $test['questions'] as $question) {
260  $this->tpl->setCurrentBlock('final_qst_row');
261  $this->tpl->setVariable('FINAL_QST_TITLE', $question['title']);
262  $this->tpl->parseCurrentBlock();
263  }
264  // begin-patch lok
265  #$this->tpl->setCurrentBlock('final_test_row');
266  #$this->tpl->setVariable('FINAL_TST_IMG',ilUtil::getImagePath('icon_tst_s.png'));
267  #$this->tpl->setVariable('FINAL_TST_ALT',$this->lng->txt('obj_tst'));
268  #$this->tpl->setVariable('FINAL_TST_TITLE',ilObject::_lookupTitle($test['obj_id']));
269  #$this->tpl->parseCurrentBlock();
270  // end-patch lok
271  }
272  }
273 
274  // begin-patch lok
275  // Edit Link
276  #$this->ctrl->setParameterByClass(get_class($this->getParentObject()),'objective_id',$a_set['id']);
277  $this->ctrl->setParameterByClass('ilcourseobjectivesgui', 'objective_id', $a_set['id']);
278  #$this->tpl->setVariable('EDIT_LINK',$this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()),'edit'));
279  $this->tpl->setVariable('EDIT_LINK', $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', 'edit'));
280  // end-patch lok
281  $this->tpl->setVariable('TXT_EDIT', $this->lng->txt('edit'));
282 
283  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
284  $alist = new ilAdvancedSelectionListGUI();
285  $alist->setId($a_set['id']);
286  //$alist->setListTitle($this->lng->txt("actions"));
287 
288  $alist->addItem(
289  $this->lng->txt('edit'),
290  '',
291  $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', 'edit')
292  );
293  // materials
294  $alist->addItem(
295  $this->lng->txt('crs_objective_action_materials'),
296  '',
297  $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', 'materialAssignment')
298  );
299  // itest
300  if ($this->getSettings()->worksWithInitialTest() && !$this->getSettings()->hasSeparateInitialTests()) {
301  $alist->addItem(
302  $this->lng->txt('crs_objective_action_itest'),
303  '',
304  $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', 'selfAssessmentAssignment')
305  );
306  }
307  // qtest
308  if ($this->getSettings()->hasSeparateQualifiedTests()) {
309  #$alist->addItem(
310  # $this->lng->txt('crs_objective_action_qtest_sep'),
311  # '',
312  # $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', 'finalSeparatedTestAssignment')
313  #);
314  } else {
315  $alist->addItem(
316  $this->lng->txt('crs_objective_action_qtest'),
317  '',
318  $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', 'finalTestAssignment')
319  );
320  }
321 
322  $this->ctrl->setParameterByClass('illopagegui', 'objective_id', $a_set['id']);
323  $alist->addItem(
324  $this->lng->txt('crs_edit_lo_introduction'),
325  '',
326  $this->ctrl->getLinkTargetByClass('illopagegui', 'edit')
327  );
328 
329 
330  $this->tpl->setVariable('VAL_ACTIONS', $alist->getHTML());
331 
332  // end-patch lok
333  }
334 
335 
342  public function parse($a_objective_ids)
343  {
344  $position = 1;
345  foreach ($a_objective_ids as $objective_id) {
346  $objective = new ilCourseObjective($this->course_obj, $objective_id);
347 
348  $objective_data = [];
349  $objective_data['id'] = $objective_id;
350  $objective_data['position'] = sprintf("%.1f", $position++) * 10;
351  $objective_data['title'] = $objective->getTitle();
352  $objective_data['description'] = $objective->getDescription();
353 
354  // begin-patch lok
355  $objective_data['online'] = $objective->isActive();
356  $objective_data['passes'] = $objective->getPasses();
357  // end-patch lok
358 
359  // assigned materials
360  $materials = array();
361  $ass_materials = new ilCourseObjectiveMaterials($objective_id);
362  foreach ($ass_materials->getMaterials() as $material) {
363  $materials[$material['ref_id']]['obj_id'] = $obj_id = ilObject::_lookupObjId($material['ref_id']);
364  $materials[$material['ref_id']]['type'] = ilObject::_lookupType($obj_id);
365 
366  switch ($material['type']) {
367  case 'pg':
368  case 'st':
369  $materials[$material['ref_id']]['items'][] = $material;
370  break;
371  default:
372 
373  }
374  }
375  $objective_data['materials'] = $materials;
376  $question_obj = new ilCourseObjectiveQuestion($objective_id);
377 
378  // self assessment questions
379  // begin-patch lok
380  if ($this->getSettings()->worksWithInitialTest()) {
381  if ($this->getSettings()->hasSeparateInitialTests()) {
382  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
383  $assignments = ilLOTestAssignments::getInstance($this->course_obj->getId());
384  $assignment = $assignments->getAssignmentByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL);
385 
386  $objective_data['initial'] = 0;
387  if ($assignment instanceof ilLOTestAssignment) {
388  $test_id = $assignment->getTestRefId();
389 
390  include_once './Services/Object/classes/class.ilObjectFactory.php';
391  $factory = new ilObjectFactory();
392  $test_candidate = $factory->getInstanceByRefId($test_id, false);
393  if ($test_candidate instanceof ilObjTest) {
394  $objective_data['initial'] = $test_id;
395  }
396  }
397  } elseif (ilLOUtils::lookupRandomTest(ilObject::_lookupObjId($this->getSettings()->getInitialTest()))) {
398  $test = array();
399  $objective_data['self'] = [];
401  $this->course_obj->getId(),
402  $objective_id,
403  ilObject::_lookupObjId($this->getSettings()->getInitialTest()),
405  ) as $sequence_id
406  ) {
407  $test['obj_id'] = ilObject::_lookupObjId($this->getSettings()->getInitialTest());
408  $qst = ilLOUtils::lookupQplBySequence($this->getSettings()->getInitialTest(), $sequence_id);
409  if ($qst) {
410  $test['questions'][] = array('title' => $qst);
411  }
412  $objective_data['self'] = array($test);
413  }
414  } else {
415  $tests = array();
416  foreach ($question_obj->getSelfAssessmentTests() as $test) {
417  $questions = array();
418  foreach ($question_obj->getQuestionsOfTest($test['obj_id']) as $qst) {
419  $questions[] = $qst;
420  }
421  $tmp_test = $test;
422  $tmp_test['questions'] = $questions;
423 
424  $tests[] = $tmp_test;
425  }
426  $objective_data['self'] = $tests;
427  }
428  }
429  // end-patch lok
430 
431  // final test questions
432  // begin-patch lok
433  // single test assignments
434  if ($this->getSettings()->getQualifyingTestType() == ilLOSettings::TYPE_QUALIFYING_SELECTED) {
435  include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
436  $assignments = ilLOTestAssignments::getInstance($this->course_obj->getId());
437  $assignment = $assignments->getAssignmentByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED);
438 
439  $objective_data['final'] = 0;
440  if ($assignment instanceof ilLOTestAssignment) {
441  $test_id = $assignment->getTestRefId();
442 
443  include_once './Services/Object/classes/class.ilObjectFactory.php';
444  $factory = new ilObjectFactory();
445  $test_candidate = $factory->getInstanceByRefId($test_id, false);
446  if ($test_candidate instanceof ilObjTest) {
447  $objective_data['final'] = $test_id;
448  }
449  }
450  } elseif ($this->getSettings()->getQualifiedTest()) {
451  if (ilLOUtils::lookupRandomTest(ilObject::_lookupObjId($this->getSettings()->getQualifiedTest()))) {
452  $test = array();
454  $this->course_obj->getId(),
455  $objective_id,
456  ilObject::_lookupObjId($this->getSettings()->getQualifiedTest()),
458  ) as $sequence_id
459  ) {
460  $test['obj_id'] = ilObject::_lookupObjId($this->getSettings()->getQualifiedTest());
461  $qst = ilLOUtils::lookupQplBySequence($this->getSettings()->getQualifiedTest(), $sequence_id);
462  if ($qst) {
463  $test['questions'][] = array('title' => $qst);
464  }
465  $objective_data['final'] = array($test);
466  }
467  } else {
468  $tests = array();
469  foreach ($question_obj->getFinalTests() as $test) {
470  $questions = array();
471  foreach ($question_obj->getQuestionsOfTest($test['obj_id']) as $qst) {
472  $questions[] = $qst;
473  }
474  $tmp_test = $test;
475  $tmp_test['questions'] = $questions;
476 
477  $tests[] = $tmp_test;
478  }
479  $objective_data['final'] = $tests;
480  }
481  }
482  // end-patch lok
483  $objectives[] = (array) $objective_data;
484  }
485  $this->setData($objectives ? $objectives : array());
486  }
487 }
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
static getInstanceByObjId($a_obj_id)
get singleton instance
static getInstance($a_container_id)
Get instance by container id.
Class ilObjectFactory.
$factory
Definition: metadata.php:47
static _lookupTitle($a_id)
lookup object title
static _lookupTitle($a_obj_id)
Lookup title.
global $ilCtrl
Definition: ilias.php:18
class ilCourseObjectiveMaterials
Class ilTable2GUI.
__construct($a_parent_obj, $a_course_obj)
Constructor.
static lookupRandomTest($a_test_obj_id)
Check if test is a random test.
class ilcourseobjective
static _lookupObjId($a_id)
addMultiCommand($a_cmd, $a_text)
Add Command button.
enable($a_module_name)
enables particular modules of table
static _lookupTargetTitle($a_obj_id)
Lookup target title.
static lookupSequencesByType($a_container_id, $a_objective_id, $a_test_id, $a_test_type)
Lookup sequence ids type $ilDB.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
User interface class for advanced drop-down selection lists.
Settings for LO courses.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
settings()
Definition: settings.php:2
disable($a_module_name)
diesables particular modules of table
setFormName($a_formname="")
Set Form name.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
const TYPE_QUALIFYING_SELECTED
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
class ilcourseobjectiveQuestion
static lookupQplBySequence($a_test_ref_id, $a_sequence_id)
Lookup assigned qpl name (including taxonomy) by sequence.
setLimit($a_limit=0, $a_default_limit=0)
$test
Definition: Utf8Test.php:84