ILIAS  release_8 Revision v8.24
class.ilTestParticipantsTableGUI.php
Go to the documentation of this file.
1<?php
2
28{
29 protected bool $manageResultsCommandsEnabled = false;
30 protected bool $manageInviteesCommandsEnabled = false;
31
32 protected ?string $rowKeyDataField;
33
34 protected $anonymity;
35
37
38 protected ilLanguage $lng;
39 protected ilCtrl $ctrl;
40 protected \ILIAS\UI\Renderer $renderer;
41 protected \ILIAS\UI\Factory $ui_factory;
42
43 public function __construct($a_parent_obj, $a_parent_cmd)
44 {
45 $this->setId('tst_participants_' . $a_parent_obj->getTestObj()->getRefId());
46 parent::__construct($a_parent_obj, $a_parent_cmd);
47
48 global $DIC;
49
50 $this->lng = $DIC->language();
51 $this->ctrl = $DIC->ctrl();
52 $this->renderer = $DIC->ui()->renderer();
53 $this->ui_factory = $DIC->ui()->factory();
54
55 $this->setStyle('table', 'fullwidth');
56
57 $this->setFormName('participantsForm');
58 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
59
60 $this->setRowTemplate("tpl.il_as_tst_participants_row.html", "Modules/Test");
61
62 $this->enable('header');
63 $this->enable('sort');
64
65 $this->setShowRowsSelector(true);
66 }
67
68 public function isManageResultsCommandsEnabled(): bool
69 {
71 }
72
74 {
75 $this->manageResultsCommandsEnabled = $manageResultsCommandsEnabled;
76 }
77
78 public function isManageInviteesCommandsEnabled(): bool
79 {
81 }
82
84 {
85 $this->manageInviteesCommandsEnabled = $manageInviteesCommandsEnabled;
86
88 $this->setSelectAllCheckbox('chbUser');
89 } else {
90 $this->setSelectAllCheckbox('');
91 }
92 }
93
94 public function getRowKeyDataField(): string
95 {
97 }
98
99 public function setRowKeyDataField(string $rowKeyDataField): void
100 {
101 $this->rowKeyDataField = $rowKeyDataField;
102 }
103
104 public function getAnonymity()
105 {
106 return $this->anonymity;
107 }
108
109 public function setAnonymity($anonymity): void
110 {
111 $this->anonymity = $anonymity;
112 }
113
115 {
117 }
118
119
121 {
122 $this->participantHasSolutionsFilterEnabled = $participantHasSolutionsFilterEnabled;
123 }
124
125 public function numericOrdering(string $a_field): bool
126 {
127 return in_array($a_field, array(
128 'access', 'tries'
129 ));
130 }
131
132 protected function needsCheckboxColumn(): bool
133 {
134 return $this->isManageInviteesCommandsEnabled();
135 }
136
137 public function initColumns(): void
138 {
139 if ($this->needsCheckboxColumn()) {
140 $this->addColumn('', '', '1%');
141 }
142
143 $this->addColumn($this->lng->txt("name"), 'name', '');
144 $this->addColumn($this->lng->txt("login"), 'login', '');
145
146 if ($this->isManageInviteesCommandsEnabled()) {
147 $this->addColumn($this->lng->txt("clientip"), 'clientip', '');
148 }
149
150 $this->addColumn($this->lng->txt("tst_started"), 'started', '');
151 $this->addColumn($this->lng->txt("tst_nr_of_tries_of_user"), 'tries', '');
152
153 $this->addColumn($this->lng->txt("unfinished_passes"), 'unfinished', '');
154 $this->addColumn($this->lng->txt("tst_finished"), 'finished', '');
155
156 $this->addColumn($this->lng->txt("last_access"), 'access', '');
157
158 if ($this->isActionsColumnRequired()) {
159 $this->addColumn('', '', '');
160 }
161 }
162
163 public function initCommands(): void
164 {
165 if ($this->isManageInviteesCommandsEnabled()) {
166 $this->addMultiCommand('saveClientIp', $this->lng->txt('save'));
167 $this->addMultiCommand('removeParticipants', $this->lng->txt('remove_as_participant'));
168 }
169 }
170
171 public function initFilter(): void
172 {
173 global $DIC;
174 $lng = $DIC['lng'];
175
177 // title/description
178 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
179 $ti = new ilSelectInputGUI($lng->txt("selection"), "selection");
180 $ti->setOptions(
181 array(
182 'all' => $lng->txt('all_participants'),
183 'withSolutions' => $lng->txt('with_solutions_participants'),
184 'withoutSolutions' => $lng->txt('without_solutions_participants')
185 )
186 );
187 $this->addFilterItem($ti);
188 $ti->readFromSession(); // get currenty value from session (always after addFilterItem())
189 $this->filter["title"] = $ti->getValue();
190 }
191 }
192
193 public function fillRow(array $a_set): void
194 {
195 if ($this->needsCheckboxColumn()) {
196 $this->tpl->setCurrentBlock('checkbox_column');
197 $this->tpl->setVariable("CHB_ROW_KEY", $this->fetchRowKey($a_set));
198 $this->tpl->parseCurrentBlock();
199 }
200
201 if ($this->isManageInviteesCommandsEnabled()) {
202 $this->tpl->setCurrentBlock('client_ip_column');
203 $this->tpl->setVariable("CLIENT_IP", $a_set['clientip']);
204 $this->tpl->setVariable("CIP_ROW_KEY", $this->fetchRowKey($a_set));
205 $this->tpl->parseCurrentBlock();
206 }
207
208 if ($this->isActionsColumnRequired()) {
209 $this->tpl->setCurrentBlock('actions_column');
210
211 if ($a_set['active_id'] > 0) {
212 $this->tpl->setVariable('ACTIONS', $this->buildActionsMenu($a_set)->getHTML());
213 } else {
214 $this->tpl->touchBlock('actions_column');
215 }
216
217 $this->tpl->parseCurrentBlock();
218 }
219
220 $this->tpl->setVariable("ROW_KEY", $this->fetchRowKey($a_set));
221 $this->tpl->setVariable("LOGIN", $a_set['login']);
222 $this->tpl->setVariable("FULLNAME", $a_set['name']);
223
224 $this->tpl->setVariable("STARTED", ($a_set['started']) ? $this->buildOkIcon() : '');
225 $this->tpl->setVariable("TRIES", $this->fetchTriesValue($a_set));
226 $this->tpl->setVariable("UNFINISHED_PASSES", $this->buildUnfinishedPassesStatusString($a_set));
227
228 $this->tpl->setVariable("FINISHED", ($a_set['finished']) ? $this->buildOkIcon() : '');
229 $this->tpl->setVariable("ACCESS", $this->buildFormattedAccessDate($a_set));
230 }
231
233 {
234 $asl = new ilAdvancedSelectionListGUI();
235
236 $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
237
238 if ($this->isManageResultsCommandsEnabled() && $data['unfinished']) {
239 $finishHref = $this->ctrl->getLinkTargetByClass('ilTestEvaluationGUI', 'finishTestPassForSingleUser');
240 $asl->addItem($this->lng->txt('finish_test'), $finishHref, $finishHref);
241 }
242
243 return $asl;
244 }
245
246 protected function isActionsColumnRequired(): bool
247 {
248 if ($this->isManageResultsCommandsEnabled()) {
249 return true;
250 }
251
252 return false;
253 }
254
255 protected function fetchRowKey(array $data): string
256 {
257 return $data[$this->getRowKeyDataField()];
258 }
259
260 protected function fetchTriesValue(array $data): string
261 {
262 if ($data['tries'] < 1) {
263 return '';
264 }
265
266 if ($data['tries'] > 1) {
267 return sprintf($this->lng->txt("passes_finished"), $data['tries']);
268 }
269
270 return sprintf($this->lng->txt("pass_finished"), $data['tries']);
271 }
272
273 protected function buildUnfinishedPassesStatusString(array $data): string
274 {
275 if ($data['unfinished']) {
276 return $this->lng->txt('yes');
277 }
278
279 return $this->lng->txt('no');
280 }
281
282 protected function buildOkIcon(): string
283 {
284 return $this->renderer->render($this->ui_factory->symbol()->icon()->custom(
285 ilUtil::getImagePath("icon_ok.svg"),
286 $this->lng->txt("ok")
287 ));
288 }
289
290 protected function buildFormattedAccessDate(array $data): string
291 {
293 }
294}
const IL_CAL_DATETIME
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
language handling
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
getHTML()
Get HTML.
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setFormName(string $a_name="")
addMultiCommand(string $a_cmd, string $a_text)
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)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
enable(string $a_module_name)
setStyle(string $a_element, string $a_style)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct($a_parent_obj, $a_parent_cmd)
setManageResultsCommandsEnabled(bool $manageResultsCommandsEnabled)
numericOrdering(string $a_field)
Should this field be sorted numeric?
setParticipantHasSolutionsFilterEnabled(bool $participantHasSolutionsFilterEnabled)
fillRow(array $a_set)
Standard Version of Fill Row.
setManageInviteesCommandsEnabled(bool $manageInviteesCommandsEnabled)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc