ILIAS  release_7 Revision v7.30-3-g800a261c036
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...
 
 getSumScores ()
 Get sum score for this question for all active ids of run. 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
 isSumScoreValid (int $nr_answer_records)
 Is sum score ok (question needs to be fully answered) More...
 
 supportsSumScore ()
 Supports sum score? More...
 
 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 10 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 178 of file class.SurveyMetricQuestionEvaluation.php.

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

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

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

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

References SurveyQuestionEvaluation\$lng, $res, and $total.

◆ 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 38 of file class.SurveyMetricQuestionEvaluation.php.

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

References $cols, SurveyQuestionEvaluation\$lng, $res, and $total.

◆ 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 16 of file class.SurveyMetricQuestionEvaluation.php.

17 {
18 parent::parseResults($a_results, $a_answers);
19
20 // add arithmetic mean
21 $total = $sum = 0;
22 foreach ($a_answers as $answers) {
23 foreach ($answers as $answer) {
24 $total++;
25 $sum += $answer["value"];
26 }
27 }
28 if ($total > 0) {
29 $a_results->setMean($sum / $total);
30 }
31 }

References $total, and ilSurveyEvaluationResults\setMean().

+ Here is the call graph for this function:

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