ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilSurveyEvaluationResults.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11{
12 protected $question; // [SurveyQuestion]
13 protected $users_answered; // [int]
14 protected $users_skipped; // [int]
15 protected $mode_value; // [int]
16 protected $mode_nr_of_selections; // [int]
17 protected $arithmetic_mean; // [float]
18 protected $median; // [string|float]
19 protected $variables = array(); // [array]
20 protected $answers = array(); // [array]
21
22 public function __construct(SurveyQuestion $a_question)
23 {
24 $this->question = $a_question;
25 }
26
27 public function getQuestion()
28 {
29 return $this->question;
30 }
31
32 public function setUsersAnswered($a_value)
33 {
34 $this->users_answered = (int)$a_value;
35 }
36
37 public function getUsersAnswered()
38 {
40 }
41
42 public function setUsersSkipped($a_value)
43 {
44 $this->users_skipped = (int)$a_value;
45 }
46
47 public function getUsersSkipped()
48 {
50 }
51
52 public function setMode($a_value, $a_nr_of_selections)
53 {
54 $this->mode_value = is_array($a_value)
55 ? $a_value
56 : trim($a_value);
57 $this->mode_nr_of_selections = (int)$a_nr_of_selections;
58 }
59
60 public function getModeValue()
61 {
62 return $this->mode_value;
63 }
64
65 public function getModeValueAsText()
66 {
67 if($this->mode_value === null)
68 {
69 return;
70 }
71
72 $res = array();
73
74 $mvalues = $this->mode_value;
75 if(!is_array($mvalues))
76 {
77 $mvalues = array($mvalues);
78 }
79 sort($mvalues, SORT_NUMERIC);
80 foreach($mvalues as $value)
81 {
82 $res[] = $this->getScaleText($value);
83 }
84
85 return implode(", ", $res);
86 }
87
88 public function getModeNrOfSelections()
89 {
91 }
92
93 public function setMean($a_mean)
94 {
95 $this->arithmetic_mean = (float)$a_mean;
96 }
97
98 public function getMean()
99 {
101 }
102
103 public function setMedian($a_value)
104 {
105 $this->median = is_array($a_value)
106 ? $a_value
107 : trim($a_value);
108 }
109
110 public function getMedian()
111 {
112 return $this->median;
113 }
114
115 public function getMedianAsText()
116 {
117 global $lng;
118
119 if($this->median === null)
120 {
121 return;
122 }
123
124 if(!is_array($this->median))
125 {
126 return $this->getScaleText($this->median);
127 }
128 else
129 {
130 return $lng->txt("median_between")." ".
131 $this->getScaleText($this->median[0])." ".
132 $lng->txt("and")." ".
133 $this->getScaleText($this->median[1]);
134 }
135 }
136
138 {
139 $this->variables[] = $a_variable;
140 }
141
142 public function getVariables()
143 {
144 if(sizeof($this->variables))
145 {
146 return $this->variables;
147 }
148 }
149
151 {
152 $this->answers[] = $a_answer;
153 }
154
155 public function getAnswers()
156 {
157 if(sizeof($this->answers))
158 {
159 return $this->answers;
160 }
161 }
162
163 protected function getScaleText($a_value)
164 {
165 if(!sizeof($this->variables))
166 {
167 return $a_value;
168 }
169 else
170 {
171 foreach($this->variables as $var)
172 {
173 if($var->cat->scale == $a_value)
174 {
175 return $var->cat->title." [".$a_value."]";
176 }
177 }
178 }
179 }
180
181 protected function getCatTitle($a_value)
182 {
183 if(!sizeof($this->variables))
184 {
185 return $a_value;
186 }
187 else
188 {
189 foreach($this->variables as $var)
190 {
191 if($var->cat->scale == $a_value)
192 {
193 return $var->cat->title;
194 }
195 }
196 }
197 }
198
199 public function getMappedTextAnswers()
200 {
201 $res = array();
202
203 foreach($this->answers as $answer)
204 {
205 if($answer->text)
206 {
207 $res[$this->getScaleText($answer->value)][] = $answer->text;
208 }
209 }
210
211 return $res;
212 }
213
214 public function getUserResults($a_active_id)
215 {
216 $res = array();
217
218 $answers = $this->getAnswers();
219 if($answers)
220 {
221 foreach($answers as $answer)
222 {
223 if($answer->active_id == $a_active_id)
224 {
225 $res[] = array(
226 $this->getScaleText($answer->value),
227 $answer->text,
228 $answer->value,
229 $this->getCatTitle($answer->value)
230 );
231 }
232 }
233 }
234
235 return $res;
236 }
237}
238
240{
241 public $cat; // [SurveyCategory]
242 public $abs; // [int]
243 public $perc; // [float]
244
245 public function __construct(ilSurveyCategory $a_cat, $a_abs, $a_perc)
246 {
247 $this->cat = $a_cat;
248 $this->abs = (int)$a_abs;
249 $this->perc = (float)$a_perc;
250 }
251}
252
254{
255 public $active_id; // [int]
256 public $value; // [int|float]
257 public $text; // [string]
258
259 public function __construct($a_active_id, $a_value, $a_text)
260 {
261 $this->active_id = (int)$a_active_id;
262 $this->value = $a_value;
263 $this->text = trim($a_text);
264 }
265}
An exception for terminatinating execution or to throw for unit testing.
Basic class for all survey question types.
Survey category class.
__construct($a_active_id, $a_value, $a_text)
__construct(ilSurveyCategory $a_cat, $a_abs, $a_perc)
__construct(SurveyQuestion $a_question)
setMode($a_value, $a_nr_of_selections)
addVariable(ilSurveyEvaluationResultsVariable $a_variable)
addAnswer(ilSurveyEvaluationResultsAnswer $a_answer)
global $lng
Definition: privfeed.php:17