19 require_once
'Modules/TestQuestionPool/classes/class.ilSingleChoiceWizardInputGUI.php';
20 require_once
'Modules/TestQuestionPool/classes/class.ilAssKprimChoiceAnswer.php';
21 require_once
'Services/MediaObjects/classes/class.ilObjMediaObject.php';
60 $this->ignoreMissingUploadsEnabled =
false;
87 $is_rte = isset($_POST[
"answer_type"]) && $_POST[
"answer_type"] ==
"multiLine";
90 if (is_array($a_value) && is_array($a_value[
'answer'])) {
94 $answer->setPosition(
$index);
95 $answer->setAnswertext(
$value);
96 if (isset($a_value[
'imagename'])) {
97 $answer->setImageFile($a_value[
'imagename'][
$index] ??
'');
100 if (isset($a_value[
'correctness']) && isset($a_value[
'correctness'][
$index]) && strlen($a_value[
'correctness'][$index])) {
101 $answer->setCorrectness((
bool) $a_value[
'correctness'][$index]);
104 $answer->setThumbPrefix($this->qstObject->getThumbPrefix());
105 $answer->setImageFsDir($this->qstObject->getImagePath());
106 $answer->setImageWebDir($this->qstObject->getImagePathWeb());
108 $this->values[] = $answer;
120 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
131 if (is_array($foundvalues)) {
133 if (is_array($foundvalues[
'answer'])) {
134 foreach ($foundvalues[
'answer'] as $aidx => $answervalue) {
135 $hasImage = isset($foundvalues[
'imagename']) ? true :
false;
136 if (((strlen($answervalue)) == 0) && !$hasImage) {
149 if (!isset($foundvalues[
'correctness']) || count($foundvalues[
'correctness']) < count($foundvalues[
'answer'])) {
170 $tpl =
new ilTemplate(
"tpl.prop_kprimchoicewizardinput.html",
true,
true,
"Modules/TestQuestionPool");
172 foreach ($this->values as
$value) {
178 if (!$this->hideImages) {
179 if (strlen($value->getImageFile())) {
180 $imagename = $value->getImageWebPath();
182 if (($this->
getSingleline()) && ($this->qstObject->getThumbSize())) {
183 if (@file_exists($value->getThumbFsPath())) {
184 $imagename = $value->getThumbWebPath();
188 $tpl->setCurrentBlock(
'image');
189 $tpl->setVariable(
'SRC_IMAGE', $imagename);
190 $tpl->setVariable(
'IMAGE_NAME', $value->getImageFile());
195 $tpl->setVariable(
"TXT_DELETE_EXISTING", $this->
lng->txt(
"delete_existing_file"));
196 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $value->getPosition());
198 $tpl->parseCurrentBlock();
200 $tpl->setCurrentBlock(
'addimage');
201 $tpl->setVariable(
"IMAGE_BROWSE", $this->
lng->txt(
'select_file'));
202 $tpl->setVariable(
"IMAGE_ID", $this->
getPostVar() .
"[image][{$value->getPosition()}]");
203 $tpl->setVariable(
"IMAGE_SUBMIT", $this->
lng->txt(
"upload"));
204 $tpl->setVariable(
"IMAGE_ROW_NUMBER", $value->getPosition());
206 $tpl->parseCurrentBlock();
209 $tpl->setCurrentBlock(
"prop_text_propval");
214 $tpl->parseCurrentBlock();
216 $tpl->setCurrentBlock(
'singleline');
218 $tpl->setVariable(
"SINGLELINE_ID", $this->
getPostVar() .
"[answer][{$value->getPosition()}]");
219 $tpl->setVariable(
"SINGLELINE_ROW_NUMBER", $value->getPosition());
223 $tpl->setVariable(
"DISABLED_SINGLELINE",
" disabled=\"disabled\"");
225 $tpl->parseCurrentBlock();
227 $tpl->setCurrentBlock(
'multiline');
232 $tpl->setVariable(
"MULTILINE_ID", $this->
getPostVar() .
"[answer][{$value->getPosition()}]");
233 $tpl->setVariable(
"MULTILINE_ROW_NUMBER", $value->getPosition());
237 $tpl->setVariable(
"DISABLED_MULTILINE",
" disabled=\"disabled\"");
239 $tpl->parseCurrentBlock();
242 $tpl->setCurrentBlock(
"move");
243 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][{$value->getPosition()}]");
244 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][{$value->getPosition()}]");
245 $tpl->setVariable(
"UP_ID",
"up_{$this->getPostVar()}[{$value->getPosition()}]");
246 $tpl->setVariable(
"DOWN_ID",
"down_{$this->getPostVar()}[{$value->getPosition()}]");
249 $tpl->parseCurrentBlock();
252 $tpl->setCurrentBlock(
"row");
255 $tpl->setVariable(
"ROW_NUMBER", $value->getPosition());
256 $tpl->setVariable(
"ID", $this->
getPostVar() .
"[answer][{$value->getPosition()}]");
259 "CORRECTNESS_TRUE_ID",
260 $this->
getPostVar() .
"[correctness][{$value->getPosition()}][true]" 263 "CORRECTNESS_FALSE_ID",
264 $this->
getPostVar() .
"[correctness][{$value->getPosition()}][false]" 266 $tpl->setVariable(
"CORRECTNESS_TRUE_VALUE", 1);
267 $tpl->setVariable(
"CORRECTNESS_FALSE_VALUE", 0);
269 if ($value->getCorrectness() !== null) {
270 if ($value->getCorrectness()) {
271 $tpl->setVariable(
'CORRECTNESS_TRUE_SELECTED',
' checked="checked"');
273 $tpl->setVariable(
'CORRECTNESS_FALSE_SELECTED',
' checked="checked"');
278 $tpl->setVariable(
"DISABLED_CORRECTNESS",
" disabled=\"disabled\"");
281 $tpl->parseCurrentBlock();
285 if (!$this->hideImages) {
287 $suff_str = $delim =
"";
289 $suff_str .= $delim .
"." .
$suffix;
292 $tpl->setCurrentBlock(
'allowed_image_suffixes');
293 $tpl->setVariable(
"TXT_ALLOWED_SUFFIXES", $this->
lng->txt(
"file_allowed_suffixes") .
" " . $suff_str);
294 $tpl->parseCurrentBlock();
297 $tpl->setCurrentBlock(
"image_heading");
298 $tpl->setVariable(
"ANSWER_IMAGE", $this->
lng->txt(
'answer_image'));
300 $tpl->parseCurrentBlock();
304 foreach ($this->qstObject->getValidOptionLabels() as $optionLabel) {
305 if ($this->qstObject->isCustomOptionLabel($optionLabel)) {
309 $tpl->setCurrentBlock(
'option_label_translations');
310 $tpl->setVariable(
'OPTION_LABEL', $optionLabel);
311 $tpl->setVariable(
'TRANSLATION_TRUE', $this->qstObject->getTrueOptionLabelTranslation($this->lng, $optionLabel));
312 $tpl->setVariable(
'TRANSLATION_FALSE', $this->qstObject->getFalseOptionLabelTranslation($this->lng, $optionLabel));
313 $tpl->parseCurrentBlock();
317 $tpl->setVariable(
"DELETE_IMAGE_HEADER", $this->
lng->txt(
'delete_image_header'));
318 $tpl->setVariable(
"DELETE_IMAGE_QUESTION", $this->
lng->txt(
'delete_image_question'));
319 $tpl->setVariable(
"ANSWER_TEXT", $this->
lng->txt(
'answer_text'));
321 $tpl->setVariable(
"OPTIONS_TEXT", $this->
lng->txt(
'options'));
331 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
332 $this->tpl->addJavascript(
"./Services/Form/js/ServiceFormWizardInput.js");
333 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/kprimchoicewizard.js");
334 $this->tpl->addJavascript(
'Modules/TestQuestionPool/js/ilAssKprimChoice.js');
339 if (is_array($_FILES) && count($_FILES) && $this->
getSingleline()) {
340 if (!$this->hideImages) {
341 if (is_array($_FILES[$this->
getPostVar()][
'error'][
'image'])) {
342 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as
$index => $error) {
346 case UPLOAD_ERR_FORM_SIZE:
347 case UPLOAD_ERR_INI_SIZE:
348 $this->
setAlert($this->
lng->txt(
"form_msg_file_size_exceeds"));
352 case UPLOAD_ERR_PARTIAL:
353 $this->
setAlert($this->
lng->txt(
"form_msg_file_partially_uploaded"));
357 case UPLOAD_ERR_NO_FILE:
359 $has_image = isset($foundvalues[
'imagename'][
$index]) ? true :
false;
360 if (!$has_image && (!strlen($foundvalues[
'answer'][$index]))) {
361 $this->
setAlert($this->
lng->txt(
"form_msg_file_no_upload"));
367 case UPLOAD_ERR_NO_TMP_DIR:
368 $this->
setAlert($this->
lng->txt(
"form_msg_file_missing_tmp_dir"));
372 case UPLOAD_ERR_CANT_WRITE:
373 $this->
setAlert($this->
lng->txt(
"form_msg_file_cannot_write_to_disk"));
377 case UPLOAD_ERR_EXTENSION:
378 $this->
setAlert($this->
lng->txt(
"form_msg_file_upload_stopped_ext"));
386 $this->
setAlert($this->
lng->txt(
"form_msg_file_no_upload"));
391 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
392 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as
$index => $tmpname) {
395 if (isset($filename_arr[
"extension"])) {
396 $suffix = $filename_arr[
"extension"];
400 if (strlen($tmpname) && is_array($this->
getSuffixes())) {
402 $this->
setAlert($this->
lng->txt(
"form_msg_file_wrong_file_type"));
410 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
411 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as
$index => $tmpname) {
418 if (!preg_match(
"/^image/", $mimetype)) {
419 $_FILES[$this->
getPostVar()][
'error'][
'image'][
$index] = self::CUSTOM_UPLOAD_ERR;
420 $this->
setAlert($this->
lng->txt(
"form_msg_file_wrong_mime_type"));
427 if (is_array($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'])) {
428 foreach ($_FILES[$this->
getPostVar()][
'tmp_name'][
'image'] as
$index => $tmpname) {
431 if (isset($filename_arr[
"extension"])) {
432 $suffix = $filename_arr[
"extension"];
436 if (strlen($tmpname)) {
438 if ($vir[0] ==
false) {
439 $_FILES[$this->
getPostVar()][
'error'][
'image'][
$index] = self::CUSTOM_UPLOAD_ERR;
440 $this->
setAlert($this->
lng->txt(
"form_msg_file_virus_found") .
"<br />" . $vir[1]);
455 foreach ($_FILES[$this->
getPostVar()][
'error'][
'image'] as
$index => $err) {
460 $this->files[
$index] = array(
476 if (!is_array($answer_text)) {
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static get(string $a_glyph, string $a_text="")
static virusHandling(string $a_file, string $a_orig_name='', bool $a_clean=true)
setVariable($variable, $value='')
Sets a variable value.
static _getUsedHTMLTagsAsString(string $a_module="")
Returns a string of all allowed HTML tags for text editing.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
const ALLOWED_PLAIN_TEXT_TAGS
sk - 12.05.2023: This const is also used in ilKprimChoiceWizardInputGUI.
__construct(Container $dic, ilPlugin $plugin)