ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.SurveyMultipleChoiceQuestionEvaluation.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
11 {
12 
13  //
14  // EXPORT
15  //
16 
17  public function getUserSpecificVariableTitles(array &$a_title_row, array &$a_title_row2, $a_do_title, $a_do_label)
18  {
19  $lng = $this->lng;
20 
21  $categories = $this->question->getCategories();
22  for ($i = 0; $i < $categories->getCategoryCount(); $i++) {
23  $cat = $categories->getCategory($i);
24 
25  $a_title_row[] = $cat->title . " [" . $cat->scale . "]";
26  $a_title_row2[] = "";
27 
28  if ($cat->other) {
29  $a_title_row[] = $cat->title . " [" . $cat->scale . "]";
30  $a_title_row2[] = $lng->txt('other');
31  }
32  }
33  }
34 
35  public function addUserSpecificResults(array &$a_row, $a_user_id, $a_results)
36  {
37  $categories = $this->question->getCategories();
38 
39  $answers = $a_results->getUserResults($a_user_id);
40  if ($answers === null) {
41  $a_row[] = $this->getSkippedValue();
42 
43  for ($i = 0; $i < $categories->getCategoryCount(); $i++) {
44  $cat = $categories->getCategory($i);
45  $a_row[] = "";
46 
47  if ($cat->other) {
48  $a_row[] = "";
49  }
50  }
51  } else {
52  $a_row[] = "";
53 
54  for ($i = 0; $i < $categories->getCategoryCount(); $i++) {
55  $cat = $categories->getCategory($i);
56  $found = false;
57  foreach ($answers as $answer) {
58  if ($answer[2] == $cat->scale) {
59  $a_row[] = $answer[2];
60  if ($cat->other) {
61  $a_row[] = $answer[1];
62  }
63  $found = true;
64  }
65  }
66  if (!$found) {
67  $a_row[] = ""; // "0" ?!
68  if ($cat->other) {
69  $a_row[] = "";
70  }
71  }
72  }
73  }
74  }
75 
79  protected function supportsSumScore() : bool
80  {
81  return true;
82  }
83 }
getUserSpecificVariableTitles(array &$a_title_row, array &$a_title_row2, $a_do_title, $a_do_label)
getSkippedValue()
Get caption for skipped value.
$i
Definition: metadata.php:24