ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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->addCommandButton('printEvaluation', $this->lng->txt('print'), 'javascript:window.print(); return false;'); // #10944
74 
75  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
76 
77  $this->setDefaultOrderField("counter");
78 
79  $this->setShowRowsSelector(true);
80 
81  $this->enable('header');
82  $this->disable('select_all');
83  }
84 
86  {
87  global $lng;
88  $cols["question"] = array(
89  "txt" => $lng->txt("question"),
90  "default" => true
91  );
92  $cols["question_type"] = array(
93  "txt" => $lng->txt("question_type"),
94  "default" => true
95  );
96  $cols["users_answered"] = array(
97  "txt" => $lng->txt("users_answered"),
98  "default" => true
99  );
100  $cols["users_skipped"] = array(
101  "txt" => $lng->txt("users_skipped"),
102  "default" => true
103  );
104  $cols["mode"] = array(
105  "txt" => $lng->txt("mode"),
106  "default" => false
107  );
108  $cols["mode_nr_of_selections"] = array(
109  "txt" => $lng->txt("mode_nr_of_selections"),
110  "default" => false
111  );
112  $cols["median"] = array(
113  "txt" => $lng->txt("median"),
114  "default" => true
115  );
116  $cols["arithmetic_mean"] = array(
117  "txt" => $lng->txt("arithmetic_mean"),
118  "default" => true
119  );
120  return $cols;
121  }
122 
123  public function numericOrdering($a_field)
124  {
125  return !in_array($a_field, array("question", "question_type"));
126  }
127 
135  public function fillRow($data)
136  {
137  $this->tpl->setVariable("TITLE", $data['title']);
138 
139  foreach ($this->getSelectedColumns() as $c)
140  {
141  if (strcmp($c, 'question') == 0)
142  {
143  $this->tpl->setCurrentBlock('question');
144  $this->tpl->setVariable("QUESTION", $data['question']);
145  $this->tpl->parseCurrentBlock();
146  }
147  if (strcmp($c, 'question_type') == 0)
148  {
149  $this->tpl->setCurrentBlock('question_type');
150  $this->tpl->setVariable("QUESTION_TYPE", $data['question_type']);
151  $this->tpl->parseCurrentBlock();
152  }
153  if (strcmp($c, 'users_answered') == 0)
154  {
155  $this->tpl->setCurrentBlock('users_answered');
156  $this->tpl->setVariable("USERS_ANSWERED", trim($data['users_answered']));
157  $this->tpl->parseCurrentBlock();
158  }
159  if (strcmp($c, 'users_skipped') == 0)
160  {
161  $this->tpl->setCurrentBlock('users_skipped');
162  $this->tpl->setVariable("USERS_SKIPPED", trim($data['users_skipped']));
163  $this->tpl->parseCurrentBlock();
164  }
165  if (strcmp($c, 'mode') == 0)
166  {
167  $this->tpl->setCurrentBlock('mode');
168  $this->tpl->setVariable("MODE", $data['mode']);
169  $this->tpl->parseCurrentBlock();
170  }
171  if (strcmp($c, 'mode_nr_of_selections') == 0)
172  {
173  $this->tpl->setCurrentBlock('mode_nr_of_selections');
174  $this->tpl->setVariable("MODE_NR_OF_SELECTIONS", strlen($data['mode_nr_of_selections']) ? $data['mode_nr_of_selections'] : 0);
175  $this->tpl->parseCurrentBlock();
176  }
177  if (strcmp($c, 'median') == 0)
178  {
179  $this->tpl->setCurrentBlock('median');
180  $this->tpl->setVariable("MEDIAN", strlen($data['median']) ? $data['median'] : $this->lng->txt("survey_not_available"));
181  $this->tpl->parseCurrentBlock();
182  }
183  if (strcmp($c, 'arithmetic_mean') == 0)
184  {
185  $this->tpl->setCurrentBlock('arithmetic_mean');
186  $this->tpl->setVariable("ARITHMETIC_MEAN", strlen($data['arithmetic_mean']) ? $data['arithmetic_mean'] : $this->lng->txt("survey_not_available"));
187  $this->tpl->parseCurrentBlock();
188  }
189  }
190 
191  if($data["subitems"])
192  {
193  $this->tpl->setCurrentBlock("tbl_content");
194  $this->tpl->parseCurrentBlock();
195 
196  foreach($data["subitems"] as $subitem)
197  {
198  $this->fillRow($subitem);
199 
200  $this->tpl->setCurrentBlock("tbl_content");
201  $this->css_row = ($this->css_row != "tblrow1")
202  ? "tblrow1"
203  : "tblrow2";
204  $this->tpl->setVariable("CSS_ROW", $this->css_row);
205  $this->tpl->parseCurrentBlock();
206  }
207  }
208  }
209 }
210 ?>