24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
25 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
55 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveySingleChoiceQuestion.php";
59 $this->
object->loadFromDb($id);
71 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
74 $this->
object->setTitle(
$_POST[
"title"]);
75 $this->
object->setAuthor(
$_POST[
"author"]);
76 $this->
object->setDescription(
$_POST[
"description"]);
77 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
78 $questiontext =
$_POST[
"question"];
79 $this->
object->setQuestiontext($questiontext);
80 $this->
object->setObligatory((
$_POST[
"obligatory"]) ? 1 : 0);
81 $this->
object->setOrientation(
$_POST[
"orientation"]);
82 $this->
object->label =
$_POST[
'label'];
84 $this->
object->categories->flushCategories();
86 foreach (
$_POST[
'answers'][
'answer'] as $key => $value)
88 if (strlen($value)) $this->
object->getCategories()->addCategory($value,
$_POST[
'answers'][
'other'][$key], 0, null,
$_POST[
'answers'][
'scale'][$key]);
90 if (strlen(
$_POST[
'answers'][
'neutral']))
92 $this->
object->getCategories()->addCategory(
$_POST[
'answers'][
'neutral'], 0, 1, null,
$_POST[
'answers_neutral_scale']);
109 $save = ((strcmp($this->ctrl->getCmd(),
"save") == 0) ||
110 (strcmp($this->ctrl->getCmd(),
"wizardanswers") == 0) ||
111 (strcmp($this->ctrl->getCmd(),
"savePhraseanswers") == 0)
114 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
116 $form->setFormAction($this->ctrl->getFormAction($this));
117 $form->setTitle($this->lng->txt($this->getQuestionType()));
118 $form->setMultipart(FALSE);
119 $form->setTableWidth(
"100%");
120 $form->setId(
"singlechoice");
124 $title->setValue($this->object->getTitle());
125 $title->setRequired(TRUE);
130 $label->
setValue($this->object->label);
131 $label->setInfo($this->lng->txt(
"label_info"));
132 $label->setRequired(
false);
133 $form->addItem($label);
136 $author =
new ilTextInputGUI($this->lng->txt(
"author"),
"author");
137 $author->
setValue($this->object->getAuthor());
138 $author->setRequired(TRUE);
139 $form->addItem($author);
142 $description =
new ilTextInputGUI($this->lng->txt(
"description"),
"description");
143 $description->
setValue($this->object->getDescription());
144 $description->setRequired(FALSE);
145 $form->addItem($description);
149 $question->
setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
150 $question->setRequired(TRUE);
151 $question->setRows(10);
152 $question->setCols(80);
153 $question->setUseRte(TRUE);
154 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
156 $question->addPlugin(
"latex");
157 $question->addButton(
"latex");
158 $question->addButton(
"pastelatex");
159 $question->removePlugin(
"ibrowser");
160 $question->setRTESupport($this->object->getId(),
"spl",
"survey");
161 $form->addItem($question);
166 $shuffle->setChecked($this->object->getObligatory());
167 $shuffle->setRequired(FALSE);
168 $form->addItem($shuffle);
173 $orientation->setValue($this->object->getOrientation());
174 $orientation->addOption(
new ilRadioOption($this->lng->txt(
'vertical'), 0));
175 $orientation->addOption(
new ilRadioOption($this->lng->txt(
'horizontal'), 1));
176 $orientation->addOption(
new ilRadioOption($this->lng->txt(
'combobox'), 2));
177 $form->addItem($orientation);
180 include_once
"./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
183 $answers->setAllowMove(
true);
184 $answers->setShowWizard(
true);
185 $answers->setShowSavePhrase(
true);
186 $answers->setUseOtherAnswer(
true);
187 $answers->setShowNeutralCategory(
true);
188 $answers->setNeutralCategoryTitle($this->lng->txt(
'matrix_neutral_answer'));
189 if (!$this->object->getCategories()->getCategoryCount())
191 $this->
object->getCategories()->addCategory(
"");
193 $answers->setValues($this->object->getCategories());
194 $answers->setDisabledScale(
false);
195 $form->addItem($answers);
197 $form->addCommandButton(
"save", $this->lng->txt(
"save"));
203 $form->setValuesByPost();
204 $errors = !$form->checkInput();
205 $form->setValuesByPost();
206 if (
$errors) $checkonly =
false;
209 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
219 $position = key(
$_POST[
'cmd'][
'addanswers']);
220 $this->
object->getCategories()->addCategoryAtPosition(
"", $position+1);
230 $position = key(
$_POST[
'cmd'][
'removeanswers']);
231 $this->
object->getCategories()->removeCategory($position);
241 $position = key(
$_POST[
'cmd'][
'upanswers']);
242 $this->
object->getCategories()->moveCategoryUp($position);
252 $position = key(
$_POST[
'cmd'][
'downanswers']);
253 $this->
object->getCategories()->moveCategoryDown($position);
265 if ($result == 0 || !$save_post_data)
267 if ($save_post_data) $this->
object->saveToDb();
268 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_addphrase.html",
"Modules/SurveyQuestionPool");
271 $this->tpl->setCurrentBlock(
"hidden");
272 $this->tpl->setVariable(
"HIDDEN_NAME",
"id");
273 $this->tpl->setVariable(
"HIDDEN_VALUE", $this->object->getId());
274 $this->tpl->parseCurrentBlock();
276 include_once
"./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
278 $colors = array(
"tblrow1",
"tblrow2");
280 foreach ($phrases as $phrase_id => $phrase_array)
282 $this->tpl->setCurrentBlock(
"phraserow");
283 $this->tpl->setVariable(
"COLOR_CLASS", $colors[$counter++ % 2]);
284 $this->tpl->setVariable(
"PHRASE_VALUE", $phrase_id);
285 $this->tpl->setVariable(
"PHRASE_NAME", $phrase_array[
"title"]);
287 $this->tpl->setVariable(
"PHRASE_CONTENT", join($categories,
","));
288 $this->tpl->parseCurrentBlock();
291 $this->tpl->setCurrentBlock(
"adm_content");
292 $this->tpl->setVariable(
"TEXT_CANCEL", $this->lng->txt(
"cancel"));
293 $this->tpl->setVariable(
"TEXT_PHRASE", $this->lng->txt(
"phrase"));
294 $this->tpl->setVariable(
"TEXT_CONTENT", $this->lng->txt(
"categories"));
295 $this->tpl->setVariable(
"TEXT_ADD_PHRASE", $this->lng->txt(
"add_phrase"));
296 $this->tpl->setVariable(
"TEXT_INTRODUCTION",$this->lng->txt(
"add_phrase_introduction"));
297 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
298 $this->tpl->parseCurrentBlock();
310 $this->ctrl->redirect($this,
'editQuestion');
320 if (strcmp(
$_POST[
"phrases"],
"") == 0)
327 if (strcmp($this->object->getPhrase(
$_POST[
"phrases"]),
"dp_standard_numbers") != 0)
329 $this->
object->addPhrase(
$_POST[
"phrases"]);
330 $this->
object->saveToDb();
338 $this->ctrl->redirect($this,
'editQuestion');
349 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_addphrase_standard_numbers.html",
"Modules/SurveyQuestionPool");
352 $this->tpl->setCurrentBlock(
"hidden");
353 $this->tpl->setVariable(
"HIDDEN_NAME",
"id");
354 $this->tpl->setVariable(
"HIDDEN_VALUE", $this->object->getId());
355 $this->tpl->parseCurrentBlock();
357 $this->tpl->setCurrentBlock(
"adm_content");
358 $this->tpl->setVariable(
"ADD_STANDARD_NUMBERS", $this->lng->txt(
"add_standard_numbers"));
359 $this->tpl->setVariable(
"TEXT_ADD_LIMITS", $this->lng->txt(
"add_limits_for_standard_numbers"));
360 $this->tpl->setVariable(
"TEXT_LOWER_LIMIT",$this->lng->txt(
"lower_limit"));
361 $this->tpl->setVariable(
"TEXT_UPPER_LIMIT",$this->lng->txt(
"upper_limit"));
362 $this->tpl->setVariable(
"VALUE_LOWER_LIMIT",
$_POST[
"lower_limit"]);
363 $this->tpl->setVariable(
"VALUE_UPPER_LIMIT",
$_POST[
"upper_limit"]);
364 $this->tpl->setVariable(
"BTN_ADD",$this->lng->txt(
"add_phrase"));
365 $this->tpl->setVariable(
"BTN_CANCEL",$this->lng->txt(
"cancel"));
366 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
367 $this->tpl->parseCurrentBlock();
378 $this->ctrl->redirect($this,
"editQuestion");
388 if ((strcmp(
$_POST[
"lower_limit"],
"") == 0) or (strcmp(
$_POST[
"upper_limit"],
"") == 0))
393 else if ((
int)
$_POST[
"upper_limit"] <= (
int)
$_POST[
"lower_limit"])
400 $this->
object->addStandardNumbers($_POST[
"lower_limit"], $_POST[
"upper_limit"]);
401 $this->
object->saveToDb();
403 $this->ctrl->redirect($this,
"editQuestion");
415 if ($result == 0 || $haserror)
417 if (!$haserror) $this->
object->saveToDb();
419 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_savephrase.html",
"Modules/SurveyQuestionPool");
420 $this->tpl->setCurrentBlock(
"adm_content");
421 $this->tpl->setVariable(
"SAVE_PHRASE_INTRODUCTION", $this->lng->txt(
"save_phrase_introduction"));
422 $this->tpl->setVariable(
"TEXT_PHRASE_TITLE", $this->lng->txt(
"enter_phrase_title"));
423 $this->tpl->setVariable(
"VALUE_PHRASE_TITLE",
$_POST[
"phrase_title"]);
424 $this->tpl->setVariable(
"BTN_CANCEL",$this->lng->txt(
"cancel"));
425 $this->tpl->setVariable(
"BTN_CONFIRM",$this->lng->txt(
"confirm"));
426 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
428 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveySavePhraseTableGUI.php";
434 foreach (
$_POST[
'answers'][
'answer'] as $key => $value)
436 array_push(
$data, array(
'answer' => $value,
'other' => ((
$_POST[
'answers'][
'other'][$key]) ?
true :
false),
'scale' =>
$_POST[
'answers'][
'scale'][$key]));
438 if (strlen(
$_POST[
'answers'][
'neutral']))
440 array_push(
$data, array(
'answer' =>
$_POST[
'answers'][
'neutral'],
'other' =>
false,
'scale' =>
$_POST[
'answers_neutral_scale']));
447 $table_gui->setData(
$data);
449 $this->tpl->setVariable(
'TABLE', $table_gui->getHTML());
450 $this->tpl->parseCurrentBlock();
462 $this->ctrl->redirect($this,
"editQuestion");
472 if (!
$_POST[
"phrase_title"])
479 if ($this->object->phraseExists(
$_POST[
"phrase_title"]))
486 $this->
object->savePhrase(
$_POST[
"phrase_title"]);
488 $this->ctrl->redirect($this,
"editQuestion");
497 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
499 $template =
new ilTemplate(
"tpl.il_svy_out_sc.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
500 $template->setCurrentBlock(
"material");
502 $template->parseCurrentBlock();
503 switch ($this->object->orientation)
507 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
509 $cat = $this->
object->categories->getCategory($i);
512 $template->setCurrentBlock(
"other_row");
513 if (strlen($cat->title))
515 $template->setVariable(
"OTHER_LABEL", $cat->title);
517 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
518 $template->setVariable(
"QUESTION_ID", $this->object->getId());
519 if (is_array($working_data))
521 foreach ($working_data as $value)
523 if (strlen($value[
"value"]))
525 if ($value[
"value"] == $cat->scale-1)
527 if (strlen($value[
'textanswer'])) $template->setVariable(
"OTHER_VALUE",
' value="' .
ilUtil::prepareFormOutput($value[
'textanswer']) .
'"');
528 if (!$value[
'uncheck'])
530 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
536 $template->parseCurrentBlock();
540 $template->setCurrentBlock(
"row");
541 if ($cat->neutral) $template->setVariable(
'ROWCLASS',
' class="neutral"');
543 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
544 $template->setVariable(
"QUESTION_ID", $this->object->getId());
545 if (is_array($working_data))
547 foreach ($working_data as $value)
549 if (strcmp($value[
"value"],
"") != 0)
551 if ($value[
"value"] == $cat->scale-1)
553 if (!$value[
'uncheck'])
555 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
561 $template->parseCurrentBlock();
563 $template->touchBlock(
'outer_row');
568 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
570 $cat = $this->
object->categories->getCategory($i);
571 $template->setCurrentBlock(
"radio_col");
572 if ($cat->neutral) $template->setVariable(
'COLCLASS',
' neutral');
573 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
574 $template->setVariable(
"QUESTION_ID", $this->object->getId());
575 if (is_array($working_data))
577 foreach ($working_data as $value)
579 if (strcmp($value[
"value"],
"") != 0)
581 if ($value[
"value"] == $cat->scale-1)
583 if (!$value[
'uncheck'])
585 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
591 $template->parseCurrentBlock();
593 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
595 $cat = $this->
object->categories->getCategory($i);
598 $template->setCurrentBlock(
"text_other_col");
599 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
600 $template->setVariable(
"QUESTION_ID", $this->object->getId());
601 if (strlen($cat->title))
603 $template->setVariable(
"OTHER_LABEL", $cat->title);
605 if (is_array($working_data))
607 foreach ($working_data as $value)
609 if (strlen($value[
"value"]))
611 if ($value[
"value"] == $cat->scale-1 && strlen($value[
'textanswer']))
618 $template->parseCurrentBlock();
622 $template->setCurrentBlock(
"text_col");
623 if ($cat->neutral) $template->setVariable(
'COLCLASS',
' neutral');
624 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
626 $template->setVariable(
"QUESTION_ID", $this->object->getId());
627 $template->parseCurrentBlock();
629 $template->touchBlock(
'text_outer_col');
634 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
636 $cat = $this->
object->categories->getCategory($i);
637 $template->setCurrentBlock(
"comborow");
638 $template->setVariable(
"TEXT_SC", $cat->title);
639 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
640 if (is_array($working_data))
642 if (strcmp($working_data[0][
"value"],
"") != 0)
644 if ($working_data[0][
"value"] == $cat->scale-1)
646 $template->setVariable(
"SELECTED_SC",
" selected=\"selected\"");
650 $template->parseCurrentBlock();
652 $template->setCurrentBlock(
"combooutput");
653 $template->setVariable(
"QUESTION_ID", $this->object->getId());
654 $template->setVariable(
"SELECT_OPTION", $this->lng->txt(
"select_option"));
655 $template->setVariable(
"TEXT_SELECTION", $this->lng->txt(
"selection"));
656 $template->parseCurrentBlock();
661 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
663 $template->setCurrentBlock(
"question_data");
664 if (strcmp($error_message,
"") != 0)
666 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
668 if ($show_questiontext)
672 $template->parseCurrentBlock();
673 return $template->get();
681 function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null)
683 $template =
new ilTemplate(
"tpl.il_svy_qpl_sc_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
684 switch ($this->object->orientation)
688 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
690 $cat = $this->
object->categories->getCategory($i);
693 $template->setCurrentBlock(
"other_row");
695 $template->setVariable(
"ALT_RADIO", $this->lng->txt(
"unchecked"));
696 $template->setVariable(
"TITLE_RADIO", $this->lng->txt(
"unchecked"));
698 $template->setVariable(
"OTHER_ANSWER",
" ");
699 $template->parseCurrentBlock();
703 $template->setCurrentBlock(
"row");
705 $template->setVariable(
"ALT_RADIO", $this->lng->txt(
"unchecked"));
706 $template->setVariable(
"TITLE_RADIO", $this->lng->txt(
"unchecked"));
708 $template->parseCurrentBlock();
714 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
716 $template->setCurrentBlock(
"radio_col");
718 $template->setVariable(
"ALT_RADIO", $this->lng->txt(
"unchecked"));
719 $template->setVariable(
"TITLE_RADIO", $this->lng->txt(
"unchecked"));
720 $template->parseCurrentBlock();
722 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
724 $cat = $this->
object->categories->getCategory($i);
727 $template->setCurrentBlock(
"other_text_col");
729 $template->setVariable(
"OTHER_ANSWER",
" ");
730 $template->parseCurrentBlock();
734 $template->setCurrentBlock(
"text_col");
735 $template->setVariable(
"TEXT_SC", $cat->title);
736 $template->parseCurrentBlock();
742 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
744 $cat = $this->
object->categories->getCategory($i);
745 $template->setCurrentBlock(
"comborow");
747 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
748 if (is_array($working_data))
750 if (strcmp($working_data[0][
"value"],
"") != 0)
752 if ($working_data[0][
"value"] == $i)
754 $template->setVariable(
"SELECTED_SC",
" selected=\"selected\"");
758 $template->parseCurrentBlock();
760 $template->setCurrentBlock(
"combooutput");
761 $template->setVariable(
"QUESTION_ID", $this->object->getId());
762 $template->setVariable(
"SELECT_OPTION", $this->lng->txt(
"select_option"));
763 $template->setVariable(
"TEXT_SELECTION", $this->lng->txt(
"selection"));
764 $template->parseCurrentBlock();
769 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
771 if ($show_questiontext)
775 $template->parseCurrentBlock();
776 return $template->get();
786 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_preview.html",
"Modules/SurveyQuestionPool");
788 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
793 global $rbacsystem,$ilTabs;
794 $this->ctrl->setParameter($this,
"sel_question_types", $this->
getQuestionType());
795 $this->ctrl->setParameter($this,
"q_id",
$_GET[
"q_id"]);
797 if ((
$_GET[
"calling_survey"] > 0) || (
$_GET[
"new_for_survey"] > 0))
802 if (strlen(
$_GET[
"new_for_survey"]))
804 $addurl =
"&new_id=" .
$_GET[
"q_id"];
806 $ilTabs->setBackTarget($this->lng->txt(
"menubacktosurvey"),
"ilias.php?baseClass=ilObjSurveyGUI&ref_id=$ref_id&cmd=questions" . $addurl);
810 $this->ctrl->setParameterByClass(
"ilObjSurveyQuestionPoolGUI",
"q_id_table_nav",
$_SESSION[
'q_id_table_nav']);
811 $ilTabs->setBackTarget($this->lng->txt(
"spl"), $this->ctrl->getLinkTargetByClass(
"ilObjSurveyQuestionPoolGUI",
"questions"));
815 $ilTabs->addTarget(
"preview",
816 $this->ctrl->getLinkTarget($this,
"preview"),
822 if ($rbacsystem->checkAccess(
'edit',
$_GET[
"ref_id"])) {
823 $ilTabs->addTarget(
"edit_properties",
824 $this->ctrl->getLinkTarget($this,
"editQuestion"),
825 array(
"editQuestion",
"save",
"cancel",
"wizardanswers",
"addSelectedPhrase",
826 "insertStandardNumbers",
"savePhraseanswers",
"confirmSavePhrase"),
833 $ilTabs->addTarget(
"material",
834 $this->ctrl->getLinkTarget($this,
"material"),
835 array(
"material",
"cancelExplorer",
"linkChilds",
"addGIT",
"addST",
836 "addPG",
"addMaterial",
"removeMaterial"),
842 if ($this->object->getId() > 0)
844 $title = $this->lng->txt(
"edit") .
" "" . $this->
object->getTitle() .
""";
851 $this->tpl->setVariable(
"HEADER",
$title);
864 if (count($this->cumulated) == 0)
866 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
868 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
871 include_once
"./classes/class.ilTemplate.php";
872 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
874 $template->setCurrentBlock(
"detail_row");
875 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
876 $questiontext = $this->
object->getQuestiontext();
877 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
878 $template->parseCurrentBlock();
879 $template->setCurrentBlock(
"detail_row");
880 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
881 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
882 $template->parseCurrentBlock();
883 $template->setCurrentBlock(
"detail_row");
884 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
885 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
886 $template->parseCurrentBlock();
887 $template->setCurrentBlock(
"detail_row");
888 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
889 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
890 $template->parseCurrentBlock();
892 $template->setCurrentBlock(
"detail_row");
893 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"mode"));
894 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MODE"]);
895 $template->parseCurrentBlock();
896 $template->setCurrentBlock(
"detail_row");
897 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"mode_nr_of_selections"));
898 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MODE_NR_OF_SELECTIONS"]);
899 $template->parseCurrentBlock();
900 $template->setCurrentBlock(
"detail_row");
901 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"median"));
902 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MEDIAN"]);
903 $template->parseCurrentBlock();
905 $template->setCurrentBlock(
"detail_row");
906 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"categories"));
908 foreach ($this->cumulated[
"variables"] as $key => $value)
910 $categories .=
"<li>" . $this->lng->txt(
"title") .
":" .
"<span class=\"bold\">" . $value[
"title"] .
"</span><br />" .
911 $this->lng->txt(
"category_nr_selected") .
": " .
"<span class=\"bold\">" . $value[
"selected"] .
"</span><br />" .
912 $this->lng->txt(
"percentage_of_selections") .
": " .
"<span class=\"bold\">" . sprintf(
"%.2f", 100*$value[
"percentage"]) .
"</span></li>";
914 $categories =
"<ol>$categories</ol>";
915 $template->setVariable(
"TEXT_OPTION_VALUE", $categories);
916 $template->parseCurrentBlock();
919 if (is_array($this->cumulated[
"textanswers"]))
921 $template->setCurrentBlock(
"detail_row");
922 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"freetext_answers"));
924 foreach ($this->cumulated[
"textanswers"] as $key => $answers)
926 $html .= $this->cumulated[
"variables"][$key][
"title"] .
"\n";
928 foreach ($answers as $answer)
930 $html .=
"<li>" . preg_replace(
"/\n/",
"<br>\n", $answer) .
"</li>\n";
934 $template->setVariable(
"TEXT_OPTION_VALUE", $html);
935 $template->parseCurrentBlock();
939 $template->setCurrentBlock(
"chart");
940 $template->setVariable(
"TEXT_CHART", $this->lng->txt(
"chart"));
941 $template->setVariable(
"ALT_CHART",
$data[
"title"] .
"( " . $this->lng->txt(
"chart") .
")");
943 include_once
"./Services/Administration/classes/class.ilSetting.php";
944 $surveySetting =
new ilSetting(
"survey");
945 if ($surveySetting->get(
"googlechart") == 1)
947 $chartcolors = array(
"2A4BD7",
"9DAFFF",
"1D6914",
"81C57A",
"814A19",
"E9DEBB",
"8126C0",
"AD2323",
"29D0D0",
"FFEE33",
"FF9233",
"FFCDF3",
"A0A0A0",
"575757",
"000000");
948 $selections = array();
952 foreach ($this->cumulated[
"variables"] as $val)
954 if ($val[
"selected"] > $maxselection) $maxselection = $val[
"selected"];
955 array_push($selections, $val[
"selected"]);
956 array_push($values, str_replace(
" ",
"+", $val[
"title"]));
959 if ($maxselection % 2 == 0)
961 $selectionlabels =
"0|" . ($maxselection / 2) .
"|$maxselection";
965 $selectionlabels =
"0|$maxselection";
967 $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(
" ",
"+", $this->object->getTitle()) .
"&chbh=20," . (round($chartwidth/count($values))-25) .
"&chdl=" . implode(
"|", $values) .
"&chdlp=b";
971 $this->ctrl->setParameterByClass(
"ilsurveyevaluationgui",
"survey", $survey_id);
972 $this->ctrl->setParameterByClass(
"ilsurveyevaluationgui",
"question", $this->object->getId());
973 $charturl = $this->ctrl->getLinkTargetByClass(
"ilsurveyevaluationgui",
"outChart");
975 $template->setVariable(
"CHART", $charturl);
976 $template->parseCurrentBlock();
978 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
979 return $template->get();