ILIAS  release_7 Revision v7.30-3-g800a261c036
class.assLongMenuGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once './Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5require_once './Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
6include_once './Modules/Test/classes/inc.AssessmentConstants.php';
7
16{
17 private $rbacsystem;
18 private $ilTabs;
19 public $lng;
20
21 public function __construct($id = -1)
22 {
24 include_once './Modules/TestQuestionPool/classes/class.assLongMenu.php';
25 $this->object = new assLongMenu();
26 if ($id >= 0) {
27 $this->object->loadFromDb($id);
28 }
29 global $DIC;
30 $rbacsystem = $DIC['rbacsystem'];
31 $ilTabs = $DIC['ilTabs'];
32 $lng = $DIC['lng'];
33 $this->rbacsystem = $rbacsystem;
34 $this->ilTabs = $ilTabs;
35 $this->lng = $lng;
36 }
37
43 protected function getUserSolution($active_id, $pass)
44 {
45 $user_solution = array();
46 if ($active_id) {
47 // hey: prevPassSolutions - obsolete due to central check
48 #$solutions = NULL;
49 #include_once "./Modules/Test/classes/class.ilObjTest.php";
50 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true))
51 #{
52 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
53 #}
54 $solutions = $this->object->getSolutionValues($active_id, $pass, !$this->getUseIntermediateSolution());
55 //$solutions = $this->object->getTestOutputSolutions($active_id, $pass);
56 // hey.
57 foreach ($solutions as $idx => $solution_value) {
58 $user_solution[$solution_value["value1"]] = $solution_value["value2"];
59 }
60 return $user_solution;
61 }
62 return $user_solution;
63 }
64
65 public function getCommand($cmd)
66 {
67 return $cmd;
68 }
69
73 protected function writePostData($always = false)
74 {
75 $form = $this->buildEditForm();
76 $form->setValuesByPost();
77 $check = $form->checkInput() && $this->verifyAnswerOptions();
78
81 $custom_check = $this->object->checkQuestionCustomPart($form);
82 if (!$check || !$custom_check) {
83 if (!$custom_check) {
84 ilUtil::sendFailure($this->lng->txt("form_input_not_valid"));
85 }
86 $this->editQuestion($form);
87 return 1;
88 }
90 return 0;
91 }
92
94 {
95 $this->object->setLongMenuTextValue(ilUtil::stripSlashesRecursive($_POST['longmenu_text']));
96 $this->object->setAnswers($this->trimArrayRecursive(json_decode(ilUtil::stripSlashesRecursive($_POST['hidden_text_files']))));
97 $this->object->setCorrectAnswers($this->trimArrayRecursive(json_decode(ilUtil::stripSlashesRecursive($_POST['hidden_correct_answers']))));
98 $this->object->setAnswerType(ilUtil::stripSlashesRecursive($_POST['long_menu_type']));
99 $this->object->setQuestion($_POST['question']);
100 $this->object->setLongMenuTextValue($_POST["longmenu_text"]);
101 $this->object->setMinAutoComplete((int) $_POST["min_auto_complete"]);
102 $this->object->setIdenticalScoring((int) $_POST["identical_scoring"]);
104 }
105
106 private function verifyAnswerOptions() : bool
107 {
108 $longmenu_text = $_POST['longmenu_text'] ?? '';
109 $hidden_text_files = $_POST['hidden_text_files'] ?? '';
110 $answer_options_from_text = preg_split(
111 "/\\[" . assLongMenu::GAP_PLACEHOLDER . " (\\d+)\\]/",
112 $longmenu_text
113 );
114 $answer_options_from_files = json_decode(ilUtil::stripSlashes($hidden_text_files));
115 if (count($answer_options_from_text) - 1 !== count($answer_options_from_files)) {
116 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('longmenu_answeroptions_differ'));
117 return false;
118 }
119 return true;
120 }
121
122 protected function trimArrayRecursive(array $data)
123 {
124 foreach ($data as $k => $v) {
125 if (is_array($v)) {
126 $data[$k] = $this->trimArrayRecursive($v);
127 } else {
128 $data[$k] = trim($v);
129 }
130 }
131 return $data;
132 }
133
134 protected function editQuestion(ilPropertyFormGUI $form = null)
135 {
136 if ($form === null) {
137 $form = $this->buildEditForm();
138 }
139
140 $this->getQuestionTemplate();
141
142 $this->tpl->setVariable("QUESTION_DATA", $this->ctrl->getHTML($form));
143 }
147 protected function buildEditForm()
148 {
149 $form = $this->buildBasicEditFormObject();
150
151 $this->addQuestionFormCommandButtons($form);
152
153 $this->addBasicQuestionFormProperties($form);
154
156 $this->populateAnswerSpecificFormPart($form);
157
158 $this->populateTaxonomyFormSection($form);
159
160 return $form;
161 }
167 {
168 $long_menu_text = new ilTextAreaInputGUI($this->lng->txt("longmenu_text"), 'longmenu_text');
169 $long_menu_text->setRequired(true);
170 //$long_menu_text->setInfo($this->lng->txt("longmenu_hint"));
171 $long_menu_text->setRows(10);
172 $long_menu_text->setCols(80);
173 if (!$this->object->getSelfAssessmentEditingMode()) {
174 if ($this->object->getAdditionalContentEditingMode() == assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_RTE) {
175 include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
176 $long_menu_text->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
177 $long_menu_text->addPlugin("latex");
178 $long_menu_text->addButton("latex");
179 $long_menu_text->addButton("pastelatex");
180 $long_menu_text->setRTESupport($this->object->getId(), "qpl", "assessment");
181 $long_menu_text->setUseRte(true);
182 }
183 } else {
184 require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
186 $long_menu_text->setUseTagsForRteOnly(false);
187 }
188
189 $long_menu_text->setValue($this->object->getLongMenuTextValue());
190 $form->addItem($long_menu_text);
191
192 $tpl = new ilTemplate("tpl.il_as_qpl_longmenu_question_gap_button_code.html", true, true, "Modules/TestQuestionPool");
193 $tpl->setVariable('INSERT_GAP', $this->lng->txt('insert_gap'));
194 $tpl->parseCurrentBlock();
195 $button = new ilCustomInputGUI('&nbsp;', '');
196 $button->setHtml($tpl->get());
197 $form->addItem($button);
198
199 require_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
200 $modal = ilModalGUI::getInstance();
201 $modal->setHeading('');
202 $modal->setId("ilGapModal");
203 //$modal->setBackdrop(ilModalGUI::BACKDROP_OFF);
204 $modal->setBody('');
205
206 $min_auto_complete = new ilNumberInputGUI($this->lng->txt("min_auto_complete"), 'min_auto_complete');
207
208 $auto_complete = $this->object->getMinAutoComplete();
209 if ($auto_complete == 0) {
211 }
212 $min_auto_complete->setValue($auto_complete);
213 $min_auto_complete->setMinValue(1);
214 $min_auto_complete->setMaxValue(99);
215 $min_auto_complete->setSize(5);
216 $form->addItem($min_auto_complete);
217 // identical scoring
218 $identical_scoring = new ilCheckboxInputGUI($this->lng->txt("identical_scoring"), "identical_scoring");
219 $identical_scoring->setValue(1);
220 $identical_scoring->setChecked($this->object->getIdenticalScoring());
221 $identical_scoring->setInfo($this->lng->txt('identical_scoring_desc'));
222 $identical_scoring->setRequired(false);
223 $form->addItem($identical_scoring);
224 $hidden_text = new ilHiddenInputGUI('hidden_text_files');
225 $form->addItem($hidden_text);
226
227 $hidden_correct = new ilHiddenInputGUI('hidden_correct_answers');
228 $form->addItem($hidden_correct);
229
230 $long_menu_language = [
231 'edit' => '[' . $this->lng->txt('edit') . ']',
232 'type' => $this->lng->txt('type'),
233 'answers' => $this->lng->txt('answers'),
234 'answer_options' => $this->lng->txt('answer_options'),
235 'correct_answers' => $this->lng->txt('correct_answers'),
236 'add_answers' => '[' . $this->lng->txt('add_answers') . ']',
237 'manual_editing' => $this->lng->txt('manual_editing')
238 ];
239
240 $question_parts = [
241 'list' => json_decode($this->object->getJsonStructure()),
242 'gap_placeholder' => assLongMenu::GAP_PLACEHOLDER,
243 'last_updated_element' => 0,
244 'replacement_word' => '',
245 'filereader_usable' => false,
246 'max_input_fields' => assLongMenu::MAX_INPUT_FIELDS
247 ];
248 $answers = $this->object->getAnswersObject();
249
250 if (is_array($_POST) && array_key_exists('hidden_text_files', $_POST)) {
251 $question_parts['list'] = json_decode($_POST['hidden_correct_answers']);
252 $answers = $_POST['hidden_text_files'];
253 }
254
255 $this->tpl->addJavaScript('./Modules/TestQuestionPool/templates/default/longMenuQuestionGapBuilder.js');
256 $this->tpl->addJavaScript('./Modules/TestQuestionPool/templates/default/longMenuQuestion.js');
257 $tpl = new ilTemplate("tpl.il_as_qpl_longmenu_question_gap.html", true, true, "Modules/TestQuestionPool");
258 $tpl->setVariable('SELECT_BOX', $this->lng->txt('insert_gap'));
259 $tpl->setVariable("SELECT", $this->lng->txt('answers_select'));
260 $tpl->setVariable("TEXT", $this->lng->txt('answers_text_box'));
261 $tpl->setVariable("POINTS", $this->lng->txt('points'));
262 $tpl->setVariable("INFO_TEXT_UPLOAD", $this->lng->txt('info_text_upload'));
263 $tpl->setVariable("TXT_BROWSE", $this->lng->txt('select_file'));
264 $tpl->setVariable('POINTS_ERROR', $this->lng->txt('enter_enough_positive_points'));
265 $tpl->setVariable('AUTOCOMPLETE_ERROR', $this->lng->txt('autocomplete_error'));
266 $tpl->setVariable('MISSING_VALUE', $this->lng->txt('msg_input_is_required'));
267 $tpl->setVariable('SAVE', $this->lng->txt('save'));
268 $tpl->setVariable('CANCEL', $this->lng->txt('cancel'));
269 $tag_input = new ilTagInputGUI();
270 $tag_input->setTypeAhead(true);
271 $tag_input->setPostVar('taggable');
272 $tag_input->setJsSelfInit(false);
273 $tag_input->setTypeAheadMinLength(1);
274 $tpl->setVariable("TAGGING_PROTOTYPE", $tag_input->render(''));
275
276 $tpl->setVariable("MY_MODAL", $modal->getHTML());
277
278 $tpl->parseCurrentBlock();
279 $this->tpl->addOnLoadCode('longMenuQuestion.Init(' .
280 json_encode($long_menu_language) . ', ' .
281 json_encode($question_parts) . ', ' .
282 $answers . ');');
283 $button = new ilCustomInputGUI('&nbsp;', '');
284 $button->setHtml($tpl->get());
285 $form->addItem($button);
286 return $form;
287 }
288
294 {
295 return $form;
296 }
297
304 {
305 return true;
306 }
307
321 public function getSolutionOutput(
322 $active_id,
323 $pass = null,
324 $graphicalOutput = false,
325 $result_output = false,
326 $show_question_only = true,
327 $show_feedback = false,
328 $show_correct_solution = false,
329 $show_manual_scoring = false,
330 $show_question_text = true
331 ) {
332 include_once "./Services/UICore/classes/class.ilTemplate.php";
333 $template = new ilTemplate("tpl.il_as_qpl_longmenu_question_output_solution.html", true, true, "Modules/TestQuestionPool");
334
335 if ($show_question_text) {
336 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
337 }
338 if (($active_id > 0) && (!$show_correct_solution)) {
339 $correct_solution = $this->getUserSolution($active_id, $pass);
340 } else {
341 $correct_solution = $this->object->getCorrectAnswersForQuestionSolution($this->object->getId());
342 }
343 $template->setVariable('LONGMENU_TEXT_SOLUTION', $this->getLongMenuTextWithInputFieldsInsteadOfGaps($correct_solution, true, $graphicalOutput));
344 $solution_template = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
345 $question_output = $template->get();
346 $feedback = '';
347 if ($show_feedback) {
348 if (!$this->isTestPresentationContext()) {
349 $fb = $this->getGenericFeedbackOutput($active_id, $pass);
350 $feedback .= strlen($fb) ? $fb : '';
351 }
352
353 $fb = $this->getSpecificFeedbackOutput(array());
354 $feedback .= strlen($fb) ? $fb : '';
355 }
356 if (strlen($feedback)) {
357 $cssClass = (
358 $this->hasCorrectSolution($active_id, $pass) ?
360 );
361
362 $solution_template->setVariable("ILC_FB_CSS_CLASS", $cssClass);
363 $solution_template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
364 }
365
366 $solution_template->setVariable("SOLUTION_OUTPUT", $question_output);
367
368 $solution_output = $solution_template->get();
369
370 if (!$show_question_only) {
371 $solution_output = $this->getILIASPage($solution_output);
372 }
373
374 return $solution_output;
375 }
376
377 public function getPreview($show_question_only = false, $showInlineFeedback = false)
378 {
379 $user_solution = is_object($this->getPreviewSession()) ? (array) $this->getPreviewSession()->getParticipantsSolution() : array();
380 $user_solution = array_values($user_solution);
381
382 include_once "./Services/UICore/classes/class.ilTemplate.php";
383 $template = new ilTemplate("tpl.il_as_qpl_longmenu_question_output.html", true, true, "Modules/TestQuestionPool");
384
385 $question_text = $this->object->getQuestion();
386 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
387 $template->setVariable("ANSWER_OPTIONS_JSON", json_encode($this->object->getAvailableAnswerOptions()));
388 $template->setVariable('AUTOCOMPLETE_LENGTH', $this->object->getMinAutoComplete());
389 $template->setVariable('LONGMENU_TEXT', $this->getLongMenuTextWithInputFieldsInsteadOfGaps($user_solution));
390
391 $question_output = $template->get();
392 if (!$show_question_only) {
393 $question_output = $this->getILIASPage($question_output);
394 }
395 return $question_output;
396 }
397
398
399
400 public function getTestOutput(
401 $active_id,
402 // hey: prevPassSolutions - will be always available from now on
403 $pass,
404 // hey.
405 $is_postponed = false,
406 $use_post_solutions = false,
407 $show_feedback = false
408 ) {
409 $user_solution = array();
410 if ($active_id) {
411 $solutions = null;
412 include_once "./Modules/Test/classes/class.ilObjTest.php";
413 if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) {
414 if (is_null($pass)) {
415 $pass = ilObjTest::_getPass($active_id);
416 }
417 }
418 $solutions = $this->object->getUserSolutionPreferingIntermediate($active_id, $pass);
419 foreach ($solutions as $idx => $solution_value) {
420 $user_solution[$solution_value["value1"]] = $solution_value["value2"];
421 }
422 }
423
424 // generate the question output
425 include_once "./Services/UICore/classes/class.ilTemplate.php";
426 $template = new ilTemplate("tpl.il_as_qpl_longmenu_question_output.html", true, true, "Modules/TestQuestionPool");
427
428 $question_text = $this->object->getQuestion();
429 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
430 $template->setVariable("ANSWER_OPTIONS_JSON", json_encode($this->object->getAvailableAnswerOptions()));
431 $template->setVariable('LONGMENU_TEXT', $this->getLongMenuTextWithInputFieldsInsteadOfGaps($user_solution));
432 $template->setVariable('AUTOCOMPLETE_LENGTH', $this->object->getMinAutoComplete());
433 $question_output = $template->get();
434 $page_output = $this->outQuestionPage("", $is_postponed, $active_id, $question_output);
435 return $page_output;
436 }
437
438 public function getSpecificFeedbackOutput($userSolution)
439 {
440 if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
441 return '';
442 }
443
444 $feedback = '<table class="test_specific_feedback"><tbody>';
445 $gaps = $this->object->getCorrectAnswers();
446 foreach ($gaps as $index => $answer) {
447 $caption = assLongMenu::GAP_PLACEHOLDER . ' ';
448 $caption .= $index + 1 . ': ';
449
450 $feedback .= '<tr><td>';
451
452 $feedback .= $caption . '</td><td>';
453 $feedback .= $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
454 $this->object->getId(),
455 0,
456 $index
457 ) . '</td> </tr>';
458 }
459 $feedback .= '</tbody></table>';
460 return $this->object->prepareTextareaOutput($feedback, true);
461 }
462
463
474 {
475 return array();
476 }
477
486 public function getAggregatedAnswersView($relevant_answers)
487 {
488 $overview = array();
489 $aggregation = array();
490 foreach ($relevant_answers as $answer) {
491 $overview[$answer['active_fi']][$answer['pass']][$answer['value1']] = $answer['value2'];
492 }
493
494 foreach ($overview as $active) {
495 foreach ($active as $answer) {
496 foreach ($answer as $option => $value) {
497 $aggregation[$option][$value] = $aggregation[$option][$value] + 1;
498 }
499 }
500 }
501 $tpl = new ilTemplate('tpl.il_as_aggregated_longmenu_question_answers_table.html', true, true, "Modules/TestQuestionPool");
502 $json = json_decode($this->object->getJsonStructure());
503 foreach ($json as $key => $value) {
504 $tpl->setVariable('TITLE', 'Longmenu ' . ($key + 1));
505 if (array_key_exists($key, $aggregation)) {
506 $aggregate = $aggregation[$key];
507 foreach ($aggregate as $answer => $counts) {
508 $tpl->setVariable('OPTION', $answer);
509 $tpl->setVariable('COUNT', $counts);
510 $tpl->parseCurrentBlock();
511 }
512 }
513 }
514
515 return $tpl->get();
516 }
517
518 public function getLongMenuTextWithInputFieldsInsteadOfGaps($user_solution = array(), $solution = false, $graphical = false)
519 {
520 $return_value = '';
521 $text_array = preg_split("/\\[" . assLongMenu::GAP_PLACEHOLDER . " (\\d+)\\]/", $this->object->getLongMenuTextValue());
522 $correct_answers = $this->object->getCorrectAnswers();
523 $answers = $this->object->getAnswers();
524 foreach ($text_array as $key => $value) {
525 $answer_is_correct = false;
526 $user_value = '';
527 $return_value .= $this->object->prepareTextareaOutput($value, true);
528 if ($key < sizeof($text_array) - 1) {
529 if (!array_key_exists($key, $correct_answers)) {
530 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('longmenu_answeroptions_differ'));
531 continue;
532 }
533 if ($correct_answers[$key][2] == assLongMenu::ANSWER_TYPE_TEXT_VAL) {
534 if (array_key_exists($key, $user_solution)) {
535 $user_value = $user_solution[$key];
536 if (in_array($user_value, $correct_answers[$key][0])) {
537 $answer_is_correct = true;
538 }
539 }
540
541 $return_value .= $this->getTextGapTemplate($key, $user_value, $solution, $answer_is_correct, $graphical);
542 } elseif ($correct_answers[$key][2] == assLongMenu::ANSWER_TYPE_SELECT_VAL) {
543 if (array_key_exists($key, $user_solution)) {
544 $user_value = $user_solution[$key];
545 if (in_array($user_value, $correct_answers[$key][0])) {
546 $answer_is_correct = true;
547 }
548 }
549 $return_value .= $this->getSelectGapTemplate($key, $answers[$key], $user_value, $solution, $answer_is_correct, $graphical);
550 }
551 }
552 }
553 return $return_value;
554 }
555
556 private function getTextGapTemplate($key, $value, $solution, $ok = false, $graphical = false)
557 {
558 $tpl = new ilTemplate("tpl.il_as_qpl_longmenu_question_text_gap.html", true, true, "Modules/TestQuestionPool");
559 if ($solution) {
560 $tpl->setVariable('DISABLED', 'disabled');
561 $tpl->setVariable('JS_IGNORE', '_ignore');
562 if ($graphical) {
563 if ($ok) {
564 $tpl->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
565 $tpl->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
566 } else {
567 $tpl->setVariable("ICON_OK", ilUtil::getImagePath("icon_not_ok.svg"));
568 $tpl->setVariable("TEXT_OK", $this->lng->txt("answer_is_wrong"));
569 }
570 }
571 }
572 $tpl->setVariable('VALUE', $value);
573 $tpl->setVariable('KEY', $key);
574
575 return $tpl->get();
576 }
577
578 private function getSelectGapTemplate($key, $answers, $user_value, $solution, $ok = false, $graphical = false)
579 {
580 $tpl = new ilTemplate("tpl.il_as_qpl_longmenu_question_select_gap.html", true, true, "Modules/TestQuestionPool");
581 $tpl->setVariable('KEY', $key);
582 if ($solution) {
583 $tpl->setVariable('DISABLED', 'disabled');
584 $tpl->setVariable('JS_IGNORE', '_ignore');
585 $tpl->setCurrentBlock('best_solution');
586 if ($user_value == -1) {
587 $tpl->setVariable("SOLUTION", $this->lng->txt("please_select"));
588 } else {
589 $tpl->setVariable('SOLUTION', $user_value);
590 }
591 if ($graphical) {
592 if ($ok) {
593 $tpl->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
594 $tpl->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
595 } else {
596 $tpl->setVariable("ICON_OK", ilUtil::getImagePath("icon_not_ok.svg"));
597 $tpl->setVariable("TEXT_OK", $this->lng->txt("answer_is_wrong"));
598 }
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()
616 {
617 return array_keys($this->object->getAnswers());
618 }
619
620 public function getAnswersFrequency($relevant_answers, $questionIndex)
621 {
622 $answers = [];
623
624 foreach ($relevant_answers 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)
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(sprintf(
655 $DIC->language()->txt('tst_corrections_answers_tbl_subindex'),
656 $DIC->language()->txt('longmenu') . ' ' . ($questionIndex + 1)
657 ));
658
659 return $table;
660 }
661
663 {
664 $correctAnswers = $this->object->getCorrectAnswers();
665
666 foreach ($this->object->getAnswers() as $lmIndex => $lm) {
667 $lmValues = array(
668 'answers_all' => array(0 => $lm),
669 'answers_all_count' => count($lm),
670 'answers_correct' => $correctAnswers[$lmIndex][0]
671 );
672
673 $lmPoints = $correctAnswers[$lmIndex][1];
674
676 $section->setTitle($this->lng->txt('longmenu') . ' ' . ($lmIndex + 1));
677 $form->addItem($section);
678
680 $this->lng->txt('answers'),
681 'longmenu_' . $lmIndex
682 );
683
684 $lmInput->setRequired(true);
685
686 $lmInput->setValues($lmValues);
687
688 $form->addItem($lmInput);
689
690 $pointsInp = new ilNumberInputGUI($this->lng->txt("points"), 'points_' . $lmIndex);
691 $pointsInp->setRequired(true);
692 $pointsInp->allowDecimals(true);
693 $pointsInp->setSize(4);
694 $pointsInp->setMinValue(0);
695 $pointsInp->setMinvalueShouldBeGreater(false);
696 $pointsInp->setValue($lmPoints);
697 $form->addItem($pointsInp);
698 }
699 }
700
705 {
706 $correctAnswers = $this->object->getCorrectAnswers();
707
708 foreach ($this->object->getAnswers() as $lmIndex => $lm) {
709 $pointsInput = (float) $form->getInput('points_' . $lmIndex);
710 $correctAnswersInput = (array) $form->getInput('longmenu_' . $lmIndex . '_tags');
711
712 foreach ($correctAnswersInput as $idx => $answer) {
713 if (in_array($answer, $lm)) {
714 continue;
715 }
716
717 unset($correctAnswersInput[$idx]);
718 }
719
720 $correctAnswersInput = array_values($correctAnswersInput);
721
722 $correctAnswers[$lmIndex][0] = $correctAnswersInput;
723 $correctAnswers[$lmIndex][1] = $pointsInput;
724 }
725
726 $this->object->setCorrectAnswers($correctAnswers);
727 }
728}
$section
Definition: Utf8Test.php:83
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
getLongMenuTextWithInputFieldsInsteadOfGaps($user_solution=array(), $solution=false, $graphical=false)
trimArrayRecursive(array $data)
getAnswersFrequency($relevant_answers, $questionIndex)
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)
getSpecificFeedbackOutput($userSolution)
Returns the answer specific feedback for the question.
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
getAnswerFrequencyTableGUI($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
getTestOutput( $active_id, $pass, $is_postponed=false, $use_post_solutions=false, $show_feedback=false)
writePostData($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)
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
editQuestion(ilPropertyFormGUI $form=null)
getTextGapTemplate($key, $value, $solution, $ok=false, $graphical=false)
supportsIntermediateSolutionOutput()
Question type specific support of intermediate solution output The function getSolutionOutput respect...
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)
const MIN_LENGTH_AUTOCOMPLETE
const ANSWER_TYPE_TEXT_VAL
const ANSWER_TYPE_SELECT_VAL
Basic GUI class for assessment questions.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
getILIASPage($html="")
Returns the ILIAS Page around a question.
getQuestionTemplate()
get question template
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
hasCorrectSolution($activeId, $passIndex)
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question,...
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
const ADDITIONAL_CONTENT_EDITING_MODE_RTE
constant for additional content editing mode "default"
static getSelfAssessmentTags()
Get tags allowed in question tags in self assessment mode.
This class represents a checkbox property in a property form.
This class represents a custom property in a property form.
This class represents a section header in a property form.
This class represents a hidden form property in a property form.
static getInstance()
Get instance.
This class represents a number property in a property form.
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
static _getUsePreviousAnswers($active_id, $user_active_user_setting=false)
Returns if the previous results should be hidden for a learner.
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
This class represents a tag list property in a property form.
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: goto.php:24
Interface ilGuiQuestionScoringAdjustable.
$index
Definition: metadata.php:128
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$data
Definition: storeScorm.php:23