ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.SurveyMultipleChoiceQuestionGUI.php
Go to the documentation of this file.
1 <?php
2  /*
3  +----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +----------------------------------------------------------------------------+
22 */
23 
24 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
25 include_once "./Modules/Survey/classes/inc.SurveyConstants.php";
26 
39 {
40 
50  $id = -1
51  )
52 
53  {
54  $this->SurveyQuestionGUI();
55  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyMultipleChoiceQuestion.php";
56  $this->object = new SurveyMultipleChoiceQuestion();
57  if ($id >= 0)
58  {
59  $this->object->loadFromDb($id);
60  }
61  }
62 
69  function writePostData($always = false)
70  {
71  $hasErrors = (!$always) ? $this->editQuestion(true) : false;
72  if (!$hasErrors)
73  {
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->use_other_answer = ($_POST['use_other_answer']) ? 1 : 0;
83  $this->object->other_answer_label = ($this->object->use_other_answer) ? $_POST['other_answer_label'] : null;
84  $this->object->use_min_answers = ($_POST['use_min_answers']) ? true : false;
85  $this->object->nr_min_answers = ($_POST['nr_min_answers'] > 0) ? $_POST['nr_min_answers'] : null;
86  $this->object->nr_max_answers = ($_POST['nr_max_answers'] > 0) ? $_POST['nr_max_answers'] : null;
87  $this->object->label = $_POST['label'];
88 
89  $this->object->categories->flushCategories();
90 
91  foreach ($_POST['answers']['answer'] as $key => $value)
92  {
93  if (strlen($value)) $this->object->getCategories()->addCategory($value, $_POST['answers']['other'][$key], 0, null, $_POST['answers']['scale'][$key]);
94  }
95  if (strlen($_POST['answers']['neutral']))
96  {
97  $this->object->getCategories()->addCategory($_POST['answers']['neutral'], 0, 1, null, $_POST['answers_neutral_scale']);
98  }
99  return 0;
100  }
101  else
102  {
103  return 1;
104  }
105  }
106 
112  public function editQuestion($checkonly = FALSE)
113  {
114  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
115  $form = new ilPropertyFormGUI();
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("multiplechoice");
121 
122  // title
123  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
124  $title->setValue($this->object->getTitle());
125  $title->setRequired(TRUE);
126  $form->addItem($title);
127 
128  // label
129  $label = new ilTextInputGUI($this->lng->txt("label"), "label");
130  $label->setValue($this->object->label);
131  $label->setInfo($this->lng->txt("label_info"));
132  $label->setRequired(false);
133  $form->addItem($label);
134 
135  // author
136  $author = new ilTextInputGUI($this->lng->txt("author"), "author");
137  $author->setValue($this->object->getAuthor());
138  $author->setRequired(TRUE);
139  $form->addItem($author);
140 
141  // description
142  $description = new ilTextInputGUI($this->lng->txt("description"), "description");
143  $description->setValue($this->object->getDescription());
144  $description->setRequired(FALSE);
145  $form->addItem($description);
146 
147  // questiontext
148  $question = new ilTextAreaInputGUI($this->lng->txt("question"), "question");
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";
155  $question->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
156  $question->addPlugin("latex");
157  $question->addButton("latex");
158  $question->addButton("pastelatex");
159  $question->removePlugin("ibrowser");
160  $question->setRTESupport($this->object->getId(), "spl", "survey", null, false, "3.4.7");
161  $form->addItem($question);
162 
163  // obligatory
164  $shuffle = new ilCheckboxInputGUI($this->lng->txt("obligatory"), "obligatory");
165  $shuffle->setValue(1);
166  $shuffle->setChecked($this->object->getObligatory());
167  $shuffle->setRequired(FALSE);
168  $form->addItem($shuffle);
169 
170  // orientation
171  $orientation = new ilRadioGroupInputGUI($this->lng->txt("orientation"), "orientation");
172  $orientation->setRequired(false);
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  $form->addItem($orientation);
177 
178  // minimum answers
179  $minanswers = new ilCheckboxInputGUI($this->lng->txt("use_min_answers"), "use_min_answers");
180  $minanswers->setValue(1);
181  $minanswers->setOptionTitle($this->lng->txt("use_min_answers_option"));
182  $minanswers->setChecked($this->object->use_min_answers);
183  $minanswers->setRequired(FALSE);
184  $nranswers = new ilNumberInputGUI($this->lng->txt("nr_min_answers"), "nr_min_answers");
185  $nranswers->setSize(5);
186  $nranswers->setDecimals(0);
187  $nranswers->setRequired(false);
188  $nranswers->setMinValue(1);
189  $nranswers->setValue($this->object->nr_min_answers);
190  $minanswers->addSubItem($nranswers);
191  $nrmaxanswers = new ilNumberInputGUI($this->lng->txt("nr_max_answers"), "nr_max_answers");
192  $nrmaxanswers->setSize(5);
193  $nrmaxanswers->setDecimals(0);
194  $nrmaxanswers->setRequired(false);
195  $nrmaxanswers->setMinValue(1);
196  $nrmaxanswers->setValue($this->object->nr_max_answers);
197  $minanswers->addSubItem($nrmaxanswers);
198  $form->addItem($minanswers);
199 
200  // Answers
201  include_once "./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
202  $answers = new ilCategoryWizardInputGUI($this->lng->txt("answers"), "answers");
203  $answers->setRequired(false);
204  $answers->setAllowMove(true);
205  $answers->setShowWizard(false);
206  $answers->setShowSavePhrase(false);
207  $answers->setUseOtherAnswer(true);
208  $answers->setShowNeutralCategory(true);
209  $answers->setNeutralCategoryTitle($this->lng->txt('matrix_neutral_answer'));
210  if (!$this->object->getCategories()->getCategoryCount())
211  {
212  $this->object->getCategories()->addCategory("");
213  }
214  $answers->setValues($this->object->getCategories());
215  $answers->setDisabledScale(false);
216  $form->addItem($answers);
217 
218  $this->addCommandButtons($form);
219 
220  $errors = false;
221 
222  if ($this->isSaveCommand())
223  {
224  $form->setValuesByPost();
225  $errors = !$form->checkInput();
226  $form->setValuesByPost(); // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
227  if ($nranswers->getValue() > $answers->getCategoryCount())
228  {
229  $nrmaxanswers->setAlert($this->lng->txt('err_minvalueganswers'));
230  if (!$errors)
231  {
232  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
233  }
234  $errors = true;
235  }
236  if ($nrmaxanswers->getValue() > 0 && ($nrmaxanswers->getValue() > $answers->getCategoryCount() || $nrmaxanswers->getValue() < $nranswers->getValue()))
237  {
238  $nrmaxanswers->setAlert($this->lng->txt('err_maxvaluegeminvalue'));
239  if (!$errors)
240  {
241  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
242  }
243  $errors = true;
244  }
245  if ($errors) $checkonly = false;
246  }
247 
248  if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
249  return $errors;
250  }
251 
255  public function addanswers()
256  {
257  $this->writePostData(true);
258  $position = key($_POST['cmd']['addanswers']);
259  $this->object->getCategories()->addCategoryAtPosition("", $position+1);
260  $this->editQuestion();
261  }
262 
266  public function removeanswers()
267  {
268  $this->writePostData(true);
269  $position = key($_POST['cmd']['removeanswers']);
270  $this->object->getCategories()->removeCategory($position);
271  $this->editQuestion();
272  }
273 
277  public function upanswers()
278  {
279  $this->writePostData(true);
280  $position = key($_POST['cmd']['upanswers']);
281  $this->object->getCategories()->moveCategoryUp($position);
282  $this->editQuestion();
283  }
284 
288  public function downanswers()
289  {
290  $this->writePostData(true);
291  $position = key($_POST['cmd']['downanswers']);
292  $this->object->getCategories()->moveCategoryDown($position);
293  $this->editQuestion();
294  }
295 
301  function getWorkingForm($working_data = "", $question_title = 1, $show_questiontext = 1, $error_message = "", $survey_id = null)
302  {
303  $template = new ilTemplate("tpl.il_svy_out_mc.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
304  $template->setCurrentBlock("material");
305  $template->setVariable("TEXT_MATERIAL", $this->getMaterialOutput());
306  $template->parseCurrentBlock();
307  switch ($this->object->getOrientation())
308  {
309  case 0:
310  // vertical orientation
311  for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++)
312  {
313  $cat = $this->object->categories->getCategory($i);
314  if ($cat->other)
315  {
316  $template->setCurrentBlock("other_row");
317  if (strlen($cat->title))
318  {
319  $template->setVariable("OTHER_LABEL", $cat->title);
320  }
321  $template->setVariable("VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
322  $template->setVariable("QUESTION_ID", $this->object->getId());
323  if (is_array($working_data))
324  {
325  foreach ($working_data as $value)
326  {
327  if (strlen($value["value"]))
328  {
329  if ($value["value"] == $cat->scale-1)
330  {
331  $template->setVariable("OTHER_VALUE", ' value="' . ilUtil::prepareFormOutput($value['textanswer']) . '"');
332  if (!$value['uncheck'])
333  {
334  $template->setVariable("CHECKED_MC", " checked=\"checked\"");
335  }
336  }
337  }
338  }
339  }
340  $template->parseCurrentBlock();
341  }
342  else
343  {
344  $template->setCurrentBlock("mc_row");
345  if ($cat->neutral) $template->setVariable('ROWCLASS', ' class="neutral"');
346  $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($cat->title));
347  $template->setVariable("VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
348  $template->setVariable("QUESTION_ID", $this->object->getId());
349  if (is_array($working_data))
350  {
351  foreach ($working_data as $value)
352  {
353  if (strlen($value["value"]))
354  {
355  if ($value["value"] == $cat->scale-1)
356  {
357  if (!$value['uncheck'])
358  {
359  $template->setVariable("CHECKED_MC", " checked=\"checked\"");
360  }
361  }
362  }
363  }
364  }
365  $template->parseCurrentBlock();
366  }
367  $template->touchBlock('outer_row');
368  }
369  break;
370  case 1:
371  // horizontal orientation
372  for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++)
373  {
374  $cat = $this->object->categories->getCategory($i);
375  $template->setCurrentBlock("checkbox_col");
376  if ($cat->neutral) $template->setVariable('COLCLASS', ' neutral');
377  $template->setVariable("VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
378  $template->setVariable("QUESTION_ID", $this->object->getId());
379  if (is_array($working_data))
380  {
381  foreach ($working_data as $value)
382  {
383  if (strlen($value["value"]))
384  {
385  if ($value["value"] == $cat->scale-1)
386  {
387  if (!$value['uncheck'])
388  {
389  $template->setVariable("CHECKED_MC", " checked=\"checked\"");
390  }
391  }
392  }
393  }
394  }
395  $template->parseCurrentBlock();
396  }
397  for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++)
398  {
399  $cat = $this->object->categories->getCategory($i);
400  if ($cat->other)
401  {
402  $template->setCurrentBlock("text_other_col");
403  $template->setVariable("VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
404  $template->setVariable("QUESTION_ID", $this->object->getId());
405  if (strlen($cat->title))
406  {
407  $template->setVariable("OTHER_LABEL", $cat->title);
408  }
409  if (is_array($working_data))
410  {
411  foreach ($working_data as $value)
412  {
413  if (strlen($value["value"]))
414  {
415  if ($value["value"] == $cat->scale-1)
416  {
417  $template->setVariable("OTHER_VALUE", ' value="' . ilUtil::prepareFormOutput($value['textanswer']) . '"');
418  }
419  }
420  }
421  }
422  $template->parseCurrentBlock();
423  }
424  else
425  {
426  $category = $this->object->categories->getCategory($i);
427  $template->setCurrentBlock("text_col");
428  if ($cat->neutral) $template->setVariable('COLCLASS', ' neutral');
429  $template->setVariable("VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
430  $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($cat->title));
431  $template->setVariable("QUESTION_ID", $this->object->getId());
432  $template->parseCurrentBlock();
433  }
434  $template->touchBlock('text_outer_col');
435  }
436  break;
437  }
438 
439  $template->setCurrentBlock("question_data");
440  if ($this->object->use_min_answers)
441  {
442  $template->setCurrentBlock('min_max_msg');
443  if ($this->object->nr_min_answers > 0 && $this->object->nr_max_answers > 0)
444  {
445  if ($this->object->nr_min_answers == $this->object->nr_max_answers)
446  {
447  $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_max_exact_answers'), $this->object->nr_min_answers));
448  }
449  else
450  {
451  $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_max_nr_answers'), $this->object->nr_min_answers, $this->object->nr_max_answers));
452  }
453  }
454  else if ($this->object->nr_min_answers > 0)
455  {
456  $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_nr_answers'), $this->object->nr_min_answers));
457  }
458  else if ($this->object->nr_max_answers > 0)
459  {
460  $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_max_nr_answers'), $this->object->nr_max_answers));
461  }
462  $template->parseCurrentBlock();
463  }
464  if (strcmp($error_message, "") != 0)
465  {
466  $template->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
467  }
468  if ($show_questiontext)
469  {
470  $this->outQuestionText($template);
471  }
472  if ($question_title)
473  {
474  $template->setVariable("QUESTION_TITLE", $this->object->getTitle());
475  }
476  $template->parseCurrentBlock();
477  return $template->get();
478  }
479 
485  function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null)
486  {
487  $template = new ilTemplate("tpl.il_svy_qpl_mc_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
488  switch ($this->object->getOrientation())
489  {
490  case 0:
491  // vertical orientation
492  for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++)
493  {
494  $cat = $this->object->categories->getCategory($i);
495  if ($cat->other)
496  {
497  $template->setCurrentBlock("other_row");
498  $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.gif")));
499  $template->setVariable("ALT_CHECKBOX", $this->lng->txt("unchecked"));
500  $template->setVariable("TITLE_CHECKBOX", $this->lng->txt("unchecked"));
501  $template->setVariable("OTHER_LABEL", ilUtil::prepareFormOutput($cat->title));
502  $template->setVariable("OTHER_ANSWER", "&nbsp;");
503  $template->parseCurrentBlock();
504  }
505  else
506  {
507  $template->setCurrentBlock("mc_row");
508  $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.gif")));
509  $template->setVariable("ALT_CHECKBOX", $this->lng->txt("unchecked"));
510  $template->setVariable("TITLE_CHECKBOX", $this->lng->txt("unchecked"));
511  $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($cat->title));
512  $template->parseCurrentBlock();
513  }
514  }
515  break;
516  case 1:
517  // horizontal orientation
518  for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++)
519  {
520  $template->setCurrentBlock("checkbox_col");
521  $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.gif")));
522  $template->setVariable("ALT_CHECKBOX", $this->lng->txt("unchecked"));
523  $template->setVariable("TITLE_CHECKBOX", $this->lng->txt("unchecked"));
524  $template->parseCurrentBlock();
525  }
526  for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++)
527  {
528  $cat = $this->object->categories->getCategory($i);
529  if ($cat->other)
530  {
531  $template->setCurrentBlock("other_text_col");
532  $template->setVariable("OTHER_LABEL", ilUtil::prepareFormOutput($cat->title));
533  $template->setVariable("OTHER_ANSWER", "&nbsp;");
534  $template->parseCurrentBlock();
535  }
536  else
537  {
538  $template->setCurrentBlock("text_col");
539  $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($cat->title));
540  $template->parseCurrentBlock();
541  }
542  }
543  break;
544  }
545 
546  if ($this->object->use_min_answers)
547  {
548  $template->setCurrentBlock('min_max_msg');
549  if ($this->object->nr_min_answers > 0 && $this->object->nr_max_answers > 0)
550  {
551  $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_max_nr_answers'), $this->object->nr_min_answers, $this->object->nr_max_answers));
552  }
553  else if ($this->object->nr_min_answers > 0)
554  {
555  $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_nr_answers'), $this->object->nr_min_answers));
556  }
557  else if ($this->object->nr_max_answers > 0)
558  {
559  $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_max_nr_answers'), $this->object->nr_max_answers));
560  }
561  $template->parseCurrentBlock();
562  }
563  if ($show_questiontext)
564  {
565  $this->outQuestionText($template);
566  }
567  if ($question_title)
568  {
569  $template->setVariable("QUESTION_TITLE", $this->object->getTitle());
570  }
571  $template->parseCurrentBlock();
572  return $template->get();
573  }
574 
575  function setQuestionTabs()
576  {
577  $this->setQuestionTabsForClass("surveymultiplechoicequestiongui");
578  }
579 
588  function getCumulatedResultsDetails($survey_id, $counter)
589  {
590  if (count($this->cumulated) == 0)
591  {
592  include_once "./Modules/Survey/classes/class.ilObjSurvey.php";
593  $nr_of_users = ilObjSurvey::_getNrOfParticipants($survey_id);
594  $this->cumulated =& $this->object->getCumulatedResults($survey_id, $nr_of_users);
595  }
596 
597  $output = "";
598  include_once "./classes/class.ilTemplate.php";
599  $template = new ilTemplate("tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE, "Modules/Survey");
600 
601  $template->setCurrentBlock("detail_row");
602  $template->setVariable("TEXT_OPTION", $this->lng->txt("question"));
603  $questiontext = $this->object->getQuestiontext();
604  $template->setVariable("TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
605  $template->parseCurrentBlock();
606  $template->setCurrentBlock("detail_row");
607  $template->setVariable("TEXT_OPTION", $this->lng->txt("question_type"));
608  $template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
609  $template->parseCurrentBlock();
610  $template->setCurrentBlock("detail_row");
611  $template->setVariable("TEXT_OPTION", $this->lng->txt("users_answered"));
612  $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_ANSWERED"]);
613  $template->parseCurrentBlock();
614  $template->setCurrentBlock("detail_row");
615  $template->setVariable("TEXT_OPTION", $this->lng->txt("users_skipped"));
616  $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_SKIPPED"]);
617  $template->parseCurrentBlock();
618  /*
619  $template->setCurrentBlock("detail_row");
620  $template->setVariable("TEXT_OPTION", $this->lng->txt("mode"));
621  $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MODE"]);
622  $template->parseCurrentBlock();
623  $template->setCurrentBlock("detail_row");
624  $template->setVariable("TEXT_OPTION", $this->lng->txt("mode_nr_of_selections"));
625  $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MODE_NR_OF_SELECTIONS"]);
626  $template->parseCurrentBlock();
627  */
628  $template->setCurrentBlock("detail_row");
629  $template->setVariable("TEXT_OPTION", $this->lng->txt("categories"));
630  $categories = "";
631  if (is_array($this->cumulated["variables"]))
632  {
633  foreach ($this->cumulated["variables"] as $key => $value)
634  {
635  $categories .= "<li>" . $value["title"] . ": n=" . $value["selected"] .
636  " (" . sprintf("%.2f", 100*$value["percentage"]) . "%)</li>";
637  }
638  }
639  $categories = "<ol>$categories</ol>";
640  $template->setVariable("TEXT_OPTION_VALUE", $categories);
641  $template->parseCurrentBlock();
642 
643  // add text answers to detailed results
644  if (is_array($this->cumulated["textanswers"]))
645  {
646  $template->setCurrentBlock("detail_row");
647  $template->setVariable("TEXT_OPTION", $this->lng->txt("freetext_answers"));
648  $html = "";
649  foreach ($this->cumulated["textanswers"] as $key => $answers)
650  {
651  $html .= $this->cumulated["variables"][$key]["title"] ."\n";
652  $html .= "<ul>\n";
653  foreach ($answers as $answer)
654  {
655  $html .= "<li>" . preg_replace("/\n/", "<br>\n", $answer) . "</li>\n";
656  }
657  $html .= "</ul>\n";
658  }
659  $template->setVariable("TEXT_OPTION_VALUE", $html);
660  $template->parseCurrentBlock();
661  }
662 
663  // chart
664  $template->setCurrentBlock("detail_row");
665  $template->setVariable("TEXT_OPTION", $this->lng->txt("chart"));
666  $template->setVariable("TEXT_OPTION_VALUE", $this->renderChart("svy_ch_".$this->object->getId(), $this->cumulated["variables"]));
667  $template->parseCurrentBlock();
668 
669  $template->setVariable("QUESTION_TITLE", "$counter. ".$this->object->getTitle());
670  return $template->get();
671  }
672 
673 
674 }
675 ?>