60 $this->validationRegexp =
'';
63 $this->glyph_factory =
$DIC->ui()->factory()->symbol()->glyph();
64 $this->button_factory =
$DIC->ui()->factory()->button();
65 $this->
renderer = $DIC->ui()->renderer();
66 $this->upload_limit =
$DIC[
'ui.upload_limit_resolver'];
74 $answers = $this->forms_helper->transformArray($a_value,
'answer', $this->
refinery->kindlyTo()->string());
75 $points = $this->forms_helper->transformPoints($a_value);
77 foreach ($answers as $index =>
$value) {
80 $points[$index] ?? 0.0,
84 (
int) $a_value[
'answer_id'][$index] ?? 0
86 if (isset($a_value[
'imagename'][$index])) {
87 $answer->setImage($a_value[
'imagename'][$index]);
89 $this->values[] = $answer;
107 $this->suffixes = $a_suffixes;
117 $this->hideImages = $a_hide;
132 $this->showPoints = $a_value;
147 $this->values = $a_values;
167 $this->singleline = $a_value;
187 $this->qstObject = &$a_value;
207 $this->allowMove = $a_allow_move;
238 $to_string = $this->
refinery->kindlyTo()->string();
239 $answers = $this->forms_helper->transformArray(
$data,
'answer', $to_string);
240 $image_names = $this->forms_helper->transformArray(
$data,
'imagename', $to_string);
241 foreach ($answers as $index =>
$value) {
242 if (
$value ===
'' && !$this->forms_helper->inArray($image_names, $index)) {
243 return 'msg_input_is_required';
247 return 'msg_input_char_limit_max';
258 if (!is_array(
$data)) {
259 $this->
setAlert($this->
lng->txt(
'msg_input_is_required'));
264 $points = $this->forms_helper->checkPointsInputEnoughPositive(
$data,
true);
265 if (!is_array($points)) {
272 if (!is_array($answers)) {
276 $image_names = $this->forms_helper->transformArray(
$data,
'imagename', $this->
refinery->kindlyTo()->string());
278 if (is_array($_FILES) && count($_FILES) && $this->
getSingleline() && (!$this->hideImages)) {
279 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image'])) {
280 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error) {
284 case UPLOAD_ERR_FORM_SIZE:
285 case UPLOAD_ERR_INI_SIZE:
286 $this->
setAlert($this->
lng->txt(
'form_msg_file_size_exceeds'));
290 case UPLOAD_ERR_PARTIAL:
291 $this->
setAlert($this->
lng->txt(
'form_msg_file_partially_uploaded'));
295 case UPLOAD_ERR_NO_FILE:
297 !$this->forms_helper->inArray($image_names, $index)
298 && !$this->forms_helper->inArray($answers, $index)
299 && $this->getRequired()
301 $this->
setAlert($this->
lng->txt(
'form_msg_file_no_upload'));
306 case UPLOAD_ERR_NO_TMP_DIR:
307 $this->
setAlert($this->
lng->txt(
'form_msg_file_missing_tmp_dir'));
311 case UPLOAD_ERR_CANT_WRITE:
312 $this->
setAlert($this->
lng->txt(
'form_msg_file_cannot_write_to_disk'));
316 case UPLOAD_ERR_EXTENSION:
317 $this->
setAlert($this->
lng->txt(
'form_msg_file_upload_stopped_ext'));
324 $this->
setAlert($this->
lng->txt(
'form_msg_file_no_upload'));
328 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
329 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
333 $suffix = $filename_arr[
'extension'];
334 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
335 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
342 $this->
setAlert($this->
lng->txt(
'form_msg_file_wrong_file_type'));
349 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
350 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
354 $suffix = $filename_arr[
'extension'];
355 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
356 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
358 if ($tmpname !==
'') {
360 if ($vir[0] ==
false) {
361 $this->
setAlert($this->
lng->txt(
'form_msg_file_virus_found') .
'<br />' . $vir[1]);
375 $tpl =
new ilTemplate(
'tpl.prop_singlechoicewizardinput.html',
true,
true,
'components/ILIAS/TestQuestionPool');
377 foreach ($this->values as
$value) {
379 if (!$this->hideImages) {
381 $imagename = $this->qstObject->getImagePathWeb() .
$value->getImage();
382 if (($this->
getSingleline()) && ($this->qstObject->getThumbSize())) {
383 if (file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() .
$value->getImage())) {
384 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() .
$value->getImage();
387 $tpl->setCurrentBlock(
'image');
388 $tpl->setVariable(
'SRC_IMAGE', $imagename);
389 $tpl->setVariable(
'IMAGE_NAME',
$value->getImage());
394 $tpl->setVariable(
'TXT_DELETE_EXISTING', $this->
lng->txt(
'delete_existing_file'));
395 $tpl->setVariable(
'IMAGE_ROW_NUMBER', $i);
396 $tpl->setVariable(
'IMAGE_POST_VAR', $this->
getPostVar());
397 $tpl->parseCurrentBlock();
399 $tpl->setCurrentBlock(
'addimage');
400 $tpl->setVariable(
'IMAGE_BROWSE', $this->
lng->txt(
'select_file'));
401 $tpl->setVariable(
'IMAGE_ID', $this->
getPostVar() .
"[image][$i]");
402 $tpl->setVariable(
'MAX_SIZE_WARNING', $this->
lng->txt(
'form_msg_file_size_exceeds'));
403 $tpl->setVariable(
'MAX_SIZE', $this->upload_limit->getPhpUploadLimitInBytes());
404 $tpl->setVariable(
'IMAGE_SUBMIT', $this->
lng->txt(
'upload'));
405 $tpl->setVariable(
'IMAGE_ROW_NUMBER', $i);
406 $tpl->setVariable(
'IMAGE_POST_VAR', $this->
getPostVar());
407 $tpl->parseCurrentBlock();
411 $tpl->setCurrentBlock(
'prop_text_propval');
416 $tpl->parseCurrentBlock();
418 $tpl->setCurrentBlock(
'prop_points_propval');
423 $tpl->parseCurrentBlock();
425 $tpl->setCurrentBlock(
'prop_answer_id_propval');
427 $tpl->parseCurrentBlock();
429 $tpl->setCurrentBlock(
'singleline');
430 $tpl->setVariable(
'SIZE', $this->
getSize());
431 $tpl->setVariable(
'SINGLELINE_ID', $this->
getPostVar() .
"[answer][$i]");
432 $tpl->setVariable(
'SINGLELINE_ROW_NUMBER', $i);
433 $tpl->setVariable(
'SINGLELINE_POST_VAR', $this->
getPostVar());
436 $tpl->setVariable(
'DISABLED_SINGLELINE',
' disabled="disabled"');
438 $tpl->parseCurrentBlock();
442 $tpl->setCurrentBlock(
'prop_points_propval');
447 $tpl->parseCurrentBlock();
449 $tpl->setCurrentBlock(
'prop_answer_id_propval');
451 $tpl->parseCurrentBlock();
453 $tpl->setCurrentBlock(
'multiline');
458 $tpl->setVariable(
'MULTILINE_ID', $this->
getPostVar() .
"[answer][$i]");
459 $tpl->setVariable(
'MULTILINE_ROW_NUMBER', $i);
460 $tpl->setVariable(
'MULTILINE_POST_VAR', $this->
getPostVar());
463 $tpl->setVariable(
'DISABLED_MULTILINE',
' disabled="disabled"');
465 $tpl->parseCurrentBlock();
468 $tpl->setCurrentBlock(
'move');
469 $tpl->setVariable(
'ID', $this->
getPostVar() .
"[$i]");
470 $tpl->setVariable(
'UP_BUTTON', $this->
renderer->render(
471 $this->button_factory->standard(
'',
'')->withSymbol($this->glyph_factory->up())
473 $tpl->setVariable(
'DOWN_BUTTON', $this->
renderer->render(
474 $this->button_factory->standard(
'',
'')->withSymbol($this->glyph_factory->down())
476 $tpl->parseCurrentBlock();
479 $tpl->setCurrentBlock(
'points');
480 $tpl->setVariable(
'POINTS_ID', $this->
getPostVar() .
"[points][$i]");
481 $tpl->setVariable(
'POINTS_POST_VAR', $this->
getPostVar());
482 $tpl->setVariable(
'POINTS_ROW_NUMBER', $i);
483 $tpl->parseCurrentBlock();
485 $tpl->setCurrentBlock(
'row');
486 $tpl->setVariable(
'POST_VAR', $this->
getPostVar());
487 $tpl->setVariable(
'ROW_NUMBER', $i);
488 $tpl->setVariable(
'ID', $this->
getPostVar() .
"[answer][$i]");
490 $tpl->setVariable(
'DISABLED_POINTS',
' disabled="disabled"');
492 $tpl->setVariable(
'ADD_BUTTON', $this->
renderer->render(
493 $this->button_factory->shy(
'',
'')->withSymbol($this->glyph_factory->add())
495 $tpl->setVariable(
'REMOVE_BUTTON', $this->
renderer->render(
496 $this->button_factory->shy(
'',
'')->withSymbol($this->glyph_factory->remove())
498 $tpl->parseCurrentBlock();
503 if (!$this->hideImages) {
505 $suff_str = $delim =
'';
507 $suff_str .= $delim .
'.' .
$suffix;
510 $tpl->setCurrentBlock(
'allowed_image_suffixes');
511 $tpl->setVariable(
'TXT_ALLOWED_SUFFIXES', $this->
lng->txt(
'file_allowed_suffixes') .
' ' . $suff_str);
512 $tpl->parseCurrentBlock();
514 $tpl->setCurrentBlock(
'image_heading');
515 $tpl->setVariable(
'ANSWER_IMAGE', $this->
lng->txt(
'answer_image'));
517 $tpl->parseCurrentBlock();
522 $tpl->setCurrentBlock(
'points_heading');
523 $tpl->setVariable(
'POINTS_TEXT', $this->
lng->txt(
'points'));
524 $tpl->parseCurrentBlock();
527 $tpl->setVariable(
'ELEMENT_ID', $this->
getPostVar());
528 $tpl->setVariable(
'TEXT_YES', $this->
lng->txt(
'yes'));
529 $tpl->setVariable(
'TEXT_NO', $this->
lng->txt(
'no'));
530 $tpl->setVariable(
'DELETE_IMAGE_HEADER', $this->
lng->txt(
'delete_image_header'));
531 $tpl->setVariable(
'DELETE_IMAGE_QUESTION', $this->
lng->txt(
'delete_image_question'));
532 $tpl->setVariable(
'ANSWER_TEXT', $this->
lng->txt(
'answer_text'));
533 $tpl->setVariable(
'COMMANDS_TEXT', $this->
lng->txt(
'actions'));
541 $tpl->addJavascript(
'assets/js/answerwizardinput.js');
542 $tpl->addJavascript(
'assets/js/singlechoicewizard.js');
Class for answers with a binary state indicator.
setVariable($variable, $value='')
Sets a variable value.
Builds a Color from either hex- or rgb values.
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.
setMaxLength(?int $a_maxlength)
static virusHandling(string $a_file, string $a_orig_name='', bool $a_clean=true)
This is how a factory for glyphs looks like.
An entity that renders components to a string output.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc