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)
 Get grid data. More...
 
 getChart ($a_results)
 Get chart. More...
 
 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)
 Parse answer data into results instance. More...
 
- 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 
)
Parameters
array$a_row
int$a_user_id
ilSurveyEvaluationResults | array$a_results

Reimplemented from SurveyQuestionEvaluation.

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

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.

References SurveyQuestionEvaluation\getSkippedValue().

+ Here is the call graph for this function:

◆ getChart()

SurveyMetricQuestionEvaluation::getChart (   $a_results)

Get chart.

Parameters
ilSurveyEvaluationResults | array$a_results
Returns
array

Reimplemented from SurveyQuestionEvaluation.

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

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
static getInstanceByType($a_type, $a_id)
Get type instance.
const TYPE_GRID
global $lng
Definition: privfeed.php:17

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

+ Here is the call graph for this function:

◆ getExportGrid()

SurveyMetricQuestionEvaluation::getExportGrid (   $a_results)

Get grid data.

Parameters
ilSurveyEvaluationResults | array$a_results
Returns
array

Reimplemented from SurveyQuestionEvaluation.

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

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 }
sprintf('%.4f', $callTime)

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

◆ getGrid()

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

Get grid data.

Parameters
ilSurveyEvaluationResults | array$a_results
bool$a_abs
bool$a_perc
Returns
array

Reimplemented from SurveyQuestionEvaluation.

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

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 }

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

◆ parseResults()

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

Parse answer data into results instance.

Parameters
ilSurveyEvaluationResults$a_results
array$a_answers
SurveyCategories$a_categories

Reimplemented from SurveyQuestionEvaluation.

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

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 }

References $total, and ilSurveyEvaluationResults\setMean().

+ Here is the call graph for this function:

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