35 $orientation->addOption(
new ilRadioOption($this->lng->txt(
'vertical'), 0));
36 $orientation->addOption(
new ilRadioOption($this->lng->txt(
'horizontal'), 1));
37 $orientation->addOption(
new ilRadioOption($this->lng->txt(
'combobox'), 2));
43 $answers->setAllowMove(
true);
44 $answers->setShowWizard(
true);
45 $answers->setShowSavePhrase(
true);
46 $answers->setUseOtherAnswer(
true);
47 $answers->setShowNeutralCategory(
true);
48 $answers->setNeutralCategoryTitle($this->lng->txt(
'svy_neutral_answer'));
49 $answers->setDisabledScale(
false);
53 $orientation->setValue($this->object->getOrientation());
54 if (!$this->object->getCategories()->getCategoryCount()) {
55 $this->
object->getCategories()->addCategory(
"");
57 $answers->setValues($this->object->getCategories());
62 $this->log->debug(
"importing edit values");
64 $this->
object->setOrientation($a_form->
getInput(
"orientation"));
66 $this->
object->categories->flushCategories();
67 foreach (
$_POST[
'answers'][
'answer'] as $key => $value) {
69 $this->
object->getCategories()->addCategory($value,
$_POST[
'answers'][
'other'][$key], 0, null,
$_POST[
'answers'][
'scale'][$key]);
72 if (strlen(
$_POST[
'answers'][
'neutral'])) {
73 $this->
object->getCategories()->addCategory(
$_POST[
'answers'][
'neutral'], 0, 1, null,
$_POST[
'answers_neutral_scale']);
77 public function getParsedAnswers(array $a_working_data = null, $a_only_user_anwers =
false)
79 if (is_array($a_working_data)) {
80 $user_answer = $a_working_data[0];
84 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
85 $cat = $this->
object->categories->getCategory(
$i);
86 $value = ($cat->scale) ? ($cat->scale - 1) :
$i;
88 $checked =
"unchecked";
90 if (is_array($a_working_data) &&
91 is_array($user_answer)) {
92 if ($value == $user_answer[
"value"]) {
94 if ($user_answer[
"textanswer"]) {
95 $text = $user_answer[
"textanswer"];
101 $idx = $cat->other .
"_" . $value;
103 if (!$a_only_user_anwers || $checked ==
"checked") {
104 $options[$idx] = array(
106 ,
"title" => trim($cat->title)
107 ,
"other" => (
bool) $cat->other
108 ,
"checked" => $checked
109 ,
"textanswer" => $text
116 return array_values($options);
124 public function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null, array $a_working_data = null)
130 $template =
new ilTemplate(
"tpl.il_svy_qpl_sc_printview.html",
true,
true,
"Modules/SurveyQuestionPool");
131 switch ($this->object->orientation) {
134 foreach ($options as $option) {
135 if ($option[
"other"]) {
136 $template->setCurrentBlock(
"other_row");
138 $template->setVariable(
"ALT_RADIO", $this->lng->txt($option[
"checked"]));
139 $template->setVariable(
"TITLE_RADIO", $this->lng->txt($option[
"checked"]));
141 $template->setVariable(
"OTHER_ANSWER", $option[
"textanswer"]
143 :
" ");
144 $template->parseCurrentBlock();
146 $template->setCurrentBlock(
"row");
148 $template->setVariable(
"ALT_RADIO", $this->lng->txt($option[
"checked"]));
149 $template->setVariable(
"TITLE_RADIO", $this->lng->txt($option[
"checked"]));
151 $template->parseCurrentBlock();
157 foreach ($options as $option) {
158 $template->setCurrentBlock(
"radio_col");
160 $template->setVariable(
"ALT_RADIO", $this->lng->txt($option[
"checked"]));
161 $template->setVariable(
"TITLE_RADIO", $this->lng->txt($option[
"checked"]));
162 $template->parseCurrentBlock();
164 foreach ($options as $option) {
165 if ($option[
"other"]) {
166 $template->setCurrentBlock(
"other_text_col");
168 $template->setVariable(
"OTHER_ANSWER", $option[
"textanswer"]
170 :
" ");
171 $template->parseCurrentBlock();
173 $template->setCurrentBlock(
"text_col");
175 $template->parseCurrentBlock();
180 foreach ($options as $option) {
181 $template->setCurrentBlock(
"comborow");
183 $template->setVariable(
"VALUE_SC", $option[
"value"]);
184 if ($option[
"checked"] ==
"checked") {
185 $template->setVariable(
"SELECTED_SC",
' selected="selected"');
187 $template->parseCurrentBlock();
189 $template->setCurrentBlock(
"combooutput");
190 $template->setVariable(
"QUESTION_ID", $this->object->getId());
191 $template->setVariable(
"SELECT_OPTION", $this->lng->txt(
"select_option"));
192 $template->setVariable(
"TEXT_SELECTION", $this->lng->txt(
"selection"));
193 $template->parseCurrentBlock();
196 if ($question_title) {
199 if ($show_questiontext) {
202 $template->parseCurrentBlock();
203 return $template->get();
216 public 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) {
225 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
226 $cat = $this->
object->categories->getCategory(
$i);
228 $debug_scale = ($cat->scale) ? ($cat->scale - 1) :
$i;
229 $this->log->debug(
"Vertical orientation - Original scale = " . $cat->scale .
" If(scale) scale -1 else i. The new scale value is = " . $debug_scale);
232 $template->setCurrentBlock(
"other_row");
233 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)) {
239 foreach ($working_data as $value) {
240 if (strlen($value[
"value"])) {
241 if ($value[
"value"] == $cat->scale - 1) {
242 if (strlen($value[
'textanswer'])) {
245 if (!$value[
'uncheck']) {
246 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
252 $template->parseCurrentBlock();
254 $template->setCurrentBlock(
"row");
256 $template->setVariable(
'ROWCLASS',
' class="neutral"');
259 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
260 $template->setVariable(
"QUESTION_ID", $this->object->getId());
261 if (is_array($working_data)) {
262 foreach ($working_data as $value) {
263 if (strcmp($value[
"value"],
"") != 0) {
264 if ($value[
"value"] == $cat->scale - 1) {
265 if (!$value[
'uncheck']) {
266 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
272 $template->parseCurrentBlock();
274 $template->touchBlock(
'outer_row');
279 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
280 $cat = $this->
object->categories->getCategory(
$i);
282 $debug_scale = ($cat->scale) ? ($cat->scale - 1) :
$i;
283 $this->log->debug(
"Horizontal orientation - Original NEUTRAL scale = " . $cat->scale .
" If(scale) scale -1 else i. The new scale value is = " . $debug_scale);
285 $template->setCurrentBlock(
"radio_col");
287 $template->setVariable(
'COLCLASS',
' neutral');
289 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
290 $template->setVariable(
"QUESTION_ID", $this->object->getId());
291 if (is_array($working_data)) {
292 foreach ($working_data as $value) {
293 if (strcmp($value[
"value"],
"") != 0) {
294 if ($value[
"value"] == $cat->scale - 1) {
295 if (!$value[
'uncheck']) {
296 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
302 $template->parseCurrentBlock();
304 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
305 $cat = $this->
object->categories->getCategory(
$i);
307 $debug_scale = ($cat->scale) ? ($cat->scale - 1) :
$i;
308 $this->log->debug(
"Horizontal orientation - Original scale = " . $cat->scale .
" If(scale) scale -1 else i. The new scale value is = " . $debug_scale);
311 $template->setCurrentBlock(
"text_other_col");
312 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
313 $template->setVariable(
"QUESTION_ID", $this->object->getId());
314 if (strlen($cat->title)) {
315 $template->setVariable(
"OTHER_LABEL", $cat->title);
317 if (is_array($working_data)) {
318 foreach ($working_data as $value) {
319 if (strlen($value[
"value"])) {
320 if ($value[
"value"] == $cat->scale - 1 && strlen($value[
'textanswer'])) {
326 $template->parseCurrentBlock();
328 $template->setCurrentBlock(
"text_col");
330 $template->setVariable(
'COLCLASS',
' neutral');
332 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
334 $template->setVariable(
"QUESTION_ID", $this->object->getId());
335 $template->parseCurrentBlock();
337 $template->touchBlock(
'text_outer_col');
342 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
343 $cat = $this->
object->categories->getCategory(
$i);
345 $debug_scale = ($cat->scale) ? ($cat->scale - 1) :
$i;
346 $this->log->debug(
"Combobox - Original scale = " . $cat->scale .
" If(scale) scale -1 else i. The new scale value is = " . $debug_scale);
348 $template->setCurrentBlock(
"comborow");
349 $template->setVariable(
"TEXT_SC", $cat->title);
350 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
351 if (is_array($working_data)) {
352 if (strcmp($working_data[0][
"value"],
"") != 0) {
353 if ($working_data[0][
"value"] == $cat->scale - 1) {
354 $template->setVariable(
"SELECTED_SC",
" selected=\"selected\"");
358 $template->parseCurrentBlock();
360 $template->setCurrentBlock(
"combooutput");
361 $template->setVariable(
"QUESTION_ID", $this->object->getId());
362 $template->setVariable(
"SELECT_OPTION", $this->lng->txt(
"select_option"));
363 $template->setVariable(
"TEXT_SELECTION", $this->lng->txt(
"selection"));
364 $template->parseCurrentBlock();
367 if ($question_title) {
368 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
370 $template->setCurrentBlock(
"question_data");
371 if (strcmp($error_message,
"") != 0) {
372 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
374 if ($show_questiontext) {
377 $template->parseCurrentBlock();
378 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.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static getHtmlPath($relative_path)
get url of path
importEditFormValues(ilPropertyFormGUI $a_form)
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.