ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilParticipantsTestResultsTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
5include_once('./Services/Table/classes/class.ilTable2GUI.php');
6require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
7
17{
20
21 protected $anonymity;
22
23 public function __construct($a_parent_obj, $a_parent_cmd)
24 {
25 $this->setId('tst_participants_' . $a_parent_obj->getTestObj()->getRefId());
26 parent::__construct($a_parent_obj, $a_parent_cmd);
27
28 global $DIC;
29 $this->lng = $DIC->language();
30 $this->ctrl = $DIC->ctrl();
31
32 $this->setStyle('table', 'fullwidth');
33
34 $this->setFormName('partResultsForm');
35 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
36
37 $this->setRowTemplate("tpl.il_as_tst_scorings_row.html", "Modules/Test");
38
39 $this->enable('header');
40 $this->enable('sort');
41
42 $this->setSelectAllCheckbox('chbUser');
43
44 $this->setDefaultOrderField('name');
45 $this->setDefaultOrderDirection('asc');
46 }
47
52 {
54 }
55
60 {
61 $this->accessResultsCommandsEnabled = $accessResultsCommandsEnabled;
62 }
63
68 {
70 }
71
76 {
77 $this->manageResultsCommandsEnabled = $manageResultsCommandsEnabled;
78 }
79
83 public function getAnonymity()
84 {
85 return $this->anonymity;
86 }
87
91 public function setAnonymity($anonymity)
92 {
93 $this->anonymity = $anonymity;
94 }
95
100 public function numericOrdering($field)
101 {
102 return in_array($field, array(
103 'scored_pass', 'answered_questions', 'reached_points', 'percent_result'
104 ));
105 }
106
107 public function init()
108 {
109 if ($this->isMultiRowSelectionRequired()) {
110 $this->setShowRowsSelector(true);
111 }
112
113 $this->initColumns();
114 $this->initCommands();
115 $this->initFilter();
116 }
117
118 public function initColumns()
119 {
120 if ($this->isMultiRowSelectionRequired()) {
121 $this->addColumn('', '', '1%', true);
122 }
123
124 $this->addColumn($this->lng->txt("name"), 'name');
125 $this->addColumn($this->lng->txt("login"), 'login');
126
127 $this->addColumn($this->lng->txt("tst_tbl_col_finished_passes"), 'finished_passes');
128
129 $this->addColumn($this->lng->txt("tst_tbl_col_scored_pass"), 'scored_pass');
130 $this->addColumn($this->lng->txt("tst_tbl_col_last_scored_access"), 'last_scored_access');
131
132 $this->addColumn($this->lng->txt("tst_tbl_col_answered_questions"), 'answered_questions');
133 $this->addColumn($this->lng->txt("tst_tbl_col_reached_points"), 'reached_points');
134 $this->addColumn($this->lng->txt("tst_tbl_col_percent_result"), 'percent_result');
135
136 $this->addColumn($this->lng->txt("tst_tbl_col_passed_status"), 'passed_status');
137 $this->addColumn($this->lng->txt("tst_tbl_col_final_mark"), 'final_mark');
138
139 if ($this->isActionsColumnRequired()) {
140 $this->addColumn($this->lng->txt('actions'), '', '');
141 }
142 }
143
144 public function initCommands()
145 {
146 if ($this->isAccessResultsCommandsEnabled() && !$this->getAnonymity()) {
147 $this->addMultiCommand('showPassOverview', $this->lng->txt('show_pass_overview'));
148 $this->addMultiCommand('showUserAnswers', $this->lng->txt('show_user_answers'));
149 $this->addMultiCommand('showDetailedResults', $this->lng->txt('show_detailed_results'));
150 }
151
152 if ($this->isManageResultsCommandsEnabled()) {
153 $this->addMultiCommand('deleteSingleUserResults', $this->lng->txt('delete_user_data'));
154 }
155 }
156
157 public function initFilter()
158 {
159 global $DIC;
160
161 // no filter at all
162 }
163
167 public function fillRow($data)
168 {
169 if ($this->isMultiRowSelectionRequired()) {
170 $this->tpl->setCurrentBlock('checkbox_column');
171 $this->tpl->setVariable("CHB_ROW_KEY", $data['active_id']);
172 $this->tpl->parseCurrentBlock();
173 }
174
175 if ($this->isActionsColumnRequired()) {
176 $this->tpl->setCurrentBlock('actions_column');
177 $this->tpl->setVariable('ACTIONS', $this->buildActionsMenu($data)->getHTML());
178 $this->tpl->parseCurrentBlock();
179 }
180
181 $this->tpl->setVariable("ROW_KEY", $data['active_id']);
182 $this->tpl->setVariable("LOGIN", $data['login']);
183 $this->tpl->setVariable("FULLNAME", $data['name']);
184
185 $this->tpl->setVariable("FINISHED_PASSES", $this->buildFinishedPassesString($data));
186 $this->tpl->setVariable("SCORED_PASS", $this->buildScoredPassString($data));
187 $this->tpl->setVariable("LAST_SCORED_ACCESS", $this->buildPassFinishedString($data));
188
189 $this->tpl->setVariable("ANSWERED_QUESTIONS", $this->buildAnsweredQuestionsString($data));
190 $this->tpl->setVariable("REACHED_POINTS", $this->buildReachedPointsString($data));
191 $this->tpl->setVariable("PERCENT_RESULT", $this->buildPercentResultString($data));
192
193 $this->tpl->setVariable("PASSED_STATUS", $this->buildPassedStatusString($data));
194 $this->tpl->setVariable("FINAL_MARK", $data['final_mark']);
195 }
196
201 protected function buildActionsMenu($data)
202 {
203 $asl = new ilAdvancedSelectionListGUI();
204
205 $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
206
207 if ($this->isAccessResultsCommandsEnabled()) {
208 $resultsHref = $this->ctrl->getLinkTargetByClass([ilTestResultsGUI::class, ilParticipantsTestResultsGUI::class, ilTestEvaluationGUI::class], 'outParticipantsResultsOverview');
209 $asl->addItem($this->lng->txt('tst_show_results'), $resultsHref, $resultsHref);
210 }
211
212 return $asl;
213 }
214
218 protected function isActionsColumnRequired()
219 {
220 if ($this->isAccessResultsCommandsEnabled()) {
221 return true;
222 }
223
224 return false;
225 }
226
227 protected function isMultiRowSelectionRequired()
228 {
229 if ($this->isAccessResultsCommandsEnabled() && !$this->getAnonymity()) {
230 return true;
231 }
232
233 if ($this->isManageResultsCommandsEnabled()) {
234 return true;
235 }
236
237 return false;
238 }
239
244 protected function buildPassedStatusString($data)
245 {
246 if ($data['passed_status']) {
247 return $this->buildPassedIcon() . ' ' . $this->lng->txt('tst_passed');
248 }
249
250 return $this->buildFailedIcon() . ' ' . $this->lng->txt('tst_failed');
251 }
252
256 protected function buildPassedIcon()
257 {
258 return $this->buildImageIcon(ilUtil::getImagePath("icon_ok.svg"), $this->lng->txt("passed"));
259 }
260
264 protected function buildFailedIcon()
265 {
266 return $this->buildImageIcon(ilUtil::getImagePath("icon_not_ok.svg"), $this->lng->txt("failed"));
267 }
268
274 protected function buildImageIcon($src, $alt)
275 {
276 return "<img border=\"0\" align=\"middle\" src=\"" . $src . "\" alt=\"" . $alt . "\" />";
277 }
278
283 protected function buildFormattedAccessDate($data)
284 {
286 }
287
292 protected function buildScoredPassString($data)
293 {
294 return $this->lng->txt('pass') . ' ' . ($data['scored_pass'] + 1);
295 }
296
301 protected function buildPassFinishedString($data)
302 {
303 return ilDatePresentation::formatDate(new ilDateTime($data['last_scored_access'], IL_CAL_UNIX));
304 }
305
306
312 {
313 $finished = $data['finished_passes'] ?? 0;
314 $started = (isset($data['has_unfinished_passes']) && $data['has_unfinished_passes']) ? $finished + 1 : $finished;
315
316 return sprintf(
317 $this->lng->txt('tst_tbl_col_finished_passes_num_of'),
318 $finished,
319 $started
320 );
321 }
322
323
329 {
330 return sprintf(
331 $this->lng->txt('tst_answered_questions_of_total'),
332 $data['answered_questions'],
333 $data['total_questions']
334 );
335 }
336
341 protected function buildReachedPointsString($data)
342 {
343 return sprintf(
344 $this->lng->txt('tst_reached_points_of_max'),
345 $data['reached_points'],
346 $data['max_points']
347 );
348 }
349
354 protected function buildPercentResultString($data)
355 {
356 return sprintf('%0.2f %%', $data['percent_result'] * 100);
357 }
358}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
const IL_CAL_DATETIME
User interface class for advanced drop-down selection lists.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
__construct($a_parent_obj, $a_parent_cmd)
Constructor.
setAccessResultsCommandsEnabled($accessResultsCommandsEnabled)
setManageResultsCommandsEnabled($manageResultsCommandsEnabled)
Class ilTable2GUI.
getHTML()
Get HTML.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormName($a_formname="")
Set Form name.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setStyle($a_element, $a_style)
enable($a_module_name)
enables particular modules of table
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc