ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilSurveyResultsCumulatedTableGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
10{
18 public function __construct($a_parent_obj, $a_parent_cmd, array $a_results)
19 {
20 global $DIC;
21
22 $lng = $DIC->language();
23 $ilCtrl = $DIC->ctrl();
24
25 $this->setId("svy_cum");
26 parent::__construct($a_parent_obj, $a_parent_cmd);
27
28 $this->lng = $lng;
29 $this->ctrl = $ilCtrl;
30
31 $this->addColumn($this->lng->txt("title"));
32 foreach ($this->getSelectedColumns() as $c) {
33 if (strcmp($c, 'question') == 0) {
34 $this->addColumn($this->lng->txt("question"));
35 }
36 if (strcmp($c, 'question_type') == 0) {
37 $this->addColumn($this->lng->txt("question_type"));
38 }
39 if (strcmp($c, 'users_answered') == 0) {
40 $this->addColumn($this->lng->txt("users_answered"));
41 }
42 if (strcmp($c, 'users_skipped') == 0) {
43 $this->addColumn($this->lng->txt("users_skipped"));
44 }
45 if (strcmp($c, 'mode') == 0) {
46 $this->addColumn($this->lng->txt("mode"));
47 }
48 if (strcmp($c, 'mode_nr_of_selections') == 0) {
49 $this->addColumn($this->lng->txt("mode_nr_of_selections"));
50 }
51 if (strcmp($c, 'median') == 0) {
52 $this->addColumn($this->lng->txt("median"));
53 }
54 if (strcmp($c, 'arithmetic_mean') == 0) {
55 $this->addColumn($this->lng->txt("arithmetic_mean"));
56 }
57 }
58
59 $this->setRowTemplate("tpl.il_svy_svy_results_cumulated_row.html", "Modules/Survey");
60 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
61 $this->setShowRowsSelector(false);
62
63 $this->getItems($a_results);
64 }
65
66 public function getSelectableColumns()
67 {
69 $cols["question"] = array(
70 "txt" => $lng->txt("question"),
71 "default" => true
72 );
73 $cols["question_type"] = array(
74 "txt" => $lng->txt("question_type"),
75 "default" => true
76 );
77 $cols["users_answered"] = array(
78 "txt" => $lng->txt("users_answered"),
79 "default" => true
80 );
81 $cols["users_skipped"] = array(
82 "txt" => $lng->txt("users_skipped"),
83 "default" => true
84 );
85 $cols["mode"] = array(
86 "txt" => $lng->txt("mode"),
87 "default" => false
88 );
89 $cols["mode_nr_of_selections"] = array(
90 "txt" => $lng->txt("mode_nr_of_selections"),
91 "default" => false
92 );
93 $cols["median"] = array(
94 "txt" => $lng->txt("median"),
95 "default" => true
96 );
97 $cols["arithmetic_mean"] = array(
98 "txt" => $lng->txt("arithmetic_mean"),
99 "default" => true
100 );
101 return $cols;
102 }
103
104 protected function getItems(array $a_results)
105 {
106 $data = array();
107
108 foreach ($a_results as $question_res) {
109 if (!is_array($question_res)) {
110 $question = $question_res->getQuestion();
111
112 $data[] = array(
113 "title" => $question->getTitle(),
114 "question" => strip_tags($question->getQuestiontext()),
115 "question_type" => SurveyQuestion::_getQuestionTypeName($question->getQuestionType()),
116 "users_answered" => $question_res->getUsersAnswered(),
117 "users_skipped" => $question_res->getUsersSkipped(),
118 "mode" => $question_res->getModeValueAsText(),
119 "mode_nr_of_selections" => $question_res->getModeNrOfSelections(),
120 "median" => $question_res->getMedianAsText(),
121 "arithmetic_mean" => $question_res->getMean()
122 );
123 }
124 // matrix
125 else {
126 // :TODO: $question->getQuestiontext() ?
127 // :TODO: should there be overall figures?
128
129 foreach ($question_res as $idx => $item) {
130 $row_title = $item[0];
131 $row_res = $item[1];
132 $question = $row_res->getQuestion();
133
134 $data[] = array(
135 "title" => $question->getTitle(),
136 "question" => $row_title,
137 "question_type" => SurveyQuestion::_getQuestionTypeName($question->getQuestionType()),
138 "users_answered" => $row_res->getUsersAnswered(),
139 "users_skipped" => $row_res->getUsersSkipped(),
140 "mode" => $row_res->getModeValueAsText(),
141 "mode_nr_of_selections" => $row_res->getModeNrOfSelections(),
142 "median" => $row_res->getMedianAsText(),
143 "arithmetic_mean" => $row_res->getMean()
144 );
145 }
146 }
147 }
148
149 $this->setData($data);
150 }
151
152 public function numericOrdering($a_field)
153 {
154 return !in_array($a_field, array("question", "question_type"));
155 }
156
164 public function fillRow($data)
165 {
166 $this->tpl->setVariable("TITLE", $data['title']);
167
168 foreach ($this->getSelectedColumns() as $c) {
169 if (strcmp($c, 'question') == 0) {
170 $this->tpl->setCurrentBlock('question');
171 $this->tpl->setVariable("QUESTION", $data['question']);
172 $this->tpl->parseCurrentBlock();
173 }
174 if (strcmp($c, 'question_type') == 0) {
175 $this->tpl->setCurrentBlock('question_type');
176 $this->tpl->setVariable("QUESTION_TYPE", trim($data['question_type']));
177 $this->tpl->parseCurrentBlock();
178 }
179 if (strcmp($c, 'users_answered') == 0) {
180 $this->tpl->setCurrentBlock('users_answered');
181 $this->tpl->setVariable("USERS_ANSWERED", trim($data['users_answered']));
182 $this->tpl->parseCurrentBlock();
183 }
184 if (strcmp($c, 'users_skipped') == 0) {
185 $this->tpl->setCurrentBlock('users_skipped');
186 $this->tpl->setVariable("USERS_SKIPPED", trim($data['users_skipped']));
187 $this->tpl->parseCurrentBlock();
188 }
189 if (strcmp($c, 'mode') == 0) {
190 $this->tpl->setCurrentBlock('mode');
191 $this->tpl->setVariable("MODE", trim($data['mode']));
192 // : $this->lng->txt("survey_not_available")
193 $this->tpl->parseCurrentBlock();
194 }
195 if (strcmp($c, 'mode_nr_of_selections') == 0) {
196 $this->tpl->setCurrentBlock('mode_nr_of_selections');
197 $this->tpl->setVariable("MODE_NR_OF_SELECTIONS", trim($data['mode_nr_of_selections']));
198 // : $this->lng->txt("survey_not_available")
199 $this->tpl->parseCurrentBlock();
200 }
201 if (strcmp($c, 'median') == 0) {
202 $this->tpl->setCurrentBlock('median');
203 $this->tpl->setVariable("MEDIAN", trim($data['median']));
204 // : $this->lng->txt("survey_not_available")
205 $this->tpl->parseCurrentBlock();
206 }
207 if (strcmp($c, 'arithmetic_mean') == 0) {
208 $this->tpl->setCurrentBlock('arithmetic_mean');
209 $this->tpl->setVariable("ARITHMETIC_MEAN", trim($data['arithmetic_mean']));
210 // : $this->lng->txt("survey_not_available");
211 $this->tpl->parseCurrentBlock();
212 }
213 }
214
215 /*
216 if($data["subitems"])
217 {
218 $this->tpl->setCurrentBlock("tbl_content");
219 $this->tpl->parseCurrentBlock();
220
221 foreach($data["subitems"] as $subitem)
222 {
223 $this->fillRow($subitem);
224
225 $this->tpl->setCurrentBlock("tbl_content");
226 $this->css_row = ($this->css_row != "tblrow1")
227 ? "tblrow1"
228 : "tblrow2";
229 $this->tpl->setVariable("CSS_ROW", $this->css_row);
230 $this->tpl->parseCurrentBlock();
231 }
232 }
233 */
234 }
235}
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
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46
$cols
Definition: xhr_table.php:11