58 $this->validationRegexp =
'';
61 $this->post_wrapper = $DIC->http()->wrapper()->post();
62 $this->glyph_factory = $DIC->ui()->factory()->symbol()->glyph();
63 $this->renderer = $DIC->ui()->renderer();
64 $this->upload_limit = $DIC[
'ui.upload_limit_resolver'];
69 $this->values = array();
70 if (is_array($a_value)) {
71 if (is_array($a_value[
'answer'])) {
72 foreach ($a_value[
'answer'] as $index =>
$value) {
73 $points = (float) str_replace(
",",
".", $a_value[
'points'][$index]);
80 (
int) $a_value[
'answer_id'][$index]
82 if (isset($a_value[
'imagename'][$index])) {
83 $answer->setImage($a_value[
'imagename'][$index]);
85 $this->values[] = $answer;
106 $this->suffixes = $a_suffixes;
116 $this->hideImages = $a_hide;
131 $this->showPoints = $a_value;
146 $this->values = $a_values;
166 $this->singleline = $a_value;
186 $this->qstObject = &$a_value;
206 $this->allowMove = $a_allow_move;
246 if (is_array($foundvalues)) {
248 if (is_array($foundvalues[
'answer'])) {
249 foreach ($foundvalues[
'answer'] as $aidx => $answervalue) {
250 if (((strlen($answervalue)) == 0) && (!isset($foundvalues[
'imagename'][$aidx]) || strlen($foundvalues[
'imagename'][$aidx]) == 0)) {
263 if (is_array($foundvalues[
'points'])) {
264 foreach ($foundvalues[
'points'] as $points) {
265 $points = str_replace(
',',
'.', $points);
266 if ($points > $max) {
269 if (((strlen($points)) == 0) || (!is_numeric($points))) {
281 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image'])) {
282 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error) {
286 case UPLOAD_ERR_FORM_SIZE:
287 case UPLOAD_ERR_INI_SIZE:
292 case UPLOAD_ERR_PARTIAL:
297 case UPLOAD_ERR_NO_FILE:
299 if ((!isset($foundvalues[
'imagename'][$index])) && (!strlen($foundvalues[
'answer'][$index]))) {
306 case UPLOAD_ERR_NO_TMP_DIR:
311 case UPLOAD_ERR_CANT_WRITE:
316 case UPLOAD_ERR_EXTENSION:
330 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
331 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
335 $suffix = $filename_arr[
"extension"];
336 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
337 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
339 if (strlen($tmpname) && is_array($this->
getSuffixes())) {
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 (strlen($tmpname)) {
360 if ($vir[0] ==
false) {
361 $this->
setAlert(
$lng->
txt(
"form_msg_file_virus_found") .
"<br />" . $vir[1]);
385 $tpl =
new ilTemplate(
"tpl.prop_singlechoicewizardinput.html",
true,
true,
"Modules/TestQuestionPool");
387 foreach ($this->values as
$value) {
389 if (!$this->hideImages) {
390 if ($value->getImage()) {
391 $imagename = $this->qstObject->getImagePathWeb() . $value->getImage();
392 if (($this->
getSingleline()) && ($this->qstObject->getThumbSize())) {
393 if (file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value->getImage())) {
394 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value->getImage();
397 $tpl->setCurrentBlock(
'image');
398 $tpl->setVariable(
'SRC_IMAGE', $imagename);
399 $tpl->setVariable(
'IMAGE_NAME', $value->getImage());
404 $tpl->setVariable(
"TXT_DELETE_EXISTING",
$lng->
txt(
"delete_existing_file"));
405 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
406 $tpl->setVariable(
"IMAGE_POST_VAR", $this->
getPostVar());
407 $tpl->parseCurrentBlock();
409 $tpl->setCurrentBlock(
'addimage');
410 $tpl->setVariable(
"IMAGE_BROWSE",
$lng->
txt(
'select_file'));
411 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][$i]");
412 $tpl->setVariable(
'MAX_SIZE_WARNING', $this->
lng->txt(
'form_msg_file_size_exceeds'));
413 $tpl->setVariable(
'MAX_SIZE', $this->upload_limit->getPhpUploadLimitInBytes());
414 $tpl->setVariable(
"IMAGE_SUBMIT",
$lng->
txt(
"upload"));
415 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
416 $tpl->setVariable(
"IMAGE_POST_VAR", $this->
getPostVar());
417 $tpl->parseCurrentBlock();
420 if (is_object($value)) {
421 $tpl->setCurrentBlock(
"prop_text_propval");
426 $tpl->parseCurrentBlock();
428 $tpl->setCurrentBlock(
"prop_points_propval");
433 $tpl->parseCurrentBlock();
435 $tpl->setCurrentBlock(
"prop_answer_id_propval");
437 $tpl->parseCurrentBlock();
439 $tpl->setCurrentBlock(
'singleline');
440 $tpl->setVariable(
"SIZE", $this->
getSize());
441 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][$i]");
442 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $i);
443 $tpl->setVariable(
"SINGLELINE_POST_VAR", $this->
getPostVar());
446 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
448 $tpl->parseCurrentBlock();
450 if (is_object($value)) {
452 $tpl->setCurrentBlock(
"prop_points_propval");
457 $tpl->parseCurrentBlock();
459 $tpl->setCurrentBlock(
"prop_answer_id_propval");
461 $tpl->parseCurrentBlock();
463 $tpl->setCurrentBlock(
'multiline');
468 $tpl->setVariable(
"MULTILINE_ID", $this->
getPostVar() .
"[answer][$i]");
469 $tpl->setVariable(
"MULTILINE_ROW_NUMBER", $i);
470 $tpl->setVariable(
"MULTILINE_POST_VAR", $this->
getPostVar());
473 $tpl->setVariable(
"DISABLED_MULTILINE",
" disabled=\"disabled\"");
475 $tpl->parseCurrentBlock();
478 $tpl->setCurrentBlock(
"move");
479 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[$i]");
480 $tpl->setVariable(
"UP_BUTTON", $this->renderer->render(
481 $this->glyph_factory->up()->withAction(
'#')
483 $tpl->setVariable(
"DOWN_BUTTON", $this->renderer->render(
484 $this->glyph_factory->down()->withAction(
'#')
486 $tpl->parseCurrentBlock();
489 $tpl->setCurrentBlock(
"points");
490 $tpl->setVariable(
"POINTS_ID", $this->
getPostVar() .
"[points][$i]");
491 $tpl->setVariable(
"POINTS_POST_VAR", $this->
getPostVar());
492 $tpl->setVariable(
"POINTS_ROW_NUMBER", $i);
493 $tpl->parseCurrentBlock();
495 $tpl->setCurrentBlock(
"row");
496 $tpl->setVariable(
"POST_VAR", $this->
getPostVar());
497 $tpl->setVariable(
"ROW_NUMBER", $i);
498 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[answer][$i]");
500 $tpl->setVariable(
"DISABLED_POINTS",
" disabled=\"disabled\"");
502 $tpl->setVariable(
"ADD_BUTTON", $this->renderer->render(
503 $this->glyph_factory->add()->withAction(
'#')
505 $tpl->setVariable(
"REMOVE_BUTTON", $this->renderer->render(
506 $this->glyph_factory->remove()->withAction(
'#')
508 $tpl->parseCurrentBlock();
513 if (!$this->hideImages) {
515 $suff_str = $delim =
"";
517 $suff_str .= $delim .
"." .
$suffix;
520 $tpl->setCurrentBlock(
'allowed_image_suffixes');
521 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
$lng->
txt(
"file_allowed_suffixes") .
" " . $suff_str);
522 $tpl->parseCurrentBlock();
524 $tpl->setCurrentBlock(
"image_heading");
525 $tpl->setVariable(
"ANSWER_IMAGE",
$lng->
txt(
'answer_image'));
527 $tpl->parseCurrentBlock();
532 $tpl->setCurrentBlock(
"points_heading");
533 $tpl->setVariable(
"POINTS_TEXT",
$lng->
txt(
'points'));
534 $tpl->parseCurrentBlock();
537 $tpl->setVariable(
"ELEMENT_ID", $this->
getPostVar());
538 $tpl->setVariable(
"TEXT_YES",
$lng->
txt(
'yes'));
539 $tpl->setVariable(
"TEXT_NO",
$lng->
txt(
'no'));
540 $tpl->setVariable(
"DELETE_IMAGE_HEADER",
$lng->
txt(
'delete_image_header'));
541 $tpl->setVariable(
"DELETE_IMAGE_QUESTION",
$lng->
txt(
'delete_image_question'));
542 $tpl->setVariable(
"ANSWER_TEXT",
$lng->
txt(
'answer_text'));
543 $tpl->setVariable(
"COMMANDS_TEXT",
$lng->
txt(
'actions'));
551 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/answerwizardinput.js");
552 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/singlechoicewizard.js");
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
An entity that renders components to a string output.
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
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...
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.
setVariable($variable, $value='')
Sets a variable value.
static _getUsedHTMLTagsAsString(string $a_module="")
Returns a string of all allowed HTML tags for text editing.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setMaxLength(?int $a_maxlength)