ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 {
23 parent::__construct();
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();
79 $custom_check = $this->object->checkQuestionCustomPart($form);
80 if (!$form->checkInput() || !$custom_check) {
81 if (!$custom_check) {
82 ilUtil::sendFailure($this->lng->txt("form_input_not_valid"));
83 }
84 $this->editQuestion($form);
85 return 1;
86 }
88 return 0;
89 }
90
92 {
93 $this->object->setLongMenuTextValue(ilUtil::stripSlashesRecursive($_POST['longmenu_text']));
94 $this->object->setAnswers(json_decode(ilUtil::stripSlashesRecursive($_POST['hidden_text_files'])));
95 $this->object->setCorrectAnswers(json_decode(ilUtil::stripSlashesRecursive($_POST['hidden_correct_answers'])));
96 $this->object->setAnswerType(ilUtil::stripSlashesRecursive($_POST['long_menu_type']));
97 $this->object->setQuestion($_POST['question']);
98 $this->object->setLongMenuTextValue($_POST["longmenu_text"]);
99 $this->object->setMinAutoComplete((int) $_POST["min_auto_complete"]);
100 $this->object->setIdenticalScoring((int) $_POST["identical_scoring"]);
102 }
103
104 protected function editQuestion(ilPropertyFormGUI $form = null)
105 {
106 if ($form === null) {
107 $form = $this->buildEditForm();
108 }
109
110 $this->getQuestionTemplate();
111 $this->tpl->addCss('Modules/Test/templates/default/ta.css');
112
113 $this->tpl->setVariable("QUESTION_DATA", $this->ctrl->getHTML($form));
114 }
118 protected function buildEditForm()
119 {
121
123
125
128
130
131 return $form;
132 }
138 {
139 $long_menu_text = new ilTextAreaInputGUI($this->lng->txt("longmenu_text"), 'longmenu_text');
140 $long_menu_text->setRequired(true);
141 //$long_menu_text->setInfo($this->lng->txt("longmenu_hint"));
142 $long_menu_text->setRows(10);
143 $long_menu_text->setCols(80);
144 if (!$this->object->getSelfAssessmentEditingMode()) {
145 if ($this->object->getAdditionalContentEditingMode() == assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT) {
146 include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
147 $long_menu_text->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
148 $long_menu_text->addPlugin("latex");
149 $long_menu_text->addButton("latex");
150 $long_menu_text->addButton("pastelatex");
151 $long_menu_text->setRTESupport($this->object->getId(), "qpl", "assessment");
152 $long_menu_text->setUseRte(true);
153 }
154 } else {
155 require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
157 $long_menu_text->setUseTagsForRteOnly(false);
158 }
159
160 $long_menu_text->setValue($this->object->prepareTextareaOutput($this->object->getLongMenuTextValue()));
161 $form->addItem($long_menu_text);
162
163 $tpl = new ilTemplate("tpl.il_as_qpl_long_menu_gap_button_code.html", true, true, "Modules/TestQuestionPool");
164 $tpl->setVariable('INSERT_GAP', $this->lng->txt('insert_gap'));
165 $tpl->parseCurrentBlock();
166 $button = new ilCustomInputGUI('&nbsp;', '');
167 $button->setHtml($tpl->get());
168 $form->addItem($button);
169
170 require_once("./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
171 $modal = ilModalGUI::getInstance();
172 $modal->setHeading('');
173 $modal->setId("ilGapModal");
174 //$modal->setBackdrop(ilModalGUI::BACKDROP_OFF);
175 $modal->setBody('');
176
177 $min_auto_complete = new ilNumberInputGUI($this->lng->txt("min_auto_complete"), 'min_auto_complete');
178
179 $auto_complete = $this->object->getMinAutoComplete();
180 if ($auto_complete == 0) {
182 }
183 $min_auto_complete->setValue($auto_complete);
184 $min_auto_complete->setMinValue(1);
185 $min_auto_complete->setMaxValue(99);
186 $min_auto_complete->setSize(5);
187 $form->addItem($min_auto_complete);
188 // identical scoring
189 $identical_scoring = new ilCheckboxInputGUI($this->lng->txt("identical_scoring"), "identical_scoring");
190 $identical_scoring->setValue(1);
191 $identical_scoring->setChecked($this->object->getIdenticalScoring());
192 $identical_scoring->setInfo($this->lng->txt('identical_scoring_desc'));
193 $identical_scoring->setRequired(false);
194 $form->addItem($identical_scoring);
195 $hidden_text = new ilHiddenInputGUI('hidden_text_files');
196 $form->addItem($hidden_text);
197
198 $hidden_correct = new ilHiddenInputGUI('hidden_correct_answers');
199 $form->addItem($hidden_correct);
200
201 $tpl = new ilTemplate("tpl.il_as_qpl_long_menu_gap.html", true, true, "Modules/TestQuestionPool");
202 if (is_array($_POST) && array_key_exists('hidden_text_files', $_POST)) {
203 $tpl->setVariable('CORRECT_ANSWERS', $_POST['hidden_correct_answers']);
204 $tpl->setVariable('ALL_ANSWERS', $_POST['hidden_text_files']);
205 } else {
206 $tpl->setVariable('CORRECT_ANSWERS', $this->object->getJsonStructure());
207 $tpl->setVariable('ALL_ANSWERS', $this->object->getAnswersObject());
208 }
209 $tpl->setVariable('MAX_INPUT_FIELDS', assLongMenu::MAX_INPUT_FIELDS);
210 $tpl->setVariable('GAP_PLACEHOLDER', assLongMenu::GAP_PLACEHOLDER);
211 $tpl->setVariable('SELECT_BOX', $this->lng->txt('insert_gap'));
212 $tpl->setVariable("SELECT", $this->lng->txt('answers_select'));
213 $tpl->setVariable("TEXT", $this->lng->txt('answers_text_box'));
214 $tpl->setVariable("POINTS", $this->lng->txt('points'));
215 $tpl->setVariable("INFO_TEXT_UPLOAD", $this->lng->txt('info_text_upload'));
216 $tpl->setVariable("TXT_BROWSE", $this->lng->txt('select_file'));
217 $tpl->setVariable("MANUAL_EDITING", $this->lng->txt('manual_editing'));
218 $tpl->setVariable("CORRECT_ANSWER_TXT", $this->lng->txt('correct_answers'));
219 $tpl->setVariable("ANSWER_OPTIONS_TXT", $this->lng->txt('answer_options'));
220 $tpl->setVariable("ANSWERS_TXT", $this->lng->txt('answers'));
221 $tpl->setVariable("TYPE_TXT", $this->lng->txt('type'));
222 $tpl->setVariable("EDIT_TXT", $this->lng->txt('edit'));
223 $tpl->setVariable("ADD_ANSWER_TXT", $this->lng->txt('add_answers'));
224 $tpl->setVariable('POINTS_ERROR', $this->lng->txt('enter_enough_positive_points'));
225 $tpl->setVariable('AUTOCOMPLETE_ERROR', $this->lng->txt('autocomplete_error'));
226 $tpl->setVariable('MISSING_VALUE', $this->lng->txt('msg_input_is_required'));
227 $tpl->setVariable('SAVE', $this->lng->txt('save'));
228 $tpl->setVariable('CANCEL', $this->lng->txt('cancel'));
229 require_once("Services/Form/classes/class.ilTagInputGUI.php");
230 $tag_input = new ilTagInputGUI();
231 $tag_input->setTypeAhead(true);
232 $tag_input->setPostVar('taggable');
233 $tag_input->setJsSelfInit(false);
234 $tag_input->setTypeAheadMinLength(1);
235 $tpl->setVariable("TAGGING_PROTOTYPE", $tag_input->render(''));
236
237 $tpl->setVariable("MY_MODAL", $modal->getHTML());
238
239 $tpl->parseCurrentBlock();
240 $button = new ilCustomInputGUI('&nbsp;', '');
241 $button->setHtml($tpl->get());
242 $form->addItem($button);
243 return $form;
244 }
245
251 {
252 return $form;
253 }
254
261 {
262 return true;
263 }
264
278 public function getSolutionOutput(
279 $active_id,
280 $pass = null,
281 $graphicalOutput = false,
282 $result_output = false,
283 $show_question_only = true,
284 $show_feedback = false,
285 $show_correct_solution = false,
286 $show_manual_scoring = false,
287 $show_question_text = true
288 ) {
289 include_once "./Services/UICore/classes/class.ilTemplate.php";
290 $template = new ilTemplate("tpl.il_as_qpl_lome_question_output_solution.html", true, true, "Modules/TestQuestionPool");
291
292 if ($show_question_text) {
293 $question_text = $this->object->getQuestion();
294 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($question_text, true));
295 }
296 if (($active_id > 0) && (!$show_correct_solution)) {
297 $correct_solution = $this->getUserSolution($active_id, $pass);
298 } else {
299 $correct_solution = $this->object->getCorrectAnswersForQuestionSolution($this->object->getId());
300 }
301 $template->setVariable('LONGMENU_TEXT_SOLUTION', $this->getLongMenuTextWithInputFieldsInsteadOfGaps($correct_solution, true, $graphicalOutput));
302 $solution_template = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
303 $question_output = $template->get();
304 $feedback = '';
305 if ($show_feedback) {
306 if (!$this->isTestPresentationContext()) {
307 $fb = $this->getGenericFeedbackOutput($active_id, $pass);
308 $feedback .= strlen($fb) ? $fb : '';
309 }
310
311 $fb = $this->getSpecificFeedbackOutput(array());
312 $feedback .= strlen($fb) ? $fb : '';
313 }
314 if (strlen($feedback)) {
315 $cssClass = (
316 $this->hasCorrectSolution($active_id, $pass) ?
318 );
319
320 $solution_template->setVariable("ILC_FB_CSS_CLASS", $cssClass);
321 $solution_template->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
322 }
323
324 $solution_template->setVariable("SOLUTION_OUTPUT", $question_output);
325
326 $solution_output = $solution_template->get();
327
328 if (!$show_question_only) {
329 $solution_output = $this->getILIASPage($solution_output);
330 }
331
332 return $solution_output;
333 }
334
335 public function getPreview($show_question_only = false, $showInlineFeedback = false)
336 {
337 $user_solution = is_object($this->getPreviewSession()) ? (array) $this->getPreviewSession()->getParticipantsSolution() : array();
338 $user_solution = array_values($user_solution);
339
340 include_once "./Services/UICore/classes/class.ilTemplate.php";
341 $template = new ilTemplate("tpl.il_as_qpl_longmenu_output.html", true, true, "Modules/TestQuestionPool");
342
343 $question_text = $this->object->getQuestion();
344 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($question_text, true));
345 $template->setVariable("ANSWER_OPTIONS_JSON", json_encode($this->object->getAvailableAnswerOptions()));
346 $template->setVariable('AUTOCOMPLETE_LENGTH', $this->object->getMinAutoComplete());
347 $template->setVariable('LONGMENU_TEXT', $this->getLongMenuTextWithInputFieldsInsteadOfGaps($user_solution));
348
349 $question_output = $template->get();
350 if (!$show_question_only) {
351 $question_output = $this->getILIASPage($question_output);
352 }
353 return $question_output;
354 }
355
356
357
358 public function getTestOutput(
359 $active_id,
360 // hey: prevPassSolutions - will be always available from now on
361 $pass,
362 // hey.
363 $is_postponed = false,
364 $use_post_solutions = false,
365 $show_feedback = false
366 ) {
367 $user_solution = array();
368 if ($active_id) {
369 $solutions = null;
370 include_once "./Modules/Test/classes/class.ilObjTest.php";
371 if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) {
372 if (is_null($pass)) {
373 $pass = ilObjTest::_getPass($active_id);
374 }
375 }
376 $solutions = $this->object->getUserSolutionPreferingIntermediate($active_id, $pass);
377 foreach ($solutions as $idx => $solution_value) {
378 $user_solution[$solution_value["value1"]] = $solution_value["value2"];
379 }
380 }
381
382 // generate the question output
383 include_once "./Services/UICore/classes/class.ilTemplate.php";
384 $template = new ilTemplate("tpl.il_as_qpl_longmenu_output.html", true, true, "Modules/TestQuestionPool");
385
386 $question_text = $this->object->getQuestion();
387 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($question_text, true));
388 $template->setVariable("ANSWER_OPTIONS_JSON", json_encode($this->object->getAvailableAnswerOptions()));
389 $template->setVariable('LONGMENU_TEXT', $this->getLongMenuTextWithInputFieldsInsteadOfGaps($user_solution));
390 $template->setVariable('AUTOCOMPLETE_LENGTH', $this->object->getMinAutoComplete());
391 $question_output = $template->get();
392 $page_output = $this->outQuestionPage("", $is_postponed, $active_id, $question_output);
393 return $page_output;
394 }
395
402 public function setQuestionTabs()
403 {
404 $this->ilTabs->clearTargets();
405
406 $this->ctrl->setParameterByClass("ilAssQuestionPageGUI", "q_id", $_GET["q_id"]);
407 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
408 $q_type = $this->object->getQuestionType();
409
410 if (strlen($q_type)) {
411 $classname = $q_type . "GUI";
412 $this->ctrl->setParameterByClass(strtolower($classname), "sel_question_types", $q_type);
413 $this->ctrl->setParameterByClass(strtolower($classname), "q_id", $_GET["q_id"]);
414 }
415
416 if ($_GET["q_id"]) {
417 if ($this->rbacsystem->checkAccess('write', $_GET["ref_id"])) {
418 // edit page
419 $this->ilTabs->addTarget(
420 "edit_page",
421 $this->ctrl->getLinkTargetByClass("ilAssQuestionPageGUI", "edit"),
422 array("edit", "insert", "exec_pg"),
423 "",
424 "",
425 $force_active
426 );
427 }
428
429 $this->addTab_QuestionPreview($this->ilTabs);
430 }
431
432 $force_active = false;
433 if ($this->rbacsystem->checkAccess('write', $_GET["ref_id"])) {
434 $url = "";
435 if ($classname) {
436 $url = $this->ctrl->getLinkTargetByClass($classname, "editQuestion");
437 }
438 $commands = $_POST["cmd"];
439 if (is_array($commands)) {
440 foreach ($commands as $key => $value) {
441 if (preg_match("/^delete_.*/", $key, $matches)) {
442 $force_active = true;
443 }
444 }
445 }
446 // edit question properties
447 $this->ilTabs->addTarget(
448 "edit_question",
449 $url,
450 array("editQuestion", "save", "saveEdit", "addkvp", "removekvp", "originalSyncForm"),
451 $classname,
452 "",
453 $force_active
454 );
455 }
456
457 // add tab for question feedback within common class assQuestionGUI
458 $this->addTab_QuestionFeedback($this->ilTabs);
459
460 // add tab for question hint within common class assQuestionGUI
461 $this->addTab_QuestionHints($this->ilTabs);
462
463 // add tab for question's suggested solution within common class assQuestionGUI
464 $this->addTab_SuggestedSolution($this->ilTabs, $classname);
465
466 // Assessment of questions sub menu entry
467 if ($_GET["q_id"]) {
468 $this->ilTabs->addTarget(
469 "statistics",
470 $this->ctrl->getLinkTargetByClass($classname, "assessment"),
471 array("assessment"),
472 $classname,
473 ""
474 );
475 }
476
477 $this->addBackTab($this->ilTabs);
478 }
479
480 public function getSpecificFeedbackOutput($userSolution)
481 {
482 if (!$this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, 0)) {
483 return '';
484 }
485
486 $feedback = '<table class="test_specific_feedback"><tbody>';
487 $gaps = $this->object->getCorrectAnswers();
488 foreach ($gaps as $index => $answer) {
489 $caption = assLongMenu::GAP_PLACEHOLDER . ' ';
490 $caption .= $index + 1 . ': ';
491
492 $feedback .= '<tr><td>';
493
494 $feedback .= $caption . '</td><td>';
495 $feedback .= $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
496 $this->object->getId(),
497 0,
498 $index
499 ) . '</td> </tr>';
500 }
501 $feedback .= '</tbody></table>';
502 return $this->object->prepareTextareaOutput($feedback, true);
503 }
504
505
516 {
517 return array();
518 }
519
528 public function getAggregatedAnswersView($relevant_answers)
529 {
530 $overview = array();
531 $aggregation = array();
532 foreach ($relevant_answers as $answer) {
533 $overview[$answer['active_fi']][$answer['pass']][$answer['value1']] = $answer['value2'];
534 }
535
536 foreach ($overview as $active) {
537 foreach ($active as $answer) {
538 foreach ($answer as $option => $value) {
539 $aggregation[$option][$value] = $aggregation[$option][$value] + 1;
540 }
541 }
542 }
543 $tpl = new ilTemplate('tpl.il_as_aggregated_long_menu_answers_table.html', true, true, "Modules/TestQuestionPool");
544 $json = json_decode($this->object->getJsonStructure());
545 foreach ($json as $key => $value) {
546 $tpl->setVariable('TITLE', 'Longmenu ' . ($key + 1));
547 if (array_key_exists($key, $aggregation)) {
548 $aggregate = $aggregation[$key];
549 foreach ($aggregate as $answer => $counts) {
550 $tpl->setVariable('OPTION', $answer);
551 $tpl->setVariable('COUNT', $counts);
552 $tpl->parseCurrentBlock();
553 }
554 }
555 }
556
557 return $tpl->get();
558 }
559
560 public function getLongMenuTextWithInputFieldsInsteadOfGaps($user_solution = array(), $solution = false, $graphical = false)
561 {
562 $return_value = '';
563 $text_array = preg_split("/\\[" . assLongMenu::GAP_PLACEHOLDER . " (\\d+)\\]/", $this->object->getLongMenuTextValue());
564 $correct_answers = $this->object->getCorrectAnswers();
565 $answers = $this->object->getAnswers();
566 foreach ($text_array as $key => $value) {
567 $answer_is_correct = false;
568 $user_value = '';
569 $return_value .= $value;
570 if ($key < sizeof($text_array) - 1) {
571 if ($correct_answers[$key][2] == assLongMenu::ANSWER_TYPE_TEXT_VAL) {
572 if (array_key_exists($key, $user_solution)) {
573 $user_value = $user_solution[$key];
574 if (in_array($user_value, $correct_answers[$key][0])) {
575 $answer_is_correct = true;
576 }
577 }
578
579 $return_value .= $this->getTextGapTemplate($key, $user_value, $solution, $answer_is_correct, $graphical);
580 } elseif ($correct_answers[$key][2] == assLongMenu::ANSWER_TYPE_SELECT_VAL) {
581 if (array_key_exists($key, $user_solution)) {
582 $user_value = $user_solution[$key];
583 if (in_array($user_value, $correct_answers[$key][0])) {
584 $answer_is_correct = true;
585 }
586 }
587 $return_value .= $this->getSelectGapTemplate($key, $answers[$key], $user_value, $solution, $answer_is_correct, $graphical);
588 }
589 }
590 }
591 return $return_value;
592 }
593
594 private function getTextGapTemplate($key, $value, $solution, $ok = false, $graphical = false)
595 {
596 $tpl = new ilTemplate("tpl.il_as_qpl_long_menu_text_gap.html", true, true, "Modules/TestQuestionPool");
597 if ($solution) {
598 $tpl->setVariable('DISABLED', 'disabled');
599 $tpl->setVariable('JS_IGNORE', '_ignore');
600 if ($graphical) {
601 if ($ok) {
602 $tpl->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
603 $tpl->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
604 } else {
605 $tpl->setVariable("ICON_OK", ilUtil::getImagePath("icon_not_ok.svg"));
606 $tpl->setVariable("TEXT_OK", $this->lng->txt("answer_is_wrong"));
607 }
608 }
609 }
610 $tpl->setVariable('VALUE', $value);
611 $tpl->setVariable('KEY', $key);
612
613 return $tpl->get();
614 }
615
616 private function getSelectGapTemplate($key, $answers, $user_value, $solution, $ok = false, $graphical = false)
617 {
618 $tpl = new ilTemplate("tpl.il_as_qpl_long_menu_select_gap.html", true, true, "Modules/TestQuestionPool");
619 $tpl->setVariable('KEY', $key);
620 if ($solution) {
621 $tpl->setVariable('DISABLED', 'disabled');
622 $tpl->setVariable('JS_IGNORE', '_ignore');
623 $tpl->setCurrentBlock('best_solution');
624 if ($user_value == -1) {
625 $tpl->setVariable("SOLUTION", $this->lng->txt("please_select"));
626 } else {
627 $tpl->setVariable('SOLUTION', $user_value);
628 }
629 if ($graphical) {
630 if ($ok) {
631 $tpl->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.svg"));
632 $tpl->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
633 } else {
634 $tpl->setVariable("ICON_OK", ilUtil::getImagePath("icon_not_ok.svg"));
635 $tpl->setVariable("TEXT_OK", $this->lng->txt("answer_is_wrong"));
636 }
637 }
638 $tpl->parseCurrentBlock();
639 } else {
640 $tpl->setVariable("PLEASE_SELECT", $this->lng->txt("please_select"));
641 foreach ($answers as $value) {
642 $tpl->setCurrentBlock('select_option');
643 $tpl->setVariable('VALUE', $value);
644 if ($value == $user_value) {
645 $tpl->setVariable('SELECTED', 'selected');
646 }
647 $tpl->parseCurrentBlock();
648 }
649 }
650 return $tpl->get();
651 }
652
653 public function getSubQuestionsIndex()
654 {
655 return array_keys($this->object->getAnswers());
656 }
657
658 public function getAnswersFrequency($relevant_answers, $questionIndex)
659 {
660 $answers = array();
661
662 foreach ($relevant_answers as $row) {
663 if ($row['value1'] != $questionIndex) {
664 continue;
665 }
666
667 if (!isset($answers[$row['value2']])) {
668 //$label = $this->getAnswerTextLabel($row['value1'], $row['value2']);
669
670 $answers[$row['value2']] = array(
671 'answer' => $row['value2'], 'frequency' => 0
672 );
673 }
674
675 $answers[$row['value2']]['frequency']++;
676 }
677
678 return $answers;
679 }
680
681 public function getAnswerFrequencyTableGUI($parentGui, $parentCmd, $relevantAnswers, $questionIndex)
682 {
683 global $DIC; /* @var ILIAS\DI\Container $DIC */
684
685 $table = parent::getAnswerFrequencyTableGUI(
686 $parentGui,
687 $parentCmd,
688 $relevantAnswers,
689 $questionIndex
690 );
691
692 $table->setTitle(sprintf(
693 $DIC->language()->txt('tst_corrections_answers_tbl_subindex'),
694 $DIC->language()->txt('longmenu') . ' ' . ($questionIndex + 1)
695 ));
696
697 return $table;
698 }
699
701 {
702 $correctAnswers = $this->object->getCorrectAnswers();
703
704 foreach ($this->object->getAnswers() as $lmIndex => $lm) {
705 $lmValues = array(
706 'answers_all' => array(0 => $lm),
707 'answers_all_count' => count($lm),
708 'answers_correct' => $correctAnswers[$lmIndex][0]
709 );
710
711 $lmPoints = $correctAnswers[$lmIndex][1];
712
714 $section->setTitle($this->lng->txt('longmenu') . ' ' . ($lmIndex + 1));
715 $form->addItem($section);
716
718 $this->lng->txt('answers'),
719 'longmenu_' . $lmIndex
720 );
721
722 $lmInput->setRequired(true);
723
724 $lmInput->setValues($lmValues);
725
726 $form->addItem($lmInput);
727
728 $pointsInp = new ilNumberInputGUI($this->lng->txt("points"), 'points_' . $lmIndex);
729 $pointsInp->setRequired(true);
730 $pointsInp->allowDecimals(true);
731 $pointsInp->setSize(4);
732 $pointsInp->setMinValue(0);
733 $pointsInp->setMinvalueShouldBeGreater(false);
734 $pointsInp->setValue($lmPoints);
735 $form->addItem($pointsInp);
736 }
737 }
738
743 {
744 $correctAnswers = $this->object->getCorrectAnswers();
745
746 foreach ($this->object->getAnswers() as $lmIndex => $lm) {
747 $pointsInput = (float) $form->getInput('points_' . $lmIndex);
748 $correctAnswersInput = (array) $form->getInput('longmenu_' . $lmIndex . '_tags');
749
750 foreach ($correctAnswersInput as $idx => $answer) {
751 if (in_array($answer, $lm)) {
752 continue;
753 }
754
755 unset($correctAnswersInput[$idx]);
756 }
757
758 $correctAnswersInput = array_values($correctAnswersInput);
759
760 $correctAnswers[$lmIndex][0] = $correctAnswersInput;
761 $correctAnswers[$lmIndex][1] = $pointsInput;
762 }
763
764 $this->object->setCorrectAnswers($correctAnswers);
765 }
766}
$section
Definition: Utf8Test.php:83
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
getLongMenuTextWithInputFieldsInsteadOfGaps($user_solution=array(), $solution=false, $graphical=false)
setQuestionTabs()
Sets the ILIAS tabs for this question type.
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)
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
getILIASPage($html="")
Returns the ILIAS Page around a question.
getQuestionTemplate()
get question template
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
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.
addBackTab(ilTabsGUI $ilTabs)
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question,...
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT
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.
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 getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$template
$key
Definition: croninfo.php:18
if(!array_key_exists('StateId', $_REQUEST)) $id
Interface ilGuiQuestionScoringAdjustable.
$index
Definition: metadata.php:60
$row
$url
if(empty($password)) $table
Definition: pwgen.php:24
if(isset($_POST['submit'])) $form
global $DIC
Definition: saml.php:7