function getTestOutput($active_id, $pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE) { // get the solution of the user for the active pass or from the last pass if allowed $user_solution = ""; if ($this->object->getIsMultipleChoice()) { $user_solution = array(); } if ($active_id) { $solutions = NULL; include_once "./Modules/Test/classes/class.ilObjTest.php"; if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) { if (is_null($pass)) { $pass = ilObjTest::_getPass($active_id); } } $solutions =& $this->object->getSolutionValues($active_id, $pass); foreach ($solutions as $idx => $solution_value) { if ($this->object->getIsMultipleChoice()) { $user_solution[] = $solution_value["value1"]; } else { $user_solution = $solution_value["value1"]; } } } $imagepath = $this->object->getImagePathWeb() . $this->object->getImageFilename(); if ($active_id) { $solutions = NULL; include_once "./Modules/Test/classes/class.ilObjTest.php"; if (!$showsolution && !ilObjTest::_getUsePreviousAnswers($active_id, true)) { if (is_null($pass)) { $pass = ilObjTest::_getPass($active_id); } } $solutions =& $this->object->getSolutionValues($active_id, $pass); include_once "./Modules/TestQuestionPool/classes/class.ilImagemapPreview.php"; $preview = new ilImagemapPreview($this->object->getImagePath() . $this->object->getImageFilename()); foreach ($solutions as $idx => $solution_value) { if (strcmp($solution_value["value1"], "") != 0) { $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); } } $preview->createPreview(); $imagepath = $this->object->getImagePathWeb() . $preview->getPreviewFilename($this->object->getImagePath(), $this->object->getImageFilename()); } // generate the question output include_once "./Services/UICore/classes/class.ilTemplate.php"; $template = new ilTemplate("tpl.il_as_qpl_imagemap_question_output.html", TRUE, TRUE, "Modules/TestQuestionPool"); $this->ctrl->setParameterByClass($this->getTargetGuiClass(), "formtimestamp", time()); $hrefArea = $this->ctrl->getLinkTargetByClass($this->getTargetGuiClass(), $this->getQuestionActionCmd()); foreach ($this->object->answers as $answer_id => $answer) { $template->setCurrentBlock("imagemap_area"); $parameter = "&selImage={$answer_id}"; if (is_array($user_solution) && in_array($answer_id, $user_solution)) { $parameter = "&remImage={$answer_id}"; } $template->setVariable("HREF_AREA", $hrefArea . $parameter); $template->setVariable("SHAPE", $answer->getArea()); $template->setVariable("COORDS", $answer->getCoords()); $template->setVariable("ALT", ilUtil::prepareFormOutput($answer->getAnswertext())); $template->setVariable("TITLE", ilUtil::prepareFormOutput($answer->getAnswertext())); $template->parseCurrentBlock(); if ($show_feedback) { if (!$this->object->getIsMultipleChoice() && strlen($user_solution) && $user_solution == $answer_id) { $feedback = $this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), $answer_id); if (strlen($feedback)) { $template->setCurrentBlock("feedback"); $template->setVariable("FEEDBACK", $feedback); $template->parseCurrentBlock(); } } } } $questiontext = $this->object->getQuestion(); $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE)); $template->setVariable("IMG_SRC", "{$imagepath}"); $template->setVariable("IMG_ALT", $this->lng->txt("imagemap")); $template->setVariable("IMG_TITLE", $this->lng->txt("imagemap")); $questionoutput = $template->get(); $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id, $questionoutput); return $pageoutput; }
/** * Insert property html */ function insert(&$a_tpl) { global $lng; $template = new ilTemplate("tpl.prop_imagemap_file.html", true, true, "Modules/TestQuestionPool"); $this->outputSuffixes($template, "allowed_image_suffixes"); if ($this->getImage() != "") { if (strlen($this->getValue())) { $template->setCurrentBlock("has_value"); $template->setVariable("TEXT_IMAGE_NAME", $this->getValue()); $template->setVariable("POST_VAR_D", $this->getPostVar()); $template->parseCurrentBlock(); } $template->setCurrentBlock("image"); if (count($this->getAreas())) { include_once "./Modules/TestQuestionPool/classes/class.ilImagemapPreview.php"; $preview = new ilImagemapPreview($this->getImagePath() . $this->getValue()); foreach ($this->getAreas() as $index => $area) { $preview->addArea($index, $area->getArea(), $area->getCoords(), $area->getAnswertext(), "", "", true, $this->getLineColor()); } $preview->createPreview(); $imagepath = $this->getImagePathWeb() . $preview->getPreviewFilename($this->getImagePath(), $this->getValue()) . "?img=" . time(); $template->setVariable("SRC_IMAGE", $imagepath); } else { $template->setVariable("SRC_IMAGE", $this->getImage()); } $template->setVariable("ALT_IMAGE", $this->getAlt()); $template->setVariable("POST_VAR_D", $this->getPostVar()); $template->setVariable("TXT_DELETE_EXISTING", $lng->txt("delete_existing_file")); $template->setVariable("TEXT_ADD_RECT", $lng->txt('add_rect')); $template->setVariable("TEXT_ADD_CIRCLE", $lng->txt('add_circle')); $template->setVariable("TEXT_ADD_POLY", $lng->txt('add_poly')); $template->parseCurrentBlock(); } if (is_array($this->getAreas()) && $this->getAreas()) { $counter = 0; foreach ($this->getAreas() as $area) { if (strlen($area->getPoints())) { $template->setCurrentBlock('area_points_value'); $template->setVariable('VALUE_POINTS', $area->getPoints()); $template->parseCurrentBlock(); } if ($this->getPointsUncheckedFieldEnabled()) { if (strlen($area->getPointsUnchecked())) { $template->setCurrentBlock('area_points_unchecked_value'); $template->setVariable('VALUE_POINTS_UNCHECKED', $area->getPointsUnchecked()); $template->parseCurrentBlock(); } $template->setCurrentBlock('area_points_unchecked_field'); $template->parseCurrentBlock(); } if (strlen($area->getAnswertext())) { $template->setCurrentBlock('area_name_value'); $template->setVariable('VALUE_NAME', $area->getAnswertext()); $template->parseCurrentBlock(); } $template->setCurrentBlock('row'); $template->setVariable('POST_VAR_R', $this->getPostVar()); $template->setVariable('TEXT_SHAPE', strtoupper($area->getArea())); $template->setVariable('VALUE_SHAPE', $area->getArea()); $coords = preg_replace("/(\\d+,\\d+,)/", "\$1 ", $area->getCoords()); $template->setVariable('VALUE_COORDINATES', $area->getCoords()); $template->setVariable('TEXT_COORDINATES', $coords); $template->setVariable('COUNTER', $counter); $template->setVariable("REMOVE_BUTTON", ilGlyphGUI::get(ilGlyphGUI::REMOVE)); $template->parseCurrentBlock(); $counter++; } $template->setCurrentBlock("areas"); $template->setVariable("TEXT_NAME", $lng->txt("hint")); if ($this->getPointsUncheckedFieldEnabled()) { $template->setVariable("TEXT_POINTS", $lng->txt("points_checked")); $template->setCurrentBlock('area_points_unchecked_head'); $template->setVariable("TEXT_POINTS_UNCHECKED", $lng->txt("points_unchecked")); $template->parseCurrentBlock(); } else { $template->setVariable("TEXT_POINTS", $lng->txt("points")); } $template->setVariable("TEXT_SHAPE", $lng->txt("shape")); $template->setVariable("TEXT_COORDINATES", $lng->txt("coordinates")); $template->setVariable("TEXT_COMMANDS", $lng->txt("actions")); $template->parseCurrentBlock(); } $template->setVariable("POST_VAR", $this->getPostVar()); $template->setVariable("ID", $this->getFieldId()); $template->setVariable("TXT_MAX_SIZE", $lng->txt("file_notice") . " " . $this->getMaxFileSizeString()); $a_tpl->setCurrentBlock("prop_generic"); $a_tpl->setVariable("PROP_GENERIC", $template->get()); $a_tpl->parseCurrentBlock(); global $tpl; $tpl->addJavascript("./Services/Form/js/ServiceFormWizardInput.js"); $tpl->addJavascript("./Modules/TestQuestionPool/templates/default/imagemap.js"); }