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->label =
$_POST[
'label'];
96 $this->
object->setAuthor(
$_POST[
"author"]);
97 $this->
object->setDescription(
$_POST[
"description"]);
98 $questiontext =
$_POST[
"question"];
99 $this->
object->setQuestiontext($questiontext);
100 $this->
object->setObligatory((
$_POST[
"obligatory"]) ? 1 : 0);
101 $this->
object->setSubtype(
$_POST[
"type"]);
102 $this->
object->setRowSeparators((
$_POST[
"row_separators"]) ? 1 : 0);
103 $this->
object->setColumnSeparators((
$_POST[
"column_separators"]) ? 1 : 0);
104 $this->
object->setNeutralColumnSeparator((
$_POST[
"neutral_column_separator"]) ? 1 : 0);
106 $this->
object->setBipolarAdjective(0,
$_POST[
"bipolar1"]);
107 $this->
object->setBipolarAdjective(1,
$_POST[
"bipolar2"]);
109 $this->
object->flushColumns();
110 foreach (
$_POST[
'columns'][
'answer'] as $key => $value)
112 if (strlen($value)) $this->
object->getColumns()->addCategory($value,
$_POST[
'columns'][
'other'][$key], 0, null,
$_POST[
'columns'][
'scale'][$key]);
114 if (strlen(
$_POST[
"columns"][
"neutral"]))
116 $this->
object->getColumns()->addCategory(
$_POST[
'columns'][
'neutral'], 0, 1, null,
$_POST[
'columns_neutral_scale']);
119 $this->
object->flushRows();
120 foreach (
$_POST[
'rows'][
'answer'] as $key => $value)
122 if (strlen($value)) $this->
object->getRows()->addCategory($value,
$_POST[
'rows'][
'other'][$key], 0,
$_POST[
'rows'][
'label'][$key]);
139 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
141 $form->setFormAction($this->ctrl->getFormAction($this));
142 $form->setTitle($this->lng->txt($this->getQuestionType()));
143 $form->setMultipart(FALSE);
144 $form->setTableWidth(
"100%");
145 $form->setId(
"multiplechoice");
149 $title->setValue($this->object->getTitle());
150 $title->setRequired(TRUE);
155 $label->
setValue($this->object->label);
156 $label->setInfo($this->lng->txt(
"label_info"));
157 $label->setRequired(
false);
158 $form->addItem($label);
161 $author =
new ilTextInputGUI($this->lng->txt(
"author"),
"author");
162 $author->
setValue($this->object->getAuthor());
163 $author->setRequired(TRUE);
164 $form->addItem($author);
167 $description =
new ilTextInputGUI($this->lng->txt(
"description"),
"description");
168 $description->
setValue($this->object->getDescription());
169 $description->setRequired(FALSE);
170 $form->addItem($description);
174 $question->
setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
175 $question->setRequired(TRUE);
176 $question->setRows(10);
177 $question->setCols(80);
178 $question->setUseRte(TRUE);
179 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
181 $question->addPlugin(
"latex");
182 $question->addButton(
"latex");
183 $question->addButton(
"pastelatex");
184 $question->removePlugin(
"ibrowser");
185 $question->setRTESupport($this->object->getId(),
"spl",
"survey", null,
false,
"3.4.7");
186 $form->addItem($question);
191 $subtype->setValue($this->object->getSubtype());
193 "0" =>
"matrix_subtype_sr",
194 "1" =>
"matrix_subtype_mr",
201 foreach ($subtypes as $idx => $st)
203 $subtype->addOption(
new ilRadioOption($this->lng->txt($st), $idx));
205 $form->addItem($subtype);
210 $shuffle->setChecked($this->object->getObligatory());
211 $shuffle->setRequired(FALSE);
212 $form->addItem($shuffle);
215 $header->setTitle($this->lng->txt(
"matrix_appearance"));
216 $form->addItem($header);
219 $column_separators =
new ilCheckboxInputGUI($this->lng->txt(
"matrix_column_separators"),
"column_separators");
221 $column_separators->setInfo($this->lng->txt(
"matrix_column_separators_description"));
222 $column_separators->setChecked($this->object->getColumnSeparators());
223 $column_separators->setRequired(
false);
224 $form->addItem($column_separators);
227 $row_separators =
new ilCheckboxInputGUI($this->lng->txt(
"matrix_row_separators"),
"row_separators");
229 $row_separators->setInfo($this->lng->txt(
"matrix_row_separators_description"));
230 $row_separators->setChecked($this->object->getRowSeparators());
231 $row_separators->setRequired(
false);
232 $form->addItem($row_separators);
235 $neutral_column_separator =
new ilCheckboxInputGUI($this->lng->txt(
"matrix_neutral_column_separator"),
"neutral_column_separator");
236 $neutral_column_separator->
setValue(1);
237 $neutral_column_separator->setInfo($this->lng->txt(
"matrix_neutral_column_separator_description"));
238 $neutral_column_separator->setChecked($this->object->getNeutralColumnSeparator());
239 $neutral_column_separator->setRequired(
false);
240 $form->addItem($neutral_column_separator);
243 $header->setTitle($this->lng->txt(
"matrix_columns"));
244 $form->addItem($header);
247 include_once
"./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
252 $columns->setShowNeutralCategory(
true);
254 $columns->setNeutralCategoryTitle($this->lng->txt(
'matrix_neutral_answer'));
255 $columns->setCategoryText($this->lng->txt(
'matrix_standard_answers'));
257 if (!$this->object->getColumnCount())
259 $this->
object->columns->addCategory(
"");
261 $columns->setValues($this->object->getColumns());
265 $header->setTitle($this->lng->txt(
"matrix_column_settings"));
266 $form->addItem($header);
269 $bipolar =
new ilCustomInputGUI($this->lng->txt(
"matrix_bipolar_adjectives"));
270 $bipolar->
setInfo($this->lng->txt(
"matrix_bipolar_adjectives_description"));
273 $bipolar1 =
new ilTextInputGUI($this->lng->txt(
"matrix_left_pole"),
"bipolar1");
274 $bipolar1->
setValue($this->object->getBipolarAdjective(0));
275 $bipolar1->setRequired(
false);
276 $bipolar->addSubItem($bipolar1);
279 $bipolar2 =
new ilTextInputGUI($this->lng->txt(
"matrix_right_pole"),
"bipolar2");
280 $bipolar2->
setValue($this->object->getBipolarAdjective(1));
281 $bipolar2->setRequired(
false);
282 $bipolar->addSubItem($bipolar2);
284 $form->addItem($bipolar);
287 $header->setTitle($this->lng->txt(
"matrix_rows"));
288 $form->addItem($header);
291 include_once
"./Modules/SurveyQuestionPool/classes/class.ilMatrixRowWizardInputGUI.php";
294 $rows->setAllowMove(
true);
295 $rows->setLabelText($this->lng->txt(
'label'));
296 $rows->setUseOtherAnswer(
true);
297 if ($this->object->getRowCount() == 0)
299 $this->
object->getRows()->addCategory(
"");
301 $rows->setValues($this->object->getRows());
302 $form->addItem($rows);
308 if ($this->
isSaveCommand(array(
"wizardcolumns",
"savePhrasecolumns")))
310 $form->setValuesByPost();
311 $errors = !$form->checkInput();
312 $form->setValuesByPost();
313 if (
$errors) $checkonly =
false;
316 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
326 $position = key(
$_POST[
'cmd'][
'addrows']);
327 $this->
object->addRowAtPosition(
"",
false, $position+1);
337 $position = key(
$_POST[
'cmd'][
'removerows']);
338 $this->
object->removeRow($position);
348 $position = key(
$_POST[
'cmd'][
'uprows']);
349 $this->
object->moveRowUp($position);
359 $position = key(
$_POST[
'cmd'][
'downrows']);
360 $this->
object->moveRowDown($position);
370 $position = key(
$_POST[
'cmd'][
'addcolumns']);
371 $this->
object->getColumns()->addCategoryAtPosition(
"", $position+1);
381 $position = key(
$_POST[
'cmd'][
'removecolumns']);
382 $this->
object->getColumns()->removeCategory($position);
392 $position = key(
$_POST[
'cmd'][
'upcolumns']);
393 $this->
object->getColumns()->moveCategoryUp($position);
403 $position = key(
$_POST[
'cmd'][
'downcolumns']);
404 $this->
object->getColumns()->moveCategoryDown($position);
418 if (!$haserror) $this->
object->saveToDb();
420 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_savephrase.html",
"Modules/SurveyQuestionPool");
421 $this->tpl->setCurrentBlock(
"adm_content");
422 $this->tpl->setVariable(
"SAVE_PHRASE_INTRODUCTION", $this->lng->txt(
"save_phrase_introduction"));
423 $this->tpl->setVariable(
"TEXT_PHRASE_TITLE", $this->lng->txt(
"enter_phrase_title"));
424 $this->tpl->setVariable(
"VALUE_PHRASE_TITLE",
$_POST[
"phrase_title"]);
425 $this->tpl->setVariable(
"BTN_CANCEL",$this->lng->txt(
"cancel"));
426 $this->tpl->setVariable(
"BTN_CONFIRM",$this->lng->txt(
"confirm"));
427 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
429 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveySavePhraseTableGUI.php";
435 foreach (
$_POST[
'columns'][
'answer'] as $key => $value)
437 array_push(
$data, array(
'answer' => $value,
'other' => ((
$_POST[
'columns'][
'other'][$key]) ?
true :
false),
'scale' =>
$_POST[
'columns'][
'scale'][$key],
'neutral' =>
false));
439 if (strlen(
$_POST[
'columns'][
'neutral']))
441 array_push(
$data, array(
'answer' =>
$_POST[
'columns'][
'neutral'],
'other' =>
false,
'scale' =>
$_POST[
'columns_neutral_scale'],
'neutral' =>
true));
448 $table_gui->setData(
$data);
450 $this->tpl->setVariable(
'TABLE', $table_gui->getHTML());
451 $this->tpl->parseCurrentBlock();
463 $this->ctrl->redirect($this,
"editQuestion");
473 if (!
$_POST[
"phrase_title"])
480 if ($this->object->phraseExists(
$_POST[
"phrase_title"]))
487 $this->
object->savePhrase(
$_POST[
"phrase_title"]);
489 $this->ctrl->redirect($this,
"editQuestion");
502 if ($save_post_data) $this->
object->saveToDb();
503 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_addphrase.html",
"Modules/SurveyQuestionPool");
506 $this->tpl->setCurrentBlock(
"hidden");
507 $this->tpl->setVariable(
"HIDDEN_NAME",
"id");
508 $this->tpl->setVariable(
"HIDDEN_VALUE", $this->object->getId());
509 $this->tpl->parseCurrentBlock();
511 include_once
"./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
513 $colors = array(
"tblrow1",
"tblrow2");
515 foreach ($phrases as $phrase_id => $phrase_array)
517 $this->tpl->setCurrentBlock(
"phraserow");
518 $this->tpl->setVariable(
"COLOR_CLASS", $colors[$counter++ % 2]);
519 $this->tpl->setVariable(
"PHRASE_VALUE", $phrase_id);
520 $this->tpl->setVariable(
"PHRASE_NAME", $phrase_array[
"title"]);
522 $this->tpl->setVariable(
"PHRASE_CONTENT", join($categories,
","));
523 $this->tpl->parseCurrentBlock();
526 $this->tpl->setCurrentBlock(
"adm_content");
527 $this->tpl->setVariable(
"TEXT_CANCEL", $this->lng->txt(
"cancel"));
528 $this->tpl->setVariable(
"TEXT_PHRASE", $this->lng->txt(
"phrase"));
529 $this->tpl->setVariable(
"TEXT_CONTENT", $this->lng->txt(
"categories"));
530 $this->tpl->setVariable(
"TEXT_ADD_PHRASE", $this->lng->txt(
"add_phrase"));
531 $this->tpl->setVariable(
"TEXT_INTRODUCTION",$this->lng->txt(
"add_phrase_introduction"));
532 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
533 $this->tpl->parseCurrentBlock();
545 $this->ctrl->redirect($this,
'editQuestion');
555 if (strcmp(
$_POST[
"phrases"],
"") == 0)
562 if (strcmp($this->object->getPhrase(
$_POST[
"phrases"]),
"dp_standard_numbers") != 0)
564 $this->
object->addPhrase(
$_POST[
"phrases"]);
565 $this->
object->saveToDb();
573 $this->ctrl->redirect($this,
'editQuestion');
584 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_addphrase_standard_numbers.html",
"Modules/SurveyQuestionPool");
587 $this->tpl->setCurrentBlock(
"hidden");
588 $this->tpl->setVariable(
"HIDDEN_NAME",
"id");
589 $this->tpl->setVariable(
"HIDDEN_VALUE", $this->object->getId());
590 $this->tpl->parseCurrentBlock();
592 $this->tpl->setCurrentBlock(
"adm_content");
593 $this->tpl->setVariable(
"ADD_STANDARD_NUMBERS", $this->lng->txt(
"add_standard_numbers"));
594 $this->tpl->setVariable(
"TEXT_ADD_LIMITS", $this->lng->txt(
"add_limits_for_standard_numbers"));
595 $this->tpl->setVariable(
"TEXT_LOWER_LIMIT",$this->lng->txt(
"lower_limit"));
596 $this->tpl->setVariable(
"TEXT_UPPER_LIMIT",$this->lng->txt(
"upper_limit"));
597 $this->tpl->setVariable(
"VALUE_LOWER_LIMIT",
$_POST[
"lower_limit"]);
598 $this->tpl->setVariable(
"VALUE_UPPER_LIMIT",
$_POST[
"upper_limit"]);
599 $this->tpl->setVariable(
"BTN_ADD",$this->lng->txt(
"add_phrase"));
600 $this->tpl->setVariable(
"BTN_CANCEL",$this->lng->txt(
"cancel"));
601 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
602 $this->tpl->parseCurrentBlock();
613 $this->ctrl->redirect($this,
"editQuestion");
623 if ((strcmp(
$_POST[
"lower_limit"],
"") == 0) or (strcmp(
$_POST[
"upper_limit"],
"") == 0))
628 else if ((
int)
$_POST[
"upper_limit"] <= (
int)
$_POST[
"lower_limit"])
635 $this->
object->addStandardNumbers($_POST[
"lower_limit"], $_POST[
"upper_limit"]);
636 $this->
object->saveToDb();
638 $this->ctrl->redirect($this,
"editQuestion");
647 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"")
649 $layout = $this->
object->getLayout();
650 $neutralstyle =
"3px solid #808080";
651 $bordercolor =
"#808080";
652 $template =
new ilTemplate(
"tpl.il_svy_out_matrix.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
653 $template->setCurrentBlock(
"material_matrix");
655 $template->parseCurrentBlock();
657 if ($this->show_layout_row)
660 $template->setCurrentBlock(
"matrix_row");
661 $template->setVariable(
"ROW", $layout_row);
662 $template->parseCurrentBlock();
665 $tplheaders =
new ilTemplate(
"tpl.il_svy_out_matrix_columnheaders.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
666 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
668 $tplheaders->setCurrentBlock(
"bipolar_start");
670 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_bipolar_adjective1"],
"%"));
671 if (count($style) > 0)
673 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
675 $tplheaders->parseCurrentBlock();
678 for ($i = 0; $i < $this->
object->getColumnCount(); $i++)
681 $col = $this->
object->getColumn($i);
684 $tplheaders->setCurrentBlock(
"neutral_column_header");
686 $tplheaders->setVariable(
"CLASS",
"rsep");
688 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_neutral"],
"%"));
689 if ($this->object->getNeutralColumnSeparator())
691 array_push($style,
"border-left: $neutralstyle!important;");
693 if (count($style) > 0)
695 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
697 $tplheaders->parseCurrentBlock();
701 if ($this->object->getColumnSeparators() == 1)
703 if (($i < $this->object->getColumnCount() - 1))
705 array_push($style,
"border-right: 1px solid $bordercolor!important");
708 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_columns"] / $this->object->getColumnCount(),
"%"));
709 $tplheaders->setCurrentBlock(
"column_header");
711 $tplheaders->setVariable(
"CLASS",
"center");
712 if (count($style) > 0)
714 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
716 $tplheaders->parseCurrentBlock();
719 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
721 $tplheaders->setCurrentBlock(
"bipolar_end");
723 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_bipolar_adjective2"],
"%"));
724 if (count($style) > 0)
726 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
728 $tplheaders->parseCurrentBlock();
732 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_row"],
"%"));
733 if (count($style) > 0)
735 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
738 $template->setCurrentBlock(
"matrix_row");
739 $template->setVariable(
"ROW", $tplheaders->get());
740 $template->parseCurrentBlock();
742 $rowclass = array(
"tblrow1",
"tblrow2");
743 for ($i = 0; $i < $this->
object->getRowCount(); $i++)
745 $rowobj = $this->
object->getRow($i);
746 $tplrow =
new ilTemplate(
"tpl.il_svy_out_matrix_row.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
747 for ($j = 0; $j < $this->
object->getColumnCount(); $j++)
749 $cat = $this->
object->getColumn($j);
750 if (($i == 0) && ($j == 0))
752 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
754 $tplrow->setCurrentBlock(
"bipolar_start");
756 $tplrow->setVariable(
"ROWSPAN", $this->object->getRowCount());
757 $tplrow->parseCurrentBlock();
760 if (($i == 0) && ($j == $this->object->getColumnCount()-1))
762 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
764 $tplrow->setCurrentBlock(
"bipolar_end");
766 $tplrow->setVariable(
"ROWSPAN", $this->object->getRowCount());
767 $tplrow->parseCurrentBlock();
770 switch ($this->object->getSubtype())
775 $tplrow->setCurrentBlock(
"neutral_radiobutton");
776 $tplrow->setVariable(
"QUESTION_ID", $this->object->getId());
777 $tplrow->setVariable(
"ROW", $i);
778 $tplrow->setVariable(
"VALUE", ($cat->scale) ? ($cat->scale - 1) : $j);
779 if (is_array($working_data))
781 foreach ($working_data as
$data)
783 if (($data[
"value"] == $cat->scale-1) && ($data[
"rowvalue"] == $i))
785 $tplrow->setVariable(
"CHECKED_RADIOBUTTON",
" checked=\"checked\"");
789 $tplrow->parseCurrentBlock();
793 $tplrow->setCurrentBlock(
"radiobutton");
794 $tplrow->setVariable(
"QUESTION_ID", $this->object->getId());
795 $tplrow->setVariable(
"ROW", $i);
796 $tplrow->setVariable(
"VALUE", ($cat->scale) ? ($cat->scale - 1) : $j);
797 if (is_array($working_data))
799 foreach ($working_data as
$data)
801 if (($data[
"value"] == $cat->scale-1) && ($data[
"rowvalue"] == $i))
803 $tplrow->setVariable(
"CHECKED_RADIOBUTTON",
" checked=\"checked\"");
807 $tplrow->parseCurrentBlock();
813 $tplrow->setCurrentBlock(
"neutral_checkbox");
814 $tplrow->setVariable(
"QUESTION_ID", $this->object->getId());
815 $tplrow->setVariable(
"ROW", $i);
816 $tplrow->setVariable(
"VALUE", ($cat->scale) ? ($cat->scale - 1) : $j);
817 if (is_array($working_data))
819 foreach ($working_data as
$data)
821 if (($data[
"value"] == $cat->scale-1) && ($data[
"rowvalue"] == $i))
823 $tplrow->setVariable(
"CHECKED_CHECKBOX",
" checked=\"checked\"");
827 $tplrow->parseCurrentBlock();
831 $tplrow->setCurrentBlock(
"checkbox");
832 $tplrow->setVariable(
"QUESTION_ID", $this->object->getId());
833 $tplrow->setVariable(
"ROW", $i);
834 $tplrow->setVariable(
"VALUE", ($cat->scale) ? ($cat->scale - 1) : $j);
835 if (is_array($working_data))
837 foreach ($working_data as
$data)
839 if (($data[
"value"] == $cat->scale-1) && ($data[
"rowvalue"] == $i))
841 $tplrow->setVariable(
"CHECKED_CHECKBOX",
" checked=\"checked\"");
845 $tplrow->parseCurrentBlock();
851 $tplrow->setCurrentBlock(
"neutral_answer");
853 if ($this->object->getNeutralColumnSeparator())
855 array_push($style,
"border-left: $neutralstyle!important");
857 if ($this->object->getColumnSeparators() == 1)
859 if ($j < $this->object->getColumnCount() - 1)
861 array_push($style,
"border-right: 1px solid $bordercolor!important");
867 $tplrow->setCurrentBlock(
"answer");
870 if ($this->object->getColumnSeparators() == 1)
872 if ($j < $this->object->getColumnCount() - 1)
874 array_push($style,
"border-right: 1px solid $bordercolor!important");
878 if ($this->object->getRowSeparators() == 1)
880 if ($i < $this->object->getRowCount() - 1)
882 array_push($style,
"border-bottom: 1px solid $bordercolor!important");
887 $tplrow->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
889 $tplrow->parseCurrentBlock();
894 $tplrow->setCurrentBlock(
"row_other");
895 $tplrow->setVariable(
"QUESTION_ID", $this->object->getId());
896 $tplrow->setVariable(
"ROW", $i);
897 if (is_array($working_data))
899 foreach ($working_data as
$data)
901 if ($data[
"rowvalue"] == $i)
907 $tplrow->parseCurrentBlock();
910 $tplrow->setVariable(
"ROWCLASS", $rowclass[$i % 2]);
911 if ($this->object->getRowSeparators() == 1)
913 if ($i < $this->object->getRowCount() - 1)
915 $tplrow->setVariable(
"STYLE",
" style=\"border-bottom: 1px solid $bordercolor!important\"");
918 $template->setCurrentBlock(
"matrix_row");
919 $template->setVariable(
"ROW", $tplrow->get());
920 $template->parseCurrentBlock();
927 $template->setCurrentBlock(
"question_data_matrix");
928 if (strcmp($error_message,
"") != 0)
930 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
932 if ($show_questiontext)
936 $template->parseCurrentBlock();
937 return $template->get();
947 $layout = $this->
object->getLayout();
948 $neutralstyle =
"3px solid #808080";
949 $bordercolor =
"#808080";
950 $template =
new ilTemplate(
"tpl.il_svy_qpl_matrix_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
952 if ($this->show_layout_row)
955 $template->setCurrentBlock(
"matrix_row");
956 $template->setVariable(
"ROW", $layout_row);
957 $template->parseCurrentBlock();
960 $tplheaders =
new ilTemplate(
"tpl.il_svy_out_matrix_columnheaders.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
961 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
963 $tplheaders->setCurrentBlock(
"bipolar_start");
965 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_bipolar_adjective1"],
"%"));
966 if (count($style) > 0)
968 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
970 $tplheaders->parseCurrentBlock();
973 for ($i = 0; $i < $this->
object->getColumnCount(); $i++)
975 $cat = $this->
object->getColumn($i);
978 $tplheaders->setCurrentBlock(
"neutral_column_header");
980 $tplheaders->setVariable(
"CLASS",
"rsep");
982 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_neutral"],
"%"));
983 if ($this->object->getNeutralColumnSeparator())
985 array_push($style,
"border-left: $neutralstyle!important;");
987 if (count($style) > 0)
989 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
991 $tplheaders->parseCurrentBlock();
996 if ($this->object->getColumnSeparators() == 1)
998 if (($i < $this->object->getColumnCount() - 1))
1000 array_push($style,
"border-right: 1px solid $bordercolor!important");
1003 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_columns"] / $this->object->getColumnCount(),
"%"));
1004 $tplheaders->setCurrentBlock(
"column_header");
1006 $tplheaders->setVariable(
"CLASS",
"center");
1007 if (count($style) > 0)
1009 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
1011 $tplheaders->parseCurrentBlock();
1015 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
1017 $tplheaders->setCurrentBlock(
"bipolar_end");
1019 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_bipolar_adjective2"],
"%"));
1020 if (count($style) > 0)
1022 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
1024 $tplheaders->parseCurrentBlock();
1028 array_push($style, sprintf(
"width: %.2f%s!important", $layout[
"percent_row"],
"%"));
1029 if (count($style) > 0)
1031 $tplheaders->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
1034 $template->setCurrentBlock(
"matrix_row");
1035 $template->setVariable(
"ROW", $tplheaders->get());
1036 $template->parseCurrentBlock();
1038 $rowclass = array(
"tblrow1",
"tblrow2");
1040 for ($i = 0; $i < $this->
object->getRowCount(); $i++)
1042 $rowobj = $this->
object->getRow($i);
1043 $tplrow =
new ilTemplate(
"tpl.il_svy_qpl_matrix_printview_row.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
1044 for ($j = 0; $j < $this->
object->getColumnCount(); $j++)
1046 $cat = $this->
object->getColumn($j);
1047 if (($i == 0) && ($j == 0))
1049 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
1051 $tplrow->setCurrentBlock(
"bipolar_start");
1053 $tplrow->setVariable(
"ROWSPAN", $this->object->getRowCount());
1054 $tplrow->parseCurrentBlock();
1057 if (($i == 0) && ($j == $this->object->getColumnCount()-1))
1059 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
1061 $tplrow->setCurrentBlock(
"bipolar_end");
1063 $tplrow->setVariable(
"ROWSPAN", $this->object->getRowCount());
1064 $tplrow->parseCurrentBlock();
1067 switch ($this->object->getSubtype())
1072 $tplrow->setCurrentBlock(
"neutral_radiobutton");
1074 $tplrow->setVariable(
"ALT_RADIO", $this->lng->txt(
"unchecked"));
1075 $tplrow->setVariable(
"TITLE_RADIO", $this->lng->txt(
"unchecked"));
1076 $tplrow->parseCurrentBlock();
1080 $tplrow->setCurrentBlock(
"radiobutton");
1082 $tplrow->setVariable(
"ALT_RADIO", $this->lng->txt(
"unchecked"));
1083 $tplrow->setVariable(
"TITLE_RADIO", $this->lng->txt(
"unchecked"));
1084 $tplrow->parseCurrentBlock();
1090 $tplrow->setCurrentBlock(
"neutral_checkbox");
1092 $tplrow->setVariable(
"ALT_CHECKBOX", $this->lng->txt(
"unchecked"));
1093 $tplrow->setVariable(
"TITLE_CHECKBOX", $this->lng->txt(
"unchecked"));
1094 $tplrow->parseCurrentBlock();
1098 $tplrow->setCurrentBlock(
"checkbox");
1100 $tplrow->setVariable(
"ALT_CHECKBOX", $this->lng->txt(
"unchecked"));
1101 $tplrow->setVariable(
"TITLE_CHECKBOX", $this->lng->txt(
"unchecked"));
1102 $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->setCurrentBlock(
"answer");
1140 if ($this->object->getColumnSeparators() == 1)
1142 if ($j < $this->object->getColumnCount() - 1)
1144 array_push($style,
"border-right: 1px solid $bordercolor!important");
1148 if ($this->object->getRowSeparators() == 1)
1150 if ($i < $this->object->getRowCount() - 1)
1152 array_push($style,
"border-bottom: 1px solid $bordercolor!important");
1157 $tplrow->setVariable(
"STYLE",
" style=\"" . implode(
";", $style) .
"\"");
1159 $tplrow->parseCurrentBlock();
1165 $tplrow->setCurrentBlock(
"text_other");
1166 $tplrow->setVariable(
"TEXT_OTHER",
" ");
1167 $tplrow->parseCurrentBlock();
1171 $tplrow->setVariable(
"ROWCLASS", $rowclass[$i % 2]);
1172 if ($this->object->getRowSeparators() == 1)
1174 if ($i < $this->object->getRowCount() - 1)
1176 $tplrow->setVariable(
"STYLE",
" style=\"border-bottom: 1px solid $bordercolor!important\"");
1179 $template->setCurrentBlock(
"matrix_row");
1180 $template->setVariable(
"ROW", $tplrow->get());
1181 $template->parseCurrentBlock();
1184 if ($question_title)
1188 $template->setCurrentBlock();
1189 if ($show_questiontext)
1193 $template->parseCurrentBlock();
1194 return $template->get();
1204 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_layout.html",
"Modules/SurveyQuestionPool");
1205 $this->show_layout_row = TRUE;
1207 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
1208 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this,
"saveLayout"));
1209 $this->tpl->setVariable(
"SAVE", $this->lng->txt(
"save"));
1219 $this->
object->saveLayout(
$_POST[
"percent_row"],
$_POST[
'percent_columns'],
$_POST[
'percent_bipolar_adjective1'],
$_POST[
'percent_bipolar_adjective2'],
$_POST[
"percent_neutral"]);
1220 $percent_values = array(
1221 "percent_row" =>
$_POST[
"percent_row"],
1222 "percent_columns" =>
$_POST[
"percent_columns"],
1223 "percent_bipolar_adjective1" =>
$_POST[
'percent_bipolar_adjective1'],
1224 "percent_bipolar_adjective2" =>
$_POST[
'percent_bipolar_adjective2'],
1225 "percent_neutral" =>
$_POST[
"percent_neutral"]
1227 $this->
object->setLayout($percent_values);
1238 $percent_values = $this->
object->getLayout();
1239 $template =
new ilTemplate(
"tpl.il_svy_out_matrix_layout.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
1240 if (strlen($this->object->getBipolarAdjective(0)) && strlen($this->object->getBipolarAdjective(1)))
1242 $template->setCurrentBlock(
"bipolar_start");
1243 $template->setVariable(
"VALUE_PERCENT_BIPOLAR_ADJECTIVE1",
" value=\"" . $percent_values[
"percent_bipolar_adjective1"] .
"\"");
1244 $template->setVariable(
"STYLE",
" style=\"width:" . $percent_values[
"percent_bipolar_adjective1"] .
"%\"");
1245 $template->parseCurrentBlock();
1246 $template->setCurrentBlock(
"bipolar_end");
1247 $template->setVariable(
"VALUE_PERCENT_BIPOLAR_ADJECTIVE2",
" value=\"" . $percent_values[
"percent_bipolar_adjective2"] .
"\"");
1248 $template->setVariable(
"STYLE",
" style=\"width:" . $percent_values[
"percent_bipolar_adjective2"] .
"%\"");
1249 $template->parseCurrentBlock();
1251 if (strlen($this->object->hasNeutralColumn()))
1253 $template->setCurrentBlock(
"bipolar_end");
1254 $template->setVariable(
"VALUE_PERCENT_NEUTRAL",
" value=\"" . $percent_values[
"percent_neutral"] .
"\"");
1255 $template->setVariable(
"STYLE_NEUTRAL",
" style=\"width:" . $percent_values[
"percent_neutral"] .
"%\"");
1256 $template->parseCurrentBlock();
1258 $template->setVariable(
"VALUE_PERCENT_ROW",
" value=\"" . $percent_values[
"percent_row"] .
"\"");
1259 $template->setVariable(
"STYLE_ROW",
" style=\"width:" . $percent_values[
"percent_row"] .
"%\"");
1260 $counter = $this->
object->getColumnCount();
1261 $template->setVariable(
"COLSPAN_COLUMNS", $counter);
1262 $template->setVariable(
"VALUE_PERCENT_COLUMNS",
" value=\"" . $percent_values[
"percent_columns"] .
"\"");
1263 $template->setVariable(
"STYLE_COLUMNS",
" style=\"width:" . $percent_values[
"percent_columns"] .
"%\"");
1264 return $template->get();
1277 if (count($this->cumulated) == 0)
1279 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
1281 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
1284 $cumulated_count = 0;
1285 foreach ($this->cumulated as $key => $value)
1287 if (is_numeric($key))
1295 include_once
"./classes/class.ilTemplate.php";
1296 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
1298 $template->setCurrentBlock(
"detail_row");
1299 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
1300 $questiontext = $this->
object->getQuestiontext();
1301 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
1302 $template->parseCurrentBlock();
1303 $template->setCurrentBlock(
"detail_row");
1304 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
1305 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()).
1306 " (".$cumulated_count.
" ".$this->lng->txt(
"rows").
")");
1307 $template->parseCurrentBlock();
1308 $template->setCurrentBlock(
"detail_row");
1309 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
1310 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"TOTAL"][
"USERS_ANSWERED"]);
1311 $template->parseCurrentBlock();
1312 $template->setCurrentBlock(
"detail_row");
1313 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
1314 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"TOTAL"][
"USERS_SKIPPED"]);
1315 $template->parseCurrentBlock();
1326 $template->setCurrentBlock(
"detail_row");
1327 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"median"));
1328 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"TOTAL"][
"MEDIAN"]);
1329 $template->parseCurrentBlock();
1331 $template->setCurrentBlock(
"detail_row");
1332 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"categories"));
1334 foreach ($this->cumulated[
"TOTAL"][
"variables"] as $key => $value)
1336 $columns .=
"<li>" . $value[
"title"] .
": n=" . $value[
"selected"] .
1337 " (" . sprintf(
"%.2f", 100*$value[
"percentage"]) .
"%)</li>";
1340 $template->setVariable(
"TEXT_OPTION_VALUE",
$columns);
1341 $template->parseCurrentBlock();
1344 $template->setCurrentBlock(
"detail_row");
1345 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"chart"));
1346 $template->setVariable(
"TEXT_OPTION_VALUE", $this->
renderChart(
"svy_ch_".$this->object->getId().
"_total", $this->cumulated[
"TOTAL"][
"variables"]));
1347 $template->parseCurrentBlock();
1349 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
1351 $output .= $template->get();
1353 foreach ($this->cumulated as $key => $value)
1355 if (is_numeric($key))
1357 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
1359 $template->setCurrentBlock(
"detail_row");
1360 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
1361 $template->setVariable(
"TEXT_OPTION_VALUE", $value[
"USERS_ANSWERED"]);
1362 $template->parseCurrentBlock();
1363 $template->setCurrentBlock(
"detail_row");
1364 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
1365 $template->setVariable(
"TEXT_OPTION_VALUE", $value[
"USERS_SKIPPED"]);
1366 $template->parseCurrentBlock();
1377 $template->setCurrentBlock(
"detail_row");
1378 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"median"));
1379 $template->setVariable(
"TEXT_OPTION_VALUE", $value[
"MEDIAN"]);
1380 $template->parseCurrentBlock();
1382 $template->setCurrentBlock(
"detail_row");
1383 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"categories"));
1385 foreach ($value[
"variables"] as $cvalue)
1387 $columns .=
"<li>" . $cvalue[
"title"] .
": n=". $cvalue[
"selected"] .
1388 " (".sprintf(
"%.2f", 100*$cvalue[
"percentage"]) .
"%)</li>";
1390 $columns =
"<ol>".$columns.
"</ol>";
1391 $template->setVariable(
"TEXT_OPTION_VALUE",
$columns);
1392 $template->parseCurrentBlock();
1395 if (is_array($value[
"textanswers"]))
1397 $template->setCurrentBlock(
"detail_row");
1398 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"freetext_answers"));
1400 foreach ($value[
"textanswers"] as $tkey => $answers)
1402 $html .= $value[
"variables"][$tkey][
"title"] .
"\n";
1404 foreach ($answers as $answer)
1406 $html .=
"<li>" . preg_replace(
"/\n/",
"<br>\n", $answer) .
"</li>\n";
1410 $template->setVariable(
"TEXT_OPTION_VALUE", $html);
1411 $template->parseCurrentBlock();
1415 $template->setCurrentBlock(
"detail_row");
1416 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"chart"));
1417 $template->setVariable(
"TEXT_OPTION_VALUE", $this->
renderChart(
"svy_ch_".$this->object->getId().
"_".$key, $value[
"variables"]));
1418 $template->parseCurrentBlock();
1420 $template->setVariable(
"QUESTION_SUBTITLE", $counter.
".".($key+1).
" ".
1421 $this->object->prepareTextareaOutput($value[
"ROW"], TRUE));
1423 $output .= $template->get();
1432 global $rbacsystem,$ilTabs;
1433 $this->ctrl->setParameterByClass(
"$guiclass",
"sel_question_types", $this->
getQuestionType());
1434 $this->ctrl->setParameterByClass(
"$guiclass",
"q_id",
$_GET[
"q_id"]);
1436 if ((
$_GET[
"calling_survey"] > 0) || (
$_GET[
"new_for_survey"] > 0))
1441 if (strlen(
$_GET[
"new_for_survey"]))
1443 $addurl =
"&new_id=" .
$_GET[
"q_id"];
1447 $addurl .=
"&pgov=".$_REQUEST[
"pgov"];
1448 $addurl .=
"&pgov_pos=".$_REQUEST[
"pgov_pos"];
1450 $ilTabs->setBackTarget($this->lng->txt(
"menubacktosurvey"),
"ilias.php?baseClass=ilObjSurveyGUI&ref_id=$ref_id&cmd=questions" . $addurl);
1454 $this->ctrl->setParameterByClass(
"ilObjSurveyQuestionPoolGUI",
"q_id_table_nav",
$_SESSION[
'q_id_table_nav']);
1455 $ilTabs->setBackTarget($this->lng->txt(
"spl"), $this->ctrl->getLinkTargetByClass(
"ilObjSurveyQuestionPoolGUI",
"questions"));
1459 $ilTabs->addTarget(
"preview",
1460 $this->ctrl->getLinkTarget($this,
"preview"),
1465 $ilTabs->addTarget(
"layout",
1466 $this->ctrl->getLinkTarget($this,
"layout"),
1467 array(
"layout",
"saveLayout"),
1471 if ($rbacsystem->checkAccess(
'edit',
$_GET[
"ref_id"]))
1473 $ilTabs->addTarget(
"edit_properties",
1474 $this->ctrl->getLinkTarget($this,
"editQuestion"),
1475 array(
"editQuestion",
"cancelExplorer",
"linkChilds",
"addGIT",
"addST",
1476 "addPG",
"editQuestion",
"addMaterial",
"removeMaterial",
1477 "save",
"cancel",
"savePhrasecolumns",
"confirmSavePhrase",
1478 "downcolumns",
"upcolumns",
"addcolumns",
"removecolumns",
1479 "downrows",
"uprows",
"addrows",
"removerows",
"wizardcolumns",
1480 "addSelectedPhrase",
"insertStandardNumbers"),
1485 if ($this->object->getId() > 0)
1487 $ilTabs->addTarget(
"material",
1488 $this->ctrl->getLinkTarget($this,
"material"),
1489 array(
"material",
"cancelExplorer",
"linkChilds",
"addGIT",
"addST",
1490 "addPG",
"addMaterial",
"removeMaterial"),
1494 if ($this->object->getId() > 0)
1496 $title = $this->lng->txt(
"edit") .
" "" . $this->
object->getTitle() .
""";
1503 $this->tpl->setVariable(
"HEADER",
$title);