4 include_once
"./Modules/TestQuestionPool/classes/class.ilSingleChoiceWizardInputGUI.php";
22 $this->values = array();
23 if (is_array($a_value))
25 if (is_array($a_value[
'answer']))
27 foreach ($a_value[
'answer'] as $index =>
$value)
29 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
31 array_push($this->values, $answer);
46 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
49 if (is_array($foundvalues))
52 if (is_array($foundvalues[
'answer']))
54 foreach ($foundvalues[
'answer'] as $aidx => $answervalue)
56 if (((strlen($answervalue)) == 0) && (strlen($foundvalues[
'imagename'][$aidx]) == 0))
58 $this->
setAlert($lng->txt(
"msg_input_is_required"));
65 if (is_array($foundvalues[
'points']))
67 foreach ($foundvalues[
'points'] as $points)
69 if ($points > $max) $max = $points;
70 if (((strlen($points)) == 0) || (!is_numeric($points)))
72 $this->
setAlert($lng->txt(
"form_msg_numeric_value_required"));
76 foreach ($foundvalues[
'points_unchecked'] as $points)
78 if ($points > $max) $max = $points;
79 if (((strlen($points)) == 0) || (!is_numeric($points)))
81 $this->
setAlert($lng->txt(
"form_msg_numeric_value_required"));
88 $this->
setAlert($lng->txt(
"enter_enough_positive_points"));
92 if (is_array($_FILES) && count($_FILES) && $this->
getSingleline())
94 if (!$this->hideImages)
96 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image']))
98 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as $index => $error)
105 case UPLOAD_ERR_INI_SIZE:
106 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
110 case UPLOAD_ERR_FORM_SIZE:
111 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
115 case UPLOAD_ERR_PARTIAL:
116 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
120 case UPLOAD_ERR_NO_FILE:
123 if ((!strlen($foundvalues[
'imagename'][$index])) && (!strlen($foundvalues[
'answer'][$index])))
125 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
131 case UPLOAD_ERR_NO_TMP_DIR:
132 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
136 case UPLOAD_ERR_CANT_WRITE:
137 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
141 case UPLOAD_ERR_EXTENSION:
142 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
153 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
158 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
160 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
164 $suffix = $filename_arr[
"extension"];
165 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
166 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
168 if (strlen($tmpname) && is_array($this->
getSuffixes()))
172 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
179 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image']))
181 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as $index => $tmpname)
185 $suffix = $filename_arr[
"extension"];
186 $mimetype = $_FILES[$this->
getPostVar()][
'type'][
'image'][$index];
187 $size_bytes = $_FILES[$this->
getPostVar()][
'size'][
'image'][$index];
189 if (strlen($tmpname))
192 if ($vir[0] ==
false)
194 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
205 $this->
setAlert($lng->txt(
"msg_input_is_required"));
221 $tpl =
new ilTemplate(
"tpl.prop_multiplechoicewizardinput.html",
true,
true,
"Modules/TestQuestionPool");
223 foreach ($this->values as
$value)
227 if (!$this->hideImages)
229 if (strlen($value->getImage()))
231 $imagename = $this->qstObject->getImagePathWeb() . $value->getImage();
232 if (($this->
getSingleline()) && ($this->qstObject->getThumbSize()))
234 if (@file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value->getImage()))
236 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value->getImage();
239 $tpl->setCurrentBlock(
'image');
240 $tpl->setVariable(
'SRC_IMAGE', $imagename);
241 $tpl->setVariable(
'IMAGE_NAME', $value->getImage());
243 $tpl->setVariable(
"TXT_DELETE_EXISTING", $lng->txt(
"delete_existing_file"));
244 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
246 if($this->disable_upload)
248 $tpl->setVariable(
'DISABLED_UPLOAD',
'type="hidden" disabled="disabled"');
250 $tpl->parseCurrentBlock();
252 $tpl->setCurrentBlock(
'addimage');
253 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][$i]");
254 $tpl->setVariable(
"IMAGE_SUBMIT", $lng->txt(
"upload"));
255 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $i);
257 if($this->disable_upload)
259 $tpl->setVariable(
'DISABLED_UPLOAD',
'type="hidden" disabled="disabled"');
261 $tpl->parseCurrentBlock();
264 if (is_object($value))
266 $tpl->setCurrentBlock(
"prop_text_propval");
268 $tpl->parseCurrentBlock();
269 $tpl->setCurrentBlock(
"prop_points_propval");
271 $tpl->parseCurrentBlock();
272 $tpl->setCurrentBlock(
"prop_points_unchecked_propval");
274 $tpl->parseCurrentBlock();
276 $tpl->setCurrentBlock(
'singleline');
277 if($this->disable_text)
279 $tpl->setVariable(
"DISABLED_SINGLELINE",
'readonly="readonly"');
280 $tpl->setVariable(
"DISABLED_SINGLELINE_BTN",
'readonly="readonly"');
283 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][$i]");
284 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $i);
289 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
291 $tpl->parseCurrentBlock();
295 if (is_object($value))
297 $tpl->setCurrentBlock(
"prop_points_propval");
299 $tpl->parseCurrentBlock();
300 $tpl->setCurrentBlock(
"prop_points_unchecked_propval");
302 $tpl->parseCurrentBlock();
304 $tpl->setCurrentBlock(
'multiline');
305 if($this->disable_text)
307 $tpl->setVariable(
"DISABLED_MULTILINE",
'readonly="readonly"');
311 $tpl->setVariable(
"MULTILINE_ID", $this->
getPostVar() .
"[answer][$i]");
312 $tpl->setVariable(
"MULTILINE_ROW_NUMBER", $i);
316 $tpl->setVariable(
"DISABLED_MULTILINE",
" disabled=\"disabled\"");
318 $tpl->parseCurrentBlock();
322 $tpl->setCurrentBlock(
"move");
323 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
324 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
328 $tpl->parseCurrentBlock();
330 $tpl->setCurrentBlock(
"row");
331 $class = ($i % 2 == 0) ?
"even" :
"odd";
332 if ($i == 0) $class .=
" first";
333 if ($i == count($this->values)-1) $class .=
" last";
334 $tpl->setVariable(
"ROW_CLASS", $class);
336 $tpl->setVariable(
"ROW_NUMBER", $i);
337 $tpl->setVariable(
"POINTS_ID", $this->
getPostVar() .
"[points][$i]");
338 $tpl->setVariable(
"POINTS_UNCHECKED_ID", $this->
getPostVar() .
"[points_unchecked][$i]");
339 if(!$this->disable_actions)
341 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]" );
342 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]");
347 $tpl->setVariable(
"DISABLED_POINTS",
" disabled=\"disabled\"");
349 if($this->disable_actions)
358 $tpl->parseCurrentBlock();
364 if (!$this->hideImages)
368 $suff_str = $delim =
"";
371 $suff_str.= $delim.
".".
$suffix;
374 $tpl->setCurrentBlock(
'allowed_image_suffixes');
375 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES", $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
376 $tpl->parseCurrentBlock();
379 $tpl->setCurrentBlock(
"image_heading");
380 $tpl->setVariable(
"ANSWER_IMAGE", $lng->txt(
'answer_image'));
382 $tpl->parseCurrentBlock();
387 $tpl->setVariable(
"TEXT_YES", $lng->txt(
'yes'));
388 $tpl->setVariable(
"TEXT_NO", $lng->txt(
'no'));
389 $tpl->setVariable(
"DELETE_IMAGE_HEADER", $lng->txt(
'delete_image_header'));
390 $tpl->setVariable(
"DELETE_IMAGE_QUESTION", $lng->txt(
'delete_image_question'));
391 $tpl->setVariable(
"ANSWER_TEXT", $lng->txt(
'answer_text'));
392 $tpl->setVariable(
"POINTS_TEXT", $lng->txt(
'points'));
393 if(!$this->disable_actions)
395 $tpl->setVariable(
"COMMANDS_TEXT", $lng->txt(
'actions'));
397 $tpl->setVariable(
"POINTS_CHECKED_TEXT", $lng->txt(
'checkbox_checked'));
398 $tpl->setVariable(
"POINTS_UNCHECKED_TEXT", $lng->txt(
'checkbox_unchecked'));
400 $a_tpl->setCurrentBlock(
"prop_generic");
401 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
402 $a_tpl->parseCurrentBlock();
405 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
407 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/multiplechoicewizard.js");