52 $this->glyph_factory = $DIC->ui()->factory()->symbol()->glyph();
53 $this->renderer = $DIC->ui()->renderer();
54 $this->upload_limit = $DIC[
'ui.upload_limit_resolver'];
56 $this->
setSuffixes(array(
"jpg",
"jpeg",
"png",
"gif"));
61 $this->text_name =
$lng->
txt(
'answer_text');
62 $this->image_name =
$lng->
txt(
'answer_image');
72 $this->suffixes = $a_suffixes;
92 $this->hideImages = $a_hide;
102 $this->values = $a_values;
117 $this->text_name = $a_value;
122 $this->image_name = $a_value;
132 $this->qstObject = &$a_value;
147 $this->values = array();
148 if (is_array($a_value)) {
149 if (is_array($a_value[
'answer'])) {
150 foreach ($a_value[
'answer'] as $index =>
$value) {
153 $a_value[
'imagename'][$index] ?? 0,
154 $a_value[
'identifier'][$index] ?? 0
156 array_push($this->values, $answer);
180 if (is_array($foundvalues)) {
182 if (is_array($foundvalues[
'answer'])) {
183 foreach ($foundvalues[
'answer'] as $aidx => $answervalue) {
184 if ($answervalue ===
'' && (
185 (!isset($foundvalues[
'imagename'][$aidx]) || $foundvalues[
'imagename'][$aidx] ===
'') &&
186 !isset($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'][$aidx])
195 if (!$this->hideImages) {
196 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image'])) {
197 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error) {
201 case UPLOAD_ERR_FORM_SIZE:
202 case UPLOAD_ERR_INI_SIZE:
207 case UPLOAD_ERR_PARTIAL:
212 case UPLOAD_ERR_NO_FILE:
214 if ((!isset($foundvalues[
'imagename'][$index]) || $foundvalues[
'imagename'][$index] ===
'') &&
215 (!isset($foundvalues[
'answer'][$index]) && $foundvalues[
'answer'][$index] ===
'')) {
222 case UPLOAD_ERR_NO_TMP_DIR:
227 case UPLOAD_ERR_CANT_WRITE:
232 case UPLOAD_ERR_EXTENSION:
241 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
242 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname) {
246 if (isset($filename_arr[
'extension'])) {
247 $suffix = $filename_arr[
"extension"];
251 if ($tmpname !=
'' && is_array($this->
getSuffixes())) {
253 if ($vir[0] ==
false) {
254 $this->
setAlert(
$lng->
txt(
"form_msg_file_virus_found") .
"<br />" . $vir[1]);
279 $global_tpl->addJavascript(
'./Modules/TestQuestionPool/templates/default/matchinginput.js');
282 $tpl =
new ilTemplate(
"tpl.prop_matchingwizardinput.html",
true,
true,
"Modules/TestQuestionPool");
284 foreach ($this->values as
$value) {
285 if (!$this->hideImages) {
286 if ($value->getPicture() &&
287 file_exists($this->qstObject->getImagePath() . $value->getPicture())
289 $imagename = $this->qstObject->getImagePathWeb() . $value->getPicture();
290 if ($this->qstObject->getThumbSize()) {
291 if (file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value->getPicture())) {
292 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value->getPicture();
296 $tpl->setCurrentBlock(
'image');
297 $tpl->setVariable(
'SRC_IMAGE', $imagename);
298 $tpl->setVariable(
'IMAGE_NAME', $value->getPicture());
300 $tpl->setVariable(
"TXT_DELETE_EXISTING",
$lng->
txt(
"delete_existing_file"));
301 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
302 $tpl->setVariable(
"IMAGE_POST_VAR", $this->
getPostVar());
303 $tpl->parseCurrentBlock();
305 $tpl->setCurrentBlock(
'addimage');
306 $tpl->setVariable(
"IMAGE_BROWSE",
$lng->
txt(
'select_file'));
307 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][$i]");
308 $tpl->setVariable(
'MAX_SIZE_WARNING', $this->
lng->txt(
'form_msg_file_size_exceeds'));
309 $tpl->setVariable(
'MAX_SIZE', $this->upload_limit->getPhpUploadLimitInBytes());
310 $tpl->setVariable(
"IMAGE_SUBMIT",
$lng->
txt(
"upload"));
311 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
312 $tpl->setVariable(
"IMAGE_POST_VAR", $this->
getPostVar());
313 $tpl->parseCurrentBlock();
316 if (is_object($value)) {
317 $tpl->setCurrentBlock(
"prop_text_propval");
319 $tpl->parseCurrentBlock();
323 $tpl->setVariable(
"SIZE", $this->
getSize());
324 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][$i]");
325 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $i);
326 $tpl->setVariable(
"SINGLELINE_POST_VAR", $this->
getPostVar());
329 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
331 $tpl->parseCurrentBlock();
332 $tpl->setCurrentBlock(
"row");
333 $tpl->setVariable(
"POST_VAR", $this->
getPostVar());
334 $tpl->setVariable(
"ROW_NUMBER", $i + 1);
335 $tpl->setVariable(
"ROW_IDENTIFIER", $value->getIdentifier());
336 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[answer][$i]");
337 $tpl->setVariable(
"ADD_BUTTON", $this->renderer->render(
338 $this->glyph_factory->add()->withAction(
'#')
340 $tpl->setVariable(
"REMOVE_BUTTON", $this->renderer->render(
341 $this->glyph_factory->remove()->withAction(
'#')
343 $tpl->parseCurrentBlock();
347 if (!$this->hideImages) {
349 $suff_str = $delim =
"";
351 $suff_str .= $delim .
"." .
$suffix;
354 $tpl->setCurrentBlock(
'allowed_image_suffixes');
355 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
$lng->
txt(
"file_allowed_suffixes") .
" " . $suff_str);
356 $tpl->parseCurrentBlock();
358 $tpl->setCurrentBlock(
"image_heading");
359 $tpl->setVariable(
"ANSWER_IMAGE", $this->image_name);
361 $tpl->parseCurrentBlock();
364 $tpl->setVariable(
"ELEMENT_ID", $this->
getPostVar());
365 $tpl->setVariable(
"TEXT_YES",
$lng->
txt(
'yes'));
366 $tpl->setVariable(
"TEXT_NO",
$lng->
txt(
'no'));
367 $tpl->setVariable(
"DELETE_IMAGE_HEADER",
$lng->
txt(
'delete_image_header'));
368 $tpl->setVariable(
"DELETE_IMAGE_QUESTION",
$lng->
txt(
'delete_image_question'));
369 $tpl->setVariable(
"ANSWER_TEXT", $this->text_name);
370 $tpl->setVariable(
"NUMBER_TEXT",
$lng->
txt(
'row'));
371 $tpl->setVariable(
"COMMANDS_TEXT",
$lng->
txt(
'actions'));
380 $this->pending = $a_val;
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An entity that renders components to a string output.
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)
This is how a factory for glyphs looks like.
setVariable($variable, $value='')
Sets a variable value.
static _getUsedHTMLTagsAsString(string $a_module="")
Returns a string of all allowed HTML tags for text editing.
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setMaxLength(?int $a_maxlength)