24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
25 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
54 include_once
"./Modules/TestQuestionPool/classes/class.assMultipleChoice.php";
58 $this->
object->loadFromDb($id);
64 if (substr(
$cmd, 0, 6) ==
"upload")
68 if (substr(
$cmd, 0, 11) ==
"deleteImage")
86 $this->tpl->addJavascript(
"./Services/JavaScript/js/Basic.js");
87 $javascript =
"<script type=\"text/javascript\">ilAddOnLoad(initialSelect);\n".
88 "function initialSelect() {\n%s\n}</script>";
89 $graphical_answer_setting = $this->
object->getGraphicalAnswerSetting();
90 $multiline_answers = $this->
object->getMultilineAnswerSetting();
91 if ($graphical_answer_setting == 0)
93 for ($i = 0; $i < $this->
object->getAnswerCount(); $i++)
95 $answer = $this->
object->getAnswer($i);
96 if (strlen($answer->getImage())) $graphical_answer_setting = 1;
100 $this->tpl->addBlockFile(
"QUESTION_DATA",
"question_data",
"tpl.il_as_qpl_mc_mr.html",
"Modules/TestQuestionPool");
102 if ($this->object->getAnswerCount() > 0)
104 $this->tpl->setCurrentBlock(
"answersheading");
105 $this->tpl->setVariable(
"TEXT_POINTS_CHECKED", $this->lng->txt(
"points_checked"));
106 $this->tpl->setVariable(
"TEXT_POINTS_UNCHECKED", $this->lng->txt(
"points_unchecked"));
107 $this->tpl->setVariable(
"TEXT_ANSWER_TEXT", $this->lng->txt(
"answer_text"));
108 $this->tpl->parseCurrentBlock();
109 $this->tpl->setCurrentBlock(
"selectall");
110 $this->tpl->setVariable(
"SELECT_ALL", $this->lng->txt(
"select_all"));
111 $this->tpl->parseCurrentBlock();
112 $this->tpl->setCurrentBlock(
"existinganswers");
113 $this->tpl->setVariable(
"DELETE", $this->lng->txt(
"delete"));
114 $this->tpl->setVariable(
"MOVE", $this->lng->txt(
"move"));
115 $this->tpl->setVariable(
"ARROW",
"<img src=\"" .
ilUtil::getImagePath(
"arrow_downright.gif") .
"\" alt=\"".$this->lng->txt(
"arrow_downright").
"\">");
116 $this->tpl->parseCurrentBlock();
118 for ($i = 0; $i < $this->
object->getAnswerCount(); $i++)
120 $answer = $this->
object->getAnswer($i);
121 if ($graphical_answer_setting == 1)
123 $imagefilename = $this->
object->getImagePath() . $answer->getImage();
124 if (!@file_exists($imagefilename))
126 $answer->setImage(
"");
128 if (strlen($answer->getImage()))
130 $imagepath = $this->
object->getImagePathWeb() . $answer->getImage();
131 $this->tpl->setCurrentBlock(
"graphical_answer_image");
132 $this->tpl->setVariable(
"IMAGE_FILE", $imagepath);
133 if (strlen($answer->getAnswertext()))
139 $this->tpl->setVariable(
"IMAGE_ALT", $this->lng->txt(
"image"));
141 $this->tpl->setVariable(
"ANSWER_ORDER", $answer->getOrder());
142 $this->tpl->setVariable(
"DELETE_IMAGE", $this->lng->txt(
"delete_image"));
143 $this->tpl->parseCurrentBlock();
145 $this->tpl->setCurrentBlock(
"graphical_answer");
146 $this->tpl->setVariable(
"ANSWER_ORDER", $answer->getOrder());
147 $this->tpl->setVariable(
"UPLOAD_IMAGE", $this->lng->txt(
"upload_image"));
148 $this->tpl->setVariable(
"VALUE_IMAGE", $answer->getImage());
149 $this->tpl->parseCurrentBlock();
151 if ($multiline_answers)
153 $this->tpl->setCurrentBlock(
"show_textarea");
154 $this->tpl->setVariable(
"ANSWER_ANSWER_ORDER", $answer->getOrder());
156 $this->tpl->parseCurrentBlock();
160 $this->tpl->setCurrentBlock(
"show_textinput");
161 $this->tpl->setVariable(
"ANSWER_ANSWER_ORDER", $answer->getOrder());
163 $this->tpl->parseCurrentBlock();
165 $this->tpl->setCurrentBlock(
"answers");
166 $this->tpl->setVariable(
"VALUE_MULTIPLE_CHOICE_POINTS_CHECKED", $answer->getPoints());
167 $this->tpl->setVariable(
"VALUE_MULTIPLE_CHOICE_POINTS_UNCHECKED", $answer->getPointsUnchecked());
168 $this->tpl->setVariable(
"ANSWER_ORDER", $answer->getOrder());
169 $this->tpl->parseCurrentBlock();
175 $internallinks = array(
176 "lm" => $this->lng->txt(
"obj_lm"),
177 "st" => $this->lng->txt(
"obj_st"),
178 "pg" => $this->lng->txt(
"obj_pg"),
179 "glo" => $this->lng->txt(
"glossary_term")
181 foreach ($internallinks as $key => $value)
183 $this->tpl->setCurrentBlock(
"internallink");
184 $this->tpl->setVariable(
"TYPE_INTERNAL_LINK", $key);
185 $this->tpl->setVariable(
"TEXT_INTERNAL_LINK", $value);
186 $this->tpl->parseCurrentBlock();
189 $this->tpl->setCurrentBlock(
"HeadContent");
191 if ($this->object->getAnswerCount() == 0)
193 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_multiple_choice.title.focus();"));
197 switch ($this->ctrl->getCmd())
200 $nrOfAnswers = $_POST[
"nrOfAnswers"];
201 if ((strcmp($nrOfAnswers,
"yn") == 0) || (strcmp($nrOfAnswers,
"tf") == 0)) $nrOfAnswers = 2;
202 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_multiple_choice.answer_".($this->object->getAnswerCount() - $nrOfAnswers).
".focus(); document.getElementById('answer_".($this->object->getAnswerCount() - $nrOfAnswers).
"').scrollIntoView(\"true\");"));
205 if ($this->object->getAnswerCount() == 0)
207 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_multiple_choice.title.focus();"));
211 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_multiple_choice.answer_".($this->object->getAnswerCount() - 1).
".focus(); document.getElementById('answer_".($this->object->getAnswerCount() - 1).
"').scrollIntoView(\"true\");"));
215 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_multiple_choice.title.focus();"));
219 $this->tpl->parseCurrentBlock();
221 for ($i = 1; $i < 10; $i++)
223 $this->tpl->setCurrentBlock(
"numbers");
224 $this->tpl->setVariable(
"VALUE_NUMBER", $i);
227 $this->tpl->setVariable(
"TEXT_NUMBER", $i .
" " . $this->lng->txt(
"answer"));
231 $this->tpl->setVariable(
"TEXT_NUMBER", $i .
" " . $this->lng->txt(
"answers"));
233 $this->tpl->parseCurrentBlock();
236 $this->tpl->setCurrentBlock(
"question_data");
237 $this->tpl->setVariable(
"TEXT_TITLE", $this->lng->txt(
"title"));
238 $this->tpl->setVariable(
"TEXT_AUTHOR", $this->lng->txt(
"author"));
239 $this->tpl->setVariable(
"TEXT_COMMENT", $this->lng->txt(
"description"));
240 $this->tpl->setVariable(
"TEXT_QUESTION", $this->lng->txt(
"question"));
241 $this->tpl->setVariable(
"MULTIPLE_CHOICE_ID", $this->object->getId());
245 $this->tpl->setVariable(
"TEXT_GRAPHICAL_ANSWERS", $this->lng->txt(
"graphical_answers"));
246 $this->tpl->setVariable(
"TEXT_HIDE_GRAPHICAL_ANSWER_SUPPORT", $this->lng->txt(
"graphical_answers_hide"));
247 $this->tpl->setVariable(
"TEXT_SHOW_GRAPHICAL_ANSWER_SUPPORT", $this->lng->txt(
"graphical_answers_show"));
248 if ($this->object->getGraphicalAnswerSetting() == 1)
250 $this->tpl->setVariable(
"SELECTED_SHOW_GRAPHICAL_ANSWER_SUPPORT",
" selected=\"selected\"");
252 if ($multiline_answers)
254 $this->tpl->setVariable(
"SELECTED_SHOW_MULTILINE_ANSWERS",
" selected=\"selected\"");
256 $this->tpl->setVariable(
"TEXT_HIDE_MULTILINE_ANSWERS", $this->lng->txt(
"multiline_answers_hide"));
257 $this->tpl->setVariable(
"TEXT_SHOW_MULTILINE_ANSWERS", $this->lng->txt(
"multiline_answers_show"));
258 $this->tpl->setVariable(
"SET_EDIT_MODE", $this->lng->txt(
"set_edit_mode"));
259 $questiontext = $this->
object->getQuestion();
260 $this->tpl->setVariable(
"VALUE_QUESTION",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
261 $this->tpl->setVariable(
"VALUE_ADD_ANSWER", $this->lng->txt(
"add"));
262 $this->tpl->setVariable(
"TEXT_SHUFFLE_ANSWERS", $this->lng->txt(
"shuffle_answers"));
263 $this->tpl->setVariable(
"TXT_YES", $this->lng->txt(
"yes"));
264 $this->tpl->setVariable(
"TXT_NO", $this->lng->txt(
"no"));
265 if ($this->object->getShuffle())
267 $this->tpl->setVariable(
"SELECTED_YES",
" selected=\"selected\"");
271 $this->tpl->setVariable(
"SELECTED_NO",
" selected=\"selected\"");
273 $this->tpl->setVariable(
"TEXT_SOLUTION_HINT", $this->lng->txt(
"solution_hint"));
274 if (count($this->object->suggested_solutions))
276 $solution_array = $this->
object->getSuggestedSolution(0);
277 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
279 $this->tpl->setVariable(
"TEXT_VALUE_SOLUTION_HINT",
" <a href=\"$href\" target=\"content\">" . $this->lng->txt(
"solution_hint").
"</a> ");
280 $this->tpl->setVariable(
"BUTTON_REMOVE_SOLUTION", $this->lng->txt(
"remove"));
281 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"change"));
282 $this->tpl->setVariable(
"VALUE_SOLUTION_HINT", $solution_array[
"internal_link"]);
286 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"add"));
288 $this->tpl->setVariable(
"SAVE",$this->lng->txt(
"save"));
289 $this->tpl->setVariable(
"SAVE_EDIT", $this->lng->txt(
"save_edit"));
290 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
291 $this->tpl->setVariable(
"CANCEL", $this->lng->txt(
"cancel"));
292 $this->ctrl->setParameter($this,
"sel_question_types",
"assMultipleChoice");
293 $this->tpl->setVariable(
"ACTION_MULTIPLE_CHOICE_TEST", $this->ctrl->getFormAction($this));
294 $this->tpl->setVariable(
"TEXT_QUESTION_TYPE", $this->
outQuestionType());
295 $this->tpl->parseCurrentBlock();
297 include_once
"./Services/RTE/classes/class.ilRTE.php";
299 include_once
"./Services/RTE/classes/class.$rtestring.php";
300 $rte =
new $rtestring();
301 $rte->addPlugin(
"latex");
302 $rte->addButton(
"latex"); $rte->addButton(
"pastelatex");
303 include_once
"./classes/class.ilObject.php";
304 $obj_id =
$_GET[
"q_id"];
306 $rte->addRTESupport($obj_id, $obj_type,
"assessment");
307 $this->tpl->setCurrentBlock(
"adm_content");
309 $this->tpl->parseCurrentBlock();
322 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
327 $nrOfAnswers = $_POST[
"nrOfAnswers"];
328 switch ($nrOfAnswers)
332 $this->
object->addAnswer(
333 $this->lng->txt(
"true"),
336 count($this->object->answers),
339 $this->
object->addAnswer(
340 $this->lng->txt(
"false"),
343 count($this->object->answers),
349 $this->
object->addAnswer(
350 $this->lng->txt(
"yes"),
353 count($this->object->answers),
356 $this->
object->addAnswer(
357 $this->lng->txt(
"no"),
360 count($this->object->answers),
365 for ($i = 0; $i < $nrOfAnswers; $i++)
367 $this->
object->addAnswer(
371 count($this->object->answers),
388 $answers = $_POST[
"chb_answers"];
389 if (is_array($answers))
392 foreach ($answers as $answer)
394 $this->
object->deleteAnswer($answer);
405 $cmd = $this->ctrl->getCmd();
407 if ((!$_POST[
"title"]) or (!$_POST[
"author"]) or (!$_POST[
"question"]))
412 foreach ($_POST as $key => $value)
414 if (preg_match(
"/answer_(\d+)/", $key, $matches))
416 if (strlen($value) == 0)
418 if (strlen($_POST[
"uploaded_image_".$matches[1]]) == 0)
442 if ((!$_POST[
"title"]) or (!$_POST[
"author"]) or (!$_POST[
"question"]))
447 if ((
$result) and (($_POST[
"cmd"][
"add"]) or ($_POST[
"cmd"][
"add_tf"]) or ($_POST[
"cmd"][
"add_yn"])))
450 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
451 $_POST[
"cmd"][
"add"] =
"";
452 $_POST[
"cmd"][
"add_yn"] =
"";
453 $_POST[
"cmd"][
"add_tf"] =
"";
457 if ($_POST[
"cmd"][
"add"] or $_POST[
"cmd"][
"add_yn"] or $_POST[
"cmd"][
"add_tf"])
459 foreach ($_POST as $key => $value)
461 if (preg_match(
"/answer_(\d+)/", $key, $matches))
465 $_POST[
"cmd"][
"add"] =
"";
466 $_POST[
"cmd"][
"add_yn"] =
"";
467 $_POST[
"cmd"][
"add_tf"] =
"";
477 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
479 $this->
object->setQuestion($questiontext);
480 $this->
object->setSuggestedSolution($_POST[
"solution_hint"], 0);
481 $this->
object->setShuffle($_POST[
"shuffle"]);
484 $this->
object->setMultilineAnswerSetting($_POST[
"multilineAnswers"]);
485 $this->
object->setGraphicalAnswerSetting($_POST[
"graphicalAnswerSupport"]);
488 $this->
object->flushAnswers();
489 $graphical_answer_setting = $this->
object->getGraphicalAnswerSetting();
491 foreach ($_POST as $key => $value)
493 if (preg_match(
"/answer_(\d+)/", $key, $matches))
495 $answer_image = $_POST[
"uploaded_image_".$matches[1]];
496 if ($graphical_answer_setting == 1)
498 foreach ($_FILES as $key2 => $value2)
500 if (preg_match(
"/image_(\d+)/", $key2, $matches2))
502 if ($matches[1] == $matches2[1])
504 if ($value2[
"tmp_name"])
507 if ($this->object->getId() <= 0)
509 $this->
object->saveToDb();
511 $this->error .= $this->lng->txt(
"question_saved_for_upload") .
"<br />";
513 $value2[
'name'] = $this->
object->createNewImageFileName($value2[
'name']);
514 $upload_result = $this->
object->setImageFile($value2[
'name'], $value2[
'tmp_name']);
515 switch ($upload_result)
518 $_POST[
"image_".$matches2[1]] = $value2[
'name'];
519 $answer_image = $value2[
'name'];
522 $this->error .= $this->lng->txt(
"error_image_upload_wrong_format") .
"<br />";
525 $this->error .= $this->lng->txt(
"error_image_upload_copy_file") .
"<br />";
533 $points = $_POST[
"points_checked_$matches[1]"];
534 $points_unchecked = $_POST[
"points_unchecked_$matches[1]"];
536 $this->
object->addAnswer(
546 if ($this->object->getMaximumPoints() < 0)
549 $this->
setErrorMessage($this->lng->txt(
"enter_enough_positive_points"));
553 if ($_POST[
"multiple_choice_id"] > 0)
555 $this->
object->setId($_POST[
"multiple_choice_id"]);
564 $this->
object->saveToDb();
565 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
571 function outQuestionForTest($formaction, $active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
573 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions, $show_feedback);
574 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
575 $this->tpl->setVariable(
"FORMACTION", $formaction);
578 function getSolutionOutput($active_id,
$pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE, $show_correct_solution = FALSE)
584 $user_solution = array();
585 if (($active_id > 0) && (!$show_correct_solution))
587 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
588 foreach ($solutions as $idx => $solution_value)
590 array_push($user_solution, $solution_value[
"value1"]);
596 foreach ($this->object->answers as $index => $answer)
598 $points_checked = $answer->getPointsChecked();
599 $points_unchecked = $answer->getPointsUnchecked();
600 if ($points_checked > $points_unchecked)
602 if ($points_checked > 0)
604 array_push($user_solution, $index);
611 include_once
"./classes/class.ilTemplate.php";
612 $template =
new ilTemplate(
"tpl.il_as_qpl_mc_mr_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
613 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
614 foreach ($keys as $answer_id)
616 $answer = $this->
object->answers[$answer_id];
617 if (($active_id > 0) && (!$show_correct_solution))
619 if ($graphicalOutput)
624 foreach ($user_solution as $mc_solution)
626 if (strcmp($mc_solution, $answer_id) == 0)
633 if ($answer->getPointsChecked() > $answer->getPointsUnchecked())
644 if ($answer->getPointsChecked() > $answer->getPointsUnchecked())
655 $template->setCurrentBlock(
"icon_ok");
657 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
658 $template->parseCurrentBlock();
662 $template->setCurrentBlock(
"icon_ok");
664 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
665 $template->parseCurrentBlock();
669 if (strlen($answer->getImage()))
671 $template->setCurrentBlock(
"answer_image");
672 $template->setVariable(
"ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
673 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
674 $alt = $answer->getImage();
675 if (strlen($answer->getAnswertext()))
677 $alt = $answer->getAnswertext();
679 $alt = preg_replace(
"/<[^>]*?>/",
"", $alt);
680 $template->setVariable(
"ATTR", $attr);
683 $template->parseCurrentBlock();
687 foreach ($user_solution as $mc_solution)
689 if (strcmp($mc_solution, $answer_id) == 0)
691 $fb = $this->
object->getFeedbackSingleAnswer($answer_id);
694 $template->setCurrentBlock(
"feedback");
695 $template->setVariable(
"FEEDBACK", $fb);
696 $template->parseCurrentBlock();
701 $template->setCurrentBlock(
"answer_row");
702 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
706 $pointschecked = $this->
object->answers[$answer_id]->getPointsChecked();
707 $pointsunchecked = $this->
object->answers[$answer_id]->getPointsUnchecked();
708 $resulttextchecked = ($pointschecked == 1) || ($pointschecked == -1) ?
"%s " . $this->lng->txt(
"point") :
"%s " . $this->lng->txt(
"points");
709 $resulttextunchecked = ($pointsunchecked == 1) || ($pointsunchecked == -1) ?
"%s " . $this->lng->txt(
"point") :
"%s " . $this->lng->txt(
"points");
710 $template->setVariable(
"RESULT_OUTPUT", sprintf(
"(" . $this->lng->txt(
"checkbox_checked") .
" = $resulttextchecked, " . $this->lng->txt(
"checkbox_unchecked") .
" = $resulttextunchecked)", $pointschecked, $pointsunchecked));
712 foreach ($user_solution as $mc_solution)
714 if (strcmp($mc_solution, $answer_id) == 0)
717 $template->setVariable(
"SOLUTION_ALT", $this->lng->txt(
"checked"));
724 $template->setVariable(
"SOLUTION_ALT", $this->lng->txt(
"unchecked"));
726 $template->parseCurrentBlock();
728 $questiontext = $this->
object->getQuestion();
729 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
730 $questionoutput = $template->get();
732 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
733 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
735 $solutionoutput = $solutiontemplate->get();
736 if (!$show_question_only)
741 return $solutionoutput;
750 include_once
"./classes/class.ilTemplate.php";
751 $template =
new ilTemplate(
"tpl.il_as_qpl_mc_mr_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
752 foreach ($keys as $answer_id)
754 $answer = $this->
object->answers[$answer_id];
755 if (strlen($answer->getImage()))
757 $template->setCurrentBlock(
"answer_image");
758 $template->setVariable(
"ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
759 $alt = $answer->getImage();
760 if (strlen($answer->getAnswertext()))
762 $alt = $answer->getAnswertext();
764 $alt = preg_replace(
"/<[^>]*?>/",
"", $alt);
767 $template->parseCurrentBlock();
769 $template->setCurrentBlock(
"answer_row");
770 $template->setVariable(
"ANSWER_ID", $answer_id);
771 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
772 $template->parseCurrentBlock();
774 $questiontext = $this->
object->getQuestion();
775 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
776 $questionoutput = $template->get();
777 if (!$show_question_only)
782 return $questionoutput;
785 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
791 $user_solution = array();
795 include_once
"./Modules/Test/classes/class.ilObjTest.php";
800 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
801 foreach ($solutions as $idx => $solution_value)
803 array_push($user_solution, $solution_value[
"value1"]);
807 include_once
"./classes/class.ilTemplate.php";
808 $template =
new ilTemplate(
"tpl.il_as_qpl_mc_mr_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
809 foreach ($keys as $answer_id)
811 $answer = $this->
object->answers[$answer_id];
812 if (strlen($answer->getImage()))
814 $template->setCurrentBlock(
"answer_image");
815 $template->setVariable(
"ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
816 $alt = $answer->getImage();
817 if (strlen($answer->getAnswertext()))
819 $alt = $answer->getAnswertext();
821 $alt = preg_replace(
"/<[^>]*?>/",
"", $alt);
824 $template->parseCurrentBlock();
827 foreach ($user_solution as $mc_solution)
829 if (strcmp($mc_solution, $answer_id) == 0)
833 $feedback = $this->
object->getFeedbackSingleAnswer($answer_id);
834 if (strlen($feedback))
836 $template->setCurrentBlock(
"feedback");
837 $template->setVariable(
"FEEDBACK", $feedback);
838 $template->parseCurrentBlock();
844 $template->setCurrentBlock(
"answer_row");
845 $template->setVariable(
"ANSWER_ID", $answer_id);
846 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
847 foreach ($user_solution as $mc_solution)
849 if (strcmp($mc_solution, $answer_id) == 0)
851 $template->setVariable(
"CHECKED_ANSWER",
" checked=\"checked\"");
854 $template->parseCurrentBlock();
856 $questiontext = $this->
object->getQuestion();
857 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
858 $questionoutput = $template->get();
859 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
866 if ($_POST[
"cmd"][
"addSuggestedSolution"])
876 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
881 $this->
object->saveToDb();
882 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
883 $this->tpl->setVariable(
"HEADER", $this->object->getTitle());
906 foreach ($_POST[
"cmd"] as $key => $value)
908 if (preg_match(
"/deleteImage_(\d+)/", $key, $matches))
910 $imageorder = $matches[1];
913 for ($i = 0; $i < $this->
object->getAnswerCount(); $i++)
915 $answer = $this->
object->getAnswer($i);
916 if ($answer->getOrder() == $imageorder)
918 $this->
object->deleteImage($answer->getImage());
919 $this->
object->answers[$i]->setImage(
"");
929 $this->
object->setMultilineAnswerSetting($_POST[
"multilineAnswers"]);
930 $this->
object->setGraphicalAnswerSetting($_POST[
"graphicalAnswerSupport"]);
944 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
947 foreach ($this->object->answers as $index => $answer)
951 $this->
object->cleanupMediaObjectUsage();
964 $this->tpl->addBlockFile(
"ADM_CONTENT",
"feedback",
"tpl.il_as_qpl_mc_mr_feedback.html",
"Modules/TestQuestionPool");
965 foreach ($this->object->answers as $index => $answer)
967 $this->tpl->setCurrentBlock(
"feedback_answer");
968 $this->tpl->setVariable(
"FEEDBACK_TEXT_ANSWER", $this->lng->txt(
"feedback"));
969 $this->tpl->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
970 $this->tpl->setVariable(
"ANSWER_ID", $index);
971 $this->tpl->setVariable(
"VALUE_FEEDBACK_ANSWER",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackSingleAnswer($index)), FALSE));
972 $this->tpl->parseCurrentBlock();
974 $this->tpl->setVariable(
"FEEDBACK_TEXT", $this->lng->txt(
"feedback"));
975 $this->tpl->setVariable(
"FEEDBACK_COMPLETE", $this->lng->txt(
"feedback_complete_solution"));
976 $this->tpl->setVariable(
"VALUE_FEEDBACK_COMPLETE",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)), FALSE));
977 $this->tpl->setVariable(
"FEEDBACK_INCOMPLETE", $this->lng->txt(
"feedback_incomplete_solution"));
978 $this->tpl->setVariable(
"VALUE_FEEDBACK_INCOMPLETE",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)), FALSE));
979 $this->tpl->setVariable(
"FEEDBACK_ANSWERS", $this->lng->txt(
"feedback_answers"));
981 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
983 $this->tpl->setVariable(
"SAVE", $this->lng->txt(
"save"));
985 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
987 include_once
"./Services/RTE/classes/class.ilRTE.php";
989 include_once
"./Services/RTE/classes/class.$rtestring.php";
990 $rte =
new $rtestring();
991 $rte->addPlugin(
"latex");
992 $rte->addButton(
"latex"); $rte->addButton(
"pastelatex");
993 include_once
"./classes/class.ilObject.php";
994 $obj_id =
$_GET[
"q_id"];
996 $rte->addRTESupport($obj_id, $obj_type,
"assessment");
1008 global $rbacsystem, $ilTabs;
1010 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
1011 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1012 $q_type = $this->
object->getQuestionType();
1014 if (strlen($q_type))
1016 $classname = $q_type .
"GUI";
1017 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
1018 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1023 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1026 $ilTabs->addTarget(
"edit_content",
1027 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
1028 array(
"edit",
"insert",
"exec_pg"),
1029 "",
"", $force_active);
1033 $ilTabs->addTarget(
"preview",
1034 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
1036 "ilPageObjectGUI",
"", $force_active);
1038 $force_active =
false;
1039 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1042 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1043 $force_active =
false;
1044 $commands = $_POST[
"cmd"];
1045 if (is_array($commands))
1047 foreach ($commands as $key => $value)
1049 if (preg_match(
"/^deleteImage_.*/", $key, $matches) ||
1050 preg_match(
"/^upload_.*/", $key, $matches)
1053 $force_active =
true;
1058 $ilTabs->addTarget(
"edit_properties",
1060 array(
"editQuestion",
"save",
"cancel",
"addSuggestedSolution",
1061 "cancelExplorer",
"linkChilds",
"removeSuggestedSolution",
1062 "toggleGraphicalAnswers",
"setMediaMode",
"uploadingImage",
"add",
"editMode",
"deleteAnswer",
1064 $classname,
"", $force_active);
1069 $ilTabs->addTarget(
"feedback",
1070 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
1071 array(
"feedback",
"saveFeedback"),
1078 $ilTabs->addTarget(
"statistics",
1079 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1080 array(
"assessment"),
1084 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
1088 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
1092 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
1103 if (strcmp(
$_GET[
"activecommand"],
"directfeedback") == 0)
1107 if (!is_array($this->choiceKeys))
1109 $this->choiceKeys = array_keys($this->object->answers);
1110 if ($this->object->getShuffle())
1112 $this->choiceKeys = $this->
object->pcArrayShuffle($this->choiceKeys);