ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSurveyResultsUserTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once('./Services/Table/classes/class.ilTable2GUI.php');
25 
35 {
36  private $is_anonymized;
37 
45  public function __construct($a_parent_obj, $a_parent_cmd, $is_anonymized)
46  {
47  $this->setId("svy_usr");
48  parent::__construct($a_parent_obj, $a_parent_cmd);
49 
50  global $lng, $ilCtrl;
51 
52  $this->is_anonymized = $is_anonymized;
53  $this->lng = $lng;
54  $this->ctrl = $ilCtrl;
55  $this->counter = 1;
56 
57  $this->setFormName('invitegroups');
58  $this->setStyle('table', 'fullwidth');
59 
60  $this->addColumn($this->lng->txt("username"),'username', '');
61  /* #8211
62  if (!$is_anonymized)
63  {
64  $this->addColumn($this->lng->txt("gender"),'gender', '');
65  }
66  */
67  $this->addColumn($this->lng->txt("question"),'', '');
68  $this->addColumn($this->lng->txt("results"),'', '');
69  $this->addColumn($this->lng->txt("workingtime"),'workingtime', '');
70  $this->addColumn($this->lng->txt("survey_results_finished"),'finished', '');
71 
72  $this->setRowTemplate("tpl.il_svy_svy_results_user_row.html", "Modules/Survey");
73 
74  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
75 
76  $this->setDefaultOrderField('username');
77 
78  $this->setShowRowsSelector(true);
79 
80  $this->enable('header');
81  $this->disable('select_all');
82  }
83 
84  protected function formatTime($timeinseconds)
85  {
86  if (is_null($timeinseconds))
87  {
88  return " ";
89  }
90  else if ($timeinseconds == 0)
91  {
92  return $this->lng->txt('not_available');
93  }
94  else
95  {
96  return sprintf("%02d:%02d:%02d", ($timeinseconds / 3600), ($timeinseconds / 60) % 60, $timeinseconds % 60);
97  }
98  }
99 
107  public function fillRow($data)
108  {
109  /* #8211
110  if (!$this->is_anonymized)
111  {
112  $this->tpl->setCurrentBlock('gender');
113  $this->tpl->setVariable("GENDER", $data['gender']);
114  $this->tpl->parseCurrentBlock();
115  }
116  */
117  $this->tpl->setVariable("USERNAME", $data['username']);
118  $this->tpl->setVariable("QUESTION", $data['question']);
119  $this->tpl->setVariable("RESULTS", $data['results']);
120  $this->tpl->setVariable("WORKINGTIME", $this->formatTime($data['workingtime']));
121 
122  if($data["finished"] !== null)
123  {
124  if($data["finished"] !== false)
125  {
126  $finished .= ilDatePresentation::formatDate(new ilDateTime($data["finished"], IL_CAL_UNIX));
127  }
128  else
129  {
130  $finished = "-";
131  }
132  $this->tpl->setVariable("FINISHED", $finished);
133  }
134  else
135  {
136  $this->tpl->setVariable("FINISHED", "&nbsp;");
137  }
138 
139  if($data["subitems"])
140  {
141  $this->tpl->setCurrentBlock("tbl_content");
142  $this->tpl->parseCurrentBlock();
143 
144  foreach($data["subitems"] as $subitem)
145  {
146  $this->fillRow($subitem);
147 
148  $this->tpl->setCurrentBlock("tbl_content");
149  $this->css_row = ($this->css_row != "tblrow1")
150  ? "tblrow1"
151  : "tblrow2";
152  $this->tpl->setVariable("CSS_ROW", $this->css_row);
153  $this->tpl->parseCurrentBlock();
154  }
155  }
156  }
157 }
158 ?>