ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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 if ($value === null) {
45 return;
46 }
47
48 $this->values[$index]->setPoints($value);
49 }
50 }
51
52 public function checkInput(): bool
53 {
54 $points = $this->forms_helper->checkPointsInputEnoughPositive($this->raw($this->getPostVar()), true);
55 if (!$this->isHidePointsEnabled() && !is_array($points)) {
56 $this->setAlert($this->lng->txt($points));
57 return false;
58 }
59
60 return true;
61 }
62
63 public function insert(ilTemplate $a_tpl): void
64 {
65 global $DIC;
66 $lng = $DIC['lng'];
67
68 $tpl = new ilTemplate('tpl.prop_textsubsetcorrection_input.html', true, true, 'components/ILIAS/TestQuestionPool');
69 $i = 0;
70 foreach ($this->values as $value) {
71 if (!$this->isHidePointsEnabled()) {
72 $tpl->setCurrentBlock('points');
73 $tpl->setVariable('POST_VAR', $this->getPostVar());
74 $tpl->setVariable('ROW_NUMBER', $i);
75 $tpl->setVariable('POINTS_ID', $this->getPostVar() . "[points][$i]");
76 $tpl->setVariable('POINTS', $this->prepareFormOutput($value->getPoints()));
77 $tpl->parseCurrentBlock();
78 }
79
80 $tpl->setCurrentBlock('row');
81 $tpl->setVariable('ANSWER', $this->prepareFormOutput($value->getAnswertext()));
82 $tpl->parseCurrentBlock();
83 $i++;
84 }
85
86 $tpl->setVariable('ELEMENT_ID', $this->getPostVar());
87 $tpl->setVariable('ANSWER_TEXT', $this->getTextInputLabel($lng));
88
89 if (!$this->isHidePointsEnabled()) {
90 $tpl->setVariable('POINTS_TEXT', $this->getPointsInputLabel($lng));
91 }
92
93 $a_tpl->setCurrentBlock('prop_generic');
94 $a_tpl->setVariable('PROP_GENERIC', $tpl->get());
95 $a_tpl->parseCurrentBlock();
96 }
97}
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