ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilAssSingleChoiceCorrectionsInputGUI.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 foreach ($this->forms_helper->transformPoints($a_value) as $index => $value) {
37 if ($value === null) {
38 return;
39 }
40
41 $this->values[$index]->setPoints($value);
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());
50 if (!is_array($result)) {
51 $this->setAlert($this->lng->txt($result));
52 return false;
53 }
54
55 return $this->checkSubItemsInput();
56 }
57
58 public function insert(ilTemplate $a_tpl): void
59 {
60 global $DIC; /* @var ILIAS\DI\Container $DIC */
61 $lng = $DIC->language();
62
63 $tpl = new ilTemplate('tpl.prop_singlechoicecorrection_input.html', true, true, 'components/ILIAS/TestQuestionPool');
64
65 if ($this->values === null) {
66 $this->values = $this->value;
67 }
68
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('prop_points_propval');
96 $tpl->setVariable('POINTS_POST_VAR', $this->getPostVar());
97 $tpl->setVariable('PROPERTY_VALUE', ilLegacyFormElementsUtil::prepareFormOutput($value->getPoints()));
98 $tpl->parseCurrentBlock();
99
100 $tpl->setCurrentBlock('row');
101 $tpl->parseCurrentBlock();
102 }
103
104 if ($this->qstObject->isSingleline()) {
105 $tpl->setCurrentBlock('image_heading');
106 $tpl->setVariable('ANSWER_IMAGE', $lng->txt('answer_image'));
107 $tpl->setVariable('TXT_MAX_SIZE', ilFileUtils::getFileSizeInfo());
108 $tpl->parseCurrentBlock();
109 }
110
111 $tpl->setCurrentBlock('points_heading');
112 $tpl->setVariable('POINTS_TEXT', $lng->txt('points'));
113 $tpl->parseCurrentBlock();
114
115 $tpl->setVariable('ELEMENT_ID', $this->getPostVar());
116 $tpl->setVariable('ANSWER_TEXT', $lng->txt('answer_text'));
117
118 $a_tpl->setCurrentBlock('prop_generic');
119 $a_tpl->setVariable('PROP_GENERIC', $tpl->get());
120 $a_tpl->parseCurrentBlock();
121 }
122}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
static getFileSizeInfo()
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static prepareFormOutput($a_str, bool $a_strip=false)
This class represents a single choice wizard property in a property form.
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
global $DIC
Definition: shib_login.php:26