58 $this->validationRegexp =
'';
61 $this->glyph_factory = $DIC->ui()->factory()->symbol()->glyph();
62 $this->
renderer = $DIC->ui()->renderer();
63 $this->upload_limit = $DIC[
'ui.upload_limit_resolver'];
71 $answers = $this->forms_helper->transformArray($a_value,
'answer', $this->
refinery->kindlyTo()->string());
72 $points = $this->forms_helper->transformPoints($a_value);
74 foreach ($answers as $index =>
$value) {
77 $points[$index] ?? 0.0,
81 (
int) $a_value[
'answer_id'][$index] ?? 0
83 if (isset($a_value[
'imagename'][$index])) {
84 $answer->setImage($a_value[
'imagename'][$index]);
86 $this->values[] = $answer;
104 $this->suffixes = $a_suffixes;
114 $this->hideImages = $a_hide;
129 $this->showPoints = $a_value;
144 $this->values = $a_values;
164 $this->singleline = $a_value;
184 $this->qstObject = &$a_value;
204 $this->allowMove = $a_allow_move;
235 $to_string = $this->
refinery->kindlyTo()->string();
236 $answers = $this->forms_helper->transformArray($data,
'answer', $to_string);
237 $image_names = $this->forms_helper->transformArray($data,
'imagename', $to_string);
238 foreach ($answers as $index =>
$value) {
239 if (
$value ===
'' && !$this->forms_helper->inArray($image_names, $index)) {
240 return 'msg_input_is_required';
244 return 'msg_input_char_limit_max';
255 if (!is_array(
$data)) {
256 $this->
setAlert($this->
lng->txt(
'msg_input_is_required'));
261 $points = $this->forms_helper->checkPointsInputEnoughPositive(
$data,
true);
262 if (!is_array($points)) {
269 if (!is_array($answers)) {
273 $image_names = $this->forms_helper->transformArray(
$data,
'imagename', $this->
refinery->kindlyTo()->string());
276 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image'])) {
277 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error) {
281 case UPLOAD_ERR_FORM_SIZE:
282 case UPLOAD_ERR_INI_SIZE:
283 $this->
setAlert($this->
lng->txt(
'form_msg_file_size_exceeds'));
287 case UPLOAD_ERR_PARTIAL:
288 $this->
setAlert($this->
lng->txt(
'form_msg_file_partially_uploaded'));
292 case UPLOAD_ERR_NO_FILE:
294 !$this->forms_helper->inArray($image_names, $index)
295 && !$this->forms_helper->inArray($answers, $index)
298 $this->
setAlert($this->
lng->txt(
'form_msg_file_no_upload'));
303 case UPLOAD_ERR_NO_TMP_DIR:
304 $this->
setAlert($this->
lng->txt(
'form_msg_file_missing_tmp_dir'));
308 case UPLOAD_ERR_CANT_WRITE:
309 $this->
setAlert($this->
lng->txt(
'form_msg_file_cannot_write_to_disk'));
313 case UPLOAD_ERR_EXTENSION:
314 $this->
setAlert($this->
lng->txt(
'form_msg_file_upload_stopped_ext'));
321 $this->
setAlert($this->
lng->txt(
'form_msg_file_no_upload'));
325 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
326 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
330 $suffix = $filename_arr[
'extension'];
331 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
332 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
339 $this->
setAlert($this->
lng->txt(
'form_msg_file_wrong_file_type'));
346 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
347 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
351 $suffix = $filename_arr[
'extension'];
352 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
353 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
355 if ($tmpname !==
'') {
357 if ($vir[0] ==
false) {
358 $this->
setAlert($this->
lng->txt(
'form_msg_file_virus_found') .
'<br />' . $vir[1]);
372 $tpl =
new ilTemplate(
'tpl.prop_singlechoicewizardinput.html',
true,
true,
'components/ILIAS/TestQuestionPool');
374 foreach ($this->values as
$value) {
376 if (!$this->hideImages) {
377 if ($value->getImage()) {
378 $imagename = $this->qstObject->getImagePathWeb() . $value->getImage();
379 if (($this->
getSingleline()) && ($this->qstObject->getThumbSize())) {
380 if (file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value->getImage())) {
381 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value->getImage();
384 $tpl->setCurrentBlock(
'image');
385 $tpl->setVariable(
'SRC_IMAGE', $imagename);
386 $tpl->setVariable(
'IMAGE_NAME', $value->getImage());
391 $tpl->setVariable(
'TXT_DELETE_EXISTING', $this->
lng->txt(
'delete_existing_file'));
392 $tpl->setVariable(
'IMAGE_ROW_NUMBER', $i);
393 $tpl->setVariable(
'IMAGE_POST_VAR', $this->
getPostVar());
394 $tpl->parseCurrentBlock();
396 $tpl->setCurrentBlock(
'addimage');
397 $tpl->setVariable(
'IMAGE_BROWSE', $this->
lng->txt(
'select_file'));
398 $tpl->setVariable(
'IMAGE_ID', $this->
getPostVar() .
"[image][$i]");
399 $tpl->setVariable(
'MAX_SIZE_WARNING', $this->
lng->txt(
'form_msg_file_size_exceeds'));
400 $tpl->setVariable(
'MAX_SIZE', $this->upload_limit->getPhpUploadLimitInBytes());
401 $tpl->setVariable(
'IMAGE_SUBMIT', $this->
lng->txt(
'upload'));
402 $tpl->setVariable(
'IMAGE_ROW_NUMBER', $i);
403 $tpl->setVariable(
'IMAGE_POST_VAR', $this->
getPostVar());
404 $tpl->parseCurrentBlock();
407 if (is_object($value)) {
408 $tpl->setCurrentBlock(
'prop_text_propval');
413 $tpl->parseCurrentBlock();
415 $tpl->setCurrentBlock(
'prop_points_propval');
420 $tpl->parseCurrentBlock();
422 $tpl->setCurrentBlock(
'prop_answer_id_propval');
424 $tpl->parseCurrentBlock();
426 $tpl->setCurrentBlock(
'singleline');
427 $tpl->setVariable(
'SIZE', $this->
getSize());
428 $tpl->setVariable(
'SINGLELINE_ID', $this->
getPostVar() .
"[answer][$i]");
429 $tpl->setVariable(
'SINGLELINE_ROW_NUMBER', $i);
430 $tpl->setVariable(
'SINGLELINE_POST_VAR', $this->
getPostVar());
433 $tpl->setVariable(
'DISABLED_SINGLELINE',
' disabled="disabled"');
435 $tpl->parseCurrentBlock();
437 if (is_object($value)) {
439 $tpl->setCurrentBlock(
'prop_points_propval');
444 $tpl->parseCurrentBlock();
446 $tpl->setCurrentBlock(
'prop_answer_id_propval');
448 $tpl->parseCurrentBlock();
450 $tpl->setCurrentBlock(
'multiline');
455 $tpl->setVariable(
'MULTILINE_ID', $this->
getPostVar() .
"[answer][$i]");
456 $tpl->setVariable(
'MULTILINE_ROW_NUMBER', $i);
457 $tpl->setVariable(
'MULTILINE_POST_VAR', $this->
getPostVar());
460 $tpl->setVariable(
'DISABLED_MULTILINE',
' disabled="disabled"');
462 $tpl->parseCurrentBlock();
465 $tpl->setCurrentBlock(
'move');
466 $tpl->setVariable(
'ID', $this->
getPostVar() .
"[$i]");
467 $tpl->setVariable(
'UP_BUTTON', $this->
renderer->render(
468 $this->glyph_factory->up()->withAction(
'#')
470 $tpl->setVariable(
'DOWN_BUTTON', $this->
renderer->render(
471 $this->glyph_factory->down()->withAction(
'#')
473 $tpl->parseCurrentBlock();
476 $tpl->setCurrentBlock(
'points');
477 $tpl->setVariable(
'POINTS_ID', $this->
getPostVar() .
"[points][$i]");
478 $tpl->setVariable(
'POINTS_POST_VAR', $this->
getPostVar());
479 $tpl->setVariable(
'POINTS_ROW_NUMBER', $i);
480 $tpl->parseCurrentBlock();
482 $tpl->setCurrentBlock(
'row');
483 $tpl->setVariable(
'POST_VAR', $this->
getPostVar());
484 $tpl->setVariable(
'ROW_NUMBER', $i);
485 $tpl->setVariable(
'ID', $this->
getPostVar() .
"[answer][$i]");
487 $tpl->setVariable(
'DISABLED_POINTS',
' disabled="disabled"');
489 $tpl->setVariable(
'ADD_BUTTON', $this->
renderer->render(
490 $this->glyph_factory->add()->withAction(
'#')
492 $tpl->setVariable(
'REMOVE_BUTTON', $this->
renderer->render(
493 $this->glyph_factory->remove()->withAction(
'#')
495 $tpl->parseCurrentBlock();
500 if (!$this->hideImages) {
502 $suff_str = $delim =
'';
504 $suff_str .= $delim .
'.' .
$suffix;
507 $tpl->setCurrentBlock(
'allowed_image_suffixes');
508 $tpl->setVariable(
'TXT_ALLOWED_SUFFIXES', $this->
lng->txt(
'file_allowed_suffixes') .
' ' . $suff_str);
509 $tpl->parseCurrentBlock();
511 $tpl->setCurrentBlock(
'image_heading');
512 $tpl->setVariable(
'ANSWER_IMAGE', $this->
lng->txt(
'answer_image'));
514 $tpl->parseCurrentBlock();
519 $tpl->setCurrentBlock(
'points_heading');
520 $tpl->setVariable(
'POINTS_TEXT', $this->
lng->txt(
'points'));
521 $tpl->parseCurrentBlock();
524 $tpl->setVariable(
'ELEMENT_ID', $this->
getPostVar());
525 $tpl->setVariable(
'TEXT_YES', $this->
lng->txt(
'yes'));
526 $tpl->setVariable(
'TEXT_NO', $this->
lng->txt(
'no'));
527 $tpl->setVariable(
'DELETE_IMAGE_HEADER', $this->
lng->txt(
'delete_image_header'));
528 $tpl->setVariable(
'DELETE_IMAGE_QUESTION', $this->
lng->txt(
'delete_image_question'));
529 $tpl->setVariable(
'ANSWER_TEXT', $this->
lng->txt(
'answer_text'));
530 $tpl->setVariable(
'COMMANDS_TEXT', $this->
lng->txt(
'actions'));
538 $tpl->addJavascript(
'assets/js/answerwizardinput.js');
539 $tpl->addJavascript(
'assets/js/singlechoicewizard.js');
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
Class for answers with a binary state indicator.
static virusHandling(string $a_file, string $a_orig_name='', bool $a_clean=true)
This is how a factory for glyphs looks like.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setVariable($variable, $value='')
Sets a variable value.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setMaxLength(?int $a_maxlength)
__construct(Container $dic, ilPlugin $plugin)