49 $orientation->addOption(
new ilRadioOption($this->
lng->txt(
'horizontal'), 1));
56 $answers->setAllowMove(
true);
57 $answers->setShowWizard(
true);
58 $answers->setShowSavePhrase(
true);
59 $answers->setUseOtherAnswer(
true);
60 $answers->setShowNeutralCategory(
true);
61 $answers->setNeutralCategoryTitle($this->
lng->txt(
'svy_neutral_answer'));
62 $answers->setDisabledScale(
false);
66 $orientation->setValue($this->
object->getOrientation());
67 if (!$this->
object->getCategories()->getCategoryCount()) {
68 $this->
object->getCategories()->addCategory(
"");
70 $answers->setValues($this->
object->getCategories());
75 $this->log->debug(
"importing edit values");
77 $this->
object->setOrientation($a_form->
getInput(
"orientation"));
79 $this->
object->categories->flushCategories();
80 $answers = $this->request->getAnswers();
81 foreach ($answers[
'answer'] as
$key => $value) {
83 $this->
object->getCategories()->addCategory(
85 $answers[
'other'][
$key] ?? 0,
88 $answers[
'scale'][$key] ?? null
92 if ($this->request->getNeutral() !==
"") {
93 $this->
object->getCategories()->addCategory($this->request->getNeutral(), 0, 1, null, $this->request->getNeutralScale());
98 array $a_working_data = null,
99 $a_only_user_anwers =
false 101 if (is_array($a_working_data)) {
102 $user_answer = $a_working_data[0] ?? null;
106 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
107 $cat = $this->
object->categories->getCategory(
$i);
108 $value = ($cat->scale) ? ($cat->scale - 1) :
$i;
110 $checked =
"unchecked";
112 if (is_array($a_working_data) &&
113 is_array($user_answer)) {
114 if ($value == $user_answer[
"value"]) {
115 $checked =
"checked";
116 if ($user_answer[
"textanswer"]) {
117 $text = $user_answer[
"textanswer"];
123 $idx = $cat->other .
"_" . $value;
125 if (!$a_only_user_anwers || $checked ===
"checked") {
126 $options[$idx] = array(
128 ,
"title" => trim($cat->title)
129 ,
"other" => (
bool) $cat->other
130 ,
"checked" => $checked
131 ,
"textanswer" => $text
138 return array_values($options);
142 int $question_title = 1,
143 bool $show_questiontext =
true,
144 ?
int $survey_id = null,
145 ?array $working_data = null
151 $template =
new ilTemplate(
"tpl.il_svy_qpl_sc_printview.html",
true,
true,
"Modules/SurveyQuestionPool");
152 switch ($this->
object->orientation) {
155 foreach ($options as $option) {
156 if ($option[
"other"]) {
157 $template->setCurrentBlock(
"other_row");
159 $template->setVariable(
"ALT_RADIO", $this->
lng->txt($option[
"checked"]));
160 $template->setVariable(
"TITLE_RADIO", $this->
lng->txt($option[
"checked"]));
161 $template->setVariable(
165 $template->setVariable(
"OTHER_ANSWER", $option[
"textanswer"]
167 :
" ");
169 $template->setCurrentBlock(
"row");
171 $template->setVariable(
"ALT_RADIO", $this->
lng->txt($option[
"checked"]));
172 $template->setVariable(
"TITLE_RADIO", $this->
lng->txt($option[
"checked"]));
175 $template->parseCurrentBlock();
180 foreach ($options as $option) {
181 $template->setCurrentBlock(
"radio_col");
183 $template->setVariable(
"ALT_RADIO", $this->
lng->txt($option[
"checked"]));
184 $template->setVariable(
"TITLE_RADIO", $this->
lng->txt($option[
"checked"]));
185 $template->parseCurrentBlock();
187 foreach ($options as $option) {
188 if ($option[
"other"]) {
189 $template->setCurrentBlock(
"other_text_col");
190 $template->setVariable(
194 $template->setVariable(
"OTHER_ANSWER", $option[
"textanswer"]
196 :
" ");
198 $template->setCurrentBlock(
"text_col");
201 $template->parseCurrentBlock();
205 foreach ($options as $option) {
206 $template->setCurrentBlock(
"comborow");
208 $template->setVariable(
"VALUE_SC", $option[
"value"]);
209 if ($option[
"checked"] ===
"checked") {
210 $template->setVariable(
"SELECTED_SC",
' selected="selected"');
212 $template->parseCurrentBlock();
214 $template->setCurrentBlock(
"combooutput");
215 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
216 $template->setVariable(
"SELECT_OPTION", $this->
lng->txt(
"select_option"));
217 $template->setVariable(
"TEXT_SELECTION", $this->
lng->txt(
"selection"));
218 $template->parseCurrentBlock();
221 if ($question_title) {
224 if ($show_questiontext) {
227 $template->parseCurrentBlock();
228 return $template->get();
237 array $working_data = null,
238 int $question_title = 1,
239 bool $show_questiontext =
true,
240 string $error_message =
"",
241 int $survey_id = null,
242 bool $compress_view =
false 244 $orientation = $this->
object->orientation;
245 $template_file =
"tpl.il_svy_out_sc.html";
246 if ($compress_view && $orientation === 1) {
247 $template_file =
"tpl.il_svy_out_sc_comp.html";
250 $template =
new ilTemplate($template_file,
true,
true,
"Modules/SurveyQuestionPool");
252 $template->setCurrentBlock(
"material");
254 $template->parseCurrentBlock();
256 switch ($orientation) {
259 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
260 $cat = $this->
object->categories->getCategory(
$i);
262 $debug_scale = ($cat->scale) ? ($cat->scale - 1) :
$i;
263 $this->log->debug(
"Vertical orientation - Original scale = " . $cat->scale .
" If(scale) scale -1 else i. The new scale value is = " . $debug_scale);
266 $template->setCurrentBlock(
"other_row");
267 if (strlen($cat->title)) {
268 $template->setVariable(
"OTHER_LABEL", $cat->title);
270 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
271 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
272 if (is_array($working_data)) {
273 foreach ($working_data as $value) {
274 if (strlen($value[
"value"])) {
275 if ($value[
"value"] == $cat->scale - 1) {
276 if (strlen($value[
'textanswer'])) {
281 if (!($value[
'uncheck'] ??
false)) {
282 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
289 $template->setCurrentBlock(
"row");
291 $template->setVariable(
'ROWCLASS',
' class="neutral"');
294 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
295 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
296 if (is_array($working_data)) {
297 foreach ($working_data as $value) {
298 if (strcmp($value[
"value"],
"") !== 0) {
299 if ($value[
"value"] == $cat->scale - 1) {
300 if (!($value[
'uncheck'] ??
false)) {
301 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
308 $template->parseCurrentBlock();
309 $template->touchBlock(
'outer_row');
314 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
315 $cat = $this->
object->categories->getCategory(
$i);
317 $debug_scale = ($cat->scale) ? ($cat->scale - 1) :
$i;
318 $this->log->debug(
"Horizontal orientation - Original NEUTRAL scale = " . $cat->scale .
" If(scale) scale -1 else i. The new scale value is = " . $debug_scale);
320 $template->setCurrentBlock(
"radio_col");
322 $template->setVariable(
'COLCLASS',
' neutral');
324 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
325 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
326 if (is_array($working_data)) {
327 foreach ($working_data as $value) {
328 if (strcmp($value[
"value"],
"") !== 0) {
329 if ($value[
"value"] == $cat->scale - 1) {
330 if (!($value[
'uncheck'] ??
false)) {
331 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
337 $template->parseCurrentBlock();
339 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
340 $cat = $this->
object->categories->getCategory(
$i);
342 $debug_scale = ($cat->scale) ? ($cat->scale - 1) :
$i;
343 $this->log->debug(
"Horizontal orientation - Original scale = " . $cat->scale .
" If(scale) scale -1 else i. The new scale value is = " . $debug_scale);
346 $template->setCurrentBlock(
"text_other_col");
347 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
348 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
349 if (strlen($cat->title)) {
350 $template->setVariable(
"OTHER_LABEL", $cat->title);
352 if (is_array($working_data)) {
353 foreach ($working_data as $value) {
354 if (strlen($value[
"value"])) {
355 if ($value[
"value"] == $cat->scale - 1 && strlen($value[
'textanswer'])) {
364 $template->setCurrentBlock(
"text_col");
366 $template->setVariable(
'COLCLASS',
' neutral');
368 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
370 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
372 $template->parseCurrentBlock();
373 $template->touchBlock(
'text_outer_col');
378 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
379 $cat = $this->
object->categories->getCategory(
$i);
381 $debug_scale = ($cat->scale) ? ($cat->scale - 1) :
$i;
382 $this->log->debug(
"Combobox - Original scale = " . $cat->scale .
" If(scale) scale -1 else i. The new scale value is = " . $debug_scale);
384 $template->setCurrentBlock(
"comborow");
385 $template->setVariable(
"TEXT_SC", $cat->title);
386 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
387 if (is_array($working_data)) {
388 if (strcmp($working_data[0][
"value"] ??
"",
"") !== 0) {
389 if ($working_data[0][
"value"] == $cat->scale - 1) {
390 $template->setVariable(
"SELECTED_SC",
" selected=\"selected\"");
394 $template->parseCurrentBlock();
396 $template->setCurrentBlock(
"combooutput");
397 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
398 $template->setVariable(
"SELECT_OPTION", $this->
lng->txt(
"select_option"));
399 $template->setVariable(
"TEXT_SELECTION", $this->
lng->txt(
"selection"));
400 $template->parseCurrentBlock();
404 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
405 $cat = $this->
object->categories->getCategory(
$i);
407 $debug_scale = ($cat->scale) ? ($cat->scale - 1) :
$i;
408 $this->log->debug(
"Horizontal orientation (compressed) - Original NEUTRAL scale = " . $cat->scale .
" If(scale) scale -1 else i. The new scale value is = " . $debug_scale);
411 $template->setCurrentBlock(
"other");
412 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
413 $template->setVariable(
"OTHER_Q_ID", $this->
object->getId());
414 if (is_array($working_data)) {
415 foreach ($working_data as $value) {
416 if (strlen($value[
"value"])) {
417 if ($value[
"value"] == $cat->scale - 1 && strlen($value[
'textanswer'])) {
425 $template->parseCurrentBlock();
429 $template->setCurrentBlock(
"radio_col");
431 $template->setVariable(
'COLCLASS',
' neutral');
433 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
434 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
435 if (is_array($working_data)) {
436 foreach ($working_data as $value) {
437 if (strcmp($value[
"value"],
"") !== 0) {
438 if ($value[
"value"] == $cat->scale - 1) {
439 if (!($value[
'uncheck'] ??
false)) {
440 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
446 $template->parseCurrentBlock();
448 $perc = round(70 / $this->
object->categories->getCategoryCount(), 2);
449 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
450 $cat = $this->
object->categories->getCategory(
$i);
452 $debug_scale = ($cat->scale) ? ($cat->scale - 1) :
$i;
453 $this->log->debug(
"Horizontal orientation - Original scale = " . $cat->scale .
" If(scale) scale -1 else i. The new scale value is = " . $debug_scale);
455 $template->setCurrentBlock(
"text_col");
457 $template->setVariable(
'COLCLASS',
' neutral');
459 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
461 $template->setVariable(
"PERC", $perc);
462 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
463 $template->parseCurrentBlock();
467 $template->setVariable(
"QUESTION_TITLE", $this->
getQuestionTitle($question_title));
468 $template->setCurrentBlock(
"question_data");
469 if (strcmp($error_message,
"") !== 0) {
470 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
472 if ($show_questiontext) {
475 $template->parseCurrentBlock();
476 return $template->get();
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getMaterialOutput()
Creates the HTML output of the question material(s)
getParsedAnswers(array $a_working_data=null, $a_only_user_anwers=false)
getQuestionTitle(int $question_title_mode=1)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getPrintViewQuestionTitle(int $question_title=1)
getWorkingForm(array $working_data=null, int $question_title=1, bool $show_questiontext=true, string $error_message="", int $survey_id=null, bool $compress_view=false)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
getPrintView(int $question_title=1, bool $show_questiontext=true, ?int $survey_id=null, ?array $working_data=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addFieldsToEditForm(ilPropertyFormGUI $a_form)
outQuestionText(ilTemplate $template)
setQuestionTabsForClass(string $guiclass)
static getHtmlPath(string $relative_path)
get url of path
importEditFormValues(ilPropertyFormGUI $a_form)
Basic class for all survey question types The SurveyQuestionGUI class defines and encapsulates basic ...