24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
41 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveySingleChoiceQuestion.php";
60 $orientation->addOption(
new ilRadioOption($this->lng->txt(
'vertical'), 0));
61 $orientation->addOption(
new ilRadioOption($this->lng->txt(
'horizontal'), 1));
62 $orientation->addOption(
new ilRadioOption($this->lng->txt(
'combobox'), 2));
66 include_once
"./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
69 $answers->setAllowMove(
true);
70 $answers->setShowWizard(
true);
71 $answers->setShowSavePhrase(
true);
72 $answers->setUseOtherAnswer(
true);
73 $answers->setShowNeutralCategory(
true);
74 $answers->setNeutralCategoryTitle($this->lng->txt(
'svy_neutral_answer'));
75 $answers->setDisabledScale(
false);
79 $orientation->setValue($this->object->getOrientation());
80 if (!$this->object->getCategories()->getCategoryCount())
82 $this->
object->getCategories()->addCategory(
"");
84 $answers->setValues($this->object->getCategories());
89 $this->
object->setOrientation($a_form->
getInput(
"orientation"));
91 $this->
object->categories->flushCategories();
93 foreach (
$_POST[
'answers'][
'answer'] as $key => $value)
95 if (strlen($value)) $this->
object->getCategories()->addCategory($value,
$_POST[
'answers'][
'other'][$key], 0, null,
$_POST[
'answers'][
'scale'][$key]);
97 if (strlen(
$_POST[
'answers'][
'neutral']))
99 $this->
object->getCategories()->addCategory(
$_POST[
'answers'][
'neutral'], 0, 1, null,
$_POST[
'answers_neutral_scale']);
103 public function getParsedAnswers(array $a_working_data = null, $a_only_user_anwers =
false)
105 if(is_array($a_working_data))
107 $user_answer = $a_working_data[0];
111 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
113 $cat = $this->
object->categories->getCategory($i);
114 $value = ($cat->scale) ? ($cat->scale - 1) : $i;
116 $checked =
"unchecked";
118 if(is_array($a_working_data) &&
119 is_array($user_answer))
121 if($value == $user_answer[
"value"])
123 $checked =
"checked";
124 if($user_answer[
"textanswer"])
126 $text = $user_answer[
"textanswer"];
132 $idx = $cat->other.
"_".$value;
134 if(!$a_only_user_anwers || $checked ==
"checked")
138 ,
"title" => trim($cat->title)
139 ,
"other" => (
bool)$cat->other
140 ,
"checked" => $checked
141 ,
"textanswer" => $text
156 function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null, array $a_working_data = null)
162 $template =
new ilTemplate(
"tpl.il_svy_qpl_sc_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
163 switch ($this->object->orientation)
169 if ($option[
"other"])
171 $template->setCurrentBlock(
"other_row");
173 $template->setVariable(
"ALT_RADIO", $this->lng->txt($option[
"checked"]));
174 $template->setVariable(
"TITLE_RADIO", $this->lng->txt($option[
"checked"]));
176 $template->setVariable(
"OTHER_ANSWER", $option[
"textanswer"]
178 :
" ");
179 $template->parseCurrentBlock();
184 $template->setCurrentBlock(
"row");
186 $template->setVariable(
"ALT_RADIO", $this->lng->txt($option[
"checked"]));
187 $template->setVariable(
"TITLE_RADIO", $this->lng->txt($option[
"checked"]));
189 $template->parseCurrentBlock();
197 $template->setCurrentBlock(
"radio_col");
199 $template->setVariable(
"ALT_RADIO", $this->lng->txt($option[
"checked"]));
200 $template->setVariable(
"TITLE_RADIO", $this->lng->txt($option[
"checked"]));
201 $template->parseCurrentBlock();
205 if ($option[
"other"])
207 $template->setCurrentBlock(
"other_text_col");
209 $template->setVariable(
"OTHER_ANSWER", $option[
"textanswer"]
211 :
" ");
212 $template->parseCurrentBlock();
216 $template->setCurrentBlock(
"text_col");
218 $template->parseCurrentBlock();
225 $template->setCurrentBlock(
"comborow");
227 $template->setVariable(
"VALUE_SC", $option[
"value"]);
228 if($option[
"checked"] ==
"checked")
230 $template->setVariable(
"SELECTED_SC",
' selected="selected"');
232 $template->parseCurrentBlock();
234 $template->setCurrentBlock(
"combooutput");
235 $template->setVariable(
"QUESTION_ID", $this->object->getId());
236 $template->setVariable(
"SELECT_OPTION", $this->lng->txt(
"select_option"));
237 $template->setVariable(
"TEXT_SELECTION", $this->lng->txt(
"selection"));
238 $template->parseCurrentBlock();
243 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
245 if ($show_questiontext)
249 $template->parseCurrentBlock();
250 return $template->get();
263 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
265 $template =
new ilTemplate(
"tpl.il_svy_out_sc.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
266 $template->setCurrentBlock(
"material");
268 $template->parseCurrentBlock();
269 switch ($this->object->orientation)
273 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
275 $cat = $this->
object->categories->getCategory($i);
278 $template->setCurrentBlock(
"other_row");
279 if (strlen($cat->title))
281 $template->setVariable(
"OTHER_LABEL", $cat->title);
283 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
284 $template->setVariable(
"QUESTION_ID", $this->object->getId());
285 if (is_array($working_data))
287 foreach ($working_data as $value)
289 if (strlen($value[
"value"]))
291 if ($value[
"value"] == $cat->scale-1)
293 if (strlen($value[
'textanswer'])) $template->setVariable(
"OTHER_VALUE",
' value="' .
ilUtil::prepareFormOutput($value[
'textanswer']) .
'"');
294 if (!$value[
'uncheck'])
296 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
302 $template->parseCurrentBlock();
306 $template->setCurrentBlock(
"row");
307 if ($cat->neutral) $template->setVariable(
'ROWCLASS',
' class="neutral"');
309 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
310 $template->setVariable(
"QUESTION_ID", $this->object->getId());
311 if (is_array($working_data))
313 foreach ($working_data as $value)
315 if (strcmp($value[
"value"],
"") != 0)
317 if ($value[
"value"] == $cat->scale-1)
319 if (!$value[
'uncheck'])
321 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
327 $template->parseCurrentBlock();
329 $template->touchBlock(
'outer_row');
334 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
336 $cat = $this->
object->categories->getCategory($i);
337 $template->setCurrentBlock(
"radio_col");
338 if ($cat->neutral) $template->setVariable(
'COLCLASS',
' neutral');
339 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
340 $template->setVariable(
"QUESTION_ID", $this->object->getId());
341 if (is_array($working_data))
343 foreach ($working_data as $value)
345 if (strcmp($value[
"value"],
"") != 0)
347 if ($value[
"value"] == $cat->scale-1)
349 if (!$value[
'uncheck'])
351 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
357 $template->parseCurrentBlock();
359 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
361 $cat = $this->
object->categories->getCategory($i);
364 $template->setCurrentBlock(
"text_other_col");
365 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
366 $template->setVariable(
"QUESTION_ID", $this->object->getId());
367 if (strlen($cat->title))
369 $template->setVariable(
"OTHER_LABEL", $cat->title);
371 if (is_array($working_data))
373 foreach ($working_data as $value)
375 if (strlen($value[
"value"]))
377 if ($value[
"value"] == $cat->scale-1 && strlen($value[
'textanswer']))
384 $template->parseCurrentBlock();
388 $template->setCurrentBlock(
"text_col");
389 if ($cat->neutral) $template->setVariable(
'COLCLASS',
' neutral');
390 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
392 $template->setVariable(
"QUESTION_ID", $this->object->getId());
393 $template->parseCurrentBlock();
395 $template->touchBlock(
'text_outer_col');
400 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
402 $cat = $this->
object->categories->getCategory($i);
403 $template->setCurrentBlock(
"comborow");
404 $template->setVariable(
"TEXT_SC", $cat->title);
405 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
406 if (is_array($working_data))
408 if (strcmp($working_data[0][
"value"],
"") != 0)
410 if ($working_data[0][
"value"] == $cat->scale-1)
412 $template->setVariable(
"SELECTED_SC",
" selected=\"selected\"");
416 $template->parseCurrentBlock();
418 $template->setCurrentBlock(
"combooutput");
419 $template->setVariable(
"QUESTION_ID", $this->object->getId());
420 $template->setVariable(
"SELECT_OPTION", $this->lng->txt(
"select_option"));
421 $template->setVariable(
"TEXT_SELECTION", $this->lng->txt(
"selection"));
422 $template->parseCurrentBlock();
427 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
429 $template->setCurrentBlock(
"question_data");
430 if (strcmp($error_message,
"") != 0)
432 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
434 if ($show_questiontext)
438 $template->parseCurrentBlock();
439 return $template->get();
457 if (count($this->cumulated) == 0)
461 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
466 $nr_of_users =
sizeof($finished_ids);
468 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users, $finished_ids);
471 include_once
"./Services/UICore/classes/class.ilTemplate.php";
472 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
474 $template->setCurrentBlock(
"detail_row");
475 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
476 $questiontext = $this->
object->getQuestiontext();
477 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
478 $template->parseCurrentBlock();
479 $template->setCurrentBlock(
"detail_row");
480 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
481 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
482 $template->parseCurrentBlock();
483 $template->setCurrentBlock(
"detail_row");
484 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
485 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
486 $template->parseCurrentBlock();
487 $template->setCurrentBlock(
"detail_row");
488 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
489 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
490 $template->parseCurrentBlock();
501 $template->setCurrentBlock(
"detail_row");
502 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"median"));
503 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MEDIAN"]);
504 $template->parseCurrentBlock();
506 $template->setCurrentBlock(
"detail_row");
507 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"categories"));
509 foreach ($this->cumulated[
"variables"] as $key => $value)
511 $categories .=
"<li>" . $value[
"title"] .
": n=" . $value[
"selected"] .
512 " (" . sprintf(
"%.2f", 100*$value[
"percentage"]) .
"%)</li>";
514 $categories =
"<ol>$categories</ol>";
515 $template->setVariable(
"TEXT_OPTION_VALUE", $categories);
516 $template->parseCurrentBlock();
519 if (is_array($this->cumulated[
"textanswers"]))
521 $template->setCurrentBlock(
"detail_row");
522 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"freetext_answers"));
524 foreach ($this->cumulated[
"textanswers"] as $key => $answers)
526 $html .= $this->cumulated[
"variables"][$key][
"title"] .
"\n";
528 foreach ($answers as $answer)
530 $html .=
"<li>" . preg_replace(
"/\n/",
"<br>\n", $answer) .
"</li>\n";
534 $template->setVariable(
"TEXT_OPTION_VALUE", $html);
535 $template->parseCurrentBlock();
539 $template->setCurrentBlock(
"detail_row");
540 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"chart"));
541 $template->setVariable(
"TEXT_OPTION_VALUE", $this->
renderChart(
"svy_ch_".$this->object->getId(), $this->cumulated[
"variables"]));
542 $template->parseCurrentBlock();
544 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
545 return $template->get();