ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
SurveyTextQuestionGUI Class Reference

Text survey question GUI representation. More...

+ Inheritance diagram for SurveyTextQuestionGUI:
+ Collaboration diagram for SurveyTextQuestionGUI:

Public Member Functions

 SurveyTextQuestionGUI ($id=-1)
 SurveyTextQuestionGUI constructor.
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object.
 editQuestion ()
 Creates an output of the edit form for the question.
 getWorkingForm ($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
 Creates the question output form for the learner.
 getPrintView ($question_title=1, $show_questiontext=1, $survey_id=null)
 Creates a HTML representation of the question.
 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.

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)

Detailed Description

Text survey question GUI representation.

The SurveyTextQuestionGUI class encapsulates the GUI representation for text 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.SurveyTextQuestionGUI.php 22686 2010-01-13 08:09:28Z hschottm

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

Member Function Documentation

SurveyTextQuestionGUI::editQuestion ( )

Creates an output of the edit form for the question.

Reimplemented from SurveyQuestionGUI.

Definition at line 96 of file class.SurveyTextQuestionGUI.php.

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

Referenced by writePostData().

{
$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("essay");
// title
$title = new ilTextInputGUI($this->lng->txt("title"), "title");
$title->setValue($this->object->getTitle());
$title->setRequired(TRUE);
$form->addItem($title);
// 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);
// maximum number of characters
$maxchars = new ilNumberInputGUI($this->lng->txt("maxchars"), "maxchars");
$maxchars->setRequired(false);
$maxchars->setSize(5);
if ($this->object->getMaxChars() > 0)
{
$maxchars->setValue($this->object->getMaxChars());
}
$maxchars->setDecimals(0);
$form->addItem($maxchars);
// textwidth
$textwidth = new ilNumberInputGUI($this->lng->txt("width"), "textwidth");
$textwidth->setRequired(true);
$textwidth->setSize(3);
$textwidth->setValue($this->object->getTextWidth());
$textwidth->setDecimals(0);
$textwidth->setMinValue(10);
$form->addItem($textwidth);
// textheight
$textheight = new ilNumberInputGUI($this->lng->txt("height"), "textheight");
$textheight->setRequired(true);
$textheight->setSize(3);
$textheight->setValue($this->object->getTextHeight());
$textheight->setDecimals(0);
$textheight->setMinValue(1);
$form->addItem($textheight);
// 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:

+ Here is the caller graph for this function:

SurveyTextQuestionGUI::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 321 of file class.SurveyTextQuestionGUI.php.

References 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("given_answers"));
$textvalues = "";
if (is_array($this->cumulated["textvalues"]))
{
foreach ($this->cumulated["textvalues"] as $textvalue)
{
$textvalues .= "<li>" . preg_replace("/\n/", "<br>", $textvalue) . "</li>";
}
}
$textvalues = "<ul>$textvalues</ul>";
$template->setVariable("TEXT_OPTION_VALUE", $textvalues);
$template->parseCurrentBlock();
$template->setVariable("QUESTION_TITLE", "$counter. ".$this->object->getTitle());
return $template->get();
}

+ Here is the call graph for this function:

SurveyTextQuestionGUI::getPrintView (   $question_title = 1,
  $show_questiontext = 1,
  $survey_id = null 
)

Creates a HTML representation of the question.

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

References ilUtil\getHtmlPath(), and ilUtil\getImagePath().

{
$template = new ilTemplate("tpl.il_svy_qpl_text_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
if ($show_questiontext)
{
$questiontext = $this->object->getQuestiontext();
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
}
if (! $this->object->getObligatory($survey_id))
{
$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("TEXTBOX_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("textbox.png")));
$template->setVariable("TEXTBOX", $this->lng->txt("textbox"));
$template->setVariable("TEXTBOX_WIDTH", $this->object->getTextWidth()*16);
$template->setVariable("TEXTBOX_HEIGHT", $this->object->getTextHeight()*16);
$template->setVariable("QUESTION_ID", $this->object->getId());
if ($this->object->getMaxChars())
{
$template->setVariable("TEXT_MAXCHARS", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxChars()));
}
return $template->get();
}

+ Here is the call graph for this function:

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

Creates the question output form for the learner.

Definition at line 197 of file class.SurveyTextQuestionGUI.php.

References SurveyQuestionGUI\getMaterialOutput(), and ilUtil\prepareFormOutput().

Referenced by preview().

{
$template = new ilTemplate("tpl.il_svy_out_text.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
$template->setCurrentBlock("material_text");
$template->setVariable("TEXT_MATERIAL", $this->getMaterialOutput());
$template->parseCurrentBlock();
if ($this->object->getTextHeight() == 1)
{
$template->setCurrentBlock("textinput");
if (is_array($working_data))
{
if (strlen($working_data[0]["textanswer"]))
{
$template->setVariable("VALUE_ANSWER", " value=\"" . ilUtil::prepareFormOutput($working_data[0]["textanswer"]) . "\"");
}
}
$template->setVariable("QUESTION_ID", $this->object->getId());
$template->setVariable("WIDTH", $this->object->getTextWidth());
if ($this->object->getMaxChars())
{
$template->setVariable("MAXLENGTH", " maxlength=\"" . $this->object->getMaxChars() . "\"");
}
$template->parseCurrentBlock();
}
else
{
$template->setCurrentBlock("textarea");
if (is_array($working_data))
{
$template->setVariable("VALUE_ANSWER", ilUtil::prepareFormOutput($working_data[0]["textanswer"]));
}
$template->setVariable("QUESTION_ID", $this->object->getId());
$template->setVariable("WIDTH", $this->object->getTextWidth());
$template->setVariable("HEIGHT", $this->object->getTextHeight());
$template->parseCurrentBlock();
}
$template->setCurrentBlock("question_data_text");
if ($show_questiontext)
{
$questiontext = $this->object->getQuestiontext();
$template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
}
if (! $this->object->getObligatory($survey_id))
{
$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("LABEL_QUESTION_ID", $this->object->getId());
if (strcmp($error_message, "") != 0)
{
$template->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
}
if ($this->object->getMaxChars())
{
$template->setVariable("TEXT_MAXCHARS", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxChars()));
}
$template->parseCurrentBlock();
return $template->get();
}

+ 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 301 of file class.SurveyTextQuestionGUI.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:

SurveyTextQuestionGUI::setQuestionTabs ( )

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

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

Definition at line 49 of file class.SurveyTextQuestionGUI.php.

References SurveyQuestionGUI\SurveyQuestionGUI().

{
include_once "./Modules/SurveyQuestionPool/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 (   $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 69 of file class.SurveyTextQuestionGUI.php.

References $_POST, and 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->setMaxChars((strlen($_POST["maxchars"])) ? $_POST["maxchars"] : null);
$this->object->setTextWidth($_POST["textwidth"]);
$this->object->setTextHeight($_POST["textheight"]);
return 0;
}
else
{
return 1;
}
}

+ Here is the call graph for this function:


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