24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
25 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
56 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyMatrixQuestion.php";
58 $this->show_layout_row = FALSE;
61 $this->
object->loadFromDb($id);
70 $cmd = $this->ctrl->getCmd();
71 $next_class = $this->ctrl->getNextClass($this);
91 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
94 $this->
object->setTitle(
$_POST[
"title"]);
95 $this->
object->setAuthor(
$_POST[
"author"]);
96 $this->
object->setDescription(
$_POST[
"description"]);
97 $questiontext =
$_POST[
"question"];
98 $this->
object->setQuestiontext($questiontext);
99 $this->
object->setObligatory((
$_POST[
"obligatory"]) ? 1 : 0);
100 $this->
object->setSubtype(
$_POST[
"type"]);
101 $this->
object->setRowSeparators((
$_POST[
"row_separators"]) ? 1 : 0);
102 $this->
object->setColumnSeparators((
$_POST[
"column_separators"]) ? 1 : 0);
103 $this->
object->setNeutralColumnSeparator((
$_POST[
"neutral_column_separator"]) ? 1 : 0);
105 $this->
object->setBipolarAdjective(0,
$_POST[
"bipolar1"]);
106 $this->
object->setBipolarAdjective(1,
$_POST[
"bipolar2"]);
108 $this->
object->flushColumns();
109 foreach (
$_POST[
'columns'][
'answer'] as
$key => $value)
111 if (strlen($value)) $this->
object->addColumn($value);
114 $this->
object->setNeutralColumn(
$_POST[
"columns"][
"neutral"]);
116 $this->
object->flushRows();
119 $this->
object->addRow($value);
136 $save = ((strcmp($this->ctrl->getCmd(),
"save") == 0) ||
137 (strcmp($this->ctrl->getCmd(),
"wizardcolumns") == 0) ||
138 (strcmp($this->ctrl->getCmd(),
"savePhrasecolumns") == 0)
141 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
143 $form->setFormAction($this->ctrl->getFormAction($this));
144 $form->setTitle($this->lng->txt($this->getQuestionType()));
145 $form->setMultipart(FALSE);
146 $form->setTableWidth(
"100%");
147 $form->setId(
"multiplechoice");
151 $title->setValue($this->object->getTitle());
152 $title->setRequired(TRUE);
156 $author =
new ilTextInputGUI($this->lng->txt(
"author"),
"author");
157 $author->
setValue($this->object->getAuthor());
158 $author->setRequired(TRUE);
159 $form->addItem($author);
162 $description =
new ilTextInputGUI($this->lng->txt(
"description"),
"description");
163 $description->
setValue($this->object->getDescription());
164 $description->setRequired(FALSE);
165 $form->addItem($description);
169 $question->
setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
170 $question->setRequired(TRUE);
171 $question->setRows(10);
172 $question->setCols(80);
173 $question->setUseRte(TRUE);
174 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
176 $question->addPlugin(
"latex");
177 $question->addButton(
"latex");
178 $question->addButton(
"pastelatex");
179 $question->removePlugin(
"ibrowser");
180 $question->setRTESupport($this->object->getId(),
"spl",
"survey");
181 $form->addItem($question);
186 $subtype->setValue($this->object->getSubtype());
188 "0" =>
"matrix_subtype_sr",
189 "1" =>
"matrix_subtype_mr",
196 foreach ($subtypes as $idx => $st)
198 $subtype->addOption(
new ilRadioOption($this->lng->txt($st), $idx));
200 $form->addItem($subtype);
205 $shuffle->setChecked($this->object->getObligatory());
206 $shuffle->setRequired(FALSE);
207 $form->addItem($shuffle);
210 $header->setTitle($this->lng->txt(
"matrix_appearance"));
211 $form->addItem($header);
214 $column_separators =
new ilCheckboxInputGUI($this->lng->txt(
"matrix_column_separators"),
"column_separators");
216 $column_separators->setInfo($this->lng->txt(
"matrix_column_separators_description"));
217 $column_separators->setChecked($this->object->getColumnSeparators());
218 $column_separators->setRequired(
false);
219 $form->addItem($column_separators);
222 $row_separators =
new ilCheckboxInputGUI($this->lng->txt(
"matrix_row_separators"),
"row_separators");
224 $row_separators->setInfo($this->lng->txt(
"matrix_row_separators_description"));
225 $row_separators->setChecked($this->object->getRowSeparators());
226 $row_separators->setRequired(
false);
227 $form->addItem($row_separators);
230 $neutral_column_separator =
new ilCheckboxInputGUI($this->lng->txt(
"matrix_neutral_column_separator"),
"neutral_column_separator");
231 $neutral_column_separator->
setValue(1);
232 $neutral_column_separator->setInfo($this->lng->txt(
"matrix_neutral_column_separator_description"));
233 $neutral_column_separator->setChecked($this->object->getNeutralColumnSeparator());
234 $neutral_column_separator->setRequired(
false);
235 $form->addItem($neutral_column_separator);
238 $header->setTitle($this->lng->txt(
"matrix_columns"));
239 $form->addItem($header);
242 include_once
"./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
247 $columns->setShowNeutralCategory(
true);
248 $columns->setNeutralCategory($this->object->getNeutralColumn());
249 $columns->setNeutralCategoryTitle($this->lng->txt(
'matrix_neutral_answer'));
250 $columns->setCategoryText($this->lng->txt(
'matrix_standard_answers'));
252 if (!$this->object->getColumnCount())
254 $this->
object->addColumn(
"");
256 $columns->setValues($this->object->getColumns());
260 $header->setTitle($this->lng->txt(
"matrix_column_settings"));
261 $form->addItem($header);
264 $bipolar =
new ilCustomInputGUI($this->lng->txt(
"matrix_bipolar_adjectives"));
265 $bipolar->
setInfo($this->lng->txt(
"matrix_bipolar_adjectives_description"));
268 $bipolar1 =
new ilTextInputGUI($this->lng->txt(
"matrix_left_pole"),
"bipolar1");
269 $bipolar1->
setValue($this->object->getBipolarAdjective(0));
270 $bipolar1->setRequired(
false);
271 $bipolar->addSubItem($bipolar1);
274 $bipolar2 =
new ilTextInputGUI($this->lng->txt(
"matrix_right_pole"),
"bipolar2");
275 $bipolar2->
setValue($this->object->getBipolarAdjective(1));
276 $bipolar2->setRequired(
false);
277 $bipolar->addSubItem($bipolar2);
279 $form->addItem($bipolar);
282 $header->setTitle($this->lng->txt(
"matrix_rows"));
283 $form->addItem($header);
288 $rows->setAllowMove(
true);
289 if (count($this->object->getRows()) == 0)
291 $this->
object->addRow(
"");
293 $rows->setValues($this->object->getRows());
294 $form->addItem($rows);
296 $form->addCommandButton(
"save", $this->lng->txt(
"save"));
302 $form->setValuesByPost();
303 $errors = !$form->checkInput();
304 $form->setValuesByPost();
305 if (
$errors) $checkonly =
false;
308 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
318 $position = key(
$_POST[
'cmd'][
'addrows']);
319 $this->
object->addRowAtPosition(
"", $position+1);
329 $position = key(
$_POST[
'cmd'][
'removerows']);
330 $this->
object->removeRow($position);
340 $position = key(
$_POST[
'cmd'][
'uprows']);
341 $this->
object->moveRowUp($position);
351 $position = key(
$_POST[
'cmd'][
'downrows']);
352 $this->
object->moveRowDown($position);
362 $position = key(
$_POST[
'cmd'][
'addcolumns']);
363 $this->
object->getColumns()->addCategoryAtPosition(
"", $position+1);
373 $position = key(
$_POST[
'cmd'][
'removecolumns']);
374 $this->
object->getColumns()->removeCategory($position);
384 $position = key(
$_POST[
'cmd'][
'upcolumns']);
385 $this->
object->getColumns()->moveCategoryUp($position);
395 $position = key(
$_POST[
'cmd'][
'downcolumns']);
396 $this->
object->getColumns()->moveCategoryDown($position);
410 if (!$haserror) $this->
object->saveToDb();
411 $nothing_selected =
true;
412 $nothing_selected =
false;
413 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_savephrase.html",
"Modules/SurveyQuestionPool");
414 $rowclass = array(
"tblrow1",
"tblrow2");
416 foreach (
$_POST[
'columns'][
'answer'] as
$key => $value)
420 $this->tpl->setCurrentBlock(
"row");
422 $this->tpl->setVariable(
"COLOR_CLASS", $rowclass[$counter % 2]);
423 $this->tpl->parseCurrentBlock();
424 $this->tpl->setCurrentBlock(
"hidden");
425 $this->tpl->setVariable(
"HIDDEN_NAME",
"columns[answer][]");
427 $this->tpl->parseCurrentBlock();
434 $this->ctrl->redirect($this,
"editQuestion");
436 $this->tpl->setCurrentBlock(
"adm_content");
437 $this->tpl->setVariable(
"SAVE_PHRASE_INTRODUCTION", $this->lng->txt(
"save_phrase_introduction"));
438 $this->tpl->setVariable(
"TEXT_PHRASE_TITLE", $this->lng->txt(
"enter_phrase_title"));
439 $this->tpl->setVariable(
"TXT_TITLE", $this->lng->txt(
"category"));
440 $this->tpl->setVariable(
"VALUE_PHRASE_TITLE",
$_POST[
"phrase_title"]);
441 $this->tpl->setVariable(
"BTN_CANCEL",$this->lng->txt(
"cancel"));
442 $this->tpl->setVariable(
"BTN_CONFIRM",$this->lng->txt(
"confirm"));
443 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
444 $this->tpl->parseCurrentBlock();
456 $this->ctrl->redirect($this,
"editQuestion");
466 if (!
$_POST[
"phrase_title"])
473 if ($this->object->phraseExists(
$_POST[
"phrase_title"]))
480 $this->
object->savePhrase(
$_POST[
'columns'][
'answer'],
$_POST[
"phrase_title"]);
482 $this->ctrl->redirect($this,
"editQuestion");
495 if ($save_post_data) $this->
object->saveToDb();
496 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_addphrase.html",
"Modules/SurveyQuestionPool");
499 $this->tpl->setCurrentBlock(
"hidden");
500 $this->tpl->setVariable(
"HIDDEN_NAME",
"id");
501 $this->tpl->setVariable(
"HIDDEN_VALUE", $this->object->getId());
502 $this->tpl->parseCurrentBlock();
504 include_once
"./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
506 $colors = array(
"tblrow1",
"tblrow2");
508 foreach ($phrases as $phrase_id => $phrase_array)
510 $this->tpl->setCurrentBlock(
"phraserow");
511 $this->tpl->setVariable(
"COLOR_CLASS", $colors[$counter++ % 2]);
512 $this->tpl->setVariable(
"PHRASE_VALUE", $phrase_id);
513 $this->tpl->setVariable(
"PHRASE_NAME", $phrase_array[
"title"]);
515 $this->tpl->setVariable(
"PHRASE_CONTENT", join($categories,
","));
516 $this->tpl->parseCurrentBlock();
519 $this->tpl->setCurrentBlock(
"adm_content");
520 $this->tpl->setVariable(
"TEXT_CANCEL", $this->lng->txt(
"cancel"));
521 $this->tpl->setVariable(
"TEXT_PHRASE", $this->lng->txt(
"phrase"));
522 $this->tpl->setVariable(
"TEXT_CONTENT", $this->lng->txt(
"categories"));
523 $this->tpl->setVariable(
"TEXT_ADD_PHRASE", $this->lng->txt(
"add_phrase"));
524 $this->tpl->setVariable(
"TEXT_INTRODUCTION",$this->lng->txt(
"add_phrase_introduction"));
525 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
526 $this->tpl->parseCurrentBlock();
538 $this->ctrl->redirect($this,
'editQuestion');
548 if (strcmp(
$_POST[
"phrases"],
"") == 0)
555 if (strcmp($this->object->getPhrase(
$_POST[
"phrases"]),
"dp_standard_numbers") != 0)
557 $this->
object->addPhrase(
$_POST[
"phrases"]);
558 $this->
object->saveToDb();
566 $this->ctrl->redirect($this,
'editQuestion');
577 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_addphrase_standard_numbers.html",
"Modules/SurveyQuestionPool");
580 $this->tpl->setCurrentBlock(
"hidden");
581 $this->tpl->setVariable(
"HIDDEN_NAME",
"id");
582 $this->tpl->setVariable(
"HIDDEN_VALUE", $this->object->getId());
583 $this->tpl->parseCurrentBlock();
585 $this->tpl->setCurrentBlock(
"adm_content");
586 $this->tpl->setVariable(
"ADD_STANDARD_NUMBERS", $this->lng->txt(
"add_standard_numbers"));
587 $this->tpl->setVariable(
"TEXT_ADD_LIMITS", $this->lng->txt(
"add_limits_for_standard_numbers"));
588 $this->tpl->setVariable(
"TEXT_LOWER_LIMIT",$this->lng->txt(
"lower_limit"));
589 $this->tpl->setVariable(
"TEXT_UPPER_LIMIT",$this->lng->txt(
"upper_limit"));
590 $this->tpl->setVariable(
"VALUE_LOWER_LIMIT",
$_POST[
"lower_limit"]);
591 $this->tpl->setVariable(
"VALUE_UPPER_LIMIT",
$_POST[
"upper_limit"]);
592 $this->tpl->setVariable(
"BTN_ADD",$this->lng->txt(
"add_phrase"));
593 $this->tpl->setVariable(
"BTN_CANCEL",$this->lng->txt(
"cancel"));
594 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
595 $this->tpl->parseCurrentBlock();
606 $this->ctrl->redirect($this,
"editQuestion");
616 if ((strcmp(
$_POST[
"lower_limit"],
"") == 0) or (strcmp(
$_POST[
"upper_limit"],
"") == 0))
621 else if ((
int)
$_POST[
"upper_limit"] <= (
int)
$_POST[
"lower_limit"])
628 $this->
object->addStandardNumbers($_POST[
"lower_limit"], $_POST[
"upper_limit"]);
629 $this->
object->saveToDb();
631 $this->ctrl->redirect($this,
"editQuestion");
640 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"")
642 $layout = $this->
object->getLayout();
643 $neutralstyle =
"3px solid #808080";
644 $bordercolor =
"#808080";
645 $template =
new ilTemplate(
"tpl.il_svy_out_matrix.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
646 $template->setCurrentBlock(
"material_matrix");
648 $template->parseCurrentBlock();
650 if ($this->show_layout_row)
653 $template->setCurrentBlock(
"matrix_row");
654 $template->setVariable(
"ROW", $layout_row);
655 $template->parseCurrentBlock();
658 $tplheaders =
new ilTemplate(
"tpl.il_svy_out_matrix_columnheaders.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
659 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
661 $tplheaders->setCurrentBlock(
"bipolar_start");
663 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_bipolar_adjective1"],
"%"));
664 if (count($style) > 0)
666 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
668 $tplheaders->parseCurrentBlock();
671 for ($i = 0; $i < $this->
object->getColumnCount(); $i++)
674 if ($this->object->getColumnSeparators() == 1)
676 if (($i < $this->object->getColumnCount() - 1))
678 array_push($style,
"border-right: 1px solid $bordercolor!important");
681 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_columns"] / $this->object->getColumnCount(),
"%"));
682 $tplheaders->setCurrentBlock(
"column_header");
684 $tplheaders->setVariable(
"CLASS",
"center");
685 if (count($style) > 0)
687 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
689 $tplheaders->parseCurrentBlock();
691 if (strlen($this->object->getNeutralColumn()))
693 $tplheaders->setCurrentBlock(
"neutral_column_header");
695 $tplheaders->setVariable(
"CLASS",
"rsep");
697 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_neutral"],
"%"));
698 if ($this->object->getNeutralColumnSeparator())
700 array_push($style,
"border-left: $neutralstyle!important;");
702 if (count($style) > 0)
704 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
706 $tplheaders->parseCurrentBlock();
708 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
710 $tplheaders->setCurrentBlock(
"bipolar_end");
712 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_bipolar_adjective2"],
"%"));
713 if (count($style) > 0)
715 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
717 $tplheaders->parseCurrentBlock();
721 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_row"],
"%"));
722 if (count($style) > 0)
724 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
727 $template->setCurrentBlock(
"matrix_row");
728 $template->setVariable(
"ROW", $tplheaders->get());
729 $template->parseCurrentBlock();
731 $rowclass = array(
"tblrow1",
"tblrow2");
732 for ($i = 0; $i < $this->
object->getRowCount(); $i++)
734 $tplrow =
new ilTemplate(
"tpl.il_svy_out_matrix_row.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
735 for ($j = 0; $j < $this->
object->getColumnCount(); $j++)
737 if (($i == 0) && ($j == 0))
739 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
741 $tplrow->setCurrentBlock(
"bipolar_start");
743 $tplrow->setVariable(
"ROWSPAN", $this->object->getRowCount());
744 $tplrow->parseCurrentBlock();
747 if (($i == 0) && ($j == $this->object->getColumnCount()-1))
749 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
751 $tplrow->setCurrentBlock(
"bipolar_end");
753 $tplrow->setVariable(
"ROWSPAN", $this->object->getRowCount());
754 $tplrow->parseCurrentBlock();
757 switch ($this->object->getSubtype())
760 $tplrow->setCurrentBlock(
"radiobutton");
761 $tplrow->setVariable(
"QUESTION_ID", $this->object->getId());
762 $tplrow->setVariable(
"ROW", $i);
763 $tplrow->setVariable(
"VALUE", $j);
764 if (is_array($working_data))
766 foreach ($working_data as
$data)
768 if (($data[
"value"] == $j) && ($data[
"rowvalue"] == $i))
770 $tplrow->setVariable(
"CHECKED_RADIOBUTTON",
" checked=\"checked\"");
774 $tplrow->parseCurrentBlock();
777 $tplrow->setCurrentBlock(
"checkbox");
778 $tplrow->setVariable(
"QUESTION_ID", $this->object->getId());
779 $tplrow->setVariable(
"ROW", $i);
780 $tplrow->setVariable(
"VALUE", $j);
781 if (is_array($working_data))
783 foreach ($working_data as
$data)
785 if (($data[
"value"] == $j) && ($data[
"rowvalue"] == $i))
787 $tplrow->setVariable(
"CHECKED_CHECKBOX",
" checked=\"checked\"");
791 $tplrow->parseCurrentBlock();
794 $tplrow->setCurrentBlock(
"answer");
797 if ($this->object->getColumnSeparators() == 1)
799 if ($j < $this->object->getColumnCount() - 1)
801 array_push($style,
"border-right: 1px solid $bordercolor!important");
805 if ($this->object->getRowSeparators() == 1)
807 if ($i < $this->object->getRowCount() - 1)
809 array_push($style,
"border-bottom: 1px solid $bordercolor!important");
814 $tplrow->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
816 $tplrow->parseCurrentBlock();
820 if (strlen($this->object->getNeutralColumn()))
822 $j = $this->
object->getNeutralColumnIndex();
823 switch ($this->object->getSubtype())
826 $tplrow->setCurrentBlock(
"neutral_radiobutton");
827 $tplrow->setVariable(
"QUESTION_ID", $this->object->getId());
828 $tplrow->setVariable(
"ROW", $i);
829 $tplrow->setVariable(
"VALUE", $j);
830 if (is_array($working_data))
832 foreach ($working_data as
$data)
834 if (($data[
"value"] == $j) && ($data[
"rowvalue"] == $i))
836 $tplrow->setVariable(
"CHECKED_RADIOBUTTON",
" checked=\"checked\"");
840 $tplrow->parseCurrentBlock();
843 $tplrow->setCurrentBlock(
"neutral_checkbox");
844 $tplrow->setVariable(
"QUESTION_ID", $this->object->getId());
845 $tplrow->setVariable(
"ROW", $i);
846 $tplrow->setVariable(
"VALUE", $j);
847 if (is_array($working_data))
849 foreach ($working_data as
$data)
851 if (($data[
"value"] == $j) && ($data[
"rowvalue"] == $i))
853 $tplrow->setVariable(
"CHECKED_CHECKBOX",
" checked=\"checked\"");
857 $tplrow->parseCurrentBlock();
860 $tplrow->setCurrentBlock(
"neutral_answer");
862 if ($this->object->getNeutralColumnSeparator())
864 array_push($style,
"border-left: $neutralstyle!important");
866 if ($this->object->getColumnSeparators() == 1)
868 if ($j < $this->object->getColumnCount() - 1)
870 array_push($style,
"border-right: 1px solid $bordercolor!important");
874 if ($this->object->getRowSeparators() == 1)
876 if ($i < $this->object->getRowCount() - 1)
878 array_push($style,
"border-bottom: 1px solid $bordercolor!important");
883 $tplrow->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
885 $tplrow->parseCurrentBlock();
889 $tplrow->setVariable(
"ROWCLASS", $rowclass[$i % 2]);
890 if ($this->object->getRowSeparators() == 1)
892 if ($i < $this->object->getRowCount() - 1)
894 $tplrow->setVariable(
"STYLE",
" style=\"border-bottom: 1px solid $bordercolor!important\"");
897 $template->setCurrentBlock(
"matrix_row");
898 $template->setVariable(
"ROW", $tplrow->get());
899 $template->parseCurrentBlock();
906 $template->setCurrentBlock(
"question_data_matrix");
907 if (strcmp($error_message,
"") != 0)
909 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
911 if ($show_questiontext)
913 $questiontext = $this->
object->getQuestiontext();
914 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
916 if (! $this->object->getObligatory())
918 $template->setVariable(
"OBLIGATORY_TEXT", $this->lng->txt(
"survey_question_optional"));
920 $template->parseCurrentBlock();
921 return $template->get();
933 $layout = $this->
object->getLayout();
934 $neutralstyle =
"3px solid #808080";
935 $bordercolor =
"#808080";
936 $template =
new ilTemplate(
"tpl.il_svy_qpl_matrix_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
938 if ($this->show_layout_row)
941 $template->setCurrentBlock(
"matrix_row");
942 $template->setVariable(
"ROW", $layout_row);
943 $template->parseCurrentBlock();
946 $tplheaders =
new ilTemplate(
"tpl.il_svy_out_matrix_columnheaders.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
947 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
949 $tplheaders->setCurrentBlock(
"bipolar_start");
951 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_bipolar_adjective1"],
"%"));
952 if (count($style) > 0)
954 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
956 $tplheaders->parseCurrentBlock();
959 for ($i = 0; $i < $this->
object->getColumnCount(); $i++)
962 if ($this->object->getColumnSeparators() == 1)
964 if (($i < $this->object->getColumnCount() - 1))
966 array_push($style,
"border-right: 1px solid $bordercolor!important");
969 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_columns"] / $this->object->getColumnCount(),
"%"));
970 $tplheaders->setCurrentBlock(
"column_header");
972 $tplheaders->setVariable(
"CLASS",
"center");
973 if (count($style) > 0)
975 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
977 $tplheaders->parseCurrentBlock();
979 if (strlen($this->object->getNeutralColumn()))
981 $tplheaders->setCurrentBlock(
"neutral_column_header");
983 $tplheaders->setVariable(
"CLASS",
"rsep");
985 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_neutral"],
"%"));
986 if ($this->object->getNeutralColumnSeparator())
988 array_push($style,
"border-left: $neutralstyle!important;");
990 if (count($style) > 0)
992 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
994 $tplheaders->parseCurrentBlock();
996 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
998 $tplheaders->setCurrentBlock(
"bipolar_end");
1000 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_bipolar_adjective2"],
"%"));
1001 if (count($style) > 0)
1003 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
1005 $tplheaders->parseCurrentBlock();
1009 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_row"],
"%"));
1010 if (count($style) > 0)
1012 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
1015 $template->setCurrentBlock(
"matrix_row");
1016 $template->setVariable(
"ROW", $tplheaders->get());
1017 $template->parseCurrentBlock();
1019 $rowclass = array(
"tblrow1",
"tblrow2");
1021 for ($i = 0; $i < $this->
object->getRowCount(); $i++)
1023 $tplrow =
new ilTemplate(
"tpl.il_svy_qpl_matrix_printview_row.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
1024 for ($j = 0; $j < $this->
object->getColumnCount(); $j++)
1026 if (($i == 0) && ($j == 0))
1028 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
1030 $tplrow->setCurrentBlock(
"bipolar_start");
1032 $tplrow->setVariable(
"ROWSPAN", $this->object->getRowCount());
1033 $tplrow->parseCurrentBlock();
1036 if (($i == 0) && ($j == $this->object->getColumnCount()-1))
1038 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
1040 $tplrow->setCurrentBlock(
"bipolar_end");
1042 $tplrow->setVariable(
"ROWSPAN", $this->object->getRowCount());
1043 $tplrow->parseCurrentBlock();
1046 switch ($this->object->getSubtype())
1049 $tplrow->setCurrentBlock(
"radiobutton");
1051 $tplrow->setVariable(
"ALT_RADIO", $this->lng->txt(
"unchecked"));
1052 $tplrow->setVariable(
"TITLE_RADIO", $this->lng->txt(
"unchecked"));
1053 $tplrow->parseCurrentBlock();
1056 $tplrow->setCurrentBlock(
"checkbox");
1058 $tplrow->setVariable(
"ALT_CHECKBOX", $this->lng->txt(
"unchecked"));
1059 $tplrow->setVariable(
"TITLE_CHECKBOX", $this->lng->txt(
"unchecked"));
1060 $tplrow->parseCurrentBlock();
1063 $tplrow->setCurrentBlock(
"answer");
1066 if ($this->object->getColumnSeparators() == 1)
1068 if ($j < $this->object->getColumnCount() - 1)
1070 array_push($style,
"border-right: 1px solid $bordercolor!important");
1074 if ($this->object->getRowSeparators() == 1)
1076 if ($i < $this->object->getRowCount() - 1)
1078 array_push($style,
"border-bottom: 1px solid $bordercolor!important");
1083 $tplrow->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
1085 $tplrow->parseCurrentBlock();
1088 if (strlen($this->object->getNeutralColumn()))
1090 $j = $this->
object->getRowCount();
1091 switch ($this->object->getSubtype())
1094 $tplrow->setCurrentBlock(
"neutral_radiobutton");
1096 $tplrow->setVariable(
"ALT_RADIO", $this->lng->txt(
"unchecked"));
1097 $tplrow->setVariable(
"TITLE_RADIO", $this->lng->txt(
"unchecked"));
1098 $tplrow->parseCurrentBlock();
1101 $tplrow->setCurrentBlock(
"neutral_checkbox");
1103 $tplrow->setVariable(
"ALT_CHECKBOX", $this->lng->txt(
"unchecked"));
1104 $tplrow->setVariable(
"TITLE_CHECKBOX", $this->lng->txt(
"unchecked"));
1105 $tplrow->parseCurrentBlock();
1108 $tplrow->setCurrentBlock(
"neutral_answer");
1110 if ($this->object->getNeutralColumnSeparator())
1112 array_push($style,
"border-left: $neutralstyle!important");
1114 if ($this->object->getColumnSeparators() == 1)
1116 if ($j < $this->object->getColumnCount() - 1)
1118 array_push($style,
"border-right: 1px solid $bordercolor!important");
1122 if ($this->object->getRowSeparators() == 1)
1124 if ($i < $this->object->getRowCount() - 1)
1126 array_push($style,
"border-bottom: 1px solid $bordercolor!important");
1131 $tplrow->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
1133 $tplrow->parseCurrentBlock();
1137 $tplrow->setVariable(
"ROWCLASS", $rowclass[$i % 2]);
1138 if ($this->object->getRowSeparators() == 1)
1140 if ($i < $this->object->getRowCount() - 1)
1142 $tplrow->setVariable(
"STYLE",
" style=\"border-bottom: 1px solid $bordercolor!important\"");
1145 $template->setCurrentBlock(
"matrix_row");
1146 $template->setVariable(
"ROW", $tplrow->get());
1147 $template->parseCurrentBlock();
1150 if ($question_title)
1154 $template->setCurrentBlock();
1155 if ($show_questiontext)
1157 $questiontext = $this->
object->getQuestiontext();
1158 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
1160 if (! $this->object->getObligatory())
1162 $template->setVariable(
"OBLIGATORY_TEXT", $this->lng->txt(
"survey_question_optional"));
1164 $template->parseCurrentBlock();
1165 return $template->get();
1175 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_preview.html",
"Modules/SurveyQuestionPool");
1177 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
1187 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_layout.html",
"Modules/SurveyQuestionPool");
1188 $this->show_layout_row = TRUE;
1190 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
1191 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this,
"saveLayout"));
1192 $this->tpl->setVariable(
"SAVE", $this->lng->txt(
"save"));
1202 $this->
object->saveLayout(
$_POST[
"percent_row"],
$_POST[
'percent_columns'],
$_POST[
'percent_bipolar_adjective1'],
$_POST[
'percent_bipolar_adjective2'],
$_POST[
"percent_neutral"]);
1203 $percent_values = array(
1204 "percent_row" =>
$_POST[
"percent_row"],
1205 "percent_columns" =>
$_POST[
"percent_columns"],
1206 "percent_bipolar_adjective1" =>
$_POST[
'percent_bipolar_adjective1'],
1207 "percent_bipolar_adjective2" =>
$_POST[
'percent_bipolar_adjective2'],
1208 "percent_neutral" =>
$_POST[
"percent_neutral"]
1210 $this->
object->setLayout($percent_values);
1221 $percent_values = $this->
object->getLayout();
1222 $template =
new ilTemplate(
"tpl.il_svy_out_matrix_layout.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
1223 if (strlen($this->object->getBipolarAdjective(0)) && strlen($this->object->getBipolarAdjective(1)))
1225 $template->setCurrentBlock(
"bipolar_start");
1226 $template->setVariable(
"VALUE_PERCENT_BIPOLAR_ADJECTIVE1",
" value=\"" . $percent_values[
"percent_bipolar_adjective1"] .
"\"");
1227 $template->setVariable(
"STYLE",
" style=\"width:" . $percent_values[
"percent_bipolar_adjective1"] .
"%\"");
1228 $template->parseCurrentBlock();
1229 $template->setCurrentBlock(
"bipolar_end");
1230 $template->setVariable(
"VALUE_PERCENT_BIPOLAR_ADJECTIVE2",
" value=\"" . $percent_values[
"percent_bipolar_adjective2"] .
"\"");
1231 $template->setVariable(
"STYLE",
" style=\"width:" . $percent_values[
"percent_bipolar_adjective2"] .
"%\"");
1232 $template->parseCurrentBlock();
1234 if (strlen($this->object->getNeutralColumn()))
1236 $template->setCurrentBlock(
"bipolar_end");
1237 $template->setVariable(
"VALUE_PERCENT_NEUTRAL",
" value=\"" . $percent_values[
"percent_neutral"] .
"\"");
1238 $template->setVariable(
"STYLE_NEUTRAL",
" style=\"width:" . $percent_values[
"percent_neutral"] .
"%\"");
1239 $template->parseCurrentBlock();
1241 $template->setVariable(
"VALUE_PERCENT_ROW",
" value=\"" . $percent_values[
"percent_row"] .
"\"");
1242 $template->setVariable(
"STYLE_ROW",
" style=\"width:" . $percent_values[
"percent_row"] .
"%\"");
1243 $counter = $this->
object->getColumnCount();
1244 $template->setVariable(
"COLSPAN_COLUMNS", $counter);
1245 $template->setVariable(
"VALUE_PERCENT_COLUMNS",
" value=\"" . $percent_values[
"percent_columns"] .
"\"");
1246 $template->setVariable(
"STYLE_COLUMNS",
" style=\"width:" . $percent_values[
"percent_columns"] .
"%\"");
1247 return $template->get();
1260 if (count($this->cumulated) == 0)
1262 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
1264 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
1268 include_once
"./classes/class.ilTemplate.php";
1269 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
1271 $template->setCurrentBlock(
"detail_row");
1272 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
1273 $questiontext = $this->
object->getQuestiontext();
1274 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
1275 $template->parseCurrentBlock();
1276 $template->setCurrentBlock(
"detail_row");
1277 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
1278 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
1279 $template->parseCurrentBlock();
1280 $template->setCurrentBlock(
"detail_row");
1281 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
1282 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"TOTAL"][
"USERS_ANSWERED"]);
1283 $template->parseCurrentBlock();
1284 $template->setCurrentBlock(
"detail_row");
1285 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
1286 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"TOTAL"][
"USERS_SKIPPED"]);
1287 $template->parseCurrentBlock();
1289 $template->setCurrentBlock(
"detail_row");
1290 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"mode"));
1291 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"TOTAL"][
"MODE"]);
1292 $template->parseCurrentBlock();
1293 $template->setCurrentBlock(
"detail_row");
1294 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"mode_nr_of_selections"));
1295 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"TOTAL"][
"MODE_NR_OF_SELECTIONS"]);
1296 $template->parseCurrentBlock();
1297 $template->setCurrentBlock(
"detail_row");
1298 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"median"));
1299 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"TOTAL"][
"MEDIAN"]);
1300 $template->parseCurrentBlock();
1302 $template->setCurrentBlock(
"detail_row");
1303 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"categories"));
1305 foreach ($this->cumulated[
"TOTAL"][
"variables"] as
$key => $value)
1307 $columns .=
"<li>" . $this->lng->txt(
"title") .
":" .
"<span class=\"bold\">" . $value[
"title"] .
"</span><br />" .
1308 $this->lng->txt(
"category_nr_selected") .
": " .
"<span class=\"bold\">" . $value[
"selected"] .
"</span><br />" .
1309 $this->lng->txt(
"percentage_of_selections") .
": " .
"<span class=\"bold\">" . sprintf(
"%.2f", 100*$value[
"percentage"]) .
"</span></li>";
1312 $template->setVariable(
"TEXT_OPTION_VALUE",
$columns);
1313 $template->parseCurrentBlock();
1315 foreach ($this->cumulated as
$key => $value)
1317 if (is_numeric(
$key))
1319 $template->setCurrentBlock(
"detail_row");
1320 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"row"));
1321 $questiontext = $value[
"ROW"];
1322 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
1323 $template->parseCurrentBlock();
1324 $template->setCurrentBlock(
"detail_row");
1325 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
1326 $template->setVariable(
"TEXT_OPTION_VALUE", $value[
"USERS_ANSWERED"]);
1327 $template->parseCurrentBlock();
1328 $template->setCurrentBlock(
"detail_row");
1329 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
1330 $template->setVariable(
"TEXT_OPTION_VALUE", $value[
"USERS_SKIPPED"]);
1331 $template->parseCurrentBlock();
1333 $template->setCurrentBlock(
"detail_row");
1334 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"mode"));
1335 $template->setVariable(
"TEXT_OPTION_VALUE", $value[
"MODE"]);
1336 $template->parseCurrentBlock();
1337 $template->setCurrentBlock(
"detail_row");
1338 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"mode_nr_of_selections"));
1339 $template->setVariable(
"TEXT_OPTION_VALUE", $value[
"MODE_NR_OF_SELECTIONS"]);
1340 $template->parseCurrentBlock();
1341 $template->setCurrentBlock(
"detail_row");
1342 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"median"));
1343 $template->setVariable(
"TEXT_OPTION_VALUE", $value[
"MEDIAN"]);
1344 $template->parseCurrentBlock();
1346 $template->setCurrentBlock(
"detail_row");
1347 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"categories"));
1349 foreach ($value[
"variables"] as
$key => $value)
1351 $columns .=
"<li>" . $this->lng->txt(
"title") .
":" .
"<span class=\"bold\">" . $value[
"title"] .
"</span><br />" .
1352 $this->lng->txt(
"category_nr_selected") .
": " .
"<span class=\"bold\">" . $value[
"selected"] .
"</span><br />" .
1353 $this->lng->txt(
"percentage_of_selections") .
": " .
"<span class=\"bold\">" . sprintf(
"%.2f", 100*$value[
"percentage"]) .
"</span></li>";
1356 $template->setVariable(
"TEXT_OPTION_VALUE",
$columns);
1357 $template->parseCurrentBlock();
1362 foreach ($this->cumulated as
$key => $value)
1364 if (is_numeric(
$key))
1366 $template->setCurrentBlock(
"chartimage");
1369 include_once
"./Services/Administration/classes/class.ilSetting.php";
1370 $surveySetting =
new ilSetting(
"survey");
1371 if ($surveySetting->get(
"googlechart") == 1)
1373 $chartcolors = array(
"2A4BD7",
"9DAFFF",
"1D6914",
"81C57A",
"814A19",
"E9DEBB",
"8126C0",
"AD2323",
"29D0D0",
"FFEE33",
"FF9233",
"FFCDF3",
"A0A0A0",
"575757",
"000000");
1374 $selections = array();
1377 foreach ($value[
"variables"] as $val)
1379 if ($val[
"selected"] > $maxselection) $maxselection = $val[
"selected"];
1380 array_push($selections, $val[
"selected"]);
1381 array_push($values, str_replace(
" ",
"+", $val[
"title"]));
1384 $selectionlabels =
"";
1385 if ($maxselection % 2 == 0)
1387 $selectionlabels =
"0|" . ($maxselection / 2) .
"|$maxselection";
1391 $selectionlabels =
"0|$maxselection";
1393 $charturl =
"http://chart.apis.google.com/chart?chco=" . implode(
"|", array_slice($chartcolors, 0, count($values))).
"&cht=bvs&chs=" . $chartwidth .
"x250&chd=t:" . implode(
",", $selections) .
"&chds=0,$maxselection&chxt=y,y&chxl=0:|$selectionlabels|1:||".str_replace(
" ",
"+", $this->lng->txt(
"mode_nr_of_selections")).
"|" .
"&chxr=1,0,$maxselection&chtt=" . str_replace(
" ",
"+", $value[
"ROW"]) .
"&chbh=20," . (round($chartwidth/count($values))-25) .
"&chdl=" . implode(
"|", $values) .
"&chdlp=b";
1397 $this->ctrl->setParameterByClass(
"ilsurveyevaluationgui",
"type",
$key);
1398 $this->ctrl->setParameterByClass(
"ilsurveyevaluationgui",
"survey", $survey_id);
1399 $this->ctrl->setParameterByClass(
"ilsurveyevaluationgui",
"question", $this->object->getId());
1400 $charturl = $this->ctrl->getLinkTargetByClass(
"ilsurveyevaluationgui",
"outChart");
1402 $template->setVariable(
"CHART", $charturl);
1403 $template->setVariable(
"ALT_CHART", $this->lng->txt(
"chart"));
1404 $template->parseCurrentBlock();
1407 $template->setCurrentBlock(
"chart");
1408 $template->setVariable(
"TEXT_CHART", $this->lng->txt(
"chart"));
1409 $template->parseCurrentBlock();
1411 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
1412 $output = $template->get();
1418 global $rbacsystem,$ilTabs;
1419 $this->ctrl->setParameterByClass(
"$guiclass",
"sel_question_types", $this->
getQuestionType());
1420 $this->ctrl->setParameterByClass(
"$guiclass",
"q_id",
$_GET[
"q_id"]);
1422 if ((
$_GET[
"calling_survey"] > 0) || (
$_GET[
"new_for_survey"] > 0))
1427 if (strlen(
$_GET[
"new_for_survey"]))
1429 $addurl =
"&new_id=" .
$_GET[
"q_id"];
1431 $ilTabs->setBackTarget($this->lng->txt(
"menubacktosurvey"),
"ilias.php?baseClass=ilObjSurveyGUI&ref_id=$ref_id&cmd=questions" . $addurl);
1435 $this->ctrl->setParameterByClass(
"ilObjSurveyQuestionPoolGUI",
"q_id_table_nav",
$_SESSION[
'q_id_table_nav']);
1436 $ilTabs->setBackTarget($this->lng->txt(
"spl"), $this->ctrl->getLinkTargetByClass(
"ilObjSurveyQuestionPoolGUI",
"questions"));
1440 $ilTabs->addTarget(
"preview",
1441 $this->ctrl->getLinkTarget($this,
"preview"),
1446 $ilTabs->addTarget(
"layout",
1447 $this->ctrl->getLinkTarget($this,
"layout"),
1448 array(
"layout",
"saveLayout"),
1452 if ($rbacsystem->checkAccess(
'edit',
$_GET[
"ref_id"]))
1454 $ilTabs->addTarget(
"edit_properties",
1455 $this->ctrl->getLinkTarget($this,
"editQuestion"),
1456 array(
"editQuestion",
"cancelExplorer",
"linkChilds",
"addGIT",
"addST",
1457 "addPG",
"editQuestion",
"addMaterial",
"removeMaterial",
1458 "save",
"cancel",
"savePhrasecolumns",
"confirmSavePhrase",
1459 "downcolumns",
"upcolumns",
"addcolumns",
"removecolumns",
1460 "downrows",
"uprows",
"addrows",
"removerows",
"wizardcolumns",
1461 "addSelectedPhrase",
"insertStandardNumbers"),
1466 if ($this->object->getId() > 0)
1468 $ilTabs->addTarget(
"material",
1469 $this->ctrl->getLinkTarget($this,
"material"),
1470 array(
"material",
"cancelExplorer",
"linkChilds",
"addGIT",
"addST",
1471 "addPG",
"addMaterial",
"removeMaterial"),
1475 if ($this->object->getId() > 0)
1477 $title = $this->lng->txt(
"edit") .
" "" . $this->
object->getTitle() .
""";
1484 $this->tpl->setVariable(
"HEADER",
$title);