ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilAssAnswerCorrectionsInputGUI.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{
18 protected $hidePointsEnabled = false;
19
23 public function isHidePointsEnabled() : bool
24 {
26 }
27
32 {
33 $this->hidePointsEnabled = $hidePointsEnabled;
34 }
35
36 public function setValue($a_value)
37 {
38 if (is_array($a_value)) {
39 if (is_array($a_value['points'])) {
40 foreach ($a_value['points'] as $index => $value) {
41 $this->values[$index]->setPoints($a_value['points'][$index]);
42 }
43 }
44 }
45 }
46
47 public function checkInput()
48 {
49 global $DIC;
50 $lng = $DIC['lng'];
52 $foundvalues = $_POST[$this->getPostVar()];
53
54 if ($this->isHidePointsEnabled()) {
55 return true;
56 }
57
58 if (is_array($foundvalues)) {
59 // check points
60 $max = 0;
61 if (is_array($foundvalues['points'])) {
62 foreach ($foundvalues['points'] as $points) {
63 if ($points > $max) {
64 $max = $points;
65 }
66 if (((strlen($points)) == 0) || (!is_numeric($points))) {
67 $this->setAlert($lng->txt("form_msg_numeric_value_required"));
68 return false;
69 }
70 if ($this->minvalueShouldBeGreater()) {
71 if (trim($points) != "" &&
72 $this->getMinValue() !== false &&
73 $points <= $this->getMinValue()) {
74 $this->setAlert($lng->txt("form_msg_value_too_low"));
75
76 return false;
77 }
78 } else {
79 if (trim($points) != "" &&
80 $this->getMinValue() !== false &&
81 $points < $this->getMinValue()) {
82 $this->setAlert($lng->txt("form_msg_value_too_low"));
83
84 return false;
85 }
86 }
87 }
88 }
89 if ($max == 0) {
90 $this->setAlert($lng->txt("enter_enough_positive_points"));
91 return false;
92 }
93 } else {
94 $this->setAlert($lng->txt("msg_input_is_required"));
95 return false;
96 }
97
98 return $this->checkSubItemsInput();
99 }
100
101 public function insert($a_tpl)
102 {
103 global $DIC;
104 $lng = $DIC['lng'];
105
106 $tpl = new ilTemplate("tpl.prop_textsubsetcorrection_input.html", true, true, "Modules/TestQuestionPool");
107 $i = 0;
108 foreach ($this->values as $value) {
109 if (!$this->isHidePointsEnabled()) {
110 $tpl->setCurrentBlock("points");
111 $tpl->setVariable("POST_VAR", $this->getPostVar());
112 $tpl->setVariable("ROW_NUMBER", $i);
113 $tpl->setVariable("POINTS_ID", $this->getPostVar() . "[points][$i]");
114 $tpl->setVariable("POINTS", ilUtil::prepareFormOutput($value->getPoints()));
115 $tpl->parseCurrentBlock();
116 }
117
118 $tpl->setCurrentBlock("row");
119 $tpl->setVariable("ANSWER", ilUtil::prepareFormOutput($value->getAnswertext()));
120 $tpl->parseCurrentBlock();
121 $i++;
122 }
123
124 $tpl->setVariable("ELEMENT_ID", $this->getPostVar());
125 $tpl->setVariable("ANSWER_TEXT", $this->getTextInputLabel($lng));
126
127 if (!$this->isHidePointsEnabled()) {
128 $tpl->setVariable("POINTS_TEXT", $this->getPointsInputLabel($lng));
129 }
130
131 $a_tpl->setCurrentBlock("prop_generic");
132 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
133 $a_tpl->parseCurrentBlock();
134 }
135}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
This class represents a single choice wizard property in a property form.
minvalueShouldBeGreater()
Get minvalueShouldBeGreater.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
special template class to simplify handling of ITX/PEAR
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
global $DIC
Definition: goto.php:24
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$index
Definition: metadata.php:128
$i
Definition: metadata.php:24