ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
24include_once('./Services/Table/classes/class.ilTable2GUI.php');
25
35{
43 public function __construct($a_parent_obj, $a_parent_cmd, array $a_results)
44 {
45 global $lng, $ilCtrl;
46
47 $this->setId("svy_cum");
48 parent::__construct($a_parent_obj, $a_parent_cmd);
49
50 $this->lng = $lng;
51 $this->ctrl = $ilCtrl;
52
53 $this->addColumn($this->lng->txt("title"));
54 foreach ($this->getSelectedColumns() as $c)
55 {
56 if (strcmp($c, 'question') == 0) $this->addColumn($this->lng->txt("question"));
57 if (strcmp($c, 'question_type') == 0) $this->addColumn($this->lng->txt("question_type"));
58 if (strcmp($c, 'users_answered') == 0) $this->addColumn($this->lng->txt("users_answered"));
59 if (strcmp($c, 'users_skipped') == 0) $this->addColumn($this->lng->txt("users_skipped"));
60 if (strcmp($c, 'mode') == 0) $this->addColumn($this->lng->txt("mode"));
61 if (strcmp($c, 'mode_nr_of_selections') == 0) $this->addColumn($this->lng->txt("mode_nr_of_selections"));
62 if (strcmp($c, 'median') == 0) $this->addColumn($this->lng->txt("median"));
63 if (strcmp($c, 'arithmetic_mean') == 0) $this->addColumn($this->lng->txt("arithmetic_mean"));
64 }
65
66 $this->setRowTemplate("tpl.il_svy_svy_results_cumulated_row.html", "Modules/Survey");
67 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
68 $this->setShowRowsSelector(false);
69
70 $this->getItems($a_results);
71 }
72
74 {
75 global $lng;
76 $cols["question"] = array(
77 "txt" => $lng->txt("question"),
78 "default" => true
79 );
80 $cols["question_type"] = array(
81 "txt" => $lng->txt("question_type"),
82 "default" => true
83 );
84 $cols["users_answered"] = array(
85 "txt" => $lng->txt("users_answered"),
86 "default" => true
87 );
88 $cols["users_skipped"] = array(
89 "txt" => $lng->txt("users_skipped"),
90 "default" => true
91 );
92 $cols["mode"] = array(
93 "txt" => $lng->txt("mode"),
94 "default" => false
95 );
96 $cols["mode_nr_of_selections"] = array(
97 "txt" => $lng->txt("mode_nr_of_selections"),
98 "default" => false
99 );
100 $cols["median"] = array(
101 "txt" => $lng->txt("median"),
102 "default" => true
103 );
104 $cols["arithmetic_mean"] = array(
105 "txt" => $lng->txt("arithmetic_mean"),
106 "default" => true
107 );
108 return $cols;
109 }
110
111 protected function getItems(array $a_results)
112 {
113 $data = array();
114
115 foreach($a_results as $question_res)
116 {
117 /* :TODO:
118 $maxlen = 75;
119 include_once "./Services/Utilities/classes/class.ilStr.php";
120 if (ilStr::strlen($questiontext) > $maxlen + 3)
121 {
122 $questiontext = ilStr::substr($questiontext, 0, $maxlen) . "...";
123 }
124 */
125
126 if(!is_array($question_res))
127 {
128 $question = $question_res->getQuestion();
129
130 $data[] = array(
131 "title" => $question->getTitle(),
132 "question" => $question->getQuestiontext(),
133 "question_type" => SurveyQuestion::_getQuestionTypeName($question->getQuestionType()),
134 "users_answered" => $question_res->getUsersAnswered(),
135 "users_skipped" => $question_res->getUsersSkipped(),
136 "mode" => $question_res->getModeValueAsText(),
137 "mode_nr_of_selections" => $question_res->getModeNrOfSelections(),
138 "median" => $question_res->getMedianAsText(),
139 "arithmetic_mean" => $question_res->getMean()
140 );
141 }
142 // matrix
143 else
144 {
145 // :TODO: $question->getQuestiontext() ?
146 // :TODO: should there be overall figures?
147
148 foreach($question_res as $idx => $item)
149 {
150 $row_title = $item[0];
151 $row_res = $item[1];
152 $question = $row_res->getQuestion();
153
154 $data[] = array(
155 "title" => $question->getTitle(),
156 "question" => $row_title,
157 "question_type" => SurveyQuestion::_getQuestionTypeName($question->getQuestionType()),
158 "users_answered" => $row_res->getUsersAnswered(),
159 "users_skipped" => $row_res->getUsersSkipped(),
160 "mode" => $row_res->getModeValueAsText(),
161 "mode_nr_of_selections" => $row_res->getModeNrOfSelections(),
162 "median" => $row_res->getMedianAsText(),
163 "arithmetic_mean" => $row_res->getMean()
164 );
165 }
166 }
167 }
168
169 $this->setData($data);
170 }
171
172 public function numericOrdering($a_field)
173 {
174 return !in_array($a_field, array("question", "question_type"));
175 }
176
184 public function fillRow($data)
185 {
186 $this->tpl->setVariable("TITLE", $data['title']);
187
188 foreach ($this->getSelectedColumns() as $c)
189 {
190 if (strcmp($c, 'question') == 0)
191 {
192 $this->tpl->setCurrentBlock('question');
193 $this->tpl->setVariable("QUESTION", $data['question']);
194 $this->tpl->parseCurrentBlock();
195 }
196 if (strcmp($c, 'question_type') == 0)
197 {
198 $this->tpl->setCurrentBlock('question_type');
199 $this->tpl->setVariable("QUESTION_TYPE", trim($data['question_type']));
200 $this->tpl->parseCurrentBlock();
201 }
202 if (strcmp($c, 'users_answered') == 0)
203 {
204 $this->tpl->setCurrentBlock('users_answered');
205 $this->tpl->setVariable("USERS_ANSWERED", trim($data['users_answered']));
206 $this->tpl->parseCurrentBlock();
207 }
208 if (strcmp($c, 'users_skipped') == 0)
209 {
210 $this->tpl->setCurrentBlock('users_skipped');
211 $this->tpl->setVariable("USERS_SKIPPED", trim($data['users_skipped']));
212 $this->tpl->parseCurrentBlock();
213 }
214 if (strcmp($c, 'mode') == 0)
215 {
216 $this->tpl->setCurrentBlock('mode');
217 $this->tpl->setVariable("MODE", trim($data['mode']));
218 // : $this->lng->txt("survey_not_available")
219 $this->tpl->parseCurrentBlock();
220 }
221 if (strcmp($c, 'mode_nr_of_selections') == 0)
222 {
223 $this->tpl->setCurrentBlock('mode_nr_of_selections');
224 $this->tpl->setVariable("MODE_NR_OF_SELECTIONS", trim($data['mode_nr_of_selections']));
225 // : $this->lng->txt("survey_not_available")
226 $this->tpl->parseCurrentBlock();
227 }
228 if (strcmp($c, 'median') == 0)
229 {
230 $this->tpl->setCurrentBlock('median');
231 $this->tpl->setVariable("MEDIAN", trim($data['median']));
232 // : $this->lng->txt("survey_not_available")
233 $this->tpl->parseCurrentBlock();
234 }
235 if (strcmp($c, 'arithmetic_mean') == 0)
236 {
237 $this->tpl->setCurrentBlock('arithmetic_mean');
238 $this->tpl->setVariable("ARITHMETIC_MEAN", trim($data['arithmetic_mean']));
239 // : $this->lng->txt("survey_not_available");
240 $this->tpl->parseCurrentBlock();
241 }
242 }
243
244 /*
245 if($data["subitems"])
246 {
247 $this->tpl->setCurrentBlock("tbl_content");
248 $this->tpl->parseCurrentBlock();
249
250 foreach($data["subitems"] as $subitem)
251 {
252 $this->fillRow($subitem);
253
254 $this->tpl->setCurrentBlock("tbl_content");
255 $this->css_row = ($this->css_row != "tblrow1")
256 ? "tblrow1"
257 : "tblrow2";
258 $this->tpl->setVariable("CSS_ROW", $this->css_row);
259 $this->tpl->parseCurrentBlock();
260 }
261 }
262 */
263 }
264}
265?>
An exception for terminatinating execution or to throw for unit testing.
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
__construct($a_parent_obj, $a_parent_cmd, array $a_results)
Constructor.
numericOrdering($a_field)
Should this field be sorted numeric?
Class ilTable2GUI.
getSelectedColumns()
Get selected columns.
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.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17