ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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", "Modules/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", ($timeinseconds / 3600), ($timeinseconds / 60) % 60, $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 }
__construct(object $a_parent_obj, string $a_parent_cmd, bool $confirmdelete=false)
enable(string $a_module_name)
setFormAction(string $a_form_action, bool $a_multipart=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
const IL_CAL_UNIX
setFormName(string $a_name="")
ilLanguage $lng
global $DIC
Definition: feed.php:28
setStyle(string $a_element, string $a_style)
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
__construct(Container $dic, ilPlugin $plugin)
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)
disable(string $a_module_name)
addMultiCommand(string $a_cmd, string $a_text)
setPrefix(string $a_prefix)