ILIAS  release_8 Revision v8.24
SurveyMultipleChoiceQuestionGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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 (int $question_title=1, bool $show_questiontext=true, ?int $survey_id=null, ?array $working_data=null)
 
 getWorkingForm (array $working_data=null, int $question_title=1, bool $show_questiontext=true, string $error_message="", int $survey_id=null, bool $compress_view=false)
 Creates the question output form for the learner. More...
 
- Public Member Functions inherited from SurveyQuestionGUI
 __construct ($a_id=-1)
 
 setQuestionTabs ()
 
 executeCommand ()
 
 getQuestionType ()
 Returns the question type string. More...
 
 setBackUrl (string $a_url)
 
 setQuestionTabsForClass (string $guiclass)
 
 getPrintView (int $question_title=1, bool $show_questiontext=true, ?int $survey_id=null, ?array $working_data=null)
 
 preview ()
 
 getWorkingForm (array $working_data=null, int $question_title=1, bool $show_questiontext=true, string $error_message="", int $survey_id=null, bool $compress_view=false)
 
 material (bool $checkonly=false)
 Material tab of the survey questions. More...
 
 deleteMaterial ()
 
 addMaterial ()
 Add materials to a question. More...
 
 removeMaterial ()
 
 cancelExplorer ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 linkChilds ()
 
 savePhrase (bool $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 (ilTemplate $template)
 
 initEditForm ()
 
 addCommandButtons (ilPropertyFormGUI $a_form)
 
 editQuestion (ilPropertyFormGUI $a_form=null)
 
 saveSync ()
 
 saveReturn ()
 
 saveForm ()
 
 save (bool $a_return=false, bool $a_sync=false)
 
 copySyncForm ()
 
 syncCopies ()
 
 originalSyncForm ()
 
 sync ()
 
 cancelSync ()
 
 redirectAfterSaving (bool $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 (int $question_title=1)
 
 getQuestionTitle (int $question_title_mode=1)
 
 getMaterialOutput ()
 Creates the HTML output of the question material(s) More...
 
 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 (?string $questiontype, int $question_id=-1)
 Creates a question gui representation. More...
 
static _getGUIClassNameForId (int $a_q_id)
 
static _getClassNameForQType (string $q_type)
 
- Data Fields inherited from SurveyQuestionGUI
SurveyQuestion $object = null
 
- Protected Attributes inherited from SurveyQuestionGUI
EditingGUIRequest $request
 
EditManager $edit_manager
 
ilRbacSystem $rbacsystem
 
ilObjUser $user
 
ilAccessHandler $access
 
ilTree $tree
 
ilToolbarGUI $toolbar
 
ilTabsGUI $tabs
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilCtrl $ctrl
 
array $cumulated = []
 
string $parent_url = ""
 
ilLogger $log
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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

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

Member Function Documentation

◆ addFieldsToEditForm()

SurveyMultipleChoiceQuestionGUI::addFieldsToEditForm ( ilPropertyFormGUI  $a_form)
protected

Reimplemented from SurveyQuestionGUI.

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

41 : void
42 {
43 // orientation
44 $orientation = new ilRadioGroupInputGUI($this->lng->txt("orientation"), "orientation");
45 $orientation->setRequired(false);
46 $orientation->addOption(new ilRadioOption($this->lng->txt('vertical'), 0));
47 $orientation->addOption(new ilRadioOption($this->lng->txt('horizontal'), 1));
48 $a_form->addItem($orientation);
49
50 // minimum answers
51 $minanswers = new ilCheckboxInputGUI($this->lng->txt("use_min_answers"), "use_min_answers");
52 $minanswers->setValue(1);
53 $minanswers->setOptionTitle($this->lng->txt("use_min_answers_option"));
54 $minanswers->setRequired(false);
55
56 $nranswers = new ilNumberInputGUI($this->lng->txt("nr_min_answers"), "nr_min_answers");
57 $nranswers->setSize(5);
58 $nranswers->setDecimals(0);
59 $nranswers->setRequired(false);
60 $nranswers->setMinValue(1);
61 $minanswers->addSubItem($nranswers);
62
63 $nrmaxanswers = new ilNumberInputGUI($this->lng->txt("nr_max_answers"), "nr_max_answers");
64 $nrmaxanswers->setSize(5);
65 $nrmaxanswers->setDecimals(0);
66 $nrmaxanswers->setRequired(false);
67 $nrmaxanswers->setMinValue(1);
68 $minanswers->addSubItem($nrmaxanswers);
69
70 $a_form->addItem($minanswers);
71
72 // Answers
73 $answers = new ilCategoryWizardInputGUI($this->lng->txt("answers"), "answers");
74 $answers->setRequired(false);
75 $answers->setAllowMove(true);
76 $answers->setShowWizard(false);
77 $answers->setShowSavePhrase(false);
78 $answers->setUseOtherAnswer(true);
79 $answers->setShowNeutralCategory(true);
80 $answers->setNeutralCategoryTitle($this->lng->txt('svy_neutral_answer'));
81 $answers->setDisabledScale(false);
82 $a_form->addItem($answers);
83
84
85 // values
86 $orientation->setValue($this->object->getOrientation());
87 $minanswers->setChecked((bool) $this->object->use_min_answers);
88 $nranswers->setValue($this->object->nr_min_answers);
89 $nrmaxanswers->setValue($this->object->nr_max_answers);
90 if (!$this->object->getCategories()->getCategoryCount()) {
91 $this->object->getCategories()->addCategory("");
92 }
93 $answers->setValues($this->object->getCategories());
94 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a checkbox property in a property form.
This class represents a number property in a property form.
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ getParsedAnswers()

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

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

160 : array {
161 if (is_array($a_working_data)) {
162 $user_answers = $a_working_data;
163 }
164
165 $options = array();
166 for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++) {
167 $cat = $this->object->categories->getCategory($i);
168 $value = ($cat->scale) ? ($cat->scale - 1) : $i;
169
170 $checked = "unchecked";
171 $text = null;
172 if (is_array($a_working_data)) {
173 foreach ($user_answers as $user_answer) {
174 if ($value == $user_answer["value"]) {
175 $checked = "checked";
176 if ($user_answer["textanswer"]) {
177 $text = $user_answer["textanswer"];
178 }
179 break;
180 }
181 }
182 }
183
184 // "other" options have to be last or horizontal will be screwed
185 $idx = $cat->other . "_" . $value;
186
187 if (!$a_only_user_anwers || $checked === "checked") {
188 $options[$idx] = array(
189 "value" => $value
190 ,"title" => trim($cat->title)
191 ,"other" => (bool) $cat->other
192 ,"checked" => $checked
193 ,"textanswer" => $text
194 );
195 }
196
197 ksort($options);
198 }
199
200 return array_values($options);
201 }
$i
Definition: metadata.php:41

◆ getPrintView()

SurveyMultipleChoiceQuestionGUI::getPrintView ( int  $question_title = 1,
bool  $show_questiontext = true,
?int  $survey_id = null,
?array  $working_data = null 
)

Reimplemented from SurveyQuestionGUI.

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

208 : string {
209 $options = $this->getParsedAnswers($working_data);
210
211 $template = new ilTemplate("tpl.il_svy_qpl_mc_printview.html", true, true, "Modules/SurveyQuestionPool");
212 switch ($this->object->getOrientation()) {
213 case 0:
214 // vertical orientation
215 foreach ($options as $option) {
216 if ($option["other"]) {
217 $template->setCurrentBlock("other_row");
218 $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_" . $option["checked"] . ".png")));
219 $template->setVariable("ALT_CHECKBOX", $this->lng->txt($option["checked"]));
220 $template->setVariable("TITLE_CHECKBOX", $this->lng->txt($option["checked"]));
221 $template->setVariable(
222 "OTHER_LABEL",
224 );
225 $template->setVariable("OTHER_ANSWER", $option["textanswer"]
226 ? ilLegacyFormElementsUtil::prepareFormOutput($option["textanswer"])
227 : "&nbsp;");
228 } else {
229 $template->setCurrentBlock("mc_row");
230 $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_" . $option["checked"] . ".png")));
231 $template->setVariable("ALT_CHECKBOX", $this->lng->txt($option["checked"]));
232 $template->setVariable("TITLE_CHECKBOX", $this->lng->txt($option["checked"]));
233 $template->setVariable("TEXT_MC", ilLegacyFormElementsUtil::prepareFormOutput($option["title"]));
234 }
235 $template->parseCurrentBlock();
236 }
237 break;
238 case 1:
239 // horizontal orientation
240 foreach ($options as $option) {
241 $template->setCurrentBlock("checkbox_col");
242 $template->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_" . $option["checked"] . ".png")));
243 $template->setVariable("ALT_CHECKBOX", $this->lng->txt($option["checked"]));
244 $template->setVariable("TITLE_CHECKBOX", $this->lng->txt($option["checked"]));
245 $template->parseCurrentBlock();
246 }
247 foreach ($options as $option) {
248 if ($option["other"]) {
249 $template->setCurrentBlock("other_text_col");
250 $template->setVariable(
251 "OTHER_LABEL",
253 );
254 $template->setVariable("OTHER_ANSWER", $option["textanswer"]
255 ? ilLegacyFormElementsUtil::prepareFormOutput($option["textanswer"])
256 : "&nbsp;");
257 } else {
258 $template->setCurrentBlock("text_col");
259 $template->setVariable("TEXT_MC", ilLegacyFormElementsUtil::prepareFormOutput($option["title"]));
260 }
261 $template->parseCurrentBlock();
262 }
263 break;
264 }
265
266 if ($this->object->use_min_answers) {
267 $template->setCurrentBlock('min_max_msg');
268 if ($this->object->nr_min_answers > 0 && $this->object->nr_max_answers > 0) {
269 $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_max_nr_answers'), $this->object->nr_min_answers, $this->object->nr_max_answers));
270 } elseif ($this->object->nr_min_answers > 0) {
271 $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_min_nr_answers'), $this->object->nr_min_answers));
272 } elseif ($this->object->nr_max_answers > 0) {
273 $template->setVariable('MIN_MAX_MSG', sprintf($this->lng->txt('msg_max_nr_answers'), $this->object->nr_max_answers));
274 }
275 $template->parseCurrentBlock();
276 }
277 if ($show_questiontext) {
278 $this->outQuestionText($template);
279 }
280 if ($question_title) {
281 $template->setVariable("QUESTION_TITLE", $this->getPrintViewQuestionTitle($question_title));
282 }
283 $template->parseCurrentBlock();
284 return $template->get();
285 }
getParsedAnswers(array $a_working_data=null, $a_only_user_anwers=false)
getPrintViewQuestionTitle(int $question_title=1)
outQuestionText(ilTemplate $template)
static prepareFormOutput($a_str, bool $a_strip=false)
special template class to simplify handling of ITX/PEAR
static getHtmlPath(string $relative_path)
get url of path
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

◆ getWorkingForm()

SurveyMultipleChoiceQuestionGUI::getWorkingForm ( array  $working_data = null,
int  $question_title = 1,
bool  $show_questiontext = true,
string  $error_message = "",
int  $survey_id = null,
bool  $compress_view = false 
)

Creates the question output form for the learner.

Reimplemented from SurveyQuestionGUI.

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

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

References $i, ILIAS\Repository\object(), and ilLegacyFormElementsUtil\prepareFormOutput().

+ Here is the call graph for this function:

◆ importEditFormValues()

SurveyMultipleChoiceQuestionGUI::importEditFormValues ( ilPropertyFormGUI  $a_form)
protected

Reimplemented from SurveyQuestionGUI.

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

134 : void
135 {
136 $this->object->setOrientation($a_form->getInput("orientation"));
137 $this->object->use_other_answer = ($a_form->getInput('use_other_answer')) ? 1 : 0;
138 $this->object->other_answer_label = $this->object->use_other_answer ? $a_form->getInput('other_answer_label') : "";
139 $this->object->use_min_answers = (bool) $a_form->getInput('use_min_answers');
140 $this->object->nr_min_answers = ($a_form->getInput('nr_min_answers') > 0) ? $a_form->getInput('nr_min_answers') : "";
141 $this->object->nr_max_answers = ($a_form->getInput('nr_max_answers') > 0) ? $a_form->getInput('nr_max_answers') : "";
142 $this->object->label = $a_form->getInput('label');
143
144 $this->object->categories->flushCategories();
145
146 $answers = $this->request->getAnswers();
147 foreach ($answers['answer'] as $key => $value) {
148 if (strlen($value)) {
149 $this->object->getCategories()->addCategory($value, $answers['other'][$key] ?? 0, 0, null, $answers['scale'][$key]);
150 }
151 }
152 if ($this->request->getNeutral() !== "") {
153 $this->object->getCategories()->addCategory($this->request->getNeutral(), 0, 1, null, $this->request->getNeutralScale());
154 }
155 }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key, and ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

◆ initObject()

SurveyMultipleChoiceQuestionGUI::initObject ( )
protected

Reimplemented from SurveyQuestionGUI.

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

27 : void
28 {
29 $this->object = new SurveyMultipleChoiceQuestion();
30 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ setQuestionTabs()

SurveyMultipleChoiceQuestionGUI::setQuestionTabs ( )

Reimplemented from SurveyQuestionGUI.

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

36 : void
37 {
38 $this->setQuestionTabsForClass("surveymultiplechoicequestiongui");
39 }
setQuestionTabsForClass(string $guiclass)

References SurveyQuestionGUI\setQuestionTabsForClass().

+ Here is the call graph for this function:

◆ validateEditForm()

SurveyMultipleChoiceQuestionGUI::validateEditForm ( ilPropertyFormGUI  $a_form)
protected

Reimplemented from SurveyQuestionGUI.

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

96 : bool
97 {
98 $errors = false;
99 if ($a_form->getInput("use_min_answers")) {
100 // #13927 - see importEditFormValues()
101 $cnt_answers = 0;
102 $answers = $this->request->getAnswers();
103 foreach ($answers['answer'] as $key => $value) {
104 if (strlen($value)) {
105 $cnt_answers++;
106 }
107 }
108 if ($this->request->getNeutral() !== "") {
109 $cnt_answers++;
110 }
111 /* this would be the DB-values
112 $cnt_answers = $a_form->getItemByPostVar("answers");
113 $cnt_answers = $cnt_answers->getCategoryCount();
114 */
115 $min_anwers = $a_form->getInput("nr_min_answers");
116 $max_anwers = $a_form->getInput("nr_max_answers");
117
118 if ($min_anwers &&
119 $min_anwers > $cnt_answers) {
120 $a_form->getItemByPostVar("nr_min_answers")->setAlert($this->lng->txt('err_minvalueganswers'));
121 $errors = true;
122 }
123 if ($max_anwers > 0 &&
124 ($max_anwers > $cnt_answers || $max_anwers < $min_anwers)) {
125 $a_form->getItemByPostVar("nr_max_answers")->setAlert($this->lng->txt('err_maxvaluegeminvalue'));
126 $errors = true;
127 }
128 }
129
130 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
131 return !$errors;
132 }
getItemByPostVar(string $a_post_var)
$errors
Definition: imgupload.php:65

References $errors, ILIAS\LTI\ToolProvider\$key, ilPropertyFormGUI\getInput(), ilPropertyFormGUI\getItemByPostVar(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

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