ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAssAnswerCorrectionsInputGUI.php
Go to the documentation of this file.
1<?php
2
28{
29 protected bool $hide_points_enabled = false;
30
31 public function isHidePointsEnabled(): bool
32 {
34 }
35
36 public function setHidePointsEnabled(bool $hide_points_enabled): void
37 {
38 $this->hide_points_enabled = $hide_points_enabled;
39 }
40
41 public function setValue($a_value): void
42 {
43 foreach ($this->forms_helper->transformPoints($a_value) as $index => $value) {
44 $this->values[$index]->setPoints($value);
45 }
46 }
47
48 public function checkInput(): bool
49 {
50 $points = $this->forms_helper->checkPointsInputEnoughPositive($this->raw($this->getPostVar()), true);
51 if (!$this->isHidePointsEnabled() && !is_array($points)) {
52 $this->setAlert($this->lng->txt($points));
53 return false;
54 }
55
56 return true;
57 }
58
59 public function insert(ilTemplate $a_tpl): void
60 {
61 global $DIC;
62 $lng = $DIC['lng'];
63
64 $tpl = new ilTemplate('tpl.prop_textsubsetcorrection_input.html', true, true, 'components/ILIAS/TestQuestionPool');
65 $i = 0;
66 foreach ($this->values as $value) {
67 if (!$this->isHidePointsEnabled()) {
68 $tpl->setCurrentBlock('points');
69 $tpl->setVariable('POST_VAR', $this->getPostVar());
70 $tpl->setVariable('ROW_NUMBER', $i);
71 $tpl->setVariable('POINTS_ID', $this->getPostVar() . "[points][$i]");
72 $tpl->setVariable('POINTS', $this->prepareFormOutput($value->getPoints()));
73 $tpl->parseCurrentBlock();
74 }
75
76 $tpl->setCurrentBlock('row');
77 $tpl->setVariable('ANSWER', $this->prepareFormOutput($value->getAnswertext()));
78 $tpl->parseCurrentBlock();
79 $i++;
80 }
81
82 $tpl->setVariable('ELEMENT_ID', $this->getPostVar());
83 $tpl->setVariable('ANSWER_TEXT', $this->getTextInputLabel($lng));
84
85 if (!$this->isHidePointsEnabled()) {
86 $tpl->setVariable('POINTS_TEXT', $this->getPointsInputLabel($lng));
87 }
88
89 $a_tpl->setCurrentBlock('prop_generic');
90 $a_tpl->setVariable('PROP_GENERIC', $tpl->get());
91 $a_tpl->parseCurrentBlock();
92 }
93}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
This class represents a single choice wizard property in a property form.
prepareFormOutput(float|string $input, bool $strip=false)
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