ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilAssErrorTextCorrectionsInputGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
14 {
15  public function setValue($a_value)
16  {
17  if (is_array($a_value)) {
18  include_once "./Modules/TestQuestionPool/classes/class.assAnswerErrorText.php";
19  if (is_array($a_value['points'])) {
20  foreach ($this->values as $idx => $key) {
21  $this->values[$idx]->points = (
22  str_replace(",", ".", $a_value['points'][$idx])
23  );
24  }
25  }
26  }
27  }
28 
29  public function checkInput()
30  {
31  global $DIC;
32  $lng = $DIC['lng'];
33 
34  if (is_array($_POST[$this->getPostVar()])) {
36  }
37  $foundvalues = $_POST[$this->getPostVar()];
38 
39  if (is_array($foundvalues)) {
40  if (is_array($foundvalues['points'])) {
41  foreach ($foundvalues['points'] as $val) {
42  if ($this->getRequired() && (strlen($val)) == 0) {
43  $this->setAlert($lng->txt("msg_input_is_required"));
44  return false;
45  }
46  if (!is_numeric(str_replace(",", ".", $val))) {
47  $this->setAlert($lng->txt("form_msg_numeric_value_required"));
48  return false;
49  }
50  if ((float) $val <= 0) {
51  $this->setAlert($lng->txt("positive_numbers_required"));
52  return false;
53  }
54  }
55  } else {
56  if ($this->getRequired()) {
57  $this->setAlert($lng->txt("msg_input_is_required"));
58  return false;
59  }
60  }
61  } else {
62  if ($this->getRequired()) {
63  $this->setAlert($lng->txt("msg_input_is_required"));
64  return false;
65  }
66  }
67 
68  return $this->checkSubItemsInput();
69  }
70 
71  public function insert($a_tpl)
72  {
73  global $DIC;
74  $lng = $DIC['lng'];
75 
76  $tpl = new ilTemplate("tpl.prop_errortextcorrection_input.html", true, true, "Modules/TestQuestionPool");
77  $i = 0;
78  foreach ($this->values as $value) {
79  $tpl->setCurrentBlock("prop_points_propval");
80  $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($value->points));
81  $tpl->parseCurrentBlock();
82 
83  $tpl->setCurrentBlock("row");
84 
85  $tpl->setVariable("TEXT_WRONG", ilUtil::prepareFormOutput($value->text_wrong));
86  $tpl->setVariable("TEXT_CORRECT", ilUtil::prepareFormOutput($value->text_correct));
87 
88  $class = ($i % 2 == 0) ? "even" : "odd";
89  if ($i == 0) {
90  $class .= " first";
91  }
92  if ($i == count($this->values) - 1) {
93  $class .= " last";
94  }
95  $tpl->setVariable("ROW_CLASS", $class);
96  $tpl->setVariable("ROW_NUMBER", $i);
97 
98  $tpl->setVariable("KEY_SIZE", $this->getKeySize());
99  $tpl->setVariable("KEY_ID", $this->getPostVar() . "[key][$i]");
100  $tpl->setVariable("KEY_MAXLENGTH", $this->getKeyMaxlength());
101 
102  $tpl->setVariable("VALUE_SIZE", $this->getValueSize());
103  $tpl->setVariable("VALUE_ID", $this->getPostVar() . "[value][$i]");
104  $tpl->setVariable("VALUE_MAXLENGTH", $this->getValueMaxlength());
105 
106  $tpl->setVariable("POST_VAR", $this->getPostVar());
107 
108  $tpl->parseCurrentBlock();
109 
110  $i++;
111  }
112  $tpl->setVariable("ELEMENT_ID", $this->getPostVar());
113  $tpl->setVariable("KEY_TEXT", $this->getKeyName());
114  $tpl->setVariable("VALUE_TEXT", $this->getValueName());
115  $tpl->setVariable("POINTS_TEXT", $lng->txt('points'));
116 
117  $a_tpl->setCurrentBlock("prop_generic");
118  $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
119  $a_tpl->parseCurrentBlock();
120  }
121 }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
special template class to simplify handling of ITX/PEAR
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
$i
Definition: disco.tpl.php:19
This class represents a key value pair wizard property in a property form.
$key
Definition: croninfo.php:18
$_POST["username"]