24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
25 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
53 include_once
"./Modules/TestQuestionPool/classes/class.assImagemapQuestion.php";
58 $this->
object->loadFromDb($id);
60 $assessmentSetting =
new ilSetting(
"assessment");
61 $this->linecolor = (strlen($assessmentSetting->get(
"imap_line_color"))) ?
"#" . $assessmentSetting->get(
"imap_line_color") :
"#FF0000";
67 if (isset($_POST[
"imagemap"]) ||
68 isset($_POST[
"imagemap_x"]) ||
69 isset($_POST[
"imagemap_y"]))
71 $this->ctrl->setCmd(
"getCoords");
88 include_once
"./Modules/TestQuestionPool/classes/class.ilImagemapPreview.php";
91 $this->tpl->addBlockFile(
"QUESTION_DATA",
"question_data",
"tpl.il_as_qpl_imagemap_question.html",
"Modules/TestQuestionPool");
92 if (($this->ctrl->getCmd() ==
"addArea" or $this->ctrl->getCmd() ==
"getCoords") and ($this->ctrl->getCmd() !=
"saveShape"))
94 foreach ($this->object->coords as $key => $value)
96 $this->tpl->setCurrentBlock(
"hidden");
97 $this->tpl->setVariable(
"HIDDEN_NAME",
"coords_$key");
98 $this->tpl->setVariable(
"HIDDEN_VALUE", $value);
99 $this->tpl->parseCurrentBlock();
101 $this->tpl->setCurrentBlock(
"hidden");
102 $this->tpl->setVariable(
"HIDDEN_NAME",
"newarea");
103 $this->tpl->setVariable(
"HIDDEN_VALUE", $_POST[
"newarea"]);
104 $this->tpl->parseCurrentBlock();
107 foreach ($this->object->answers as $index => $answer)
109 $preview->addArea($index, $answer->getArea(), $answer->getCoords(), $answer->getAnswertext(),
"",
"",
true,
$this->linecolor);
112 $disabled_save =
" disabled=\"disabled\"";
114 switch ($_POST[
"newarea"])
117 if (count($this->object->coords) == 0)
121 else if (count($this->object->coords) == 1)
124 $preview->addPoint(
$preview->getAreaCount(), join($this->object->coords,
","), TRUE,
"blue");
126 else if (count($this->object->coords) == 2)
128 $coords = join($this->object->coords,
",");
134 if (count($this->object->coords) == 0)
138 else if (count($this->object->coords) == 1)
141 $preview->addPoint(
$preview->getAreaCount(), join($this->object->coords,
","), TRUE,
"blue");
143 else if (count($this->object->coords) == 2)
145 if (preg_match(
"/(\d+)\s*,\s*(\d+)\s+(\d+)\s*,\s*(\d+)/", $this->object->coords[0] .
" " . $this->object->coords[1], $matches))
147 $coords =
"$matches[1],$matches[2]," . (int)sqrt((($matches[3]-$matches[1])*($matches[3]-$matches[1]))+(($matches[4]-$matches[2])*($matches[4]-$matches[2])));
154 if (count($this->object->coords) == 0)
158 else if (count($this->object->coords) == 1)
161 $preview->addPoint(
$preview->getAreaCount(), join($this->object->coords,
","), TRUE,
"blue");
163 else if (count($this->object->coords) > 1)
167 $coords = join($this->object->coords,
",");
173 $preview->addArea(
$preview->getAreaCount(), $_POST[
"newarea"], $coords, $_POST[
"shapetitle"],
"",
"",
true,
"blue");
176 $imagepath = $this->
object->getImagePathWeb() .
$preview->getPreviewFilename($this->object->getImagePath(), $this->
object->get_image_filename()) .
"?img=" . time();
179 $this->tpl->setCurrentBlock(
"maparea");
180 $this->tpl->setVariable(
"IMAGE_SOURCE",
"$imagepath");
181 $this->tpl->parseCurrentBlock();
185 $this->tpl->setCurrentBlock(
"imagearea");
186 $this->tpl->setVariable(
"IMAGE_SOURCE",
"$imagepath");
187 $this->tpl->setVariable(
"ALT_IMAGE", $this->lng->txt(
"imagemap"));
188 $this->tpl->parseCurrentBlock();
190 $this->tpl->setCurrentBlock(
"imagemapeditor");
191 $this->tpl->setVariable(
"TEXT_IMAGEMAP", $this->lng->txt(
"imagemap"));
192 $this->tpl->setVariable(
"VALUE_SHAPETITLE", $_POST[
"shapetitle"]);
193 $this->tpl->setVariable(
"TEXT_SHAPETITLE", $this->lng->txt(
"name"));
194 $this->tpl->setVariable(
"CANCEL", $this->lng->txt(
"cancel"));
195 $this->tpl->setVariable(
"SAVE", $this->lng->txt(
"save"));
196 $this->tpl->setVariable(
"DISABLED_SAVE", $disabled_save);
197 $this->tpl->parseCurrentBlock();
198 $this->tpl->setCurrentBlock(
"adm_content");
199 $this->tpl->setVariable(
"IMAGEMAP_ID", $this->object->getId());
200 $this->ctrl->setParameter($this,
"sel_question_types",
"assImagemapQuestion");
201 $this->ctrl->setParameter($this,
"editmap",
"1");
202 $this->tpl->setVariable(
"ACTION_IMAGEMAP_QUESTION", $this->ctrl->getFormaction($this));
203 $this->tpl->parseCurrentBlock();
207 $tblrow = array(
"tblrow1top",
"tblrow2top");
208 for ($i = 0; $i < $this->
object->getAnswerCount(); $i++)
210 $this->tpl->setCurrentBlock(
"answers");
211 $answer = $this->
object->getAnswer($i);
212 $this->tpl->setVariable(
"ANSWER_ORDER", $answer->getOrder());
214 $this->tpl->setVariable(
"TEXT_POINTS", $this->lng->txt(
"points"));
215 if ((strcmp(
$_GET[
"markarea"],
"") != 0) && (
$_GET[
"markarea"] == $i))
217 $this->tpl->setVariable(
"CLASS_FULLWIDTH",
"fullwidth_marked");
221 $this->tpl->setVariable(
"CLASS_FULLWIDTH",
"fullwidth");
223 $this->tpl->setVariable(
"VALUE_IMAGEMAP_POINTS", $answer->getPoints());
224 $this->tpl->setVariable(
"COLOR_CLASS", $tblrow[$i % 2]);
226 switch ($answer->getArea())
230 $coords = preg_replace(
"/(\d+,\d+,)/",
"\$1 ", $answer->getCoords());
233 $coords = preg_replace(
"/(\d+,\d+,)/",
"\$1 ", $answer->getCoords());
236 $this->tpl->setVariable(
"COORDINATES", $coords);
237 $this->tpl->setVariable(
"AREA", $answer->getArea());
238 $this->tpl->setVariable(
"TEXT_SHAPE", strtoupper($answer->getArea()));
239 $this->tpl->parseCurrentBlock();
241 if ($this->object->getAnswerCount())
243 $this->tpl->setCurrentBlock(
"selectall");
244 $this->tpl->setVariable(
"SELECT_ALL", $this->lng->txt(
"select_all"));
246 $this->tpl->setVariable(
"COLOR_CLASS", $tblrow[$i % 2]);
247 $this->tpl->parseCurrentBlock();
248 $this->tpl->setCurrentBlock(
"QFooter");
249 $this->tpl->setVariable(
"DELETE_AREA", $this->lng->txt(
"delete_area"));
250 $this->tpl->setVariable(
"ARROW",
"<img src=\"" .
ilUtil::getImagePath(
"arrow_downright.gif") .
"\" alt=\"".$this->lng->txt(
"arrow_downright").
"\"/>");
251 $this->tpl->parseCurrentBlock();
252 $this->tpl->setCurrentBlock(
"answerheader");
253 $this->tpl->setVariable(
"TEXT_NAME", $this->lng->txt(
"name"));
254 $this->tpl->setVariable(
"TEXT_TRUE", $this->lng->txt(
"true"));
255 $this->tpl->setVariable(
"TEXT_POINTS", $this->lng->txt(
"points"));
256 $this->tpl->setVariable(
"TEXT_SHAPE", $this->lng->txt(
"shape"));
257 $this->tpl->setVariable(
"TEXT_COORDINATES", $this->lng->txt(
"coordinates"));
258 $this->tpl->parseCurrentBlock();
264 $internallinks = array(
265 "lm" => $this->lng->txt(
"obj_lm"),
266 "st" => $this->lng->txt(
"obj_st"),
267 "pg" => $this->lng->txt(
"obj_pg"),
268 "glo" => $this->lng->txt(
"glossary_term")
270 foreach ($internallinks as $key => $value)
272 $this->tpl->setCurrentBlock(
"internallink");
273 $this->tpl->setVariable(
"TYPE_INTERNAL_LINK", $key);
274 $this->tpl->setVariable(
"TEXT_INTERNAL_LINK", $value);
275 $this->tpl->parseCurrentBlock();
278 if (strcmp($this->object->get_image_filename(),
"") != 0)
280 $this->tpl->setCurrentBlock(
"addarea");
281 $this->tpl->setVariable(
"ADD_AREA", $this->lng->txt(
"add_area"));
282 $this->tpl->setVariable(
"TEXT_RECT", $this->lng->txt(
"rectangle"));
283 $this->tpl->setVariable(
"TEXT_CIRCLE", $this->lng->txt(
"circle"));
284 $this->tpl->setVariable(
"TEXT_POLY", $this->lng->txt(
"polygon"));
285 if (array_key_exists(
"newarea", $_POST))
287 switch ($_POST[
"newarea"])
290 $this->tpl->setVariable(
"SELECTED_CIRCLE",
" selected=\"selected\"");
293 $this->tpl->setVariable(
"SELECTED_POLY",
" selected=\"selected\"");
296 $this->tpl->setVariable(
"SELECTED_RECT",
" selected=\"selected\"");
300 $this->tpl->parseCurrentBlock();
302 $this->tpl->setCurrentBlock(
"HeadContent");
303 $this->tpl->addJavascript(
"./Services/JavaScript/js/Basic.js");
304 $javascript =
"<script type=\"text/javascript\">ilAddOnLoad(initialSelect);\n".
305 "function initialSelect() {\n%s\n}</script>";
306 if (strcmp(
$_GET[
"markarea"],
"") != 0)
308 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_imagemap.answer_".
$_GET[
"markarea"].
".focus(); document.frm_imagemap.answer_".
$_GET[
"markarea"].
".scrollIntoView(\"true\");"));
312 switch ($this->ctrl->getCmd())
316 if ($this->object->getAnswerCount() > 0)
318 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_imagemap.answer_".($this->object->getAnswerCount() - 1).
".focus(); document.frm_imagemap.answer_".($this->object->getAnswerCount() - 1).
".scrollIntoView(\"true\");"));
322 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_imagemap.title.focus();"));
326 $this->tpl->setVariable(
"CONTENT_BLOCK", sprintf($javascript,
"document.frm_imagemap.title.focus();"));
330 $this->tpl->parseCurrentBlock();
331 $this->tpl->setCurrentBlock(
"question_data");
332 $img = $this->
object->get_image_filename();
333 $this->tpl->setVariable(
"TEXT_IMAGE", $this->lng->txt(
"image"));
336 $this->tpl->setVariable(
"IMAGE_FILENAME",
$img);
337 $this->tpl->setVariable(
"VALUE_IMAGE_UPLOAD", $this->lng->txt(
"change"));
338 $this->tpl->setCurrentBlock(
"imageupload");
340 $this->tpl->parse(
"imageupload");
342 if (count($this->object->answers))
345 foreach ($this->object->answers as $index => $answer)
347 $preview->addArea($index, $answer->getArea(), $answer->getCoords(), $answer->getAnswertext(), $this->ctrl->getLinkTarget($this,
"editQuestion") .
"&markarea=$index",
"",
true,
$this->linecolor);
350 $imagepath = $this->
object->getImagePathWeb() .
$preview->getPreviewFilename($this->object->getImagePath(), $this->
object->get_image_filename());
351 $map =
$preview->getImagemap(
"imagemap_" . $this->object->getId());
355 $imagepath = $this->
object->getImagePathWeb() .
$img;
357 $size = GetImageSize ($this->object->getImagePath() . $this->
object->get_image_filename());
360 $this->tpl->setVariable(
"UPLOADED_IMAGE",
"<img src=\"$imagepath\" alt=\"$img\" border=\"0\" " .
$size[3] .
" usemap=\"" .
"#imagemap_" . $this->object->getId().
"\" />\n$map\n");
364 $this->tpl->setVariable(
"UPLOADED_IMAGE",
"<img src=\"$imagepath\" alt=\"$img\" border=\"0\" " .
$size[3] .
" />");
369 $this->tpl->setVariable(
"VALUE_IMAGE_UPLOAD", $this->lng->txt(
"upload"));
373 $imgmap = $this->
object->get_imagemap_filename();
374 $this->tpl->setVariable(
"TEXT_IMAGEMAP", $this->lng->txt(
"imagemap_file"));
375 $this->tpl->setVariable(
"VALUE_IMAGEMAP_UPLOAD", $this->lng->txt(
"add_imagemap"));
376 $this->tpl->setCurrentBlock(
"questioneditor");
380 $questiontext = $this->
object->getQuestion();
381 $this->tpl->setVariable(
"VALUE_QUESTION",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
382 $this->tpl->setVariable(
"TEXT_TITLE", $this->lng->txt(
"title"));
383 $this->tpl->setVariable(
"TEXT_AUTHOR", $this->lng->txt(
"author"));
384 $this->tpl->setVariable(
"TEXT_COMMENT", $this->lng->txt(
"description"));
385 $this->tpl->setVariable(
"TEXT_QUESTION", $this->lng->txt(
"question"));
386 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
388 $this->tpl->setVariable(
"TEXT_SOLUTION_HINT", $this->lng->txt(
"solution_hint"));
389 if (count($this->object->suggested_solutions))
391 $solution_array = $this->
object->getSuggestedSolution(0);
392 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
394 $this->tpl->setVariable(
"TEXT_VALUE_SOLUTION_HINT",
" <a href=\"$href\" target=\"content\">" . $this->lng->txt(
"solution_hint").
"</a> ");
395 $this->tpl->setVariable(
"BUTTON_REMOVE_SOLUTION", $this->lng->txt(
"remove"));
396 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"change"));
397 $this->tpl->setVariable(
"VALUE_SOLUTION_HINT", $solution_array[
"internal_link"]);
401 $this->tpl->setVariable(
"BUTTON_ADD_SOLUTION", $this->lng->txt(
"add"));
404 $this->tpl->setVariable(
"SAVE",$this->lng->txt(
"save"));
405 $this->tpl->setVariable(
"SAVE_EDIT", $this->lng->txt(
"save_edit"));
406 $this->tpl->setVariable(
"CANCEL",$this->lng->txt(
"cancel"));
407 $this->tpl->setVariable(
"TEXT_QUESTION_TYPE", $this->
outQuestionType());
408 $this->tpl->parseCurrentBlock();
409 $this->tpl->setCurrentBlock(
"adm_content");
410 $this->ctrl->setParameter($this,
"sel_question_types",
"assImagemapQuestion");
411 $this->tpl->setVariable(
"ACTION_IMAGEMAP_QUESTION", $this->ctrl->getFormaction($this));
412 $this->tpl->setVariable(
"IMAGEMAP_ID", $this->object->getId());
413 $this->tpl->parseCurrentBlock();
414 include_once
"./Services/RTE/classes/class.ilRTE.php";
416 include_once
"./Services/RTE/classes/class.$rtestring.php";
417 $rte =
new $rtestring();
418 $rte->addPlugin(
"latex");
419 $rte->addButton(
"latex"); $rte->addButton(
"pastelatex");
420 include_once
"./classes/class.ilObject.php";
421 $obj_id =
$_GET[
"q_id"];
423 $rte->addRTESupport($obj_id, $obj_type,
"assessment");
424 $this->tpl->setCurrentBlock(
"adm_content");
426 $this->tpl->parseCurrentBlock();
448 $_SESSION[
"last_area"] = $_POST[
"newarea"];
452 $this->ctrl->setCmd(
"");
459 if (
$_GET[
"q_id"] < 1)
472 if (
$_GET[
"q_id"] < 1)
486 $checked_areas = array();
487 foreach ($_POST as $key => $value)
489 if (preg_match(
"/cb_(\d+)/", $key, $matches))
491 array_push($checked_areas, $matches[1]);
494 rsort($checked_areas, SORT_NUMERIC);
495 foreach ($checked_areas as $index)
497 $this->
object->deleteArea($index);
515 if (
$_GET[
"editmap"])
517 $this->
object->coords = array();
518 foreach ($_POST as $key => $value)
520 if (preg_match(
"/coords_(\d+)/", $key, $matches))
522 $this->
object->coords[$matches[1]] = $value;
525 if (isset($_POST[
"imagemap_x"]))
527 array_push($this->object->coords, $_POST[
"imagemap_x"] .
"," . $_POST[
"imagemap_y"]);
529 if ($this->ctrl->getCmd() ==
"saveShape")
532 switch ($_POST[
"newarea"])
535 $coords = join($this->object->coords,
",");
538 if (preg_match(
"/(\d+)\s*,\s*(\d+)\s+(\d+)\s*,\s*(\d+)/", $this->object->coords[0] .
" " . $this->object->coords[1], $matches))
540 $coords =
"$matches[1],$matches[2]," . (int)sqrt((($matches[3]-$matches[1])*($matches[3]-$matches[1]))+(($matches[4]-$matches[2])*($matches[4]-$matches[2])));
544 $coords = join($this->object->coords,
",");
547 $this->
object->addAnswer($_POST[
"shapetitle"], 0, count($this->object->answers), $coords, $_POST[
"newarea"]);
559 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
561 $this->
object->setQuestion($questiontext);
562 $this->
object->setSuggestedSolution($_POST[
"solution_hint"], 0);
563 $this->
object->setShuffle($_POST[
"shuffle"]);
568 if (($_POST[
"id"] > 0) or (
$result != 1))
573 if (strlen($_FILES[
'imageName'][
'tmp_name']) == 0)
579 if ($this->object->getId() <= 0)
581 $this->
object->saveToDb();
582 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
586 $this->
object->setImageFilename($_FILES[
'imageName'][
'name'], $_FILES[
'imageName'][
'tmp_name']);
590 if (empty($_FILES[
'imagemapName'][
'tmp_name']))
594 $this->
object->flushAnswers();
595 foreach ($_POST as $key => $value)
597 if (preg_match(
"/answer_(\d+)/", $key, $matches))
599 $points = $_POST[
"points_$matches[1]"];
601 $this->
object->addAnswer(
613 if ($this->object->getId() <= 0)
615 $this->
object->saveToDb();
616 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
620 $this->
object->setImagemapFilename($_FILES[
'imagemapName'][
'name'], $_FILES[
'imagemapName'][
'tmp_name']);
625 if (($this->ctrl->getCmd() ==
"uploadingImage") and (!empty($_FILES[
'imageName'][
'tmp_name'])))
627 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_upload_image"));
629 else if (($_POST[
"cmd"][
"uploadingImagemap"]) and (!empty($_FILES[
'imagemapName'][
'tmp_name'])))
631 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_upload_imagemap"));
635 if ($this->ctrl->getCmd() ==
"addArea")
637 $this->
object->saveToDb();
642 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
647 function outQuestionForTest($formaction, $active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
649 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions, $show_feedback);
650 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
652 $this->ctrl->setParameterByClass(
"ilTestOutputGUI",
"formtimestamp", time());
653 $formaction = $this->ctrl->getLinkTargetByClass(
"ilTestOutputGUI",
"selectImagemapRegion");
654 include_once
"./Modules/Test/classes/class.ilObjTest.php";
658 $info =& $this->
object->getSolutionValues($active_id,
$pass);
662 $info =& $this->
object->getSolutionValues($active_id, NULL);
666 if (strcmp($info[0][
"value1"],
"") != 0)
668 $formaction .=
"&selImage=" . $info[0][
"value1"];
671 $this->tpl->setVariable(
"FORMACTION", $formaction);
674 function getSolutionOutput($active_id,
$pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE, $show_correct_solution = FALSE)
676 $imagepath = $this->
object->getImagePathWeb() . $this->
object->get_image_filename();
677 $solutions = array();
678 if (($active_id > 0) && (!$show_correct_solution))
680 include_once
"./Modules/Test/classes/class.ilObjTest.php";
685 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
691 foreach ($this->object->answers as $index => $answer)
693 if ($answer->getPoints() > $max_points)
695 $max_points = $answer->getPoints();
696 $found_index = $index;
699 array_push($solutions, array(
"value1" => $found_index));
702 if (is_array($solutions))
704 include_once
"./Modules/TestQuestionPool/classes/class.ilImagemapPreview.php";
706 foreach ($solutions as $idx => $solution_value)
708 if (strcmp($solution_value[
"value1"],
"") != 0)
710 $preview->addArea($solution_value[
"value1"], $this->object->answers[$solution_value[
"value1"]]->getArea(), $this->
object->answers[$solution_value[
"value1"]]->getCoords(), $this->
object->answers[$solution_value[
"value1"]]->getAnswertext(),
"",
"",
true,
$this->linecolor);
711 $solution_id = $solution_value[
"value1"];
715 $imagepath = $this->
object->getImagePathWeb() .
$preview->getPreviewFilename($this->object->getImagePath(), $this->
object->get_image_filename());
719 include_once
"./classes/class.ilTemplate.php";
720 $template =
new ilTemplate(
"tpl.il_as_qpl_imagemap_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
721 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
722 $questiontext = $this->
object->getQuestion();
723 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
724 $template->setVariable(
"IMG_SRC",
"$imagepath");
725 $template->setVariable(
"IMG_ALT", $this->lng->txt(
"imagemap"));
726 $template->setVariable(
"IMG_TITLE", $this->lng->txt(
"imagemap"));
727 if (($active_id > 0) && (!$show_correct_solution))
729 if ($graphicalOutput)
732 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
733 if ($reached_points == $this->object->getMaximumPoints())
735 $template->setCurrentBlock(
"icon_ok");
737 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
738 $template->parseCurrentBlock();
742 $template->setCurrentBlock(
"icon_ok");
743 if ($reached_points > 0)
746 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
751 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
753 $template->parseCurrentBlock();
760 $fb = $this->
object->getFeedbackSingleAnswer($solution_id);
763 $template->setCurrentBlock(
"feedback");
764 $template->setVariable(
"FEEDBACK", $fb);
765 $template->parseCurrentBlock();
769 $questionoutput = $template->get();
771 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
772 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
774 $solutionoutput = $solutiontemplate->get();
775 if (!$show_question_only)
780 return $solutionoutput;
785 $imagepath = $this->
object->getImagePathWeb() . $this->
object->get_image_filename();
787 include_once
"./classes/class.ilTemplate.php";
788 $template =
new ilTemplate(
"tpl.il_as_qpl_imagemap_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
790 foreach ($this->object->answers as $answer_id => $answer)
792 $template->setCurrentBlock(
"imagemap_area");
793 $template->setVariable(
"HREF_AREA", $formaction);
794 $template->setVariable(
"SHAPE", $answer->getArea());
795 $template->setVariable(
"COORDS", $answer->getCoords());
798 $template->parseCurrentBlock();
800 $questiontext = $this->
object->getQuestion();
801 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
802 $template->setVariable(
"IMG_SRC",
"$imagepath");
803 $template->setVariable(
"IMG_ALT", $this->lng->txt(
"imagemap"));
804 $template->setVariable(
"IMG_TITLE", $this->lng->txt(
"imagemap"));
805 $questionoutput = $template->get();
806 if (!$show_question_only)
811 return $questionoutput;
814 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
821 include_once
"./Modules/Test/classes/class.ilObjTest.php";
826 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
827 foreach ($solutions as $idx => $solution_value)
829 $user_solution = $solution_value[
"value1"];
833 $imagepath = $this->
object->getImagePathWeb() . $this->
object->get_image_filename();
837 include_once
"./Modules/Test/classes/class.ilObjTest.php";
842 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
843 include_once
"./Modules/TestQuestionPool/classes/class.ilImagemapPreview.php";
845 foreach ($solutions as $idx => $solution_value)
847 if (strcmp($solution_value[
"value1"],
"") != 0)
849 $preview->addArea($solution_value[
"value1"], $this->object->answers[$solution_value[
"value1"]]->getArea(), $this->
object->answers[$solution_value[
"value1"]]->getCoords(), $this->
object->answers[$solution_value[
"value1"]]->getAnswertext(),
"",
"",
true,
$this->linecolor);
853 $imagepath = $this->
object->getImagePathWeb() .
$preview->getPreviewFilename($this->object->getImagePath(), $this->
object->get_image_filename());
857 include_once
"./classes/class.ilTemplate.php";
858 $template =
new ilTemplate(
"tpl.il_as_qpl_imagemap_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
859 $this->ctrl->setParameterByClass(
"ilTestOutputGUI",
"formtimestamp", time());
860 $formaction = $this->ctrl->getLinkTargetByClass(
"ilTestOutputGUI",
"selectImagemapRegion");
861 foreach ($this->object->answers as $answer_id => $answer)
863 $template->setCurrentBlock(
"imagemap_area");
864 $template->setVariable(
"HREF_AREA", $formaction .
"&selImage=$answer_id");
865 $template->setVariable(
"SHAPE", $answer->getArea());
866 $template->setVariable(
"COORDS", $answer->getCoords());
869 $template->parseCurrentBlock();
872 if (strlen($user_solution) && $user_solution == $answer_id)
874 $feedback = $this->
object->getFeedbackSingleAnswer($user_solution);
875 if (strlen($feedback))
877 $template->setCurrentBlock(
"feedback");
878 $template->setVariable(
"FEEDBACK", $feedback);
879 $template->parseCurrentBlock();
884 $questiontext = $this->
object->getQuestion();
885 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
886 $template->setVariable(
"IMG_SRC",
"$imagepath");
887 $template->setVariable(
"IMG_ALT", $this->lng->txt(
"imagemap"));
888 $template->setVariable(
"IMG_TITLE", $this->lng->txt(
"imagemap"));
889 $questionoutput = $template->get();
890 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
899 if ((!$_POST[
"title"]) or (!$_POST[
"author"]) or (!$_POST[
"question"]))
909 if ($_POST[
"cmd"][
"addSuggestedSolution"])
919 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
924 $this->
object->saveToDb();
925 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
926 $this->tpl->setVariable(
"HEADER", $this->object->getTitle());
940 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
943 foreach ($this->object->answers as $index => $answer)
947 $this->
object->cleanupMediaObjectUsage();
960 $this->tpl->addBlockFile(
"ADM_CONTENT",
"feedback",
"tpl.il_as_qpl_imagemap_feedback.html",
"Modules/TestQuestionPool");
961 foreach ($this->object->answers as $index => $answer)
963 $this->tpl->setCurrentBlock(
"feedback_answer");
964 $this->tpl->setVariable(
"FEEDBACK_TEXT_ANSWER", $this->lng->txt(
"feedback"));
965 $text = strtoupper($answer->getArea() .
" (" . $answer->getCoords() .
")");
966 if (strlen($answer->getAnswertext()))
968 $text = $answer->getAnswertext() .
": " . $text;
970 $this->tpl->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($text, TRUE));
971 $this->tpl->setVariable(
"ANSWER_ID", $index);
972 $this->tpl->setVariable(
"VALUE_FEEDBACK_ANSWER",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackSingleAnswer($index)), FALSE));
973 $this->tpl->parseCurrentBlock();
975 $this->tpl->setVariable(
"FEEDBACK_TEXT", $this->lng->txt(
"feedback"));
976 $this->tpl->setVariable(
"FEEDBACK_COMPLETE", $this->lng->txt(
"feedback_complete_solution"));
977 $this->tpl->setVariable(
"VALUE_FEEDBACK_COMPLETE",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)), FALSE));
978 $this->tpl->setVariable(
"FEEDBACK_INCOMPLETE", $this->lng->txt(
"feedback_incomplete_solution"));
979 $this->tpl->setVariable(
"VALUE_FEEDBACK_INCOMPLETE",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)), FALSE));
980 $this->tpl->setVariable(
"FEEDBACK_ANSWERS", $this->lng->txt(
"feedback_answers"));
982 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
984 $this->tpl->setVariable(
"SAVE", $this->lng->txt(
"save"));
986 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
988 include_once
"./Services/RTE/classes/class.ilRTE.php";
990 include_once
"./Services/RTE/classes/class.$rtestring.php";
991 $rte =
new $rtestring();
992 $rte->addPlugin(
"latex");
993 $rte->addButton(
"latex"); $rte->addButton(
"pastelatex");
994 include_once
"./classes/class.ilObject.php";
995 $obj_id =
$_GET[
"q_id"];
997 $rte->addRTESupport($obj_id, $obj_type,
"assessment");
1009 global $rbacsystem, $ilTabs;
1011 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
1012 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
1013 $q_type = $this->
object->getQuestionType();
1015 if (strlen($q_type))
1017 $classname = $q_type .
"GUI";
1018 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
1019 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
1024 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1027 $ilTabs->addTarget(
"edit_content",
1028 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
1029 array(
"edit",
"insert",
"exec_pg"),
1030 "",
"", $force_active);
1034 $ilTabs->addTarget(
"preview",
1035 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
1037 "ilPageObjectGUI",
"", $force_active);
1040 $force_active =
false;
1041 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
1044 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
1045 if (array_key_exists(
"imagemap_x", $_POST))
1047 $force_active =
true;
1050 $ilTabs->addTarget(
"edit_properties",
1052 array(
"editQuestion",
"save",
"cancel",
"addSuggestedSolution",
1053 "cancelExplorer",
"linkChilds",
"removeSuggestedSolution",
1054 "uploadingImage",
"uploadingImagemap",
"addArea",
1055 "deletearea",
"saveShape",
"back",
"saveEdit"),
1056 $classname,
"", $force_active);
1061 $ilTabs->addTarget(
"feedback",
1062 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
1063 array(
"feedback",
"saveFeedback"),
1070 $ilTabs->addTarget(
"statistics",
1071 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
1072 array(
"assessment"),
1076 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
1080 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
1084 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));