56 $this->ignoreMissingUploadsEnabled =
false;
83 $is_rte = isset($_POST[
"answer_type"]) && $_POST[
"answer_type"] ==
"multiLine";
86 if (is_array($a_value) && is_array($a_value[
'answer'])) {
87 foreach ($a_value[
'answer'] as $index =>
$value) {
90 $answer->setPosition($index);
91 $answer->setAnswertext(
$value);
92 if (isset($a_value[
'imagename'])) {
93 $answer->setImageFile($a_value[
'imagename'][$index] ??
'');
96 if (isset($a_value[
'correctness']) && isset($a_value[
'correctness'][$index]) && strlen($a_value[
'correctness'][$index])) {
97 $answer->setCorrectness((
bool) $a_value[
'correctness'][$index]);
100 $answer->setThumbPrefix($this->qstObject->getThumbPrefix());
101 $answer->setImageFsDir($this->qstObject->getImagePath());
102 $answer->setImageWebDir($this->qstObject->getImagePathWeb());
104 $this->values[] = $answer;
126 if (is_array($foundvalues)) {
128 if (is_array($foundvalues[
'answer'])) {
129 foreach ($foundvalues[
'answer'] as $aidx => $answervalue) {
130 $hasImage = isset($foundvalues[
'imagename']) ? true :
false;
131 if (((strlen($answervalue)) == 0) && !$hasImage) {
144 if (!isset($foundvalues[
'correctness']) || count($foundvalues[
'correctness']) < count($foundvalues[
'answer'])) {
165 $tpl =
new ilTemplate(
"tpl.prop_kprimchoicewizardinput.html",
true,
true,
"Modules/TestQuestionPool");
167 foreach ($this->values as
$value) {
173 if (!$this->hideImages) {
174 if ($value->getImageFile() !== null
175 && $value->getImageFile() !==
'') {
176 $imagename = $value->getImageWebPath();
178 if (($this->
getSingleline()) && ($this->qstObject->getThumbSize())) {
179 if (@file_exists($value->getThumbFsPath())) {
180 $imagename = $value->getThumbWebPath();
184 $tpl->setCurrentBlock(
'image');
185 $tpl->setVariable(
'SRC_IMAGE', $imagename);
186 $tpl->setVariable(
'IMAGE_NAME', $value->getImageFile());
191 $tpl->setVariable(
"TXT_DELETE_EXISTING", $this->
lng->txt(
"delete_existing_file"));
192 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $value->getPosition());
194 $tpl->parseCurrentBlock();
196 $tpl->setCurrentBlock(
'addimage');
197 $tpl->setVariable(
"IMAGE_BROWSE", $this->
lng->txt(
'select_file'));
198 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][{$value->getPosition()}]");
199 $tpl->setVariable(
'MAX_SIZE_WARNING', $this->
lng->txt(
'form_msg_file_size_exceeds'));
200 $tpl->setVariable(
'MAX_SIZE', $this->upload_limit->getPhpUploadLimitInBytes());
201 $tpl->setVariable(
"IMAGE_SUBMIT", $this->
lng->txt(
"upload"));
202 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $value->getPosition());
204 $tpl->parseCurrentBlock();
207 $tpl->setCurrentBlock(
"prop_text_propval");
212 $tpl->parseCurrentBlock();
214 $tpl->setCurrentBlock(
'singleline');
216 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][{$value->getPosition()}]");
217 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $value->getPosition());
221 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
223 $tpl->parseCurrentBlock();
225 $tpl->setCurrentBlock(
'multiline');
230 $tpl->setVariable(
"MULTILINE_ID", $this->
getPostVar() .
"[answer][{$value->getPosition()}]");
231 $tpl->setVariable(
"MULTILINE_ROW_NUMBER", $value->getPosition());
235 $tpl->setVariable(
"DISABLED_MULTILINE",
" disabled=\"disabled\"");
237 $tpl->parseCurrentBlock();
240 $tpl->setCurrentBlock(
"move");
241 $tpl->setVariable(
"UP_ID",
"up_{$this->getPostVar()}[{$value->getPosition()}]");
242 $tpl->setVariable(
"DOWN_ID",
"down_{$this->getPostVar()}[{$value->getPosition()}]");
243 $tpl->setVariable(
"UP_BUTTON", $this->renderer->render(
244 $this->glyph_factory->up()->withAction(
'#')
246 $tpl->setVariable(
"DOWN_BUTTON", $this->renderer->render(
247 $this->glyph_factory->down()->withAction(
'#')
249 $tpl->parseCurrentBlock();
252 $tpl->setCurrentBlock(
"row");
255 $tpl->setVariable(
"ROW_NUMBER", $value->getPosition());
256 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[answer][{$value->getPosition()}]");
259 "CORRECTNESS_TRUE_ID",
260 $this->
getPostVar() .
"[correctness][{$value->getPosition()}][true]" 263 "CORRECTNESS_FALSE_ID",
264 $this->
getPostVar() .
"[correctness][{$value->getPosition()}][false]" 266 $tpl->setVariable(
"CORRECTNESS_TRUE_VALUE", 1);
267 $tpl->setVariable(
"CORRECTNESS_FALSE_VALUE", 0);
269 if ($value->getCorrectness() !== null) {
270 if ($value->getCorrectness()) {
271 $tpl->setVariable(
'CORRECTNESS_TRUE_SELECTED',
' checked="checked"');
273 $tpl->setVariable(
'CORRECTNESS_FALSE_SELECTED',
' checked="checked"');
278 $tpl->setVariable(
"DISABLED_CORRECTNESS",
" disabled=\"disabled\"");
281 $tpl->parseCurrentBlock();
285 if (!$this->hideImages) {
287 $suff_str = $delim =
"";
289 $suff_str .= $delim .
"." .
$suffix;
292 $tpl->setCurrentBlock(
'allowed_image_suffixes');
293 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES", $this->
lng->txt(
"file_allowed_suffixes") .
" " . $suff_str);
294 $tpl->parseCurrentBlock();
297 $tpl->setCurrentBlock(
"image_heading");
298 $tpl->setVariable(
"ANSWER_IMAGE", $this->
lng->txt(
'answer_image'));
300 $tpl->parseCurrentBlock();
304 foreach ($this->qstObject->getValidOptionLabels() as $optionLabel) {
305 if ($this->qstObject->isCustomOptionLabel($optionLabel)) {
309 $tpl->setCurrentBlock(
'option_label_translations');
310 $tpl->setVariable(
'OPTION_LABEL', $optionLabel);
311 $tpl->setVariable(
'TRANSLATION_TRUE', $this->qstObject->getTrueOptionLabelTranslation($this->lng, $optionLabel));
312 $tpl->setVariable(
'TRANSLATION_FALSE', $this->qstObject->getFalseOptionLabelTranslation($this->lng, $optionLabel));
313 $tpl->parseCurrentBlock();
317 $tpl->setVariable(
"DELETE_IMAGE_HEADER", $this->
lng->txt(
'delete_image_header'));
318 $tpl->setVariable(
"DELETE_IMAGE_QUESTION", $this->
lng->txt(
'delete_image_question'));
319 $tpl->setVariable(
"ANSWER_TEXT", $this->
lng->txt(
'answer_text'));
321 $tpl->setVariable(
"OPTIONS_TEXT", $this->
lng->txt(
'options'));
327 $this->tpl->addJavascript(
"Modules/TestQuestionPool/templates/default/answerwizardinput.js");
328 $this->tpl->addJavascript(
"Modules/TestQuestionPool/templates/default/kprimchoicewizard.js");
329 $this->tpl->addJavascript(
'Modules/TestQuestionPool/js/ilAssKprimChoice.js');
334 if (is_array($_FILES) && count($_FILES) && $this->
getSingleline()) {
335 if (!$this->hideImages) {
336 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image'])) {
337 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error) {
341 case UPLOAD_ERR_FORM_SIZE:
342 case UPLOAD_ERR_INI_SIZE:
343 $this->
setAlert($this->
lng->txt(
"form_msg_file_size_exceeds"));
347 case UPLOAD_ERR_PARTIAL:
348 $this->
setAlert($this->
lng->txt(
"form_msg_file_partially_uploaded"));
352 case UPLOAD_ERR_NO_FILE:
354 $has_image = isset($foundvalues[
'imagename'][$index]) ? true :
false;
355 if (!$has_image && (!strlen($foundvalues[
'answer'][$index]))) {
356 $this->
setAlert($this->
lng->txt(
"form_msg_file_no_upload"));
362 case UPLOAD_ERR_NO_TMP_DIR:
363 $this->
setAlert($this->
lng->txt(
"form_msg_file_missing_tmp_dir"));
367 case UPLOAD_ERR_CANT_WRITE:
368 $this->
setAlert($this->
lng->txt(
"form_msg_file_cannot_write_to_disk"));
372 case UPLOAD_ERR_EXTENSION:
373 $this->
setAlert($this->
lng->txt(
"form_msg_file_upload_stopped_ext"));
381 $this->
setAlert($this->
lng->txt(
"form_msg_file_no_upload"));
386 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
387 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
390 if (isset($filename_arr[
"extension"])) {
391 $suffix = $filename_arr[
"extension"];
392 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
393 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
395 if (strlen($tmpname) && is_array($this->
getSuffixes())) {
397 $this->
setAlert($this->
lng->txt(
"form_msg_file_wrong_file_type"));
405 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
406 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
407 if ($_FILES[$this->
getPostVar()][
'error'][
'image'][$index] > 0) {
413 if (!preg_match(
"/^image/", $mimetype)) {
414 $_FILES[$this->
getPostVar()][
'error'][
'image'][$index] = self::CUSTOM_UPLOAD_ERR;
415 $this->
setAlert($this->
lng->txt(
"form_msg_file_wrong_mime_type"));
422 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
423 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
426 if (isset($filename_arr[
"extension"])) {
427 $suffix = $filename_arr[
"extension"];
428 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
429 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
431 if (strlen($tmpname)) {
433 if ($vir[0] ==
false) {
434 $_FILES[$this->
getPostVar()][
'error'][
'image'][$index] = self::CUSTOM_UPLOAD_ERR;
435 $this->
setAlert($this->
lng->txt(
"form_msg_file_virus_found") .
"<br />" . $vir[1]);
450 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $err) {
455 $this->files[$index] = array(
456 'position' => $index,
457 'tmp_name' => $_FILES[$this->
getPostVar()][
'tmp_name'][
'image'][$index],
458 'name' => $_FILES[$this->
getPostVar()][
'name'][
'image'][$index],
459 'type' => $_FILES[$this->
getPostVar()][
'type'][
'image'][$index],
460 'size' => $_FILES[$this->
getPostVar()][
'size'][
'image'][$index]
471 if (!is_array($answer_text)) {
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
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...
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.