Public Member Functions

ASS_TextQuestionGUI Class Reference

Text question GUI representation. More...

Inheritance diagram for ASS_TextQuestionGUI:
Collaboration diagram for ASS_TextQuestionGUI:

Public Member Functions

 ASS_TextQuestionGUI ($id=-1)
 ASS_TextQuestionGUI constructor.
 getQuestionType ()
 Returns the question type string.
 editQuestion ()
 Creates an output of the edit form for the question.
 outOtherQuestionData ()
 Sets the extra fields i.e.
 checkInput ()
 check input fields
 writePostData ()
 Evaluates a posted edit form and writes the form data in the question object.
 outWorkingForm ($test_id="", $is_postponed=false, $showsolution=0)
 Creates the question output form for the learner.
 outUserSolution ($user_id, $test_id)
 Creates an output of the user's solution.
 addSuggestedSolution ()

Detailed Description

Text question GUI representation.

The ASS_TextQuestionGUI class encapsulates the GUI representation for text questions.

Author:
Helmut Schottmüller <hschottm@tzi.de>
Version:
Id:
class.assTextQuestionGUI.php 11101 2006-06-06 08:33:14Z hschottm

class.assTextQuestionGUI.php assessment

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


Member Function Documentation

ASS_TextQuestionGUI::addSuggestedSolution (  ) 

Reimplemented from ASS_QuestionGUI.

Definition at line 269 of file class.assTextQuestionGUI.php.

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

        {
                $_SESSION["subquestion_index"] = 0;
                if ($_POST["cmd"]["addSuggestedSolution"])
                {
                        $this->writePostData();
                        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("qt_text");
                parent::addSuggestedSolution();
        }

Here is the call graph for this function:

ASS_TextQuestionGUI::ASS_TextQuestionGUI ( id = -1  ) 

ASS_TextQuestionGUI constructor.

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

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

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

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

        {
                $this->ASS_QuestionGUI();
                $this->object = new ASS_TextQuestion();
                if ($id >= 0)
                {
                        $this->object->loadFromDb($id);
                }
        }

Here is the call graph for this function:

ASS_TextQuestionGUI::checkInput (  ) 

check input fields

Definition at line 175 of file class.assTextQuestionGUI.php.

References $_POST, and $cmd.

Referenced by addSuggestedSolution().

        {
                $cmd = $this->ctrl->getCmd();

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

Here is the caller graph for this function:

ASS_TextQuestionGUI::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 80 of file class.assTextQuestionGUI.php.

References ASS_Question::_getInternalLinkHref(), ASS_QuestionGUI::getQuestionTemplate(), and outOtherQuestionData().

Referenced by addSuggestedSolution().

        {
                $this->tpl->setVariable("HEADER", $this->object->getTitle());
                $javascript = "<script type=\"text/javascript\">function initialSelect() {\n%s\n}</script>";
                // single response
                $this->getQuestionTemplate("qt_text");
                $this->tpl->addBlockFile("QUESTION_DATA", "question_data", "tpl.il_as_qpl_text_question.html", true);
                // call to other question data i.e. estimated working time block
                $this->outOtherQuestionData();

                $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();
                }
                
                $this->tpl->setCurrentBlock("HeadContent");
                $this->tpl->setVariable("CONTENT_BLOCK", sprintf($javascript, "document.frm_text_question.title.focus();"));
                $this->tpl->parseCurrentBlock();
                $this->tpl->setCurrentBlock("question_data");
                $this->tpl->setVariable("TEXT_QUESTION_ID", $this->object->getId());
                $this->tpl->setVariable("VALUE_TEXT_QUESTION_TITLE", htmlspecialchars($this->object->getTitle()));
                $this->tpl->setVariable("VALUE_TEXT_QUESTION_COMMENT", htmlspecialchars($this->object->getComment()));
                $this->tpl->setVariable("VALUE_TEXT_QUESTION_AUTHOR", htmlspecialchars($this->object->getAuthor()));
                $questiontext = $this->object->get_question();
                $questiontext = preg_replace("/<br \/>/", "\n", $questiontext);
                $this->tpl->setVariable("VALUE_QUESTION", htmlspecialchars($questiontext));
                $this->tpl->setVariable("VALUE_POINTS", htmlspecialchars($this->object->getPoints()));
                if ($this->object->getMaxNumOfChars())
                {
                        $this->tpl->setVariable("VALUE_MAXCHARS", htmlspecialchars($this->object->getMaxNumOfChars()));
                }
                $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("TEXT_MAXCHARS", $this->lng->txt("maxchars"));
                $this->tpl->setVariable("TEXT_POINTS", $this->lng->txt("points"));
                $this->tpl->setVariable("DESCRIPTION_MAXCHARS", $this->lng->txt("description_maxchars"));
                $this->tpl->setVariable("TEXT_SOLUTION_HINT", $this->lng->txt("solution_hint"));
                if (count($this->object->suggested_solutions))
                {
                        $solution_array = $this->object->getSuggestedSolution(0);
                        $href = ASS_Question::_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("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
                $this->ctrl->setParameter($this, "sel_question_types", "qt_text");
                $this->tpl->setVariable("ACTION_TEXT_QUESTION", $this->ctrl->getFormAction($this));

                $this->tpl->parseCurrentBlock();

                $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:

ASS_TextQuestionGUI::getQuestionType (  ) 

Returns the question type string.

Returns the question type string

Returns:
string The question type string public

Reimplemented from ASS_QuestionGUI.

Definition at line 68 of file class.assTextQuestionGUI.php.

        {
                return "qt_text";
        }

ASS_TextQuestionGUI::outOtherQuestionData (  ) 

Sets the extra fields i.e.

estimated working time of a question from a posted create/edit form

Sets the extra fields i.e. estimated working time of a question from a posted create/edit form

private

Reimplemented from ASS_QuestionGUI.

Definition at line 162 of file class.assTextQuestionGUI.php.

References ilUtil::makeTimeSelect().

Referenced by editQuestion().

        {
                $this->tpl->setCurrentBlock("other_question_data");
                $est_working_time = $this->object->getEstimatedWorkingTime();
                $this->tpl->setVariable("TEXT_WORKING_TIME", $this->lng->txt("working_time"));
                $this->tpl->setVariable("TIME_FORMAT", $this->lng->txt("time_format"));
                $this->tpl->setVariable("VALUE_WORKING_TIME", ilUtil::makeTimeSelect("Estimated", false, $est_working_time[h], $est_working_time[m], $est_working_time[s]));
                $this->tpl->parseCurrentBlock();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ASS_TextQuestionGUI::outUserSolution ( user_id,
test_id 
)

Creates an output of the user's solution.

Creates an output of the user's solution

public

Definition at line 265 of file class.assTextQuestionGUI.php.

        {
        }

ASS_TextQuestionGUI::outWorkingForm ( test_id = "",
is_postponed = false,
showsolution = 0 
)

Creates the question output form for the learner.

Creates the question output form for the learner

public

Definition at line 230 of file class.assTextQuestionGUI.php.

References $ilUser, $output, and ASS_QuestionGUI::outQuestionPage().

        {
                global $ilUser;
                $output = $this->outQuestionPage("", $is_postponed);
                // set solutions
                if ($test_id)
                {
                        $solutions =& $this->object->getSolutionValues($test_id);
                        foreach ($solutions as $idx => $solution_value)
                        {
                                $repl_str = $solution_value->value1."</textarea>";
                                $output = str_replace("</textarea>", $repl_str, $output);
                        }
                        $reached_points = $this->object->getReachedPoints($ilUser->id, $test_id);
                        $received_points = "<p>" . sprintf($this->lng->txt("you_received_a_of_b_points"), $reached_points, $this->object->getMaximumPoints());
                        $received_points .= "</p>";
                }
                if ($this->object->getMaxNumOfChars())
                {
                        $output = str_replace("</textarea>", "</textarea><p>" . sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxNumOfChars()) . "</p>", $output);
                }
                if (!$showsolution)
                {
                        $received_points = "";
                }
                $this->tpl->setVariable("TEXT_QUESTION", $output.$received_points);
        }

Here is the call graph for this function:

ASS_TextQuestionGUI::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 ASS_QuestionGUI.

Definition at line 194 of file class.assTextQuestionGUI.php.

References $_POST, $result, ilUtil::stripSlashes(), and ASS_QuestionGUI::writeOtherPostData().

Referenced by addSuggestedSolution().

        {
                $result = 0;
                if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]) or (!$_POST["points"]))
                {
                        $result = 1;
                }

                $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
                $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
                $this->object->setComment(ilUtil::stripSlashes($_POST["comment"]));
                $questiontext = ilUtil::stripSlashes($_POST["question"], true, "<strong><em><code><cite>");
                $questiontext = preg_replace("/\n/", "<br />", $questiontext);
                $this->object->set_question($questiontext);
                $this->object->setPoints($_POST["points"]);
                $this->object->setSuggestedSolution($_POST["solution_hint"], 0);
                $this->object->setMaxNumOfChars($_POST["maxchars"]);

                $saved = $this->writeOtherPostData($result);

                // Set the question id from a hidden form parameter
                if ($_POST["text_question_id"] > 0)
                {
                        $this->object->setId($_POST["text_question_id"]);
                }
                
                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: