ILIAS  release_7 Revision v7.30-3-g800a261c036
class.assOrderingQuestionGUI.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';
6require_once './Modules/TestQuestionPool/interfaces/interface.ilGuiAnswerScoringAdjustable.php';
7require_once './Modules/Test/classes/inc.AssessmentConstants.php';
8
25{
26 const CMD_EDIT_NESTING = 'editNesting';
27 const CMD_SAVE_NESTING = 'saveNesting';
28 const CMD_SWITCH_TO_TERMS = 'changeToText';
29 const CMD_SWITCH_TO_PICTURESS = 'changeToPictures';
30
31 const TAB_EDIT_QUESTION = 'edit_question';
32 const TAB_EDIT_NESTING = 'edit_nesting';
33
34 public const F_USE_NESTED = 'nested_answers';
35 public const F_NESTED_ORDER = 'order_elems';
36 public const F_NESTED_ORDER_ORDER = 'content';
37 public const F_NESTED_ORDER_INDENT = 'indentation';
39
43 public $object;
44
45 public $old_ordering_depth = array();
46 public $leveled_ordering = array();
47
57 public function __construct($id = -1)
58 {
60 include_once "./Modules/TestQuestionPool/classes/class.assOrderingQuestion.php";
61 $this->object = new assOrderingQuestion();
62 if ($id >= 0) {
63 $this->object->loadFromDb($id);
64 }
65 }
66
67 public function changeToPictures()
68 {
69 if (!$this->object->isImageOrderingType()) {
70 //perhaps clear something?
71 }
72
73 $this->object->setContentType($this->object::OQ_CT_PICTURES);
74 $this->object->saveToDb();
75
76 $values = $this->request->getParsedBody();
77 $this->buildEditFormAfterTypeChange($values);
78 }
79
80 public function changeToText()
81 {
82 $ordering_element_list = $this->object->getOrderingElementList();
83 foreach ($ordering_element_list as $element) {
84 $this->object->dropImageFile($element->getContent());
85 }
86
87 $this->object->setContentType($this->object::OQ_CT_TERMS);
88 $this->object->saveToDb();
89
90 $this->buildEditFormAfterTypeChange($this->request->getParsedBody());
91 }
92
93 private function buildEditFormAfterTypeChange(array $values) : void
94 {
95 $form = $this->buildEditForm();
96
97 $ordering_element_list = $this->object->getOrderingElementList();
98 $ordering_element_list->resetElements();
99
101 $form->setValuesByArray($values);
102 $form->getItemByPostVar(assOrderingQuestion::ORDERING_ELEMENT_FORM_FIELD_POSTVAR)->setElementList($ordering_element_list);
103 $this->renderEditForm($form);
104 $this->addEditSubtabs();
105 }
106
107 public function saveNesting()
108 {
109 $form = $this->buildNestingForm();
110 $form->setValuesByPost();
112 if ($form->checkInput()) {
113 $list = $this->object->getOrderingElementList();
114
115 $ordered = [];
116 foreach (array_keys($post[self::F_NESTED_ORDER_ORDER]) as $idx => $identifier) {
117 $element_identifier = str_replace(self::F_NESTED_IDENTIFIER_PREFIX, '', $identifier);
118 $element = $list->getElementByRandomIdentifier($element_identifier);
119
120 $ordered[] = $element
121 ->withPosition($idx)
122 ->withIndentation($post[self::F_NESTED_ORDER_INDENT][$identifier]);
123 }
124
125 $list = $list->withElements($ordered);
126 $this->object->setOrderingElementList($list);
127 $this->tpl->setOnScreenMessage('success', $this->lng->txt('saved_successfully'), true);
128 } else {
129 $this->tpl->setOnScreenMessage('error', $this->lng->txt('form_input_not_valid'), true);
130 }
131
132 $this->editNesting();
133 }
134
135
136 public function removeElementImage()
137 {
138 $this->uploadElementImage();
139 }
140
141 public function uploadElementImage()
142 {
143 $form = $this->buildEditForm();
144 $form->setValuesByPost();
145 $submitted_list = $this->fetchSolutionListFromSubmittedForm($form);
146
147 $elements = [];
148 foreach ($submitted_list->getElements() as $submitted_element) {
149 if ($submitted_element->isImageUploadAvailable()) {
150 $filename = $this->object->storeImageFile(
151 $submitted_element->getUploadImageFile(),
152 $submitted_element->getUploadImageName()
153 );
154
155 if (is_null($filename)) {
156 ilUtil::sendFailure($this->lng->txt('form_upload_error'));
157 } else {
158 $submitted_element = $submitted_element->withContent($filename);
159 }
160 }
161
162 if ($submitted_element->isImageRemovalRequest()) {
163 $this->object->dropImageFile($submitted_element->getContent());
164 $submitted_element = $submitted_element->withContent('');
165 }
166
167 $elements[] = $submitted_element;
168 }
169
170 $list = $this->object->getOrderingElementList()->withElements($elements);
171 $this->object->setOrderingElementList($list);
172
174 $this->writeQuestionSpecificPostData($form);
175
176 $this->editQuestion();
177 }
178
180 {
181 $post = $_POST;
182 $thumb_geometry = (int) ($post["thumb_geometry"] ?? $this->object->getThumbGeometry());
183 $this->object->setThumbGeometry($thumb_geometry);
184
185 $points = (float) str_replace(',', '.', $post['points']);
186
187 $this->object->setPoints($points);
188
189 $use_nested = $post[self::F_USE_NESTED] === "1";
190
191 $this->object->setNestingType($use_nested);
192 }
193
194
196 {
198 ->getElementList($this->object->getId());
199
200 $use_nested = $_POST[self::F_USE_NESTED] === "1";
201
202 if ($use_nested) {
203 $existing_list = $this->object->getOrderingElementList();
204
205 $nu = [];
206 $parent_indent = -1;
207 foreach ($list->getElements() as $element) {
208 $element = $list->ensureValidIdentifiers($element);
209
210 if ($existing = $existing_list->getElementByRandomIdentifier($element->getRandomIdentifier())) {
211 if ($existing->getIndentation() == $parent_indent + 1) {
212 $element = $element
213 ->withIndentation($existing->getIndentation());
214 }
215 }
216 $parent_indent = $element->getIndentation();
217 $nu[] = $element;
218 }
219 $list = $list->withElements($nu);
220 }
221
222 return $list;
223 }
224
226 {
227 $list = $this->fetchSolutionListFromSubmittedForm($form);
228 $this->object->setOrderingElementList($list);
229 return;
230 }
231
233 {
234 $header = new ilFormSectionHeaderGUI();
235 $header->setTitle($this->lng->txt('oq_header_ordering_elements'));
236 $form->addItem($header);
237
238 $orderingElementInput = $this->object->buildOrderingElementInputGui();
239 $orderingElementInput->setStylingDisabled($this->isRenderPurposePrintPdf());
240 $this->object->initOrderingElementAuthoringProperties($orderingElementInput);
241
242 $list = $this->object->getOrderingElementList();
243 $orderingElementInput->setElementList($list);
244 $form->addItem($orderingElementInput);
245
246 return $form;
247 }
248
250 {
251 if ($this->object->isImageOrderingType()) {
252 $geometry = new ilNumberInputGUI($this->lng->txt("thumb_geometry"), "thumb_geometry");
253 $geometry->setValue($this->object->getThumbGeometry());
254 $geometry->setRequired(true);
255 $geometry->setMaxLength(6);
256 $geometry->setMinValue(20);
257 $geometry->setSize(6);
258 $geometry->setInfo($this->lng->txt("thumb_geometry_info"));
259 $form->addItem($geometry);
260 }
261
262 // points
263 $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
264 $points->allowDecimals(true);
265 $points->setValue($this->object->getPoints());
266 $points->setRequired(true);
267 $points->setSize(3);
268 $points->setMinValue(0);
269 $points->setMinvalueShouldBeGreater(true);
270 $form->addItem($points);
271
272 $nested_answers = new ilSelectInputGUI(
273 $this->lng->txt('qst_use_nested_answers'),
274 self::F_USE_NESTED
275 );
276 $nested_answers_options = [
277 0 => $this->lng->txt('qst_nested_nested_answers_off'),
278 1 => $this->lng->txt('qst_nested_nested_answers_on')
279 ];
280 $nested_answers->setOptions($nested_answers_options);
281 $nested_answers->setValue($this->object->isOrderingTypeNested());
282 $form->addItem($nested_answers);
283
284 return $form;
285 }
286
293 protected function writePostData($forceSaving = false)
294 {
295 $form = $this->buildEditForm();
296 $form->setValuesByPost();
297
298 if (!$form->checkInput()) {
299 $this->renderEditForm($form);
300 $this->addEditSubtabs(self::TAB_EDIT_QUESTION);
301 return 1; // return 1 = something went wrong, no saving happened
302 }
303
306 $this->writeAnswerSpecificPostData($form);
307 $this->writeQuestionSpecificPostData($form);
308
309 return 0; // return 0 = all fine, was saved either forced or validated
310 }
311
312 protected function addEditSubtabs($active = self::TAB_EDIT_QUESTION)
313 {
314 $tabs = $this->getTabs();
315 $tabs->addSubTab(
316 self::TAB_EDIT_QUESTION,
317 $this->lng->txt('edit_question'),
318 $this->ctrl->getLinkTarget($this, 'editQuestion')
319 );
320 if ($this->object->isOrderingTypeNested()) {
321 $tabs->addSubTab(
322 self::TAB_EDIT_NESTING,
323 $this->lng->txt('tab_nest_answers'),
324 $this->ctrl->getLinkTarget($this, self::CMD_EDIT_NESTING)
325 );
326 }
327 $tabs->setTabActive('edit_question');
328 $tabs->setSubTabActive($active);
329 }
330
331 public function editQuestion($checkonly = false)
332 {
333 $this->renderEditForm($this->buildEditForm());
334 $this->addEditSubtabs(self::TAB_EDIT_QUESTION);
335 }
336
337 public function editNesting()
338 {
339 $this->renderEditForm($this->buildNestingForm());
340 $this->addEditSubtabs(self::TAB_EDIT_NESTING);
341 $this->tpl->addCss(ilObjStyleSheet::getContentStylePath(0));
342 $this->tpl->addCss(ilObjStyleSheet::getSyntaxStylePath());
343 }
344
345
347 {
348 require_once 'Modules/TestQuestionPool/classes/forms/class.ilAssOrderingQuestionAuthoringFormGUI.php';
350 $form->setFormAction($this->ctrl->getFormAction($this));
351 $form->setTitle($this->outQuestionType());
352 $form->setMultipart($this->object->isImageOrderingType());
353 $form->setTableWidth("100%");
354 $form->setId("ordering");
355 // title, author, description, question, working time (assessment mode)
356 $this->addBasicQuestionFormProperties($form);
358 $this->populateAnswerSpecificFormPart($form);
359 $this->populateTaxonomyFormSection($form);
360
361 $form->addSpecificOrderingQuestionCommandButtons($this->object);
362 $form->addGenericAssessmentQuestionCommandButtons($this->object);
363
364 return $form;
365 }
366
367 protected function buildNestingForm()
368 {
370 $form->setFormAction($this->ctrl->getFormAction($this));
371 $form->setTitle($this->outQuestionType());
372 $form->setTableWidth("100%");
373
374 $header = new ilFormSectionHeaderGUI();
375 $header->setTitle($this->lng->txt('oq_header_ordering_elements'));
376 $form->addItem($header);
377
378 $orderingElementInput = $this->object->buildNestedOrderingElementInputGui();
379 $orderingElementInput->setStylingDisabled($this->isRenderPurposePrintPdf());
380
381 $this->object->initOrderingElementAuthoringProperties($orderingElementInput);
382
383 $list = $this->object->getOrderingElementList();
384 foreach ($list->getElements() as $element) {
385 $element = $list->ensureValidIdentifiers($element);
386 }
387
388 $orderingElementInput->setElementList($list);
389
390 $form->addItem($orderingElementInput);
391 $form->addCommandButton(self::CMD_SAVE_NESTING, $this->lng->txt("save"));
392 return $form;
393 }
394
395
402 {
403 return true;
404 }
405
421 public function getSolutionOutput(
422 $active_id,
423 $pass = null,
424 $graphicalOutput = false,
425 $result_output = false,
426 $show_question_only = true,
427 $show_feedback = false,
428 $show_correct_solution = false,
429 $show_manual_scoring = false,
430 $show_question_text = true
431 ) {
432 $solutionOrderingList = $this->object->getOrderingElementListForSolutionOutput(
433 $show_correct_solution,
434 $active_id,
435 $pass,
437 );
438
439 $answers_gui = $this->object->buildNestedOrderingElementInputGui();
440
441 if ($show_correct_solution) {
443 } else {
445 }
446
447 $answers_gui->setInteractionEnabled(false);
448 $answers_gui->setElementList($solutionOrderingList);
449
450 if ($graphicalOutput) {
451 $answers_gui->setShowCorrectnessIconsEnabled(true);
452 }
453 $answers_gui->setCorrectnessTrueElementList(
454 $solutionOrderingList->getParityTrueElementList($this->object->getOrderingElementList())
455 );
456 $solution_html = $answers_gui->getHTML();
457
458 $template = new ilTemplate("tpl.il_as_qpl_nested_ordering_output_solution.html", true, true, "Modules/TestQuestionPool");
459 $template->setVariable('SOLUTION_OUTPUT', $solution_html);
460 if ($show_question_text == true) {
461 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
462 }
463 $questionoutput = $template->get();
464
465 $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", true, true, "Modules/TestQuestionPool");
466 $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);
467
468 if ($show_feedback) {
469 $feedback = '';
470
471 if (!$this->isTestPresentationContext()) {
472 $fb = $this->getGenericFeedbackOutput($active_id, $pass);
473 $feedback .= strlen($fb) ? $fb : '';
474 }
475
476 $fb = $this->getSpecificFeedbackOutput(array());
477 $feedback .= strlen($fb) ? $fb : '';
478
479 if (strlen($feedback)) {
480 $cssClass = (
481 $this->hasCorrectSolution($active_id, $pass) ?
483 );
484
485 $solutiontemplate->setVariable("ILC_FB_CSS_CLASS", $cssClass);
486 $solutiontemplate->setVariable("FEEDBACK", $this->object->prepareTextareaOutput($feedback, true));
487 }
488 }
489
490 if ($show_question_only) {
491 return $solutiontemplate->get();
492 }
493
494 return $this->getILIASPage($solutiontemplate->get());
495
496 // is this template still in use? it is not used at this point any longer!
497 // $template = new ilTemplate("tpl.il_as_qpl_ordering_output_solution.html", TRUE, TRUE, "Modules/TestQuestionPool");
498 }
499
500 public function getPreview($show_question_only = false, $showInlineFeedback = false)
501 {
502 if ($this->getPreviewSession() && $this->getPreviewSession()->hasParticipantSolution()) {
503 $solutionOrderingElementList = unserialize(
504 $this->getPreviewSession()->getParticipantsSolution()
505 );
506 } else {
507 $solutionOrderingElementList = $this->object->getShuffledOrderingElementList();
508 }
509
510 $answers = $this->object->buildNestedOrderingElementInputGui();
511 $answers->setNestingEnabled($this->object->isOrderingTypeNested());
513 $answers->setInteractionEnabled($this->isInteractivePresentation());
514 $answers->setElementList($solutionOrderingElementList);
515
516 $template = new ilTemplate("tpl.il_as_qpl_ordering_output.html", true, true, "Modules/TestQuestionPool");
517
518 $template->setCurrentBlock('nested_ordering_output');
519 $template->setVariable('NESTED_ORDERING', $answers->getHTML());
520 $template->parseCurrentBlock();
521
522 $template->setVariable("QUESTIONTEXT", $this->object->getQuestionForHTMLOutput());
523
524 if ($show_question_only) {
525 return $template->get();
526 }
527
528 return $this->getILIASPage($template->get());
529 }
530
532 {
533 global $DIC; /* @var ILIAS\DI\Container $DIC */
534
535 $files = [];
536
537 if ($DIC['ilBrowser']->isMobile() || $DIC['ilBrowser']->isIpad()) {
538 $files[] = './node_modules/@andxor/jquery-ui-touch-punch-fix/jquery.ui.touch-punch.js';
539 }
540
541 return $files;
542 }
543
544 // hey: prevPassSolutions - pass will be always available from now on
545 public function getTestOutput($activeId, $pass, $isPostponed = false, $userSolutionPost = false, $inlineFeedback = false)
546 // hey.
547 {
548 // hey: prevPassSolutions - fixed variable type, makes phpstorm stop crying
549 $userSolutionPost = is_array($userSolutionPost) ? $userSolutionPost : array();
550 // hey.
551
552 $orderingGUI = $this->object->buildNestedOrderingElementInputGui();
553 $orderingGUI->setNestingEnabled($this->object->isOrderingTypeNested());
554
555 $solutionOrderingElementList = $this->object->getSolutionOrderingElementListForTestOutput(
556 $orderingGUI,
557 $userSolutionPost,
558 $activeId,
559 $pass
560 );
561
562 $template = new ilTemplate('tpl.il_as_qpl_ordering_output.html', true, true, 'Modules/TestQuestionPool');
563
565 $orderingGUI->setElementList($solutionOrderingElementList);
566
567 $template->setCurrentBlock('nested_ordering_output');
568 $template->setVariable('NESTED_ORDERING', $orderingGUI->getHTML());
569 $template->parseCurrentBlock();
570
571 $template->setVariable('QUESTIONTEXT', $this->object->getQuestionForHTMLOutput());
572
573 $pageoutput = $this->outQuestionPage('', $isPostponed, $activeId, $template->get());
574
575 return $pageoutput;
576 }
577
578 protected function isInteractivePresentation()
579 {
580 if ($this->isRenderPurposePlayback()) {
581 return true;
582 }
583
584 if ($this->isRenderPurposeDemoplay()) {
585 return true;
586 }
587
588 return false;
589 }
590
591 protected function getTabs() : ilTabsGUI
592 {
593 global $DIC;
594 return $DIC['ilTabs'];
595 }
596
597 public function getSpecificFeedbackOutput($userSolution)
598 {
599 if (!$this->object->feedbackOBJ->specificAnswerFeedbackExists()) {
600 return '';
601 }
602
603 $tpl = new ilTemplate('tpl.il_as_qpl_ordering_elem_fb.html', true, true, 'Modules/TestQuestionPool');
604
605 foreach ($this->object->getOrderingElementList() as $element) {
606 $feedback = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
607 $this->object->getId(),
608 0,
609 $element->getPosition()
610 );
611
612 if ($this->object->isImageOrderingType()) {
613 $imgSrc = $this->object->getImagePathWeb() . $element->getContent();
614 $tpl->setCurrentBlock('image');
615 $tpl->setVariable('IMG_SRC', $imgSrc);
616 } else {
617 $tpl->setCurrentBlock('text');
618 }
619 $tpl->setVariable('CONTENT', $element->getContent());
620 $tpl->parseCurrentBlock();
621
622 $tpl->setCurrentBlock('element');
623 $tpl->setVariable('FEEDBACK', $feedback);
624 $tpl->parseCurrentBlock();
625 }
626
627 return $this->object->prepareTextareaOutput($tpl->get(), true);
628 }
629
640 {
641 return array();
642 }
643
654 {
655 return array();
656 }
657
666 public function getAggregatedAnswersView($relevant_answers)
667 {
668 $aggView = $this->aggregateAnswers(
669 $relevant_answers,
670 $this->object->getOrderingElementList()
671 );
672
673 return $this->renderAggregateView($aggView)->get();
674 }
675
676 public function aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
677 {
678 $passdata = array(); // Regroup answers into units of passes.
679 foreach ($relevant_answers_chosen as $answer_chosen) {
680 $passdata[$answer_chosen['active_fi'] . '-' . $answer_chosen['pass']][$answer_chosen['value2']] = $answer_chosen['value1'];
681 }
682
683 $variants = array(); // Determine unique variants.
684 foreach ($passdata as $key => $data) {
685 $hash = md5(implode('-', $data));
686 $value_set = false;
687 foreach ($variants as $vkey => $variant) {
688 if ($variant['hash'] == $hash) {
689 $variant['count']++;
690 $value_set = true;
691 }
692 }
693 if (!$value_set) {
694 $variants[$key]['hash'] = $hash;
695 $variants[$key]['count'] = 1;
696 }
697 }
698
699 $aggregate = array(); // Render aggregate from variant.
700 foreach ($variants as $key => $variant_entry) {
701 $variant = $passdata[$key];
702
703 foreach ($variant as $variant_key => $variant_line) {
704 $i = 0;
705 $aggregated_info_for_answer['count'] = $variant_entry['count'];
706 foreach ($answers_defined_on_question as $element) {
707 $i++;
708
709 if ($this->object->isImageOrderingType()) {
710 $element->setImageThumbnailPrefix($this->object->getThumbPrefix());
711 $element->setImagePathWeb($this->object->getImagePathWeb());
712 $element->setImagePathFs($this->object->getImagePath());
713
714 $src = $element->getPresentationImageUrl();
715 $alt = $element->getContent();
716 $content = "<img src='{$src}' alt='{$alt}' title='{$alt}'/>";
717 } else {
718 $content = $element->getContent();
719 }
720
721 $aggregated_info_for_answer[$i . ' - ' . $content]
722 = $passdata[$key][$i];
723 }
724 }
725 $aggregate[] = $aggregated_info_for_answer;
726 }
727 return $aggregate;
728 }
729
735 public function renderAggregateView($aggregate)
736 {
737 $tpl = new ilTemplate('tpl.il_as_aggregated_answers_table.html', true, true, "Modules/TestQuestionPool");
738
739 foreach ($aggregate as $line_data) {
740 $tpl->setCurrentBlock('aggregaterow');
741 $count = array_shift($line_data);
742 $html = '<ul>';
743 foreach ($line_data as $key => $line) {
744 $html .= '<li>' . ++$line . '&nbsp;-&nbsp;' . $key . '</li>';
745 }
746 $html .= '</ul>';
747 $tpl->setVariable('COUNT', $count);
748 $tpl->setVariable('OPTION', $html);
749
750 $tpl->parseCurrentBlock();
751 }
752 return $tpl;
753 }
754
756 {
757 if ($this->object->isImageOrderingType()) {
758 $element->setImageThumbnailPrefix($this->object->getThumbPrefix());
759 $element->setImagePathWeb($this->object->getImagePathWeb());
760 $element->setImagePathFs($this->object->getImagePath());
761
762 $src = $element->getPresentationImageUrl();
763 $alt = $element->getContent();
764 $content = "<img src='{$src}' alt='{$alt}' title='{$alt}'/>";
765 } else {
766 $content = $element->getContent();
767 }
768
769 return $content;
770 }
771
773 {
774 $html = '<ul>';
775
776 $lastIndent = 0;
777 $firstElem = true;
778
779 foreach ($list as $elem) {
780 if ($elem->getIndentation() > $lastIndent) {
781 $html .= '<ul><li>';
782 } elseif ($elem->getIndentation() < $lastIndent) {
783 $html .= '</li></ul><li>';
784 } elseif (!$firstElem) {
785 $html .= '</li><li>';
786 } else {
787 $html .= '<li>';
788 }
789
790 $html .= $this->getAnswerStatisticOrderingElementHtml($elem);
791
792 $firstElem = false;
793 $lastIndent = $elem->getIndentation();
794 }
795
796 $html .= '</li>';
797
798 for ($i = $lastIndent; $i > 0; $i--) {
799 $html .= '</ul></li>';
800 }
801
802 $html .= '</ul>';
803
804 return $html;
805 }
806
807 public function getAnswersFrequency($relevantAnswers, $questionIndex)
808 {
809 $answersByActiveAndPass = array();
810
811 foreach ($relevantAnswers as $row) {
812 $key = $row['active_fi'] . ':' . $row['pass'];
813
814 if (!isset($answersByActiveAndPass[$key])) {
815 $answersByActiveAndPass[$key] = array();
816 }
817
818 $answersByActiveAndPass[$key][$row['value1']] = $row['value2'];
819 }
820
821 $solutionLists = array();
822
823 foreach ($answersByActiveAndPass as $indexedSolutions) {
824 $solutionLists[] = $this->object->getSolutionOrderingElementList($indexedSolutions);
825 }
826
827 /* @var ilAssOrderingElementList[] $answers */
828 $answers = array();
829
830 foreach ($solutionLists as $orderingElementList) {
831 $hash = $orderingElementList->getHash();
832
833 if (!isset($answers[$hash])) {
834 $variantHtml = $this->getAnswerStatisticOrderingVariantHtml(
835 $orderingElementList
836 );
837
838 $answers[$hash] = array(
839 'answer' => $variantHtml, 'frequency' => 0
840 );
841 }
842
843 $answers[$hash]['frequency']++;
844 }
845
846 return array_values($answers);
847 }
848
853 {
855 $orderingInput->prepareReprintable($this->object);
856 }
857
862 {
863 $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
864 $points->allowDecimals(true);
865 $points->setValue($this->object->getPoints());
866 $points->setRequired(true);
867 $points->setSize(3);
868 $points->setMinValue(0);
869 $points->setMinvalueShouldBeGreater(true);
870 $form->addItem($points);
871
872 $header = new ilFormSectionHeaderGUI();
873 $header->setTitle($this->lng->txt('oq_header_ordering_elements'));
874 $form->addItem($header);
875
876 $orderingElementInput = $this->object->buildNestedOrderingElementInputGui();
877
878 $this->object->initOrderingElementAuthoringProperties($orderingElementInput);
879
880 $orderingElementInput->setElementList($this->object->getOrderingElementList());
881
882 $form->addItem($orderingElementInput);
883 }
884
889 {
890 $this->object->setPoints((float) $form->getInput('points'));
891
892 $submittedElementList = $this->fetchSolutionListFromSubmittedForm($form);
893
894 $curElementList = $this->object->getOrderingElementList();
895
896 $newElementList = new ilAssOrderingElementList();
897 $newElementList->setQuestionId($this->object->getId());
898
899 foreach ($submittedElementList as $submittedElement) {
900 if (!$curElementList->elementExistByRandomIdentifier($submittedElement->getRandomIdentifier())) {
901 continue;
902 }
903
904 $curElement = $curElementList->getElementByRandomIdentifier($submittedElement->getRandomIdentifier());
905
906 $curElement->setPosition($submittedElement->getPosition());
907
908 if ($this->object->isOrderingTypeNested()) {
909 $curElement->setIndentation($submittedElement->getIndentation());
910 }
911
912 $newElementList->addElement($curElement);
913 }
914
915 $this->object->setOrderingElementList($newElementList);
916 }
917}
$filename
Definition: buildRTE.php:89
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
Ordering question GUI representation.
prepareReprintableCorrectionsForm(ilPropertyFormGUI $form)
addEditSubtabs($active=self::TAB_EDIT_QUESTION)
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.
fetchSolutionListFromSubmittedForm(ilPropertyFormGUI $form)
getAnswersFrequency($relevantAnswers, $questionIndex)
getPreview($show_question_only=false, $showInlineFeedback=false)
__construct($id=-1)
assOrderingQuestionGUI constructor
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
Adds the answer specific form parts to a question property form gui.
aggregateAnswers($relevant_answers_chosen, $answers_defined_on_question)
getAnswerStatisticOrderingElementHtml(ilAssOrderingElement $element)
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
Extracts the answer specific values from $_POST and applies them to the data object.
populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
supportsIntermediateSolutionOutput()
Question type specific support of intermediate solution output The function getSolutionOutput respect...
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
writePostData($forceSaving=false)
{Evaluates a posted edit form and writes the form data in the question object.integer A positive valu...
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
getAnswerStatisticOrderingVariantHtml(ilAssOrderingElementList $list)
getTestOutput($activeId, $pass, $isPostponed=false, $userSolutionPost=false, $inlineFeedback=false)
getSpecificFeedbackOutput($userSolution)
Returns the answer specific feedback for the question.
Class for ordering questions.
Basic GUI class for assessment questions.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
getILIASPage($html="")
Returns the ILIAS Page around a question.
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.
setImageThumbnailPrefix($imageThumbnailPrefix)
This class represents a section header in a property form.
This class represents a number property in a property form.
static getSyntaxStylePath()
get syntax style path
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
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.
getItemByPostVar($a_post_var)
Get Item by POST variable.
This class represents a selection list property in a property form.
Tabs GUI.
special template class to simplify handling of ITX/PEAR
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $DIC
Definition: goto.php:24
Interface ilGuiAnswerScoringAdjustable.
Interface ilGuiQuestionScoringAdjustable.
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$data
Definition: storeScorm.php:23