Metric survey question GUI representation. More...
Inheritance diagram for SurveyMetricQuestionGUI:
Collaboration diagram for SurveyMetricQuestionGUI:Public Member Functions | |
| SurveyMetricQuestionGUI ($id=-1) | |
| SurveyMetricQuestionGUI constructor. | |
| editQuestion () | |
| Creates an output of the edit form for the question. | |
| writePostData () | |
| Evaluates a posted edit form and writes the form data in the question object. | |
| getPrintView ($question_title=1, $show_questiontext=1) | |
| Creates a HTML representation of the question. | |
| getWorkingForm ($working_data="", $question_title=1, $show_questiontext=1, $error_message="") | |
| Creates the question output form for the learner. | |
| preview () | |
| Creates a preview of the question. | |
| setQuestionTabs () | |
| getCumulatedResultRow ($counter, $css_class, $survey_id) | |
| Creates a the cumulated results row for the question. | |
| getCumulatedResultsDetails ($survey_id, $counter) | |
| Creates the detailed output of the cumulated results for the question. | |
Metric survey question GUI representation.
The SurveyMetricQuestionGUI class encapsulates the GUI representation for metric survey question types.
Definition at line 38 of file class.SurveyMetricQuestionGUI.php.
| SurveyMetricQuestionGUI::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 69 of file class.SurveyMetricQuestionGUI.php.
References $_GET, SurveyQuestion::_getInternalLinkHref(), ilRTE::_getRTEClassname(), ilObject::_lookupType(), and ilUtil::prepareFormOutput().
{
$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_metric.html", "Modules/SurveyQuestionPool");
$this->tpl->addBlockFile("OTHER_QUESTION_DATA", "other_question_data", "tpl.il_svy_qpl_other_question_data.html", "Modules/SurveyQuestionPool");
$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 "./Modules/SurveyQuestionPool/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());
$questiontext = $this->object->getQuestiontext();
$this->tpl->setVariable("VALUE_QUESTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
$this->tpl->setVariable("VALUE_MINIMUM", $this->object->getMinimum());
$this->tpl->setVariable("VALUE_MAXIMUM", $this->object->getMaximum());
$this->tpl->setVariable("TEXT_MINIMUM", $this->lng->txt("minimum"));
$this->tpl->setVariable("TEXT_MAXIMUM", $this->lng->txt("maximum"));
$this->tpl->setVariable("TEXT_SUBTYPE", $this->lng->txt("subtype"));
$this->tpl->setVariable("DESCRIPTION_NONRATIO", $this->lng->txt("metric_subtype_description_interval"));
$this->tpl->setVariable("TEXT_NONRATIO", $this->lng->txt("non_ratio"));
$this->tpl->setVariable("DESCRIPTION_RATIONONABSOLUTE", $this->lng->txt("metric_subtype_description_rationonabsolute"));
$this->tpl->setVariable("TEXT_RATIONONABSOLUTE", $this->lng->txt("ratio_non_absolute"));
$this->tpl->setVariable("DESCRIPTION_RATIOABSOLUTE", $this->lng->txt("metric_subtype_description_ratioabsolute"));
$this->tpl->setVariable("TEXT_RATIOABSOLUTE", $this->lng->txt("ratio_absolute"));
if ($this->object->getSubtype() == SUBTYPE_NON_RATIO)
{
$this->tpl->setVariable("CHECKED_NONRATIO", " checked=\"checked\"");
}
else if ($this->object->getSubtype() == SUBTYPE_RATIO_NON_ABSOLUTE)
{
$this->tpl->setVariable("CHECKED_RATIONONABSOLUTE", " checked=\"checked\"");
}
else if ($this->object->getSubtype() == SUBTYPE_RATIO_ABSOLUTE)
{
$this->tpl->setVariable("CHECKED_RATIOABSOLUTE", " checked=\"checked\"");
}
$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_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("TEXT_QUESTION_TYPE", $this->lng->txt("questiontype"));
$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->addButton("pastelatex");
$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:| SurveyMetricQuestionGUI::getCumulatedResultRow | ( | $ | counter, | |
| $ | css_class, | |||
| $ | survey_id | |||
| ) |
Creates a the cumulated results row for the question.
Creates a the cumulated results row for the question
Reimplemented from SurveyQuestionGUI.
Definition at line 367 of file class.SurveyMetricQuestionGUI.php.
References ilObjSurvey::_getNrOfParticipants().
{
include_once "./classes/class.ilTemplate.php";
if (count($this->cumulated) == 0)
{
include_once "./Modules/Survey/classes/class.ilObjSurvey.php";
$nr_of_users = ilObjSurvey::_getNrOfParticipants($survey_id);
$this->cumulated =& $this->object->getCumulatedResults($survey_id, $nr_of_users);
}
$template = new ilTemplate("tpl.il_svy_svy_cumulated_results_row.html", TRUE, TRUE, "Modules/Survey");
$template->setVariable("QUESTION_TITLE", ($counter+1) . ". ".$this->object->getTitle());
$maxlen = 37;
$questiontext = preg_replace("/<[^>]+?>/ims", "", $this->object->getQuestiontext());
if (strlen($questiontext) > $maxlen + 3)
{
$questiontext = substr($questiontext, 0, $maxlen) . "...";
}
$template->setVariable("QUESTION_TEXT", $questiontext);
$template->setVariable("USERS_ANSWERED", $this->cumulated["USERS_ANSWERED"]);
$template->setVariable("USERS_SKIPPED", $this->cumulated["USERS_SKIPPED"]);
$template->setVariable("QUESTION_TYPE", $this->lng->txt($this->cumulated["QUESTION_TYPE"]));
$template->setVariable("MODE", $this->cumulated["MODE"]);
$template->setVariable("MODE_NR_OF_SELECTIONS", $this->cumulated["MODE_NR_OF_SELECTIONS"]);
$template->setVariable("MEDIAN", $this->cumulated["MEDIAN"]);
$template->setVariable("ARITHMETIC_MEAN", $this->cumulated["ARITHMETIC_MEAN"]);
$template->setVariable("COLOR_CLASS", $css_class);
return $template->get();
}
Here is the call graph for this function:| SurveyMetricQuestionGUI::getCumulatedResultsDetails | ( | $ | survey_id, | |
| $ | counter | |||
| ) |
Creates the detailed output of the cumulated results for the question.
Creates the detailed output of the cumulated results for the question
| integer | $survey_id The database ID of the survey | |
| integer | $counter The counter of the question position in the survey |
Definition at line 406 of file class.SurveyMetricQuestionGUI.php.
References $data, and ilObjSurvey::_getNrOfParticipants().
{
if (count($this->cumulated) == 0)
{
include_once "./Modules/Survey/classes/class.ilObjSurvey.php";
$nr_of_users = ilObjSurvey::_getNrOfParticipants($survey_id);
$this->cumulated =& $this->object->getCumulatedResults($survey_id, $nr_of_users);
}
$output = "";
include_once "./classes/class.ilTemplate.php";
$template = new ilTemplate("tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE, "Modules/Survey");
$template->setCurrentBlock("detail_row");
$template->setVariable("TEXT_OPTION", $this->lng->txt("question"));
$questiontext = $this->object->getQuestiontext();
$template->setVariable("TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
$template->parseCurrentBlock();
$template->setCurrentBlock("detail_row");
$template->setVariable("TEXT_OPTION", $this->lng->txt("question_type"));
$template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
$template->parseCurrentBlock();
$template->setCurrentBlock("detail_row");
$template->setVariable("TEXT_OPTION", $this->lng->txt("users_answered"));
$template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_ANSWERED"]);
$template->parseCurrentBlock();
$template->setCurrentBlock("detail_row");
$template->setVariable("TEXT_OPTION", $this->lng->txt("users_skipped"));
$template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_SKIPPED"]);
$template->parseCurrentBlock();
$template->setCurrentBlock("detail_row");
$template->setVariable("TEXT_OPTION", $this->lng->txt("subtype"));
switch ($this->object->getSubType())
{
case SUBTYPE_NON_RATIO:
$template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt("non_ratio"));
break;
case SUBTYPE_RATIO_NON_ABSOLUTE:
$template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt("ratio_non_absolute"));
break;
case SUBTYPE_RATIO_ABSOLUTE:
$template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt("ratio_absolute"));
break;
}
$template->parseCurrentBlock();
$template->setCurrentBlock("detail_row");
$template->setVariable("TEXT_OPTION", $this->lng->txt("mode"));
$template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MODE"]);
$template->parseCurrentBlock();
$template->setCurrentBlock("detail_row");
$template->setVariable("TEXT_OPTION", $this->lng->txt("mode_nr_of_selections"));
$template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MODE_NR_OF_SELECTIONS"]);
$template->parseCurrentBlock();
$template->setCurrentBlock("detail_row");
$template->setVariable("TEXT_OPTION", $this->lng->txt("median"));
$template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MEDIAN"]);
$template->parseCurrentBlock();
$template->setCurrentBlock("detail_row");
$template->setVariable("TEXT_OPTION", $this->lng->txt("arithmetic_mean"));
$template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["ARITHMETIC_MEAN"]);
$template->parseCurrentBlock();
$template->setCurrentBlock("detail_row");
$template->setVariable("TEXT_OPTION", $this->lng->txt("values"));
$values = "";
if (is_array($this->cumulated["values"]))
{
foreach ($this->cumulated["values"] as $key => $value)
{
$values .= "<li>" . $this->lng->txt("value") . ": " . "<span class=\"bold\">" . $value["value"] . "</span><br />" .
$this->lng->txt("value_nr_entered") . ": " . "<span class=\"bold\">" . $value["selected"] . "</span><br />" .
$this->lng->txt("percentage_of_entered_values") . ": " . "<span class=\"bold\">" . sprintf("%.2f", 100*$value["percentage"]) . "</span></li>";
}
}
$values = "<ol>$values</ol>";
$template->setVariable("TEXT_OPTION_VALUE", $values);
$template->parseCurrentBlock();
// display chart for metric question for array $eval["values"]
$template->setCurrentBlock("chart");
$template->setVariable("TEXT_CHART", $this->lng->txt("chart"));
$template->setVariable("ALT_CHART", $data["title"] . "( " . $this->lng->txt("chart") . ")");
$this->ctrl->setParameterByClass("ilsurveyevaluationgui", "survey", $survey_id);
$this->ctrl->setParameterByClass("ilsurveyevaluationgui", "question", $this->object->getId());
$template->setVariable("CHART", $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "outChart"));
$template->parseCurrentBlock();
$template->setVariable("QUESTION_TITLE", "$counter. ".$this->object->getTitle());
return $template->get();
}
Here is the call graph for this function:| SurveyMetricQuestionGUI::getPrintView | ( | $ | question_title = 1, |
|
| $ | show_questiontext = 1 | |||
| ) |
Creates a HTML representation of the question.
Creates a HTML representation of the question
private
Reimplemented from SurveyQuestionGUI.
Definition at line 228 of file class.SurveyMetricQuestionGUI.php.
{
$template = new ilTemplate("tpl.il_svy_qpl_metric_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
$template->setVariable("MIN_MAX", $this->object->getMinMaxText());
/*
if (strlen($this->object->getMinimum()))
{
$template->setCurrentBlock("minimum");
$template->setVariable("TEXT_MINIMUM", $this->lng->txt("minimum"));
$template->setVariable("VALUE_MINIMUM", $this->object->getMinimum());
$template->parseCurrentBlock();
}
if (strlen($this->object->getMaximum()))
{
$template->setCurrentBlock("maximum");
$template->setVariable("TEXT_MAXIMUM", $this->lng->txt("maximum"));
$template->setVariable("VALUE_MAXIMUM", $this->object->getMaximum());
$template->parseCurrentBlock();
}*/
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
if ($show_questiontext)
{
$questiontext = $this->object->getQuestiontext();
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
}
if (! $this->object->getObligatory())
{
$template->setVariable("OBLIGATORY_TEXT", $this->lng->txt("survey_question_optional"));
}
if ($question_title)
{
$template->setVariable("QUESTION_TITLE", $this->object->getTitle());
}
$template->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
$template->setVariable("QUESTION_ID", $this->object->getId());
$solution_text = "";
$len = 10;
for ($i = 0; $i < 10; $i++) $solution_text .= " ";
$template->setVariable("TEXT_SOLUTION", $solution_text);
$template->parseCurrentBlock();
return $template->get();
}
| SurveyMetricQuestionGUI::getWorkingForm | ( | $ | working_data = "", |
|
| $ | question_title = 1, |
|||
| $ | show_questiontext = 1, |
|||
| $ | error_message = "" | |||
| ) |
Creates the question output form for the learner.
Creates the question output form for the learner
public
Definition at line 281 of file class.SurveyMetricQuestionGUI.php.
References SurveyQuestion::_getInternalLinkHref().
Referenced by preview().
{
$template = new ilTemplate("tpl.il_svy_out_metric.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
if (count($this->object->material))
{
$template->setCurrentBlock("material_metric");
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
$href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
$template->setVariable("TEXT_MATERIAL", $this->lng->txt("material") . ": <a href=\"$href\" target=\"content\">" . $this->object->material["title"]. "</a> ");
$template->parseCurrentBlock();
}
$template->setVariable("MIN_MAX", $this->object->getMinMaxText());
/*if (strlen($this->object->getMinimum()))
{
$template->setCurrentBlock("minimum");
$template->setVariable("TEXT_MINIMUM", $this->lng->txt("minimum"));
$template->setVariable("VALUE_MINIMUM", $this->object->getMinimum());
$template->parseCurrentBlock();
}
if (strlen($this->object->getMaximum()))
{
$template->setCurrentBlock("maximum");
$template->setVariable("TEXT_MAXIMUM", $this->lng->txt("maximum"));
$template->setVariable("VALUE_MAXIMUM", $this->object->getMaximum());
$template->parseCurrentBlock();
}*/
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
if ($show_questiontext)
{
$questiontext = $this->object->getQuestiontext();
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
}
if (! $this->object->getObligatory())
{
$template->setVariable("OBLIGATORY_TEXT", $this->lng->txt("survey_question_optional"));
}
if ($question_title)
{
$template->setVariable("QUESTION_TITLE", $this->object->getTitle());
}
$template->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
$template->setVariable("QUESTION_ID", $this->object->getId());
if (is_array($working_data))
{
$template->setVariable("VALUE_METRIC", $working_data[0]["value"]);
}
$template->setVariable("INPUT_SIZE", 10);
if (strcmp($error_message, "") != 0)
{
$template->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
}
$template->parseCurrentBlock();
return $template->get();
}
Here is the call graph for this function:
Here is the caller graph for this function:| SurveyMetricQuestionGUI::preview | ( | ) |
Creates a preview of the question.
Creates a preview of the question
private
Definition at line 346 of file class.SurveyMetricQuestionGUI.php.
References getWorkingForm().
{
$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_preview.html", "Modules/SurveyQuestionPool");
$question_output = $this->getWorkingForm();
$this->tpl->setVariable("QUESTION_OUTPUT", $question_output);
$this->tpl->parseCurrentBlock();
}
Here is the call graph for this function:| SurveyMetricQuestionGUI::setQuestionTabs | ( | ) |
Definition at line 354 of file class.SurveyMetricQuestionGUI.php.
References SurveyQuestionGUI::setQuestionTabsForClass().
{
$this->setQuestionTabsForClass("surveymetricquestiongui");
}
Here is the call graph for this function:| SurveyMetricQuestionGUI::SurveyMetricQuestionGUI | ( | $ | id = -1 |
) |
SurveyMetricQuestionGUI constructor.
The constructor takes possible arguments an creates an instance of the SurveyMetricQuestionGUI object.
| integer | $id The database id of a metric question object public |
Definition at line 48 of file class.SurveyMetricQuestionGUI.php.
References SurveyQuestionGUI::SurveyQuestionGUI().
{
$this->SurveyQuestionGUI();
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyMetricQuestion.php";
$this->object = new SurveyMetricQuestion();
if ($id >= 0)
{
$this->object->loadFromDb($id);
}
}
Here is the call graph for this function:| SurveyMetricQuestionGUI::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 169 of file class.SurveyMetricQuestionGUI.php.
References 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 "./Services/Utilities/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"]));
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);
}
$this->object->setSubtype($_POST["type"]);
$minimum = $_POST["minimum"];
if ($this->object->getSubtype() > 3)
{
if ($minimum < 0)
{
$this->errormessage = $this->lng->txt("ratio_scale_ge_zero");
$result = 1;
}
}
$this->object->setMinimum($minimum);
$this->object->setMaximum($_POST["maximum"]);
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