ILIAS  release_8 Revision v8.24
class.ilEssayKeywordWizardInputGUI.php
Go to the documentation of this file.
1<?php
19{
20 public function setValue($a_value): void
21 {
22 $this->values = array();
23 if (is_array($a_value)) {
24 if (is_array($a_value['answer'])) {
25 foreach ($a_value['answer'] as $index => $value) {
26 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
27 if (isset($a_value['points'])) {
28 $pvalue = $a_value['points'][$index];
29 } else {
30 $value = 0.0;
31 }
32 if (isset($a_value['points_unchecked'])) {
33 $value_unchecked = $a_value['points_unchecked'][$index];
34 } else {
35 $value_unchecked = 0.0;
36 }
37 $answer = new ASS_AnswerMultipleResponseImage($value, (float) $pvalue, $index, $value_unchecked);
38 $this->values[] = $answer;
39 }
40 }
41 }
42 }
43
48 public function checkInput(): bool
49 {
50 global $DIC;
51 $lng = $DIC['lng'];
52
53 include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
54 if (is_array($_POST[$this->getPostVar()])) {
56 $_POST[$this->getPostVar()],
57 false,
59 "assessment"
60 )
61 );
62 } else {
63 $foundvalues = $_POST[$this->getPostVar()];
64 }
65 if (is_array($foundvalues)) {
66 // check answers
67 if (is_array($foundvalues['answer'])) {
68 foreach ($foundvalues['answer'] as $aidx => $answervalue) {
69 if (((strlen($answervalue)) == 0) && (!isset($foundvalues['imagename']) || strlen($foundvalues['imagename'][$aidx]) == 0)) {
70 $this->setAlert($lng->txt("msg_input_is_required"));
71 return false;
72 }
73
74 if (mb_strlen($answervalue) > $this->getMaxLength()) {
75 $this->setAlert($lng->txt("msg_input_char_limit_max"));
76 return false;
77 }
78 }
79 }
80 // check points
81 $max = 0;
82 if (is_array($foundvalues['points'])) {
83 foreach ($foundvalues['points'] as $points) {
84 if ($points > $max) {
85 $max = $points;
86 }
87 if (((strlen($points)) == 0) || (!is_numeric($points))) {
88 $this->setAlert($lng->txt("form_msg_numeric_value_required"));
89 return false;
90 }
91 }
92 }
93 if ($max == 0) {
94 $this->setAlert($lng->txt("enter_enough_positive_points"));
95 return false;
96 }
97 } else {
98 $this->setAlert($lng->txt("msg_input_is_required"));
99 return false;
100 }
101
102 return $this->checkSubItemsInput();
103 }
104
109 public function insert(ilTemplate $a_tpl): void
110 {
111 global $DIC;
112 $lng = $DIC['lng'];
113
114 $tpl = new ilTemplate("tpl.prop_essaykeywordswizardinput.html", true, true, "Modules/TestQuestionPool");
115 $i = 0;
116 foreach ($this->values as $value) {
117 if ($this->getSingleline()) {
118 if (is_object($value)) {
119 $tpl->setCurrentBlock("prop_text_propval");
120 $tpl->setVariable(
121 "PROPERTY_VALUE",
123 );
124 $tpl->parseCurrentBlock();
125 $tpl->setCurrentBlock("prop_points_propval");
126 $tpl->setVariable(
127 "PROPERTY_VALUE",
129 );
130 $tpl->parseCurrentBlock();
131 }
132 $tpl->setCurrentBlock('singleline');
133 $tpl->setVariable("SIZE", $this->getSize());
134 $tpl->setVariable("SINGLELINE_ID", $this->getPostVar() . "[answer][$i]");
135 $tpl->setVariable("SINGLELINE_ROW_NUMBER", $i);
136 $tpl->setVariable("SINGLELINE_POST_VAR", $this->getPostVar());
137 $tpl->setVariable("MAXLENGTH", $this->getMaxLength());
138 if ($this->getDisabled()) {
139 $tpl->setVariable("DISABLED_SINGLELINE", " disabled=\"disabled\"");
140 }
141 $tpl->parseCurrentBlock();
142 } else {
143 if (!$this->getSingleline()) {
144 if (is_object($value)) {
145 $tpl->setCurrentBlock("prop_points_propval");
146 $tpl->setVariable(
147 "PROPERTY_VALUE",
149 );
150 $tpl->parseCurrentBlock();
151 }
152 }
153 }
154
155 $tpl->setCurrentBlock("row");
156 $tpl->setVariable("POST_VAR", $this->getPostVar());
157 $tpl->setVariable("ROW_NUMBER", $i);
158 $tpl->setVariable("ID", $this->getPostVar() . "[answer][$i]");
159 $tpl->setVariable("POINTS_ID", $this->getPostVar() . "[points][$i]");
160 $tpl->setVariable("CMD_ADD", "cmd[add" . $this->getFieldId() . "][$i]");
161 $tpl->setVariable("CMD_REMOVE", "cmd[remove" . $this->getFieldId() . "][$i]");
162 if ($this->getDisabled()) {
163 $tpl->setVariable("DISABLED_POINTS", " disabled=\"disabled\"");
164 }
165 $tpl->setVariable("ADD_BUTTON", ilGlyphGUI::get(ilGlyphGUI::ADD));
166 $tpl->setVariable("REMOVE_BUTTON", ilGlyphGUI::get(ilGlyphGUI::REMOVE));
167 $tpl->parseCurrentBlock();
168 $i++;
169 }
170
171 $tpl->setVariable("ELEMENT_ID", $this->getPostVar());
172 $tpl->setVariable("TEXT_YES", $lng->txt('yes'));
173 $tpl->setVariable("TEXT_NO", $lng->txt('no'));
174 $tpl->setVariable("DELETE_IMAGE_HEADER", $lng->txt('delete_image_header'));
175 $tpl->setVariable("DELETE_IMAGE_QUESTION", $lng->txt('delete_image_question'));
176 $tpl->setVariable("ANSWER_TEXT", $lng->txt('answer_text'));
177 $tpl->setVariable("POINTS_TEXT", $lng->txt('points'));
178 $tpl->setVariable("COMMANDS_TEXT", $lng->txt('actions'));
179 $tpl->setVariable("POINTS_CHECKED_TEXT", $lng->txt('checkbox_checked'));
180
181 $a_tpl->setCurrentBlock("prop_generic");
182 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
183 $a_tpl->parseCurrentBlock();
184
185 global $DIC;
186 $tpl = $DIC['tpl'];
187 $tpl->addJavascript("./Services/Form/js/ServiceFormWizardInput.js");
188 $tpl->addJavascript("./Modules/TestQuestionPool/templates/default/essaykeywordwizard.js");
189 }
190}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
insert(ilTemplate $a_tpl)
Insert property html.
checkInput()
Check input, strip slashes etc.
static get(string $a_glyph, string $a_text="")
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)
static _getUsedHTMLTagsAsString(string $a_module="")
Returns a string of all allowed HTML tags for text editing.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
global $DIC
Definition: feed.php:28
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$index
Definition: metadata.php:145
$i
Definition: metadata.php:41