4 require_once
'./Modules/TestQuestionPool/classes/class.ilSingleChoiceWizardInputGUI.php';
5 require_once
'Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php';
40 parent::__construct($a_title, $a_postvar);
41 $this->
setSuffixes(array(
"jpg",
"jpeg",
"png",
"gif"));
43 $this->text_name =
$lng->txt(
'answer_text');
44 $this->image_name =
$lng->txt(
'answer_image');
54 $this->suffixes = $a_suffixes;
74 $this->hideImages = $a_hide;
84 $this->values = $a_values;
99 $this->text_name = $a_value;
104 $this->image_name = $a_value;
114 $this->qstObject = &$a_value;
134 $this->allowMove = $a_allow_move;
154 $this->values = array();
155 if (is_array($a_value)) {
156 if (is_array($a_value[
'answer'])) {
158 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMatchingTerm.php";
160 array_push($this->values, $answer);
175 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
180 if (is_array($foundvalues)) {
182 if (is_array($foundvalues[
'answer'])) {
183 foreach ($foundvalues[
'answer'] as $aidx => $answervalue) {
184 if (((strlen($answervalue)) == 0) && (strlen($foundvalues[
'imagename'][$aidx]) == 0)) {
190 if (!$this->hideImages) {
191 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image'])) {
192 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as
$index => $error) {
196 case UPLOAD_ERR_INI_SIZE:
197 $this->
setAlert(
$lng->txt(
"form_msg_file_size_exceeds"));
201 case UPLOAD_ERR_FORM_SIZE:
202 $this->
setAlert(
$lng->txt(
"form_msg_file_size_exceeds"));
206 case UPLOAD_ERR_PARTIAL:
207 $this->
setAlert(
$lng->txt(
"form_msg_file_partially_uploaded"));
211 case UPLOAD_ERR_NO_FILE:
213 if ((!strlen($foundvalues[
'imagename'][$index])) && (!strlen($foundvalues[
'answer'][$index]))) {
220 case UPLOAD_ERR_NO_TMP_DIR:
221 $this->
setAlert(
$lng->txt(
"form_msg_file_missing_tmp_dir"));
225 case UPLOAD_ERR_CANT_WRITE:
226 $this->
setAlert(
$lng->txt(
"form_msg_file_cannot_write_to_disk"));
230 case UPLOAD_ERR_EXTENSION:
231 $this->
setAlert(
$lng->txt(
"form_msg_file_upload_stopped_ext"));
239 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
240 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as
$index => $tmpname) {
243 $suffix = $filename_arr[
"extension"];
246 if (strlen($tmpname) && is_array($this->
getSuffixes())) {
248 if ($vir[0] ==
false) {
249 $this->
setAlert(
$lng->txt(
"form_msg_file_virus_found") .
"<br />" . $vir[1]);
254 $this->
setAlert(
$lng->txt(
"form_msg_file_wrong_file_type"));
275 $tpl =
new ilTemplate(
"tpl.prop_matchingwizardinput.html",
true,
true,
"Modules/TestQuestionPool");
277 foreach ($this->values as
$value) {
278 if (!$this->hideImages) {
279 if (strlen($value->picture)) {
280 $imagename = $this->qstObject->getImagePathWeb() . $value->picture;
281 if ($this->qstObject->getThumbSize()) {
282 if (@file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value->picture)) {
283 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value->picture;
286 $tpl->setCurrentBlock(
'image');
287 $tpl->setVariable(
'SRC_IMAGE', $imagename);
288 $tpl->setVariable(
'IMAGE_NAME', $value->picture);
290 $tpl->setVariable(
"TXT_DELETE_EXISTING",
$lng->txt(
"delete_existing_file"));
291 $tpl->setVariable(
"IMAGE_ROW_NUMBER",
$i);
293 $tpl->parseCurrentBlock();
295 $tpl->setCurrentBlock(
'addimage');
296 $tpl->setVariable(
"IMAGE_BROWSE",
$lng->txt(
'select_file'));
297 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][$i]");
298 $tpl->setVariable(
"IMAGE_SUBMIT",
$lng->txt(
"upload"));
299 $tpl->setVariable(
"IMAGE_ROW_NUMBER",
$i);
301 $tpl->parseCurrentBlock();
304 if (is_object($value)) {
305 $tpl->setCurrentBlock(
"prop_text_propval");
307 $tpl->parseCurrentBlock();
312 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][$i]");
313 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER",
$i);
317 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
319 $tpl->parseCurrentBlock();
321 $tpl->setCurrentBlock(
"move");
322 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
323 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
327 $tpl->parseCurrentBlock();
329 $tpl->setCurrentBlock(
"row");
331 $tpl->setVariable(
"ROW_NUMBER",
$i + 1);
332 $tpl->setVariable(
"ROW_IDENTIFIER", $value->identifier);
334 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]");
335 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]");
338 $tpl->parseCurrentBlock();
342 if (!$this->hideImages) {
344 $suff_str = $delim =
"";
346 $suff_str .= $delim .
"." .
$suffix;
349 $tpl->setCurrentBlock(
'allowed_image_suffixes');
350 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
$lng->txt(
"file_allowed_suffixes") .
" " . $suff_str);
351 $tpl->parseCurrentBlock();
353 $tpl->setCurrentBlock(
"image_heading");
354 $tpl->setVariable(
"ANSWER_IMAGE", $this->image_name);
356 $tpl->parseCurrentBlock();
360 $tpl->setVariable(
"TEXT_YES",
$lng->txt(
'yes'));
361 $tpl->setVariable(
"TEXT_NO",
$lng->txt(
'no'));
362 $tpl->setVariable(
"DELETE_IMAGE_HEADER",
$lng->txt(
'delete_image_header'));
363 $tpl->setVariable(
"DELETE_IMAGE_QUESTION",
$lng->txt(
'delete_image_question'));
364 $tpl->setVariable(
"ANSWER_TEXT", $this->text_name);
365 $tpl->setVariable(
"NUMBER_TEXT",
$lng->txt(
'row'));
366 $tpl->setVariable(
"COMMANDS_TEXT",
$lng->txt(
'actions'));
368 $a_tpl->setCurrentBlock(
"prop_generic");
369 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
370 $a_tpl->parseCurrentBlock();
Class for matching question terms.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getMaxLength()
Get Max Length.
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
static _getUsedHTMLTagsAsString($a_module="")
Returns a string of all allowed HTML tags for text editing.
static get($a_glyph, $a_text="")
Get glyph html.
special template class to simplify handling of ITX/PEAR
setSize($a_size)
Set Size.
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
This class represents a text property in a property form.