4 require_once
'./Modules/TestQuestionPool/classes/class.ilSingleChoiceWizardInputGUI.php';
43 $this->
setSuffixes(array(
"jpg",
"jpeg",
"png",
"gif"));
45 $this->text_name = $lng->txt(
'answer_text');
46 $this->image_name = $lng->txt(
'answer_image');
80 $this->suffixes = $a_suffixes;
100 $this->hideImages = $a_hide;
110 $this->values = $a_values;
125 $this->text_name = $a_value;
130 $this->image_name = $a_value;
140 $this->qstObject =& $a_value;
160 $this->allowMove = $a_allow_move;
180 $this->values = array();
181 if (is_array($a_value))
183 if (is_array($a_value[
'answer']))
185 foreach ($a_value[
'answer'] as $index =>
$value)
187 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
189 array_push($this->values, $answer);
203 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
209 if (is_array($foundvalues))
212 if (is_array($foundvalues[
'answer']))
214 foreach ($foundvalues[
'answer'] as $aidx => $answervalue)
216 if (((strlen($answervalue)) == 0) && (strlen($foundvalues[
'imagename'][$aidx]) == 0))
218 $this->
setAlert($lng->txt(
"msg_input_is_required"));
223 if (!$this->hideImages)
225 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image']))
227 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error)
234 case UPLOAD_ERR_INI_SIZE:
235 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
239 case UPLOAD_ERR_FORM_SIZE:
240 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
244 case UPLOAD_ERR_PARTIAL:
245 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
249 case UPLOAD_ERR_NO_FILE:
252 if ((!strlen($foundvalues[
'imagename'][$index])) && (!strlen($foundvalues[
'answer'][$index])))
254 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
260 case UPLOAD_ERR_NO_TMP_DIR:
261 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
265 case UPLOAD_ERR_CANT_WRITE:
266 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
270 case UPLOAD_ERR_EXTENSION:
271 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
279 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
281 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
285 $suffix = $filename_arr[
"extension"];
288 if (strlen($tmpname) && is_array($this->
getSuffixes()))
291 if ($vir[0] ==
false)
293 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
299 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
319 $tpl =
new ilTemplate(
"tpl.prop_matchingwizardinput.html",
true,
true,
"Modules/TestQuestionPool");
321 foreach ($this->values as
$value)
323 if (!$this->hideImages)
325 if (strlen($value->picture))
327 $imagename = $this->qstObject->getImagePathWeb() . $value->picture;
328 if ($this->qstObject->getThumbSize())
330 if (@file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value->picture))
332 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value->picture;
335 $tpl->setCurrentBlock(
'image');
336 $tpl->setVariable(
'SRC_IMAGE', $imagename);
337 $tpl->setVariable(
'IMAGE_NAME', $value->picture);
339 $tpl->setVariable(
"TXT_DELETE_EXISTING", $lng->txt(
"delete_existing_file"));
340 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
342 if($this->disable_upload)
344 $tpl->setVariable(
'DISABLED_UPLOAD',
'type="hidden" disabled="disabled"');
346 $tpl->parseCurrentBlock();
348 $tpl->setCurrentBlock(
'addimage');
349 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][$i]");
350 $tpl->setVariable(
"IMAGE_SUBMIT", $lng->txt(
"upload"));
351 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
353 if($this->disable_upload)
355 $tpl->setVariable(
'DISABLED_UPLOAD',
'type="hidden" disabled="disabled"');
357 $tpl->parseCurrentBlock();
360 if (is_object($value))
362 $tpl->setCurrentBlock(
"prop_text_propval");
364 $tpl->parseCurrentBlock();
368 if($this->disable_text)
370 $tpl->setVariable(
"DISABLED_SINGLELINE",
'readonly="readonly"');
371 $tpl->setVariable(
"DISABLED_SINGLELINE_BTN",
'readonly="readonly"');
374 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][$i]");
375 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $i);
380 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
382 $tpl->parseCurrentBlock();
385 $tpl->setCurrentBlock(
"move");
386 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
387 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
391 $tpl->parseCurrentBlock();
393 $tpl->setCurrentBlock(
"row");
394 $class = ($i % 2 == 0) ?
"even" :
"odd";
395 if ($i == 0) $class .=
" first";
396 if ($i == count($this->values)-1) $class .=
" last";
397 $tpl->setVariable(
"ROW_CLASS", $class);
399 $tpl->setVariable(
"ROW_NUMBER", $i+1);
400 $tpl->setVariable(
"ROW_IDENTIFIER", $value->identifier);
403 if($this->disable_actions)
410 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]");
411 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]");
415 $tpl->parseCurrentBlock();
419 if (!$this->hideImages)
423 $suff_str = $delim =
"";
426 $suff_str.= $delim.
".".
$suffix;
429 $tpl->setCurrentBlock(
'allowed_image_suffixes');
430 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES", $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
431 $tpl->parseCurrentBlock();
433 $tpl->setCurrentBlock(
"image_heading");
434 $tpl->setVariable(
"ANSWER_IMAGE", $this->image_name);
436 $tpl->parseCurrentBlock();
440 $tpl->setVariable(
"TEXT_YES", $lng->txt(
'yes'));
441 $tpl->setVariable(
"TEXT_NO", $lng->txt(
'no'));
442 $tpl->setVariable(
"DELETE_IMAGE_HEADER", $lng->txt(
'delete_image_header'));
443 $tpl->setVariable(
"DELETE_IMAGE_QUESTION", $lng->txt(
'delete_image_question'));
444 $tpl->setVariable(
"ANSWER_TEXT", $this->text_name);
445 $tpl->setVariable(
"NUMBER_TEXT", $lng->txt(
'row'));
446 if(!$this->disable_actions)
448 $tpl->setVariable(
"COMMANDS_TEXT", $lng->txt(
'actions'));
451 $a_tpl->setCurrentBlock(
"prop_generic");
452 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
453 $a_tpl->parseCurrentBlock();