24 include_once
"./Modules/TestQuestionPool/classes/class.ilSingleChoiceWizardInputGUI.php";
54 $this->
setSuffixes(array(
"jpg",
"jpeg",
"png",
"gif"));
56 $this->text_name = $lng->txt(
'answer_text');
57 $this->image_name = $lng->txt(
'answer_image');
67 $this->suffixes = $a_suffixes;
87 $this->hideImages = $a_hide;
97 $this->values = $a_values;
112 $this->text_name = $a_value;
117 $this->image_name = $a_value;
127 $this->qstObject =& $a_value;
147 $this->allowMove = $a_allow_move;
167 $this->values = array();
168 if (is_array($a_value))
170 if (is_array($a_value[
'answer']))
172 foreach ($a_value[
'answer'] as $index =>
$value)
174 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
176 array_push($this->values, $answer);
190 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
193 if (is_array($foundvalues))
196 if (is_array($foundvalues[
'answer']))
198 foreach ($foundvalues[
'answer'] as $aidx => $answervalue)
200 if (((strlen($answervalue)) == 0) && (strlen($foundvalues[
'imagename'][$aidx]) == 0))
202 $this->
setAlert($lng->txt(
"msg_input_is_required"));
210 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image']))
212 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error)
219 case UPLOAD_ERR_INI_SIZE:
220 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
224 case UPLOAD_ERR_FORM_SIZE:
225 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
229 case UPLOAD_ERR_PARTIAL:
230 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
234 case UPLOAD_ERR_NO_FILE:
237 if ((!strlen($foundvalues[
'imagename'][$index])) && (!strlen($foundvalues[
'answer'][$index])))
239 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
245 case UPLOAD_ERR_NO_TMP_DIR:
246 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
250 case UPLOAD_ERR_CANT_WRITE:
251 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
255 case UPLOAD_ERR_EXTENSION:
256 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
267 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
272 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
274 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
278 $suffix = $filename_arr[
"extension"];
279 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
280 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
282 if (strlen($tmpname) && is_array($this->
getSuffixes()))
286 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
293 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
295 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
299 $suffix = $filename_arr[
"extension"];
300 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
301 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
303 if (strlen($tmpname))
306 if ($vir[0] ==
false)
308 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
318 $this->
setAlert($lng->txt(
"msg_input_is_required"));
334 $tpl =
new ilTemplate(
"tpl.prop_matchingwizardinput.html",
true,
true,
"Modules/TestQuestionPool");
336 foreach ($this->values as
$value)
338 if (!$this->hideImages)
340 if (strlen($value->picture))
342 $imagename = $this->qstObject->getImagePathWeb() . $value->picture;
343 if ($this->qstObject->getThumbSize())
345 if (@file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value->picture))
347 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value->picture;
350 $tpl->setCurrentBlock(
'image');
351 $tpl->setVariable(
'SRC_IMAGE', $imagename);
352 $tpl->setVariable(
'IMAGE_NAME', $value->picture);
354 $tpl->setVariable(
"TXT_DELETE_EXISTING", $lng->txt(
"delete_existing_file"));
355 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
357 $tpl->parseCurrentBlock();
359 $tpl->setCurrentBlock(
'addimage');
360 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][$i]");
361 $tpl->setVariable(
"IMAGE_SUBMIT", $lng->txt(
"upload"));
362 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
364 $tpl->parseCurrentBlock();
367 if (is_object($value))
369 $tpl->setCurrentBlock(
"prop_text_propval");
371 $tpl->parseCurrentBlock();
376 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][$i]");
377 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $i);
382 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
384 $tpl->parseCurrentBlock();
387 $tpl->setCurrentBlock(
"move");
388 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
389 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
393 $tpl->parseCurrentBlock();
395 $tpl->setCurrentBlock(
"row");
396 $class = ($i % 2 == 0) ?
"even" :
"odd";
397 if ($i == 0) $class .=
" first";
398 if ($i == count($this->values)-1) $class .=
" last";
399 $tpl->setVariable(
"ROW_CLASS", $class);
401 $tpl->setVariable(
"ROW_NUMBER", $i+1);
402 $tpl->setVariable(
"ROW_IDENTIFIER", $value->identifier);
404 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]");
405 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]");
408 $tpl->parseCurrentBlock();
412 if (!$this->hideImages)
416 $suff_str = $delim =
"";
419 $suff_str.= $delim.
".".
$suffix;
422 $tpl->setCurrentBlock(
'allowed_image_suffixes');
423 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES", $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
424 $tpl->parseCurrentBlock();
426 $tpl->setCurrentBlock(
"image_heading");
427 $tpl->setVariable(
"ANSWER_IMAGE", $this->image_name);
429 $tpl->parseCurrentBlock();
433 $tpl->setVariable(
"TEXT_YES", $lng->txt(
'yes'));
434 $tpl->setVariable(
"TEXT_NO", $lng->txt(
'no'));
435 $tpl->setVariable(
"DELETE_IMAGE_HEADER", $lng->txt(
'delete_image_header'));
436 $tpl->setVariable(
"DELETE_IMAGE_QUESTION", $lng->txt(
'delete_image_question'));
437 $tpl->setVariable(
"ANSWER_TEXT", $this->text_name);
438 $tpl->setVariable(
"NUMBER_TEXT", $lng->txt(
'row'));
439 $tpl->setVariable(
"COMMANDS_TEXT", $lng->txt(
'actions'));
441 $a_tpl->setCurrentBlock(
"prop_generic");
442 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
443 $a_tpl->parseCurrentBlock();