ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
SurveyMetricQuestionEvaluation Class Reference

Survey metric evaluation. More...

+ Inheritance diagram for SurveyMetricQuestionEvaluation:
+ Collaboration diagram for SurveyMetricQuestionEvaluation:

Public Member Functions

 getGrid ($a_results, $a_abs=true, $a_perc=true)
 
 getChart ($a_results)
 
 getExportGrid ($a_results)
 Get grid data. More...
 
 addUserSpecificResults (array &$a_row, $a_user_id, $a_results)
 
- Public Member Functions inherited from SurveyQuestionEvaluation
 __construct (SurveyQuestion $a_question, array $a_finished_ids=null)
 Constructor. More...
 
 getResults ()
 Get results. More...
 
 parseUserSpecificResults ($a_qres, $a_user_id)
 
 getGrid ($a_results, $a_abs=true, $a_perc=true)
 Get grid data. More...
 
 getTextAnswers ($a_results)
 Get text answers. More...
 
 getChart ($a_results)
 Get chart. More...
 
 getSkippedValue ()
 Get caption for skipped value. More...
 
 exportResults ($a_results, $a_do_title, $a_do_label)
 
 getExportGrid ($a_results)
 Get grid data. More...
 
 getUserSpecificVariableTitles (array &$a_title_row, array &$a_title_row2, $a_do_title, $a_do_label)
 Get title columns for user-specific export. More...
 
 addUserSpecificResults (array &$a_row, $a_user_id, $a_results)
 

Protected Member Functions

 parseResults (ilSurveyEvaluationResults $a_results, array $a_answers, SurveyCategories $a_categories=null)
 
- Protected Member Functions inherited from SurveyQuestionEvaluation
 parseResults (ilSurveyEvaluationResults $a_results, array $a_answers, SurveyCategories $a_categories=null)
 Parse answer data into results instance. More...
 
 getChartColors ()
 
 getSurveyId ()
 
 getNrOfParticipants ()
 Returns the number of participants for a survey. More...
 
 getAnswerData ()
 

Additional Inherited Members

- Protected Attributes inherited from SurveyQuestionEvaluation
 $question
 
 $finished_ids
 
 $chart_width = 400
 
 $chart_height = 300
 

Detailed Description

Survey metric evaluation.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 12 of file class.SurveyMetricQuestionEvaluation.php.

Member Function Documentation

◆ addUserSpecificResults()

SurveyMetricQuestionEvaluation::addUserSpecificResults ( array $a_row,
  $a_user_id,
  $a_results 
)

Definition at line 200 of file class.SurveyMetricQuestionEvaluation.php.

References SurveyQuestionEvaluation\getSkippedValue().

201  {
202  $answer = $a_results->getUserResults($a_user_id);
203  if($answer === null)
204  {
205  $a_row[] = $this->getSkippedValue();
206  }
207  else
208  {
209  $a_row[] = $answer[0][0];
210  }
211  }
getSkippedValue()
Get caption for skipped value.
+ Here is the call graph for this function:

◆ getChart()

SurveyMetricQuestionEvaluation::getChart (   $a_results)

Definition at line 112 of file class.SurveyMetricQuestionEvaluation.php.

References $chart, $data, $lng, $total, array, ilChartGrid\DATA_BARS, SurveyQuestionEvaluation\getChartColors(), ilChart\getInstanceByType(), and ilChart\TYPE_GRID.

113  {
114  global $lng;
115 
116  include_once "Services/Chart/classes/class.ilChart.php";
117  $chart = ilChart::getInstanceByType(ilChart::TYPE_GRID, $a_results->getQuestion()->getId());
118  $chart->setYAxisToInteger(true);
119 
120  $colors = $this->getChartColors();
121  $chart->setColors($colors);
122 
123  // :TODO:
124  $chart->setsize($this->chart_width, $this->chart_height);
125 
126  $data = $chart->getDataInstance(ilChartGrid::DATA_BARS);
127  $data->setLabel($lng->txt("category_nr_selected"));
128  $data->setBarOptions(0.5, "center");
129  $data->setFill(1);
130 
131  $total = sizeof($a_results->getAnswers());
132  if($total > 0)
133  {
134  $cumulated = array();
135  foreach($a_results->getAnswers() as $answer)
136  {
137  $cumulated[$answer->value]++;
138  }
139 
140  $labels = array();
141  foreach($cumulated as $value => $count)
142  {
143  $data->addPoint($value, $count);
144  $labels[$value] = $value;
145  }
146  $chart->addData($data);
147 
148  $chart->setTicks($labels, false, true);
149 
150  return $chart->getHTML();
151  }
152  }
$total
Definition: Utf8Test.php:87
Create styles array
The data for the language used.
const TYPE_GRID
global $lng
Definition: privfeed.php:17
static getInstanceByType($a_type, $a_id)
Get type instance.
+ Here is the call graph for this function:

◆ getExportGrid()

SurveyMetricQuestionEvaluation::getExportGrid (   $a_results)

Get grid data.

Parameters
ilSurveyEvaluationResults | array$a_results
Returns
array

Definition at line 165 of file class.SurveyMetricQuestionEvaluation.php.

References $lng, $res, $total, and array.

166  {
167  global $lng;
168 
169  $res = array(
170  "cols" => array(
171  $lng->txt("value"),
172  $lng->txt("category_nr_selected"),
173  $lng->txt("svy_fraction_of_selections")
174  ),
175  "rows" => array()
176  );
177 
178  // as we have no variables build rows from answers directly
179  $total = sizeof($a_results->getAnswers());
180  if($total > 0)
181  {
182  $cumulated = array();
183  foreach($a_results->getAnswers() as $answer)
184  {
185  $cumulated[$answer->value]++;
186  }
187  foreach($cumulated as $value => $count)
188  {
189  $res["rows"][] = array(
190  $value,
191  $count,
192  sprintf("%.2f", $count/$total*100)."%"
193  );
194  }
195  }
196 
197  return $res;
198  }
$total
Definition: Utf8Test.php:87
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17

◆ getGrid()

SurveyMetricQuestionEvaluation::getGrid (   $a_results,
  $a_abs = true,
  $a_perc = true 
)

Definition at line 43 of file class.SurveyMetricQuestionEvaluation.php.

References $lng, $res, $total, and array.

44  {
45  global $lng;
46 
47  if((bool)$a_abs && (bool)$a_perc)
48  {
49  $cols = array(
50  $lng->txt("category_nr_selected"),
51  $lng->txt("svy_fraction_of_selections")
52  );
53  }
54  else if((bool)$a_abs)
55  {
56  $cols = array(
57  $lng->txt("category_nr_selected")
58  );
59  }
60  else
61  {
62  $cols = array(
63  $lng->txt("svy_fraction_of_selections")
64  );
65  }
66 
67  $res = array(
68  "cols" => $cols,
69  "rows" => array()
70  );
71 
72  // as we have no variables build rows from answers directly
73  $total = sizeof($a_results->getAnswers());
74  if($total > 0)
75  {
76  $cumulated = array();
77  foreach($a_results->getAnswers() as $answer)
78  {
79  $cumulated[$answer->value]++;
80  }
81  foreach($cumulated as $value => $count)
82  {
83  $perc = sprintf("%.2f", $count/$total*100)."%";
84  if((bool)$a_abs && (bool)$a_perc)
85  {
86  $res["rows"][] = array(
87  $value,
88  $count,
89  $perc
90  );
91  }
92  else if((bool)$a_abs)
93  {
94  $res["rows"][] = array(
95  $value,
96  $count
97  );
98  }
99  else
100  {
101  $res["rows"][] = array(
102  $value,
103  $perc
104  );
105  }
106  }
107  }
108 
109  return $res;
110  }
$total
Definition: Utf8Test.php:87
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17

◆ parseResults()

SurveyMetricQuestionEvaluation::parseResults ( ilSurveyEvaluationResults  $a_results,
array  $a_answers,
SurveyCategories  $a_categories = null 
)
protected

Definition at line 18 of file class.SurveyMetricQuestionEvaluation.php.

References $total, and ilSurveyEvaluationResults\setMean().

19  {
20  parent::parseResults($a_results, $a_answers);
21 
22  // add arithmetic mean
23  $total = $sum = 0;
24  foreach($a_answers as $answers)
25  {
26  foreach($answers as $answer)
27  {
28  $total++;
29  $sum += $answer["value"];
30  }
31  }
32  if($total > 0)
33  {
34  $a_results->setMean($sum/$total);
35  }
36  }
$total
Definition: Utf8Test.php:87
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: