50 $this->
setSuffixes(array(
"jpg",
"jpeg",
"png",
"gif"));
52 $this->validationRegexp =
"";
62 $this->values = array();
63 if (is_array($a_value))
65 if (is_array($a_value[
'answer']))
67 foreach ($a_value[
'answer'] as $index =>
$value)
69 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
71 array_push($this->values, $answer);
84 $this->suffixes = $a_suffixes;
94 $this->hideImages = $a_hide;
109 $this->showPoints = $a_value;
124 $this->values = $a_values;
144 $this->singleline = $a_value;
164 $this->qstObject =& $a_value;
184 $this->allowMove = $a_allow_move;
206 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
210 if (is_array($foundvalues))
213 if (is_array($foundvalues[
'answer']))
215 foreach ($foundvalues[
'answer'] as $aidx => $answervalue)
217 if (((strlen($answervalue)) == 0) && (strlen($foundvalues[
'imagename'][$aidx]) == 0))
219 $this->
setAlert($lng->txt(
"msg_input_is_required"));
226 if (is_array($foundvalues[
'points']))
228 foreach ($foundvalues[
'points'] as
$points)
230 if ($points > $max) $max =
$points;
231 if (((strlen($points)) == 0) || (!is_numeric($points)))
233 $this->
setAlert($lng->txt(
"form_msg_numeric_value_required"));
240 $this->
setAlert($lng->txt(
"enter_enough_positive_points"));
246 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image']))
248 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index =>
$error)
255 case UPLOAD_ERR_INI_SIZE:
256 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
260 case UPLOAD_ERR_FORM_SIZE:
261 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
265 case UPLOAD_ERR_PARTIAL:
266 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
270 case UPLOAD_ERR_NO_FILE:
273 if ((!strlen($foundvalues[
'imagename'][$index])) && (!strlen($foundvalues[
'answer'][$index])))
275 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
281 case UPLOAD_ERR_NO_TMP_DIR:
282 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
286 case UPLOAD_ERR_CANT_WRITE:
287 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
291 case UPLOAD_ERR_EXTENSION:
292 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
303 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
308 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
310 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
314 $suffix = $filename_arr[
"extension"];
315 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
316 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
318 if (strlen($tmpname) && is_array($this->
getSuffixes()))
322 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
329 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
331 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
335 $suffix = $filename_arr[
"extension"];
336 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
337 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
339 if (strlen($tmpname))
342 if ($vir[0] ==
false)
344 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
354 $this->
setAlert($lng->txt(
"msg_input_is_required"));
370 $tpl =
new ilTemplate(
"tpl.prop_singlechoicewizardinput.html",
true,
true,
"Modules/TestQuestionPool");
372 foreach ($this->values as
$value)
376 if (!$this->hideImages)
378 if (strlen($value->getImage()))
380 $imagename = $this->qstObject->getImagePathWeb() . $value->getImage();
381 if (($this->
getSingleline()) && ($this->qstObject->getThumbSize()))
383 if (@file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value->getImage()))
385 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value->getImage();
388 $tpl->setCurrentBlock(
'image');
389 $tpl->setVariable(
'SRC_IMAGE', $imagename);
390 $tpl->setVariable(
'IMAGE_NAME', $value->getImage());
392 $tpl->setVariable(
"TXT_DELETE_EXISTING", $lng->txt(
"delete_existing_file"));
393 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
395 $tpl->parseCurrentBlock();
397 $tpl->setCurrentBlock(
'addimage');
398 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][$i]");
399 $tpl->setVariable(
"IMAGE_SUBMIT", $lng->txt(
"upload"));
400 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
402 $tpl->parseCurrentBlock();
405 if (is_object($value))
407 $tpl->setCurrentBlock(
"prop_text_propval");
409 $tpl->parseCurrentBlock();
410 $tpl->setCurrentBlock(
"prop_points_propval");
412 $tpl->parseCurrentBlock();
414 $tpl->setCurrentBlock(
'singleline');
416 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][$i]");
417 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $i);
422 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
424 $tpl->parseCurrentBlock();
428 if (is_object($value))
432 $tpl->setCurrentBlock(
"prop_points_propval");
434 $tpl->parseCurrentBlock();
437 $tpl->setCurrentBlock(
'multiline');
439 $tpl->setVariable(
"MULTILINE_ID", $this->
getPostVar() .
"[answer][$i]");
440 $tpl->setVariable(
"MULTILINE_ROW_NUMBER", $i);
444 $tpl->setVariable(
"DISABLED_MULTILINE",
" disabled=\"disabled\"");
446 $tpl->parseCurrentBlock();
450 $tpl->setCurrentBlock(
"move");
451 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
452 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
456 $tpl->parseCurrentBlock();
460 $tpl->setCurrentBlock(
"points");
461 $tpl->setVariable(
"POINTS_ID", $this->
getPostVar() .
"[points][$i]");
463 $tpl->setVariable(
"POINTS_ROW_NUMBER", $i);
464 $tpl->parseCurrentBlock();
466 $tpl->setCurrentBlock(
"row");
467 $class = ($i % 2 == 0) ?
"even" :
"odd";
468 if ($i == 0) $class .=
" first";
469 if ($i == count($this->values)-1) $class .=
" last";
470 $tpl->setVariable(
"ROW_CLASS", $class);
472 $tpl->setVariable(
"ROW_NUMBER", $i);
474 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]");
475 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]");
478 $tpl->setVariable(
"DISABLED_POINTS",
" disabled=\"disabled\"");
482 $tpl->parseCurrentBlock();
488 if (!$this->hideImages)
492 $suff_str = $delim =
"";
495 $suff_str.= $delim.
".".
$suffix;
498 $tpl->setCurrentBlock(
'allowed_image_suffixes');
499 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES", $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
500 $tpl->parseCurrentBlock();
502 $tpl->setCurrentBlock(
"image_heading");
503 $tpl->setVariable(
"ANSWER_IMAGE", $lng->txt(
'answer_image'));
505 $tpl->parseCurrentBlock();
511 $tpl->setCurrentBlock(
"points_heading");
512 $tpl->setVariable(
"POINTS_TEXT", $lng->txt(
'points'));
513 $tpl->parseCurrentBlock();
517 $tpl->setVariable(
"TEXT_YES", $lng->txt(
'yes'));
518 $tpl->setVariable(
"TEXT_NO", $lng->txt(
'no'));
519 $tpl->setVariable(
"DELETE_IMAGE_HEADER", $lng->txt(
'delete_image_header'));
520 $tpl->setVariable(
"DELETE_IMAGE_QUESTION", $lng->txt(
'delete_image_question'));
521 $tpl->setVariable(
"ANSWER_TEXT", $lng->txt(
'answer_text'));
522 $tpl->setVariable(
"COMMANDS_TEXT", $lng->txt(
'actions'));
524 $a_tpl->setCurrentBlock(
"prop_generic");
525 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
526 $a_tpl->parseCurrentBlock();
529 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
531 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/singlechoicewizard.js");