ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAssAnswerCorrectionsInputGUI.php
Go to the documentation of this file.
1 <?php
2 
28 {
32  protected $hidePointsEnabled = false;
33 
37  public function isHidePointsEnabled(): bool
38  {
40  }
41 
45  public function setHidePointsEnabled(bool $hidePointsEnabled): void
46  {
47  $this->hidePointsEnabled = $hidePointsEnabled;
48  }
49 
50  public function setValue($a_value): void
51  {
52  if (is_array($a_value)) {
53  if (is_array($a_value['points'])) {
54  foreach ($a_value['points'] as $index => $value) {
55  $this->values[$index]->setPoints($a_value['points'][$index]);
56  }
57  }
58  }
59  }
60 
61  public function checkInput(): bool
62  {
63  global $DIC;
64  $lng = $DIC['lng'];
65  $foundvalues = $_POST[$this->getPostVar()];
66 
67  if ($this->isHidePointsEnabled()) {
68  return true;
69  }
70 
71  if (is_array($foundvalues)) {
72  // check points
73  $max = 0;
74  if (is_array($foundvalues['points'])) {
75  foreach ($foundvalues['points'] as $points) {
76  $points = str_replace(',', '.', $points);
77  if ($points > $max) {
78  $max = $points;
79  }
80  if (((strlen($points)) == 0) || (!is_numeric($points))) {
81  $this->setAlert($lng->txt("form_msg_numeric_value_required"));
82  return false;
83  }
84  if ($this->minvalueShouldBeGreater()) {
85  if (trim($points) != "" &&
86  $this->getMinValue() !== false &&
87  $points <= $this->getMinValue()) {
88  $this->setAlert($lng->txt("form_msg_value_too_low"));
89 
90  return false;
91  }
92  } else {
93  if (trim($points) != "" &&
94  $this->getMinValue() !== false &&
95  $points < $this->getMinValue()) {
96  $this->setAlert($lng->txt("form_msg_value_too_low"));
97 
98  return false;
99  }
100  }
101  }
102  }
103  if ($max == 0) {
104  $this->setAlert($lng->txt("enter_enough_positive_points"));
105  return false;
106  }
107  } else {
108  $this->setAlert($lng->txt("msg_input_is_required"));
109  return false;
110  }
111 
112  return $this->checkSubItemsInput();
113  }
114 
115  public function insert(ilTemplate $a_tpl): void
116  {
117  global $DIC;
118  $lng = $DIC['lng'];
119 
120  $tpl = new ilTemplate("tpl.prop_textsubsetcorrection_input.html", true, true, "Modules/TestQuestionPool");
121  $i = 0;
122  foreach ($this->values as $value) {
123  if (!$this->isHidePointsEnabled()) {
124  $tpl->setCurrentBlock("points");
125  $tpl->setVariable("POST_VAR", $this->getPostVar());
126  $tpl->setVariable("ROW_NUMBER", $i);
127  $tpl->setVariable("POINTS_ID", $this->getPostVar() . "[points][$i]");
128  $tpl->setVariable("POINTS", ilLegacyFormElementsUtil::prepareFormOutput($value->getPoints()));
129  $tpl->parseCurrentBlock();
130  }
131 
132  $tpl->setCurrentBlock("row");
133  $tpl->setVariable("ANSWER", ilLegacyFormElementsUtil::prepareFormOutput($value->getAnswertext()));
134  $tpl->parseCurrentBlock();
135  $i++;
136  }
137 
138  $tpl->setVariable("ELEMENT_ID", $this->getPostVar());
139  $tpl->setVariable("ANSWER_TEXT", $this->getTextInputLabel($lng));
140 
141  if (!$this->isHidePointsEnabled()) {
142  $tpl->setVariable("POINTS_TEXT", $this->getPointsInputLabel($lng));
143  }
144 
145  $a_tpl->setCurrentBlock("prop_generic");
146  $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
147  $a_tpl->parseCurrentBlock();
148  }
149 }
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)
$index
Definition: metadata.php:145
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
minvalueShouldBeGreater()
Get minvalueShouldBeGreater.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$i
Definition: metadata.php:41