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();
411 $tpl->setCurrentBlock(
"prop_points_propval");
413 $tpl->parseCurrentBlock();
416 $tpl->setCurrentBlock(
'singleline');
418 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][$i]");
419 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $i);
424 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
426 $tpl->parseCurrentBlock();
430 if (is_object($value))
434 $tpl->setCurrentBlock(
"prop_points_propval");
436 $tpl->parseCurrentBlock();
439 $tpl->setCurrentBlock(
'multiline');
441 $tpl->setVariable(
"MULTILINE_ID", $this->
getPostVar() .
"[answer][$i]");
442 $tpl->setVariable(
"MULTILINE_ROW_NUMBER", $i);
446 $tpl->setVariable(
"DISABLED_MULTILINE",
" disabled=\"disabled\"");
448 $tpl->parseCurrentBlock();
452 $tpl->setCurrentBlock(
"move");
453 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
454 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
458 $tpl->parseCurrentBlock();
462 $tpl->setCurrentBlock(
"points");
463 $tpl->setVariable(
"POINTS_ID", $this->
getPostVar() .
"[points][$i]");
465 $tpl->setVariable(
"POINTS_ROW_NUMBER", $i);
466 $tpl->parseCurrentBlock();
468 $tpl->setCurrentBlock(
"row");
469 $class = ($i % 2 == 0) ?
"even" :
"odd";
470 if ($i == 0) $class .=
" first";
471 if ($i == count($this->values)-1) $class .=
" last";
472 $tpl->setVariable(
"ROW_CLASS", $class);
474 $tpl->setVariable(
"ROW_NUMBER", $i);
476 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]");
477 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]");
480 $tpl->setVariable(
"DISABLED_POINTS",
" disabled=\"disabled\"");
484 $tpl->parseCurrentBlock();
490 if (!$this->hideImages)
494 $suff_str = $delim =
"";
497 $suff_str.= $delim.
".".
$suffix;
500 $tpl->setCurrentBlock(
'allowed_image_suffixes');
501 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES", $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
502 $tpl->parseCurrentBlock();
504 $tpl->setCurrentBlock(
"image_heading");
505 $tpl->setVariable(
"ANSWER_IMAGE", $lng->txt(
'answer_image'));
507 $tpl->parseCurrentBlock();
513 $tpl->setCurrentBlock(
"points_heading");
514 $tpl->setVariable(
"POINTS_TEXT", $lng->txt(
'points'));
515 $tpl->parseCurrentBlock();
519 $tpl->setVariable(
"TEXT_YES", $lng->txt(
'yes'));
520 $tpl->setVariable(
"TEXT_NO", $lng->txt(
'no'));
521 $tpl->setVariable(
"DELETE_IMAGE_HEADER", $lng->txt(
'delete_image_header'));
522 $tpl->setVariable(
"DELETE_IMAGE_QUESTION", $lng->txt(
'delete_image_question'));
523 $tpl->setVariable(
"ANSWER_TEXT", $lng->txt(
'answer_text'));
524 $tpl->setVariable(
"COMMANDS_TEXT", $lng->txt(
'actions'));
526 $a_tpl->setCurrentBlock(
"prop_generic");
527 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
528 $a_tpl->parseCurrentBlock();
531 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
533 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/singlechoicewizard.js");