4 require_once
'Modules/TestQuestionPool/classes/class.ilSingleChoiceWizardInputGUI.php';
5 require_once
'Modules/TestQuestionPool/classes/class.ilAssKprimChoiceAnswer.php';
6 require_once
'Services/MediaObjects/classes/class.ilObjMediaObject.php';
49 $this->ignoreMissingUploadsEnabled =
false;
74 $this->values = array();
76 if (is_array($a_value) && is_array($a_value[
'answer'])) {
80 $answer->setPosition(
$index);
81 $answer->setAnswertext(
$value);
82 $answer->setImageFile($a_value[
'imagename'][
$index]);
84 if (strlen($a_value[
'correctness'][$index])) {
85 $answer->setCorrectness((
bool) $a_value[
'correctness'][$index]);
88 $answer->setThumbPrefix($this->qstObject->getThumbPrefix());
89 $answer->setImageFsDir($this->qstObject->getImagePath());
90 $answer->setImageWebDir($this->qstObject->getImagePathWeb());
92 $this->values[] = $answer;
104 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
118 if (is_array($foundvalues)) {
120 if (is_array($foundvalues[
'answer'])) {
121 foreach ($foundvalues[
'answer'] as $aidx => $answervalue) {
122 if (((strlen($answervalue)) == 0) && (strlen($foundvalues[
'imagename'][$aidx]) == 0)) {
130 if (!isset($foundvalues[
'correctness']) || count($foundvalues[
'correctness']) < count($foundvalues[
'answer'])) {
149 public function insert($a_tpl)
151 $tpl =
new ilTemplate(
"tpl.prop_kprimchoicewizardinput.html",
true,
true,
"Modules/TestQuestionPool");
153 foreach ($this->values as
$value) {
159 if (!$this->hideImages) {
160 if (strlen($value->getImageFile())) {
161 $imagename = $value->getImageWebPath();
163 if (($this->
getSingleline()) && ($this->qstObject->getThumbSize())) {
164 if (@file_exists($value->getThumbFsPath())) {
165 $imagename = $value->getThumbWebPath();
169 $tpl->setCurrentBlock(
'image');
170 $tpl->setVariable(
'SRC_IMAGE', $imagename);
171 $tpl->setVariable(
'IMAGE_NAME', $value->getImageFile());
173 $tpl->setVariable(
"TXT_DELETE_EXISTING", $this->lng->txt(
"delete_existing_file"));
174 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $value->getPosition());
176 $tpl->parseCurrentBlock();
178 $tpl->setCurrentBlock(
'addimage');
179 $tpl->setVariable(
"IMAGE_BROWSE", $this->lng->txt(
'select_file'));
180 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][{$value->getPosition()}]");
181 $tpl->setVariable(
"IMAGE_SUBMIT", $this->lng->txt(
"upload"));
182 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $value->getPosition());
184 $tpl->parseCurrentBlock();
187 $tpl->setCurrentBlock(
"prop_text_propval");
189 $tpl->parseCurrentBlock();
191 $tpl->setCurrentBlock(
'singleline');
193 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][{$value->getPosition()}]");
194 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $value->getPosition());
198 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
200 $tpl->parseCurrentBlock();
202 $tpl->setCurrentBlock(
'multiline');
204 $tpl->setVariable(
"MULTILINE_ID", $this->
getPostVar() .
"[answer][{$value->getPosition()}]");
205 $tpl->setVariable(
"MULTILINE_ROW_NUMBER", $value->getPosition());
208 $tpl->setVariable(
"DISABLED_MULTILINE",
" disabled=\"disabled\"");
210 $tpl->parseCurrentBlock();
213 $tpl->setCurrentBlock(
"move");
214 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][{$value->getPosition()}]");
215 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][{$value->getPosition()}]");
216 $tpl->setVariable(
"UP_ID",
"up_{$this->getPostVar()}[{$value->getPosition()}]");
217 $tpl->setVariable(
"DOWN_ID",
"down_{$this->getPostVar()}[{$value->getPosition()}]");
220 $tpl->parseCurrentBlock();
223 $tpl->setCurrentBlock(
"row");
226 $tpl->setVariable(
"ROW_NUMBER", $value->getPosition());
227 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[answer][{$value->getPosition()}]");
230 "CORRECTNESS_TRUE_ID",
231 $this->
getPostVar() .
"[correctness][{$value->getPosition()}][true]" 234 "CORRECTNESS_FALSE_ID",
235 $this->
getPostVar() .
"[correctness][{$value->getPosition()}][false]" 237 $tpl->setVariable(
"CORRECTNESS_TRUE_VALUE", 1);
238 $tpl->setVariable(
"CORRECTNESS_FALSE_VALUE", 0);
240 if ($value->getCorrectness() !== null) {
241 if ($value->getCorrectness()) {
242 $tpl->setVariable(
'CORRECTNESS_TRUE_SELECTED',
' checked="checked"');
244 $tpl->setVariable(
'CORRECTNESS_FALSE_SELECTED',
' checked="checked"');
249 $tpl->setVariable(
"DISABLED_CORRECTNESS",
" disabled=\"disabled\"");
252 $tpl->parseCurrentBlock();
256 if (!$this->hideImages) {
258 $suff_str = $delim =
"";
260 $suff_str .= $delim .
"." .
$suffix;
263 $tpl->setCurrentBlock(
'allowed_image_suffixes');
264 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES", $this->lng->txt(
"file_allowed_suffixes") .
" " . $suff_str);
265 $tpl->parseCurrentBlock();
268 $tpl->setCurrentBlock(
"image_heading");
269 $tpl->setVariable(
"ANSWER_IMAGE", $this->lng->txt(
'answer_image'));
271 $tpl->parseCurrentBlock();
275 foreach ($this->qstObject->getValidOptionLabels() as $optionLabel) {
276 if ($this->qstObject->isCustomOptionLabel($optionLabel)) {
280 $tpl->setCurrentBlock(
'option_label_translations');
281 $tpl->setVariable(
'OPTION_LABEL', $optionLabel);
282 $tpl->setVariable(
'TRANSLATION_TRUE', $this->qstObject->getTrueOptionLabelTranslation($this->lng, $optionLabel));
283 $tpl->setVariable(
'TRANSLATION_FALSE', $this->qstObject->getFalseOptionLabelTranslation($this->lng, $optionLabel));
284 $tpl->parseCurrentBlock();
288 $tpl->setVariable(
"DELETE_IMAGE_HEADER", $this->lng->txt(
'delete_image_header'));
289 $tpl->setVariable(
"DELETE_IMAGE_QUESTION", $this->lng->txt(
'delete_image_question'));
290 $tpl->setVariable(
"ANSWER_TEXT", $this->lng->txt(
'answer_text'));
292 $tpl->setVariable(
"OPTIONS_TEXT", $this->lng->txt(
'options'));
298 $a_tpl->setCurrentBlock(
"prop_generic");
299 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
300 $a_tpl->parseCurrentBlock();
302 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
303 $this->tpl->addJavascript(
"./Services/Form/js/ServiceFormWizardInput.js");
304 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/kprimchoicewizard.js");
305 $this->tpl->addJavascript(
'Modules/TestQuestionPool/js/ilAssKprimChoice.js');
310 if (is_array($_FILES) && count($_FILES) && $this->
getSingleline()) {
311 if (!$this->hideImages) {
312 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image'])) {
313 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as
$index => $error) {
317 case UPLOAD_ERR_INI_SIZE:
318 $this->
setAlert($this->lng->txt(
"form_msg_file_size_exceeds"));
322 case UPLOAD_ERR_FORM_SIZE:
323 $this->
setAlert($this->lng->txt(
"form_msg_file_size_exceeds"));
327 case UPLOAD_ERR_PARTIAL:
328 $this->
setAlert($this->lng->txt(
"form_msg_file_partially_uploaded"));
332 case UPLOAD_ERR_NO_FILE:
334 if ((!strlen($foundvalues[
'imagename'][
$index])) && (!strlen($foundvalues[
'answer'][$index]))) {
335 $this->
setAlert($this->lng->txt(
"form_msg_file_no_upload"));
341 case UPLOAD_ERR_NO_TMP_DIR:
342 $this->
setAlert($this->lng->txt(
"form_msg_file_missing_tmp_dir"));
346 case UPLOAD_ERR_CANT_WRITE:
347 $this->
setAlert($this->lng->txt(
"form_msg_file_cannot_write_to_disk"));
351 case UPLOAD_ERR_EXTENSION:
352 $this->
setAlert($this->lng->txt(
"form_msg_file_upload_stopped_ext"));
360 $this->
setAlert($this->lng->txt(
"form_msg_file_no_upload"));
365 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
366 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as
$index => $tmpname) {
369 $suffix = $filename_arr[
"extension"];
373 if (strlen($tmpname) && is_array($this->
getSuffixes())) {
375 $this->
setAlert($this->lng->txt(
"form_msg_file_wrong_file_type"));
382 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
383 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as
$index => $tmpname) {
390 if (!preg_match(
"/^image/", $mimetype)) {
391 $_FILES[$this->
getPostVar()][
'error'][
'image'][
$index] = self::CUSTOM_UPLOAD_ERR;
392 $this->
setAlert($this->lng->txt(
"form_msg_file_wrong_mime_type"));
399 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
400 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as
$index => $tmpname) {
403 $suffix = $filename_arr[
"extension"];
407 if (strlen($tmpname)) {
409 if ($vir[0] ==
false) {
410 $_FILES[$this->
getPostVar()][
'error'][
'image'][
$index] = self::CUSTOM_UPLOAD_ERR;
411 $this->
setAlert($this->lng->txt(
"form_msg_file_virus_found") .
"<br />" . $vir[1]);
425 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as
$index => $err) {
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.
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
__construct(Container $dic, ilPlugin $plugin)