ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
SurveyMultipleChoiceQuestionGUI Class Reference

MultipleChoice survey question GUI representation. More...

+ Inheritance diagram for SurveyMultipleChoiceQuestionGUI:
+ Collaboration diagram for SurveyMultipleChoiceQuestionGUI:

Public Member Functions

 setQuestionTabs ()
 
 getParsedAnswers (array $a_working_data=null, $a_only_user_anwers=false)
 
 getPrintView ($question_title=1, $show_questiontext=1, $survey_id=null, array $a_working_data=null)
 Creates a HTML representation of the question. More...
 
 getWorkingForm ($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
 Creates the question output form for the learner. More...
 
 getCumulatedResultsDetails ($survey_id, $counter, $finished_ids)
 Creates the detailed output of the cumulated results for the question. More...
 
- Public Member Functions inherited from SurveyQuestionGUI
 __construct ($a_id=-1)
 
 setQuestionTabs ()
 
executeCommand ()
 
 _getGUIClassNameForId ($a_q_id)
 
 _getClassNameForQType ($q_type)
 
 getQuestionType ()
 Returns the question type string. More...
 
 setBackUrl ($a_url)
 
 setQuestionTabsForClass ($guiclass)
 
 getPrintView ($question_title=1, $show_questiontext=1)
 
 preview ()
 Creates a preview of the question. More...
 
 getWorkingForm ($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
 
 getCumulatedResultsDetails ($survey_id, $counter, $finished_ids)
 
 material ($checkonly=FALSE)
 Material tab of the survey questions. More...
 
 deleteMaterial ()
 
 addMaterial ()
 Add materials to a question. More...
 
 removeMaterial ()
 
 cancelExplorer ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 linkChilds ()
 
 savePhrase ($a_reload=false)
 Creates an output to save the current answers as a phrase. More...
 
 confirmSavePhrase ()
 Save a new phrase to the database. More...
 

Protected Member Functions

 initObject ()
 
 addFieldsToEditForm (ilPropertyFormGUI $a_form)
 
 validateEditForm (ilPropertyFormGUI $a_form)
 
 importEditFormValues (ilPropertyFormGUI $a_form)
 
- Protected Member Functions inherited from SurveyQuestionGUI
 initObject ()
 
 outQuestionText ($template)
 
 initEditForm ()
 
 addCommandButtons ($a_form)
 
 editQuestion (ilPropertyFormGUI $a_form=null)
 
 saveSync ()
 
 saveReturn ()
 
 saveForm ()
 
 save ($a_return=false, $a_sync=false)
 
 copySyncForm ()
 
 syncCopies ()
 
 originalSyncForm ()
 
 sync ()
 
 cancelSync ()
 
 redirectAfterSaving ($a_return=false)
 Redirect to calling survey or to edit form. More...
 
 cancel ()
 
 validateEditForm (ilPropertyFormGUI $a_form)
 
 addFieldsToEditForm (ilPropertyFormGUI $a_form)
 
 importEditFormValues (ilPropertyFormGUI $a_form)
 
 getPrintViewQuestionTitle ($question_title=1)
 
 getMaterialOutput ()
 Creates the HTML output of the question material(s) More...
 
 renderChart ($a_id, $a_variables)
 
 initPhrasesForm ()
 
 addPhrase (ilPropertyFormGUI $a_form=null)
 Creates an output for the addition of phrases. More...
 
 addSelectedPhrase ()
 
 renderStatisticsDetailsTable (array $a_head, array $a_rows, array $a_foot=null)
 

Additional Inherited Members

- Static Public Member Functions inherited from SurveyQuestionGUI
static & _getQuestionGUI ($questiontype, $question_id=-1)
 Creates a question gui representation. More...
 
- Data Fields inherited from SurveyQuestionGUI
 $object
 
- Protected Attributes inherited from SurveyQuestionGUI
 $tpl
 
 $lng
 
 $ctrl
 
 $cumulated
 
 $parent_url
 

Detailed Description

MultipleChoice survey question GUI representation.

The SurveyMultipleChoiceQuestionGUI class encapsulates the GUI representation for multiple choice survey question types.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

Definition at line 37 of file class.SurveyMultipleChoiceQuestionGUI.php.

Member Function Documentation

◆ addFieldsToEditForm()

SurveyMultipleChoiceQuestionGUI::addFieldsToEditForm ( ilPropertyFormGUI  $a_form)
protected

Reimplemented from SurveyQuestionGUI.

Definition at line 54 of file class.SurveyMultipleChoiceQuestionGUI.php.

55 {
56 // orientation
57 $orientation = new ilRadioGroupInputGUI($this->lng->txt("orientation"), "orientation");
58 $orientation->setRequired(false);
59 $orientation->addOption(new ilRadioOption($this->lng->txt('vertical'), 0));
60 $orientation->addOption(new ilRadioOption($this->lng->txt('horizontal'), 1));
61 $a_form->addItem($orientation);
62
63 // minimum answers
64 $minanswers = new ilCheckboxInputGUI($this->lng->txt("use_min_answers"), "use_min_answers");
65 $minanswers->setValue(1);
66 $minanswers->setOptionTitle($this->lng->txt("use_min_answers_option"));
67 $minanswers->setRequired(FALSE);
68
69 $nranswers = new ilNumberInputGUI($this->lng->txt("nr_min_answers"), "nr_min_answers");
70 $nranswers->setSize(5);
71 $nranswers->setDecimals(0);
72 $nranswers->setRequired(false);
73 $nranswers->setMinValue(1);
74 $minanswers->addSubItem($nranswers);
75
76 $nrmaxanswers = new ilNumberInputGUI($this->lng->txt("nr_max_answers"), "nr_max_answers");
77 $nrmaxanswers->setSize(5);
78 $nrmaxanswers->setDecimals(0);
79 $nrmaxanswers->setRequired(false);
80 $nrmaxanswers->setMinValue(1);
81 $minanswers->addSubItem($nrmaxanswers);
82
83 $a_form->addItem($minanswers);
84
85 // Answers
86 include_once "./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
87 $answers = new ilCategoryWizardInputGUI($this->lng->txt("answers"), "answers");
88 $answers->setRequired(false);
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);
96 $a_form->addItem($answers);
97
98
99 // values
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())
105 {
106 $this->object->getCategories()->addCategory("");
107 }
108 $answers->setValues($this->object->getCategories());
109 }
This class represents a survey question category wizard property in a property form.
This class represents a checkbox property in a property form.
This class represents a number property in a property form.
addItem($a_item)
Add Item (Property, SectionHeader).
This class represents a property in a property form.
This class represents an option in a radio group.

References ilPropertyFormGUI\addItem().

+ Here is the call graph for this function:

◆ getCumulatedResultsDetails()

SurveyMultipleChoiceQuestionGUI::getCumulatedResultsDetails (   $survey_id,
  $counter,
  $finished_ids 
)

Creates the detailed output of the cumulated results for the question.

Parameters
integer$survey_idThe database ID of the survey
integer$counterThe counter of the question position in the survey
Returns
string HTML text with the cumulated results @access private

Reimplemented from SurveyQuestionGUI.

Definition at line 528 of file class.SurveyMultipleChoiceQuestionGUI.php.

529 {
530 if (count($this->cumulated) == 0)
531 {
532 if(!$finished_ids)
533 {
534 include_once "./Modules/Survey/classes/class.ilObjSurvey.php";
535 $nr_of_users = ilObjSurvey::_getNrOfParticipants($survey_id);
536 }
537 else
538 {
539 $nr_of_users = sizeof($finished_ids);
540 }
541 $this->cumulated =& $this->object->getCumulatedResults($survey_id, $nr_of_users, $finished_ids);
542 }
543
544 $output = "";
545 include_once "./Services/UICore/classes/class.ilTemplate.php";
546 $template = new ilTemplate("tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE, "Modules/Survey");
547
548 $template->setCurrentBlock("detail_row");
549 $template->setVariable("TEXT_OPTION", $this->lng->txt("question"));
550 $questiontext = $this->object->getQuestiontext();
551 $template->setVariable("TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
552 $template->parseCurrentBlock();
553 $template->setCurrentBlock("detail_row");
554 $template->setVariable("TEXT_OPTION", $this->lng->txt("question_type"));
555 $template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
556 $template->parseCurrentBlock();
557 $template->setCurrentBlock("detail_row");
558 $template->setVariable("TEXT_OPTION", $this->lng->txt("users_answered"));
559 $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_ANSWERED"]);
560 $template->parseCurrentBlock();
561 $template->setCurrentBlock("detail_row");
562 $template->setVariable("TEXT_OPTION", $this->lng->txt("users_skipped"));
563 $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_SKIPPED"]);
564 $template->parseCurrentBlock();
565 /*
566 $template->setCurrentBlock("detail_row");
567 $template->setVariable("TEXT_OPTION", $this->lng->txt("mode"));
568 $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MODE"]);
569 $template->parseCurrentBlock();
570 $template->setCurrentBlock("detail_row");
571 $template->setVariable("TEXT_OPTION", $this->lng->txt("mode_nr_of_selections"));
572 $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MODE_NR_OF_SELECTIONS"]);
573 $template->parseCurrentBlock();
574 */
575 $template->setCurrentBlock("detail_row");
576 $template->setVariable("TEXT_OPTION", $this->lng->txt("categories"));
577 $table = array();
578 $idx = $selsum = 0;
579 if (is_array($this->cumulated["variables"]))
580 {
581 foreach ($this->cumulated["variables"] as $key => $value)
582 {
583 $table[] = array(
584 (++$idx).".",
585 $value["title"],
586 $value["selected"],
587 sprintf("%.2f", 100*$value["percentage"])."%"
588 );
589 $selsum += (int)$value["selected"];
590 }
591 }
592 $head = array(
593 "",
594 $this->lng->txt("title"),
595 $this->lng->txt("category_nr_selected"),
596 $this->lng->txt("percentage_of_selections")
597 );
598 $foot = array(null, null, $selsum, null);
599 $template->setVariable("TEXT_OPTION_VALUE",
600 $this->renderStatisticsDetailsTable($head, $table, $foot));
601 $template->parseCurrentBlock();
602
603 // add text answers to detailed results
604 if (is_array($this->cumulated["textanswers"]))
605 {
606 $template->setCurrentBlock("detail_row");
607 $template->setVariable("TEXT_OPTION", $this->lng->txt("freetext_answers"));
608 $html = "";
609 foreach ($this->cumulated["textanswers"] as $key => $answers)
610 {
611 $html .= $this->cumulated["variables"][$key]["title"] ."\n";
612 $html .= "<ul>\n";
613 foreach ($answers as $answer)
614 {
615 $html .= "<li>" . preg_replace("/\n/", "<br>\n", $answer) . "</li>\n";
616 }
617 $html .= "</ul>\n";
618 }
619 $template->setVariable("TEXT_OPTION_VALUE", $html);
620 $template->parseCurrentBlock();
621 }
622
623 // chart
624 $template->setCurrentBlock("detail_row");
625 $template->setVariable("TEXT_OPTION", $this->lng->txt("chart"));
626 $template->setVariable("TEXT_OPTION_VALUE", $this->renderChart("svy_ch_".$this->object->getId(), $this->cumulated["variables"]));
627 $template->parseCurrentBlock();
628
629 $template->setVariable("QUESTION_TITLE", "$counter. ".$this->object->getTitle());
630 return $template->get();
631 }
renderChart($a_id, $a_variables)
renderStatisticsDetailsTable(array $a_head, array $a_rows, array $a_foot=null)
_getNrOfParticipants($survey_id)
Returns the number of participants for a survey.
special template class to simplify handling of ITX/PEAR
$html
Definition: example_001.php:87

References $html, ilObjSurvey\_getNrOfParticipants(), SurveyQuestionGUI\renderChart(), and SurveyQuestionGUI\renderStatisticsDetailsTable().

+ Here is the call graph for this function:

◆ getParsedAnswers()

SurveyMultipleChoiceQuestionGUI::getParsedAnswers ( array  $a_working_data = null,
  $a_only_user_anwers = false 
)

Definition at line 175 of file class.SurveyMultipleChoiceQuestionGUI.php.

176 {
177 if(is_array($a_working_data))
178 {
179 $user_answers = $a_working_data;
180 }
181
182 $options = array();
183 for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++)
184 {
185 $cat = $this->object->categories->getCategory($i);
186 $value = ($cat->scale) ? ($cat->scale - 1) : $i;
187
188 $checked = "unchecked";
189 $text = null;
190 if(is_array($a_working_data))
191 {
192 foreach($user_answers as $user_answer)
193 {
194 if($value == $user_answer["value"])
195 {
196 $checked = "checked";
197 if($user_answer["textanswer"])
198 {
199 $text = $user_answer["textanswer"];
200 }
201 break;
202 }
203 }
204 }
205
206 // "other" options have to be last or horizontal will be screwed
207 $idx = $cat->other."_".$value;
208
209 if(!$a_only_user_anwers || $checked == "checked")
210
211 $options[$idx] = array(
212 "value" => $value
213 ,"title" => trim($cat->title)
214 ,"other" => (bool)$cat->other
215 ,"checked" => $checked
216 ,"textanswer" => $text
217 );
218
219 ksort($options);
220 }
221
222 return array_values($options);
223 }
$text
if(!is_array($argv)) $options

References $options, and $text.

Referenced by getPrintView().

+ Here is the caller graph for this function:

◆ getPrintView()

SurveyMultipleChoiceQuestionGUI::getPrintView (   $question_title = 1,
  $show_questiontext = 1,
  $survey_id = null,
array  $a_working_data = null 
)

Creates a HTML representation of the question.

@access private

Definition at line 230 of file class.SurveyMultipleChoiceQuestionGUI.php.

231 {
232 $options = $this->getParsedAnswers($a_working_data);
233
234 $template = new ilTemplate("tpl.il_svy_qpl_mc_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
235 switch ($this->object->getOrientation())
236 {
237 case 0:
238 // vertical orientation
239 foreach($options as $option)
240 {
241 if ($option["other"])
242 {
243 $template->setCurrentBlock("other_row");
244 $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_".$option["checked"].".png")));
245 $template->setVariable("ALT_CHECKBOX", $this->lng->txt($option["checked"]));
246 $template->setVariable("TITLE_CHECKBOX", $this->lng->txt($option["checked"]));
247 $template->setVariable("OTHER_LABEL", ilUtil::prepareFormOutput($option["title"]));
248 $template->setVariable("OTHER_ANSWER", $option["textanswer"]
249 ? ilUtil::prepareFormOutput($option["textanswer"])
250 : "&nbsp;");
251 $template->parseCurrentBlock();
252 }
253 else
254 {
255 $template->setCurrentBlock("mc_row");
256 $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_".$option["checked"].".png")));
257 $template->setVariable("ALT_CHECKBOX", $this->lng->txt($option["checked"]));
258 $template->setVariable("TITLE_CHECKBOX", $this->lng->txt($option["checked"]));
259 $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($option["title"]));
260 $template->parseCurrentBlock();
261 }
262 }
263 break;
264 case 1:
265 // horizontal orientation
266 foreach($options as $option)
267 {
268 $template->setCurrentBlock("checkbox_col");
269 $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_".$option["checked"].".png")));
270 $template->setVariable("ALT_CHECKBOX", $this->lng->txt($option["checked"]));
271 $template->setVariable("TITLE_CHECKBOX", $this->lng->txt($option["checked"]));
272 $template->parseCurrentBlock();
273 }
274 foreach($options as $option)
275 {
276 if ($option["other"])
277 {
278 $template->setCurrentBlock("other_text_col");
279 $template->setVariable("OTHER_LABEL", ilUtil::prepareFormOutput($option["title"]));
280 $template->setVariable("OTHER_ANSWER", $option["textanswer"]
281 ? ilUtil::prepareFormOutput($option["textanswer"])
282 : "&nbsp;");
283 $template->parseCurrentBlock();
284 }
285 else
286 {
287 $template->setCurrentBlock("text_col");
288 $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($option["title"]));
289 $template->parseCurrentBlock();
290 }
291 }
292 break;
293 }
294
295 if ($this->object->use_min_answers)
296 {
297 $template->setCurrentBlock('min_max_msg');
298 if ($this->object->nr_min_answers > 0 && $this->object->nr_max_answers > 0)
299 {
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));
301 }
302 else if ($this->object->nr_min_answers > 0)
303 {
304 $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_nr_answers'), $this->object->nr_min_answers));
305 }
306 else if ($this->object->nr_max_answers > 0)
307 {
308 $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_max_nr_answers'), $this->object->nr_max_answers));
309 }
310 $template->parseCurrentBlock();
311 }
312 if ($show_questiontext)
313 {
314 $this->outQuestionText($template);
315 }
316 if ($question_title)
317 {
318 $template->setVariable("QUESTION_TITLE", $this->getPrintViewQuestionTitle($question_title));
319 }
320 $template->parseCurrentBlock();
321 return $template->get();
322 }
getParsedAnswers(array $a_working_data=null, $a_only_user_anwers=false)
getPrintViewQuestionTitle($question_title=1)
static getHtmlPath($relative_path)
get url of path
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public

References $options, ilUtil\getHtmlPath(), ilUtil\getImagePath(), getParsedAnswers(), SurveyQuestionGUI\getPrintViewQuestionTitle(), SurveyQuestionGUI\outQuestionText(), and ilUtil\prepareFormOutput().

+ Here is the call graph for this function:

◆ getWorkingForm()

SurveyMultipleChoiceQuestionGUI::getWorkingForm (   $working_data = "",
  $question_title = 1,
  $show_questiontext = 1,
  $error_message = "",
  $survey_id = null 
)

Creates the question output form for the learner.

@access public

Reimplemented from SurveyQuestionGUI.

Definition at line 334 of file class.SurveyMultipleChoiceQuestionGUI.php.

335 {
336 $template = new ilTemplate("tpl.il_svy_out_mc.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
337 $template->setCurrentBlock("material");
338 $template->setVariable("TEXT_MATERIAL", $this->getMaterialOutput());
339 $template->parseCurrentBlock();
340 switch ($this->object->getOrientation())
341 {
342 case 0:
343 // vertical orientation
344 for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++)
345 {
346 $cat = $this->object->categories->getCategory($i);
347 if ($cat->other)
348 {
349 $template->setCurrentBlock("other_row");
350 if (strlen($cat->title))
351 {
352 $template->setVariable("OTHER_LABEL", $cat->title);
353 }
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))
357 {
358 foreach ($working_data as $value)
359 {
360 if (strlen($value["value"]))
361 {
362 if ($value["value"] == $cat->scale-1)
363 {
364 $template->setVariable("OTHER_VALUE", ' value="' . ilUtil::prepareFormOutput($value['textanswer']) . '"');
365 if (!$value['uncheck'])
366 {
367 $template->setVariable("CHECKED_MC", " checked=\"checked\"");
368 }
369 }
370 }
371 }
372 }
373 $template->parseCurrentBlock();
374 }
375 else
376 {
377 $template->setCurrentBlock("mc_row");
378 if ($cat->neutral) $template->setVariable('ROWCLASS', ' class="neutral"');
379 $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($cat->title));
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))
383 {
384 foreach ($working_data as $value)
385 {
386 if (strlen($value["value"]))
387 {
388 if ($value["value"] == $cat->scale-1)
389 {
390 if (!$value['uncheck'])
391 {
392 $template->setVariable("CHECKED_MC", " checked=\"checked\"");
393 }
394 }
395 }
396 }
397 }
398 $template->parseCurrentBlock();
399 }
400 $template->touchBlock('outer_row');
401 }
402 break;
403 case 1:
404 // horizontal orientation
405
406 // #15477 - reverting the categorizing of answers
407 for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++)
408 {
409 $cat = $this->object->categories->getCategory($i);
410
411 // checkbox
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))
417 {
418 foreach ($working_data as $value)
419 {
420 if (strlen($value["value"]))
421 {
422 if ($value["value"] == $cat->scale-1)
423 {
424 if (!$value['uncheck'])
425 {
426 $template->setVariable("CHECKED_MC", " checked=\"checked\"");
427 }
428 }
429 }
430 }
431 }
432 $template->parseCurrentBlock();
433
434 // answer & input
435 if ($cat->other)
436 {
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))
441 {
442 $template->setVariable("OTHER_LABEL", $cat->title);
443 }
444 if (is_array($working_data))
445 {
446 foreach ($working_data as $value)
447 {
448 if (strlen($value["value"]))
449 {
450 if ($value["value"] == $cat->scale-1)
451 {
452 $template->setVariable("OTHER_VALUE", ' value="' . ilUtil::prepareFormOutput($value['textanswer']) . '"');
453 }
454 }
455 }
456 }
457 $template->parseCurrentBlock();
458 }
459 // answer
460 else
461 {
462 $template->setCurrentBlock("text_col");
463 if ($cat->neutral) $template->setVariable('COLCLASS', ' neutral');
464 $template->setVariable("VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
465 $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($cat->title));
466 $template->setVariable("QUESTION_ID", $this->object->getId());
467 $template->parseCurrentBlock();
468 }
469 $template->touchBlock('text_outer_col');
470 }
471 break;
472 }
473
474 $template->setCurrentBlock("question_data");
475 if ($this->object->use_min_answers)
476 {
477 $template->setCurrentBlock('min_max_msg');
478 if ($this->object->nr_min_answers > 0 && $this->object->nr_max_answers > 0)
479 {
480 if ($this->object->nr_min_answers == $this->object->nr_max_answers)
481 {
482 $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_max_exact_answers'), $this->object->nr_min_answers));
483 }
484 else
485 {
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));
487 }
488 }
489 else if ($this->object->nr_min_answers > 0)
490 {
491 $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_nr_answers'), $this->object->nr_min_answers));
492 }
493 else if ($this->object->nr_max_answers > 0)
494 {
495 $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_max_nr_answers'), $this->object->nr_max_answers));
496 }
497 $template->parseCurrentBlock();
498 }
499 if (strcmp($error_message, "") != 0)
500 {
501 $template->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
502 }
503 if ($show_questiontext)
504 {
505 $this->outQuestionText($template);
506 }
507 if ($question_title)
508 {
509 $template->setVariable("QUESTION_TITLE", $this->object->getTitle());
510 }
511 $template->parseCurrentBlock();
512 return $template->get();
513 }
getMaterialOutput()
Creates the HTML output of the question material(s)

References SurveyQuestionGUI\getMaterialOutput(), SurveyQuestionGUI\outQuestionText(), and ilUtil\prepareFormOutput().

+ Here is the call graph for this function:

◆ importEditFormValues()

SurveyMultipleChoiceQuestionGUI::importEditFormValues ( ilPropertyFormGUI  $a_form)
protected

Reimplemented from SurveyQuestionGUI.

Definition at line 153 of file class.SurveyMultipleChoiceQuestionGUI.php.

154 {
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');
162
163 $this->object->categories->flushCategories();
164
165 foreach ($_POST['answers']['answer'] as $key => $value)
166 {
167 if (strlen($value)) $this->object->getCategories()->addCategory($value, $_POST['answers']['other'][$key], 0, null, $_POST['answers']['scale'][$key]);
168 }
169 if (strlen($_POST['answers']['neutral']))
170 {
171 $this->object->getCategories()->addCategory($_POST['answers']['neutral'], 0, 1, null, $_POST['answers_neutral_scale']);
172 }
173 }
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
$_POST['username']
Definition: cron.php:12

References $_POST, and ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

◆ initObject()

SurveyMultipleChoiceQuestionGUI::initObject ( )
protected

Reimplemented from SurveyQuestionGUI.

Definition at line 39 of file class.SurveyMultipleChoiceQuestionGUI.php.

40 {
41 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyMultipleChoiceQuestion.php";
42 $this->object = new SurveyMultipleChoiceQuestion();
43 }

◆ setQuestionTabs()

SurveyMultipleChoiceQuestionGUI::setQuestionTabs ( )

Reimplemented from SurveyQuestionGUI.

Definition at line 49 of file class.SurveyMultipleChoiceQuestionGUI.php.

50 {
51 $this->setQuestionTabsForClass("surveymultiplechoicequestiongui");
52 }

References SurveyQuestionGUI\setQuestionTabsForClass().

+ Here is the call graph for this function:

◆ validateEditForm()

SurveyMultipleChoiceQuestionGUI::validateEditForm ( ilPropertyFormGUI  $a_form)
protected

Reimplemented from SurveyQuestionGUI.

Definition at line 111 of file class.SurveyMultipleChoiceQuestionGUI.php.

112 {
113 if($a_form->getInput("use_min_answers"))
114 {
115 // #13927 - see importEditFormValues()
116 $cnt_answers = 0;
117 foreach ($_POST['answers']['answer'] as $key => $value)
118 {
119 if (strlen($value))
120 {
121 $cnt_answers++;
122 }
123 }
124 if (strlen($_POST['answers']['neutral']))
125 {
126 $cnt_answers++;
127 }
128 /* this would be the DB-values
129 $cnt_answers = $a_form->getItemByPostVar("answers");
130 $cnt_answers = $cnt_answers->getCategoryCount();
131 */
132 $min_anwers = $a_form->getInput("nr_min_answers");
133 $max_anwers = $a_form->getInput("nr_max_answers");
134
135 if ($min_anwers &&
136 $min_anwers > $cnt_answers)
137 {
138 $a_form->getItemByPostVar("nr_min_answers")->setAlert($this->lng->txt('err_minvalueganswers'));
139 $errors = true;
140 }
141 if ($max_anwers > 0 &&
142 ($max_anwers > $cnt_answers || $max_anwers < $min_anwers))
143 {
144 $a_form->getItemByPostVar("nr_max_answers")->setAlert($this->lng->txt('err_maxvaluegeminvalue'));
145 $errors = true;
146 }
147 }
148
149 ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
150 return !$errors;
151 }
getItemByPostVar($a_post_var)
Get Item by POST variable.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$errors

References $_POST, $errors, ilPropertyFormGUI\getInput(), ilPropertyFormGUI\getItemByPostVar(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: