ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSurveyResultsUserTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
10 {
11  private $is_anonymized;
12 
20  public function __construct($a_parent_obj, $a_parent_cmd, $is_anonymized)
21  {
22  global $DIC;
23 
24  $this->setId("svy_usr");
25  parent::__construct($a_parent_obj, $a_parent_cmd);
26 
27  $lng = $DIC->language();
28  $ilCtrl = $DIC->ctrl();
29 
30  $this->is_anonymized = $is_anonymized;
31  $this->lng = $lng;
32  $this->ctrl = $ilCtrl;
33  $this->counter = 1;
34 
35  $this->setFormName('invitegroups');
36  $this->setStyle('table', 'fullwidth');
37 
38  $this->addColumn($this->lng->txt("username"), 'username', '');
39  $this->addColumn($this->lng->txt("question"), '', '');
40  $this->addColumn($this->lng->txt("results"), '', '');
41  $this->addColumn($this->lng->txt("workingtime"), 'workingtime', '');
42  $this->addColumn($this->lng->txt("survey_results_finished"), 'finished', '');
43 
44  $this->setRowTemplate("tpl.il_svy_svy_results_user_row.html", "Modules/Survey");
45 
46  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
47 
48  $this->setDefaultOrderField('username');
49 
50  $this->setShowRowsSelector(true);
51 
52  $this->enable('header');
53  $this->disable('select_all');
54  }
55 
56  protected function formatTime($timeinseconds)
57  {
58  if (is_null($timeinseconds)) {
59  return " ";
60  } elseif ($timeinseconds == 0) {
61  return $this->lng->txt('not_available');
62  } else {
63  return sprintf("%02d:%02d:%02d", ($timeinseconds / 3600), ($timeinseconds / 60) % 60, $timeinseconds % 60);
64  }
65  }
66 
74  public function fillRow($data)
75  {
76  $this->tpl->setVariable("USERNAME", $data['username']);
77  $this->tpl->setVariable("QUESTION", $data['question']);
78  $results = array_map(function ($i) {
79  return htmlentities($i);
80  }, $data["results"]);
81  $this->tpl->setVariable("RESULTS", $results
82  ? implode("<br />", $results)
84  $this->tpl->setVariable("WORKINGTIME", $this->formatTime($data['workingtime']));
85 
86  if ($data["finished"] !== null) {
87  if ($data["finished"] !== false) {
88  $finished .= ilDatePresentation::formatDate(new ilDateTime($data["finished"], IL_CAL_UNIX));
89  } else {
90  $finished = "-";
91  }
92  $this->tpl->setVariable("FINISHED", $finished);
93  } else {
94  $this->tpl->setVariable("FINISHED", "&nbsp;");
95  }
96 
97  if ($data["subitems"]) {
98  $this->tpl->setCurrentBlock("tbl_content");
99  $this->tpl->parseCurrentBlock();
100 
101  foreach ($data["subitems"] as $subitem) {
102  $this->fillRow($subitem);
103 
104  $this->tpl->setCurrentBlock("tbl_content");
105  $this->css_row = ($this->css_row != "tblrow1")
106  ? "tblrow1"
107  : "tblrow2";
108  $this->tpl->setVariable("CSS_ROW", $this->css_row);
109  $this->tpl->parseCurrentBlock();
110  }
111  }
112  }
113 }
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setStyle($a_element, $a_style)
static getSurveySkippedValue()
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
setId($a_val)
Set id.
global $DIC
Definition: goto.php:24
enable($a_module_name)
enables particular modules of table
$results
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
disable($a_module_name)
diesables particular modules of table
__construct($a_parent_obj, $a_parent_cmd, $is_anonymized)
Constructor.
setFormName($a_formname="")
Set Form name.
__construct(Container $dic, ilPlugin $plugin)
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.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
$i
Definition: metadata.php:24