24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
41 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyMultipleChoiceQuestion.php";
59 $orientation->addOption(
new ilRadioOption($this->lng->txt(
'vertical'), 0));
60 $orientation->addOption(
new ilRadioOption($this->lng->txt(
'horizontal'), 1));
64 $minanswers =
new ilCheckboxInputGUI($this->lng->txt(
"use_min_answers"),
"use_min_answers");
66 $minanswers->setOptionTitle($this->lng->txt(
"use_min_answers_option"));
67 $minanswers->setRequired(FALSE);
69 $nranswers =
new ilNumberInputGUI($this->lng->txt(
"nr_min_answers"),
"nr_min_answers");
71 $nranswers->setDecimals(0);
72 $nranswers->setRequired(
false);
73 $nranswers->setMinValue(1);
74 $minanswers->addSubItem($nranswers);
76 $nrmaxanswers =
new ilNumberInputGUI($this->lng->txt(
"nr_max_answers"),
"nr_max_answers");
78 $nrmaxanswers->setDecimals(0);
79 $nrmaxanswers->setRequired(
false);
80 $nrmaxanswers->setMinValue(1);
81 $minanswers->addSubItem($nrmaxanswers);
86 include_once
"./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
89 $answers->setAllowMove(
true);
90 $answers->setShowWizard(
false);
91 $answers->setShowSavePhrase(
false);
92 $answers->setUseOtherAnswer(
true);
93 $answers->setShowNeutralCategory(
true);
94 $answers->setNeutralCategoryTitle($this->lng->txt(
'svy_neutral_answer'));
95 $answers->setDisabledScale(
false);
100 $orientation->setValue($this->
object->getOrientation());
101 $minanswers->setChecked($this->
object->use_min_answers);
102 $nranswers->setValue($this->
object->nr_min_answers);
103 $nrmaxanswers->setValue($this->
object->nr_max_answers);
104 if (!$this->
object->getCategories()->getCategoryCount())
106 $this->
object->getCategories()->addCategory(
"");
108 $answers->setValues($this->
object->getCategories());
113 if($a_form->
getInput(
"use_min_answers"))
117 foreach (
$_POST[
'answers'][
'answer'] as $key => $value)
124 if (strlen(
$_POST[
'answers'][
'neutral']))
132 $min_anwers = $a_form->
getInput(
"nr_min_answers");
133 $max_anwers = $a_form->
getInput(
"nr_max_answers");
136 $min_anwers > $cnt_answers)
138 $a_form->
getItemByPostVar(
"nr_min_answers")->setAlert($this->lng->txt(
'err_minvalueganswers'));
141 if ($max_anwers > 0 &&
142 ($max_anwers > $cnt_answers || $max_anwers < $min_anwers))
144 $a_form->
getItemByPostVar(
"nr_max_answers")->setAlert($this->lng->txt(
'err_maxvaluegeminvalue'));
155 $this->
object->setOrientation($a_form->
getInput(
"orientation"));
156 $this->
object->use_other_answer = ($a_form->
getInput(
'use_other_answer')) ? 1 : 0;
157 $this->
object->other_answer_label = $this->
object->use_other_answer ? $a_form->
getInput(
'other_answer_label') : null;
158 $this->
object->use_min_answers = ($a_form->
getInput(
'use_min_answers')) ?
true :
false;
159 $this->
object->nr_min_answers = ($a_form->
getInput(
'nr_min_answers') > 0) ? $a_form->
getInput(
'nr_min_answers') : null;
160 $this->
object->nr_max_answers = ($a_form->
getInput(
'nr_max_answers') > 0) ? $a_form->
getInput(
'nr_max_answers') : null;
161 $this->
object->label = $a_form->
getInput(
'label');
163 $this->
object->categories->flushCategories();
165 foreach (
$_POST[
'answers'][
'answer'] as $key => $value)
167 if (strlen($value)) $this->
object->getCategories()->addCategory($value,
$_POST[
'answers'][
'other'][$key], 0, null,
$_POST[
'answers'][
'scale'][$key]);
169 if (strlen(
$_POST[
'answers'][
'neutral']))
171 $this->
object->getCategories()->addCategory(
$_POST[
'answers'][
'neutral'], 0, 1, null,
$_POST[
'answers_neutral_scale']);
177 if(is_array($a_working_data))
179 $user_answers = $a_working_data;
183 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
185 $cat = $this->
object->categories->getCategory($i);
186 $value = ($cat->scale) ? ($cat->scale - 1) : $i;
188 $checked =
"unchecked";
190 if(is_array($a_working_data))
192 foreach($user_answers as $user_answer)
194 if($value == $user_answer[
"value"])
196 $checked =
"checked";
197 if($user_answer[
"textanswer"])
199 $text = $user_answer[
"textanswer"];
207 $idx = $cat->other.
"_".$value;
209 if(!$a_only_user_anwers || $checked ==
"checked")
213 ,
"title" => trim($cat->title)
214 ,
"other" => (
bool)$cat->other
215 ,
"checked" => $checked
216 ,
"textanswer" =>
$text 230 function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null,
array $a_working_data = null)
234 $template =
new ilTemplate(
"tpl.il_svy_qpl_mc_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
235 switch ($this->
object->getOrientation())
241 if ($option[
"other"])
243 $template->setCurrentBlock(
"other_row");
245 $template->setVariable(
"ALT_CHECKBOX", $this->lng->txt($option[
"checked"]));
246 $template->setVariable(
"TITLE_CHECKBOX", $this->lng->txt($option[
"checked"]));
248 $template->setVariable(
"OTHER_ANSWER", $option[
"textanswer"]
251 $template->parseCurrentBlock();
255 $template->setCurrentBlock(
"mc_row");
257 $template->setVariable(
"ALT_CHECKBOX", $this->lng->txt($option[
"checked"]));
258 $template->setVariable(
"TITLE_CHECKBOX", $this->lng->txt($option[
"checked"]));
260 $template->parseCurrentBlock();
268 $template->setCurrentBlock(
"checkbox_col");
270 $template->setVariable(
"ALT_CHECKBOX", $this->lng->txt($option[
"checked"]));
271 $template->setVariable(
"TITLE_CHECKBOX", $this->lng->txt($option[
"checked"]));
272 $template->parseCurrentBlock();
276 if ($option[
"other"])
278 $template->setCurrentBlock(
"other_text_col");
280 $template->setVariable(
"OTHER_ANSWER", $option[
"textanswer"]
283 $template->parseCurrentBlock();
287 $template->setCurrentBlock(
"text_col");
289 $template->parseCurrentBlock();
295 if ($this->
object->use_min_answers)
297 $template->setCurrentBlock(
'min_max_msg');
298 if ($this->
object->nr_min_answers > 0 && $this->object->nr_max_answers > 0)
300 $template->setVariable(
'MIN_MAX_MSG', sprintf($this->lng->txt(
'msg_min_max_nr_answers'), $this->
object->nr_min_answers, $this->
object->nr_max_answers));
302 else if ($this->
object->nr_min_answers > 0)
304 $template->setVariable(
'MIN_MAX_MSG', sprintf($this->lng->txt(
'msg_min_nr_answers'), $this->
object->nr_min_answers));
306 else if ($this->
object->nr_max_answers > 0)
308 $template->setVariable(
'MIN_MAX_MSG', sprintf($this->lng->txt(
'msg_max_nr_answers'), $this->
object->nr_max_answers));
310 $template->parseCurrentBlock();
312 if ($show_questiontext)
320 $template->parseCurrentBlock();
321 return $template->get();
334 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
336 $template =
new ilTemplate(
"tpl.il_svy_out_mc.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
337 $template->setCurrentBlock(
"material");
339 $template->parseCurrentBlock();
340 switch ($this->
object->getOrientation())
344 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
346 $cat = $this->
object->categories->getCategory($i);
349 $template->setCurrentBlock(
"other_row");
350 if (strlen($cat->title))
352 $template->setVariable(
"OTHER_LABEL", $cat->title);
354 $template->setVariable(
"VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
355 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
356 if (is_array($working_data))
358 foreach ($working_data as $value)
360 if (strlen($value[
"value"]))
362 if ($value[
"value"] == $cat->scale-1)
365 if (!$value[
'uncheck'])
367 $template->setVariable(
"CHECKED_MC",
" checked=\"checked\"");
373 $template->parseCurrentBlock();
377 $template->setCurrentBlock(
"mc_row");
378 if ($cat->neutral) $template->setVariable(
'ROWCLASS',
' class="neutral"');
380 $template->setVariable(
"VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
381 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
382 if (is_array($working_data))
384 foreach ($working_data as $value)
386 if (strlen($value[
"value"]))
388 if ($value[
"value"] == $cat->scale-1)
390 if (!$value[
'uncheck'])
392 $template->setVariable(
"CHECKED_MC",
" checked=\"checked\"");
398 $template->parseCurrentBlock();
400 $template->touchBlock(
'outer_row');
407 for ($i = 0; $i < $this->
object->categories->getCategoryCount(); $i++)
409 $cat = $this->
object->categories->getCategory($i);
412 $template->setCurrentBlock(
"checkbox_col");
413 if ($cat->neutral) $template->setVariable(
'COLCLASS',
' neutral');
414 $template->setVariable(
"VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
415 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
416 if (is_array($working_data))
418 foreach ($working_data as $value)
420 if (strlen($value[
"value"]))
422 if ($value[
"value"] == $cat->scale-1)
424 if (!$value[
'uncheck'])
426 $template->setVariable(
"CHECKED_MC",
" checked=\"checked\"");
432 $template->parseCurrentBlock();
437 $template->setCurrentBlock(
"text_other_col");
438 $template->setVariable(
"VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
439 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
440 if (strlen($cat->title))
442 $template->setVariable(
"OTHER_LABEL", $cat->title);
444 if (is_array($working_data))
446 foreach ($working_data as $value)
448 if (strlen($value[
"value"]))
450 if ($value[
"value"] == $cat->scale-1)
457 $template->parseCurrentBlock();
462 $template->setCurrentBlock(
"text_col");
463 if ($cat->neutral) $template->setVariable(
'COLCLASS',
' neutral');
464 $template->setVariable(
"VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
466 $template->setVariable(
"QUESTION_ID", $this->
object->getId());
467 $template->parseCurrentBlock();
469 $template->touchBlock(
'text_outer_col');
474 $template->setCurrentBlock(
"question_data");
475 if ($this->
object->use_min_answers)
477 $template->setCurrentBlock(
'min_max_msg');
478 if ($this->
object->nr_min_answers > 0 && $this->object->nr_max_answers > 0)
480 if ($this->
object->nr_min_answers == $this->object->nr_max_answers)
482 $template->setVariable(
'MIN_MAX_MSG', sprintf($this->lng->txt(
'msg_min_max_exact_answers'), $this->
object->nr_min_answers));
486 $template->setVariable(
'MIN_MAX_MSG', sprintf($this->lng->txt(
'msg_min_max_nr_answers'), $this->
object->nr_min_answers, $this->
object->nr_max_answers));
489 else if ($this->
object->nr_min_answers > 0)
491 $template->setVariable(
'MIN_MAX_MSG', sprintf($this->lng->txt(
'msg_min_nr_answers'), $this->
object->nr_min_answers));
493 else if ($this->
object->nr_max_answers > 0)
495 $template->setVariable(
'MIN_MAX_MSG', sprintf($this->lng->txt(
'msg_max_nr_answers'), $this->
object->nr_max_answers));
497 $template->parseCurrentBlock();
499 if (strcmp($error_message,
"") != 0)
501 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
503 if ($show_questiontext)
509 $template->setVariable(
"QUESTION_TITLE", $this->
object->getTitle());
511 $template->parseCurrentBlock();
512 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)
outQuestionText($template)
getWorkingForm($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
Creates the question output form for the learner.
getPrintView($question_title=1, $show_questiontext=1, $survey_id=null, array $a_working_data=null)
Creates a HTML representation of the question.
if(!is_array($argv)) $options
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
MultipleChoice survey question GUI representation.
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.
validateEditForm(ilPropertyFormGUI $a_form)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
importEditFormValues(ilPropertyFormGUI $a_form)
Create new PHPExcel object
obj_idprivate
MultipleChoice survey question.
getPrintViewQuestionTitle($question_title=1)
getParsedAnswers(array $a_working_data=null, $a_only_user_anwers=false)
Basic class for all survey question types.
addFieldsToEditForm(ilPropertyFormGUI $a_form)