ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SurveyMetricQuestionEvaluation Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 getGrid ( $a_results, bool $a_abs=true, bool $a_perc=true)
 
 getChart ($a_results)
 
 getExportGrid ($a_results)
 Get grid data. More...
 
 addUserSpecificResults (array &$a_row, int $a_user_id, $a_results)
 
- Public Member Functions inherited from SurveyQuestionEvaluation
 __construct (SurveyQuestion $a_question, array $a_finished_ids=[])
 
 getResults ()
 Get results. More...
 
 getSumScores ()
 Get sum score for this question for all active ids of run. More...
 
 parseUserSpecificResults ($a_qres, int $a_user_id)
 
 getGrid ( $a_results, bool $a_abs=true, bool $a_perc=true)
 Get grid data. More...
 
 getTextAnswers ($a_results)
 Get text answers. More...
 
 getChart ($a_results)
 
 getSkippedValue ()
 Get caption for skipped value. More...
 
 exportResults ( $a_results, bool $a_do_title, bool $a_do_label)
 
 getExportGrid ($a_results)
 Get grid data. More...
 
 getUserSpecificVariableTitles (array &$a_title_row, array &$a_title_row2, bool $a_do_title, bool $a_do_label)
 Get title columns for user-specific export. More...
 
 addUserSpecificResults (array &$a_row, int $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 ()
 
 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
ilLanguage $lng
 
ilDBInterface $db
 
SurveyQuestion $question
 
array $finished_ids
 
int $chart_width = 400
 
int $chart_height = 300
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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 24 of file class.SurveyMetricQuestionEvaluation.php.

Member Function Documentation

◆ addUserSpecificResults()

SurveyMetricQuestionEvaluation::addUserSpecificResults ( array &  $a_row,
int  $a_user_id,
  $a_results 
)
Parameters
array | ilSurveyEvaluationResults$a_results

Reimplemented from SurveyQuestionEvaluation.

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

212 : void {
213 $answer = $a_results->getUserResults($a_user_id);
214 if (count($answer) === 0) {
215 $a_row[] = $this->getSkippedValue();
216 } else {
217 $a_row[] = $answer[0][0];
218 }
219 }
getSkippedValue()
Get caption for skipped value.

◆ getChart()

SurveyMetricQuestionEvaluation::getChart (   $a_results)
Parameters
array | ilSurveyEvaluationResults$a_results

Reimplemented from SurveyQuestionEvaluation.

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

122 : ?array
123 {
125
126 $chart = ilChart::getInstanceByType(ilChart::TYPE_GRID, $a_results->getQuestion()->getId());
127 $chart->setYAxisToInteger(true);
128
129 $colors = $this->getChartColors();
130 $chart->setColors($colors);
131
132 // :TODO:
133 $chart->setSize((string) $this->chart_width, (string) $this->chart_height);
134
135 $data = $chart->getDataInstance(ilChartGrid::DATA_BARS);
136 $data->setLabel($lng->txt("category_nr_selected"));
137 $data->setBarOptions(0.5, "center");
138 $data->setFill(1);
139
140 $total = count($a_results->getAnswers());
141 if ($total > 0) {
142 $cumulated = array();
143 foreach ($a_results->getAnswers() as $answer) {
144 $cumulated[(string) $answer->value] = ($cumulated[(string) $answer->value] ?? 0) + 1;
145 }
146
147 $labels = array();
148 foreach ($cumulated as $value => $count) {
149 $data->addPoint($value, $count);
150 $labels[$value] = $value;
151 }
152 $chart->addData($data);
153
154 $chart->setTicks($labels, false, true);
155
156 return array(
157 $chart->getHTML(),
158 null
159 );
160 }
161 return null;
162 }
static getInstanceByType(int $a_type, string $a_id)
const TYPE_GRID
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...

References $data, $lng, ilChartGrid\DATA_BARS, ilSurveyEvaluationResults\getAnswers(), ilChart\getInstanceByType(), ilSurveyEvaluationResults\getQuestion(), 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

Reimplemented from SurveyQuestionEvaluation.

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

173 : array
174 {
176
177 $res = array(
178 "cols" => array(
179 $lng->txt("value"),
180 $lng->txt("category_nr_selected"),
181 $lng->txt("svy_fraction_of_selections")
182 ),
183 "rows" => array()
184 );
185
186 // as we have no variables build rows from answers directly
187 $total = count($a_results->getAnswers());
188 if ($total > 0) {
189 $cumulated = array();
190 foreach ($a_results->getAnswers() as $answer) {
191 $cumulated[(string) $answer->value] = ($cumulated[(string) $answer->value] ?? 0) + 1;
192 }
193 foreach ($cumulated as $value => $count) {
194 $res["rows"][] = array(
195 $value,
196 $count,
197 sprintf("%.2f", $count / $total * 100) . "%"
198 );
199 }
200 }
201
202 return $res;
203 }
$res
Definition: ltiservices.php:69

References $lng, $res, and ilSurveyEvaluationResults\getAnswers().

+ Here is the call graph for this function:

◆ getGrid()

SurveyMetricQuestionEvaluation::getGrid (   $a_results,
bool  $a_abs = true,
bool  $a_perc = true 
)
Parameters
array | ilSurveyEvaluationResults$a_results

Reimplemented from SurveyQuestionEvaluation.

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

62 : array {
64
65 if ($a_abs && $a_perc) {
66 $cols = array(
67 $lng->txt("category_nr_selected"),
68 $lng->txt("svy_fraction_of_selections")
69 );
70 } elseif ($a_abs) {
71 $cols = array(
72 $lng->txt("category_nr_selected")
73 );
74 } else {
75 $cols = array(
76 $lng->txt("svy_fraction_of_selections")
77 );
78 }
79
80 $res = array(
81 "cols" => $cols,
82 "rows" => array()
83 );
84
85 // as we have no variables build rows from answers directly
86 $answ = $a_results->getAnswers();
87 $total = count($answ);
88
89 if ($total > 0) {
90 $cumulated = array();
91 foreach ($a_results->getAnswers() as $answer) {
92 $cumulated[(string) $answer->value] = ($cumulated[(string) $answer->value] ?? 0) + 1;
93 }
94 foreach ($cumulated as $value => $count) {
95 $perc = sprintf("%.2f", $count / $total * 100) . "%";
96 if ($a_abs && $a_perc) {
97 $res["rows"][] = array(
98 $value,
99 $count,
100 $perc
101 );
102 } elseif ($a_abs) {
103 $res["rows"][] = array(
104 $value,
105 $count
106 );
107 } else {
108 $res["rows"][] = array(
109 $value,
110 $perc
111 );
112 }
113 }
114 }
115
116 return $res;
117 }

References $lng.

◆ parseResults()

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

Parse answer data into results instance.

Reimplemented from SurveyQuestionEvaluation.

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

34 : void {
35 parent::parseResults($a_results, $a_answers);
36
37 // add arithmetic mean
38 $total = $sum = 0;
39 foreach ($a_answers as $answers) {
40 foreach ($answers as $answer) {
41 $total++;
42 $sum += $answer["value"];
43 }
44 }
45 if ($total > 0) {
46 $a_results->setMean($sum / $total);
47 }
48 }

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