ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
class.ilCourseObjectiveQuestionAssignmentTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
27{
29 private int $mode = 0;
31
32 private int $objective_id = 0;
34 private \ILIAS\TestQuestionPool\Questions\PublicInterface $questioninfo;
35
37 protected ilTree $tree;
38
39 public function __construct(object $a_parent_obj, ilObject $a_course_obj, int $a_objective_id, int $a_mode)
40 {
41 global $DIC;
42
43 $this->objective_id = $a_objective_id;
44 $this->course_obj = $a_course_obj;
45 $this->settings = ilLOSettings::getInstanceByObjId($this->course_obj->getId());
46 $this->objDefinition = $DIC['objDefinition'];
47 $this->tree = $DIC->repositoryTree();
48 $this->questioninfo = $DIC->testQuestion();
49
50 parent::__construct($a_parent_obj, 'materialAssignment');
51 $this->lng->loadLanguageModule('crs');
52
53 $this->setFormName('assignments');
54 $this->addColumn($this->lng->txt('type'), 'type', "20px");
55 $this->addColumn($this->lng->txt('title'), 'title', '');
56
57 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
58 $this->setRowTemplate("tpl.crs_objective_list_questions_row.html", "components/ILIAS/Course");
59 $this->disable('sort');
60 $this->disable('header');
61 $this->disable('numinfo');
62 $this->disable('select_all');
63
64 #$this->setDefaultOrderField('title');
65 $this->setLimit(200);
66
67 $this->mode = $a_mode;
68 switch ($a_mode) {
70 $this->addCommandButton('updateSelfAssessmentAssignment', $this->lng->txt('crs_wiz_next'));
71 break;
72
74 $this->addCommandButton('updateFinalTestAssignment', $this->lng->txt('crs_wiz_next'));
75 break;
76 }
77
79 }
80
81 public function getSettings(): ilLOSettings
82 {
83 return $this->settings;
84 }
85
86 protected function fillRow(array $a_set): void
87 {
88 foreach ($a_set['sub'] as $sub_data) {
89 if ($sub_data['description']) {
90 $this->tpl->setVariable('QST_DESCRIPTION', $sub_data['description']);
91 }
92 if ($sub_data['qst_txt']) {
93 $txt = $sub_data['qst_txt'];
94 if ($sub_data['qst_points']) {
95 $this->lng->loadLanguageModule('assessment');
96 $txt .= (' (' . $sub_data['qst_points'] . ' ' . $this->lng->txt('points') . ')');
97 }
98
99 $this->tpl->setVariable('QST_DESCRIPTION', $txt);
100 }
101 $this->tpl->setCurrentBlock('qst');
102 $this->tpl->setVariable('QST_TITLE', $sub_data['title']);
103 $this->tpl->setVariable('QST_ID', $a_set['id'] . '_' . $sub_data['id']);
104
105 switch ($this->mode) {
107 if ($this->objective_qst_obj->isSelfAssessmentQuestion($sub_data['id'])) {
108 $this->tpl->setVariable('QST_CHECKED', 'checked="checked"');
109 }
110 break;
111
113 if ($this->objective_qst_obj->isFinalTestQuestion($sub_data['id'])) {
114 $this->tpl->setVariable('QST_CHECKED', 'checked="checked"');
115 }
116 break;
117 }
118 $this->tpl->parseCurrentBlock();
119 }
120 if (count($a_set['sub'])) {
121 $this->tpl->setVariable('TXT_QUESTIONS', $this->lng->txt('objs_qst'));
122 }
123 $this->tpl->setVariable('VAL_ID', $a_set['id']);
124
125 $this->tpl->setVariable('ROW_TYPE_IMG', ilObject::_getIcon($a_set['obj_id'], "tiny", $a_set['type']));
126 $this->tpl->setVariable('ROW_TYPE_ALT', $this->lng->txt('obj_' . $a_set['type']));
127
128 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
129 if (strlen($a_set['description'])) {
130 $this->tpl->setVariable('VAL_DESC', $a_set['description']);
131 }
132 }
133
134 public function parse(array $a_assignable): void
135 {
136 $a_assignable = $this->getTestNode();
137 $tests = array();
138 foreach ($a_assignable as $node) {
139 $tmp_data = array();
140 $subobjects = array();
141
142 if (!$tmp_tst = ilObjectFactory::getInstanceByRefId((int) ($node['ref_id'] ?? 0), false)) {
143 continue;
144 }
145
146 foreach ($qst = $this->sortQuestions($tmp_tst->getAllQuestions()) as $question_data) {
147 $tmp_question = ilObjTest::_instanciateQuestion($question_data['question_id']);
148 #$sub['qst_txt'] = $tmp_question->_getQuestionText($question_data['question_id']);
149 $sub['qst_txt'] = '';
150 $sub['qst_points'] = $this->questioninfo->getGeneralQuestionProperties($question_data['question_id'])->getAvailablePoints();
151
152 $sub['title'] = $tmp_question->getTitle();
153 $sub['description'] = $tmp_question->getComment();
154 $sub['id'] = $question_data['question_id'];
155
156 $subobjects[] = $sub;
157 }
158 $tmp_data['title'] = $node['title'];
159 $tmp_data['description'] = $node['description'];
160 $tmp_data['type'] = $node['type'];
161 $tmp_data['id'] = $node['child'];
162 $tmp_data['obj_id'] = $node['obj_id'];
163 $tmp_data['sub'] = $subobjects;
164 $tests[] = $tmp_data;
165 }
166 $this->setData($tests);
167 }
168
169 protected function getTestNode(): array
170 {
172 $tst_ref_id = $this->getSettings()->getInitialTest();
173 if ($tst_ref_id) {
174 return array($this->tree->getNodeData($tst_ref_id));
175 }
176 }
178 $tst_ref_id = $this->getSettings()->getQualifiedTest();
179 if ($tst_ref_id) {
180 return array($this->tree->getNodeData($tst_ref_id));
181 }
182 }
183 return [];
184 }
185
186 // end-patch lok
187
188 protected function initQuestionAssignments(): void
189 {
190 $this->objective_qst_obj = new ilCourseObjectiveQuestion($this->objective_id);
191 }
192
193 protected function sortQuestions(array $a_qst_ids): array
194 {
195 return ilArrayUtil::sortArray($a_qst_ids, 'title', 'asc');
196 }
197}
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
Class ilObject Basic functions for all objects.
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)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26