4 include_once
"Modules/SurveyQuestionPool/classes/class.SurveyQuestionEvaluation.php";
25 for (
$r = 0;
$r < $this->question->getRowCount();
$r++) {
31 $this->question->getColumns()
35 $this->question->getRow($r)->title,
49 public function getGrid($a_results, $a_abs =
true, $a_perc =
true)
59 $tmp = array_shift($tmp);
60 $vars = $tmp[1]->getVariables();
62 foreach ($vars as $var) {
63 $res[
"cols"][] = $var->cat->title;
67 foreach ($a_results as $results_row) {
70 ++$q_counter .
". " . $results_row[0]
73 $vars = $results_row[1]->getVariables();
75 foreach ($vars as $var) {
77 ? sprintf(
"%.2f", $var->perc * 100) .
"%" 80 if ((
bool) $a_abs && (
bool) $a_perc) {
81 $parsed_row[] = $var->abs .
" / " . $perc;
82 } elseif ((
bool) $a_abs) {
83 $parsed_row[] = $var->abs;
85 $parsed_row[] = $perc;
90 $res[
"rows"][] = $parsed_row;
99 foreach ($a_results as $results_row) {
100 $texts = $results_row[1]->getMappedTextAnswers();
102 $idx = $results_row[0];
103 foreach ($texts as $answers) {
104 foreach ($answers as $answer) {
105 $res[$idx][] = $answer;
118 include_once
"Services/Chart/classes/class.ilChart.php";
120 $chart->setXAxisToInteger(
true);
121 $chart->setStacked(
true);
124 $chart->setColors($colors);
131 $row_idx =
sizeof($a_results);
134 $text_shortened =
false;
135 foreach ($a_results as
$row) {
138 $row_title = $row[0];
139 $row_results = $row[1];
142 $row_title = ++$row_counter .
". " . $row_title;
144 if ($labels[$row_idx] != $row_title) {
145 $text_shortened =
true;
149 $vars = $row_results->getVariables();
151 foreach ($vars as $idx => $var) {
152 if (!array_key_exists($idx,
$data)) {
154 $data[$idx]->setLabel($var->cat->title);
155 $data[$idx]->setBarOptions(0.5,
"center",
true);
156 $data[$idx]->setFill(1);
164 $data[$idx]->addPoint($var->abs, $row_idx);
170 $this->chart_height = count($a_results) * 40;
172 if ($text_shortened) {
173 $this->chart_width = 500;
175 $chart->setSize($this->chart_width, $this->chart_height);
177 foreach (
$data as $var) {
178 $chart->addData($var);
181 $chart->setTicks(
false, $labels,
true);
197 $question = $a_results[0][1]->getQuestion();
212 $row[] = (int) $a_results[0][1]->getUsersAnswered();
213 $row[] = (int) $a_results[0][1]->getUsersSkipped();
222 foreach ($a_results as $row_result) {
223 $row_title = $row_result[0];
224 $row_res = $row_result[1];
242 $row[] = is_array($row_res->getModeValue())
243 ? implode(
", ", $row_res->getModeValue())
244 : $row_res->getModeValue();
246 $row[] = $row_res->getModeValueAsText();
247 $row[] = (int) $row_res->getModeNrOfSelections();
250 $row[] = $row_res->getMedianAsText();
252 $row[] = $row_res->getMean();
263 for (
$i = 0;
$i < $this->question->getRowCount();
$i++) {
265 $row = $this->question->getRow(
$i);
267 if ($a_do_title && $a_do_label) {
268 $a_title_row[] =
$row->title;
269 $a_title_row2[] =
$row->label;
271 if ($this->question->getSubtype() == 0) {
272 $a_title_row[] =
$row->title;
273 $a_title_row2[] =
$row->label;
277 $a_title_row[] =
$row->title;
278 $a_title_row2[] =
$lng->txt(
'other');
280 } elseif ($a_do_title) {
281 $a_title_row[] =
$row->title;
282 $a_title_row2[] =
"";
284 if ($this->question->getSubtype() == 0) {
285 $a_title_row[] =
$row->title;
286 $a_title_row2[] =
"";
290 $a_title_row[] =
$row->title;
291 $a_title_row2[] =
$lng->txt(
'other');
294 $a_title_row[] =
$row->label;
295 $a_title_row2[] =
"";
297 if ($this->question->getSubtype() == 0) {
298 $a_title_row[] =
$row->label;
299 $a_title_row2[] =
"";
303 $a_title_row[] =
$row->label;
304 $a_title_row2[] =
$lng->txt(
'other');
309 if ($this->question->getSubtype() == 1) {
311 $col = $this->question->getColumn(
$index);
313 $a_title_row[] = $col->title .
" [" . $col->scale .
"]";
314 $a_title_row2[] =
"";
322 $answer_map = array();
323 foreach ($a_results as $row_results) {
324 $row_title = $row_results[0];
325 $row_result = $row_results[1];
327 $answers = $row_result->getUserResults($a_user_id);
328 if ($answers !== null) {
329 foreach ($answers as $answer) {
331 if ($this->question->getSubtype() == 1) {
332 $answer_map[$row_title .
"|" . $answer[2]] = $answer[2];
334 $answer_map[$row_title] = $answer[3];
335 $answer_map[$row_title .
"|scale"] = $answer[2];
338 $answer_map[$row_title .
"|txt"] = $answer[1];
344 if (!
sizeof($answer_map)) {
350 for (
$i = 0;
$i < $this->question->getRowCount();
$i++) {
351 $row = $this->question->getRow(
$i);
352 $row_title =
$row->title;
354 $a_row[] = $answer_map[$row_title];
355 if ($this->question->getSubtype() == 0) {
356 $a_row[] = $answer_map[$row_title .
"|scale"];
360 $a_row[] = $answer_map[$row_title .
"|txt"];
364 if ($this->question->getSubtype() == 1) {
366 $col = $this->question->getColumn(
$index);
367 $a_row[] = $answer_map[$row_title .
"|" . $col->scale];
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
getUserSpecificVariableTitles(array &$a_title_row, array &$a_title_row2, $a_do_title, $a_do_label)
addUserSpecificResults(array &$a_row, $a_user_id, $a_results)
exportResults($a_results, $a_do_title, $a_do_label)
Survey question evaluation.
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
Survey matrix evaluation.
getTextAnswers($a_results)
Survey evaluation answers.
foreach($_POST as $key=> $value) $res
parseResults(ilSurveyEvaluationResults $a_results, array $a_answers, SurveyCategories $a_categories=null)
Parse answer data into results instance.
getSkippedValue()
Get caption for skipped value.
static getInstanceByType($a_type, $a_id)
Get type instance.
getGrid($a_results, $a_abs=true, $a_perc=true)