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']);
108 function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null)
110 $template =
new ilTemplate(
"tpl.il_svy_qpl_sc_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
111 switch ($this->object->orientation)
115 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
117 $cat = $this->
object->categories->getCategory($i);
120 $template->setCurrentBlock(
"other_row");
122 $template->setVariable(
"ALT_RADIO", $this->lng->txt(
"unchecked"));
123 $template->setVariable(
"TITLE_RADIO", $this->lng->txt(
"unchecked"));
125 $template->setVariable(
"OTHER_ANSWER",
" ");
126 $template->parseCurrentBlock();
130 $template->setCurrentBlock(
"row");
132 $template->setVariable(
"ALT_RADIO", $this->lng->txt(
"unchecked"));
133 $template->setVariable(
"TITLE_RADIO", $this->lng->txt(
"unchecked"));
135 $template->parseCurrentBlock();
141 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
143 $template->setCurrentBlock(
"radio_col");
145 $template->setVariable(
"ALT_RADIO", $this->lng->txt(
"unchecked"));
146 $template->setVariable(
"TITLE_RADIO", $this->lng->txt(
"unchecked"));
147 $template->parseCurrentBlock();
149 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
151 $cat = $this->
object->categories->getCategory($i);
154 $template->setCurrentBlock(
"other_text_col");
156 $template->setVariable(
"OTHER_ANSWER",
" ");
157 $template->parseCurrentBlock();
161 $template->setCurrentBlock(
"text_col");
163 $template->parseCurrentBlock();
169 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
171 $cat = $this->
object->categories->getCategory($i);
172 $template->setCurrentBlock(
"comborow");
174 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
175 if (is_array($working_data))
177 if (strcmp($working_data[0][
"value"],
"") != 0)
179 if ($working_data[0][
"value"] == $i)
181 $template->setVariable(
"SELECTED_SC",
" selected=\"selected\"");
185 $template->parseCurrentBlock();
187 $template->setCurrentBlock(
"combooutput");
188 $template->setVariable(
"QUESTION_ID", $this->object->getId());
189 $template->setVariable(
"SELECT_OPTION", $this->lng->txt(
"select_option"));
190 $template->setVariable(
"TEXT_SELECTION", $this->lng->txt(
"selection"));
191 $template->parseCurrentBlock();
196 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
198 if ($show_questiontext)
202 $template->parseCurrentBlock();
203 return $template->get();
216 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
218 $template =
new ilTemplate(
"tpl.il_svy_out_sc.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
219 $template->setCurrentBlock(
"material");
221 $template->parseCurrentBlock();
222 switch ($this->object->orientation)
226 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
228 $cat = $this->
object->categories->getCategory($i);
231 $template->setCurrentBlock(
"other_row");
232 if (strlen($cat->title))
234 $template->setVariable(
"OTHER_LABEL", $cat->title);
236 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
237 $template->setVariable(
"QUESTION_ID", $this->object->getId());
238 if (is_array($working_data))
240 foreach ($working_data as $value)
242 if (strlen($value[
"value"]))
244 if ($value[
"value"] == $cat->scale-1)
246 if (strlen($value[
'textanswer'])) $template->setVariable(
"OTHER_VALUE",
' value="' .
ilUtil::prepareFormOutput($value[
'textanswer']) .
'"');
247 if (!$value[
'uncheck'])
249 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
255 $template->parseCurrentBlock();
259 $template->setCurrentBlock(
"row");
260 if ($cat->neutral) $template->setVariable(
'ROWCLASS',
' class="neutral"');
262 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
263 $template->setVariable(
"QUESTION_ID", $this->object->getId());
264 if (is_array($working_data))
266 foreach ($working_data as $value)
268 if (strcmp($value[
"value"],
"") != 0)
270 if ($value[
"value"] == $cat->scale-1)
272 if (!$value[
'uncheck'])
274 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
280 $template->parseCurrentBlock();
282 $template->touchBlock(
'outer_row');
287 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
289 $cat = $this->
object->categories->getCategory($i);
290 $template->setCurrentBlock(
"radio_col");
291 if ($cat->neutral) $template->setVariable(
'COLCLASS',
' neutral');
292 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
293 $template->setVariable(
"QUESTION_ID", $this->object->getId());
294 if (is_array($working_data))
296 foreach ($working_data as $value)
298 if (strcmp($value[
"value"],
"") != 0)
300 if ($value[
"value"] == $cat->scale-1)
302 if (!$value[
'uncheck'])
304 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
310 $template->parseCurrentBlock();
312 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
314 $cat = $this->
object->categories->getCategory($i);
317 $template->setCurrentBlock(
"text_other_col");
318 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
319 $template->setVariable(
"QUESTION_ID", $this->object->getId());
320 if (strlen($cat->title))
322 $template->setVariable(
"OTHER_LABEL", $cat->title);
324 if (is_array($working_data))
326 foreach ($working_data as $value)
328 if (strlen($value[
"value"]))
330 if ($value[
"value"] == $cat->scale-1 && strlen($value[
'textanswer']))
337 $template->parseCurrentBlock();
341 $template->setCurrentBlock(
"text_col");
342 if ($cat->neutral) $template->setVariable(
'COLCLASS',
' neutral');
343 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
345 $template->setVariable(
"QUESTION_ID", $this->object->getId());
346 $template->parseCurrentBlock();
348 $template->touchBlock(
'text_outer_col');
353 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
355 $cat = $this->
object->categories->getCategory($i);
356 $template->setCurrentBlock(
"comborow");
357 $template->setVariable(
"TEXT_SC", $cat->title);
358 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
359 if (is_array($working_data))
361 if (strcmp($working_data[0][
"value"],
"") != 0)
363 if ($working_data[0][
"value"] == $cat->scale-1)
365 $template->setVariable(
"SELECTED_SC",
" selected=\"selected\"");
369 $template->parseCurrentBlock();
371 $template->setCurrentBlock(
"combooutput");
372 $template->setVariable(
"QUESTION_ID", $this->object->getId());
373 $template->setVariable(
"SELECT_OPTION", $this->lng->txt(
"select_option"));
374 $template->setVariable(
"TEXT_SELECTION", $this->lng->txt(
"selection"));
375 $template->parseCurrentBlock();
380 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
382 $template->setCurrentBlock(
"question_data");
383 if (strcmp($error_message,
"") != 0)
385 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
387 if ($show_questiontext)
391 $template->parseCurrentBlock();
392 return $template->get();
410 if (count($this->cumulated) == 0)
414 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
419 $nr_of_users =
sizeof($finished_ids);
421 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users, $finished_ids);
424 include_once
"./Services/UICore/classes/class.ilTemplate.php";
425 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
427 $template->setCurrentBlock(
"detail_row");
428 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
429 $questiontext = $this->
object->getQuestiontext();
430 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
431 $template->parseCurrentBlock();
432 $template->setCurrentBlock(
"detail_row");
433 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
434 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
435 $template->parseCurrentBlock();
436 $template->setCurrentBlock(
"detail_row");
437 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
438 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
439 $template->parseCurrentBlock();
440 $template->setCurrentBlock(
"detail_row");
441 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
442 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
443 $template->parseCurrentBlock();
454 $template->setCurrentBlock(
"detail_row");
455 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"median"));
456 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MEDIAN"]);
457 $template->parseCurrentBlock();
459 $template->setCurrentBlock(
"detail_row");
460 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"categories"));
462 foreach ($this->cumulated[
"variables"] as $key => $value)
464 $categories .=
"<li>" . $value[
"title"] .
": n=" . $value[
"selected"] .
465 " (" . sprintf(
"%.2f", 100*$value[
"percentage"]) .
"%)</li>";
467 $categories =
"<ol>$categories</ol>";
468 $template->setVariable(
"TEXT_OPTION_VALUE", $categories);
469 $template->parseCurrentBlock();
472 if (is_array($this->cumulated[
"textanswers"]))
474 $template->setCurrentBlock(
"detail_row");
475 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"freetext_answers"));
477 foreach ($this->cumulated[
"textanswers"] as $key => $answers)
479 $html .= $this->cumulated[
"variables"][$key][
"title"] .
"\n";
481 foreach ($answers as $answer)
483 $html .=
"<li>" . preg_replace(
"/\n/",
"<br>\n", $answer) .
"</li>\n";
487 $template->setVariable(
"TEXT_OPTION_VALUE", $html);
488 $template->parseCurrentBlock();
492 $template->setCurrentBlock(
"detail_row");
493 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"chart"));
494 $template->setVariable(
"TEXT_OPTION_VALUE", $this->
renderChart(
"svy_ch_".$this->object->getId(), $this->cumulated[
"variables"]));
495 $template->parseCurrentBlock();
497 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
498 return $template->get();