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