ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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  $this->values[$index]->setPoints($value);
38  }
39  }
40 
41  public function checkInput(): bool
42  {
43  $data = $this->raw($this->getPostVar());
44 
45  $result = $this->forms_helper->checkPointsInputEnoughPositive($data, $this->getRequired());
46  if (!is_array($result)) {
47  $this->setAlert($this->lng->txt($result));
48  return false;
49  }
50 
51  return $this->checkSubItemsInput();
52  }
53 
54  public function insert(ilTemplate $a_tpl): void
55  {
56  global $DIC; /* @var ILIAS\DI\Container $DIC */
57  $lng = $DIC->language();
58 
59  $tpl = new ilTemplate('tpl.prop_singlechoicecorrection_input.html', true, true, 'components/ILIAS/TestQuestionPool');
60 
61  if ($this->values === null) {
62  $this->values = $this->value;
63  }
64 
65  foreach ($this->values as $value) {
66  if ($this->qstObject->isSingleline()) {
67  if ($value->hasImage()) {
68  $imagename = $this->qstObject->getImagePathWeb() . $value->getImage();
69  if (($this->getSingleline()) && ($this->qstObject->getThumbSize())) {
70  if (@file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value->getImage())) {
71  $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value->getImage();
72  }
73  }
74 
75  $tpl->setCurrentBlock('image');
76  $tpl->setVariable('SRC_IMAGE', $imagename);
77  $tpl->setVariable('IMAGE_NAME', $value->getImage());
78  $tpl->setVariable('ALT_IMAGE', ilLegacyFormElementsUtil::prepareFormOutput($value->getAnswertext()));
79  $tpl->parseCurrentBlock();
80  } else {
81  $tpl->setCurrentBlock('image');
82  $tpl->touchBlock('image');
83  $tpl->parseCurrentBlock();
84  }
85  }
86 
87  $tpl->setCurrentBlock('answer');
88  $tpl->setVariable('ANSWER', $value->getAnswertext());
89  $tpl->parseCurrentBlock();
90 
91  $tpl->setCurrentBlock('prop_points_propval');
92  $tpl->setVariable('POINTS_POST_VAR', $this->getPostVar());
93  $tpl->setVariable('PROPERTY_VALUE', ilLegacyFormElementsUtil::prepareFormOutput($value->getPoints()));
94  $tpl->parseCurrentBlock();
95 
96  $tpl->setCurrentBlock('row');
97  $tpl->parseCurrentBlock();
98  }
99 
100  if ($this->qstObject->isSingleline()) {
101  $tpl->setCurrentBlock('image_heading');
102  $tpl->setVariable('ANSWER_IMAGE', $lng->txt('answer_image'));
103  $tpl->setVariable('TXT_MAX_SIZE', ilFileUtils::getFileSizeInfo());
104  $tpl->parseCurrentBlock();
105  }
106 
107  $tpl->setCurrentBlock('points_heading');
108  $tpl->setVariable('POINTS_TEXT', $lng->txt('points'));
109  $tpl->parseCurrentBlock();
110 
111  $tpl->setVariable('ELEMENT_ID', $this->getPostVar());
112  $tpl->setVariable('ANSWER_TEXT', $lng->txt('answer_text'));
113 
114  $a_tpl->setCurrentBlock('prop_generic');
115  $a_tpl->setVariable('PROP_GENERIC', $tpl->get());
116  $a_tpl->parseCurrentBlock();
117  }
118 }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
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)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
global $DIC
Definition: shib_login.php:22
static getFileSizeInfo()
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This class represents a single choice wizard property in a property form.