34 $this->
setSuffixes(array(
"jpg",
"jpeg",
"png",
"gif"));
36 $this->validationRegexp =
"";
70 $this->values = array();
71 if (is_array($a_value))
73 if (is_array($a_value[
'answer']))
75 foreach ($a_value[
'answer'] as $index =>
$value)
77 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerBinaryStateImage.php";
79 array_push($this->values, $answer);
92 $this->suffixes = $a_suffixes;
102 $this->hideImages = $a_hide;
117 $this->showPoints = $a_value;
132 $this->values = $a_values;
152 $this->singleline = $a_value;
172 $this->qstObject =& $a_value;
192 $this->allowMove = $a_allow_move;
214 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
218 if (is_array($foundvalues))
221 if (is_array($foundvalues[
'answer']))
223 foreach ($foundvalues[
'answer'] as $aidx => $answervalue)
225 if (((strlen($answervalue)) == 0) && (strlen($foundvalues[
'imagename'][$aidx]) == 0))
227 $this->
setAlert($lng->txt(
"msg_input_is_required"));
234 if (is_array($foundvalues[
'points']))
236 foreach ($foundvalues[
'points'] as $points)
238 if ($points > $max) $max = $points;
239 if (((strlen($points)) == 0) || (!is_numeric($points)))
241 $this->
setAlert($lng->txt(
"form_msg_numeric_value_required"));
248 $this->
setAlert($lng->txt(
"enter_enough_positive_points"));
254 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image']))
256 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error)
263 case UPLOAD_ERR_INI_SIZE:
264 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
268 case UPLOAD_ERR_FORM_SIZE:
269 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
273 case UPLOAD_ERR_PARTIAL:
274 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
278 case UPLOAD_ERR_NO_FILE:
281 if ((!strlen($foundvalues[
'imagename'][$index])) && (!strlen($foundvalues[
'answer'][$index])))
283 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
289 case UPLOAD_ERR_NO_TMP_DIR:
290 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
294 case UPLOAD_ERR_CANT_WRITE:
295 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
299 case UPLOAD_ERR_EXTENSION:
300 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
311 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
316 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
318 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
322 $suffix = $filename_arr[
"extension"];
323 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
324 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
326 if (strlen($tmpname) && is_array($this->
getSuffixes()))
330 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
337 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
339 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
343 $suffix = $filename_arr[
"extension"];
344 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
345 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
347 if (strlen($tmpname))
350 if ($vir[0] ==
false)
352 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
362 $this->
setAlert($lng->txt(
"msg_input_is_required"));
378 $tpl =
new ilTemplate(
"tpl.prop_singlechoicewizardinput.html",
true,
true,
"Modules/TestQuestionPool");
380 foreach ($this->values as
$value)
384 if (!$this->hideImages)
386 if (strlen($value->getImage()))
388 $imagename = $this->qstObject->getImagePathWeb() . $value->getImage();
389 if (($this->
getSingleline()) && ($this->qstObject->getThumbSize()))
391 if (@file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value->getImage()))
393 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value->getImage();
396 $tpl->setCurrentBlock(
'image');
397 $tpl->setVariable(
'SRC_IMAGE', $imagename);
398 $tpl->setVariable(
'IMAGE_NAME', $value->getImage());
400 $tpl->setVariable(
"TXT_DELETE_EXISTING", $lng->txt(
"delete_existing_file"));
401 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
403 if($this->disable_upload)
405 $tpl->setVariable(
'DISABLED_UPLOAD',
'type="hidden" disabled="disabled"');
407 $tpl->parseCurrentBlock();
409 $tpl->setCurrentBlock(
'addimage');
410 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][$i]");
411 $tpl->setVariable(
"IMAGE_SUBMIT", $lng->txt(
"upload"));
412 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
414 if($this->disable_upload)
416 $tpl->setVariable(
'DISABLED_UPLOAD',
'type="hidden" disabled="disabled"');
419 $tpl->parseCurrentBlock();
422 if (is_object($value))
424 $tpl->setCurrentBlock(
"prop_text_propval");
426 $tpl->parseCurrentBlock();
428 $tpl->setCurrentBlock(
"prop_points_propval");
430 $tpl->parseCurrentBlock();
433 $tpl->setCurrentBlock(
'singleline');
434 if($this->disable_text)
436 $tpl->setVariable(
"DISABLED_SINGLELINE",
'readonly="readonly"');
437 $tpl->setVariable(
"DISABLED_SINGLELINE_BTN",
'readonly="readonly"');
440 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][$i]");
441 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $i);
446 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
448 $tpl->parseCurrentBlock();
452 if (is_object($value))
456 $tpl->setCurrentBlock(
"prop_points_propval");
458 $tpl->parseCurrentBlock();
461 $tpl->setCurrentBlock(
'multiline');
462 if($this->disable_text)
464 $tpl->setVariable(
"DISABLED_MULTILINE",
'readonly="readonly"');
468 $tpl->setVariable(
"MULTILINE_ID", $this->
getPostVar() .
"[answer][$i]");
469 $tpl->setVariable(
"MULTILINE_ROW_NUMBER", $i);
473 $tpl->setVariable(
"DISABLED_MULTILINE",
" disabled=\"disabled\"");
475 $tpl->parseCurrentBlock();
479 $tpl->setCurrentBlock(
"move");
480 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
481 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
485 $tpl->parseCurrentBlock();
489 $tpl->setCurrentBlock(
"points");
490 $tpl->setVariable(
"POINTS_ID", $this->
getPostVar() .
"[points][$i]");
492 $tpl->setVariable(
"POINTS_ROW_NUMBER", $i);
493 $tpl->parseCurrentBlock();
495 $tpl->setCurrentBlock(
"row");
496 $class = ($i % 2 == 0) ?
"even" :
"odd";
497 if ($i == 0) $class .=
" first";
498 if ($i == count($this->values)-1) $class .=
" last";
499 $tpl->setVariable(
"ROW_CLASS", $class);
501 $tpl->setVariable(
"ROW_NUMBER", $i);
502 if(!$this->disable_actions)
506 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]" );
507 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]" );
513 $tpl->setVariable(
"DISABLED_POINTS",
" disabled=\"disabled\"");
515 $tpl->parseCurrentBlock();
521 if (!$this->hideImages)
525 $suff_str = $delim =
"";
528 $suff_str.= $delim.
".".
$suffix;
531 $tpl->setCurrentBlock(
'allowed_image_suffixes');
532 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES", $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
533 $tpl->parseCurrentBlock();
535 $tpl->setCurrentBlock(
"image_heading");
536 $tpl->setVariable(
"ANSWER_IMAGE", $lng->txt(
'answer_image'));
538 $tpl->parseCurrentBlock();
544 $tpl->setCurrentBlock(
"points_heading");
545 $tpl->setVariable(
"POINTS_TEXT", $lng->txt(
'points'));
546 $tpl->parseCurrentBlock();
548 if(!$this->disable_actions)
550 $tpl->setVariable(
"COMMANDS_TEXT", $lng->txt(
'actions'));
553 $tpl->setVariable(
"TEXT_YES", $lng->txt(
'yes'));
554 $tpl->setVariable(
"TEXT_NO", $lng->txt(
'no'));
555 $tpl->setVariable(
"DELETE_IMAGE_HEADER", $lng->txt(
'delete_image_header'));
556 $tpl->setVariable(
"DELETE_IMAGE_QUESTION", $lng->txt(
'delete_image_question'));
557 $tpl->setVariable(
"ANSWER_TEXT", $lng->txt(
'answer_text'));
560 $a_tpl->setCurrentBlock(
"prop_generic");
561 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
562 $a_tpl->parseCurrentBlock();
565 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
567 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/singlechoicewizard.js");