ILIAS  release_8 Revision v8.24
class.assLongMenuGUI.php
Go to the documentation of this file.
1<?php
2
19include_once './Modules/Test/classes/inc.AssessmentConstants.php';
20
29{
30 private $ilTabs;
31
32 public function __construct($id = -1)
33 {
35 include_once './Modules/TestQuestionPool/classes/class.assLongMenu.php';
36 $this->object = new assLongMenu();
37 if ($id >= 0) {
38 $this->object->loadFromDb($id);
39 }
40 global $DIC;
41 $ilTabs = $DIC['ilTabs'];
42 $lng = $DIC['lng'];
43 $this->ilTabs = $ilTabs;
44 $this->lng = $lng;
45 }
46
52 protected function getUserSolution($active_id, $pass): array
53 {
54 $user_solution = array();
55 if ($active_id) {
56 $solutions = $this->object->getSolutionValues($active_id, $pass, true);
57 // hey.
58 foreach ($solutions as $idx => $solution_value) {
59 $user_solution[$solution_value["value1"]] = $solution_value["value2"];
60 }
61 return $user_solution;
62 }
63 return $user_solution;
64 }
65
66 public function getCommand($cmd)
67 {
68 return $cmd;
69 }
70
74 protected function writePostData(bool $always = false): int
75 {
76 $form = $this->buildEditForm();
77 $form->setValuesByPost();
78 $check = $form->checkInput() && $this->verifyAnswerOptions();
79
80 if (!$check) {
81 $this->editQuestion($form);
82 return 1;
83 }
86 $custom_check = $this->object->checkQuestionCustomPart($form);
87 if (!$custom_check) {
88 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_input_not_valid"));
89 $this->editQuestion($form);
90 return 1;
91 }
93 return 0;
94 }
95
97 {
98 $longmenu_text = $this->request->raw('longmenu_text') ?? '';
99 $hidden_text_files = $this->request->raw('hidden_text_files') ?? '';
100 $hidden_correct_answers = $this->request->raw('hidden_correct_answers') ?? [];
101 $long_menu_type = $this->request->raw('long_menu_type') ?? '';
102 $this->object->setLongMenuTextValue(ilUtil::stripSlashes($longmenu_text));
103 $this->object->setAnswers($this->trimArrayRecursive($this->stripSlashesRecursive(json_decode($hidden_text_files))));
104 $this->object->setCorrectAnswers($this->trimArrayRecursive($this->stripSlashesRecursive(json_decode($hidden_correct_answers))));
105 $this->object->setAnswerType(ilArrayUtil::stripSlashesRecursive($long_menu_type));
106 $this->object->setQuestion($this->request->raw('question'));
107 $this->object->setLongMenuTextValue($this->request->raw('longmenu_text'));
108 $this->object->setMinAutoComplete($this->request->int('min_auto_complete'));
109 $this->object->setIdenticalScoring($this->request->int('identical_scoring'));
110
112 }
113
114 private function verifyAnswerOptions(): bool
115 {
116 $longmenu_text = $this->request->raw('longmenu_text') ?? '';
117 $hidden_text_files = $this->request->raw('hidden_text_files') ?? '';
118 $answer_options_from_text = preg_split(
119 "/\\[" . assLongMenu::GAP_PLACEHOLDER . " (\\d+)\\]/",
120 $longmenu_text
121 );
122
123 $answer_options_from_files = $this->stripSlashesRecursive(json_decode($hidden_text_files));
124 if (count($answer_options_from_text) - 1 !== count($answer_options_from_files)) {
125 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('longmenu_answeroptions_differ'));
126 return false;
127 }
128
129 return true;
130 }
131
132 private function stripSlashesRecursive(array $data): array
133 {
134 return array_map(
135 function ($v) {
136 if (is_array($v)) {
137 return $this->stripSlashesRecursive($v);
138 }
139 return ilUtil::stripSlashes($v);
140 },
141 $data
142 );
143 }
144
145 private function trimArrayRecursive(array $data): array
146 {
147 return array_map(
148 function ($v) {
149 if (is_array($v)) {
150 return $this->trimArrayRecursive($v);
151 }
152 return trim($v);
153 },
154 $data
155 );
156 }
157
158 protected function editQuestion(ilPropertyFormGUI $form = null): void
159 {
160 if ($form === null) {
161 $form = $this->buildEditForm();
162 }
163
164 $this->getQuestionTemplate();
165
166 $this->tpl->setVariable("QUESTION_DATA", $this->ctrl->getHTML($form));
167 }
171 protected function buildEditForm(): ilPropertyFormGUI
172 {
173 $form = $this->buildBasicEditFormObject();
174
175 $this->addQuestionFormCommandButtons($form);
176
177 $this->addBasicQuestionFormProperties($form);
178
180 //$this->populateAnswerSpecificFormPart($form);
181
182 $this->populateTaxonomyFormSection($form);
183
184 return $form;
185 }
191 {
192 $long_menu_text = new ilTextAreaInputGUI($this->lng->txt("longmenu_text"), 'longmenu_text');
193 $long_menu_text->setRequired(true);
194 //$long_menu_text->setInfo($this->lng->txt("longmenu_hint"));
195 $long_menu_text->setRows(10);
196 $long_menu_text->setCols(80);
197 if (!$this->object->getSelfAssessmentEditingMode()) {
198 if ($this->object->getAdditionalContentEditingMode() == assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_RTE) {
199 include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
200 $long_menu_text->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
201 $long_menu_text->addPlugin("latex");
202 $long_menu_text->addButton("latex");
203 $long_menu_text->addButton("pastelatex");
204 $long_menu_text->setRTESupport($this->object->getId(), "qpl", "assessment");
205 $long_menu_text->setUseRte(true);
206 }
207 } else {
208 require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
210 $long_menu_text->setUseTagsForRteOnly(false);
211 }
212
213 $long_menu_text->setValue($this->object->getLongMenuTextValue());
214 $form->addItem($long_menu_text);
215
216 $tpl = new ilTemplate("tpl.il_as_qpl_longmenu_question_gap_button_code.html", true, true, "Modules/TestQuestionPool");
217 $tpl->setVariable('INSERT_GAP', $this->lng->txt('insert_gap'));
219 $button = new ilCustomInputGUI('&nbsp;', '');
220 $button->setHtml($tpl->get());
221 $form->addItem($button);
222
223 $modal = ilModalGUI::getInstance();
224 $modal->setHeading('');
225 $modal->setId("ilGapModal");
226 //$modal->setBackdrop(ilModalGUI::BACKDROP_OFF);
227 $modal->setBody('');
228
229 $min_auto_complete = new ilNumberInputGUI($this->lng->txt("min_auto_complete"), 'min_auto_complete');
230
231 $auto_complete = $this->object->getMinAutoComplete();
232 if ($auto_complete == 0) {
234 }
235 $min_auto_complete->setValue($auto_complete);
236 $min_auto_complete->setMinValue(1);
237 $min_auto_complete->setMaxValue(99);
238 $min_auto_complete->setSize(5);
239 $form->addItem($min_auto_complete);
240 // identical scoring
241 $identical_scoring = new ilCheckboxInputGUI($this->lng->txt("identical_scoring"), "identical_scoring");
242 $identical_scoring->setValue(1);
243 $identical_scoring->setChecked($this->object->getIdenticalScoring());
244 $identical_scoring->setInfo($this->lng->txt('identical_scoring_desc'));
245 $identical_scoring->setRequired(false);
246 $form->addItem($identical_scoring);
247 $hidden_text = new ilHiddenInputGUI('hidden_text_files');
248 $form->addItem($hidden_text);
249
250 $hidden_correct = new ilHiddenInputGUI('hidden_correct_answers');
251 $form->addItem($hidden_correct);
252
253 $long_menu_language = [
254 'edit' => '[' . $this->lng->txt('edit') . ']',
255 'type' => $this->lng->txt('type'),
256 'answers' => $this->lng->txt('answers'),
257 'answer_options' => $this->lng->txt('answer_options'),
258 'correct_answers' => $this->lng->txt('correct_answers'),
259 'add_answers' => '[' . $this->lng->txt('add_answers') . ']',
260 'manual_editing' => $this->lng->txt('manual_editing')
261 ];
262
263 $question_parts = [
264 'list' => json_decode($this->object->getJsonStructure()),
265 'gap_placeholder' => assLongMenu::GAP_PLACEHOLDER,
266 'last_updated_element' => 0,
267 'replacement_word' => '',
268 'filereader_usable' => false,
269 'max_input_fields' => assLongMenu::MAX_INPUT_FIELDS
270 ];
271 $answers = $this->object->getAnswersObject();
272
273 if ($this->request->isset('hidden_text_files')) {
274 $question_parts['list'] = json_decode($this->request->raw('hidden_correct_answers'));
275 $answers = $this->request->raw('hidden_text_files');
276 }
277
278 $this->tpl->addJavaScript('./Modules/TestQuestionPool/templates/default/longMenuQuestionGapBuilder.js');
279 $this->tpl->addJavaScript('./Modules/TestQuestionPool/templates/default/longMenuQuestion.js');
280 $tpl = new ilTemplate("tpl.il_as_qpl_longmenu_question_gap.html", true, true, "Modules/TestQuestionPool");
281 $tpl->setVariable('MAX_INPUT_FIELDS', assLongMenu::MAX_INPUT_FIELDS);
282 $tpl->setVariable('GAP_PLACEHOLDER', assLongMenu::GAP_PLACEHOLDER);
283 $tpl->setVariable('SELECT_BOX', $this->lng->txt('insert_gap'));
284 $tpl->setVariable("SELECT", $this->lng->txt('answers_select'));
285 $tpl->setVariable("TEXT", $this->lng->txt('answers_text_box'));
286 $tpl->setVariable("POINTS", $this->lng->txt('points'));
287 $tpl->setVariable("INFO_TEXT_UPLOAD", $this->lng->txt('info_text_upload'));
288 $tpl->setVariable("TXT_BROWSE", $this->lng->txt('select_file'));
289 $tpl->setVariable('POINTS_ERROR', $this->lng->txt('enter_enough_positive_points'));
290 $tpl->setVariable('AUTOCOMPLETE_ERROR', $this->lng->txt('autocomplete_error'));
291 $tpl->setVariable('MISSING_VALUE', $this->lng->txt('msg_input_is_required'));
292 $tpl->setVariable('SAVE', $this->lng->txt('save'));
293 $tpl->setVariable('CANCEL', $this->lng->txt('cancel'));
294 $tag_input = new ilTagInputGUI();
295 $tag_input->setPostVar('taggable');
296 $tag_input->setJsSelfInit(false);
297 $tag_input->setTypeAheadMinLength(1);
298 $tpl->setVariable("TAGGING_PROTOTYPE", $tag_input->render(''));
299
300 $tpl->setVariable("MY_MODAL", $modal->getHTML());
301
303 $this->tpl->addOnLoadCode('longMenuQuestion.Init(' .
304 json_encode($long_menu_language) . ', ' .
305 json_encode($question_parts) . ', ' .
306 $answers . ');');
307 $button = new ilCustomInputGUI('&nbsp;', '');
308 $button->setHtml($tpl->get());
309 $form->addItem($button);
310 return $form;
311 }
312
318 {
319 return $form;
320 }
321
334 public function getSolutionOutput(
335 $active_id,
336 $pass = null,
337 $graphicalOutput = false,
338 $result_output = false,
339 $show_question_only = true,
340 $show_feedback = false,
341 $show_correct_solution = false,
342 $show_manual_scoring = false,
343 $show_question_text = true
344 ): string {
345 $template = new ilTemplate("tpl.il_as_qpl_longmenu_question_output_solution.html", true, true, "Modules/TestQuestionPool");
346
347 if ($show_question_text) {
348 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
349 }
350 if (($active_id > 0) && (!$show_correct_solution)) {
351 $correct_solution = $this->getUserSolution($active_id, $pass);
352 } else {
353 $correct_solution = $this->object->getCorrectAnswersForQuestionSolution($this->object->getId());
354 }
355 $template->setVariable('LONGMENU_TEXT_SOLUTION', $this->getLongMenuTextWithInputFieldsInsteadOfGaps($correct_solution, true, $graphicalOutput));
356 $solution_template = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
357 $question_output = $template->get();
358 $feedback = '';
359 if ($show_feedback) {
360 if (!$this->isTestPresentationContext()) {
361 $fb = $this->getGenericFeedbackOutput((int) $active_id, $pass);
362 $feedback .= strlen($fb) ? $fb : '';
363 }
364
365 $fb = $this->getSpecificFeedbackOutput(array());
366 $feedback .= strlen($fb) ? $fb : '';
367 }
368 if (strlen($feedback)) {
369 $cssClass = (
370 $this->hasCorrectSolution($active_id, $pass) ?
372 );
373
374 $solution_template->setVariable("ILC_FB_CSS_CLASS", $cssClass);
375 $solution_template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
376 }
377
378 $solution_template->setVariable("SOLUTION_OUTPUT", $question_output);
379
380 $solution_output = $solution_template->get();
381
382 if (!$show_question_only) {
383 $solution_output = $this->getILIASPage($solution_output);
384 }
385
386 return $solution_output;
387 }
388
389 public function getPreview($show_question_only = false, $showInlineFeedback = false): string
390 {
391 $user_solution = is_object($this->getPreviewSession()) ? (array) $this->getPreviewSession()->getParticipantsSolution() : array();
392 $user_solution = array_values($user_solution);
393
394 $template = $this->getTemplateForPreviewAndTest($user_solution);
395
396 $question_output = $template->get();
397 if (!$show_question_only) {
398 $question_output = $this->getILIASPage($question_output);
399 }
400 return $question_output;
401 }
402
403 public function getTestOutput(
404 $active_id,
405 // hey: prevPassSolutions - will be always available from now on
406 $pass,
407 // hey.
408 $is_postponed = false,
409 $use_post_solutions = false,
410 $show_feedback = false
411 ): string {
412 $user_solution = array();
413 if ($active_id) {
414 $solutions = $this->object->getUserSolutionPreferingIntermediate($active_id, $pass);
415 foreach ($solutions as $idx => $solution_value) {
416 $user_solution[$solution_value["value1"]] = $solution_value["value2"];
417 }
418 }
419
420 $template = $this->getTemplateForPreviewAndTest($user_solution);
421
422 $question_output = $template->get();
423 $page_output = $this->outQuestionPage("", $is_postponed, $active_id, $question_output);
424 return $page_output;
425 }
426
427 protected function getTemplateForPreviewAndTest(array $user_solution): ilTemplate
428 {
429 $template = new ilTemplate("tpl.il_as_qpl_longmenu_question_output.html", true, true, "Modules/TestQuestionPool");
430 $this->tpl->addJavaScript('./Modules/TestQuestionPool/templates/default/longMenuQuestionPlayer.js');
431 $this->tpl->addOnLoadCode('il.test.player.longmenu.init('
432 . $this->object->getMinAutoComplete() . ', '
433 . json_encode($this->object->getAvailableAnswerOptions())
434 . ')');
435
436 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
437 $template->setVariable('LONGMENU_TEXT', $this->getLongMenuTextWithInputFieldsInsteadOfGaps($user_solution));
438 return $template;
439 }
440
441 public function getSpecificFeedbackOutput(array $userSolution): string
442 {
443 if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
444 return '';
445 }
446
447 $feedback = '<table class="test_specific_feedback"><tbody>';
448 $gaps = $this->object->getCorrectAnswers();
449 foreach ($gaps as $index => $answer) {
450 $caption = assLongMenu::GAP_PLACEHOLDER . ' ';
451 $caption .= $index + 1 . ': ';
452
453 $feedback .= '<tr><td>';
454
455 $feedback .= $caption . '</td><td>';
456 $feedback .= $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
457 $this->object->getId(),
458 0,
459 $index
460 ) . '</td> </tr>';
461 }
462 $feedback .= '</tbody></table>';
463 return $this->object->prepareTextareaOutput($feedback, true);
464 }
465
466
477 {
478 return array();
479 }
480
487 public function getAggregatedAnswersView(array $relevant_answers): string
488 {
489 $overview = array();
490 $aggregation = array();
491 foreach ($relevant_answers as $answer) {
492 $overview[$answer['active_fi']][$answer['pass']][$answer['value1']] = $answer['value2'];
493 }
494
495 foreach ($overview as $active) {
496 foreach ($active as $answer) {
497 foreach ($answer as $option => $value) {
498 $aggregation[$option][$value] = $aggregation[$option][$value] + 1;
499 }
500 }
501 }
502 $tpl = new ilTemplate('tpl.il_as_aggregated_longmenu_question_answers_table.html', true, true, "Modules/TestQuestionPool");
503 $json = json_decode($this->object->getJsonStructure());
504 foreach ($json as $key => $value) {
505 $tpl->setVariable('TITLE', 'Longmenu ' . ($key + 1));
506 if (array_key_exists($key, $aggregation)) {
507 $aggregate = $aggregation[$key];
508 foreach ($aggregate as $answer => $counts) {
509 $tpl->setVariable('OPTION', $answer);
510 $tpl->setVariable('COUNT', $counts);
511 $tpl->parseCurrentBlock();
512 }
513 }
514 }
515
516 return $tpl->get();
517 }
518
519 public function getLongMenuTextWithInputFieldsInsteadOfGaps($user_solution = array(), $solution = false, $graphical = false): string
520 {
521 $return_value = '';
522 $text_array = preg_split("/\\[" . assLongMenu::GAP_PLACEHOLDER . " (\\d+)\\]/", $this->object->getLongMenuTextValue());
523 $correct_answers = $this->object->getCorrectAnswers();
524 $answers = $this->object->getAnswers();
525 foreach ($text_array as $key => $value) {
526 $answer_is_correct = false;
527 $user_value = '';
528 $return_value .= $this->object->prepareTextareaOutput($value, true);
529 if ($key < sizeof($text_array) - 1) {
530 if (!array_key_exists($key, $correct_answers)) {
531 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('longmenu_answeroptions_differ'));
532 continue;
533 }
534 if ($correct_answers[$key][2] == assLongMenu::ANSWER_TYPE_TEXT_VAL) {
535 if (array_key_exists($key, $user_solution)) {
536 $user_value = $user_solution[$key];
537 if (in_array($user_value, $correct_answers[$key][0])) {
538 $answer_is_correct = true;
539 }
540 }
541
542 $return_value .= $this->getTextGapTemplate($key, $user_value, $solution, $answer_is_correct, $graphical);
543 } elseif ($correct_answers[$key][2] == assLongMenu::ANSWER_TYPE_SELECT_VAL) {
544 if (array_key_exists($key, $user_solution)) {
545 $user_value = $user_solution[$key];
546 if (in_array($user_value, $correct_answers[$key][0])) {
547 $answer_is_correct = true;
548 }
549 }
550 $return_value .= $this->getSelectGapTemplate($key, $answers[$key], $user_value, $solution, $answer_is_correct, $graphical);
551 }
552 }
553 }
554 return $return_value;
555 }
556
557 private function getTextGapTemplate($key, $value, $solution, $ok = false, $graphical = false): string
558 {
559 $tpl = new ilTemplate("tpl.il_as_qpl_longmenu_question_text_gap.html", true, true, "Modules/TestQuestionPool");
560 if ($solution) {
561 $tpl->setVariable('DISABLED', 'disabled');
562 $tpl->setVariable('JS_IGNORE', '_ignore');
563 if ($graphical) {
564 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
565 if ($ok) {
566 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
567 }
568 $tpl->setVariable("ICON_OK", $correctness_icon);
569 }
570 }
571 if ($solution) {
572 $tpl->setVariable('SIZE', 'size="' . mb_strlen($value) . '"');
573 }
574 $tpl->setVariable('VALUE', $value);
575 $tpl->setVariable('KEY', $key);
576
577 return $tpl->get();
578 }
579
580 private function getSelectGapTemplate($key, $answers, $user_value, $solution, $ok = false, $graphical = false): string
581 {
582 $tpl = new ilTemplate("tpl.il_as_qpl_longmenu_question_select_gap.html", true, true, "Modules/TestQuestionPool");
583 $tpl->setVariable('KEY', $key);
584 if ($solution) {
585 $tpl->setVariable('DISABLED', 'disabled');
586 $tpl->setVariable('JS_IGNORE', '_ignore');
587 $tpl->setCurrentBlock('best_solution');
588 if ($user_value == -1) {
589 $tpl->setVariable("SOLUTION", $this->lng->txt("please_select"));
590 } else {
591 $tpl->setVariable('SOLUTION', $user_value);
592 }
593 if ($graphical) {
594 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_NOT_OK);
595 if ($ok) {
596 $correctness_icon = $this->generateCorrectnessIconsForCorrectness(self::CORRECTNESS_OK);
597 }
598 $tpl->setVariable("ICON_OK", $correctness_icon);
599 }
600 $tpl->parseCurrentBlock();
601 } else {
602 $tpl->setVariable("PLEASE_SELECT", $this->lng->txt("please_select"));
603 foreach ($answers as $value) {
604 $tpl->setCurrentBlock('select_option');
605 $tpl->setVariable('VALUE', $value);
606 if ($value == $user_value) {
607 $tpl->setVariable('SELECTED', 'selected');
608 }
609 $tpl->parseCurrentBlock();
610 }
611 }
612 return $tpl->get();
613 }
614
615 public function getSubQuestionsIndex(): array
616 {
617 return array_keys($this->object->getAnswers());
618 }
619
620 public function getAnswersFrequency($relevantAnswers, $questionIndex): array
621 {
622 $answers = [];
623
624 foreach ($relevantAnswers as $row) {
625 if ($row['value1'] != $questionIndex) {
626 continue;
627 }
628
629 if (!isset($answers[$row['value2']])) {
630 //$label = $this->getAnswerTextLabel($row['value1'], $row['value2']);
631
632 $answers[$row['value2']] = array(
633 'answer' => $row['value2'], 'frequency' => 0
634 );
635 }
636
637 $answers[$row['value2']]['frequency']++;
638 }
639
640 return $answers;
641 }
642
643 public function getAnswerFrequencyTableGUI($parentGui, $parentCmd, $relevantAnswers, $questionIndex): ilAnswerFrequencyStatisticTableGUI
644 {
645 global $DIC; /* @var ILIAS\DI\Container $DIC */
646
647 $table = parent::getAnswerFrequencyTableGUI(
648 $parentGui,
649 $parentCmd,
650 $relevantAnswers,
651 $questionIndex
652 );
653
654 $table->setTitle(
655 sprintf(
656 $DIC->language()->txt('tst_corrections_answers_tbl_subindex'),
657 $DIC->language()->txt('longmenu') . ' ' . ($questionIndex + 1)
658 )
659 );
660
661 return $table;
662 }
663
665 {
666 $correctAnswers = $this->object->getCorrectAnswers();
667
668 foreach ($this->object->getAnswers() as $lmIndex => $lm) {
669 $lmValues = array(
670 'answers_all' => array(0 => $lm),
671 'answers_all_count' => count($lm),
672 'answers_correct' => $correctAnswers[$lmIndex][0]
673 );
674
675 $lmPoints = $correctAnswers[$lmIndex][1];
676
677 $section = new ilFormSectionHeaderGUI();
678 $section->setTitle($this->lng->txt('longmenu') . ' ' . ($lmIndex + 1));
679 $form->addItem($section);
680
682 $this->lng->txt('answers'),
683 'longmenu_' . $lmIndex
684 );
685
686 $lmInput->setRequired(true);
687
688 $lmInput->setValues($lmValues);
689
690 $form->addItem($lmInput);
691
692 $pointsInp = new ilNumberInputGUI($this->lng->txt("points"), 'points_' . $lmIndex);
693 $pointsInp->setRequired(true);
694 $pointsInp->allowDecimals(true);
695 $pointsInp->setSize(4);
696 $pointsInp->setMinValue(0);
697 $pointsInp->setMinvalueShouldBeGreater(false);
698 $pointsInp->setValue($lmPoints);
699 $form->addItem($pointsInp);
700 }
701 }
702
707 {
708 $correctAnswers = $this->object->getCorrectAnswers();
709
710 foreach ($this->object->getAnswers() as $lmIndex => $lm) {
711 $pointsInput = (float) str_replace(',', '.', $form->getInput('points_' . $lmIndex));
712 $correctAnswersInput = (array) $form->getInput('longmenu_' . $lmIndex . '_tags');
713
714 foreach ($correctAnswersInput as $idx => $answer) {
715 if (in_array($answer, $lm)) {
716 continue;
717 }
718
719 unset($correctAnswersInput[$idx]);
720 }
721
722 $correctAnswersInput = array_values($correctAnswersInput);
723
724 $correctAnswers[$lmIndex][0] = $correctAnswersInput;
725 $correctAnswers[$lmIndex][1] = $pointsInput;
726 }
727
728 $this->object->setCorrectAnswers($correctAnswers);
729 }
730}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$check
Definition: buildRTE.php:81
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
return true
getLongMenuTextWithInputFieldsInsteadOfGaps($user_solution=array(), $solution=false, $graphical=false)
trimArrayRecursive(array $data)
getAggregatedAnswersView(array $relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
getSolutionOutput( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
Get the question solution output.
getSelectGapTemplate($key, $answers, $user_value, $solution, $ok=false, $graphical=false)
getUserSolution($active_id, $pass)
getAnswersFrequency($relevantAnswers, $questionIndex)
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
getTemplateForPreviewAndTest(array $user_solution)
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
getAnswerFrequencyTableGUI($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
getTestOutput( $active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
writePostData(bool $always=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
editQuestion(ilPropertyFormGUI $form=null)
getTextGapTemplate($key, $value, $solution, $ok=false, $graphical=false)
stripSlashesRecursive(array $data)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
getPreview($show_question_only=false, $showInlineFeedback=false)
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
getSpecificFeedbackOutput(array $userSolution)
Returns the answer specific feedback for the question.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const MIN_LENGTH_AUTOCOMPLETE
const ANSWER_TYPE_TEXT_VAL
const ANSWER_TYPE_SELECT_VAL
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
populateTaxonomyFormSection(ilPropertyFormGUI $form)
getILIASPage(string $html="")
Returns the ILIAS Page around a question.
ilGlobalPageTemplate $tpl
addBasicQuestionFormProperties(ilPropertyFormGUI $form)
getGenericFeedbackOutput(int $active_id, ?int $pass)
addQuestionFormCommandButtons(ilPropertyFormGUI $form)
hasCorrectSolution($activeId, $passIndex)
const ADDITIONAL_CONTENT_EDITING_MODE_RTE
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
static getSelfAssessmentTags()
Get tags allowed in question tags in self assessment mode.
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $blockname=self::DEFAULT_BLOCK)
Parses the given block.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance()
This class represents a number property in a property form.
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.
This class represents a property form user interface.
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-...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$index
Definition: metadata.php:145
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
string $key
Consumer key/client ID value.
Definition: System.php:193