ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCourseObjectiveQuestionsTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
21use ILIAS\HTTP\Services as HTTPServices;
22use ILIAS\Refinery\Factory as Refinery;
23
30{
31 protected HTTPServices $http;
32 protected Refinery $refinery;
34
35
36 public function __construct(object $a_parent_obj, ilObject $a_course_obj)
37 {
38 global $DIC;
39
40 $this->course_obj = $a_course_obj;
41 parent::__construct($a_parent_obj, 'questionOverview');
42
43 $this->http = $DIC->http();
44 $this->refinery = $DIC->refinery();
45
46 $this->lng->loadLanguageModule('crs');
47 $this->setFormName('questions');
48 $this->addColumn($this->lng->txt('title'), 'title', '33%');
49 $this->addColumn($this->lng->txt('crs_objective_self_assessment'), 'self', '33%%');
50 $this->addColumn($this->lng->txt('crs_objective_final_test'), 'final', '33%');
51
52 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
53 $this->setRowTemplate("tpl.crs_questions_table_row.html", "components/ILIAS/Course");
54 $this->disable('sort');
55 $this->enable('header');
56 $this->disable('numinfo');
57 $this->enable('select_all');
58 $this->setLimit(200);
59 $this->addCommandButton('saveQuestionOverview', $this->lng->txt('save'));
60 }
61
62 protected function fillRow(array $a_set): void
63 {
64 static $row_counter = 1;
65
66 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
67 if (strlen($a_set['description']) !== 0) {
68 $this->tpl->setVariable('VAL_DESC', $a_set['description']);
69 }
70
71 foreach ($a_set['self_tests'] as $tst) {
72 foreach ($tst['questions'] as $qst) {
73 $this->tpl->setCurrentBlock('self_qst');
74 $this->tpl->setVariable('SELF_QST_TITLE', $qst['title']);
75 if (strlen($qst['description']) !== 0) {
76 $this->tpl->setVariable('SELF_QST_DESCRIPTION', $qst['description']);
77 }
78 $this->tpl->setVariable('SELF_QST_POINTS', $qst['points']);
79 $this->tpl->setVariable('SELF_QST_TXT_POINTS', $this->lng->txt('crs_objective_points'));
80 $this->tpl->parseCurrentBlock();
81 }
82 $this->tpl->setCurrentBlock('self_tst');
83 $this->tpl->setVariable('SELF_TST_TITLE', $tst['title']);
84 if (strlen($tst['description']) !== 0) {
85 $this->tpl->setVariable('SELF_TST_DESC', $tst['description']);
86 }
87 $this->tpl->setVariable('SELF_TYPE_IMG', ilUtil::getImagePath('standard/icon_tst.svg'));
88 $this->tpl->setVariable('SELF_TYPE_ALT', $this->lng->txt('obj_tst'));
89 $this->tpl->parseCurrentBlock();
90 }
91 if (count($a_set['self_tests']) > 0) {
92 $this->tpl->setVariable('SELF_TXT_ALL_POINTS', $this->lng->txt('crs_objective_all_points'));
93 $this->tpl->setVariable('SELF_TXT_POINTS', $this->lng->txt('crs_objective_points'));
94 $this->tpl->setVariable('SELF_TXT_REQ_POINTS', $this->lng->txt('crs_obj_required_points'));
95 $this->tpl->setVariable('SELF_POINTS', $a_set['self_max_points']);
96 $this->tpl->setVariable('SELF_ID', $a_set['id']);
97 $this->tpl->setVariable('SELF_LIMIT', $a_set['self_limit']);
98 }
99
100 foreach ($a_set['final_tests'] as $tst) {
101 foreach ($tst['questions'] as $qst) {
102 $this->tpl->setCurrentBlock('final_qst');
103 $this->tpl->setVariable('FINAL_QST_TITLE', $qst['title']);
104 if (strlen($qst['description']) !== 0) {
105 $this->tpl->setVariable('FINAL_QST_DESCRIPTION', $qst['description']);
106 }
107 $this->tpl->setVariable('FINAL_QST_POINTS', $qst['points']);
108 $this->tpl->setVariable('FINAL_QST_TXT_POINTS', $this->lng->txt('crs_objective_points'));
109 $this->tpl->parseCurrentBlock();
110 }
111 $this->tpl->setCurrentBlock('final_tst');
112 $this->tpl->setVariable('FINAL_TST_TITLE', $tst['title']);
113 if (strlen($tst['description']) !== 0) {
114 $this->tpl->setVariable('FINAL_TST_DESC', $tst['description']);
115 }
116 $this->tpl->setVariable('FINAL_TYPE_IMG', ilUtil::getImagePath('standard/icon_tst.svg'));
117 $this->tpl->setVariable('FINAL_TYPE_ALT', $this->lng->txt('obj_tst'));
118 $this->tpl->parseCurrentBlock();
119 }
120 if (count($a_set['final_tests']) > 0) {
121 $this->tpl->setVariable('FINAL_TXT_ALL_POINTS', $this->lng->txt('crs_objective_all_points'));
122 $this->tpl->setVariable('FINAL_TXT_POINTS', $this->lng->txt('crs_objective_points'));
123 $this->tpl->setVariable('FINAL_TXT_REQ_POINTS', $this->lng->txt('crs_obj_required_points'));
124 $this->tpl->setVariable('FINAL_POINTS', $a_set['final_max_points']);
125 $this->tpl->setVariable('FINAL_ID', $a_set['id']);
126 $this->tpl->setVariable('FINAL_LIMIT', $a_set['final_limit']);
127 }
128 }
129
130 public function parse(array $a_objective_ids): void
131 {
132 $post_self_limits = [];
133 if ($this->http->wrapper()->post()->has('self')) {
134 $post_self_limits = $this->http->wrapper()->post()->retrieve(
135 'self',
136 $this->refinery->kindlyTo()->dictOf(
137 $this->refinery->kindlyTo()->float()
138 )
139 );
140 }
141 $post_final_limits = [];
142 if ($this->http->wrapper()->post()->has('final')) {
143 $post_final_limits = $this->http->wrapper()->post()->retrieve(
144 'final',
145 $this->refinery->kindlyTo()->dictOf(
146 $this->refinery->kindlyTo()->float()
147 )
148 );
149 }
150
151 $objectives = array();
152 foreach ($a_objective_ids as $objective_id) {
153 $objective = new ilCourseObjective($this->course_obj, $objective_id);
154
155 // Self assessment tests
156 $question_obj = new ilCourseObjectiveQuestion($objective_id);
157
158 $tests = array();
159 foreach ($question_obj->getSelfAssessmentTests() as $tmp_test) {
160 if (isset($post_self_limits[$objective_id])) {
161 $objective_data['self_limit'] = (float) $post_self_limits[$objective_id];
162 } else {
163 $objective_data['self_limit'] = $tmp_test['limit'];
164 }
165 $questions = array();
166 foreach ($question_obj->getQuestionsOfTest($tmp_test['obj_id']) as $tmp_question) {
167 $qst['title'] = $tmp_question['title'];
168 $qst['description'] = $tmp_question['description'];
169 $qst['points'] = $tmp_question['points'];
170
171 $questions[] = $qst;
172 }
173 $tst['questions'] = $questions;
174 $tst['title'] = ilObject::_lookupTitle($tmp_test['obj_id']);
175 $tst['description'] = ilObject::_lookupDescription($tmp_test['obj_id']);
176
177 $tests[] = $tst;
178 }
179 $objective_data['self_tests'] = $tests;
180 $objective_data['self_max_points'] = $question_obj->getSelfAssessmentPoints();
181
182 // Final tests
183 $tests = array();
184 foreach ($question_obj->getFinalTests() as $tmp_test) {
185 if (isset($post_final_limits[$objective_id])) {
186 $objective_data['final_limit'] = (float) $post_final_limits[$objective_id];
187 } else {
188 $objective_data['final_limit'] = $tmp_test['limit'];
189 }
190
191 $questions = array();
192 foreach ($question_obj->getQuestionsOfTest($tmp_test['obj_id']) as $tmp_question) {
193 $qst['title'] = $tmp_question['title'];
194 $qst['description'] = $tmp_question['description'];
195 $qst['points'] = $tmp_question['points'];
196
197 $questions[] = $qst;
198 }
199 $tst['questions'] = $questions;
200 $tst['title'] = ilObject::_lookupTitle($tmp_test['obj_id']);
201 $tst['description'] = ilObject::_lookupDescription($tmp_test['obj_id']);
202
203 $tests[] = $tst;
204 }
205
206 $objective_data['final_tests'] = $tests;
207 $objective_data['final_max_points'] = $question_obj->getFinalTestPoints();
208
209 $objective_data['id'] = $objective_id;
210 $objective_data['title'] = $objective->getTitle();
211
212 $objective_data['description'] = $objective->getDescription();
213
214 $objectives[] = $objective_data;
215 }
216 $this->setData($objectives);
217 }
218}
Builds data types.
Definition: Factory.php:36
Class Services.
Definition: Services.php:38
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.
class ilcourseobjective
Class ilObject Basic functions for all objects.
static _lookupTitle(int $obj_id)
static _lookupDescription(int $obj_id)
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.
enable(string $a_module_name)
disable(string $a_module_name)
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$objectives