24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
43 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyMatrixQuestion.php";
63 "0" =>
"matrix_subtype_sr",
64 "1" =>
"matrix_subtype_mr",
71 foreach ($subtypes as $idx => $st)
73 $subtype->addOption(
new ilRadioOption($this->lng->txt($st), $idx));
79 $header->setTitle($this->lng->txt(
"matrix_appearance"));
83 $column_separators =
new ilCheckboxInputGUI($this->lng->txt(
"matrix_column_separators"),
"column_separators");
85 $column_separators->setInfo($this->lng->txt(
"matrix_column_separators_description"));
86 $column_separators->setRequired(
false);
87 $a_form->
addItem($column_separators);
90 $row_separators =
new ilCheckboxInputGUI($this->lng->txt(
"matrix_row_separators"),
"row_separators");
92 $row_separators->setInfo($this->lng->txt(
"matrix_row_separators_description"));
93 $row_separators->setRequired(
false);
94 $a_form->
addItem($row_separators);
97 $neutral_column_separator =
new ilCheckboxInputGUI($this->lng->txt(
"matrix_neutral_column_separator"),
"neutral_column_separator");
98 $neutral_column_separator->
setValue(1);
99 $neutral_column_separator->setInfo($this->lng->txt(
"matrix_neutral_column_separator_description"));
100 $neutral_column_separator->setRequired(
false);
101 $a_form->
addItem($neutral_column_separator);
105 $header->setTitle($this->lng->txt(
"matrix_columns"));
109 include_once
"./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
114 $columns->setShowNeutralCategory(
true);
116 $columns->setNeutralCategoryTitle($this->lng->txt(
'matrix_neutral_answer'));
117 $columns->setCategoryText($this->lng->txt(
'matrix_standard_answers'));
123 $header->setTitle($this->lng->txt(
"matrix_column_settings"));
127 $bipolar =
new ilCustomInputGUI($this->lng->txt(
"matrix_bipolar_adjectives"));
128 $bipolar->
setInfo($this->lng->txt(
"matrix_bipolar_adjectives_description"));
131 $bipolar1 =
new ilTextInputGUI($this->lng->txt(
"matrix_left_pole"),
"bipolar1");
133 $bipolar->addSubItem($bipolar1);
136 $bipolar2 =
new ilTextInputGUI($this->lng->txt(
"matrix_right_pole"),
"bipolar2");
138 $bipolar->addSubItem($bipolar2);
144 $header->setTitle($this->lng->txt(
"matrix_rows"));
148 include_once
"./Modules/SurveyQuestionPool/classes/class.ilMatrixRowWizardInputGUI.php";
150 $rows->setRequired(
false);
151 $rows->setAllowMove(
true);
152 $rows->setLabelText($this->lng->txt(
'label'));
153 $rows->setUseOtherAnswer(
true);
158 $subtype->setValue($this->object->getSubtype());
159 $column_separators->setChecked($this->object->getColumnSeparators());
160 $row_separators->setChecked($this->object->getRowSeparators());
161 $neutral_column_separator->setChecked($this->object->getNeutralColumnSeparator());
163 if (!$this->object->getColumnCount())
165 $this->
object->columns->addCategory(
"");
167 $columns->setValues($this->object->getColumns());
169 $bipolar1->setValue($this->object->getBipolarAdjective(0));
170 $bipolar2->setValue($this->object->getBipolarAdjective(1));
172 if ($this->object->getRowCount() == 0)
174 $this->
object->getRows()->addCategory(
"");
176 $rows->setValues($this->object->getRows());
181 $this->
object->setSubtype($a_form->
getInput(
"type"));
182 $this->
object->setRowSeparators($a_form->
getInput(
"row_separators") ? 1 : 0);
183 $this->
object->setColumnSeparators($a_form->
getInput(
"column_separators") ? 1 : 0);
184 $this->
object->setNeutralColumnSeparator($a_form->
getInput(
"neutral_column_separator") ? 1 : 0);
187 $this->
object->setBipolarAdjective(0, $a_form->
getInput(
"bipolar1"));
188 $this->
object->setBipolarAdjective(1, $a_form->
getInput(
"bipolar2"));
191 $this->
object->flushColumns();
193 foreach (
$_POST[
'columns'][
'answer'] as $key => $value)
195 if (strlen($value)) $this->
object->getColumns()->addCategory($value,
$_POST[
'columns'][
'other'][$key], 0, null,
$_POST[
'columns'][
'scale'][$key]);
197 if (strlen(
$_POST[
"columns"][
"neutral"]))
199 $this->
object->getColumns()->addCategory(
$_POST[
'columns'][
'neutral'], 0, 1, null,
$_POST[
'columns_neutral_scale']);
203 $this->
object->flushRows();
204 foreach (
$_POST[
'rows'][
'answer'] as $key => $value)
206 if (strlen($value)) $this->
object->getRows()->addCategory($value,
$_POST[
'rows'][
'other'][$key], 0,
$_POST[
'rows'][
'label'][$key]);
210 public function getParsedAnswers(array $a_working_data = null, $a_only_user_anwers =
false)
212 if(is_array($a_working_data))
214 $user_answers = $a_working_data;
218 for ($i = 0; $i < $this->
object->getRowCount(); $i++)
220 $rowobj = $this->
object->getRow($i);
225 for ($j = 0; $j < $this->
object->getColumnCount(); $j++)
227 $cat = $this->
object->getColumn($j);
228 $value = ($cat->scale) ? ($cat->scale - 1) : $j;
230 $checked =
"unchecked";
231 if(is_array($a_working_data))
233 foreach($user_answers as $user_answer)
235 if($user_answer[
"rowvalue"] == $i &&
236 $user_answer[
"value"] == $value)
238 $checked =
"checked";
239 if($user_answer[
"textanswer"])
241 $text = $user_answer[
"textanswer"];
247 if(!$a_only_user_anwers || $checked ==
"checked")
249 $cols[$value] = array(
250 "title" => trim($cat->title)
251 ,
"neutral" => (
bool)$cat->neutral
252 ,
"checked" => $checked
257 if($a_only_user_anwers ||
sizeof($cols) || $text)
261 "title" => trim($rowobj->title)
262 ,
"other" => (
bool)$rowobj->other
263 ,
"textanswer" => $text
277 function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null, array $a_working_data = null)
281 $layout = $this->
object->getLayout();
282 $neutralstyle =
"3px solid #808080";
283 $bordercolor =
"#808080";
284 $template =
new ilTemplate(
"tpl.il_svy_qpl_matrix_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
286 if ($this->show_layout_row)
289 $template->setCurrentBlock(
"matrix_row");
290 $template->setVariable(
"ROW", $layout_row);
291 $template->parseCurrentBlock();
294 $tplheaders =
new ilTemplate(
"tpl.il_svy_out_matrix_columnheaders.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
295 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
297 $tplheaders->setCurrentBlock(
"bipolar_start");
299 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_bipolar_adjective1"],
"%"));
300 if (count($style) > 0)
302 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
304 $tplheaders->parseCurrentBlock();
307 for ($i = 0; $i < $this->
object->getColumnCount(); $i++)
309 $cat = $this->
object->getColumn($i);
312 $tplheaders->setCurrentBlock(
"neutral_column_header");
314 $tplheaders->setVariable(
"CLASS",
"rsep");
316 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_neutral"],
"%"));
317 if ($this->object->getNeutralColumnSeparator())
319 array_push($style,
"border-left: $neutralstyle!important;");
321 if (count($style) > 0)
323 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
325 $tplheaders->parseCurrentBlock();
330 if ($this->object->getColumnSeparators() == 1)
332 if (($i < $this->object->getColumnCount() - 1))
334 array_push($style,
"border-right: 1px solid $bordercolor!important");
337 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_columns"] / $this->object->getColumnCount(),
"%"));
338 $tplheaders->setCurrentBlock(
"column_header");
340 $tplheaders->setVariable(
"CLASS",
"center");
341 if (count($style) > 0)
343 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
345 $tplheaders->parseCurrentBlock();
349 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
351 $tplheaders->setCurrentBlock(
"bipolar_end");
353 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_bipolar_adjective2"],
"%"));
354 if (count($style) > 0)
356 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
358 $tplheaders->parseCurrentBlock();
362 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_row"],
"%"));
363 if (count($style) > 0)
365 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
368 $template->setCurrentBlock(
"matrix_row");
369 $template->setVariable(
"ROW", $tplheaders->get());
370 $template->parseCurrentBlock();
372 $rowclass = array(
"tblrow1",
"tblrow2");
374 for ($i = 0; $i < $this->
object->getRowCount(); $i++)
376 $rowobj = $this->
object->getRow($i);
377 $tplrow =
new ilTemplate(
"tpl.il_svy_qpl_matrix_printview_row.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
378 for ($j = 0; $j < $this->
object->getColumnCount(); $j++)
380 $cat = $this->
object->getColumn($j);
381 if (($i == 0) && ($j == 0))
383 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
385 $tplrow->setCurrentBlock(
"bipolar_start");
387 $tplrow->setVariable(
"ROWSPAN", $this->object->getRowCount());
388 $tplrow->parseCurrentBlock();
391 if (($i == 0) && ($j == $this->object->getColumnCount()-1))
393 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
395 $tplrow->setCurrentBlock(
"bipolar_end");
397 $tplrow->setVariable(
"ROWSPAN", $this->object->getRowCount());
398 $tplrow->parseCurrentBlock();
402 $value = ($cat->scale) ? ($cat->scale - 1) : $j;
403 $col =
$options[$i][
"cols"][$value];
405 switch ($this->object->getSubtype())
410 $tplrow->setCurrentBlock(
"neutral_radiobutton");
412 $tplrow->setVariable(
"ALT_RADIO", $this->lng->txt($col[
"checked"]));
413 $tplrow->setVariable(
"TITLE_RADIO", $this->lng->txt($col[
"checked"]));
414 $tplrow->parseCurrentBlock();
418 $tplrow->setCurrentBlock(
"radiobutton");
420 $tplrow->setVariable(
"ALT_RADIO", $this->lng->txt($col[
"checked"]));
421 $tplrow->setVariable(
"TITLE_RADIO", $this->lng->txt($col[
"checked"]));
422 $tplrow->parseCurrentBlock();
428 $tplrow->setCurrentBlock(
"neutral_checkbox");
430 $tplrow->setVariable(
"ALT_CHECKBOX", $this->lng->txt($col[
"checked"]));
431 $tplrow->setVariable(
"TITLE_CHECKBOX", $this->lng->txt($col[
"checked"]));
432 $tplrow->parseCurrentBlock();
436 $tplrow->setCurrentBlock(
"checkbox");
438 $tplrow->setVariable(
"ALT_CHECKBOX", $this->lng->txt($col[
"checked"]));
439 $tplrow->setVariable(
"TITLE_CHECKBOX", $this->lng->txt($col[
"checked"]));
440 $tplrow->parseCurrentBlock();
446 $tplrow->setCurrentBlock(
"neutral_answer");
448 if ($this->object->getNeutralColumnSeparator())
450 array_push($style,
"border-left: $neutralstyle!important");
452 if ($this->object->getColumnSeparators() == 1)
454 if ($j < $this->object->getColumnCount() - 1)
456 array_push($style,
"border-right: 1px solid $bordercolor!important");
460 if ($this->object->getRowSeparators() == 1)
462 if ($i < $this->object->getRowCount() - 1)
464 array_push($style,
"border-bottom: 1px solid $bordercolor!important");
469 $tplrow->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
471 $tplrow->parseCurrentBlock();
475 $tplrow->setCurrentBlock(
"answer");
478 if ($this->object->getColumnSeparators() == 1)
480 if ($j < $this->object->getColumnCount() - 1)
482 array_push($style,
"border-right: 1px solid $bordercolor!important");
486 if ($this->object->getRowSeparators() == 1)
488 if ($i < $this->object->getRowCount() - 1)
490 array_push($style,
"border-bottom: 1px solid $bordercolor!important");
495 $tplrow->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
497 $tplrow->parseCurrentBlock();
504 $tplrow->setCurrentBlock(
"text_other");
505 $tplrow->setVariable(
"TEXT_OTHER", $text
507 :
" ");
508 $tplrow->parseCurrentBlock();
512 $tplrow->setVariable(
"ROWCLASS", $rowclass[$i % 2]);
513 if ($this->object->getRowSeparators() == 1)
515 if ($i < $this->object->getRowCount() - 1)
517 $tplrow->setVariable(
"STYLE",
" style=\"border-bottom: 1px solid $bordercolor!important\"");
520 $template->setCurrentBlock(
"matrix_row");
521 $template->setVariable(
"ROW", $tplrow->get());
522 $template->parseCurrentBlock();
529 $template->setCurrentBlock();
530 if ($show_questiontext)
534 $template->parseCurrentBlock();
535 return $template->get();
552 $ilTabs->activateTab(
"layout");
554 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_layout.html",
"Modules/SurveyQuestionPool");
555 $this->show_layout_row = TRUE;
557 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
558 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this,
"saveLayout"));
559 $this->tpl->setVariable(
"SAVE", $this->lng->txt(
"save"));
569 $percent_values = array(
570 "percent_row" => (
int)
$_POST[
"percent_row"],
571 "percent_columns" => (
int)$_POST[
"percent_columns"],
572 "percent_bipolar_adjective1" => (
int)$_POST[
'percent_bipolar_adjective1'],
573 "percent_bipolar_adjective2" => (
int)$_POST[
'percent_bipolar_adjective2'],
574 "percent_neutral" => (
int)$_POST[
"percent_neutral"]
576 $this->
object->setLayout($percent_values);
579 if(array_sum($percent_values) == 100)
581 $this->
object->saveLayout($percent_values[
"percent_row"],
582 $percent_values[
'percent_columns'],
583 $percent_values[
'percent_bipolar_adjective1'],
584 $percent_values[
'percent_bipolar_adjective2'],
585 $percent_values[
"percent_neutral"]);
602 $percent_values = $this->
object->getLayout();
603 $template =
new ilTemplate(
"tpl.il_svy_out_matrix_layout.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
604 if (strlen($this->object->getBipolarAdjective(0)) && strlen($this->object->getBipolarAdjective(1)))
606 $template->setCurrentBlock(
"bipolar_start");
607 $template->setVariable(
"VALUE_PERCENT_BIPOLAR_ADJECTIVE1",
" value=\"" . $percent_values[
"percent_bipolar_adjective1"] .
"\"");
608 $template->setVariable(
"STYLE",
" style=\"width:" . $percent_values[
"percent_bipolar_adjective1"] .
"%\"");
609 $template->parseCurrentBlock();
610 $template->setCurrentBlock(
"bipolar_end");
611 $template->setVariable(
"VALUE_PERCENT_BIPOLAR_ADJECTIVE2",
" value=\"" . $percent_values[
"percent_bipolar_adjective2"] .
"\"");
612 $template->setVariable(
"STYLE",
" style=\"width:" . $percent_values[
"percent_bipolar_adjective2"] .
"%\"");
613 $template->parseCurrentBlock();
615 $counter = $this->
object->getColumnCount();
616 if (strlen($this->object->hasNeutralColumn()))
618 $template->setCurrentBlock(
"neutral_start");
619 $template->setVariable(
"VALUE_PERCENT_NEUTRAL",
" value=\"" . $percent_values[
"percent_neutral"] .
"\"");
620 $template->setVariable(
"STYLE_NEUTRAL",
" style=\"width:" . $percent_values[
"percent_neutral"] .
"%\"");
621 $template->parseCurrentBlock();
624 $template->setVariable(
"VALUE_PERCENT_ROW",
" value=\"" . $percent_values[
"percent_row"] .
"\"");
625 $template->setVariable(
"STYLE_ROW",
" style=\"width:" . $percent_values[
"percent_row"] .
"%\"");
626 $template->setVariable(
"COLSPAN_COLUMNS", $counter);
627 $template->setVariable(
"VALUE_PERCENT_COLUMNS",
" value=\"" . $percent_values[
"percent_columns"] .
"\"");
628 $template->setVariable(
"STYLE_COLUMNS",
" style=\"width:" . $percent_values[
"percent_columns"] .
"%\"");
629 return $template->get();
642 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
644 $layout = $this->
object->getLayout();
645 $neutralstyle =
"3px solid #808080";
646 $bordercolor =
"#808080";
647 $template =
new ilTemplate(
"tpl.il_svy_out_matrix.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
648 $template->setCurrentBlock(
"material_matrix");
650 $template->parseCurrentBlock();
652 if ($this->show_layout_row)
655 $template->setCurrentBlock(
"matrix_row");
656 $template->setVariable(
"ROW", $layout_row);
657 $template->parseCurrentBlock();
660 $tplheaders =
new ilTemplate(
"tpl.il_svy_out_matrix_columnheaders.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
661 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
663 $tplheaders->setCurrentBlock(
"bipolar_start");
665 array_push($style, sprintf(
"width: %.2F%s!important", $layout[
"percent_bipolar_adjective1"],
"%"));
666 if (count($style) > 0)
668 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
670 $tplheaders->parseCurrentBlock();
673 for ($i = 0; $i < $this->
object->getColumnCount(); $i++)
676 $col = $this->
object->getColumn($i);
679 $tplheaders->setCurrentBlock(
"neutral_column_header");
681 $tplheaders->setVariable(
"CLASS",
"rsep");
683 array_push($style, sprintf(
"width: %.2F%s!important", $layout[
"percent_neutral"],
"%"));
684 if ($this->object->getNeutralColumnSeparator())
686 array_push($style,
"border-left: $neutralstyle!important;");
688 if (count($style) > 0)
690 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
692 $tplheaders->parseCurrentBlock();
696 if ($this->object->getColumnSeparators() == 1)
698 if (($i < $this->object->getColumnCount() - 1))
700 array_push($style,
"border-right: 1px solid $bordercolor!important");
703 array_push($style, sprintf(
"width: %.2F%s!important", $layout[
"percent_columns"] / $this->object->getColumnCount(),
"%"));
704 $tplheaders->setCurrentBlock(
"column_header");
706 $tplheaders->setVariable(
"CLASS",
"center");
707 if (count($style) > 0)
709 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
711 $tplheaders->parseCurrentBlock();
714 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
716 $tplheaders->setCurrentBlock(
"bipolar_end");
718 array_push($style, sprintf(
"width: %.2F%s!important", $layout[
"percent_bipolar_adjective2"],
"%"));
719 if (count($style) > 0)
721 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
723 $tplheaders->parseCurrentBlock();
727 array_push($style, sprintf(
"width: %.2F%s!important", $layout[
"percent_row"],
"%"));
728 if (count($style) > 0)
730 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
733 $template->setCurrentBlock(
"matrix_row");
734 $template->setVariable(
"ROW", $tplheaders->get());
735 $template->parseCurrentBlock();
737 $rowclass = array(
"tblrow1",
"tblrow2");
738 for ($i = 0; $i < $this->
object->getRowCount(); $i++)
740 $rowobj = $this->
object->getRow($i);
741 $tplrow =
new ilTemplate(
"tpl.il_svy_out_matrix_row.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
742 for ($j = 0; $j < $this->
object->getColumnCount(); $j++)
744 $cat = $this->
object->getColumn($j);
745 if (($i == 0) && ($j == 0))
747 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
749 $tplrow->setCurrentBlock(
"bipolar_start");
751 $tplrow->setVariable(
"ROWSPAN", $this->object->getRowCount());
752 $tplrow->parseCurrentBlock();
755 if (($i == 0) && ($j == $this->object->getColumnCount()-1))
757 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
759 $tplrow->setCurrentBlock(
"bipolar_end");
761 $tplrow->setVariable(
"ROWSPAN", $this->object->getRowCount());
762 $tplrow->parseCurrentBlock();
765 switch ($this->object->getSubtype())
770 $tplrow->setCurrentBlock(
"neutral_radiobutton");
771 $tplrow->setVariable(
"QUESTION_ID", $this->object->getId());
772 $tplrow->setVariable(
"ROW", $i);
773 $tplrow->setVariable(
"VALUE", ($cat->scale) ? ($cat->scale - 1) : $j);
774 if (is_array($working_data))
776 foreach ($working_data as $data)
778 if (($data[
"value"] == $cat->scale-1) && ($data[
"rowvalue"] == $i))
780 $tplrow->setVariable(
"CHECKED_RADIOBUTTON",
" checked=\"checked\"");
784 $tplrow->parseCurrentBlock();
788 $tplrow->setCurrentBlock(
"radiobutton");
789 $tplrow->setVariable(
"QUESTION_ID", $this->object->getId());
790 $tplrow->setVariable(
"ROW", $i);
791 $tplrow->setVariable(
"VALUE", ($cat->scale) ? ($cat->scale - 1) : $j);
792 if (is_array($working_data))
794 foreach ($working_data as $data)
796 if (($data[
"value"] == $cat->scale-1) && ($data[
"rowvalue"] == $i))
798 $tplrow->setVariable(
"CHECKED_RADIOBUTTON",
" checked=\"checked\"");
802 $tplrow->parseCurrentBlock();
808 $tplrow->setCurrentBlock(
"neutral_checkbox");
809 $tplrow->setVariable(
"QUESTION_ID", $this->object->getId());
810 $tplrow->setVariable(
"ROW", $i);
811 $tplrow->setVariable(
"VALUE", ($cat->scale) ? ($cat->scale - 1) : $j);
812 if (is_array($working_data))
814 foreach ($working_data as $data)
816 if (($data[
"value"] == $cat->scale-1) && ($data[
"rowvalue"] == $i))
818 $tplrow->setVariable(
"CHECKED_CHECKBOX",
" checked=\"checked\"");
822 $tplrow->parseCurrentBlock();
826 $tplrow->setCurrentBlock(
"checkbox");
827 $tplrow->setVariable(
"QUESTION_ID", $this->object->getId());
828 $tplrow->setVariable(
"ROW", $i);
829 $tplrow->setVariable(
"VALUE", ($cat->scale) ? ($cat->scale - 1) : $j);
830 if (is_array($working_data))
832 foreach ($working_data as $data)
834 if (($data[
"value"] == $cat->scale-1) && ($data[
"rowvalue"] == $i))
836 $tplrow->setVariable(
"CHECKED_CHECKBOX",
" checked=\"checked\"");
840 $tplrow->parseCurrentBlock();
846 $tplrow->setCurrentBlock(
"neutral_answer");
848 if ($this->object->getNeutralColumnSeparator())
850 array_push($style,
"border-left: $neutralstyle!important");
852 if ($this->object->getColumnSeparators() == 1)
854 if ($j < $this->object->getColumnCount() - 1)
856 array_push($style,
"border-right: 1px solid $bordercolor!important");
862 $tplrow->setCurrentBlock(
"answer");
865 if ($this->object->getColumnSeparators() == 1)
867 if ($j < $this->object->getColumnCount() - 1)
869 array_push($style,
"border-right: 1px solid $bordercolor!important");
873 if ($this->object->getRowSeparators() == 1)
875 if ($i < $this->object->getRowCount() - 1)
877 array_push($style,
"border-bottom: 1px solid $bordercolor!important");
882 $tplrow->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
884 $tplrow->parseCurrentBlock();
889 $tplrow->setCurrentBlock(
"row_other");
890 $tplrow->setVariable(
"QUESTION_ID", $this->object->getId());
891 $tplrow->setVariable(
"ROW", $i);
892 if (is_array($working_data))
894 foreach ($working_data as $data)
896 if ($data[
"rowvalue"] == $i)
902 $tplrow->parseCurrentBlock();
905 $tplrow->setVariable(
"ROWCLASS", $rowclass[$i % 2]);
906 if ($this->object->getRowSeparators() == 1)
908 if ($i < $this->object->getRowCount() - 1)
910 $tplrow->setVariable(
"STYLE",
" style=\"border-bottom: 1px solid $bordercolor!important\"");
913 $template->setCurrentBlock(
"matrix_row");
914 $template->setVariable(
"ROW", $tplrow->get());
915 $template->parseCurrentBlock();
922 $template->setCurrentBlock(
"question_data_matrix");
923 if (strcmp($error_message,
"") != 0)
925 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
927 if ($show_questiontext)
931 $template->parseCurrentBlock();
932 return $template->get();
950 if (count($this->cumulated) == 0)
954 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
959 $nr_of_users =
sizeof($finished_ids);
961 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users, $finished_ids);
964 $cumulated_count = 0;
965 foreach ($this->cumulated as $key => $value)
967 if (is_numeric($key))
975 include_once
"./Services/UICore/classes/class.ilTemplate.php";
976 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
978 $template->setCurrentBlock(
"detail_row");
979 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
980 $questiontext = $this->
object->getQuestiontext();
981 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
982 $template->parseCurrentBlock();
983 $template->setCurrentBlock(
"detail_row");
984 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
985 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()).
986 " (".$cumulated_count.
" ".$this->lng->txt(
"rows").
")");
987 $template->parseCurrentBlock();
988 $template->setCurrentBlock(
"detail_row");
989 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
990 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"TOTAL"][
"USERS_ANSWERED"]);
991 $template->parseCurrentBlock();
992 $template->setCurrentBlock(
"detail_row");
993 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
994 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"TOTAL"][
"USERS_SKIPPED"]);
995 $template->parseCurrentBlock();
1006 $template->setCurrentBlock(
"detail_row");
1007 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"median"));
1008 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"TOTAL"][
"MEDIAN"]);
1009 $template->parseCurrentBlock();
1011 $template->setCurrentBlock(
"detail_row");
1012 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"categories"));
1014 foreach ($this->cumulated[
"TOTAL"][
"variables"] as $key => $value)
1016 $columns .=
"<li>" . $value[
"title"] .
": n=" . $value[
"selected"] .
1017 " (" . sprintf(
"%.2f", 100*$value[
"percentage"]) .
"%)</li>";
1020 $template->setVariable(
"TEXT_OPTION_VALUE",
$columns);
1021 $template->parseCurrentBlock();
1024 $template->setCurrentBlock(
"detail_row");
1025 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"chart"));
1026 $template->setVariable(
"TEXT_OPTION_VALUE", $this->
renderChart(
"svy_ch_".$this->object->getId().
"_total", $this->cumulated[
"TOTAL"][
"variables"]));
1027 $template->parseCurrentBlock();
1029 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
1031 $output .= $template->get();
1033 foreach ($this->cumulated as $key => $value)
1035 if (is_numeric($key))
1037 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
1039 $template->setCurrentBlock(
"detail_row");
1040 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
1041 $template->setVariable(
"TEXT_OPTION_VALUE", $value[
"USERS_ANSWERED"]);
1042 $template->parseCurrentBlock();
1043 $template->setCurrentBlock(
"detail_row");
1044 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
1045 $template->setVariable(
"TEXT_OPTION_VALUE", $value[
"USERS_SKIPPED"]);
1046 $template->parseCurrentBlock();
1057 $template->setCurrentBlock(
"detail_row");
1058 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"median"));
1059 $template->setVariable(
"TEXT_OPTION_VALUE", $value[
"MEDIAN"]);
1060 $template->parseCurrentBlock();
1062 $template->setCurrentBlock(
"detail_row");
1063 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"categories"));
1065 foreach ($value[
"variables"] as $cvalue)
1067 $columns .=
"<li>" . $cvalue[
"title"] .
": n=". $cvalue[
"selected"] .
1068 " (".sprintf(
"%.2f", 100*$cvalue[
"percentage"]) .
"%)</li>";
1070 $columns =
"<ol>".$columns.
"</ol>";
1071 $template->setVariable(
"TEXT_OPTION_VALUE",
$columns);
1072 $template->parseCurrentBlock();
1075 if (is_array($value[
"textanswers"]))
1077 $template->setCurrentBlock(
"detail_row");
1078 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"freetext_answers"));
1080 foreach ($value[
"textanswers"] as $tkey => $answers)
1082 $html .= $value[
"variables"][$tkey][
"title"] .
"\n";
1084 foreach ($answers as $answer)
1086 $html .=
"<li>" . preg_replace(
"/\n/",
"<br>\n", $answer) .
"</li>\n";
1090 $template->setVariable(
"TEXT_OPTION_VALUE", $html);
1091 $template->parseCurrentBlock();
1095 $template->setCurrentBlock(
"detail_row");
1096 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"chart"));
1097 $template->setVariable(
"TEXT_OPTION_VALUE", $this->
renderChart(
"svy_ch_".$this->object->getId().
"_".$key, $value[
"variables"]));
1098 $template->parseCurrentBlock();
1100 $template->setVariable(
"QUESTION_SUBTITLE", $counter.
".".($key+1).
" ".
1101 $this->object->prepareTextareaOutput($value[
"ROW"], TRUE));
1103 $output .= $template->get();