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->log->debug(
"importing edit values");
91 $this->
object->setOrientation($a_form->
getInput(
"orientation"));
93 $this->
object->categories->flushCategories();
94 foreach (
$_POST[
'answers'][
'answer'] as $key => $value)
96 if (strlen($value)) $this->
object->getCategories()->addCategory($value,
$_POST[
'answers'][
'other'][$key], 0, null,
$_POST[
'answers'][
'scale'][$key]);
98 if (strlen(
$_POST[
'answers'][
'neutral']))
100 $this->
object->getCategories()->addCategory(
$_POST[
'answers'][
'neutral'], 0, 1, null,
$_POST[
'answers_neutral_scale']);
106 if(is_array($a_working_data))
108 $user_answer = $a_working_data[0];
112 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
114 $cat = $this->
object->categories->getCategory($i);
115 $value = ($cat->scale) ? ($cat->scale - 1) : $i;
117 $checked =
"unchecked";
119 if(is_array($a_working_data) &&
120 is_array($user_answer))
122 if($value == $user_answer[
"value"])
124 $checked =
"checked";
125 if($user_answer[
"textanswer"])
127 $text = $user_answer[
"textanswer"];
133 $idx = $cat->other.
"_".$value;
135 if(!$a_only_user_anwers || $checked ==
"checked")
139 ,
"title" => trim($cat->title)
140 ,
"other" => (
bool)$cat->other
141 ,
"checked" => $checked
142 ,
"textanswer" =>
$text 157 function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null,
array $a_working_data = null)
163 $template =
new ilTemplate(
"tpl.il_svy_qpl_sc_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
164 switch ($this->
object->orientation)
170 if ($option[
"other"])
172 $template->setCurrentBlock(
"other_row");
174 $template->setVariable(
"ALT_RADIO", $this->lng->txt($option[
"checked"]));
175 $template->setVariable(
"TITLE_RADIO", $this->lng->txt($option[
"checked"]));
177 $template->setVariable(
"OTHER_ANSWER", $option[
"textanswer"]
179 :
" ");
180 $template->parseCurrentBlock();
185 $template->setCurrentBlock(
"row");
187 $template->setVariable(
"ALT_RADIO", $this->lng->txt($option[
"checked"]));
188 $template->setVariable(
"TITLE_RADIO", $this->lng->txt($option[
"checked"]));
190 $template->parseCurrentBlock();
198 $template->setCurrentBlock(
"radio_col");
200 $template->setVariable(
"ALT_RADIO", $this->lng->txt($option[
"checked"]));
201 $template->setVariable(
"TITLE_RADIO", $this->lng->txt($option[
"checked"]));
202 $template->parseCurrentBlock();
206 if ($option[
"other"])
208 $template->setCurrentBlock(
"other_text_col");
210 $template->setVariable(
"OTHER_ANSWER", $option[
"textanswer"]
212 :
" ");
213 $template->parseCurrentBlock();
217 $template->setCurrentBlock(
"text_col");
219 $template->parseCurrentBlock();
226 $template->setCurrentBlock(
"comborow");
228 $template->setVariable(
"VALUE_SC", $option[
"value"]);
229 if($option[
"checked"] ==
"checked")
231 $template->setVariable(
"SELECTED_SC",
' selected="selected"');
233 $template->parseCurrentBlock();
235 $template->setCurrentBlock(
"combooutput");
236 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
237 $template->setVariable(
"SELECT_OPTION", $this->lng->txt(
"select_option"));
238 $template->setVariable(
"TEXT_SELECTION", $this->lng->txt(
"selection"));
239 $template->parseCurrentBlock();
246 if ($show_questiontext)
250 $template->parseCurrentBlock();
251 return $template->get();
264 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
266 $template =
new ilTemplate(
"tpl.il_svy_out_sc.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
267 $template->setCurrentBlock(
"material");
269 $template->parseCurrentBlock();
270 switch ($this->
object->orientation)
274 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
276 $cat = $this->
object->categories->getCategory($i);
278 $debug_scale = ($cat->scale) ? ($cat->scale - 1) : $i;
279 $this->log->debug(
"Vertical orientation - Original scale = ".$cat->scale.
" If(scale) scale -1 else i. The new scale value is = ".$debug_scale);
283 $template->setCurrentBlock(
"other_row");
284 if (strlen($cat->title))
286 $template->setVariable(
"OTHER_LABEL", $cat->title);
288 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
289 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
290 if (is_array($working_data))
292 foreach ($working_data as $value)
294 if (strlen($value[
"value"]))
296 if ($value[
"value"] == $cat->scale-1)
298 if (strlen($value[
'textanswer'])) $template->setVariable(
"OTHER_VALUE",
' value="' .
ilUtil::prepareFormOutput($value[
'textanswer']) .
'"');
299 if (!$value[
'uncheck'])
301 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
307 $template->parseCurrentBlock();
311 $template->setCurrentBlock(
"row");
312 if ($cat->neutral) $template->setVariable(
'ROWCLASS',
' class="neutral"');
314 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
315 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
316 if (is_array($working_data))
318 foreach ($working_data as $value)
320 if (strcmp($value[
"value"],
"") != 0)
322 if ($value[
"value"] == $cat->scale-1)
324 if (!$value[
'uncheck'])
326 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
332 $template->parseCurrentBlock();
334 $template->touchBlock(
'outer_row');
339 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
341 $cat = $this->
object->categories->getCategory($i);
343 $debug_scale = ($cat->scale) ? ($cat->scale - 1) : $i;
344 $this->log->debug(
"Horizontal orientation - Original NEUTRAL scale = ".$cat->scale.
" If(scale) scale -1 else i. The new scale value is = ".$debug_scale);
346 $template->setCurrentBlock(
"radio_col");
347 if ($cat->neutral) $template->setVariable(
'COLCLASS',
' neutral');
348 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
349 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
350 if (is_array($working_data))
352 foreach ($working_data as $value)
354 if (strcmp($value[
"value"],
"") != 0)
356 if ($value[
"value"] == $cat->scale-1)
358 if (!$value[
'uncheck'])
360 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
366 $template->parseCurrentBlock();
368 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
370 $cat = $this->
object->categories->getCategory($i);
372 $debug_scale = ($cat->scale) ? ($cat->scale - 1) : $i;
373 $this->log->debug(
"Horizontal orientation - Original scale = ".$cat->scale.
" If(scale) scale -1 else i. The new scale value is = ".$debug_scale);
377 $template->setCurrentBlock(
"text_other_col");
378 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
379 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
380 if (strlen($cat->title))
382 $template->setVariable(
"OTHER_LABEL", $cat->title);
384 if (is_array($working_data))
386 foreach ($working_data as $value)
388 if (strlen($value[
"value"]))
390 if ($value[
"value"] == $cat->scale-1 && strlen($value[
'textanswer']))
397 $template->parseCurrentBlock();
401 $template->setCurrentBlock(
"text_col");
402 if ($cat->neutral) $template->setVariable(
'COLCLASS',
' neutral');
403 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
405 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
406 $template->parseCurrentBlock();
408 $template->touchBlock(
'text_outer_col');
413 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
415 $cat = $this->
object->categories->getCategory($i);
417 $debug_scale = ($cat->scale) ? ($cat->scale - 1) : $i;
418 $this->log->debug(
"Combobox - Original scale = ".$cat->scale.
" If(scale) scale -1 else i. The new scale value is = ".$debug_scale);
420 $template->setCurrentBlock(
"comborow");
421 $template->setVariable(
"TEXT_SC", $cat->title);
422 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) : $i);
423 if (is_array($working_data))
425 if (strcmp($working_data[0][
"value"],
"") != 0)
427 if ($working_data[0][
"value"] == $cat->scale-1)
429 $template->setVariable(
"SELECTED_SC",
" selected=\"selected\"");
433 $template->parseCurrentBlock();
435 $template->setCurrentBlock(
"combooutput");
436 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
437 $template->setVariable(
"SELECT_OPTION", $this->lng->txt(
"select_option"));
438 $template->setVariable(
"TEXT_SELECTION", $this->lng->txt(
"selection"));
439 $template->parseCurrentBlock();
444 $template->setVariable(
"QUESTION_TITLE", $this->
object->getTitle());
446 $template->setCurrentBlock(
"question_data");
447 if (strcmp($error_message,
"") != 0)
449 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
451 if ($show_questiontext)
455 $template->parseCurrentBlock();
456 return $template->get();
setQuestionTabsForClass($guiclass)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
This class represents an option in a radio group.
getMaterialOutput()
Creates the HTML output of the question material(s)
getParsedAnswers(array $a_working_data=null, $a_only_user_anwers=false)
SingleChoice survey question.
outQuestionText($template)
SingleChoice survey question GUI representation.
addFieldsToEditForm(ilPropertyFormGUI $a_form)
getWorkingForm($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
Creates the question output form for the learner.
if(!is_array($argv)) $options
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
static getHtmlPath($relative_path)
get url of path
Create styles array
The data for the language used.
importEditFormValues(ilPropertyFormGUI $a_form)
Create new PHPExcel object
obj_idprivate
getPrintView($question_title=1, $show_questiontext=1, $survey_id=null, array $a_working_data=null)
Creates a HTML representation of the question.
getPrintViewQuestionTitle($question_title=1)
Basic class for all survey question types.