Public Member Functions

assImagemapQuestionGUI Class Reference

Image map question GUI representation. More...

Inheritance diagram for assImagemapQuestionGUI:
Collaboration diagram for assImagemapQuestionGUI:

Public Member Functions

 assImagemapQuestionGUI ($id=-1)
 assImagemapQuestionGUI constructor
 getQuestionType ()
 Returns the question type string.
 getCommand ($cmd)
 editQuestion ()
 Creates an output of the edit form for the question.
 getCoords ()
 back ()
 saveShape ()
 addArea ()
 uploadingImage ()
 uploadingImagemap ()
 deleteArea ()
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object.
 outQuestionForTest ($formaction, $active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE)
 getSolutionOutput ($active_id, $pass=NULL, $graphicalOutput=FALSE, $result_output=FALSE, $show_question_only=TRUE)
 getPreview ()
 getTestOutput ($active_id, $pass=NULL, $is_postponed=FALSE, $use_post_solutions=FALSE)
 checkInput ()
 check input fields
 addSuggestedSolution ()
 Handler for cmd[addSuggestedSolution] to add a suggested solution for the question.

Detailed Description

Image map question GUI representation.

The assImagemapQuestionGUI class encapsulates the GUI representation for image map questions.

Author:
Helmut Schottmüller <helmut.schottmueller@mac.com>
Version:
Id:
class.assImagemapQuestionGUI.php 14114 2007-06-12 14:41:49Z hschottm

class.assImagemapQuestionGUI.php Assessment

Definition at line 38 of file class.assImagemapQuestionGUI.php.


Member Function Documentation

assImagemapQuestionGUI::addArea (  ) 

Definition at line 450 of file class.assImagemapQuestionGUI.php.

References $_POST, $_SESSION, editQuestion(), assQuestionGUI::getErrorMessage(), sendInfo(), and writePostData().

        {
                $_SESSION["last_area"] = $_POST["newarea"];
                if ($this->writePostData())
                {
      sendInfo($this->getErrorMessage());
                        $this->ctrl->setCmd("");
                }
                $this->editQuestion();
        }

Here is the call graph for this function:

assImagemapQuestionGUI::addSuggestedSolution (  ) 

Handler for cmd[addSuggestedSolution] to add a suggested solution for the question.

Handler for cmd[addSuggestedSolution] to add a suggested solution for the question

public

Reimplemented from assQuestionGUI.

Definition at line 867 of file class.assImagemapQuestionGUI.php.

References $_GET, $_POST, $_SESSION, checkInput(), editQuestion(), assQuestionGUI::getErrorMessage(), assQuestionGUI::getQuestionTemplate(), sendInfo(), and writePostData().

        {
                $_SESSION["subquestion_index"] = 0;
                if ($_POST["cmd"]["addSuggestedSolution"])
                {
                        if ($this->writePostData())
                        {
                                sendInfo($this->getErrorMessage());
                                $this->editQuestion();
                                return;
                        }
                        if (!$this->checkInput())
                        {
                                sendInfo($this->lng->txt("fill_out_all_required_fields_add_answer"));
                                $this->editQuestion();
                                return;
                        }
                }
                $this->object->saveToDb();
                $_GET["q_id"] = $this->object->getId();
                $this->tpl->setVariable("HEADER", $this->object->getTitle());
                $this->getQuestionTemplate();
                parent::addSuggestedSolution();
        }

Here is the call graph for this function:

assImagemapQuestionGUI::assImagemapQuestionGUI ( id = -1  ) 

assImagemapQuestionGUI constructor

The constructor takes possible arguments an creates an instance of the assImagemapQuestionGUI object.

Parameters:
integer $id The database id of a image map question object public

Definition at line 48 of file class.assImagemapQuestionGUI.php.

References $id, and assQuestionGUI::assQuestionGUI().

        {
                include_once "./assessment/classes/class.assImagemapQuestion.php";
                $this->assQuestionGUI();
                $this->object = new assImagemapQuestion();
                if ($id >= 0)
                {
                        $this->object->loadFromDb($id);
                }
        }

Here is the call graph for this function:

assImagemapQuestionGUI::back (  ) 

Definition at line 440 of file class.assImagemapQuestionGUI.php.

References editQuestion().

        {
                $this->editQuestion();
        }

Here is the call graph for this function:

assImagemapQuestionGUI::checkInput (  ) 

check input fields

Definition at line 858 of file class.assImagemapQuestionGUI.php.

References $_POST.

Referenced by addSuggestedSolution(), and writePostData().

        {
                if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
                {
                        return false;
                }
                return true;
        }

Here is the caller graph for this function:

assImagemapQuestionGUI::deleteArea (  ) 

Definition at line 473 of file class.assImagemapQuestionGUI.php.

References $_POST, $key, editQuestion(), and writePostData().

        {
                $this->writePostData();
                $checked_areas = array();
                foreach ($_POST as $key => $value)
                {
                        if (preg_match("/cb_(\d+)/", $key, $matches))
                        {
                                array_push($checked_areas, $matches[1]);
                        }
                }
                rsort($checked_areas, SORT_NUMERIC);
                foreach ($checked_areas as $index)
                {
                        $this->object->deleteArea($index);
                }
                $this->editQuestion();
        }

Here is the call graph for this function:

assImagemapQuestionGUI::editQuestion (  ) 

Creates an output of the edit form for the question.

Creates an output of the edit form for the question

public

Definition at line 95 of file class.assImagemapQuestionGUI.php.

References $_GET, $_POST, $img, $key, $obj_id, $preview, assQuestion::_getInternalLinkHref(), ilRTE::_getRTEClassname(), ilObject::_lookupType(), ilUtil::getImagePath(), assQuestionGUI::getQuestionTemplate(), assQuestionGUI::outOtherQuestionData(), ilUtil::prepareFormOutput(), and sendInfo().

Referenced by addArea(), addSuggestedSolution(), back(), deleteArea(), getCoords(), uploadingImage(), and uploadingImagemap().

        {
                include_once "./assessment/classes/class.ilImagemapPreview.php";
                //$this->tpl->setVariable("HEADER", $this->object->getTitle());
                $this->getQuestionTemplate();
                $this->tpl->addBlockFile("QUESTION_DATA", "question_data", "tpl.il_as_qpl_imagemap_question.html", true);
                if (($this->ctrl->getCmd() == "addArea" or $this->ctrl->getCmd() == "getCoords") and ($this->ctrl->getCmd() != "saveShape"))
                {
                        foreach ($this->object->coords as $key => $value)
                        {
                                $this->tpl->setCurrentBlock("hidden");
                                $this->tpl->setVariable("HIDDEN_NAME", "coords_$key");
                                $this->tpl->setVariable("HIDDEN_VALUE", $value);
                                $this->tpl->parseCurrentBlock();
                        }
                        $this->tpl->setCurrentBlock("hidden");
                        $this->tpl->setVariable("HIDDEN_NAME", "newarea");
                        $this->tpl->setVariable("HIDDEN_VALUE", $_POST["newarea"]);
                        $this->tpl->parseCurrentBlock();

                        $preview = new ilImagemapPreview($this->object->getImagePath().$this->object->get_image_filename());
                        foreach ($this->object->answers as $index => $answer)
                        {
                                $preview->addArea($index, $answer->getArea(), $answer->getCoords(), $answer->getAnswertext(), "", "", true);
                        }
                        $hidearea = false;
                        $disabled_save = " disabled=\"disabled\"";
                        $coords = "";
                        switch ($_POST["newarea"])
                        {
                                case "rect":
                                        if (count($this->object->coords) == 0)
                                        {
                                                sendInfo($this->lng->txt("rectangle_click_tl_corner"));
                                        }
                                        else if (count($this->object->coords) == 1)
                                        {
                                                sendInfo($this->lng->txt("rectangle_click_br_corner"));
                                        }
                                        else if (count($this->object->coords) == 2)
                                        {
                                                $coords = join($this->object->coords, ",");
                                                $hidearea = true;
                                                $disabled_save = "";
                                        }
                                        break;
                                case "circle":
                                        if (count($this->object->coords) == 0)
                                        {
                                                sendInfo($this->lng->txt("circle_click_center"));
                                        }
                                        else if (count($this->object->coords) == 1)
                                        {
                                                sendInfo($this->lng->txt("circle_click_circle"));
                                        }
                                        else if (count($this->object->coords) == 2)
                                        {
                                                if (preg_match("/(\d+)\s*,\s*(\d+)\s+(\d+)\s*,\s*(\d+)/", $this->object->coords[0] . " " . $this->object->coords[1], $matches))
                                                {
                                                        $coords = "$matches[1],$matches[2]," . (int)sqrt((($matches[3]-$matches[1])*($matches[3]-$matches[1]))+(($matches[4]-$matches[2])*($matches[4]-$matches[2])));
                                                }
                                                $hidearea = true;
                                                $disabled_save = "";
                                        }
                                        break;
                                case "poly":
                                        if (count($this->object->coords) == 0)
                                        {
                                                sendInfo($this->lng->txt("polygon_click_starting_point"));
                                        }
                                        else if (count($this->object->coords) == 1)
                                        {
                                                sendInfo($this->lng->txt("polygon_click_next_point"));
                                        }
                                        else if (count($this->object->coords) > 1)
                                        {
                                                sendInfo($this->lng->txt("polygon_click_next_or_save"));
                                                $disabled_save = "";
                                                $coords = join($this->object->coords, ",");
                                        }
                                        break;
                        }
                        if ($coords)
                        {
                                $preview->addArea($preview->getAreaCount(), $_POST["newarea"], $coords, $_POST["shapetitle"], "", "", true, "blue");
                        }
                        $preview->createPreview();
                        $imagepath = $this->object->getImagePathWeb() . $preview->getPreviewFilename($this->object->getImagePath(), $this->object->get_image_filename());
                        if (!$hidearea)
                        {
                                $this->tpl->setCurrentBlock("maparea");
                                $this->tpl->setVariable("IMAGE_SOURCE", "$imagepath");
                                $this->tpl->parseCurrentBlock();
                        }
                        else
                        {
                                $this->tpl->setCurrentBlock("imagearea");
                                $this->tpl->setVariable("IMAGE_SOURCE", "$imagepath");
                                $this->tpl->setVariable("ALT_IMAGE", $this->lng->txt("imagemap"));
                                $this->tpl->parseCurrentBlock();
                        }
                        $this->tpl->setCurrentBlock("imagemapeditor");
                        $this->tpl->setVariable("TEXT_IMAGEMAP", $this->lng->txt("imagemap"));
                        $this->tpl->setVariable("VALUE_SHAPETITLE", $_POST["shapetitle"]);
                        $this->tpl->setVariable("TEXT_SHAPETITLE", $this->lng->txt("name"));
                        $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
                        $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
                        $this->tpl->setVariable("DISABLED_SAVE", $disabled_save);
                        $this->tpl->parseCurrentBlock();
                        $this->tpl->setCurrentBlock("adm_content");
                        $this->tpl->setVariable("IMAGEMAP_ID", $this->object->getId());
                        $this->ctrl->setParameter($this, "sel_question_types", "assImagemapQuestion");
                        $this->ctrl->setParameter($this, "editmap", "1");
                        $this->tpl->setVariable("ACTION_IMAGEMAP_QUESTION",     $this->ctrl->getFormaction($this));
                        $this->tpl->parseCurrentBlock();
                }
                else
                {
                        $tblrow = array("tblrow1top", "tblrow2top");
                        for ($i = 0; $i < $this->object->getAnswerCount(); $i++)
                        {
                                $this->tpl->setCurrentBlock("answers");
                                $answer = $this->object->getAnswer($i);
                                $this->tpl->setVariable("ANSWER_ORDER", $answer->getOrder());
                                $this->tpl->setVariable("VALUE_ANSWER", ilUtil::prepareFormOutput($answer->getAnswertext()));
                                $this->tpl->setVariable("TEXT_POINTS", $this->lng->txt("points"));
                                if ((strcmp($_GET["markarea"], "") != 0) && ($_GET["markarea"] == $i))
                                {
                                        $this->tpl->setVariable("CLASS_FULLWIDTH", "fullwidth_marked");
                                }
                                else
                                {
                                        $this->tpl->setVariable("CLASS_FULLWIDTH", "fullwidth");
                                }
                                $this->tpl->setVariable("VALUE_IMAGEMAP_POINTS", $answer->getPoints());
                                $this->tpl->setVariable("COLOR_CLASS", $tblrow[$i % 2]);
                                $coords = "";
                                switch ($answer->getArea())
                                {
                                        case "poly":
                                        case "rect":
                                                $coords = preg_replace("/(\d+,\d+,)/", "\$1 ", $answer->getCoords());
                                                break;
                                        case "circle":
                                                $coords = preg_replace("/(\d+,\d+,)/", "\$1 ", $answer->getCoords());
                                                break;
                                }
                                $this->tpl->setVariable("COORDINATES", $coords);
                                $this->tpl->setVariable("AREA", $answer->getArea());
                                $this->tpl->setVariable("TEXT_SHAPE", strtoupper($answer->getArea()));
                                $this->tpl->parseCurrentBlock();
                        }
                        if ($this->object->getAnswerCount())
                        {
                                $this->tpl->setCurrentBlock("selectall");
                                $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
                                $i++;
                                $this->tpl->setVariable("COLOR_CLASS", $tblrow[$i % 2]);
                                $this->tpl->parseCurrentBlock();
                                $this->tpl->setCurrentBlock("QFooter");
                                $this->tpl->setVariable("DELETE_AREA", $this->lng->txt("delete_area"));
                                $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
                                $this->tpl->parseCurrentBlock();
                                $this->tpl->setCurrentBlock("answerheader");
                                $this->tpl->setVariable("TEXT_NAME", $this->lng->txt("name"));
                                $this->tpl->setVariable("TEXT_TRUE", $this->lng->txt("true"));
                                $this->tpl->setVariable("TEXT_POINTS", $this->lng->txt("points"));
                                $this->tpl->setVariable("TEXT_SHAPE", $this->lng->txt("shape"));
                                $this->tpl->setVariable("TEXT_COORDINATES", $this->lng->txt("coordinates"));
                                $this->tpl->parseCurrentBlock();
                        }
                        // call to other question data i.e. estimated working time block
                        $this->outOtherQuestionData();
                        // image block

                        $internallinks = array(
                                "lm" => $this->lng->txt("obj_lm"),
                                "st" => $this->lng->txt("obj_st"),
                                "pg" => $this->lng->txt("obj_pg"),
                                "glo" => $this->lng->txt("glossary_term")
                        );
                        foreach ($internallinks as $key => $value)
                        {
                                $this->tpl->setCurrentBlock("internallink");
                                $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
                                $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
                                $this->tpl->parseCurrentBlock();
                        }

                        if (strcmp($this->object->get_image_filename(), "") != 0)
                        {
                                $this->tpl->setCurrentBlock("addarea");
                                $this->tpl->setVariable("ADD_AREA", $this->lng->txt("add_area"));
                                $this->tpl->setVariable("TEXT_RECT", $this->lng->txt("rectangle"));
                                $this->tpl->setVariable("TEXT_CIRCLE", $this->lng->txt("circle"));
                                $this->tpl->setVariable("TEXT_POLY", $this->lng->txt("polygon"));
                                if (array_key_exists("newarea", $_POST))
                                {
                                        switch ($_POST["newarea"])
                                        {
                                                case "circle":
                                                        $this->tpl->setVariable("SELECTED_CIRCLE", " selected=\"selected\"");
                                                        break;
                                                case "poly":
                                                        $this->tpl->setVariable("SELECTED_POLY", " selected=\"selected\"");
                                                        break;
                                                case "rect":
                                                        $this->tpl->setVariable("SELECTED_RECT", " selected=\"selected\"");
                                                        break;
                                        }
                                }
                                $this->tpl->parseCurrentBlock();
                        }
                        $this->tpl->setCurrentBlock("HeadContent");
                        $javascript = "<script type=\"text/javascript\">function initialSelect() {\n%s\n}</script>";
                        if (strcmp($_GET["markarea"], "") != 0)
                        {
                                $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_imagemap.answer_".$_GET["markarea"].".focus(); document.frm_imagemap.answer_".$_GET["markarea"].".scrollIntoView(\"true\");"));
                        }
                        else
                        {
                                switch ($this->ctrl->getCmd())
                                {
                                        case "saveShape":
                                        case "deletearea":
                                                if ($this->object->getAnswerCount() > 0)
                                                {
                                                        $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\");"));
                                                }
                                                else
                                                {
                                                        $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_imagemap.title.focus();"));
                                                }
                                                break;
                                        default:
                                                $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_imagemap.title.focus();"));
                                                break;
                                }
                        }
                        $this->tpl->parseCurrentBlock();
                        $this->tpl->setCurrentBlock("question_data");
                        $img = $this->object->get_image_filename();
                        $this->tpl->setVariable("TEXT_IMAGE", $this->lng->txt("image"));
                        if (!empty($img))
                        {
                                $this->tpl->setVariable("IMAGE_FILENAME", $img);
                                $this->tpl->setVariable("VALUE_IMAGE_UPLOAD", $this->lng->txt("change"));
                                $this->tpl->setCurrentBlock("imageupload");
                                //$this->tpl->setVariable("UPLOADED_IMAGE", $img);
                                $this->tpl->parse("imageupload");
                                $map = "";
                                if (count($this->object->answers))
                                {
                                        $preview = new ilImagemapPreview($this->object->getImagePath() . $this->object->get_image_filename());
                                        foreach ($this->object->answers as $index => $answer)
                                        {
                                                $preview->addArea($index, $answer->getArea(), $answer->getCoords(), $answer->getAnswertext(), $this->ctrl->getLinkTarget($this, "editQuestion") . "&markarea=$index", "", true);
                                        }
                                        $preview->createPreview();
                                        $imagepath = $this->object->getImagePathWeb() . $preview->getPreviewFilename($this->object->getImagePath(), $this->object->get_image_filename());
                                        $map = $preview->getImagemap("imagemap_" . $this->object->getId());
                                }
                                else
                                {
                                        $imagepath = $this->object->getImagePathWeb() . $img;
                                }
                                $size = GetImageSize ($this->object->getImagePath() . $this->object->get_image_filename());
                                if ($map)
                                {
                                        $this->tpl->setVariable("UPLOADED_IMAGE", "<img src=\"$imagepath\" alt=\"$img\" border=\"0\" " . $size[3] . " usemap=\"" . "#imagemap_" . $this->object->getId(). "\" />\n$map\n");
                                }
                                else
                                {
                                        $this->tpl->setVariable("UPLOADED_IMAGE", "<img src=\"$imagepath\" alt=\"$img\" border=\"0\" " . $size[3] . " />");
                                }
                        }
                        else
                        {
                                $this->tpl->setVariable("VALUE_IMAGE_UPLOAD", $this->lng->txt("upload"));
                        }

                        // imagemap block
                        $imgmap = $this->object->get_imagemap_filename();
                        $this->tpl->setVariable("TEXT_IMAGEMAP", $this->lng->txt("imagemap_file"));
                        $this->tpl->setVariable("VALUE_IMAGEMAP_UPLOAD", $this->lng->txt("add_imagemap"));
                        $this->tpl->setCurrentBlock("questioneditor");
                        $this->tpl->setVariable("VALUE_IMAGEMAP_TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
                        $this->tpl->setVariable("VALUE_IMAGEMAP_COMMENT", ilUtil::prepareFormOutput($this->object->getComment()));
                        $this->tpl->setVariable("VALUE_IMAGEMAP_AUTHOR", ilUtil::prepareFormOutput($this->object->getAuthor()));
                        $questiontext = $this->object->getQuestion();
                        $this->tpl->setVariable("VALUE_QUESTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
                        $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
                        $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
                        $this->tpl->setVariable("TEXT_COMMENT", $this->lng->txt("description"));
                        $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
                        $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));

                        $this->tpl->setVariable("TEXT_SOLUTION_HINT", $this->lng->txt("solution_hint"));
                        if (count($this->object->suggested_solutions))
                        {
                                $solution_array = $this->object->getSuggestedSolution(0);
                                include_once "./assessment/classes/class.assQuestion.php";
                                $href = assQuestion::_getInternalLinkHref($solution_array["internal_link"]);
                                $this->tpl->setVariable("TEXT_VALUE_SOLUTION_HINT", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("solution_hint"). "</a> ");
                                $this->tpl->setVariable("BUTTON_REMOVE_SOLUTION", $this->lng->txt("remove"));
                                $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("change"));
                                $this->tpl->setVariable("VALUE_SOLUTION_HINT", $solution_array["internal_link"]);
                        }
                        else
                        {
                                $this->tpl->setVariable("BUTTON_ADD_SOLUTION", $this->lng->txt("add"));
                        }

                        $this->tpl->setVariable("SAVE",$this->lng->txt("save"));
                        $this->tpl->setVariable("SAVE_EDIT", $this->lng->txt("save_edit"));
                        $this->tpl->setVariable("CANCEL",$this->lng->txt("cancel"));
                        $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("assImagemapQuestion"));
                        $this->tpl->parseCurrentBlock();
                        $this->tpl->setCurrentBlock("adm_content");
                        $this->ctrl->setParameter($this, "sel_question_types", "assImagemapQuestion");
                        $this->tpl->setVariable("ACTION_IMAGEMAP_QUESTION",     $this->ctrl->getFormaction($this));
                        $this->tpl->setVariable("IMAGEMAP_ID", $this->object->getId());
                        $this->tpl->parseCurrentBlock();
                        include_once "./Services/RTE/classes/class.ilRTE.php";
                        $rtestring = ilRTE::_getRTEClassname();
                        include_once "./Services/RTE/classes/class.$rtestring.php";
                        $rte = new $rtestring();
                        $rte->addPlugin("latex");
                        $rte->addButton("latex");
                        include_once "./classes/class.ilObject.php";
                        $obj_id = $_GET["q_id"];
                        $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
                        $rte->addRTESupport($obj_id, $obj_type, "assessment");
                        $this->tpl->setCurrentBlock("adm_content");
                        $this->tpl->setVariable("BODY_ATTRIBUTES", " onload=\"initialSelect();\""); 
                        $this->tpl->parseCurrentBlock();
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

assImagemapQuestionGUI::getCommand ( cmd  ) 

Reimplemented from assQuestionGUI.

Definition at line 74 of file class.assImagemapQuestionGUI.php.

References $_POST, and $cmd.

        {
                if (isset($_POST["imagemap"]) ||
                isset($_POST["imagemap_x"]) ||
                isset($_POST["imagemap_y"]))
                {
                        $this->ctrl->setCmd("getCoords");
                        $cmd = "getCoords";
                }

                return $cmd;
        }

assImagemapQuestionGUI::getCoords (  ) 

Definition at line 434 of file class.assImagemapQuestionGUI.php.

References editQuestion(), and writePostData().

        {
                $this->writePostData();
                $this->editQuestion();
        }

Here is the call graph for this function:

assImagemapQuestionGUI::getPreview (  ) 

Definition at line 758 of file class.assImagemapQuestionGUI.php.

References ilUtil::prepareFormOutput().

        {
                $imagepath = $this->object->getImagePathWeb() . $this->object->get_image_filename();
                // generate the question output
                include_once "./classes/class.ilTemplate.php";
                $template = new ilTemplate("tpl.il_as_qpl_imagemap_question_output.html", TRUE, TRUE, TRUE);
                $formaction = "#";
                foreach ($this->object->answers as $answer_id => $answer)
                {
                        $template->setCurrentBlock("imagemap_area");
                        $template->setVariable("HREF_AREA", $formaction);
                        $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();
                }
                $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();
                $questionoutput = preg_replace("/<div[^>]*?>(.*)<\/div>/is", "\\1", $questionoutput);
                return $questionoutput;
        }

Here is the call graph for this function:

assImagemapQuestionGUI::getQuestionType (  ) 

Returns the question type string.

Returns the question type string

Returns:
string The question type string public

Reimplemented from assQuestionGUI.

Definition at line 69 of file class.assImagemapQuestionGUI.php.

        {
                return "assImagemapQuestion";
        }

assImagemapQuestionGUI::getSolutionOutput ( active_id,
pass = NULL,
graphicalOutput = FALSE,
result_output = FALSE,
show_question_only = TRUE 
)

Definition at line 663 of file class.assImagemapQuestionGUI.php.

References $idx, $preview, ilObjTest::_getHidePreviousResults(), ilObjTest::_getPass(), assQuestionGUI::getILIASPage(), and ilUtil::getImagePath().

        {
                $imagepath = $this->object->getImagePathWeb() . $this->object->get_image_filename();
                $solutions = array();
                if ($active_id)
                {
                        include_once "./assessment/classes/class.ilObjTest.php";
                        if ((!$showsolution) && ilObjTest::_getHidePreviousResults($active_id, true))
                        {
                                if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
                        }
                        $solutions =& $this->object->getSolutionValues($active_id, $pass);
                }
                else
                {
                        $found_index = -1;
                        $max_points = 0;
                        foreach ($this->object->answers as $index => $answer)
                        {
                                if ($answer->getPoints() > $max_points)
                                {
                                        $max_points = $answer->getPoints();
                                        $found_index = $index;
                                }
                        }
                        array_push($solutions, array("value1" => $found_index));
                }
                if (is_array($solutions))
                {
                        include_once "./assessment/classes/class.ilImagemapPreview.php";
                        $preview = new ilImagemapPreview($this->object->getImagePath().$this->object->get_image_filename());
                        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);
                                }
                        }
                        $preview->createPreview();
                        $imagepath = $this->object->getImagePathWeb() . $preview->getPreviewFilename($this->object->getImagePath(), $this->object->get_image_filename());
                }
                
                // generate the question output
                include_once "./classes/class.ilTemplate.php";
                $template = new ilTemplate("tpl.il_as_qpl_imagemap_question_output_solution.html", TRUE, TRUE, TRUE);
                $solutiontemplate = new ilTemplate("tpl.il_as_tst_solution_output.html", TRUE, TRUE, TRUE);
                $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"));
                if ($active_id)
                {
                        if ($graphicalOutput)
                        {
                                // output of ok/not ok icons for user entered solutions
                                $reached_points = $this->object->getReachedPoints($active_id);
                                if ($reached_points == $this->object->getMaximumPoints())
                                {
                                        $template->setCurrentBlock("icon_ok");
                                        $template->setVariable("ICON_OK", ilUtil::getImagePath("icon_ok.gif"));
                                        $template->setVariable("TEXT_OK", $this->lng->txt("answer_is_right"));
                                        $template->parseCurrentBlock();
                                }
                                else
                                {
                                        $template->setCurrentBlock("icon_ok");
                                        if ($reached_points > 0)
                                        {
                                                $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_mostly_ok.gif"));
                                                $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_not_correct_but_positive"));
                                        }
                                        else
                                        {
                                                $template->setVariable("ICON_NOT_OK", ilUtil::getImagePath("icon_not_ok.gif"));
                                                $template->setVariable("TEXT_NOT_OK", $this->lng->txt("answer_is_wrong"));
                                        }
                                        $template->parseCurrentBlock();
                                }
                        }
                }
                        
                $questionoutput = $template->get();
                $solutiontemplate->setVariable("SOLUTION_OUTPUT", $questionoutput);

                $solutionoutput = $solutiontemplate->get(); 
                if (!$show_question_only)
                {
                        // get page object output
                        $pageoutput = $this->getILIASPage();
                        $solutionoutput = preg_replace("/(<div( xmlns:xhtml\=\"http:\/\/www.w3.org\/1999\/xhtml\"){0,1} class\=\"ilc_Question\"><\/div>)/ims", $solutionoutput, $pageoutput);
                }
                return $solutionoutput;
        }

Here is the call graph for this function:

assImagemapQuestionGUI::getTestOutput ( active_id,
pass = NULL,
is_postponed = FALSE,
use_post_solutions = FALSE 
)

Definition at line 785 of file class.assImagemapQuestionGUI.php.

References $idx, $preview, ilObjTest::_getHidePreviousResults(), ilObjTest::_getPass(), assQuestionGUI::outQuestionPage(), and ilUtil::prepareFormOutput().

Referenced by outQuestionForTest().

        {
                // get page object output
                $pageoutput = $this->outQuestionPage("", $is_postponed, $active_id);

                // get the solution of the user for the active pass or from the last pass if allowed
                $user_solution = "";
                if ($active_id)
                {
                        $solutions = NULL;
                        include_once "./assessment/classes/class.ilObjTest.php";
                        if (ilObjTest::_getHidePreviousResults($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)
                        {
                                $user_solution = $solution_value["value1"];
                        }
                }

                $imagepath = $this->object->getImagePathWeb() . $this->object->get_image_filename();
                if ($active_id)
                {
                        $solutions = NULL;
                        include_once "./assessment/classes/class.ilObjTest.php";
                        if ((!$showsolution) && ilObjTest::_getHidePreviousResults($active_id, true))
                        {
                                if (is_null($pass)) $pass = ilObjTest::_getPass($active_id);
                        }
                        $solutions =& $this->object->getSolutionValues($active_id, $pass);
                        include_once "./assessment/classes/class.ilImagemapPreview.php";
                        $preview = new ilImagemapPreview($this->object->getImagePath().$this->object->get_image_filename());
                        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);
                                }
                        }
                        $preview->createPreview();
                        $imagepath = $this->object->getImagePathWeb() . $preview->getPreviewFilename($this->object->getImagePath(), $this->object->get_image_filename());
                }
                
                // generate the question output
                include_once "./classes/class.ilTemplate.php";
                $template = new ilTemplate("tpl.il_as_qpl_imagemap_question_output.html", TRUE, TRUE, TRUE);
                $this->ctrl->setParameterByClass("ilTestOutputGUI", "formtimestamp", time());
                $formaction = $this->ctrl->getLinkTargetByClass("ilTestOutputGUI", "selectImagemapRegion");
                foreach ($this->object->answers as $answer_id => $answer)
                {
                        $template->setCurrentBlock("imagemap_area");
                        $template->setVariable("HREF_AREA", $formaction . "&amp;selImage=$answer_id");
                        $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();
                }
                $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();
                $questionoutput = preg_replace("/(<div( xmlns:xhtml\=\"http:\/\/www.w3.org\/1999\/xhtml\"){0,1} class\=\"ilc_Question\"><\/div>)/ims", $questionoutput, $pageoutput);
                return $questionoutput;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

assImagemapQuestionGUI::outQuestionForTest ( formaction,
active_id,
pass = NULL,
is_postponed = FALSE,
use_post_solutions = FALSE 
)

Definition at line 636 of file class.assImagemapQuestionGUI.php.

References ilObjTest::_getHidePreviousResults(), ilObjTest::_getPass(), and getTestOutput().

        {
                $test_output = $this->getTestOutput($active_id, $pass, $is_postponed, $use_post_solutions); 
                $this->tpl->setVariable("QUESTION_OUTPUT", $test_output);

                $this->ctrl->setParameterByClass("ilTestOutputGUI", "formtimestamp", time());
                $formaction = $this->ctrl->getLinkTargetByClass("ilTestOutputGUI", "selectImagemapRegion");
                include_once "./assessment/classes/class.ilObjTest.php";
                if (ilObjTest::_getHidePreviousResults($active_id, true))
                {
                        $pass = ilObjTest::_getPass($active_id);
                        $info =& $this->object->getSolutionValues($active_id, $pass);
                }
                else
                {
                        $info =& $this->object->getSolutionValues($active_id, NULL);
                }
                if (count($info))
                {
                        if (strcmp($info[0]["value1"], "") != 0)
                        {
                                $formaction .= "&selImage=" . $info[0]["value1"];
                        }
                }
                $this->tpl->setVariable("FORMACTION", $formaction);
        }

Here is the call graph for this function:

assImagemapQuestionGUI::saveShape (  ) 

Definition at line 445 of file class.assImagemapQuestionGUI.php.

References assQuestionGUI::save().

        {
                $this->save();
        }

Here is the call graph for this function:

assImagemapQuestionGUI::uploadingImage (  ) 

Definition at line 461 of file class.assImagemapQuestionGUI.php.

References editQuestion(), and writePostData().

        {
                $this->writePostData();
                $this->editQuestion();
        }

Here is the call graph for this function:

assImagemapQuestionGUI::uploadingImagemap (  ) 

Definition at line 467 of file class.assImagemapQuestionGUI.php.

References editQuestion(), and writePostData().

        {
                $this->writePostData();
                $this->editQuestion();
        }

Here is the call graph for this function:

assImagemapQuestionGUI::writePostData (  ) 

Evaluates a posted edit form and writes the form data in the question object.

Evaluates a posted edit form and writes the form data in the question object

Returns:
integer A positive value, if one of the required fields wasn't set, else 0 private

Reimplemented from assQuestionGUI.

Definition at line 500 of file class.assImagemapQuestionGUI.php.

References $_GET, $_POST, $key, $result, ilObjAdvancedEditing::_getUsedHTMLTagsAsString(), checkInput(), sendInfo(), ilUtil::stripSlashes(), and assQuestionGUI::writeOtherPostData().

Referenced by addArea(), addSuggestedSolution(), deleteArea(), getCoords(), uploadingImage(), and uploadingImagemap().

        {
                $result = 0;
                $saved = false;

                if ($_GET["editmap"])
                {
                        $this->object->coords = array();
                        foreach ($_POST as $key => $value)
                        {
                                if (preg_match("/coords_(\d+)/", $key, $matches))
                                {
                                        $this->object->coords[$matches[1]] = $value;
                                }
                        }
                        if (isset($_POST["imagemap_x"]))
                        {
                                array_push($this->object->coords, $_POST["imagemap_x"] . "," . $_POST["imagemap_y"]);
                        }
                        if ($this->ctrl->getCmd() == "saveShape")
                        {
                                $coords = "";
                                switch ($_POST["newarea"])
                                {
                                        case "rect":
                                                $coords = join($this->object->coords, ",");
                                                break;
                                        case "circle":
                                                if (preg_match("/(\d+)\s*,\s*(\d+)\s+(\d+)\s*,\s*(\d+)/", $this->object->coords[0] . " " . $this->object->coords[1], $matches))
                                                {
                                                        $coords = "$matches[1],$matches[2]," . (int)sqrt((($matches[3]-$matches[1])*($matches[3]-$matches[1]))+(($matches[4]-$matches[2])*($matches[4]-$matches[2])));
                                                }
                                                break;
                                        case "poly":
                                                $coords = join($this->object->coords, ",");
                                                break;
                                }
                                $this->object->addAnswer($_POST["shapetitle"], 0, count($this->object->answers), $coords, $_POST["newarea"]);
                        }
                }
                else
                {
                        if (!$this->checkInput())
                        {
                                $result = 1;
                        }
                        $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
                        $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
                        $this->object->setComment(ilUtil::stripSlashes($_POST["comment"]));
                        include_once "./classes/class.ilObjAdvancedEditing.php";
                        $questiontext = ilUtil::stripSlashes($_POST["question"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
                        $this->object->setQuestion($questiontext);
                        $this->object->setSuggestedSolution($_POST["solution_hint"], 0);
                        $this->object->setShuffle($_POST["shuffle"]);

                        // adding estimated working time
                        $saved = $this->writeOtherPostData($result);

                        if (($_POST["id"] > 0) or ($result != 1))
                        {
                                // Question is already saved, so imagemaps and images can be uploaded
                                //setting image file
                                if (empty($_FILES['imageName']['tmp_name']))
                                {
                                        $this->object->setImageFilename(ilUtil::stripSlashes($_POST["uploaded_image"]));
                                }
                                else
                                {
                                        if ($this->object->getId() <= 0)
                                        {
                                                $this->object->saveToDb();
                                                $_GET["q_id"] = $this->object->getId();
                                                $saved = true;
                                                sendInfo($this->lng->txt("question_saved_for_upload"));
                                        }
                                        $this->object->setImageFilename($_FILES['imageName']['name'], $_FILES['imageName']['tmp_name']);
                                }

                                //setting imagemap
                                if (empty($_FILES['imagemapName']['tmp_name']))
                                {
                                        $this->object->setImagemapFilename(ilUtil::stripSlashes($_POST['uploaded_imagemap']));
                                        // Add all answers from the form into the object
                                        $this->object->flushAnswers();
                                        foreach ($_POST as $key => $value)
                                        {
                                                if (preg_match("/answer_(\d+)/", $key, $matches))
                                                {
                                                        $points = $_POST["points_$matches[1]"];

                                                        $this->object->addAnswer(
                                                                ilUtil::stripSlashes($_POST["$key"]),
                                                                ilUtil::stripSlashes($points),
                                                                $matches[1],
                                                                ilUtil::stripSlashes($_POST["coords_$matches[1]"]),
                                                                ilUtil::stripSlashes($_POST["area_$matches[1]"])
                                                        );
                                                }
                                        }
                                }
                                else
                                {
                                        if ($this->object->getId() <= 0)
                                        {
                                                $this->object->saveToDb();
                                                $_GET["q_id"] = $this->object->getId();
                                                $saved = true;
                                                sendInfo($this->lng->txt("question_saved_for_upload"));
                                        }
                                        $this->object->setImagemapFilename($_FILES['imagemapName']['name'], $_FILES['imagemapName']['tmp_name']);
                                }
                        }
                        else
                        {
                                if (($this->ctrl->getCmd() == "uploadingImage") and (!empty($_FILES['imageName']['tmp_name'])))
                                {
                                        sendInfo($this->lng->txt("fill_out_all_required_fields_upload_image"));
                                }
                                else if (($_POST["cmd"]["uploadingImagemap"]) and (!empty($_FILES['imagemapName']['tmp_name'])))
                                {
                                        sendInfo($this->lng->txt("fill_out_all_required_fields_upload_imagemap"));
                                }
                        }
                }
                if ($this->ctrl->getCmd() == "addArea")
                {
                        $this->object->saveToDb();
                        $saved = true;
                }
                if ($saved)
                {
                        $_GET["q_id"] = $this->object->getId();
                }
                return $result;
        }

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: