59 $this->button_factory =
$DIC->ui()->factory()->button();
60 $this->glyph_factory =
$DIC->ui()->factory()->symbol()->glyph();
61 $this->
renderer = $DIC->ui()->renderer();
64 $this->validationRegexp =
"";
71 $answers = $this->forms_helper->transformArray($a_value,
'answer', $this->
refinery->kindlyTo()->string());
72 $images = $this->forms_helper->transformArray($a_value,
'imagename', $this->
refinery->kindlyTo()->string());
73 $points = $this->forms_helper->transformPoints($a_value);
75 foreach ($answers as $index =>
$value) {
78 $points[$index] ?? 0.0,
84 if ($this->forms_helper->inArray($images, $index)) {
85 $answer->setImage($images[$index]);
87 $this->values[] = $answer;
98 $this->values = $a_values;
118 $this->singleline = $a_value;
138 $this->qstObject = &$a_value;
158 $this->allowMove = $a_allow_move;
213 $this->minvalue = $a_minvalue;
233 if (!is_array(
$data)) {
234 $this->
setAlert($this->
lng->txt(
'msg_input_is_required'));
239 $points = $this->forms_helper->checkPointsInputEnoughPositive(
$data,
true);
240 if (!is_array($points)) {
244 foreach ($points as
$value) {
248 $this->
setAlert($this->
lng->txt(
'form_msg_value_too_low'));
255 $answers = $this->forms_helper->transformArray(
$data,
'answer', $this->
refinery->kindlyTo()->string());
256 foreach ($answers as $answer) {
257 if ($answer ===
'') {
258 $this->
setAlert($this->
lng->txt(
'msg_input_is_required'));
270 foreach ($this->values as
$value) {
273 $tpl->setCurrentBlock(
"prop_text_propval");
278 $tpl->parseCurrentBlock();
279 $tpl->setCurrentBlock(
"prop_points_propval");
284 $tpl->parseCurrentBlock();
286 $tpl->setCurrentBlock(
'singleline');
287 $tpl->setVariable(
"SIZE", $this->
getSize());
288 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][$i]");
289 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $i);
290 $tpl->setVariable(
"SINGLELINE_POST_VAR", $this->
getPostVar());
293 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
295 $tpl->parseCurrentBlock();
298 $tpl->setCurrentBlock(
"prop_points_propval");
303 $tpl->parseCurrentBlock();
305 $tpl->setCurrentBlock(
'multiline');
307 $tpl->setVariable(
"MULTILINE_ID", $this->
getPostVar() .
"[answer][$i]");
308 $tpl->setVariable(
"MULTILINE_ROW_NUMBER", $i);
309 $tpl->setVariable(
"MULTILINE_POST_VAR", $this->
getPostVar());
311 $tpl->setVariable(
"DISABLED_MULTILINE",
" disabled=\"disabled\"");
313 $tpl->parseCurrentBlock();
316 $tpl->setCurrentBlock(
"move");
317 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
318 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
319 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[$i]");
320 $tpl->setVariable(
"UP_BUTTON", $this->
renderer->render(
321 $this->button_factory->shy(
'',
'')->withSymbol($this->glyph_factory->up())
323 $tpl->setVariable(
"DOWN_BUTTON", $this->
renderer->render(
324 $this->button_factory->shy(
'',
'')->withSymbol($this->glyph_factory->down())
326 $tpl->parseCurrentBlock();
328 $tpl->setCurrentBlock(
"row");
329 $tpl->setVariable(
"POST_VAR", $this->
getPostVar());
330 $tpl->setVariable(
"ROW_NUMBER", $i);
331 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[answer][$i]");
332 $tpl->setVariable(
"POINTS_ID", $this->
getPostVar() .
"[points][$i]");
334 $tpl->setVariable(
"ADD_REMOVE_ID", $this->
getPostVar() .
"[$i]");
335 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]");
336 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]");
337 $tpl->setVariable(
"ADD_BUTTON", $this->
renderer->render(
338 $this->button_factory->shy(
'',
'')->withSymbol($this->glyph_factory->add())
340 $tpl->setVariable(
"REMOVE_BUTTON", $this->
renderer->render(
341 $this->button_factory->shy(
'',
'')->withSymbol($this->glyph_factory->remove())
345 $tpl->setVariable(
"DISABLED_POINTS",
" disabled=\"disabled\"");
347 $tpl->parseCurrentBlock();
351 $tpl->setVariable(
"ELEMENT_ID", $this->
getPostVar());
354 $tpl->setVariable(
"COMMANDS_TEXT", $this->
lng->txt(
'actions'));
362 $tpl->addJavascript(
"assets/js/answerwizardinput.js");
363 $tpl->addJavascript(
"assets/js/answerwizard.js");
372 return $lng->
txt(
'answer_text');
389 return "tpl.prop_answerwizardinput.html";
394 $input_string = $this->
refinery->kindlyTo()->string()->transform($input);
397 [
'{',
'}',
'\'],
400 ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401,
Class for answers with a binary state indicator.
setVariable($variable, $value='')
Sets a variable value.
Builds a Color from either hex- or rgb values.
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...
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This class represents a text property in a property form.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
This is how a factory for glyphs looks like.
An entity that renders components to a string output.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc