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.assSingleChoice.php";
58 $this->
object->loadFromDb($id);
64 if (substr(
$cmd, 0, 6) ==
"upload")
68 if (substr(
$cmd, 0, 11) ==
"deleteImage")
84 $this->tpl->addJavascript(
"./Services/JavaScript/js/Basic.js");
85 $javascript =
"<script type=\"text/javascript\">ilAddOnLoad(initialSelect);\n".
86 "function initialSelect() {\n%s\n}</script>";
87 $graphical_answer_setting = $this->
object->getGraphicalAnswerSetting();
88 $multiline_answers = $this->
object->getMultilineAnswerSetting();
89 if ($graphical_answer_setting == 0)
91 for ($i = 0; $i < $this->
object->getAnswerCount(); $i++)
93 $answer = $this->
object->getAnswer($i);
94 if (strlen($answer->getImage())) $graphical_answer_setting = 1;
97 $this->
object->setGraphicalAnswerSetting($graphical_answer_setting);
99 $this->tpl->addBlockFile(
"QUESTION_DATA",
"question_data",
"tpl.il_as_qpl_mc_sr.html",
"Modules/TestQuestionPool");
101 if ($this->object->getAnswerCount() > 0)
103 $this->tpl->setCurrentBlock(
"answersheading");
104 $this->tpl->setVariable(
"TEXT_POINTS", $this->lng->txt(
"points"));
105 $this->tpl->setVariable(
"TEXT_ANSWER_TEXT", $this->lng->txt(
"answer_text"));
106 $this->tpl->parseCurrentBlock();
107 $this->tpl->setCurrentBlock(
"selectall");
108 $this->tpl->setVariable(
"SELECT_ALL", $this->lng->txt(
"select_all"));
109 $this->tpl->parseCurrentBlock();
110 $this->tpl->setCurrentBlock(
"existinganswers");
111 $this->tpl->setVariable(
"DELETE", $this->lng->txt(
"delete"));
112 $this->tpl->setVariable(
"MOVE", $this->lng->txt(
"move"));
113 $this->tpl->setVariable(
"ARROW",
"<img src=\"" .
ilUtil::getImagePath(
"arrow_downright.gif") .
"\" alt=\"".$this->lng->txt(
"arrow_downright").
"\">");
114 $this->tpl->parseCurrentBlock();
116 for ($i = 0; $i < $this->
object->getAnswerCount(); $i++)
118 $answer = $this->
object->getAnswer($i);
119 if ($graphical_answer_setting == 1)
121 $imagefilename = $this->
object->getImagePath() . $answer->getImage();
122 if (!@file_exists($imagefilename))
124 $answer->setImage(
"");
126 if (strlen($answer->getImage()))
128 $imagepath = $this->
object->getImagePathWeb() . $answer->getImage();
129 $this->tpl->setCurrentBlock(
"graphical_answer_image");
130 $this->tpl->setVariable(
"IMAGE_FILE", $imagepath);
131 if (strlen($answer->getAnswertext()))
137 $this->tpl->setVariable(
"IMAGE_ALT", $this->lng->txt(
"image"));
139 $this->tpl->setVariable(
"ANSWER_ORDER", $answer->getOrder());
140 $this->tpl->setVariable(
"DELETE_IMAGE", $this->lng->txt(
"delete_image"));
141 $this->tpl->parseCurrentBlock();
143 $this->tpl->setCurrentBlock(
"graphical_answer");
144 $this->tpl->setVariable(
"ANSWER_ORDER", $answer->getOrder());
145 $this->tpl->setVariable(
"UPLOAD_IMAGE", $this->lng->txt(
"upload_image"));
146 $this->tpl->setVariable(
"VALUE_IMAGE", $answer->getImage());
147 $this->tpl->parseCurrentBlock();
149 if ($multiline_answers)
151 $this->tpl->setCurrentBlock(
"show_textarea");
152 $this->tpl->setVariable(
"ANSWER_ANSWER_ORDER", $answer->getOrder());
154 $this->tpl->parseCurrentBlock();
158 $this->tpl->setCurrentBlock(
"show_textinput");
159 $this->tpl->setVariable(
"ANSWER_ANSWER_ORDER", $answer->getOrder());
161 $this->tpl->parseCurrentBlock();
163 $this->tpl->setCurrentBlock(
"answers");
164 $this->tpl->setVariable(
"ANSWER_ORDER", $answer->getOrder());
165 $this->tpl->setVariable(
"VALUE_MULTIPLE_CHOICE_POINTS", $answer->getPoints());
166 $this->tpl->setVariable(
"VALUE_TRUE", $this->lng->txt(
"true"));
167 $this->tpl->parseCurrentBlock();
172 $internallinks = array(
173 "lm" => $this->lng->txt(
"obj_lm"),
174 "st" => $this->lng->txt(
"obj_st"),
175 "pg" => $this->lng->txt(
"obj_pg"),
176 "glo" => $this->lng->txt(
"glossary_term")
178 foreach ($internallinks as $key => $value)
180 $this->tpl->setCurrentBlock(
"internallink");
181 $this->tpl->setVariable(
"TYPE_INTERNAL_LINK", $key);
182 $this->tpl->setVariable(
"TEXT_INTERNAL_LINK", $value);
183 $this->tpl->parseCurrentBlock();
186 $this->tpl->setCurrentBlock(
"HeadContent");
187 if ($this->object->getAnswerCount() == 0)
189 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_multiple_choice.title.focus();"));
193 switch ($this->ctrl->getCmd())
196 $nrOfAnswers = $_POST[
"nrOfAnswers"];
197 if ((strcmp($nrOfAnswers,
"yn") == 0) || (strcmp($nrOfAnswers,
"tf") == 0)) $nrOfAnswers = 2;
198 $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\");"));
201 if ($this->object->getAnswerCount() == 0)
203 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_multiple_choice.title.focus();"));
207 $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\");"));
211 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_multiple_choice.title.focus();"));
215 $this->tpl->parseCurrentBlock();
217 for ($i = 1; $i < 10; $i++)
219 $this->tpl->setCurrentBlock(
"numbers");
220 $this->tpl->setVariable(
"VALUE_NUMBER", $i);
223 $this->tpl->setVariable(
"TEXT_NUMBER", $i .
" " . $this->lng->txt(
"answer"));
227 $this->tpl->setVariable(
"TEXT_NUMBER", $i .
" " . $this->lng->txt(
"answers"));
229 $this->tpl->parseCurrentBlock();
232 $this->tpl->setCurrentBlock(
"numbers");
233 $this->tpl->setVariable(
"VALUE_NUMBER",
"yn");
234 $this->tpl->setVariable(
"TEXT_NUMBER", $this->lng->txt(
"add_answer_yn"));
235 $this->tpl->parseCurrentBlock();
237 $this->tpl->setCurrentBlock(
"numbers");
238 $this->tpl->setVariable(
"VALUE_NUMBER",
"tf");
239 $this->tpl->setVariable(
"TEXT_NUMBER", $this->lng->txt(
"add_answer_tf"));
240 $this->tpl->parseCurrentBlock();
242 $this->tpl->setCurrentBlock(
"question_data");
243 $this->tpl->setVariable(
"MULTIPLE_CHOICE_ID", $this->object->getId());
247 $questiontext = $this->
object->getQuestion();
248 $this->tpl->setVariable(
"VALUE_QUESTION",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
249 $this->tpl->setVariable(
"VALUE_ADD_ANSWER", $this->lng->txt(
"add"));
250 $this->tpl->setVariable(
"TEXT_GRAPHICAL_ANSWERS", $this->lng->txt(
"graphical_answers"));
251 $this->tpl->setVariable(
"TEXT_HIDE_GRAPHICAL_ANSWER_SUPPORT", $this->lng->txt(
"graphical_answers_hide"));
252 $this->tpl->setVariable(
"TEXT_SHOW_GRAPHICAL_ANSWER_SUPPORT", $this->lng->txt(
"graphical_answers_show"));
253 if ($this->object->getGraphicalAnswerSetting() == 1)
255 $this->tpl->setVariable(
"SELECTED_SHOW_GRAPHICAL_ANSWER_SUPPORT",
" selected=\"selected\"");
257 if ($multiline_answers)
259 $this->tpl->setVariable(
"SELECTED_SHOW_MULTILINE_ANSWERS",
" selected=\"selected\"");
261 $this->tpl->setVariable(
"TEXT_HIDE_MULTILINE_ANSWERS", $this->lng->txt(
"multiline_answers_hide"));
262 $this->tpl->setVariable(
"TEXT_SHOW_MULTILINE_ANSWERS", $this->lng->txt(
"multiline_answers_show"));
263 $this->tpl->setVariable(
"SET_EDIT_MODE", $this->lng->txt(
"set_edit_mode"));
264 $this->tpl->setVariable(
"TEXT_TITLE", $this->lng->txt(
"title"));
265 $this->tpl->setVariable(
"TEXT_AUTHOR", $this->lng->txt(
"author"));
266 $this->tpl->setVariable(
"TEXT_COMMENT", $this->lng->txt(
"description"));
267 $this->tpl->setVariable(
"TEXT_QUESTION", $this->lng->txt(
"question"));
268 $this->tpl->setVariable(
"TEXT_SHUFFLE_ANSWERS", $this->lng->txt(
"shuffle_answers"));
269 $this->tpl->setVariable(
"TXT_YES", $this->lng->txt(
"yes"));
270 $this->tpl->setVariable(
"TXT_NO", $this->lng->txt(
"no"));
271 if ($this->object->getShuffle())
273 $this->tpl->setVariable(
"SELECTED_YES",
" selected=\"selected\"");
277 $this->tpl->setVariable(
"SELECTED_NO",
" selected=\"selected\"");
279 $this->tpl->setVariable(
"TEXT_SOLUTION_HINT", $this->lng->txt(
"solution_hint"));
280 if (count($this->object->suggested_solutions))
282 $solution_array = $this->
object->getSuggestedSolution(0);
283 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
285 $this->tpl->setVariable(
"TEXT_VALUE_SOLUTION_HINT",
" <a href=\"$href\" target=\"content\">" . $this->lng->txt(
"solution_hint").
"</a> ");
286 $this->tpl->setVariable(
"BUTTON_REMOVE_SOLUTION", $this->lng->txt(
"remove"));
287 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"change"));
288 $this->tpl->setVariable(
"VALUE_SOLUTION_HINT", $solution_array[
"internal_link"]);
292 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"add"));
294 $this->tpl->setVariable(
"SAVE",$this->lng->txt(
"save"));
295 $this->tpl->setVariable(
"SAVE_EDIT", $this->lng->txt(
"save_edit"));
296 $this->tpl->setVariable(
"CANCEL",$this->lng->txt(
"cancel"));
297 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
298 $this->ctrl->setParameter($this,
"sel_question_types",
"assSingleChoice");
299 $this->tpl->setVariable(
"ACTION_MULTIPLE_CHOICE_TEST", $this->ctrl->getFormAction($this));
300 $this->tpl->setVariable(
"TEXT_QUESTION_TYPE", $this->
outQuestionType());
302 $this->tpl->parseCurrentBlock();
303 include_once
"./Services/RTE/classes/class.ilRTE.php";
305 include_once
"./Services/RTE/classes/class.$rtestring.php";
306 $rte =
new $rtestring();
307 $rte->addPlugin(
"latex");
308 $rte->addButton(
"latex");
309 $rte->addButton(
"pastelatex");
310 include_once
"./classes/class.ilObject.php";
311 $obj_id =
$_GET[
"q_id"];
313 $rte->addRTESupport($obj_id, $obj_type,
"assessment");
315 $this->tpl->setCurrentBlock(
"adm_content");
317 $this->tpl->parseCurrentBlock();
330 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
335 $nrOfAnswers = $_POST[
"nrOfAnswers"];
336 switch ($nrOfAnswers)
340 $this->
object->addAnswer(
341 $this->lng->txt(
"true"),
344 count($this->object->answers),
347 $this->
object->addAnswer(
348 $this->lng->txt(
"false"),
351 count($this->object->answers),
357 $this->
object->addAnswer(
358 $this->lng->txt(
"yes"),
361 count($this->object->answers),
364 $this->
object->addAnswer(
365 $this->lng->txt(
"no"),
368 count($this->object->answers),
373 for ($i = 0; $i < $nrOfAnswers; $i++)
375 $this->
object->addAnswer(
379 count($this->object->answers),
396 $answers = $_POST[
"chb_answers"];
397 if (is_array($answers))
400 foreach ($answers as $answer)
402 $this->
object->deleteAnswer($answer);
413 $cmd = $this->ctrl->getCmd();
415 if ((!$_POST[
"title"]) or (!$_POST[
"author"]) or (!$_POST[
"question"]))
420 foreach ($_POST as $key => $value)
422 if (preg_match(
"/answer_(\d+)/", $key, $matches))
424 if (strlen($value) == 0)
426 if (strlen($_POST[
"uploaded_image_".$matches[1]]) == 0)
448 if ((!$_POST[
"title"]) or (!$_POST[
"author"]) or (!$_POST[
"question"]))
453 if ((
$result) and (($_POST[
"cmd"][
"add"]) or ($_POST[
"cmd"][
"add_tf"]) or ($_POST[
"cmd"][
"add_yn"])))
456 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
457 $_POST[
"cmd"][
"add"] =
"";
458 $_POST[
"cmd"][
"add_yn"] =
"";
459 $_POST[
"cmd"][
"add_tf"] =
"";
463 if ($_POST[
"cmd"][
"add"] or $_POST[
"cmd"][
"add_yn"] or $_POST[
"cmd"][
"add_tf"])
465 foreach ($_POST as $key => $value)
467 if (preg_match(
"/answer_(\d+)/", $key, $matches))
471 $_POST[
"cmd"][
"add"] =
"";
472 $_POST[
"cmd"][
"add_yn"] =
"";
473 $_POST[
"cmd"][
"add_tf"] =
"";
483 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
485 $this->
object->setQuestion($questiontext);
486 $this->
object->setSuggestedSolution($_POST[
"solution_hint"], 0);
487 $this->
object->setShuffle($_POST[
"shuffle"]);
488 $this->
object->setMultilineAnswerSetting($_POST[
"multilineAnswers"]);
489 $this->
object->setGraphicalAnswerSetting($_POST[
"graphicalAnswerSupport"]);
494 $this->
object->flushAnswers();
495 $graphical_answer_setting = $this->
object->getGraphicalAnswerSetting();
497 foreach ($_POST as $key => $value)
499 if (preg_match(
"/answer_(\d+)/", $key, $matches))
501 $answer_image = $_POST[
"uploaded_image_".$matches[1]];
502 if ($graphical_answer_setting == 1)
504 foreach ($_FILES as $key2 => $value2)
506 if (preg_match(
"/image_(\d+)/", $key2, $matches2))
508 if ($matches[1] == $matches2[1])
510 if ($value2[
"tmp_name"])
513 if ($this->object->getId() <= 0)
515 $this->
object->saveToDb();
519 $value2[
'name'] = $this->
object->createNewImageFileName($value2[
'name']);
520 $upload_result = $this->
object->setImageFile($value2[
'name'], $value2[
'tmp_name']);
521 switch ($upload_result)
524 $_POST[
"image_".$matches2[1]] = $value2[
'name'];
525 $answer_image = $value2[
'name'];
539 $points = $_POST[
"points_$matches[1]"];
541 $this->
object->addAnswer(
550 if ($this->object->getMaximumPoints() < 0)
553 $this->
setErrorMessage($this->lng->txt(
"enter_enough_positive_points"));
557 if ($_POST[
"multiple_choice_id"] > 0)
559 $this->
object->setId($_POST[
"multiple_choice_id"]);
568 $this->
object->saveToDb();
569 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
575 function outQuestionForTest($formaction, $active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
577 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions, $show_feedback);
578 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
579 $this->tpl->setVariable(
"FORMACTION", $formaction);
582 function getSolutionOutput($active_id,
$pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE, $show_correct_solution = FALSE)
589 if (($active_id > 0) && (!$show_correct_solution))
591 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
592 foreach ($solutions as $idx => $solution_value)
594 $user_solution = $solution_value[
"value1"];
601 foreach ($this->object->answers as $index => $answer)
603 if ($answer->getPoints() > $max_points)
605 $max_points = $answer->getPoints();
606 $found_index = $index;
609 $user_solution = $found_index;
612 include_once
"./classes/class.ilTemplate.php";
613 $template =
new ilTemplate(
"tpl.il_as_qpl_mc_sr_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
614 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
615 foreach ($keys as $answer_id)
617 $answer = $this->
object->answers[$answer_id];
618 if (($active_id > 0) && (!$show_correct_solution))
620 if ($graphicalOutput)
624 if (strcmp($user_solution, $answer_id) == 0)
626 if ($answer->getPoints() == $this->
object->getMaximumPoints())
636 $template->setCurrentBlock(
"icon_ok");
638 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
639 $template->parseCurrentBlock();
643 $template->setCurrentBlock(
"icon_not_ok");
644 if ($answer->getPoints() > 0)
647 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
652 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
654 $template->parseCurrentBlock();
657 if (strlen($user_solution) == 0)
659 $template->setCurrentBlock(
"icon_not_ok");
661 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
662 $template->parseCurrentBlock();
666 if (strlen($answer->getImage()))
668 $template->setCurrentBlock(
"answer_image");
669 $template->setVariable(
"ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
670 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
671 $alt = $answer->getImage();
672 if (strlen($answer->getAnswertext()))
674 $alt = $answer->getAnswertext();
676 $alt = preg_replace(
"/<[^>]*?>/",
"", $alt);
677 $template->setVariable(
"ATTR", $attr);
680 $template->parseCurrentBlock();
684 if (strcmp($user_solution, $answer_id) == 0)
686 $fb = $this->
object->getFeedbackSingleAnswer($answer_id);
689 $template->setCurrentBlock(
"feedback");
690 $template->setVariable(
"FEEDBACK", $fb);
691 $template->parseCurrentBlock();
695 $template->setCurrentBlock(
"answer_row");
696 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
697 if (strcmp($user_solution, $answer_id) == 0)
700 $template->setVariable(
"SOLUTION_ALT", $this->lng->txt(
"checked"));
705 $template->setVariable(
"SOLUTION_ALT", $this->lng->txt(
"unchecked"));
709 $points = $this->
object->answers[$answer_id]->getPoints();
710 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
711 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
713 $template->parseCurrentBlock();
715 $questiontext = $this->
object->getQuestion();
716 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
717 $questionoutput = $template->get();
719 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
720 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
722 $solutionoutput = $solutiontemplate->get();
723 if (!$show_question_only)
728 return $solutionoutput;
736 include_once
"./classes/class.ilTemplate.php";
737 $template =
new ilTemplate(
"tpl.il_as_qpl_mc_sr_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
738 foreach ($keys as $answer_id)
740 $answer = $this->
object->answers[$answer_id];
741 if (strlen($answer->getImage()))
743 $template->setCurrentBlock(
"answer_image");
744 $template->setVariable(
"ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
745 $alt = $answer->getImage();
746 if (strlen($answer->getAnswertext()))
748 $alt = $answer->getAnswertext();
750 $alt = preg_replace(
"/<[^>]*?>/",
"", $alt);
753 $template->parseCurrentBlock();
755 $template->setCurrentBlock(
"answer_row");
756 $template->setVariable(
"ANSWER_ID", $answer_id);
757 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
758 $template->parseCurrentBlock();
760 $questiontext = $this->
object->getQuestion();
761 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
762 $questionoutput = $template->get();
763 if (!$show_question_only)
768 return $questionoutput;
771 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
780 include_once
"./Modules/Test/classes/class.ilObjTest.php";
785 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
786 foreach ($solutions as $idx => $solution_value)
788 $user_solution = $solution_value[
"value1"];
793 include_once
"./classes/class.ilTemplate.php";
794 $template =
new ilTemplate(
"tpl.il_as_qpl_mc_sr_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
795 foreach ($keys as $answer_id)
797 $answer = $this->
object->answers[$answer_id];
798 if (strlen($answer->getImage()))
800 $template->setCurrentBlock(
"answer_image");
801 $template->setVariable(
"ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
802 $alt = $answer->getImage();
803 if (strlen($answer->getAnswertext()))
805 $alt = $answer->getAnswertext();
807 $alt = preg_replace(
"/<[^>]*?>/",
"", $alt);
810 $template->parseCurrentBlock();
814 if (strcmp($user_solution, $answer_id) == 0)
816 $feedback = $this->
object->getFeedbackSingleAnswer($answer_id);
817 if (strlen($feedback))
819 $template->setCurrentBlock(
"feedback");
820 $template->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback, TRUE));
821 $template->parseCurrentBlock();
825 $template->setCurrentBlock(
"answer_row");
826 $template->setVariable(
"ANSWER_ID", $answer_id);
827 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
828 if (strcmp($user_solution, $answer_id) == 0)
830 $template->setVariable(
"CHECKED_ANSWER",
" checked=\"checked\"");
832 $template->parseCurrentBlock();
834 $questiontext = $this->
object->getQuestion();
835 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
836 $questionoutput = $template->get();
837 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
844 if ($_POST[
"cmd"][
"addSuggestedSolution"])
854 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
859 $this->
object->saveToDb();
860 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
861 $this->tpl->setVariable(
"HEADER", $this->object->getTitle());
884 foreach ($_POST[
"cmd"] as $key => $value)
886 if (preg_match(
"/deleteImage_(\d+)/", $key, $matches))
888 $imageorder = $matches[1];
891 for ($i = 0; $i < $this->
object->getAnswerCount(); $i++)
893 $answer = $this->
object->getAnswer($i);
894 if ($answer->getOrder() == $imageorder)
896 $this->
object->deleteImage($answer->getImage());
897 $this->
object->answers[$i]->setImage(
"");
907 $this->
object->setMultilineAnswerSetting($_POST[
"multilineAnswers"]);
908 $this->
object->setGraphicalAnswerSetting($_POST[
"graphicalAnswerSupport"]);
922 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
925 foreach ($this->object->answers as $index => $answer)
929 $this->
object->cleanupMediaObjectUsage();
942 $this->tpl->addBlockFile(
"ADM_CONTENT",
"feedback",
"tpl.il_as_qpl_mc_sr_feedback.html",
"Modules/TestQuestionPool");
943 foreach ($this->object->answers as $index => $answer)
945 $this->tpl->setCurrentBlock(
"feedback_answer");
946 $this->tpl->setVariable(
"FEEDBACK_TEXT_ANSWER", $this->lng->txt(
"feedback"));
947 $this->tpl->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
948 $this->tpl->setVariable(
"ANSWER_ID", $index);
949 $this->tpl->setVariable(
"VALUE_FEEDBACK_ANSWER",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackSingleAnswer($index)), FALSE));
950 $this->tpl->parseCurrentBlock();
952 $this->tpl->setVariable(
"FEEDBACK_TEXT", $this->lng->txt(
"feedback"));
953 $this->tpl->setVariable(
"FEEDBACK_COMPLETE", $this->lng->txt(
"feedback_complete_solution"));
954 $this->tpl->setVariable(
"VALUE_FEEDBACK_COMPLETE",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)), FALSE));
955 $this->tpl->setVariable(
"FEEDBACK_INCOMPLETE", $this->lng->txt(
"feedback_incomplete_solution"));
956 $this->tpl->setVariable(
"VALUE_FEEDBACK_INCOMPLETE",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)), FALSE));
957 $this->tpl->setVariable(
"FEEDBACK_ANSWERS", $this->lng->txt(
"feedback_answers"));
959 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
961 $this->tpl->setVariable(
"SAVE", $this->lng->txt(
"save"));
963 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
965 include_once
"./Services/RTE/classes/class.ilRTE.php";
967 include_once
"./Services/RTE/classes/class.$rtestring.php";
968 $rte =
new $rtestring();
969 $rte->addPlugin(
"latex");
970 $rte->addButton(
"latex"); $rte->addButton(
"pastelatex");
971 include_once
"./classes/class.ilObject.php";
972 $obj_id =
$_GET[
"q_id"];
974 $rte->addRTESupport($obj_id, $obj_type,
"assessment");
986 global $rbacsystem, $ilTabs;
988 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
989 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
990 $q_type = $this->
object->getQuestionType();
994 $classname = $q_type .
"GUI";
995 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
996 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1001 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1004 $ilTabs->addTarget(
"edit_content",
1005 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
1006 array(
"edit",
"insert",
"exec_pg"),
1007 "",
"", $force_active);
1011 $ilTabs->addTarget(
"preview",
1012 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
1014 "ilPageObjectGUI",
"", $force_active);
1017 $force_active =
false;
1018 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1021 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1022 $commands = $_POST[
"cmd"];
1023 if (is_array($commands))
1025 foreach ($commands as $key => $value)
1027 if (preg_match(
"/^deleteImage_.*/", $key, $matches) ||
1028 preg_match(
"/^upload_.*/", $key, $matches)
1031 $force_active =
true;
1036 $ilTabs->addTarget(
"edit_properties",
1038 array(
"editQuestion",
"save",
"cancel",
"addSuggestedSolution",
1039 "cancelExplorer",
"linkChilds",
"removeSuggestedSolution",
1040 "toggleGraphicalAnswers",
"setMediaMode",
"uploadingImage",
"add",
"editMode",
"deleteAnswer",
"addYesNo",
"addTrueFalse",
1042 $classname,
"", $force_active);
1047 $ilTabs->addTarget(
"feedback",
1048 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
1049 array(
"feedback",
"saveFeedback"),
1056 $ilTabs->addTarget(
"statistics",
1057 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1058 array(
"assessment"),
1062 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
1066 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
1070 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
1081 if (strcmp(
$_GET[
"activecommand"],
"directfeedback") == 0)
1085 if (!is_array($this->choiceKeys))
1087 $this->choiceKeys = array_keys($this->object->answers);
1088 if ($this->object->getShuffle())
1090 $this->choiceKeys = $this->
object->pcArrayShuffle($this->choiceKeys);