Survey matrix evaluation.
More...
|
| getResults () |
|
| getGrid ($a_results, $a_abs=true, $a_perc=true) |
|
| getTextAnswers ($a_results) |
|
| getChart ($a_results) |
|
| exportResults ($a_results, $a_do_title, $a_do_label) |
|
| getUserSpecificVariableTitles (array &$a_title_row, array &$a_title_row2, $a_do_title, $a_do_label) |
|
| addUserSpecificResults (array &$a_row, $a_user_id, $a_results) |
|
| __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) |
|
◆ addUserSpecificResults()
SurveyMatrixQuestionEvaluation::addUserSpecificResults |
( |
array & |
$a_row, |
|
|
|
$a_user_id, |
|
|
|
$a_results |
|
) |
| |
Definition at line 317 of file class.SurveyMatrixQuestionEvaluation.php.
References $i, $index, and SurveyQuestionEvaluation\getSkippedValue().
319 $answer_map = array();
320 foreach ($a_results as $row_results) {
321 $row_title = $row_results[0];
322 $row_result = $row_results[1];
324 $answers = $row_result->getUserResults($a_user_id);
325 if ($answers !== null) {
326 foreach ($answers as $answer) {
328 if ($this->question->getSubtype() == 1) {
329 $answer_map[$row_title .
"|" . $answer[2]] = $answer[2];
331 $answer_map[$row_title] = $answer[3];
332 $answer_map[$row_title .
"|scale"] = $answer[2];
335 $answer_map[$row_title .
"|txt"] = $answer[1];
341 if (!
sizeof($answer_map)) {
347 for (
$i = 0;
$i < $this->question->getRowCount();
$i++) {
348 $row = $this->question->getRow(
$i);
349 $row_title = $row->title;
351 $a_row[] = $answer_map[$row_title];
352 if ($this->question->getSubtype() == 0) {
353 $a_row[] = $answer_map[$row_title .
"|scale"];
357 $a_row[] = $answer_map[$row_title .
"|txt"];
361 if ($this->question->getSubtype() == 1) {
363 $col = $this->question->getColumn(
$index);
364 $a_row[] = $answer_map[$row_title .
"|" . $col->scale];
getSkippedValue()
Get caption for skipped value.
◆ exportResults()
SurveyMatrixQuestionEvaluation::exportResults |
( |
|
$a_results, |
|
|
|
$a_do_title, |
|
|
|
$a_do_label |
|
) |
| |
Definition at line 192 of file class.SurveyMatrixQuestionEvaluation.php.
References SurveyQuestionEvaluation\$question, $rows, and SurveyQuestion\_getQuestionTypeName().
194 $question = $a_results[0][1]->getQuestion();
209 $row[] = (int) $a_results[0][1]->getUsersAnswered();
210 $row[] = (int) $a_results[0][1]->getUsersSkipped();
219 foreach ($a_results as $row_result) {
220 $row_title = $row_result[0];
221 $row_res = $row_result[1];
239 $row[] = is_array($row_res->getModeValue())
240 ? implode(
", ", $row_res->getModeValue())
241 : $row_res->getModeValue();
243 $row[] = $row_res->getModeValueAsText();
244 $row[] = (int) $row_res->getModeNrOfSelections();
247 $row[] = $row_res->getMedianAsText();
249 $row[] = $row_res->getMean();
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
◆ getChart()
SurveyMatrixQuestionEvaluation::getChart |
( |
|
$a_results | ) |
|
Definition at line 112 of file class.SurveyMatrixQuestionEvaluation.php.
References $data, SurveyQuestionEvaluation\$lng, ilChartGrid\DATA_BARS, SurveyQuestionEvaluation\getChartColors(), ilChart\getInstanceByType(), ilUtil\shortenText(), and ilChart\TYPE_GRID.
117 $chart->setXAxisToInteger(
true);
118 $chart->setStacked(
true);
121 $chart->setColors($colors);
126 $data = $labels = $legend = array();
128 $row_idx =
sizeof($a_results);
131 $text_shortened =
false;
132 foreach ($a_results as $row) {
135 $row_title = $row[0];
136 $row_results = $row[1];
139 $row_title = ++$row_counter .
". " . $row_title;
141 if ($labels[$row_idx] != $row_title) {
142 $text_shortened =
true;
146 $vars = $row_results->getVariables();
148 foreach ($vars as $idx => $var) {
149 if (!array_key_exists($idx,
$data)) {
151 $data[$idx]->setLabel($var->cat->title);
152 $data[$idx]->setBarOptions(0.5,
"center",
true);
153 $data[$idx]->setFill(1);
161 $data[$idx]->addPoint($var->abs, $row_idx);
167 $this->chart_height = count($a_results) * 40;
169 if ($text_shortened) {
170 $this->chart_width = 500;
172 $chart->setSize($this->chart_width, $this->chart_height);
174 foreach (
$data as $var) {
175 $chart->addData($var);
178 $chart->setTicks(
false, $labels,
true);
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
static getInstanceByType($a_type, $a_id)
Get type instance.
◆ getGrid()
SurveyMatrixQuestionEvaluation::getGrid |
( |
|
$a_results, |
|
|
|
$a_abs = true , |
|
|
|
$a_perc = true |
|
) |
| |
Definition at line 47 of file class.SurveyMatrixQuestionEvaluation.php.
References SurveyQuestionEvaluation\$lng, and $res.
57 $tmp = array_shift($tmp);
58 $vars = $tmp[1]->getVariables();
60 foreach ($vars as $var) {
61 $res[
"cols"][] = $var->cat->title;
65 foreach ($a_results as $results_row) {
68 ++$q_counter .
". " . $results_row[0]
71 $vars = $results_row[1]->getVariables();
73 foreach ($vars as $var) {
75 ? sprintf(
"%.2f", $var->perc * 100) .
"%" 78 if ((
bool) $a_abs && (
bool) $a_perc) {
79 $parsed_row[] = $var->abs .
" / " . $perc;
80 } elseif ((
bool) $a_abs) {
81 $parsed_row[] = $var->abs;
83 $parsed_row[] = $perc;
88 $res[
"rows"][] = $parsed_row;
foreach($_POST as $key=> $value) $res
◆ getResults()
SurveyMatrixQuestionEvaluation::getResults |
( |
| ) |
|
◆ getTextAnswers()
SurveyMatrixQuestionEvaluation::getTextAnswers |
( |
|
$a_results | ) |
|
Definition at line 93 of file class.SurveyMatrixQuestionEvaluation.php.
References $res.
97 foreach ($a_results as $results_row) {
98 $texts = $results_row[1]->getMappedTextAnswers();
100 $idx = $results_row[0];
101 foreach ($texts as $answers) {
102 foreach ($answers as $answer) {
103 $res[$idx][] = $answer;
foreach($_POST as $key=> $value) $res
◆ getUserSpecificVariableTitles()
SurveyMatrixQuestionEvaluation::getUserSpecificVariableTitles |
( |
array & |
$a_title_row, |
|
|
array & |
$a_title_row2, |
|
|
|
$a_do_title, |
|
|
|
$a_do_label |
|
) |
| |
Definition at line 256 of file class.SurveyMatrixQuestionEvaluation.php.
References $i, $index, and SurveyQuestionEvaluation\$lng.
260 for (
$i = 0;
$i < $this->question->getRowCount();
$i++) {
262 $row = $this->question->getRow(
$i);
264 if ($a_do_title && $a_do_label) {
265 $a_title_row[] = $row->title;
266 $a_title_row2[] = $row->label;
268 if ($this->question->getSubtype() == 0) {
269 $a_title_row[] = $row->title;
270 $a_title_row2[] = $row->label;
274 $a_title_row[] = $row->title;
275 $a_title_row2[] =
$lng->txt(
'other');
277 } elseif ($a_do_title) {
278 $a_title_row[] = $row->title;
279 $a_title_row2[] =
"";
281 if ($this->question->getSubtype() == 0) {
282 $a_title_row[] = $row->title;
283 $a_title_row2[] =
"";
287 $a_title_row[] = $row->title;
288 $a_title_row2[] =
$lng->txt(
'other');
291 $a_title_row[] = $row->label;
292 $a_title_row2[] =
"";
294 if ($this->question->getSubtype() == 0) {
295 $a_title_row[] = $row->label;
296 $a_title_row2[] =
"";
300 $a_title_row[] = $row->label;
301 $a_title_row2[] =
$lng->txt(
'other');
306 if ($this->question->getSubtype() == 1) {
308 $col = $this->question->getColumn(
$index);
310 $a_title_row[] = $col->title .
" [" . $col->scale .
"]";
311 $a_title_row2[] =
"";
◆ isSumScoreValid()
SurveyMatrixQuestionEvaluation::isSumScoreValid |
( |
int |
$nr_answer_records | ) |
|
|
protected |
◆ supportsSumScore()
SurveyMatrixQuestionEvaluation::supportsSumScore |
( |
| ) |
|
|
protected |
The documentation for this class was generated from the following file: