ILIAS  release_8 Revision v8.24
class.ilCourseObjectivesTableGUI.php
Go to the documentation of this file.
1<?php
2
26{
29
30 public function __construct(object $a_parent_obj, ilObject $a_course_obj)
31 {
32 global $DIC;
33
34 $this->course_obj = $a_course_obj;
35
36 $this->settings = ilLOSettings::getInstanceByObjId($this->course_obj->getId());
37
38 parent::__construct($a_parent_obj, 'listObjectives');
39 $this->lng->loadLanguageModule('crs');
40 $this->setFormName('objectives');
41 $this->addColumn('', 'f', "1px");
42 $this->addColumn($this->lng->txt('position'), 'position', '10em');
43 $this->addColumn($this->lng->txt('title'), 'title', '20%');
44 $this->addColumn($this->lng->txt('crs_objective_assigned_materials'), 'materials');
45 if ($this->getSettings()->worksWithInitialTest()) {
46 $this->addColumn($this->lng->txt('crs_objective_self_assessment'), 'self');
47 }
48 if ($this->getSettings()->getQualifyingTestType() == ilLOSettings::TYPE_QUALIFYING_SELECTED) {
49 $this->addColumn($this->lng->txt('crs_objective_tbl_col_final_tsts'), 'final');
50 } else {
51 $this->addColumn($this->lng->txt('crs_objective_final_test'), 'final');
52 }
53 $this->addColumn($this->lng->txt('actions'), '5em');
54
55 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
56 $this->setRowTemplate("tpl.crs_objectives_table_row.html", "Modules/Course");
57 $this->disable('sort');
58 $this->enable('header');
59 $this->disable('numinfo');
60 $this->enable('select_all');
61 $this->setSelectAllCheckbox('objective');
62 $this->setLimit(200);
63 $this->addMultiCommand('activateObjectives', $this->lng->txt('set_online'));
64 $this->addMultiCommand('deactivateObjectives', $this->lng->txt('set_offline'));
65 $this->addMultiCommand('askDeleteObjectives', $this->lng->txt('delete'));
66 $this->addCommandButton('saveSorting', $this->lng->txt('sorting_save'));
67 }
68
69 public function getSettings(): ilLOSettings
70 {
71 return $this->settings;
72 }
73
74 protected function fillRow(array $a_set): void
75 {
76 $this->tpl->setVariable('VAL_ID', $a_set['id']);
77 $this->tpl->setVariable('VAL_POSITION', $a_set['position']);
78
79 // begin-patch lok
80 if ($a_set['online']) {
81 $this->tpl->setVariable('VAL_ONOFFLINE', $this->lng->txt('online'));
82 $this->tpl->setVariable('ONOFFLINE_CLASS', 'smallgreen');
83 } else {
84 $this->tpl->setVariable('VAL_ONOFFLINE', $this->lng->txt('offline'));
85 $this->tpl->setVariable('ONOFFLINE_CLASS', 'smallred');
86 }
87
88 if ($a_set['passes']) {
89 $this->tpl->setVariable('PASSES_TXT', $this->lng->txt('crs_loc_passes_info'));
90 $this->tpl->setVariable('PASSES_VAL', $a_set['passes']);
91 }
92
93 // begin-patch lok
94 $this->ctrl->setParameterByClass('ilcourseobjectivesgui', 'objective_id', $a_set['id']);
95 $this->tpl->setVariable('VAL_TITLE_LINKED', $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', 'edit'));
96 // end-patch lok
97
98 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
99 if (strlen($a_set['description'])) {
100 $this->tpl->setVariable('VAL_DESC', $a_set['description']);
101 }
102
103 // materials
104 foreach ($a_set['materials'] as $data) {
105 if ($data['items'] ?? false) {
106 $this->tpl->touchBlock('ul_begin');
107 foreach ($data['items'] as $pg_st) {
108 $this->tpl->setCurrentBlock('st_pg');
109 $this->tpl->setVariable('MAT_IMG', ilObject::_getIcon($pg_st['obj_id'], "tiny", $pg_st['type']));
110 $this->tpl->setVariable('MAT_ALT', $this->lng->txt('obj_' . $pg_st['type']));
111 $title = ilLMObject::_lookupTitle($pg_st['obj_id']);
112 $this->tpl->setVariable('MAT_TITLE', $title);
113 $this->tpl->parseCurrentBlock();
114 }
115 $this->tpl->touchBlock('ul_end');
116 } else {
117 $this->tpl->touchBlock('new_line');
118 }
119 $this->tpl->setCurrentBlock('mat_row');
120 $this->tpl->setVariable('LM_IMG', ilObject::_getIcon($data['obj_id'], "tiny", $data['type']));
121 $this->tpl->setVariable('LM_ALT', $this->lng->txt('obj_' . $data['type']));
122
123 if ($data['online']) {
124 $this->tpl->setCurrentBlock('mat_online');
125 $this->tpl->setVariable('MAT_VAL_ONOFFLINE', $this->lng->txt('online'));
126 } else {
127 $this->tpl->setCurrentBlock('mat_offline');
128 $this->tpl->setVariable('MAT_VAL_ONOFFLINE', $this->lng->txt('offline'));
129 }
130 $this->tpl->parseCurrentBlock();
131 $this->tpl->setCurrentBlock('mat_row');
132
133 if ($data['type'] == 'catr' || $data['type'] == 'crsr' || $data['type'] == 'grpr') {
134 $this->tpl->setVariable(
135 'LM_TITLE',
137 );
138 } else {
139 $this->tpl->setVariable('LM_TITLE', ilObject::_lookupTitle($data['obj_id']));
140 }
141
142 $this->tpl->parseCurrentBlock();
143 }
144
145 // self assessment
146 // begin-patch lok
147 if ($this->getSettings()->worksWithInitialTest()) {
148 if ($this->getSettings()->hasSeparateInitialTests()) {
149 if ($a_set['initial'] ?? false) {
150 $obj_id = ilObject::_lookupObjId($a_set['initial']);
151 $this->tpl->setCurrentBlock('initial_test_per_objective');
152 $this->tpl->setVariable('IT_IMG', ilObject::_getIcon($obj_id, 'tiny'));
153 $this->tpl->setVariable('IT_ALT', $this->lng->txt('obj_tst'));
154 $this->tpl->setVariable('IT_TITLE', ilObject::_lookupTitle($obj_id));
155 $this->tpl->setVariable('IT_TITLE_LINK', ilLink::_getLink($a_set['initial']));
156
157 $this->ctrl->setParameterByClass('ilobjtestgui', 'ref_id', $a_set['initial']);
158 $this->ctrl->setParameterByClass('ilobjtestgui', 'cmd', 'questionsTabGateway');
159 $this->tpl->setVariable(
160 'IT_TITLE_LINK',
161 $this->ctrl->getLinkTargetByClass('ilobjtestgui')
162 );
163
164 $this->tpl->parseCurrentBlock();
165 } else {
166 $this->tpl->touchBlock('with_self_test');
167 }
168 } else {
169 foreach (($a_set['self'] ?? []) as $test) {
170 // begin-patch lok
171 foreach ((array) ($test['questions'] ?? []) as $question) {
172 $this->tpl->setCurrentBlock('self_qst_row');
173 $this->tpl->setVariable('SELF_QST_TITLE', $question['title']);
174 $this->tpl->parseCurrentBlock();
175 }
176 if (count($test['questions'] ?? []) === 0) {
177 $this->tpl->touchBlock('self_qst_row');
178 }
179 // end-patch lok
180 }
181 // begin-patch lok
182 if (count($a_set['self'] ?? []) === 0) {
183 $this->tpl->touchBlock('self_qst_row');
184 }
185 }
186
187 // end-patch lok
188 }
189 // end-patch lok
190
191 // final test questions
192 if ($this->getSettings()->getQualifyingTestType() == ilLOSettings::TYPE_QUALIFYING_SELECTED) {
193 if ($a_set['final'] ?? false) {
194 $obj_id = ilObject::_lookupObjId($a_set['final']);
195 $this->tpl->setCurrentBlock('final_test_per_objective');
196 $this->tpl->setVariable('FT_IMG', ilObject::_getIcon($obj_id, 'tiny'));
197 $this->tpl->setVariable('FT_ALT', $this->lng->txt('obj_tst'));
198 $this->tpl->setVariable('FT_TITLE', ilObject::_lookupTitle($obj_id));
199
200 $this->ctrl->setParameterByClass('ilobjtestgui', 'ref_id', $a_set['final']);
201 $this->ctrl->setParameterByClass('ilobjtestgui', 'cmd', 'questionsTabGateway');
202 $this->tpl->setVariable(
203 'FT_TITLE_LINK',
204 $this->ctrl->getLinkTargetByClass('ilobjtestgui')
205 );
206
207 $this->tpl->parseCurrentBlock();
208 } else {
209 $this->tpl->touchBlock('with_final_test');
210 }
211 } else {
212 foreach ((array) ($a_set['final'] ?? []) as $test) {
213 foreach ((array) ($test['questions'] ?? []) as $question) {
214 $this->tpl->setCurrentBlock('final_qst_row');
215 $this->tpl->setVariable('FINAL_QST_TITLE', $question['title'] ?? '');
216 $this->tpl->parseCurrentBlock();
217 }
218 if (count($test['questions'] ?? []) === 0) {
219 $this->tpl->touchBlock('final_qst_row');
220 }
221 }
222 if (count($a_set['final'] ?? []) === 0) {
223 $this->tpl->touchBlock('final_qst_row');
224 }
225 }
226 $this->ctrl->setParameterByClass('ilcourseobjectivesgui', 'objective_id', $a_set['id']);
227 $this->tpl->setVariable('EDIT_LINK', $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', 'edit'));
228 $this->tpl->setVariable('TXT_EDIT', $this->lng->txt('edit'));
229
230 $alist = new ilAdvancedSelectionListGUI();
231 $alist->setId($a_set['id']);
232
233 $alist->addItem(
234 $this->lng->txt('edit'),
235 '',
236 $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', 'edit')
237 );
238 // materials
239 $alist->addItem(
240 $this->lng->txt('crs_objective_action_materials'),
241 '',
242 $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', 'materialAssignment')
243 );
244 // itest
245 if ($this->getSettings()->worksWithInitialTest() && !$this->getSettings()->hasSeparateInitialTests()) {
246 $alist->addItem(
247 $this->lng->txt('crs_objective_action_itest'),
248 '',
249 $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', 'selfAssessmentAssignment')
250 );
251 }
252 // qtest
253 if ($this->getSettings()->hasSeparateQualifiedTests()) {
254 // @todo
255 } else {
256 $alist->addItem(
257 $this->lng->txt('crs_objective_action_qtest'),
258 '',
259 $this->ctrl->getLinkTargetByClass('ilcourseobjectivesgui', 'finalTestAssignment')
260 );
261 }
262
263 $this->ctrl->setParameterByClass('illopagegui', 'objective_id', $a_set['id']);
264 $alist->addItem(
265 $this->lng->txt('crs_edit_lo_introduction'),
266 '',
267 $this->ctrl->getLinkTargetByClass('illopagegui', 'edit')
268 );
269
270 $this->tpl->setVariable('VAL_ACTIONS', $alist->getHTML());
271
272 // end-patch lok
273 }
274
275 public function parse(array $a_objective_ids): void
276 {
277 $position = 1;
278 $objectives = [];
279 foreach ($a_objective_ids as $objective_id) {
280 $objective = new ilCourseObjective($this->course_obj, $objective_id);
281
282 $objective_data = [];
283 $objective_data['id'] = $objective_id;
284 $objective_data['position'] = sprintf("%.1f", $position++) * 10;
285 $objective_data['title'] = $objective->getTitle();
286 $objective_data['description'] = $objective->getDescription();
287
288 $objective_data['online'] = $objective->isActive();
289 $objective_data['passes'] = $objective->getPasses();
290
291 // assigned materials
292 $materials = array();
293 $ass_materials = new ilCourseObjectiveMaterials($objective_id);
294 foreach ($ass_materials->getMaterials() as $material) {
295 $materials[$material['ref_id']]['obj_id'] = $obj_id = ilObject::_lookupObjId($material['ref_id']);
296 $materials[$material['ref_id']]['type'] = ilObject::_lookupType($obj_id);
297
298 switch ($material['type']) {
299 case 'pg':
300 case 'st':
301 $materials[$material['ref_id']]['items'][] = $material;
302 break;
303 default:
304
305 }
306 $materials[$material['ref_id']]['online'] = !ilObject::lookupOfflineStatus($obj_id);
307 }
308 $objective_data['materials'] = $materials;
309 $question_obj = new ilCourseObjectiveQuestion($objective_id);
310
311 // self assessment questions
312 // begin-patch lok
313 if ($this->getSettings()->worksWithInitialTest()) {
314 if ($this->getSettings()->hasSeparateInitialTests()) {
315 $assignments = ilLOTestAssignments::getInstance($this->course_obj->getId());
316 $assignment = $assignments->getAssignmentByObjective(
317 $objective_id,
319 );
320
321 $objective_data['initial'] = 0;
322 if ($assignment instanceof ilLOTestAssignment) {
323 $test_id = $assignment->getTestRefId();
324
326 $test_candidate = $factory->getInstanceByRefId($test_id, false);
327 if ($test_candidate instanceof ilObjTest) {
328 $objective_data['initial'] = $test_id;
329 }
330 }
331 } elseif (ilLOUtils::lookupRandomTest(ilObject::_lookupObjId($this->getSettings()->getInitialTest()))) {
332 $test = array();
333 $objective_data['self'] = [];
335 $this->course_obj->getId(),
336 $objective_id,
337 ilObject::_lookupObjId($this->getSettings()->getInitialTest()),
339 ) as $sequence_id
340 ) {
341 $test['obj_id'] = ilObject::_lookupObjId($this->getSettings()->getInitialTest());
342 $qst = ilLOUtils::lookupQplBySequence($this->getSettings()->getInitialTest(), $sequence_id);
343 if ($qst) {
344 $test['questions'][] = array('title' => $qst);
345 }
346 $objective_data['self'] = array($test);
347 }
348 } else {
349 $tests = array();
350 foreach ($question_obj->getSelfAssessmentTests() as $test) {
351 $questions = array();
352 foreach ($question_obj->getQuestionsOfTest($test['obj_id']) as $qst) {
353 $questions[] = $qst;
354 }
355 $tmp_test = $test;
356 $tmp_test['questions'] = $questions;
357
358 $tests[] = $tmp_test;
359 }
360 $objective_data['self'] = $tests;
361 }
362 }
363
364 if ($this->getSettings()->getQualifyingTestType() == ilLOSettings::TYPE_QUALIFYING_SELECTED) {
365 $assignments = ilLOTestAssignments::getInstance($this->course_obj->getId());
366 $assignment = $assignments->getAssignmentByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED);
367
368 $objective_data['final'] = 0;
369 if ($assignment instanceof ilLOTestAssignment) {
370 $test_id = $assignment->getTestRefId();
371
373 $test_candidate = $factory->getInstanceByRefId($test_id, false);
374 if ($test_candidate instanceof ilObjTest) {
375 $objective_data['final'] = $test_id;
376 }
377 }
378 } elseif ($this->getSettings()->getQualifiedTest()) {
379 if (ilLOUtils::lookupRandomTest(ilObject::_lookupObjId($this->getSettings()->getQualifiedTest()))) {
380 $test = array();
382 $this->course_obj->getId(),
383 $objective_id,
384 ilObject::_lookupObjId($this->getSettings()->getQualifiedTest()),
386 ) as $sequence_id
387 ) {
388 $test['obj_id'] = ilObject::_lookupObjId($this->getSettings()->getQualifiedTest());
389 $qst = ilLOUtils::lookupQplBySequence($this->getSettings()->getQualifiedTest(), $sequence_id);
390 if ($qst) {
391 $test['questions'][] = array('title' => $qst);
392 }
393 $objective_data['final'] = array($test);
394 }
395 } else {
396 $tests = array();
397 foreach ($question_obj->getFinalTests() as $test) {
398 $questions = array();
399 foreach ($question_obj->getQuestionsOfTest($test['obj_id']) as $qst) {
400 $questions[] = $qst;
401 }
402 $tmp_test = $test;
403 $tmp_test['questions'] = $questions;
404
405 $tests[] = $tmp_test;
406 }
407 $objective_data['final'] = $tests;
408 }
409 }
410 // end-patch lok
411 $objectives[] = $objective_data;
412 }
413 $this->setData($objectives);
414 }
415}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTargetTitle(int $a_obj_id)
class ilCourseObjectiveMaterials
class ilcourseobjectiveQuestion
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(object $a_parent_obj, ilObject $a_course_obj)
fillRow(array $a_set)
Standard Version of Fill Row.
static _lookupTitle(int $a_obj_id)
static lookupSequencesByType(int $a_container_id, int $a_objective_id, int $a_test_id, int $a_test_type)
Settings for LO courses.
static getInstanceByObjId(int $a_obj_id)
const TYPE_QUALIFYING_SELECTED
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(int $a_container_id)
static lookupRandomTest(int $a_test_obj_id)
static lookupQplBySequence(int $a_test_ref_id, int $a_sequence_id)
Lookup assigned qpl name (including taxonomy) by sequence.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setFormName(string $a_name="")
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setData(array $a_data)
Set table data.
enable(string $a_module_name)
disable(string $a_module_name)
global $DIC
Definition: feed.php:28
$factory
Definition: metadata.php:75
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$objectives