ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAssMultipleChoiceCorrectionsInputGUI.php
Go to the documentation of this file.
1<?php
2
28{
32 protected $qstObject;
33
34 public function setValue($a_value): void
35 {
36 $points = $this->forms_helper->transformPoints($a_value, 'points');
37 $points_unchecked = $this->forms_helper->transformPoints($a_value, 'points_unchecked');
38
39 foreach ($this->values as $index => $value) {
40 $this->values[$index]->setPoints($points[$index] ?? 0.0);
41 $this->values[$index]->setPointsUnchecked($points_unchecked[$index] ?? 0.0);
42 }
43 }
44
45 public function checkInput(): bool
46 {
47 $data = $this->raw($this->getPostVar());
48
49 $result = $this->forms_helper->checkPointsInputEnoughPositive($data, $this->getRequired(), 'points');
50 if (!is_array($result)) {
51 $this->setAlert($this->lng->txt($result));
52 return false;
53 }
54
55 $result = $this->forms_helper->checkPointsInput($data, $this->getRequired(), 'points_unchecked');
56 if (!is_array($result)) {
57 $this->setAlert($this->lng->txt($result));
58 return false;
59 }
60
61 return $this->checkSubItemsInput();
62 }
63
64 public function insert(ilTemplate $a_tpl): void
65 {
66 $tpl = new ilTemplate("tpl.prop_multiplechoicecorrection_input.html", true, true, "components/ILIAS/TestQuestionPool");
67
68 $i = 0;
69 foreach ($this->values as $value) {
70 if ($this->qstObject->isSingleline()) {
71 if ($value->hasImage()) {
72 $imagename = $this->qstObject->getImagePathWeb() . $value->getImage();
73 if (($this->getSingleline()) && ($this->qstObject->getThumbSize())) {
74 if (file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value->getImage())) {
75 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value->getImage();
76 }
77 }
78
79 $tpl->setCurrentBlock('image');
80 $tpl->setVariable('SRC_IMAGE', $imagename);
81 $tpl->setVariable('IMAGE_NAME', $value->getImage());
82 $tpl->setVariable('ALT_IMAGE', ilLegacyFormElementsUtil::prepareFormOutput($value->getAnswertext()));
83 $tpl->parseCurrentBlock();
84 } else {
85 $tpl->setCurrentBlock('image');
86 $tpl->touchBlock('image');
87 $tpl->parseCurrentBlock();
88 }
89 }
90
91 $tpl->setCurrentBlock("answer");
92 $tpl->setVariable("ANSWER", $value->getAnswertext());
93 $tpl->parseCurrentBlock();
94
95 $tpl->setCurrentBlock("row");
96 $tpl->setVariable("POINTS_POST_VAR", $this->getPostVar());
97 $tpl->setVariable("POINTS_ROW_NUMBER", $i);
98 $tpl->setVariable(
99 "PROPERTY_VALUE_CHECKED",
101 );
102 $tpl->setVariable(
103 "PROPERTY_VALUE_UNCHECKED",
105 );
106 $tpl->parseCurrentBlock();
107
108 $i++;
109 }
110
111 if ($this->qstObject->isSingleline()) {
112 $tpl->setCurrentBlock("image_heading");
113 $tpl->setVariable("ANSWER_IMAGE", $this->lng->txt('answer_image'));
114 $tpl->setVariable("TXT_MAX_SIZE", ilFileUtils::getFileSizeInfo());
115 $tpl->parseCurrentBlock();
116 }
117
118 $tpl->setCurrentBlock("points_heading");
119 $tpl->setVariable("POINTS_CHECKED_TEXT", $this->lng->txt('points_checked'));
120 $tpl->setVariable("POINTS_UNCHECKED_TEXT", $this->lng->txt('points_unchecked'));
121 $tpl->parseCurrentBlock();
122
123 $tpl->setVariable("ELEMENT_ID", $this->getPostVar());
124 $tpl->setVariable("ANSWER_TEXT", $this->lng->txt('answer_text'));
125
126 $a_tpl->setCurrentBlock("prop_generic");
127 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
128 $a_tpl->parseCurrentBlock();
129 }
130}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
static getFileSizeInfo()
static prepareFormOutput($a_str, bool $a_strip=false)
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
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)