ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSurveyMaintenanceTableGUI.php
Go to the documentation of this file.
1<?php
2
23{
24 protected int $counter;
25 protected bool $confirmdelete;
26
27 public function __construct(
28 object $a_parent_obj,
29 string $a_parent_cmd,
30 bool $confirmdelete = false
31 ) {
32 global $DIC;
33
34 parent::__construct($a_parent_obj, $a_parent_cmd);
35
36 $lng = $DIC->language();
37 $ilCtrl = $DIC->ctrl();
38
39 $this->lng = $lng;
40 $this->ctrl = $ilCtrl;
41 $this->counter = 1;
42 $this->confirmdelete = $confirmdelete;
43
44 $this->setFormName('maintenanceform');
45 $this->setStyle('table', 'fullwidth');
46
47 if (!$confirmdelete) {
48 $this->addColumn('', '', '1%', true);
49 }
50 $this->addColumn($this->lng->txt("name"), 'name', '');
51 $this->addColumn($this->lng->txt("login"), 'login', '');
52 $this->addColumn($this->lng->txt("last_access"), 'last_access', '');
53 $this->addColumn($this->lng->txt("workingtime"), 'workingtime', '');
54 $this->addColumn($this->lng->txt("svy_status"), '', '');
55 $this->addColumn($this->lng->txt("survey_results_finished"), 'finished', '');
56
57 $this->setRowTemplate("tpl.il_svy_svy_maintenance_row.html", "components/ILIAS/Survey/Participants");
58
59 if ($confirmdelete) {
60 $this->addCommandButton('confirmDeleteSelectedUserData', $this->lng->txt('confirm'));
61 $this->addCommandButton('cancelDeleteSelectedUserData', $this->lng->txt('cancel'));
62 } else {
63 $this->addMultiCommand('deleteSingleUserResults', $this->lng->txt('svy_remove_participants'));
64 }
65
66 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
67
68 $this->setDefaultOrderField("name");
69 $this->setDefaultOrderDirection("asc");
70
71 $this->setShowRowsSelector(true);
72
73 if ($confirmdelete) {
74 $this->disable('sort');
75 $this->disable('select_all');
76 } else {
77 $this->setPrefix('chbUser');
78 $this->setSelectAllCheckbox('chbUser');
79 $this->enable('sort');
80 $this->enable('select_all');
81 }
82 $this->enable('header');
83 }
84
85 protected function fillRow(array $a_set): void
86 {
87 if (!$this->confirmdelete) {
88 $this->tpl->setCurrentBlock('checkbox');
89 if ($a_set["invited"]) {
90 $this->tpl->setVariable("CB_USER_ID", "inv" . $a_set['usr_id']);
91 } else {
92 $this->tpl->setVariable("CB_USER_ID", $a_set['id']);
93 }
94 } else {
95 $this->tpl->setCurrentBlock('hidden');
96 if ($a_set["invited"]) {
97 $this->tpl->setVariable("HIDDEN_USER_ID", "inv" . $a_set['usr_id']);
98 } else {
99 $this->tpl->setVariable("HIDDEN_USER_ID", $a_set['id']);
100 }
101 }
102 $this->tpl->parseCurrentBlock();
103 $this->tpl->setVariable("USER_ID", $a_set["id"]);
104 $this->tpl->setVariable("VALUE_USER_NAME", $a_set['name']);
105 $this->tpl->setVariable("VALUE_USER_LOGIN", $a_set['login']);
106 $this->tpl->setVariable("LAST_ACCESS", ilDatePresentation::formatDate(new ilDateTime($a_set['last_access'], IL_CAL_UNIX)));
107 $this->tpl->setVariable("WORKINGTIME", $this->formatTime($a_set['workingtime'] ?? null));
108
109 $state = $this->lng->txt("svy_status_in_progress");
110 if ($a_set['last_access'] == "" && $a_set["invited"]) {
111 $state = $this->lng->txt("svy_status_invited");
112 }
113 if (($a_set["finished"] ?? false) !== false) {
114 $state = $this->lng->txt("svy_status_finished");
115 }
116 $this->tpl->setVariable("STATUS", $state);
117 $finished = "";
118 if ((int) ($a_set["finished"] ?? 0) > 0) {
119 $finished .= ilDatePresentation::formatDate(new ilDateTime($a_set["finished"], IL_CAL_UNIX));
120 } else {
121 $finished = "-";
122 }
123 $this->tpl->setVariable("FINISHED", $finished);
124 }
125
130 protected function formatTime($timeinseconds): string
131 {
132 if (is_null($timeinseconds)) {
133 return " ";
134 }
135
136 if ($timeinseconds == 0) {
137 return $this->lng->txt('not_available');
138 }
139
140 return sprintf("%02d:%02d:%02d", (int) ($timeinseconds / 3600), (int) ($timeinseconds / 60) % 60, (int) $timeinseconds % 60);
141 }
142
143 public function numericOrdering(string $a_field): bool
144 {
145 switch ($a_field) {
146 case 'workingtime':
147 return true;
148
149 default:
150 return false;
151 }
152 }
153}
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(object $a_parent_obj, string $a_parent_cmd, bool $confirmdelete=false)
fillRow(array $a_set)
Standard Version of Fill Row.
numericOrdering(string $a_field)
Should this field be sorted numeric?
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.
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setFormName(string $a_name="")
addMultiCommand(string $a_cmd, string $a_text)
setPrefix(string $a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
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)
setDefaultOrderField(string $a_defaultorderfield)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
ilLanguage $lng
enable(string $a_module_name)
setStyle(string $a_element, string $a_style)
disable(string $a_module_name)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26