ILIAS  release_8 Revision v8.24
class.ilCourseObjectiveQuestionAssignmentTableGUI.php
Go to the documentation of this file.
1<?php
18declare(strict_types=0);
19
26{
28 private int $mode = 0;
30
31 private int $objective_id = 0;
33
35 protected ilTree $tree;
36
37 public function __construct(object $a_parent_obj, ilObject $a_course_obj, int $a_objective_id, int $a_mode)
38 {
39 global $DIC;
40
41 $this->objective_id = $a_objective_id;
42 $this->course_obj = $a_course_obj;
43 $this->settings = ilLOSettings::getInstanceByObjId($this->course_obj->getId());
44 $this->objDefinition = $DIC['objDefinition'];
45 $this->tree = $DIC->repositoryTree();
46
47 parent::__construct($a_parent_obj, 'materialAssignment');
48 $this->lng->loadLanguageModule('crs');
49
50 $this->setFormName('assignments');
51 $this->addColumn($this->lng->txt('type'), 'type', "20px");
52 $this->addColumn($this->lng->txt('title'), 'title', '');
53
54 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
55 $this->setRowTemplate("tpl.crs_objective_list_questions_row.html", "Modules/Course");
56 $this->disable('sort');
57 $this->disable('header');
58 $this->disable('numinfo');
59 $this->disable('select_all');
60
61 #$this->setDefaultOrderField('title');
62 $this->setLimit(200);
63
64 $this->mode = $a_mode;
65 switch ($a_mode) {
67 $this->addCommandButton('updateSelfAssessmentAssignment', $this->lng->txt('crs_wiz_next'));
68 break;
69
71 $this->addCommandButton('updateFinalTestAssignment', $this->lng->txt('crs_wiz_next'));
72 break;
73 }
74
76 }
77
78 public function getSettings(): ilLOSettings
79 {
80 return $this->settings;
81 }
82
83 protected function fillRow(array $a_set): void
84 {
85 foreach ($a_set['sub'] as $sub_data) {
86 if ($sub_data['description']) {
87 $this->tpl->setVariable('QST_DESCRIPTION', $sub_data['description']);
88 }
89 if ($sub_data['qst_txt']) {
90 $txt = $sub_data['qst_txt'];
91 if ($sub_data['qst_points']) {
92 $this->lng->loadLanguageModule('assessment');
93 $txt .= (' (' . $sub_data['qst_points'] . ' ' . $this->lng->txt('points') . ')');
94 }
95
96 $this->tpl->setVariable('QST_DESCRIPTION', $txt);
97 }
98 $this->tpl->setCurrentBlock('qst');
99 $this->tpl->setVariable('QST_TITLE', $sub_data['title']);
100 $this->tpl->setVariable('QST_ID', $a_set['id'] . '_' . $sub_data['id']);
101
102 switch ($this->mode) {
104 if ($this->objective_qst_obj->isSelfAssessmentQuestion($sub_data['id'])) {
105 $this->tpl->setVariable('QST_CHECKED', 'checked="checked"');
106 }
107 break;
108
110 if ($this->objective_qst_obj->isFinalTestQuestion($sub_data['id'])) {
111 $this->tpl->setVariable('QST_CHECKED', 'checked="checked"');
112 }
113 break;
114 }
115 $this->tpl->parseCurrentBlock();
116 }
117 if (count($a_set['sub'])) {
118 $this->tpl->setVariable('TXT_QUESTIONS', $this->lng->txt('objs_qst'));
119 }
120 $this->tpl->setVariable('VAL_ID', $a_set['id']);
121
122 $this->tpl->setVariable('ROW_TYPE_IMG', ilObject::_getIcon($a_set['obj_id'], "tiny", $a_set['type']));
123 $this->tpl->setVariable('ROW_TYPE_ALT', $this->lng->txt('obj_' . $a_set['type']));
124
125 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
126 if (strlen($a_set['description'])) {
127 $this->tpl->setVariable('VAL_DESC', $a_set['description']);
128 }
129 }
130
131 public function parse(array $a_assignable): void
132 {
133 $a_assignable = $this->getTestNode();
134 $tests = array();
135 foreach ($a_assignable as $node) {
136 $tmp_data = array();
137 $subobjects = array();
138
139 if (!$tmp_tst = ilObjectFactory::getInstanceByRefId((int) ($node['ref_id'] ?? 0), false)) {
140 continue;
141 }
142
143 foreach ($qst = $this->sortQuestions($tmp_tst->getAllQuestions()) as $question_data) {
144 $tmp_question = ilObjTest::_instanciateQuestion($question_data['question_id']);
145 #$sub['qst_txt'] = $tmp_question->_getQuestionText($question_data['question_id']);
146 $sub['qst_txt'] = '';
147 $sub['qst_points'] = assQuestion::_getMaximumPoints($question_data['question_id']);
148
149 $sub['title'] = $tmp_question->getTitle();
150 $sub['description'] = $tmp_question->getComment();
151 $sub['id'] = $question_data['question_id'];
152
153 $subobjects[] = $sub;
154 }
155 $tmp_data['title'] = $node['title'];
156 $tmp_data['description'] = $node['description'];
157 $tmp_data['type'] = $node['type'];
158 $tmp_data['id'] = $node['child'];
159 $tmp_data['obj_id'] = $node['obj_id'];
160 $tmp_data['sub'] = $subobjects;
161 $tests[] = $tmp_data;
162 }
163 $this->setData($tests);
164 }
165
166 protected function getTestNode(): array
167 {
169 $tst_ref_id = $this->getSettings()->getInitialTest();
170 if ($tst_ref_id) {
171 return array($this->tree->getNodeData($tst_ref_id));
172 }
173 }
175 $tst_ref_id = $this->getSettings()->getQualifiedTest();
176 if ($tst_ref_id) {
177 return array($this->tree->getNodeData($tst_ref_id));
178 }
179 }
180 return [];
181 }
182
183 // end-patch lok
184
185 protected function initQuestionAssignments(): void
186 {
187 $this->objective_qst_obj = new ilCourseObjectiveQuestion($this->objective_id);
188 }
189
190 protected function sortQuestions(array $a_qst_ids): array
191 {
192 return ilArrayUtil::sortArray($a_qst_ids, 'title', 'asc');
193 }
194}
static _getMaximumPoints(int $question_id)
Returns the maximum points, a learner can reach answering the question.
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
TableGUI for question assignments of course objectives.
__construct(object $a_parent_obj, ilObject $a_course_obj, int $a_objective_id, int $a_mode)
class ilcourseobjectiveQuestion
Settings for LO courses.
static getInstanceByObjId(int $a_obj_id)
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
parses the objects.xml it handles the xml-description of all ilias objects
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
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="")
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)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setData(array $a_data)
Set table data.
disable(string $a_module_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$txt
Definition: error.php:13
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc