ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
SurveyMultipleChoiceQuestionGUI Class Reference

MultipleChoice survey question GUI representation. More...

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

Public Member Functions

 setQuestionTabs ()
 
 getPrintView ($question_title=1, $show_questiontext=1, $survey_id=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)
 
 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 ()
 

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

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

References ilPropertyFormGUI\addItem(), ilFormPropertyGUI\setRequired(), ilNumberInputGUI\setSize(), and ilCheckboxInputGUI\setValue().

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 an option in a radio group.
This class represents a checkbox property in a property form.
addItem($a_item)
Add Item (Property, SectionHeader).
This class represents a property in a property form.
This class represents a number property in a property form.
setValue($a_value)
Set Value.
This class represents a survey question category wizard property in a property form.
setSize($a_size)
Set Size.
setRequired($a_required)
Set Required.
+ 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 private

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

References ilObjSurvey\_getNrOfParticipants(), and SurveyQuestionGUI\renderChart().

475  {
476  if (count($this->cumulated) == 0)
477  {
478  if(!$finished_ids)
479  {
480  include_once "./Modules/Survey/classes/class.ilObjSurvey.php";
481  $nr_of_users = ilObjSurvey::_getNrOfParticipants($survey_id);
482  }
483  else
484  {
485  $nr_of_users = sizeof($finished_ids);
486  }
487  $this->cumulated =& $this->object->getCumulatedResults($survey_id, $nr_of_users, $finished_ids);
488  }
489 
490  $output = "";
491  include_once "./Services/UICore/classes/class.ilTemplate.php";
492  $template = new ilTemplate("tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE, "Modules/Survey");
493 
494  $template->setCurrentBlock("detail_row");
495  $template->setVariable("TEXT_OPTION", $this->lng->txt("question"));
496  $questiontext = $this->object->getQuestiontext();
497  $template->setVariable("TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
498  $template->parseCurrentBlock();
499  $template->setCurrentBlock("detail_row");
500  $template->setVariable("TEXT_OPTION", $this->lng->txt("question_type"));
501  $template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
502  $template->parseCurrentBlock();
503  $template->setCurrentBlock("detail_row");
504  $template->setVariable("TEXT_OPTION", $this->lng->txt("users_answered"));
505  $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_ANSWERED"]);
506  $template->parseCurrentBlock();
507  $template->setCurrentBlock("detail_row");
508  $template->setVariable("TEXT_OPTION", $this->lng->txt("users_skipped"));
509  $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_SKIPPED"]);
510  $template->parseCurrentBlock();
511  /*
512  $template->setCurrentBlock("detail_row");
513  $template->setVariable("TEXT_OPTION", $this->lng->txt("mode"));
514  $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MODE"]);
515  $template->parseCurrentBlock();
516  $template->setCurrentBlock("detail_row");
517  $template->setVariable("TEXT_OPTION", $this->lng->txt("mode_nr_of_selections"));
518  $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MODE_NR_OF_SELECTIONS"]);
519  $template->parseCurrentBlock();
520  */
521  $template->setCurrentBlock("detail_row");
522  $template->setVariable("TEXT_OPTION", $this->lng->txt("categories"));
523  $categories = "";
524  if (is_array($this->cumulated["variables"]))
525  {
526  foreach ($this->cumulated["variables"] as $key => $value)
527  {
528  $categories .= "<li>" . $value["title"] . ": n=" . $value["selected"] .
529  " (" . sprintf("%.2f", 100*$value["percentage"]) . "%)</li>";
530  }
531  }
532  $categories = "<ol>$categories</ol>";
533  $template->setVariable("TEXT_OPTION_VALUE", $categories);
534  $template->parseCurrentBlock();
535 
536  // add text answers to detailed results
537  if (is_array($this->cumulated["textanswers"]))
538  {
539  $template->setCurrentBlock("detail_row");
540  $template->setVariable("TEXT_OPTION", $this->lng->txt("freetext_answers"));
541  $html = "";
542  foreach ($this->cumulated["textanswers"] as $key => $answers)
543  {
544  $html .= $this->cumulated["variables"][$key]["title"] ."\n";
545  $html .= "<ul>\n";
546  foreach ($answers as $answer)
547  {
548  $html .= "<li>" . preg_replace("/\n/", "<br>\n", $answer) . "</li>\n";
549  }
550  $html .= "</ul>\n";
551  }
552  $template->setVariable("TEXT_OPTION_VALUE", $html);
553  $template->parseCurrentBlock();
554  }
555 
556  // chart
557  $template->setCurrentBlock("detail_row");
558  $template->setVariable("TEXT_OPTION", $this->lng->txt("chart"));
559  $template->setVariable("TEXT_OPTION_VALUE", $this->renderChart("svy_ch_".$this->object->getId(), $this->cumulated["variables"]));
560  $template->parseCurrentBlock();
561 
562  $template->setVariable("QUESTION_TITLE", "$counter. ".$this->object->getTitle());
563  return $template->get();
564  }
special template class to simplify handling of ITX/PEAR
renderChart($a_id, $a_variables)
_getNrOfParticipants($survey_id)
Returns the number of participants for a survey.
+ Here is the call graph for this function:

◆ getPrintView()

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

Creates a HTML representation of the question.

private

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

References ilUtil\getHtmlPath(), ilUtil\getImagePath(), SurveyQuestionGUI\outQuestionText(), and ilUtil\prepareFormOutput().

181  {
182  $template = new ilTemplate("tpl.il_svy_qpl_mc_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
183  switch ($this->object->getOrientation())
184  {
185  case 0:
186  // vertical orientation
187  for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++)
188  {
189  $cat = $this->object->categories->getCategory($i);
190  if ($cat->other)
191  {
192  $template->setCurrentBlock("other_row");
193  $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.png")));
194  $template->setVariable("ALT_CHECKBOX", $this->lng->txt("unchecked"));
195  $template->setVariable("TITLE_CHECKBOX", $this->lng->txt("unchecked"));
196  $template->setVariable("OTHER_LABEL", ilUtil::prepareFormOutput($cat->title));
197  $template->setVariable("OTHER_ANSWER", "&nbsp;");
198  $template->parseCurrentBlock();
199  }
200  else
201  {
202  $template->setCurrentBlock("mc_row");
203  $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.png")));
204  $template->setVariable("ALT_CHECKBOX", $this->lng->txt("unchecked"));
205  $template->setVariable("TITLE_CHECKBOX", $this->lng->txt("unchecked"));
206  $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($cat->title));
207  $template->parseCurrentBlock();
208  }
209  }
210  break;
211  case 1:
212  // horizontal orientation
213  for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++)
214  {
215  $template->setCurrentBlock("checkbox_col");
216  $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.png")));
217  $template->setVariable("ALT_CHECKBOX", $this->lng->txt("unchecked"));
218  $template->setVariable("TITLE_CHECKBOX", $this->lng->txt("unchecked"));
219  $template->parseCurrentBlock();
220  }
221  for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++)
222  {
223  $cat = $this->object->categories->getCategory($i);
224  if ($cat->other)
225  {
226  $template->setCurrentBlock("other_text_col");
227  $template->setVariable("OTHER_LABEL", ilUtil::prepareFormOutput($cat->title));
228  $template->setVariable("OTHER_ANSWER", "&nbsp;");
229  $template->parseCurrentBlock();
230  }
231  else
232  {
233  $template->setCurrentBlock("text_col");
234  $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($cat->title));
235  $template->parseCurrentBlock();
236  }
237  }
238  break;
239  }
240 
241  if ($this->object->use_min_answers)
242  {
243  $template->setCurrentBlock('min_max_msg');
244  if ($this->object->nr_min_answers > 0 && $this->object->nr_max_answers > 0)
245  {
246  $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_max_nr_answers'), $this->object->nr_min_answers, $this->object->nr_max_answers));
247  }
248  else if ($this->object->nr_min_answers > 0)
249  {
250  $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_nr_answers'), $this->object->nr_min_answers));
251  }
252  else if ($this->object->nr_max_answers > 0)
253  {
254  $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_max_nr_answers'), $this->object->nr_max_answers));
255  }
256  $template->parseCurrentBlock();
257  }
258  if ($show_questiontext)
259  {
260  $this->outQuestionText($template);
261  }
262  if ($question_title)
263  {
264  $template->setVariable("QUESTION_TITLE", $this->object->getTitle());
265  }
266  $template->parseCurrentBlock();
267  return $template->get();
268  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
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
+ 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.

public

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

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

281  {
282  $template = new ilTemplate("tpl.il_svy_out_mc.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
283  $template->setCurrentBlock("material");
284  $template->setVariable("TEXT_MATERIAL", $this->getMaterialOutput());
285  $template->parseCurrentBlock();
286  switch ($this->object->getOrientation())
287  {
288  case 0:
289  // vertical orientation
290  for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++)
291  {
292  $cat = $this->object->categories->getCategory($i);
293  if ($cat->other)
294  {
295  $template->setCurrentBlock("other_row");
296  if (strlen($cat->title))
297  {
298  $template->setVariable("OTHER_LABEL", $cat->title);
299  }
300  $template->setVariable("VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
301  $template->setVariable("QUESTION_ID", $this->object->getId());
302  if (is_array($working_data))
303  {
304  foreach ($working_data as $value)
305  {
306  if (strlen($value["value"]))
307  {
308  if ($value["value"] == $cat->scale-1)
309  {
310  $template->setVariable("OTHER_VALUE", ' value="' . ilUtil::prepareFormOutput($value['textanswer']) . '"');
311  if (!$value['uncheck'])
312  {
313  $template->setVariable("CHECKED_MC", " checked=\"checked\"");
314  }
315  }
316  }
317  }
318  }
319  $template->parseCurrentBlock();
320  }
321  else
322  {
323  $template->setCurrentBlock("mc_row");
324  if ($cat->neutral) $template->setVariable('ROWCLASS', ' class="neutral"');
325  $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($cat->title));
326  $template->setVariable("VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
327  $template->setVariable("QUESTION_ID", $this->object->getId());
328  if (is_array($working_data))
329  {
330  foreach ($working_data as $value)
331  {
332  if (strlen($value["value"]))
333  {
334  if ($value["value"] == $cat->scale-1)
335  {
336  if (!$value['uncheck'])
337  {
338  $template->setVariable("CHECKED_MC", " checked=\"checked\"");
339  }
340  }
341  }
342  }
343  }
344  $template->parseCurrentBlock();
345  }
346  $template->touchBlock('outer_row');
347  }
348  break;
349  case 1:
350  // horizontal orientation
351 
352  // #15477 - reverting the categorizing of answers
353  for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++)
354  {
355  $cat = $this->object->categories->getCategory($i);
356 
357  // checkbox
358  $template->setCurrentBlock("checkbox_col");
359  if ($cat->neutral) $template->setVariable('COLCLASS', ' neutral');
360  $template->setVariable("VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
361  $template->setVariable("QUESTION_ID", $this->object->getId());
362  if (is_array($working_data))
363  {
364  foreach ($working_data as $value)
365  {
366  if (strlen($value["value"]))
367  {
368  if ($value["value"] == $cat->scale-1)
369  {
370  if (!$value['uncheck'])
371  {
372  $template->setVariable("CHECKED_MC", " checked=\"checked\"");
373  }
374  }
375  }
376  }
377  }
378  $template->parseCurrentBlock();
379 
380  // answer & input
381  if ($cat->other)
382  {
383  $template->setCurrentBlock("text_other_col");
384  $template->setVariable("VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
385  $template->setVariable("QUESTION_ID", $this->object->getId());
386  if (strlen($cat->title))
387  {
388  $template->setVariable("OTHER_LABEL", $cat->title);
389  }
390  if (is_array($working_data))
391  {
392  foreach ($working_data as $value)
393  {
394  if (strlen($value["value"]))
395  {
396  if ($value["value"] == $cat->scale-1)
397  {
398  $template->setVariable("OTHER_VALUE", ' value="' . ilUtil::prepareFormOutput($value['textanswer']) . '"');
399  }
400  }
401  }
402  }
403  $template->parseCurrentBlock();
404  }
405  // answer
406  else
407  {
408  $template->setCurrentBlock("text_col");
409  if ($cat->neutral) $template->setVariable('COLCLASS', ' neutral');
410  $template->setVariable("VALUE_MC", ($cat->scale) ? ($cat->scale - 1) : $i);
411  $template->setVariable("TEXT_MC", ilUtil::prepareFormOutput($cat->title));
412  $template->setVariable("QUESTION_ID", $this->object->getId());
413  $template->parseCurrentBlock();
414  }
415  $template->touchBlock('text_outer_col');
416  }
417  break;
418  }
419 
420  $template->setCurrentBlock("question_data");
421  if ($this->object->use_min_answers)
422  {
423  $template->setCurrentBlock('min_max_msg');
424  if ($this->object->nr_min_answers > 0 && $this->object->nr_max_answers > 0)
425  {
426  if ($this->object->nr_min_answers == $this->object->nr_max_answers)
427  {
428  $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_max_exact_answers'), $this->object->nr_min_answers));
429  }
430  else
431  {
432  $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_max_nr_answers'), $this->object->nr_min_answers, $this->object->nr_max_answers));
433  }
434  }
435  else if ($this->object->nr_min_answers > 0)
436  {
437  $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_nr_answers'), $this->object->nr_min_answers));
438  }
439  else if ($this->object->nr_max_answers > 0)
440  {
441  $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_max_nr_answers'), $this->object->nr_max_answers));
442  }
443  $template->parseCurrentBlock();
444  }
445  if (strcmp($error_message, "") != 0)
446  {
447  $template->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
448  }
449  if ($show_questiontext)
450  {
451  $this->outQuestionText($template);
452  }
453  if ($question_title)
454  {
455  $template->setVariable("QUESTION_TITLE", $this->object->getTitle());
456  }
457  $template->parseCurrentBlock();
458  return $template->get();
459  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getMaterialOutput()
Creates the HTML output of the question material(s)
special template class to simplify handling of ITX/PEAR
+ Here is the call graph for this function:

◆ importEditFormValues()

SurveyMultipleChoiceQuestionGUI::importEditFormValues ( ilPropertyFormGUI  $a_form)
protected

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

References $_POST, and ilPropertyFormGUI\getInput().

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  }
$_POST['username']
Definition: cron.php:12
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
+ Here is the call graph for this function:

◆ initObject()

SurveyMultipleChoiceQuestionGUI::initObject ( )
protected

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 ( )

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

References SurveyQuestionGUI\setQuestionTabsForClass().

50  {
51  $this->setQuestionTabsForClass("surveymultiplechoicequestiongui");
52  }
+ Here is the call graph for this function:

◆ validateEditForm()

SurveyMultipleChoiceQuestionGUI::validateEditForm ( ilPropertyFormGUI  $a_form)
protected

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

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

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  }
$_POST['username']
Definition: cron.php:12
getItemByPostVar($a_post_var)
Get Item by POST variable.
$errors
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

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