ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
 $lng
 
 $db
 
 $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 181 of file class.SurveyMetricQuestionEvaluation.php.

182 {
183 $answer = $a_results->getUserResults($a_user_id);
184 if ($answer === null) {
185 $a_row[] = $this->getSkippedValue();
186 } else {
187 $a_row[] = $answer[0][0];
188 }
189 }
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 99 of file class.SurveyMetricQuestionEvaluation.php.

100 {
102
103 include_once "Services/Chart/classes/class.ilChart.php";
104 $chart = ilChart::getInstanceByType(ilChart::TYPE_GRID, $a_results->getQuestion()->getId());
105 $chart->setYAxisToInteger(true);
106
107 $colors = $this->getChartColors();
108 $chart->setColors($colors);
109
110 // :TODO:
111 $chart->setsize($this->chart_width, $this->chart_height);
112
113 $data = $chart->getDataInstance(ilChartGrid::DATA_BARS);
114 $data->setLabel($lng->txt("category_nr_selected"));
115 $data->setBarOptions(0.5, "center");
116 $data->setFill(1);
117
118 $total = sizeof($a_results->getAnswers());
119 if ($total > 0) {
120 $cumulated = array();
121 foreach ($a_results->getAnswers() as $answer) {
122 $cumulated[$answer->value]++;
123 }
124
125 $labels = array();
126 foreach ($cumulated as $value => $count) {
127 $data->addPoint($value, $count);
128 $labels[$value] = $value;
129 }
130 $chart->addData($data);
131
132 $chart->setTicks($labels, false, true);
133
134 return $chart->getHTML();
135 }
136 }
$total
Definition: Utf8Test.php:87
static getInstanceByType($a_type, $a_id)
Get type instance.
const TYPE_GRID

References $chart, $data, SurveyQuestionEvaluation\$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 149 of file class.SurveyMetricQuestionEvaluation.php.

150 {
152
153 $res = array(
154 "cols" => array(
155 $lng->txt("value"),
156 $lng->txt("category_nr_selected"),
157 $lng->txt("svy_fraction_of_selections")
158 ),
159 "rows" => array()
160 );
161
162 // as we have no variables build rows from answers directly
163 $total = sizeof($a_results->getAnswers());
164 if ($total > 0) {
165 $cumulated = array();
166 foreach ($a_results->getAnswers() as $answer) {
167 $cumulated[$answer->value]++;
168 }
169 foreach ($cumulated as $value => $count) {
170 $res["rows"][] = array(
171 $value,
172 $count,
173 sprintf("%.2f", $count/$total*100) . "%"
174 );
175 }
176 }
177
178 return $res;
179 }
sprintf('%.4f', $callTime)
foreach($_POST as $key=> $value) $res

References SurveyQuestionEvaluation\$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 40 of file class.SurveyMetricQuestionEvaluation.php.

41 {
43
44 if ((bool) $a_abs && (bool) $a_perc) {
45 $cols = array(
46 $lng->txt("category_nr_selected"),
47 $lng->txt("svy_fraction_of_selections")
48 );
49 } elseif ((bool) $a_abs) {
50 $cols = array(
51 $lng->txt("category_nr_selected")
52 );
53 } else {
54 $cols = array(
55 $lng->txt("svy_fraction_of_selections")
56 );
57 }
58
59 $res = array(
60 "cols" => $cols,
61 "rows" => array()
62 );
63
64 // as we have no variables build rows from answers directly
65 $answ = $a_results->getAnswers();
66 if (is_array($answ)) {
67 $total = sizeof($a_results->getAnswers());
68 if ($total > 0) {
69 $cumulated = array();
70 foreach ($a_results->getAnswers() as $answer) {
71 $cumulated[$answer->value]++;
72 }
73 foreach ($cumulated as $value => $count) {
74 $perc = sprintf("%.2f", $count / $total * 100) . "%";
75 if ((bool) $a_abs && (bool) $a_perc) {
76 $res["rows"][] = array(
77 $value,
78 $count,
79 $perc
80 );
81 } elseif ((bool) $a_abs) {
82 $res["rows"][] = array(
83 $value,
84 $count
85 );
86 } else {
87 $res["rows"][] = array(
88 $value,
89 $perc
90 );
91 }
92 }
93 }
94 }
95
96 return $res;
97 }
$cols
Definition: xhr_table.php:11

References $cols, SurveyQuestionEvaluation\$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 foreach ($answers as $answer) {
26 $total++;
27 $sum += $answer["value"];
28 }
29 }
30 if ($total > 0) {
31 $a_results->setMean($sum/$total);
32 }
33 }

References $total, and ilSurveyEvaluationResults\setMean().

+ Here is the call graph for this function:

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