ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
SurveyMetricQuestionGUI Class Reference

Metric survey question GUI representation. More...

+ Inheritance diagram for SurveyMetricQuestionGUI:
+ Collaboration diagram for SurveyMetricQuestionGUI:

Public Member Functions

 SurveyMetricQuestionGUI ($id=-1)
 SurveyMetricQuestionGUI constructor.
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object.
 editQuestion ($checkonly=FALSE)
 Creates an output of the edit form for the question.
 getPrintView ($question_title=1, $show_questiontext=1, $survey_id=null)
 Creates a HTML representation of the question.
 getWorkingForm ($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
 Creates the question output form for the learner.
 preview ()
 Creates a preview of the question.
 setQuestionTabs ()
 getCumulatedResultsDetails ($survey_id, $counter)
 Creates the detailed output of the cumulated results for the question.
- Public Member Functions inherited from SurveyQuestionGUI
 SurveyQuestionGUI ()
 SurveyQuestion constructor.
 addErrorMessage ($errormessage)
 outErrorMessages ()
executeCommand ()
 execute command
 getCommand ($cmd)
 _getGUIClassNameForId ($a_q_id)
 _getClassNameForQType ($q_type)
 originalSyncForm ()
 sync ()
 cancelSync ()
 save ()
 save question
 cancel ()
 cancelDeleteCategory ()
 Cancels the form adding a phrase.
 material ($checkonly=FALSE)
 Material tab of the survey questions.
 deleteMaterial ()
 addMaterial ()
 Add materials to a question.
 removeMaterial ()
 cancelExplorer ()
 addPG ()
 addST ()
 addGIT ()
 linkChilds ()
 getPrintView ($question_title=1, $show_questiontext=1)
 Creates a HTML representation of the question.
 setQuestionTabsForClass ($guiclass)
 getQuestionType ()
 Returns the question type string.
 getCumulatedResultRow ($counter, $css_class, $survey_id)
 Creates a the cumulated results row for the question.
 editQuestion ()

Additional Inherited Members

- Static Public Member Functions inherited from SurveyQuestionGUI
static & _getQuestionGUI ($questiontype, $question_id=-1)
 Creates a question gui representation.
- Data Fields inherited from SurveyQuestionGUI
 $object
 $tpl
 $lng
 $cumulated
 An array containing the cumulated results of the question for a given survey.
- Protected Member Functions inherited from SurveyQuestionGUI
 getMaterialOutput ()
 Creates the HTML output of the question material(s)
 outQuestionText ($template)

Detailed Description

Metric survey question GUI representation.

The SurveyMetricQuestionGUI class encapsulates the GUI representation for metric survey question types.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
Id:
class.SurveyMetricQuestionGUI.php 24564 2010-07-12 08:28:45Z hschottm

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

Member Function Documentation

SurveyMetricQuestionGUI::editQuestion (   $checkonly = FALSE)

Creates an output of the edit form for the question.

public

Definition at line 98 of file class.SurveyMetricQuestionGUI.php.

References $errors, $title, ilObjAdvancedEditing\_getUsedHTMLTags(), ilNumberInputGUI\setDecimals(), ilFormPropertyGUI\setRequired(), ilTextInputGUI\setValue(), ilCheckboxInputGUI\setValue(), ilNumberInputGUI\setValue(), and ilTextAreaInputGUI\setValue().

{
$save = ((strcmp($this->ctrl->getCmd(), "save") == 0) || (strcmp($this->ctrl->getCmd(), "saveEdit") == 0)) ? TRUE : FALSE;
include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setFormAction($this->ctrl->getFormAction($this));
$form->setTitle($this->lng->txt($this->getQuestionType()));
$form->setMultipart(FALSE);
$form->setTableWidth("100%");
$form->setId("multiplechoice");
// title
$title = new ilTextInputGUI($this->lng->txt("title"), "title");
$title->setValue($this->object->getTitle());
$title->setRequired(TRUE);
$form->addItem($title);
// label
$label = new ilTextInputGUI($this->lng->txt("label"), "label");
$label->setValue($this->object->label);
$label->setInfo($this->lng->txt("label_info"));
$label->setRequired(false);
$form->addItem($label);
// author
$author = new ilTextInputGUI($this->lng->txt("author"), "author");
$author->setValue($this->object->getAuthor());
$author->setRequired(TRUE);
$form->addItem($author);
// description
$description = new ilTextInputGUI($this->lng->txt("description"), "description");
$description->setValue($this->object->getDescription());
$description->setRequired(FALSE);
$form->addItem($description);
// questiontext
$question = new ilTextAreaInputGUI($this->lng->txt("question"), "question");
$question->setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
$question->setRequired(TRUE);
$question->setRows(10);
$question->setCols(80);
$question->setUseRte(TRUE);
include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
$question->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
$question->addPlugin("latex");
$question->addButton("latex");
$question->addButton("pastelatex");
$question->removePlugin("ibrowser");
$question->setRTESupport($this->object->getId(), "spl", "survey");
$form->addItem($question);
// subtype
$subtype = new ilRadioGroupInputGUI($this->lng->txt("subtype"), "type");
$subtype->setRequired(true);
$subtype->setValue($this->object->getSubtype());
$subtype->addOption(new ilRadioOption($this->lng->txt('non_ratio'), 3, $this->lng->txt("metric_subtype_description_interval")));
$subtype->addOption(new ilRadioOption($this->lng->txt('ratio_non_absolute'), 4, $this->lng->txt("metric_subtype_description_rationonabsolute")));
$subtype->addOption(new ilRadioOption($this->lng->txt('ratio_absolute'), 5, $this->lng->txt("metric_subtype_description_ratioabsolute")));
$form->addItem($subtype);
// minimum value
$minimum = new ilNumberInputGUI($this->lng->txt("minimum"), "minimum");
$minimum->setValue($this->object->getMinimum());
$minimum->setRequired(false);
$minimum->setSize(6);
if ($this->object->getSubtype() > 3)
{
$minimum->setMinValue(0);
}
if ($this->object->getSubtype() == 5)
{
$minimum->setDecimals(0);
}
$form->addItem($minimum);
// maximum value
$maximum = new ilNumberInputGUI($this->lng->txt("maximum"), "maximum");
if ($this->object->getSubtype() == 5)
{
$maximum->setDecimals(0);
}
$maximum->setValue($this->object->getMaximum());
$maximum->setRequired(false);
$maximum->setSize(6);
$form->addItem($maximum);
// obligatory
$shuffle = new ilCheckboxInputGUI($this->lng->txt("obligatory"), "obligatory");
$shuffle->setValue(1);
$shuffle->setChecked($this->object->getObligatory());
$shuffle->setRequired(FALSE);
$form->addItem($shuffle);
$form->addCommandButton("save", $this->lng->txt("save"));
$errors = false;
if ($save)
{
$form->setValuesByPost();
$errors = !$form->checkInput();
$form->setValuesByPost(); // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
if ($errors) $checkonly = false;
}
if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
return $errors;
}

+ Here is the call graph for this function:

SurveyMetricQuestionGUI::getCumulatedResultsDetails (   $survey_id,
  $counter 
)

Creates the detailed output of the cumulated results for the question.

Parameters
integer$survey_idThe database ID of the survey
integer$counterThe counter of the question position in the survey
Returns
string HTML text with the cumulated results private

Definition at line 324 of file class.SurveyMetricQuestionGUI.php.

References $data, ilObjSurvey\_getNrOfParticipants(), SUBTYPE_NON_RATIO, SUBTYPE_RATIO_ABSOLUTE, and SUBTYPE_RATIO_NON_ABSOLUTE.

{
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())
{
$template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt("non_ratio"));
break;
$template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt("ratio_non_absolute"));
break;
$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");
$charturl = "";
include_once "./Services/Administration/classes/class.ilSetting.php";
$surveySetting = new ilSetting("survey");
if ($surveySetting->get("googlechart") == 1)
{
$selections = array();
$values = array();
$maxselection = 0;
if (is_array($this->cumulated["values"]))
{
foreach ($this->cumulated["values"] as $val)
{
if ($val["selected"] > $maxselection) $maxselection = $val["selected"];
array_push($selections, $val["selected"]);
array_push($values, $val["value"]);
}
}
$selectionlabels = "";
if ($maxselection % 2 == 0)
{
$selectionlabels = "0|" . ($maxselection / 2) . "|$maxselection";
}
else
{
$selectionlabels = "0|$maxselection";
}
$chartwidth = 800;
$charturl = "http://chart.apis.google.com/chart?chco=76A4FB&cht=bvs&chs=$chartwidth" . "x250&chd=t:" . implode(",", $selections) . "&chds=0,$maxselection&chxt=x,y,x,y&chxl=0:|" . implode("|", $values) . "|1:|$selectionlabels|2:||" . $this->lng->txt("values")."||3:||".$this->lng->txt("mode_nr_of_selections")."|" . "&chxr=1,0,$maxselection&chtt=" . str_replace(" ", "+", $this->object->getTitle());
}
else
{
$this->ctrl->setParameterByClass("ilsurveyevaluationgui", "survey", $survey_id);
$this->ctrl->setParameterByClass("ilsurveyevaluationgui", "question", $this->object->getId());
$charturl = $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "outChart");
}
$template->setVariable("CHART", $charturl);
$template->setVariable("TEXT_CHART", $this->lng->txt("chart"));
$template->setVariable("ALT_CHART", $data["title"] . "( " . $this->lng->txt("chart") . ")");
$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,
  $survey_id = null 
)

Creates a HTML representation of the question.

Creates a HTML representation of the question

private

Definition at line 216 of file class.SurveyMetricQuestionGUI.php.

References SurveyQuestionGUI\outQuestionText().

{
$template = new ilTemplate("tpl.il_svy_qpl_metric_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
$template->setVariable("MIN_MAX", $this->object->getMinMaxText());
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
if ($show_questiontext)
{
$this->outQuestionText($template);
}
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 .= "&#160;";
$template->setVariable("TEXT_SOLUTION", $solution_text);
$template->parseCurrentBlock();
return $template->get();
}

+ Here is the call graph for this function:

SurveyMetricQuestionGUI::getWorkingForm (   $working_data = "",
  $question_title = 1,
  $show_questiontext = 1,
  $error_message = "",
  $survey_id = null 
)

Creates the question output form for the learner.

Creates the question output form for the learner

public

Definition at line 249 of file class.SurveyMetricQuestionGUI.php.

References SurveyQuestionGUI\getMaterialOutput(), and SurveyQuestionGUI\outQuestionText().

Referenced by preview().

{
$template = new ilTemplate("tpl.il_svy_out_metric.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
$template->setCurrentBlock("material_metric");
$template->setVariable("TEXT_MATERIAL", $this->getMaterialOutput());
$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)
{
$this->outQuestionText($template);
}
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 304 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);
}

+ Here is the call graph for this function:

SurveyMetricQuestionGUI::setQuestionTabs ( )

Definition at line 311 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.

Parameters
integer$idThe database id of a metric question object public

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

References SurveyQuestionGUI\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 (   $always = false)

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

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

References $_POST, and SurveyQuestionGUI\editQuestion().

{
$hasErrors = (!$always) ? $this->editQuestion(true) : false;
if (!$hasErrors)
{
$this->object->setTitle($_POST["title"]);
$this->object->setAuthor($_POST["author"]);
$this->object->setDescription($_POST["description"]);
$questiontext = $_POST["question"];
$this->object->setQuestiontext($questiontext);
$this->object->setObligatory(($_POST["obligatory"]) ? 1 : 0);
$this->object->setOrientation($_POST["orientation"]);
$this->object->label = $_POST['label'];
$this->object->setSubtype($_POST["type"]);
$this->object->setMinimum($_POST["minimum"]);
$this->object->setMaximum($_POST["maximum"]);
return 0;
}
else
{
return 1;
}
}

+ Here is the call graph for this function:


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