34 $answers = $this->forms_helper->transformArray($a_value,
'answer', $this->
refinery->kindlyTo()->string());
35 $points = $this->forms_helper->transformPoints($a_value);
36 $points_unchecked = $this->forms_helper->transformPoints($a_value,
'points_unchecked');
37 $images = $this->forms_helper->transformArray($a_value,
'imagename', $this->
refinery->kindlyTo()->string());
39 foreach ($answers as $index =>
$value) {
41 $answer->setPointsChecked($points[$index] ?? 0.0);
42 $answer->setPointsUnchecked($points_unchecked[$index] ?? 0.0);
44 if ($this->forms_helper->inArray($images, $index)) {
45 $answer->setImage($images[$index]);
48 $this->values[] = $answer;
60 if (!is_array(
$data)) {
61 $this->
setAlert($this->
lng->txt(
'msg_input_is_required'));
66 $points = $this->forms_helper->checkPointsInputEnoughPositive(
$data,
true);
67 if (!is_array($points)) {
71 $points_unchecked = $this->forms_helper->checkPointsInput(
$data,
true,
'points_unchecked');
72 if (!is_array($points_unchecked)) {
73 $this->
setAlert($this->
lng->txt($points_unchecked));
79 if (!is_array($answers)) {
83 $image_names = $this->forms_helper->transformArray(
$data,
'imagename', $this->
refinery->kindlyTo()->string());
86 if (is_array($_FILES) && count($_FILES) && $this->
getSingleline()) {
87 if (!$this->hideImages) {
88 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image'])) {
89 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error) {
93 case UPLOAD_ERR_FORM_SIZE:
94 case UPLOAD_ERR_INI_SIZE:
95 $this->
setAlert($this->
lng->txt(
'form_msg_file_size_exceeds'));
99 case UPLOAD_ERR_PARTIAL:
100 $this->
setAlert($this->
lng->txt(
'form_msg_file_partially_uploaded'));
104 case UPLOAD_ERR_NO_FILE:
106 !$this->forms_helper->inArray($image_names, $index)
107 && !$this->forms_helper->inArray($answers, $index)
110 $this->
setAlert($this->
lng->txt(
'form_msg_file_no_upload'));
115 case UPLOAD_ERR_NO_TMP_DIR:
116 $this->
setAlert($this->
lng->txt(
'form_msg_file_missing_tmp_dir'));
120 case UPLOAD_ERR_CANT_WRITE:
121 $this->
setAlert($this->
lng->txt(
'form_msg_file_cannot_write_to_disk'));
125 case UPLOAD_ERR_EXTENSION:
126 $this->
setAlert($this->
lng->txt(
'form_msg_file_upload_stopped_ext'));
134 $this->
setAlert($this->
lng->txt(
'form_msg_file_no_upload'));
139 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
140 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
143 if (isset($filename_arr[
'extension'])) {
144 $suffix = $filename_arr[
'extension'];
145 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
146 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
148 if (strlen($tmpname) && is_array($this->
getSuffixes())) {
150 $this->
setAlert($this->
lng->txt(
'form_msg_file_wrong_file_type'));
158 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
159 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
162 if (isset($filename_arr[
'extension'])) {
163 $suffix = $filename_arr[
'extension'];
164 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
165 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
167 if (strlen($tmpname)) {
169 if ($vir[0] ==
false) {
170 $this->
setAlert($this->
lng->txt(
'form_msg_file_virus_found') .
'<br />' . $vir[1]);
192 $tpl =
new ilTemplate(
"tpl.prop_multiplechoicewizardinput.html",
true,
true,
"components/ILIAS/TestQuestionPool");
194 foreach ($this->values as
$value) {
196 if (!$this->hideImages) {
197 if ($value->hasImage()) {
198 $imagename = $this->qstObject->getImagePathWeb() . $value->getImage();
199 if (($this->
getSingleline()) && ($this->qstObject->getThumbSize())) {
200 if (file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value->getImage())) {
201 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value->getImage();
204 $tpl->setCurrentBlock(
'image');
205 $tpl->setVariable(
'SRC_IMAGE', $imagename);
206 $tpl->setVariable(
'IMAGE_NAME', $value->getImage());
211 $tpl->setVariable(
"TXT_DELETE_EXISTING",
$lng->
txt(
"delete_existing_file"));
212 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
213 $tpl->setVariable(
"IMAGE_POST_VAR", $this->
getPostVar());
214 $tpl->parseCurrentBlock();
216 $tpl->setCurrentBlock(
'addimage');
217 $tpl->setVariable(
"IMAGE_BROWSE",
$lng->
txt(
'select_file'));
218 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][$i]");
219 $tpl->setVariable(
'MAX_SIZE_WARNING', $this->
lng->txt(
'form_msg_file_size_exceeds'));
220 $tpl->setVariable(
'MAX_SIZE', $this->upload_limit->getPhpUploadLimitInBytes());
221 $tpl->setVariable(
"IMAGE_SUBMIT",
$lng->
txt(
"upload"));
222 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
223 $tpl->setVariable(
"IMAGE_POST_VAR", $this->
getPostVar());
224 $tpl->parseCurrentBlock();
227 if (is_object($value)) {
228 $tpl->setCurrentBlock(
"prop_text_propval");
233 $tpl->parseCurrentBlock();
234 $tpl->setCurrentBlock(
"prop_points_propval");
239 $tpl->parseCurrentBlock();
240 $tpl->setCurrentBlock(
"prop_points_unchecked_propval");
245 $tpl->parseCurrentBlock();
246 $tpl->setCurrentBlock(
"prop_answer_id_propval");
248 $tpl->parseCurrentBlock();
250 $tpl->setCurrentBlock(
'singleline');
251 $tpl->setVariable(
"SIZE", $this->
getSize());
252 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][$i]");
253 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $i);
254 $tpl->setVariable(
"SINGLELINE_POST_VAR", $this->
getPostVar());
257 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
259 $tpl->parseCurrentBlock();
261 if (is_object($value)) {
262 $tpl->setCurrentBlock(
"prop_points_propval");
267 $tpl->parseCurrentBlock();
268 $tpl->setCurrentBlock(
"prop_points_unchecked_propval");
273 $tpl->parseCurrentBlock();
274 $tpl->setCurrentBlock(
"prop_answer_id_propval");
276 $tpl->parseCurrentBlock();
278 $tpl->setCurrentBlock(
'multiline');
283 $tpl->setVariable(
"MULTILINE_ID", $this->
getPostVar() .
"[answer][$i]");
284 $tpl->setVariable(
"MULTILINE_ROW_NUMBER", $i);
285 $tpl->setVariable(
"MULTILINE_POST_VAR", $this->
getPostVar());
288 $tpl->setVariable(
"DISABLED_MULTILINE",
" disabled=\"disabled\"");
290 $tpl->parseCurrentBlock();
293 $tpl->setCurrentBlock(
"move");
294 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[$i]");
295 $tpl->setVariable(
"UP_BUTTON", $this->
renderer->render(
296 $this->glyph_factory->up()->withAction(
'#')
298 $tpl->setVariable(
"DOWN_BUTTON", $this->
renderer->render(
299 $this->glyph_factory->down()->withAction(
'#')
301 $tpl->parseCurrentBlock();
303 $tpl->setCurrentBlock(
"row");
304 $tpl->setVariable(
"POST_VAR", $this->
getPostVar());
305 $tpl->setVariable(
"ROW_NUMBER", $i);
306 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[answer][$i]");
307 $tpl->setVariable(
"POINTS_ID", $this->
getPostVar() .
"[points][$i]");
308 $tpl->setVariable(
"POINTS_UNCHECKED_ID", $this->
getPostVar() .
"[points_unchecked][$i]");
310 $tpl->setVariable(
"DISABLED_POINTS",
" disabled=\"disabled\"");
312 $tpl->setVariable(
"ADD_BUTTON", $this->
renderer->render(
313 $this->glyph_factory->add()->withAction(
'#')
315 $tpl->setVariable(
"REMOVE_BUTTON", $this->
renderer->render(
316 $this->glyph_factory->remove()->withAction(
'#')
318 $tpl->parseCurrentBlock();
323 if (!$this->hideImages) {
325 $suff_str = $delim =
"";
327 $suff_str .= $delim .
"." .
$suffix;
330 $tpl->setCurrentBlock(
'allowed_image_suffixes');
331 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
$lng->
txt(
"file_allowed_suffixes") .
" " . $suff_str);
332 $tpl->parseCurrentBlock();
335 $tpl->setCurrentBlock(
"image_heading");
336 $tpl->setVariable(
"ANSWER_IMAGE",
$lng->
txt(
'answer_image'));
338 $tpl->parseCurrentBlock();
342 $tpl->setVariable(
"ELEMENT_ID", $this->
getPostVar());
343 $tpl->setVariable(
"TEXT_YES",
$lng->
txt(
'yes'));
344 $tpl->setVariable(
"TEXT_NO",
$lng->
txt(
'no'));
345 $tpl->setVariable(
"DELETE_IMAGE_HEADER",
$lng->
txt(
'delete_image_header'));
346 $tpl->setVariable(
"DELETE_IMAGE_QUESTION",
$lng->
txt(
'delete_image_question'));
347 $tpl->setVariable(
"ANSWER_TEXT",
$lng->
txt(
'answer_text'));
348 $tpl->setVariable(
"POINTS_TEXT",
$lng->
txt(
'points'));
349 $tpl->setVariable(
"COMMANDS_TEXT",
$lng->
txt(
'actions'));
350 $tpl->setVariable(
"POINTS_CHECKED_TEXT",
$lng->
txt(
'checkbox_checked'));
351 $tpl->setVariable(
"POINTS_UNCHECKED_TEXT",
$lng->
txt(
'checkbox_unchecked'));
359 $tpl->addJavascript(
"assets/js/answerwizardinput.js");
360 $tpl->addJavascript(
"assets/js/multiplechoicewizard.js");
365 $this->pending = $a_val;
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
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.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)