Text survey question GUI representation. More...
Inheritance diagram for SurveyTextQuestionGUI:
Collaboration diagram for SurveyTextQuestionGUI:Public Member Functions | |
| SurveyTextQuestionGUI ($id=-1) | |
| SurveyTextQuestionGUI constructor. | |
| getQuestionType () | |
| Returns the question type string. | |
| editQuestion () | |
| Creates an output of the edit form for the question. | |
| outWorkingForm ($working_data="", $question_title=1, $error_message="") | |
| Creates the question output form for the learner. | |
| preview () | |
| Creates a preview of the question. | |
| writePostData () | |
| Evaluates a posted edit form and writes the form data in the question object. | |
| setQuestionTabs () | |
| outCumulatedResultsDetails (&$cumulated_results, $counter) | |
Text survey question GUI representation.
The SurveyTextQuestionGUI class encapsulates the GUI representation for text survey question types.
class.SurveyTextQuestionGUI.php Survey
Definition at line 38 of file class.SurveyTextQuestionGUI.php.
| SurveyTextQuestionGUI::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 83 of file class.SurveyTextQuestionGUI.php.
References $_GET, $key, $obj_id, SurveyQuestion::_getInternalLinkHref(), ilRTE::_getRTEClassname(), ilObject::_lookupType(), and ilUtil::prepareFormOutput().
{
$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_text.html", true);
$this->tpl->addBlockFile("OTHER_QUESTION_DATA", "other_question_data", "tpl.il_svy_qpl_other_question_data.html", true);
$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("adm_content");
$this->tpl->setVariable("TEXT_MATERIAL", $this->lng->txt("material"));
if (count($this->object->material))
{
include_once "./survey/classes/class.SurveyQuestion.php";
$href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
$this->tpl->setVariable("TEXT_VALUE_MATERIAL", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("material"). "</a> ");
$this->tpl->setVariable("BUTTON_REMOVE_MATERIAL", $this->lng->txt("remove"));
$this->tpl->setVariable("BUTTON_ADD_MATERIAL", $this->lng->txt("change"));
$this->tpl->setVariable("VALUE_MATERIAL", $this->object->material["internal_link"]);
$this->tpl->setVariable("VALUE_MATERIAL_TITLE", $this->object->material["title"]);
$this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
}
else
{
$this->tpl->setVariable("BUTTON_ADD_MATERIAL", $this->lng->txt("add"));
}
$this->tpl->setVariable("QUESTION_ID", $this->object->getId());
$this->tpl->setVariable("VALUE_TITLE", $this->object->getTitle());
$this->tpl->setVariable("VALUE_DESCRIPTION", $this->object->getDescription());
$this->tpl->setVariable("VALUE_AUTHOR", $this->object->getAuthor());
if ($this->object->getMaxChars() > 0)
{
$this->tpl->setVariable("VALUE_MAXCHARS", $this->object->getMaxChars());
}
$questiontext = $this->object->getQuestiontext();
$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_DESCRIPTION", $this->lng->txt("description"));
$this->tpl->setVariable("TEXT_MAXCHARS", $this->lng->txt("maxchars"));
$this->tpl->setVariable("DESCRIPTION_MAXCHARS", $this->lng->txt("description_maxchars"));
$this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
$this->tpl->setVariable("TEXT_OBLIGATORY", $this->lng->txt("obligatory"));
if ($this->object->getObligatory())
{
$this->tpl->setVariable("CHECKED_OBLIGATORY", " checked=\"checked\"");
}
$this->tpl->setVariable("SAVE",$this->lng->txt("save"));
$this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
$this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
$this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt($this->getQuestionType()));
$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");
$rte->removePlugin("ibrowser");
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, "survey");
}
Here is the call graph for this function:| SurveyTextQuestionGUI::getQuestionType | ( | ) |
Returns the question type string.
Returns the question type string
Definition at line 71 of file class.SurveyTextQuestionGUI.php.
{
return "SurveyTextQuestion";
}
| SurveyTextQuestionGUI::outCumulatedResultsDetails | ( | &$ | cumulated_results, | |
| $ | counter | |||
| ) |
Definition at line 272 of file class.SurveyTextQuestionGUI.php.
{
$this->tpl->setCurrentBlock("detail_row");
$this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("question"));
$questiontext = $this->object->getQuestiontext();
$this->tpl->setVariable("TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
$this->tpl->parseCurrentBlock();
$this->tpl->setCurrentBlock("detail_row");
$this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("question_type"));
$this->tpl->setVariable("TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
$this->tpl->parseCurrentBlock();
$this->tpl->setCurrentBlock("detail_row");
$this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("users_answered"));
$this->tpl->setVariable("TEXT_OPTION_VALUE", $cumulated_results["USERS_ANSWERED"]);
$this->tpl->parseCurrentBlock();
$this->tpl->setCurrentBlock("detail_row");
$this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("users_skipped"));
$this->tpl->setVariable("TEXT_OPTION_VALUE", $cumulated_results["USERS_SKIPPED"]);
$this->tpl->parseCurrentBlock();
$this->tpl->setCurrentBlock("detail_row");
$this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("given_answers"));
$textvalues = "";
if (is_array($cumulated_results["textvalues"]))
{
foreach ($cumulated_results["textvalues"] as $textvalue)
{
$textvalues .= "<li>" . preg_replace("/\n/", "<br>", $textvalue) . "</li>";
}
}
$textvalues = "<ul>$textvalues</ul>";
$this->tpl->setVariable("TEXT_OPTION_VALUE", $textvalues);
$this->tpl->parseCurrentBlock();
$this->tpl->setCurrentBlock("detail");
$this->tpl->setVariable("QUESTION_TITLE", "$counter. ".$this->object->getTitle());
$this->tpl->parseCurrentBlock();
}
| SurveyTextQuestionGUI::outWorkingForm | ( | $ | working_data = "", |
|
| $ | question_title = 1, |
|||
| $ | error_message = "" | |||
| ) |
Creates the question output form for the learner.
Creates the question output form for the learner
public
Definition at line 165 of file class.SurveyTextQuestionGUI.php.
References SurveyQuestion::_getInternalLinkHref().
Referenced by preview().
{
if (count($this->object->material))
{
$this->tpl->setCurrentBlock("material_text");
include_once "./survey/classes/class.SurveyQuestion.php";
$href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
$this->tpl->setVariable("TEXT_MATERIAL", $this->lng->txt("material") . ": <a href=\"$href\" target=\"content\">" . $this->object->material["title"]. "</a> ");
$this->tpl->parseCurrentBlock();
}
$this->tpl->setCurrentBlock("question_data_text");
$questiontext = $this->object->getQuestiontext();
$this->tpl->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
if (! $this->object->getObligatory())
{
$this->tpl->setVariable("OBLIGATORY_TEXT", $this->lng->txt("survey_question_optional"));
}
if ($question_title)
{
$this->tpl->setVariable("QUESTION_TITLE", $this->object->getTitle());
}
$this->tpl->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
$this->tpl->setVariable("QUESTION_ID", $this->object->getId());
if (is_array($working_data))
{
$this->tpl->setVariable("VALUE_ANSWER", $working_data[0]["textanswer"]);
}
if (strcmp($error_message, "") != 0)
{
$this->tpl->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
}
if ($this->object->getMaxChars())
{
$this->tpl->setVariable("TEXT_MAXCHARS", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxChars()));
}
$this->tpl->parseCurrentBlock();
}
Here is the call graph for this function:
Here is the caller graph for this function:| SurveyTextQuestionGUI::preview | ( | ) |
Creates a preview of the question.
Creates a preview of the question
private
Definition at line 210 of file class.SurveyTextQuestionGUI.php.
References outWorkingForm().
{
$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_preview.html", true);
$this->tpl->addBlockFile("TEXT", "text", "tpl.il_svy_out_text.html", true);
$this->outWorkingForm();
$this->tpl->parseCurrentBlock();
}
Here is the call graph for this function:| SurveyTextQuestionGUI::setQuestionTabs | ( | ) |
Definition at line 267 of file class.SurveyTextQuestionGUI.php.
References SurveyQuestionGUI::setQuestionTabsForClass().
{
$this->setQuestionTabsForClass("surveytextquestiongui");
}
Here is the call graph for this function:| SurveyTextQuestionGUI::SurveyTextQuestionGUI | ( | $ | id = -1 |
) |
SurveyTextQuestionGUI constructor.
The constructor takes possible arguments an creates an instance of the SurveyTextQuestionGUI object.
| integer | $id The database id of a text question object public |
Definition at line 49 of file class.SurveyTextQuestionGUI.php.
References $id, and SurveyQuestionGUI::SurveyQuestionGUI().
{
$this->SurveyQuestionGUI();
include_once "./survey/classes/class.SurveyTextQuestion.php";
$this->object = new SurveyTextQuestion();
if ($id >= 0)
{
$this->object->loadFromDb($id);
}
}
Here is the call graph for this function:| SurveyTextQuestionGUI::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
Definition at line 226 of file class.SurveyTextQuestionGUI.php.
References $_POST, $result, ilObjAdvancedEditing::_getUsedHTMLTagsAsString(), and ilUtil::stripSlashes().
{
$result = 0;
if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
$result = 1;
// Set the question id from a hidden form parameter
if ($_POST["id"] > 0)
$this->object->setId($_POST["id"]);
include_once "./classes/class.ilUtil.php";
$this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
$this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
$this->object->setDescription(ilUtil::stripSlashes($_POST["description"]));
$this->object->setMaxChars(ilUtil::stripSlashes($_POST["maxchars"]));
if (strlen($_POST["material"]))
{
$this->object->setMaterial($_POST["material"], 0, ilUtil::stripSlashes($_POST["material_title"]));
}
include_once "./classes/class.ilObjAdvancedEditing.php";
$questiontext = ilUtil::stripSlashes($_POST["question"], true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey"));
$this->object->setQuestiontext($questiontext);
if ($_POST["obligatory"])
{
$this->object->setObligatory(1);
}
else
{
$this->object->setObligatory(0);
}
if ($saved)
{
// If the question was saved automatically before an upload, we have to make
// sure, that the state after the upload is saved. Otherwise the user could be
// irritated, if he presses cancel, because he only has the question state before
// the upload process.
$this->object->saveToDb();
}
return $result;
}
Here is the call graph for this function:
1.7.1