56         $this->ignoreMissingUploadsEnabled = 
false;
    83         $answer_type = $this->
str(
'answer_type');
    85         $answers = $this->forms_helper->transformArray($a_value, 
'answer', $this->
refinery->kindlyTo()->string());
    86         $imagename = $this->forms_helper->transformArray($a_value, 
'imagename', $this->
refinery->kindlyTo()->string());
    87         $correctness = $this->forms_helper->transformArray($a_value, 
'correctness', $this->
refinery->kindlyTo()->bool());
    89         foreach ($answers as $index => 
$value) {
    92             $answer->setPosition($index);
    93             $answer->setAnswertext(
$value);
    94             $answer->setThumbPrefix($this->qstObject->getThumbPrefix());
    95             $answer->setImageFsDir($this->qstObject->getImagePath());
    96             $answer->setImageWebDir($this->qstObject->getImagePathWeb());
    98             if ($this->forms_helper->inArray($imagename, $index)) {
    99                 $answer->setImageFile($imagename[$index]);
   102             if (isset($correctness[$index])) {
   103                 $answer->setCorrectness($correctness[$index]);
   106             $this->values[] = $answer;
   116         if (!is_array(
$data)) {
   117             $this->
setAlert($this->
lng->txt(
'msg_input_is_required'));
   123         if (!is_array($answers)) {
   129         $correctness = $this->forms_helper->transformArray(
$data, 
'correctness', $this->
refinery->kindlyTo()->bool());
   130         if (count($answers) !== count($correctness)) {
   131             $this->
setAlert($this->
lng->txt(
'msg_input_is_required'));
   147         $tpl = 
new ilTemplate(
"tpl.prop_kprimchoicewizardinput.html", 
true, 
true, 
"components/ILIAS/TestQuestionPool");
   149         foreach ($this->values as 
$value) {
   151                 if (!$this->hideImages) {
   152                     if ($value->getImageFile() !== null
   153                         && $value->getImageFile() !== 
'') {
   154                         $imagename = $value->getImageWebPath();
   156                         if (($this->
getSingleline()) && ($this->qstObject->getThumbSize())) {
   157                             if (@file_exists($value->getThumbFsPath())) {
   158                                 $imagename = $value->getThumbWebPath();
   162                         $tpl->setCurrentBlock(
'image');
   163                         $tpl->setVariable(
'SRC_IMAGE', $imagename);
   164                         $tpl->setVariable(
'IMAGE_NAME', $value->getImageFile());
   169                         $tpl->setVariable(
"TXT_DELETE_EXISTING", $this->
lng->txt(
"delete_existing_file"));
   170                         $tpl->setVariable(
"IMAGE_ROW_NUMBER", $value->getPosition());
   172                         $tpl->parseCurrentBlock();
   174                     $tpl->setCurrentBlock(
'addimage');
   175                     $tpl->setVariable(
"IMAGE_BROWSE", $this->
lng->txt(
'select_file'));
   176                     $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() . 
"[image][{$value->getPosition()}]");
   177                     $tpl->setVariable(
'MAX_SIZE_WARNING', $this->
lng->txt(
'form_msg_file_size_exceeds'));
   178                     $tpl->setVariable(
'MAX_SIZE', $this->upload_limit->getPhpUploadLimitInBytes());
   179                     $tpl->setVariable(
"IMAGE_SUBMIT", $this->
lng->txt(
"upload"));
   180                     $tpl->setVariable(
"IMAGE_ROW_NUMBER", $value->getPosition());
   182                     $tpl->parseCurrentBlock();
   185                 $tpl->setCurrentBlock(
"prop_text_propval");
   190                 $tpl->parseCurrentBlock();
   192                 $tpl->setCurrentBlock(
'singleline');
   194                 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() . 
"[answer][{$value->getPosition()}]");
   195                 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $value->getPosition());
   199                     $tpl->setVariable(
"DISABLED_SINGLELINE", 
" disabled=\"disabled\"");
   201                 $tpl->parseCurrentBlock();
   203                 $tpl->setCurrentBlock(
'multiline');
   208                 $tpl->setVariable(
"MULTILINE_ID", $this->
getPostVar() . 
"[answer][{$value->getPosition()}]");
   209                 $tpl->setVariable(
"MULTILINE_ROW_NUMBER", $value->getPosition());
   213                     $tpl->setVariable(
"DISABLED_MULTILINE", 
" disabled=\"disabled\"");
   215                 $tpl->parseCurrentBlock();
   218                 $tpl->setCurrentBlock(
"move");
   219                 $tpl->setVariable(
"UP_ID", 
"up_{$this->getPostVar()}[{$value->getPosition()}]");
   220                 $tpl->setVariable(
"DOWN_ID", 
"down_{$this->getPostVar()}[{$value->getPosition()}]");
   221                 $tpl->setVariable(
"UP_BUTTON", $this->renderer->render(
   222                     $this->glyph_factory->up()->withAction(
'#')
   224                 $tpl->setVariable(
"DOWN_BUTTON", $this->renderer->render(
   225                     $this->glyph_factory->down()->withAction(
'#')
   227                 $tpl->parseCurrentBlock();
   230             $tpl->setCurrentBlock(
"row");
   233             $tpl->setVariable(
"ROW_NUMBER", $value->getPosition());
   234             $tpl->setVariable(
"ID", $this->
getPostVar() . 
"[answer][{$value->getPosition()}]");
   237                 "CORRECTNESS_TRUE_ID",
   238                 $this->
getPostVar() . 
"[correctness][{$value->getPosition()}][true]"   241                 "CORRECTNESS_FALSE_ID",
   242                 $this->
getPostVar() . 
"[correctness][{$value->getPosition()}][false]"   244             $tpl->setVariable(
"CORRECTNESS_TRUE_VALUE", 1);
   245             $tpl->setVariable(
"CORRECTNESS_FALSE_VALUE", 0);
   247             if ($value->getCorrectness() !== null) {
   248                 if ($value->getCorrectness()) {
   249                     $tpl->setVariable(
'CORRECTNESS_TRUE_SELECTED', 
' checked="checked"');
   251                     $tpl->setVariable(
'CORRECTNESS_FALSE_SELECTED', 
' checked="checked"');
   256                 $tpl->setVariable(
"DISABLED_CORRECTNESS", 
" disabled=\"disabled\"");
   259             $tpl->parseCurrentBlock();
   263             if (!$this->hideImages) {
   265                     $suff_str = $delim = 
"";
   267                         $suff_str .= $delim . 
"." . 
$suffix;
   270                     $tpl->setCurrentBlock(
'allowed_image_suffixes');
   271                     $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES", $this->
lng->txt(
"file_allowed_suffixes") . 
" " . $suff_str);
   272                     $tpl->parseCurrentBlock();
   275                 $tpl->setCurrentBlock(
"image_heading");
   276                 $tpl->setVariable(
"ANSWER_IMAGE", $this->
lng->txt(
'answer_image'));
   278                 $tpl->parseCurrentBlock();
   282         foreach ($this->qstObject->getValidOptionLabels() as $optionLabel) {
   283             if ($this->qstObject->isCustomOptionLabel($optionLabel)) {
   287             $tpl->setCurrentBlock(
'option_label_translations');
   288             $tpl->setVariable(
'OPTION_LABEL', $optionLabel);
   289             $tpl->setVariable(
'TRANSLATION_TRUE', $this->qstObject->getTrueOptionLabelTranslation($this->lng, $optionLabel));
   290             $tpl->setVariable(
'TRANSLATION_FALSE', $this->qstObject->getFalseOptionLabelTranslation($this->lng, $optionLabel));
   291             $tpl->parseCurrentBlock();
   295         $tpl->setVariable(
"DELETE_IMAGE_HEADER", $this->
lng->txt(
'delete_image_header'));
   296         $tpl->setVariable(
"DELETE_IMAGE_QUESTION", $this->
lng->txt(
'delete_image_question'));
   297         $tpl->setVariable(
"ANSWER_TEXT", $this->
lng->txt(
'answer_text'));
   299         $tpl->setVariable(
"OPTIONS_TEXT", $this->
lng->txt(
'options'));
   305         $this->tpl->addJavascript(
"assets/js/answerwizardinput.js");
   306         $this->tpl->addJavascript(
"assets/js/kprimchoicewizard.js");
   307         $this->tpl->addJavascript(
'assets/js/ilAssKprimChoice.js');
   312         if (is_array($_FILES) && count($_FILES) && $this->
getSingleline()) {
   313             if (!$this->hideImages) {
   314                 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image'])) {
   315                     foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error) {
   319                                 case UPLOAD_ERR_FORM_SIZE:
   320                                 case UPLOAD_ERR_INI_SIZE:
   321                                     $this->
setAlert($this->
lng->txt(
"form_msg_file_size_exceeds"));
   325                                 case UPLOAD_ERR_PARTIAL:
   326                                     $this->
setAlert($this->
lng->txt(
"form_msg_file_partially_uploaded"));
   330                                 case UPLOAD_ERR_NO_FILE:
   332                                         $has_image = isset($foundvalues[
'imagename'][$index]) ? true : 
false;
   333                                         if (!$has_image && (!strlen($foundvalues[
'answer'][$index]))) {
   334                                             $this->
setAlert($this->
lng->txt(
"form_msg_file_no_upload"));
   340                                 case UPLOAD_ERR_NO_TMP_DIR:
   341                                     $this->
setAlert($this->
lng->txt(
"form_msg_file_missing_tmp_dir"));
   345                                 case UPLOAD_ERR_CANT_WRITE:
   346                                     $this->
setAlert($this->
lng->txt(
"form_msg_file_cannot_write_to_disk"));
   350                                 case UPLOAD_ERR_EXTENSION:
   351                                     $this->
setAlert($this->
lng->txt(
"form_msg_file_upload_stopped_ext"));
   359                         $this->
setAlert($this->
lng->txt(
"form_msg_file_no_upload"));
   364                 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
   365                     foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
   368                         if (isset($filename_arr[
"extension"])) {
   369                             $suffix = $filename_arr[
"extension"];
   370                             $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
   371                             $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
   373                             if (strlen($tmpname) && is_array($this->
getSuffixes())) {
   375                                     $this->
setAlert($this->
lng->txt(
"form_msg_file_wrong_file_type"));
   383                 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
   384                     foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
   385                         if ($_FILES[$this->
getPostVar()][
'error'][
'image'][$index] > 0) {
   391                         if (!preg_match(
"/^image/", $mimetype)) {
   392                             $_FILES[$this->
getPostVar()][
'error'][
'image'][$index] = self::CUSTOM_UPLOAD_ERR;
   393                             $this->
setAlert($this->
lng->txt(
"form_msg_file_wrong_mime_type"));
   400                 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
   401                     foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
   404                         if (isset($filename_arr[
"extension"])) {
   405                             $suffix = $filename_arr[
"extension"];
   406                             $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
   407                             $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
   409                             if (strlen($tmpname)) {
   411                                 if ($vir[0] == 
false) {
   412                                     $_FILES[$this->
getPostVar()][
'error'][
'image'][$index] = self::CUSTOM_UPLOAD_ERR;
   413                                     $this->
setAlert($this->
lng->txt(
"form_msg_file_virus_found") . 
"<br />" . $vir[1]);
   428         foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $err) {
   433             $this->files[$index] = [
   434                 'position' => $index,
   435                 'tmp_name' => $_FILES[$this->
getPostVar()][
'tmp_name'][
'image'][$index],
   436                 'name' => $_FILES[$this->
getPostVar()][
'name'][
'image'][$index],
   437                 'type' => $_FILES[$this->
getPostVar()][
'type'][
'image'][$index],
   438                 'size' => $_FILES[$this->
getPostVar()][
'size'][
'image'][$index]
   449         if (!is_array($answer_text)) {
 parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
 
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
 
static virusHandling(string $a_file, string $a_orig_name='', bool $a_clean=true)
 
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)
 
const ALLOWED_PLAIN_TEXT_TAGS
sk - 12.05.2023: This const is also used in ilKprimChoiceWizardInputGUI. 
 
__construct(Container $dic, ilPlugin $plugin)