23 for ($r = 0; $r < $this->question->getRowCount(); $r++) {
29 $this->question->getColumns()
33 $this->question->getRow($r)->title,
47 public function getGrid($a_results, $a_abs =
true, $a_perc =
true)
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;
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;
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);
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();
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[] =
"";
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];
383 if ($nr_answer_records == $this->question->getRowCount()) {
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
getUserSpecificVariableTitles(array &$a_title_row, array &$a_title_row2, $a_do_title, $a_do_label)
addUserSpecificResults(array &$a_row, $a_user_id, $a_results)
isSumScoreValid(int $nr_answer_records)
exportResults($a_results, $a_do_title, $a_do_label)
Survey question evaluation.
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
Survey matrix evaluation.
getTextAnswers($a_results)
Survey evaluation answers.
foreach($_POST as $key=> $value) $res
parseResults(ilSurveyEvaluationResults $a_results, array $a_answers, SurveyCategories $a_categories=null)
Parse answer data into results instance.
getSkippedValue()
Get caption for skipped value.
static getInstanceByType($a_type, $a_id)
Get type instance.
getGrid($a_results, $a_abs=true, $a_perc=true)