33 if (is_array($a_value) && isset($a_value[
'answer']) && is_array($a_value[
'answer'])) {
34 foreach ($a_value[
'answer'] as $index =>
$value) {
36 $answer->setPointsChecked((
float) ($a_value[
'points'][$index] ?? 0));
37 $answer->setPointsUnchecked((
float) ($a_value[
'points_unchecked'][$index] ?? 0));
38 if (isset($a_value[
'imagename'][$index])) {
39 $answer->setImage($a_value[
'imagename'][$index]);
41 $this->values[] = $answer;
56 if (!$this->post_wrapper->has($post_var)) {
60 $values = $this->post_wrapper->retrieve($post_var, $this->
refinery->custom()->transformation(fn($v) => $v));
70 if (is_array($foundvalues)) {
72 if (is_array($foundvalues[
'answer'])) {
73 foreach ($foundvalues[
'answer'] as $aidx => $answervalue) {
74 if (((strlen($answervalue)) == 0) && (!isset($foundvalues[
'imagename']) || !isset($foundvalues[
'imagename'][$aidx]) || strlen($foundvalues[
'imagename'][$aidx]) == 0)) {
87 if (is_array($foundvalues[
'points'])) {
88 foreach ($foundvalues[
'points'] as $points) {
89 $points = str_replace(
',',
'.', $points);
93 if (((strlen($points)) == 0) || (!is_numeric($points))) {
98 foreach ($foundvalues[
'points_unchecked'] as $points) {
99 $points = str_replace(
',',
'.', $points);
100 if (((strlen($points)) == 0) || (!is_numeric($points))) {
111 if (is_array($_FILES) && count($_FILES) && $this->
getSingleline()) {
112 if (!$this->hideImages) {
113 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image'])) {
114 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error) {
118 case UPLOAD_ERR_FORM_SIZE:
119 case UPLOAD_ERR_INI_SIZE:
124 case UPLOAD_ERR_PARTIAL:
129 case UPLOAD_ERR_NO_FILE:
131 if (isset($a_value[
'imagename']) && (!strlen($foundvalues[
'imagename'][$index])) && (!strlen($foundvalues[
'answer'][$index]))) {
138 case UPLOAD_ERR_NO_TMP_DIR:
143 case UPLOAD_ERR_CANT_WRITE:
148 case UPLOAD_ERR_EXTENSION:
162 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
163 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
166 if (isset($filename_arr[
"extension"])) {
167 $suffix = $filename_arr[
"extension"];
168 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
169 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
171 if (strlen($tmpname) && is_array($this->
getSuffixes())) {
181 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
182 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
185 if (isset($filename_arr[
"extension"])) {
186 $suffix = $filename_arr[
"extension"];
187 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
188 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
190 if (strlen($tmpname)) {
192 if ($vir[0] ==
false) {
193 $this->
setAlert(
$lng->
txt(
"form_msg_file_virus_found") .
"<br />" . $vir[1]);
219 $tpl =
new ilTemplate(
"tpl.prop_multiplechoicewizardinput.html",
true,
true,
"Modules/TestQuestionPool");
221 foreach ($this->values as
$value) {
223 if (!$this->hideImages) {
224 if ($value->hasImage()) {
225 $imagename = $this->qstObject->getImagePathWeb() . $value->getImage();
226 if (($this->
getSingleline()) && ($this->qstObject->getThumbSize())) {
227 if (file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value->getImage())) {
228 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value->getImage();
231 $tpl->setCurrentBlock(
'image');
232 $tpl->setVariable(
'SRC_IMAGE', $imagename);
233 $tpl->setVariable(
'IMAGE_NAME', $value->getImage());
238 $tpl->setVariable(
"TXT_DELETE_EXISTING",
$lng->
txt(
"delete_existing_file"));
239 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
240 $tpl->setVariable(
"IMAGE_POST_VAR", $this->
getPostVar());
241 $tpl->parseCurrentBlock();
243 $tpl->setCurrentBlock(
'addimage');
244 $tpl->setVariable(
"IMAGE_BROWSE",
$lng->
txt(
'select_file'));
245 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][$i]");
246 $tpl->setVariable(
'MAX_SIZE_WARNING', $this->
lng->txt(
'form_msg_file_size_exceeds'));
247 $tpl->setVariable(
'MAX_SIZE', $this->upload_limit->getPhpUploadLimitInBytes());
248 $tpl->setVariable(
"IMAGE_SUBMIT",
$lng->
txt(
"upload"));
249 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
250 $tpl->setVariable(
"IMAGE_POST_VAR", $this->
getPostVar());
251 $tpl->parseCurrentBlock();
254 if (is_object($value)) {
255 $tpl->setCurrentBlock(
"prop_text_propval");
260 $tpl->parseCurrentBlock();
261 $tpl->setCurrentBlock(
"prop_points_propval");
266 $tpl->parseCurrentBlock();
267 $tpl->setCurrentBlock(
"prop_points_unchecked_propval");
272 $tpl->parseCurrentBlock();
273 $tpl->setCurrentBlock(
"prop_answer_id_propval");
275 $tpl->parseCurrentBlock();
277 $tpl->setCurrentBlock(
'singleline');
278 $tpl->setVariable(
"SIZE", $this->
getSize());
279 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][$i]");
280 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $i);
281 $tpl->setVariable(
"SINGLELINE_POST_VAR", $this->
getPostVar());
284 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
286 $tpl->parseCurrentBlock();
288 if (is_object($value)) {
289 $tpl->setCurrentBlock(
"prop_points_propval");
294 $tpl->parseCurrentBlock();
295 $tpl->setCurrentBlock(
"prop_points_unchecked_propval");
300 $tpl->parseCurrentBlock();
301 $tpl->setCurrentBlock(
"prop_answer_id_propval");
303 $tpl->parseCurrentBlock();
305 $tpl->setCurrentBlock(
'multiline');
310 $tpl->setVariable(
"MULTILINE_ID", $this->
getPostVar() .
"[answer][$i]");
311 $tpl->setVariable(
"MULTILINE_ROW_NUMBER", $i);
312 $tpl->setVariable(
"MULTILINE_POST_VAR", $this->
getPostVar());
315 $tpl->setVariable(
"DISABLED_MULTILINE",
" disabled=\"disabled\"");
317 $tpl->parseCurrentBlock();
320 $tpl->setCurrentBlock(
"move");
321 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[$i]");
322 $tpl->setVariable(
"UP_BUTTON", $this->renderer->render(
323 $this->glyph_factory->up()->withAction(
'#')
325 $tpl->setVariable(
"DOWN_BUTTON", $this->renderer->render(
326 $this->glyph_factory->down()->withAction(
'#')
328 $tpl->parseCurrentBlock();
330 $tpl->setCurrentBlock(
"row");
331 $tpl->setVariable(
"POST_VAR", $this->
getPostVar());
332 $tpl->setVariable(
"ROW_NUMBER", $i);
333 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[answer][$i]");
334 $tpl->setVariable(
"POINTS_ID", $this->
getPostVar() .
"[points][$i]");
335 $tpl->setVariable(
"POINTS_UNCHECKED_ID", $this->
getPostVar() .
"[points_unchecked][$i]");
337 $tpl->setVariable(
"DISABLED_POINTS",
" disabled=\"disabled\"");
339 $tpl->setVariable(
"ADD_BUTTON", $this->renderer->render(
340 $this->glyph_factory->add()->withAction(
'#')
342 $tpl->setVariable(
"REMOVE_BUTTON", $this->renderer->render(
343 $this->glyph_factory->remove()->withAction(
'#')
345 $tpl->parseCurrentBlock();
350 if (!$this->hideImages) {
352 $suff_str = $delim =
"";
354 $suff_str .= $delim .
"." .
$suffix;
357 $tpl->setCurrentBlock(
'allowed_image_suffixes');
358 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
$lng->
txt(
"file_allowed_suffixes") .
" " . $suff_str);
359 $tpl->parseCurrentBlock();
362 $tpl->setCurrentBlock(
"image_heading");
363 $tpl->setVariable(
"ANSWER_IMAGE",
$lng->
txt(
'answer_image'));
365 $tpl->parseCurrentBlock();
369 $tpl->setVariable(
"ELEMENT_ID", $this->
getPostVar());
370 $tpl->setVariable(
"TEXT_YES",
$lng->
txt(
'yes'));
371 $tpl->setVariable(
"TEXT_NO",
$lng->
txt(
'no'));
372 $tpl->setVariable(
"DELETE_IMAGE_HEADER",
$lng->
txt(
'delete_image_header'));
373 $tpl->setVariable(
"DELETE_IMAGE_QUESTION",
$lng->
txt(
'delete_image_question'));
374 $tpl->setVariable(
"ANSWER_TEXT",
$lng->
txt(
'answer_text'));
375 $tpl->setVariable(
"POINTS_TEXT",
$lng->
txt(
'points'));
376 $tpl->setVariable(
"COMMANDS_TEXT",
$lng->
txt(
'actions'));
377 $tpl->setVariable(
"POINTS_CHECKED_TEXT",
$lng->
txt(
'checkbox_checked'));
378 $tpl->setVariable(
"POINTS_UNCHECKED_TEXT",
$lng->
txt(
'checkbox_unchecked'));
386 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/answerwizardinput.js");
387 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/multiplechoicewizard.js");
392 $this->pending = $a_val;
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)
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked, set/unset) and an image file.
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)