ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilSurveyResultsCumulatedTableGUI.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 {
43  public function __construct($a_parent_obj, $a_parent_cmd, $detail)
44  {
45  $this->setId("svy_cum");
46  parent::__construct($a_parent_obj, $a_parent_cmd);
47 
48  global $lng, $ilCtrl;
49 
50  $this->lng = $lng;
51  $this->ctrl = $ilCtrl;
52  $this->counter = 1;
53  $this->totalcount = 0;
54 
55  $this->setFormName('invitegroups');
56  $this->setStyle('table', 'fullwidth');
57 
58  $this->addColumn($this->lng->txt("title"),'counter', ''); // #13649
59  foreach ($this->getSelectedColumns() as $c)
60  {
61  if (strcmp($c, 'question') == 0) $this->addColumn($this->lng->txt("question"),'question', '');
62  if (strcmp($c, 'question_type') == 0) $this->addColumn($this->lng->txt("question_type"),'question_type', '');
63  if (strcmp($c, 'users_answered') == 0) $this->addColumn($this->lng->txt("users_answered"),'users_answered', '');
64  if (strcmp($c, 'users_skipped') == 0) $this->addColumn($this->lng->txt("users_skipped"),'users_skipped', '');
65  if (strcmp($c, 'mode') == 0) $this->addColumn($this->lng->txt("mode"),'mode', '');
66  if (strcmp($c, 'mode_nr_of_selections') == 0) $this->addColumn($this->lng->txt("mode_nr_of_selections"),'mode_nr_of_selections', '');
67  if (strcmp($c, 'median') == 0) $this->addColumn($this->lng->txt("median"),'median', '');
68  if (strcmp($c, 'arithmetic_mean') == 0) $this->addColumn($this->lng->txt("arithmetic_mean"),'arithmetic_mean', '');
69  }
70 
71  $this->setRowTemplate("tpl.il_svy_svy_results_cumulated_row.html", "Modules/Survey");
72 
73  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
74 
75  $this->setDefaultOrderField("counter");
76 
77  $this->setShowRowsSelector(true);
78 
79  $this->enable('header');
80  $this->disable('select_all');
81  }
82 
84  {
85  global $lng;
86  $cols["question"] = array(
87  "txt" => $lng->txt("question"),
88  "default" => true
89  );
90  $cols["question_type"] = array(
91  "txt" => $lng->txt("question_type"),
92  "default" => true
93  );
94  $cols["users_answered"] = array(
95  "txt" => $lng->txt("users_answered"),
96  "default" => true
97  );
98  $cols["users_skipped"] = array(
99  "txt" => $lng->txt("users_skipped"),
100  "default" => true
101  );
102  $cols["mode"] = array(
103  "txt" => $lng->txt("mode"),
104  "default" => false
105  );
106  $cols["mode_nr_of_selections"] = array(
107  "txt" => $lng->txt("mode_nr_of_selections"),
108  "default" => false
109  );
110  $cols["median"] = array(
111  "txt" => $lng->txt("median"),
112  "default" => true
113  );
114  $cols["arithmetic_mean"] = array(
115  "txt" => $lng->txt("arithmetic_mean"),
116  "default" => true
117  );
118  return $cols;
119  }
120 
121  public function numericOrdering($a_field)
122  {
123  return !in_array($a_field, array("question", "question_type"));
124  }
125 
133  public function fillRow($data)
134  {
135  $this->tpl->setVariable("TITLE", $data['title']);
136 
137  foreach ($this->getSelectedColumns() as $c)
138  {
139  if (strcmp($c, 'question') == 0)
140  {
141  $this->tpl->setCurrentBlock('question');
142  $this->tpl->setVariable("QUESTION", $data['question']);
143  $this->tpl->parseCurrentBlock();
144  }
145  if (strcmp($c, 'question_type') == 0)
146  {
147  $this->tpl->setCurrentBlock('question_type');
148  $this->tpl->setVariable("QUESTION_TYPE", $data['question_type']);
149  $this->tpl->parseCurrentBlock();
150  }
151  if (strcmp($c, 'users_answered') == 0)
152  {
153  $this->tpl->setCurrentBlock('users_answered');
154  $this->tpl->setVariable("USERS_ANSWERED", trim($data['users_answered']));
155  $this->tpl->parseCurrentBlock();
156  }
157  if (strcmp($c, 'users_skipped') == 0)
158  {
159  $this->tpl->setCurrentBlock('users_skipped');
160  $this->tpl->setVariable("USERS_SKIPPED", trim($data['users_skipped']));
161  $this->tpl->parseCurrentBlock();
162  }
163  if (strcmp($c, 'mode') == 0)
164  {
165  $this->tpl->setCurrentBlock('mode');
166  $this->tpl->setVariable("MODE", $data['mode']);
167  $this->tpl->parseCurrentBlock();
168  }
169  if (strcmp($c, 'mode_nr_of_selections') == 0)
170  {
171  $this->tpl->setCurrentBlock('mode_nr_of_selections');
172  $this->tpl->setVariable("MODE_NR_OF_SELECTIONS", strlen($data['mode_nr_of_selections']) ? $data['mode_nr_of_selections'] : 0);
173  $this->tpl->parseCurrentBlock();
174  }
175  if (strcmp($c, 'median') == 0)
176  {
177  $this->tpl->setCurrentBlock('median');
178  $this->tpl->setVariable("MEDIAN", strlen($data['median']) ? $data['median'] : $this->lng->txt("survey_not_available"));
179  $this->tpl->parseCurrentBlock();
180  }
181  if (strcmp($c, 'arithmetic_mean') == 0)
182  {
183  $this->tpl->setCurrentBlock('arithmetic_mean');
184  $this->tpl->setVariable("ARITHMETIC_MEAN", strlen($data['arithmetic_mean']) ? $data['arithmetic_mean'] : $this->lng->txt("survey_not_available"));
185  $this->tpl->parseCurrentBlock();
186  }
187  }
188 
189  if($data["subitems"])
190  {
191  $this->tpl->setCurrentBlock("tbl_content");
192  $this->tpl->parseCurrentBlock();
193 
194  foreach($data["subitems"] as $subitem)
195  {
196  $this->fillRow($subitem);
197 
198  $this->tpl->setCurrentBlock("tbl_content");
199  $this->css_row = ($this->css_row != "tblrow1")
200  ? "tblrow1"
201  : "tblrow2";
202  $this->tpl->setVariable("CSS_ROW", $this->css_row);
203  $this->tpl->parseCurrentBlock();
204  }
205  }
206  }
207 }
208 ?>
__construct($a_parent_obj, $a_parent_cmd, $detail)
Constructor.
setFormName($a_formname)
Set Form name.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setStyle($a_element, $a_style)
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
Class ilTable2GUI.
enable($a_module_name)
enables particular modules of table
getSelectedColumns()
Get selected columns.
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
global $lng
Definition: privfeed.php:40
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
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.