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.SurveyNominalQuestion.php";
59 $this->
object->loadFromDb($id);
72 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_nominal.html",
"Modules/SurveyQuestionPool");
73 $this->tpl->addBlockFile(
"OTHER_QUESTION_DATA",
"other_question_data",
"tpl.il_svy_qpl_other_question_data.html",
"Modules/SurveyQuestionPool");
74 $this->tpl->setVariable(
"TEXT_ORIENTATION", $this->lng->txt(
"orientation"));
75 switch ($this->object->getOrientation())
78 $this->tpl->setVariable(
"CHECKED_VERTICAL",
" checked=\"checked\"");
81 $this->tpl->setVariable(
"CHECKED_HORIZONTAL",
" checked=\"checked\"");
84 $this->tpl->setVariable(
"CHECKED_COMBOBOX",
" checked=\"checked\"");
87 $this->tpl->setVariable(
"TXT_VERTICAL", $this->lng->txt(
"vertical"));
88 $this->tpl->setVariable(
"TXT_HORIZONTAL", $this->lng->txt(
"horizontal"));
91 $this->tpl->setVariable(
"TXT_COMBOBOX", $this->lng->txt(
"combobox"));
94 $internallinks = array(
95 "lm" => $this->lng->txt(
"obj_lm"),
96 "st" => $this->lng->txt(
"obj_st"),
97 "pg" => $this->lng->txt(
"obj_pg"),
98 "glo" => $this->lng->txt(
"glossary_term")
100 foreach ($internallinks as $key => $value)
102 $this->tpl->setCurrentBlock(
"internallink");
103 $this->tpl->setVariable(
"TYPE_INTERNAL_LINK", $key);
104 $this->tpl->setVariable(
"TEXT_INTERNAL_LINK", $value);
105 $this->tpl->parseCurrentBlock();
108 $this->tpl->setCurrentBlock(
"adm_content");
109 $this->tpl->setVariable(
"TEXT_MATERIAL", $this->lng->txt(
"material"));
110 if (count($this->object->material))
112 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
114 $this->tpl->setVariable(
"TEXT_VALUE_MATERIAL",
" <a href=\"$href\" target=\"content\">" . $this->lng->txt(
"material").
"</a> ");
115 $this->tpl->setVariable(
"BUTTON_REMOVE_MATERIAL", $this->lng->txt(
"remove"));
116 $this->tpl->setVariable(
"BUTTON_ADD_MATERIAL", $this->lng->txt(
"change"));
117 $this->tpl->setVariable(
"VALUE_MATERIAL", $this->object->material[
"internal_link"]);
118 $this->tpl->setVariable(
"VALUE_MATERIAL_TITLE", $this->object->material[
"title"]);
119 $this->tpl->setVariable(
"TEXT_TITLE", $this->lng->txt(
"title"));
123 $this->tpl->setVariable(
"BUTTON_ADD_MATERIAL", $this->lng->txt(
"add"));
125 $this->tpl->setVariable(
"QUESTION_ID", $this->object->getId());
126 $this->tpl->setVariable(
"VALUE_TITLE", $this->object->getTitle());
127 $this->tpl->setVariable(
"VALUE_DESCRIPTION", $this->object->getDescription());
128 $this->tpl->setVariable(
"VALUE_AUTHOR", $this->object->getAuthor());
129 $questiontext = $this->
object->getQuestiontext();
130 $this->tpl->setVariable(
"VALUE_QUESTION",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
131 $this->tpl->setVariable(
"TXT_SR", $this->lng->txt(
"multiple_choice_single_response"));
132 $this->tpl->setVariable(
"TXT_MR", $this->lng->txt(
"multiple_choice_multiple_response"));
133 $this->tpl->setVariable(
"TEXT_SUBTYPE", $this->lng->txt(
"subtype"));
134 $this->tpl->setVariable(
"DESCRIPTION_QUESTION_TYPE", $this->lng->txt(
"multiple_choice_subtype_description"));
137 $this->tpl->setVariable(
"CHECKED_SR",
" checked=\"checked\"");
141 $this->tpl->setVariable(
"CHECKED_MR",
" checked=\"checked\"");
143 $this->tpl->setVariable(
"TEXT_TITLE", $this->lng->txt(
"title"));
144 $this->tpl->setVariable(
"TEXT_AUTHOR", $this->lng->txt(
"author"));
145 $this->tpl->setVariable(
"TEXT_DESCRIPTION", $this->lng->txt(
"description"));
146 $this->tpl->setVariable(
"TEXT_QUESTION", $this->lng->txt(
"question"));
147 $this->tpl->setVariable(
"TEXT_QUESTION_TYPE", $this->lng->txt(
"questiontype"));
148 $this->tpl->setVariable(
"TEXT_OBLIGATORY", $this->lng->txt(
"obligatory"));
149 if ($this->object->getObligatory())
151 $this->tpl->setVariable(
"CHECKED_OBLIGATORY",
" checked=\"checked\"");
153 $this->tpl->setVariable(
"SAVE",$this->lng->txt(
"save"));
154 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
155 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
156 $this->tpl->setVariable(
"TEXT_QUESTION_TYPE", $this->lng->txt($this->getQuestionType()));
157 $this->tpl->parseCurrentBlock();
158 include_once
"./Services/RTE/classes/class.ilRTE.php";
160 include_once
"./Services/RTE/classes/class.$rtestring.php";
161 $rte =
new $rtestring();
162 $rte->addPlugin(
"latex");
163 $rte->addButton(
"latex"); $rte->addButton(
"pastelatex");
164 $rte->removePlugin(
"ibrowser");
165 include_once
"./classes/class.ilObject.php";
166 $obj_id =
$_GET[
"q_id"];
168 $rte->addRTESupport($obj_id, $obj_type,
"survey");
180 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
182 $template =
new ilTemplate(
"tpl.il_svy_out_nominal.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
183 if (count($this->object->material))
185 $template->setCurrentBlock(
"material_nominal");
186 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
188 $template->setVariable(
"TEXT_MATERIAL", $this->lng->txt(
"material") .
": <a href=\"$href\" target=\"content\">" . $this->
object->material[
"title"].
"</a> ");
189 $template->parseCurrentBlock();
191 switch ($this->object->getOrientation())
195 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++) {
196 $category = $this->
object->categories->getCategory($i);
199 $template->setCurrentBlock(
"nominal_row_sr");
201 $template->setVariable(
"VALUE_NOMINAL", $i);
202 $template->setVariable(
"QUESTION_ID", $this->object->getId());
203 if (is_array($working_data))
205 foreach ($working_data as $value)
207 if (strlen($value[
"value"]))
209 if ($value[
"value"] == $i)
211 $template->setVariable(
"CHECKED_NOMINAL",
" checked=\"checked\"");
216 $template->parseCurrentBlock();
220 $template->setCurrentBlock(
"nominal_row_mr");
222 $template->setVariable(
"VALUE_NOMINAL", $i);
223 $template->setVariable(
"QUESTION_ID", $this->object->getId());
224 if (is_array($working_data))
226 foreach ($working_data as $value)
228 if (strlen($value[
"value"]))
230 if ($value[
"value"] == $i)
232 $template->setVariable(
"CHECKED_NOMINAL",
" checked=\"checked\"");
237 $template->parseCurrentBlock();
245 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
247 $category = $this->
object->categories->getCategory($i);
248 $template->setCurrentBlock(
"radio_col_nominal");
249 $template->setVariable(
"VALUE_NOMINAL", $i);
250 $template->setVariable(
"QUESTION_ID", $this->object->getId());
251 if (is_array($working_data))
253 foreach ($working_data as $value)
255 if (strlen($value[
"value"]))
257 if ($value[
"value"] == $i)
259 $template->setVariable(
"CHECKED_NOMINAL",
" checked=\"checked\"");
264 $template->parseCurrentBlock();
266 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
268 $category = $this->
object->categories->getCategory($i);
269 $template->setCurrentBlock(
"text_col_nominal");
270 $template->setVariable(
"VALUE_NOMINAL", $i);
272 $template->setVariable(
"QUESTION_ID", $this->object->getId());
273 $template->parseCurrentBlock();
278 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
280 $category = $this->
object->categories->getCategory($i);
281 $template->setCurrentBlock(
"checkbox_col_nominal");
282 $template->setVariable(
"VALUE_NOMINAL", $i);
283 $template->setVariable(
"QUESTION_ID", $this->object->getId());
284 if (is_array($working_data))
286 foreach ($working_data as $value)
288 if (strlen($value[
"value"]))
290 if ($value[
"value"] == $i)
292 $template->setVariable(
"CHECKED_NOMINAL",
" checked=\"checked\"");
297 $template->parseCurrentBlock();
299 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
301 $category = $this->
object->categories->getCategory($i);
302 $template->setCurrentBlock(
"text_col_nominal_mr");
303 $template->setVariable(
"VALUE_NOMINAL", $i);
305 $template->setVariable(
"QUESTION_ID", $this->object->getId());
306 $template->parseCurrentBlock();
312 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
314 $category = $this->
object->categories->getCategory($i);
315 $template->setCurrentBlock(
"comborow_nominal");
317 $template->setVariable(
"VALUE_NOMINAL", $i);
318 if (is_array($working_data))
320 foreach ($working_data as $value)
322 if (strlen($value[
"value"]))
324 if ($value[
"value"] == $i)
326 $template->setVariable(
"SELECTED_NOMINAL",
" selected=\"selected\"");
331 $template->parseCurrentBlock();
333 $template->setCurrentBlock(
"combooutput_nominal");
334 $template->setVariable(
"QUESTION_ID", $this->object->getId());
335 $template->setVariable(
"SELECT_OPTION", $this->lng->txt(
"select_option"));
336 $template->setVariable(
"TEXT_SELECTION", $this->lng->txt(
"selection"));
337 $template->parseCurrentBlock();
341 $template->setCurrentBlock(
"question_data_nominal");
342 if (strcmp($error_message,
"") != 0)
344 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
346 if ($show_questiontext)
348 $questiontext = $this->
object->getQuestiontext();
349 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
351 if (!$this->object->getObligatory($survey_id))
353 $template->setVariable(
"OBLIGATORY_TEXT", $this->lng->txt(
"survey_question_optional"));
357 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
359 $template->parseCurrentBlock();
360 return $template->get();
370 function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null)
372 $template =
new ilTemplate(
"tpl.il_svy_qpl_nominal_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
373 switch ($this->object->getOrientation())
377 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++) {
378 $category = $this->
object->categories->getCategory($i);
381 $template->setCurrentBlock(
"nominal_row_sr");
383 $template->setVariable(
"ALT_RADIO", $this->lng->txt(
"unchecked"));
384 $template->setVariable(
"TITLE_RADIO", $this->lng->txt(
"unchecked"));
386 $template->parseCurrentBlock();
390 $template->setCurrentBlock(
"nominal_row_mr");
392 $template->setVariable(
"ALT_CHECKBOX", $this->lng->txt(
"unchecked"));
393 $template->setVariable(
"TITLE_CHECKBOX", $this->lng->txt(
"unchecked"));
395 $template->parseCurrentBlock();
403 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
405 $category = $this->
object->categories->getCategory($i);
406 $template->setCurrentBlock(
"radio_col_nominal");
408 $template->setVariable(
"ALT_RADIO", $this->lng->txt(
"unchecked"));
409 $template->setVariable(
"TITLE_RADIO", $this->lng->txt(
"unchecked"));
410 $template->parseCurrentBlock();
412 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
414 $category = $this->
object->categories->getCategory($i);
415 $template->setCurrentBlock(
"text_col_nominal");
417 $template->parseCurrentBlock();
422 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
424 $category = $this->
object->categories->getCategory($i);
425 $template->setCurrentBlock(
"checkbox_col_nominal");
427 $template->setVariable(
"ALT_CHECKBOX", $this->lng->txt(
"unchecked"));
428 $template->setVariable(
"TITLE_CHECKBOX", $this->lng->txt(
"unchecked"));
429 $template->parseCurrentBlock();
431 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
433 $category = $this->
object->categories->getCategory($i);
434 $template->setCurrentBlock(
"text_col_nominal_mr");
436 $template->parseCurrentBlock();
442 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
444 $category = $this->
object->categories->getCategory($i);
445 $template->setCurrentBlock(
"comborow_nominal");
447 $template->setVariable(
"VALUE_NOMINAL", $i);
448 $template->parseCurrentBlock();
450 $template->setCurrentBlock(
"combooutput_nominal");
451 $template->setVariable(
"QUESTION_ID", $this->object->getId());
452 $template->setVariable(
"SELECT_OPTION", $this->lng->txt(
"select_option"));
453 $template->setVariable(
"TEXT_SELECTION", $this->lng->txt(
"selection"));
454 $template->parseCurrentBlock();
458 if ($show_questiontext)
460 $questiontext = $this->
object->getQuestiontext();
461 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
463 if (! $this->object->getObligatory($survey_id))
465 $template->setVariable(
"OBLIGATORY_TEXT", $this->lng->txt(
"survey_question_optional"));
469 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
471 $template->parseCurrentBlock();
472 return $template->get();
484 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_preview.html",
"Modules/SurveyQuestionPool");
486 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
500 if ((!$_POST[
"title"]) or (!$_POST[
"author"]) or (!$_POST[
"question"]))
$result = 1;
503 if ($_POST[
"id"] > 0) $this->
object->setId($_POST[
"id"]);
504 include_once
"./Services/Utilities/classes/class.ilUtil.php";
508 if (strlen($_POST[
"material"]))
510 $this->
object->setMaterial($_POST[
"material"], 0,
ilUtil::stripSlashes($_POST[
"material_title"]));
512 $this->
object->setSubtype($_POST[
"type"]);
513 $this->
object->setOrientation($_POST[
"orientation"]);
514 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
516 $this->
object->setQuestiontext($questiontext);
517 if ($_POST[
"obligatory"])
519 $this->
object->setObligatory(1);
523 $this->
object->setObligatory(0);
532 $this->
object->saveToDb(
"",
false);
546 if ($this->object->getId() < 1)
548 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_category"),
true);
549 $this->ctrl->redirect($this,
"editQuestion");
551 if (strcmp($this->ctrl->getCmd(),
"categories") == 0)
$_SESSION[
"spl_modified"] =
false;
552 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_nominal_answers.html",
"Modules/SurveyQuestionPool");
554 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
556 $this->tpl->setCurrentBlock(
"cat_selector");
557 $this->tpl->setVariable(
"CATEGORY_ORDER", $i);
558 $this->tpl->parseCurrentBlock();
559 $this->tpl->setCurrentBlock(
"categories");
560 $category = $this->
object->categories->getCategory($i);
561 $this->tpl->setVariable(
"CATEGORY_ORDER", $i);
562 $this->tpl->setVariable(
"CATEGORY_NUMBER", $i+1);
563 $this->tpl->setVariable(
"VALUE_CATEGORY", $category);
564 $this->tpl->setVariable(
"TEXT_CATEGORY", $this->lng->txt(
"category"));
565 $this->tpl->parseCurrentBlock();
570 $nrOfCategories = $_POST[
"nrOfCategories"];
571 if ($nrOfCategories < 1) $nrOfCategories = 1;
573 for ($i = 1; $i <= $nrOfCategories; $i++)
575 $this->tpl->setCurrentBlock(
"categories");
576 $this->tpl->setVariable(
"CATEGORY_ORDER", $this->object->categories->getCategoryCount() + $i - 1);
577 $this->tpl->setVariable(
"TEXT_CATEGORY", $this->lng->txt(
"category"));
578 $this->tpl->parseCurrentBlock();
586 $this->tpl->setCurrentBlock(
"move_buttons");
587 $this->tpl->setVariable(
"INSERT_BEFORE", $this->lng->txt(
"insert_before"));
588 $this->tpl->setVariable(
"INSERT_AFTER", $this->lng->txt(
"insert_after"));
589 $this->tpl->parseCurrentBlock();
593 include_once
"./Services/Utilities/classes/class.ilUtil.php";
594 if ($this->object->categories->getCategoryCount() == 0)
598 $this->tpl->setCurrentBlock(
"nocategories");
599 $this->tpl->setVariable(
"NO_CATEGORIES", $this->lng->txt(
"question_contains_no_categories"));
600 $this->tpl->parseCurrentBlock();
605 $this->tpl->setCurrentBlock(
"selectall");
606 $this->tpl->setVariable(
"SELECT_ALL", $this->lng->txt(
"select_all"));
607 $this->tpl->parseCurrentBlock();
608 $this->tpl->setCurrentBlock(
"existingcategories");
609 $this->tpl->setVariable(
"DELETE", $this->lng->txt(
"delete"));
610 $this->tpl->setVariable(
"MOVE", $this->lng->txt(
"move"));
611 $this->tpl->setVariable(
"ARROW",
"<img src=\"" .
ilUtil::getImagePath(
"arrow_downright.gif") .
"\" alt=\"".$this->lng->txt(
"arrow_downright").
"\">");
612 $this->tpl->parseCurrentBlock();
615 for ($i = 1; $i < 10; $i++)
617 $this->tpl->setCurrentBlock(
"numbers");
618 $this->tpl->setVariable(
"VALUE_NUMBER", $i);
621 $this->tpl->setVariable(
"TEXT_NUMBER", $i .
" " . $this->lng->txt(
"category"));
625 $this->tpl->setVariable(
"TEXT_NUMBER", $i .
" " . $this->lng->txt(
"categories"));
627 $this->tpl->parseCurrentBlock();
630 $this->tpl->setCurrentBlock(
"adm_content");
631 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
632 $this->tpl->setVariable(
"VALUE_ADD_CATEGORY", $this->lng->txt(
"add"));
633 $this->tpl->setVariable(
"SAVE", $this->lng->txt(
"save"));
636 $this->tpl->setVariable(
"FORM_DATA_MODIFIED_PRESS_SAVE", $this->lng->txt(
"form_data_modified_press_save"));
638 $questiontext = $this->
object->getQuestiontext();
639 $this->tpl->setVariable(
"QUESTION_TEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
640 $this->tpl->parseCurrentBlock();
662 $originalexists = $this->
object->_questionExists($this->object->original_id);
663 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
664 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
672 $this->ctrl->redirect($this,
"categories");
706 $this->
object->categories->flushCategories();
710 include_once
"./Services/Utilities/classes/class.ilUtil.php";
711 foreach ($_POST as $key => $value)
713 if (preg_match(
"/^category_(\d+)/", $key, $matches))
716 if (strlen($array1[$matches[1]]) == 0) $complete =
false;
719 $this->
object->categories->addCategoryArray($array1);
722 $this->
object->saveCategoriesToDb();
737 $nothing_selected =
true;
738 if (array_key_exists(
"chb_category", $_POST))
740 if (count($_POST[
"chb_category"]))
742 $nothing_selected =
false;
743 $this->
object->categories->removeCategories($_POST[
"chb_category"]);
746 if ($nothing_selected)
ilUtil::sendInfo($this->lng->txt(
"category_delete_select_none"));
761 $nothing_selected =
true;
762 if (array_key_exists(
"chb_category", $_POST))
764 if (count($_POST[
"chb_category"]))
766 $nothing_selected =
false;
768 $_SESSION[
"spl_move"] = $_POST[
"chb_category"];
771 if ($nothing_selected)
ilUtil::sendInfo($this->lng->txt(
"no_category_selected_for_move"));
785 if (array_key_exists(
"chb_category", $_POST))
787 if (count($_POST[
"chb_category"]) == 1)
790 $this->
object->categories->removeCategories(
$_SESSION[
"spl_move"]);
791 $newinsertindex = $this->
object->categories->getCategoryIndex($_POST[
"category_".$_POST[
"chb_category"][0]]);
792 if ($newinsertindex ===
false) $newinsertindex = 0;
793 $move_categories =
$_SESSION[
"spl_move"];
794 natsort($move_categories);
795 foreach (array_reverse($move_categories) as $index)
797 $this->
object->categories->addCategoryAtPosition($_POST[
"category_$index"], $newinsertindex);
820 if (array_key_exists(
"chb_category", $_POST))
822 if (count($_POST[
"chb_category"]) == 1)
825 $this->
object->categories->removeCategories(
$_SESSION[
"spl_move"]);
826 $newinsertindex = $this->
object->categories->getCategoryIndex($_POST[
"category_".$_POST[
"chb_category"][0]]);
827 if ($newinsertindex ===
false) $newinsertindex = 0;
828 $move_categories =
$_SESSION[
"spl_move"];
829 natsort($move_categories);
830 foreach (array_reverse($move_categories) as $index)
832 $this->
object->categories->addCategoryAtPosition($_POST[
"category_$index"], $newinsertindex+1);
855 include_once
"./classes/class.ilTemplate.php";
856 if (count($this->cumulated) == 0)
858 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
860 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
862 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_row.html", TRUE, TRUE,
"Modules/Survey");
863 $template->setVariable(
"QUESTION_TITLE", ($counter+1) .
". ".$this->object->getTitle());
865 $questiontext = preg_replace(
"/<[^>]+?>/ims",
"", $this->object->getQuestiontext());
866 if (strlen($questiontext) > $maxlen + 3)
868 $questiontext = substr($questiontext, 0, $maxlen) .
"...";
870 $template->setVariable(
"QUESTION_TEXT", $questiontext);
871 $template->setVariable(
"USERS_ANSWERED", $this->cumulated[
"USERS_ANSWERED"]);
872 $template->setVariable(
"USERS_SKIPPED", $this->cumulated[
"USERS_SKIPPED"]);
873 $template->setVariable(
"QUESTION_TYPE", $this->lng->txt($this->cumulated[
"QUESTION_TYPE"]));
874 $template->setVariable(
"MODE", $this->cumulated[
"MODE"]);
875 $template->setVariable(
"MODE_NR_OF_SELECTIONS", $this->cumulated[
"MODE_NR_OF_SELECTIONS"]);
876 $template->setVariable(
"MEDIAN", $this->cumulated[
"MEDIAN"]);
877 $template->setVariable(
"ARITHMETIC_MEAN", $this->cumulated[
"ARITHMETIC_MEAN"]);
878 $template->setVariable(
"COLOR_CLASS", $css_class);
879 return $template->get();
894 if (count($this->cumulated) == 0)
896 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
898 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
902 include_once
"./classes/class.ilTemplate.php";
903 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
905 $template->setCurrentBlock(
"detail_row");
906 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
907 $questiontext = $this->
object->getQuestiontext();
908 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
909 $template->parseCurrentBlock();
910 $template->setCurrentBlock(
"detail_row");
911 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
912 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
913 $template->parseCurrentBlock();
914 $template->setCurrentBlock(
"detail_row");
915 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
916 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
917 $template->parseCurrentBlock();
918 $template->setCurrentBlock(
"detail_row");
919 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
920 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
921 $template->parseCurrentBlock();
923 $template->setCurrentBlock(
"detail_row");
924 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"subtype"));
925 switch ($this->object->getSubType())
928 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"multiple_choice_single_response"));
931 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"multiple_choice_multiple_response"));
934 $template->parseCurrentBlock();
936 $template->setCurrentBlock(
"detail_row");
937 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"mode"));
938 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MODE"]);
939 $template->parseCurrentBlock();
940 $template->setCurrentBlock(
"detail_row");
941 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"mode_nr_of_selections"));
942 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MODE_NR_OF_SELECTIONS"]);
943 $template->parseCurrentBlock();
945 $template->setCurrentBlock(
"detail_row");
946 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"categories"));
948 if (is_array($this->cumulated[
"variables"]))
950 foreach ($this->cumulated[
"variables"] as $key => $value)
952 $categories .=
"<li>" . $this->lng->txt(
"title") .
":" .
"<span class=\"bold\">" . $value[
"title"] .
"</span><br />" .
953 $this->lng->txt(
"category_nr_selected") .
": " .
"<span class=\"bold\">" . $value[
"selected"] .
"</span><br />" .
954 $this->lng->txt(
"percentage_of_selections") .
": " .
"<span class=\"bold\">" . sprintf(
"%.2f", 100*$value[
"percentage"]) .
"</span></li>";
957 $categories =
"<ol>$categories</ol>";
958 $template->setVariable(
"TEXT_OPTION_VALUE", $categories);
959 $template->parseCurrentBlock();
962 $template->setCurrentBlock(
"chart");
963 $template->setVariable(
"TEXT_CHART", $this->lng->txt(
"chart"));
964 $template->setVariable(
"ALT_CHART",
$data[
"title"] .
"( " . $this->lng->txt(
"chart") .
")");
967 include_once
"./Services/Administration/classes/class.ilSetting.php";
968 $surveySetting =
new ilSetting(
"survey");
969 if ($surveySetting->get(
"googlechart") == 1)
971 $chartcolors = array(
"2A4BD7",
"9DAFFF",
"1D6914",
"81C57A",
"814A19",
"E9DEBB",
"8126C0",
"AD2323",
"29D0D0",
"FFEE33",
"FF9233",
"FFCDF3",
"A0A0A0",
"575757",
"000000");
972 $selections = array();
975 foreach ($this->cumulated[
"variables"] as $val)
977 if ($val[
"selected"] > $maxselection) $maxselection = $val[
"selected"];
978 array_push($selections, $val[
"selected"]);
979 array_push($values, str_replace(
" ",
"+", $val[
"title"]));
982 if ($maxselection % 2 == 0)
984 $selectionlabels =
"0|" . ($maxselection / 2) .
"|$maxselection";
988 $selectionlabels =
"0|$maxselection";
990 $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)+1.5)) .
"&chdl=" . implode(
"|", $values) .
"&chdlp=b";
994 $this->ctrl->setParameterByClass(
"ilsurveyevaluationgui",
"survey", $survey_id);
995 $this->ctrl->setParameterByClass(
"ilsurveyevaluationgui",
"question", $this->object->getId());
996 $charturl = $this->ctrl->getLinkTargetByClass(
"ilsurveyevaluationgui",
"outChart");
998 $template->setVariable(
"CHART", $charturl);
999 $template->parseCurrentBlock();
1001 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
1002 return $template->get();