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