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. | |
| outAdditionalOutput () | |
| Overwrite in child classes if there is any additional action needed during the preview of the question. | |
| outWorkingForm ($test_id="", $is_postponed=false, $showsolution=0, $show_question_page=true, $show_solution_only=false, $ilUser=NULL, $pass=NULL, $mixpass=false) | |
| Creates the question output form for the learner. | |
| addSuggestedSolution () | |
Text question GUI representation.
The ASS_TextQuestionGUI class encapsulates the GUI representation for text questions.
class.assTextQuestionGUI.php assessment
Definition at line 38 of file class.assTextQuestionGUI.php.
| ASS_TextQuestionGUI::addSuggestedSolution | ( | ) |
Reimplemented from ASS_QuestionGUI.
Definition at line 335 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.
| 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();
include_once "./assessment/classes/class.assTextQuestion.php";
$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 178 of file class.assTextQuestionGUI.php.
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 81 of file class.assTextQuestionGUI.php.
References $key, 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);
include_once "./assessment/classes/class.assQuestion.php";
$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("TEXT_QUESTION_TYPE", $this->lng->txt("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
Reimplemented from ASS_QuestionGUI.
Definition at line 69 of file class.assTextQuestionGUI.php.
{
return "qt_text";
}
| ASS_TextQuestionGUI::outAdditionalOutput | ( | ) |
Overwrite in child classes if there is any additional action needed during the preview of the question.
Reimplemented from ASS_QuestionGUI.
Definition at line 226 of file class.assTextQuestionGUI.php.
Referenced by outWorkingForm().
{
if ($this->object->getMaxNumOfChars() > 0)
{
$this->tpl->addBlockFile("CONTENT_BLOCK", "charcounter", "tpl.charcounter.html", true);
$this->tpl->setCurrentBlock("charcounter");
$this->tpl->setVariable("CHARACTERS", $this->lng->txt("characters"));
$this->tpl->parseCurrentBlock();
}
}
Here is the caller graph for this function:| 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 165 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::outWorkingForm | ( | $ | test_id = "", |
|
| $ | is_postponed = false, |
|||
| $ | showsolution = 0, |
|||
| $ | show_question_page = true, |
|||
| $ | show_solution_only = false, |
|||
| $ | ilUser = NULL, |
|||
| $ | pass = NULL, |
|||
| $ | mixpass = false | |||
| ) |
Creates the question output form for the learner.
Creates the question output form for the learner
| integer | $test_id Database ID of a test which contains the question | |
| boolean | $is_postponed True if the question is a postponed question ("Postponed" added to the title) | |
| boolean | $showsolution Forces the output of the users solution if set to true | |
| boolean | $show_question_page Forces the output of the question only (without the surrounding page) when set to false. Default is true. | |
| boolean | $show_solution_only Forces the output of the correct question solution only when set to true. Default is false | |
| object | $ilUser The user object of the user who answered the question | |
| integer | $pass The pass of the question which should be displayed | |
| boolean | $mixpass Mixes test passes (takes the last pass of the question) when set to true. Default is false. public |
Definition at line 251 of file class.assTextQuestionGUI.php.
References $idx, $ilUser, $output, ilObjTest::_getHidePreviousResults(), ilObjTest::_getPass(), outAdditionalOutput(), and ASS_QuestionGUI::outQuestionPage().
{
if ($test_id) $this->outAdditionalOutput();
if (!is_object($ilUser))
{
global $ilUser;
}
$output = $this->outQuestionPage("", $is_postponed, $test_id);
if ($showsolution && !$show_solution_only)
{
$solutionintroduction = "<p>" . $this->lng->txt("tst_your_answer_was") . "</p>";
$output = preg_replace("/(<div[^<]*?ilc_PageTitle.*?<\/div>)/", "\\1" . $solutionintroduction, $output);
}
$solutionoutput = preg_replace("/.*?(<div[^<]*?ilc_Question.*?<\/div>).*/", "\\1", $output);
if (!$show_question_page)
{
$output = preg_replace("/.*?(<div[^<]*?ilc_Question.*?<\/div>).*/", "\\1", $output);
}
// if wants solution only then strip the question element from output
if ($show_solution_only)
{
$output = preg_replace("/(<div[^<]*?ilc_Question[^>]*>.*?<\/div>)/", "", $output);
}
// set solutions
if ($test_id)
{
$solutions = NULL;
include_once "./assessment/classes/class.ilObjTest.php";
if ((!$showsolution) && ilObjTest::_getHidePreviousResults($test_id, true))
{
if ($show_question_page)
{
if (is_null($pass)) $pass = ilObjTest::_getPass($ilUser->id, $test_id);
}
}
if ($mixpass) $pass = NULL;
$solutions =& $this->object->getSolutionValues($test_id, $ilUser, $pass);
foreach ($solutions as $idx => $solution_value)
{
$repl_str = $solution_value["value1"]."</textarea>";
$output = str_replace("</textarea>", $repl_str, $output);
}
if (!$show_question_page)
$output = preg_replace ("/<textarea[^>]*>(.*?)<\/textarea>/s","[\\1]", $output);
}
if ($showsolution)
{
$maxchars = "";
if ($this->object->getMaxNumOfChars())
{
$maxchars = "<p>" . $this->lng->txt("maxchars") . ": " . $this->object->getMaxNumOfChars() . "</p>";
}
$solutionoutput = preg_replace("/(<textarea.*?)<\/div>/", $maxchars . "<p>" . $this->lng->txt("tst_no_solution_available") . "</p></div>", $solutionoutput);
}
if ($this->object->getMaxNumOfChars())
{
$output = str_replace("<textarea", "<p class=\"quote\">" . sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxNumOfChars()) . "</p><textarea", $output);
}
if (!$showsolution)
{
$solutionoutput="";
$received_points = "";
}
$this->tpl->setVariable("TEXT_QUESTION", $output.$solutionoutput.$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
Reimplemented from ASS_QuestionGUI.
Definition at line 197 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:
1.7.1