ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
SurveyTextQuestionGUI Class Reference

Text survey question GUI representation. More...

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

Public Member Functions

 setQuestionTabs ()
 
 getParsedAnswers (array $a_working_data=null, $a_only_user_anwers=false)
 
 getPrintView ($question_title=1, $show_questiontext=1, $survey_id=null, array $a_working_data=null)
 
 getWorkingForm ($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
 Creates the question output form for the learner. More...
 
 getCumulatedResultsDetails ($survey_id, $counter, $finished_ids)
 Creates the detailed output of the cumulated results for the question. More...
 
- Public Member Functions inherited from SurveyQuestionGUI
 __construct ($a_id=-1)
 
 setQuestionTabs ()
 
executeCommand ()
 
 _getGUIClassNameForId ($a_q_id)
 
 _getClassNameForQType ($q_type)
 
 getQuestionType ()
 Returns the question type string. More...
 
 setBackUrl ($a_url)
 
 setQuestionTabsForClass ($guiclass)
 
 getPrintView ($question_title=1, $show_questiontext=1)
 
 preview ()
 Creates a preview of the question. More...
 
 getWorkingForm ($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
 
 getCumulatedResultsDetails ($survey_id, $counter, $finished_ids)
 
 material ($checkonly=FALSE)
 Material tab of the survey questions. More...
 
 deleteMaterial ()
 
 addMaterial ()
 Add materials to a question. More...
 
 removeMaterial ()
 
 cancelExplorer ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 linkChilds ()
 
 savePhrase ($a_reload=false)
 Creates an output to save the current answers as a phrase. More...
 
 confirmSavePhrase ()
 Save a new phrase to the database. More...
 

Protected Member Functions

 initObject ()
 
 addFieldsToEditForm (ilPropertyFormGUI $a_form)
 
 importEditFormValues (ilPropertyFormGUI $a_form)
 
- Protected Member Functions inherited from SurveyQuestionGUI
 initObject ()
 
 outQuestionText ($template)
 
 initEditForm ()
 
 addCommandButtons ($a_form)
 
 editQuestion (ilPropertyFormGUI $a_form=null)
 
 saveSync ()
 
 saveReturn ()
 
 saveForm ()
 
 save ($a_return=false, $a_sync=false)
 
 copySyncForm ()
 
 syncCopies ()
 
 originalSyncForm ()
 
 sync ()
 
 cancelSync ()
 
 redirectAfterSaving ($a_return=false)
 Redirect to calling survey or to edit form. More...
 
 cancel ()
 
 validateEditForm (ilPropertyFormGUI $a_form)
 
 addFieldsToEditForm (ilPropertyFormGUI $a_form)
 
 importEditFormValues (ilPropertyFormGUI $a_form)
 
 getMaterialOutput ()
 Creates the HTML output of the question material(s) More...
 
 renderChart ($a_id, $a_variables)
 
 initPhrasesForm ()
 
 addPhrase (ilPropertyFormGUI $a_form=null)
 Creates an output for the addition of phrases. More...
 
 addSelectedPhrase ()
 

Additional Inherited Members

- Static Public Member Functions inherited from SurveyQuestionGUI
static & _getQuestionGUI ($questiontype, $question_id=-1)
 Creates a question gui representation. More...
 
- Data Fields inherited from SurveyQuestionGUI
 $object
 
- Protected Attributes inherited from SurveyQuestionGUI
 $tpl
 
 $lng
 
 $ctrl
 
 $cumulated
 
 $parent_url
 

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$

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

Member Function Documentation

◆ addFieldsToEditForm()

SurveyTextQuestionGUI::addFieldsToEditForm ( ilPropertyFormGUI  $a_form)
protected

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

References ilPropertyFormGUI\addItem(), and ilFormPropertyGUI\setRequired().

56  {
57  // maximum number of characters
58  $maxchars = new ilNumberInputGUI($this->lng->txt("maxchars"), "maxchars");
59  $maxchars->setRequired(false);
60  $maxchars->setSize(5);
61  $maxchars->setDecimals(0);
62  $a_form->addItem($maxchars);
63 
64  // textwidth
65  $textwidth = new ilNumberInputGUI($this->lng->txt("width"), "textwidth");
66  $textwidth->setRequired(true);
67  $textwidth->setSize(3);
68  $textwidth->setDecimals(0);
69  $textwidth->setMinValue(10, true);
70  $a_form->addItem($textwidth);
71 
72  // textheight
73  $textheight = new ilNumberInputGUI($this->lng->txt("height"), "textheight");
74  $textheight->setRequired(true);
75  $textheight->setSize(3);
76 
77  $textheight->setDecimals(0);
78  $textheight->setMinValue(1);
79  $a_form->addItem($textheight);
80 
81  // values
82  if ($this->object->getMaxChars() > 0)
83  {
84  $maxchars->setValue($this->object->getMaxChars());
85  }
86  $textwidth->setValue($this->object->getTextWidth());
87  $textheight->setValue($this->object->getTextHeight());
88  }
addItem($a_item)
Add Item (Property, SectionHeader).
This class represents a number property in a property form.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:

◆ getCumulatedResultsDetails()

SurveyTextQuestionGUI::getCumulatedResultsDetails (   $survey_id,
  $counter,
  $finished_ids 
)

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

References ilObjSurvey\_getNrOfParticipants().

230  {
231  if (count($this->cumulated) == 0)
232  {
233  if(!$finished_ids)
234  {
235  include_once "./Modules/Survey/classes/class.ilObjSurvey.php";
236  $nr_of_users = ilObjSurvey::_getNrOfParticipants($survey_id);
237  }
238  else
239  {
240  $nr_of_users = sizeof($finished_ids);
241  }
242  $this->cumulated =& $this->object->getCumulatedResults($survey_id, $nr_of_users, $finished_ids);
243  }
244 
245  $output = "";
246  include_once "./Services/UICore/classes/class.ilTemplate.php";
247  $template = new ilTemplate("tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE, "Modules/Survey");
248 
249  $template->setCurrentBlock("detail_row");
250  $template->setVariable("TEXT_OPTION", $this->lng->txt("question"));
251  $questiontext = $this->object->getQuestiontext();
252  $template->setVariable("TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
253  $template->parseCurrentBlock();
254  $template->setCurrentBlock("detail_row");
255  $template->setVariable("TEXT_OPTION", $this->lng->txt("question_type"));
256  $template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
257  $template->parseCurrentBlock();
258  $template->setCurrentBlock("detail_row");
259  $template->setVariable("TEXT_OPTION", $this->lng->txt("users_answered"));
260  $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_ANSWERED"]);
261  $template->parseCurrentBlock();
262  $template->setCurrentBlock("detail_row");
263  $template->setVariable("TEXT_OPTION", $this->lng->txt("users_skipped"));
264  $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["USERS_SKIPPED"]);
265  $template->parseCurrentBlock();
266 
267  $template->setCurrentBlock("detail_row");
268  $template->setVariable("TEXT_OPTION", $this->lng->txt("given_answers"));
269  $textvalues = "";
270  if (is_array($this->cumulated["textvalues"]))
271  {
272  foreach ($this->cumulated["textvalues"] as $textvalue)
273  {
274  $textvalues .= "<li>" . preg_replace("/\n/", "<br>", $textvalue) . "</li>";
275  }
276  }
277  $textvalues = "<ul>$textvalues</ul>";
278  $template->setVariable("TEXT_OPTION_VALUE", $textvalues);
279  $template->parseCurrentBlock();
280 
281  $template->setVariable("QUESTION_TITLE", "$counter. ".$this->object->getTitle());
282  return $template->get();
283  }
special template class to simplify handling of ITX/PEAR
_getNrOfParticipants($survey_id)
Returns the number of participants for a survey.
+ Here is the call graph for this function:

◆ getParsedAnswers()

SurveyTextQuestionGUI::getParsedAnswers ( array  $a_working_data = null,
  $a_only_user_anwers = false 
)

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

References $res.

Referenced by getPrintView().

99  {
100  $res = array();
101 
102  if(is_array($a_working_data))
103  {
104  $res[] = array("textanswer"=>trim($a_working_data[0]["textanswer"]));
105  }
106 
107  return $res;
108  }
+ Here is the caller graph for this function:

◆ getPrintView()

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

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

References ilUtil\getHtmlPath(), ilUtil\getImagePath(), getParsedAnswers(), and SurveyQuestionGUI\outQuestionText().

111  {
112  $user_answer = null;
113  if($a_working_data)
114  {
115  $user_answer = $this->getParsedAnswers($a_working_data);
116  $user_answer = $user_answer[0]["textanswer"];
117  }
118 
119  $template = new ilTemplate("tpl.il_svy_qpl_text_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
120  if ($show_questiontext)
121  {
122  $this->outQuestionText($template);
123  }
124  if ($question_title)
125  {
126  $template->setVariable("QUESTION_TITLE", $this->object->getTitle());
127  }
128  $template->setVariable("QUESTION_ID", $this->object->getId());
129  $template->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
130  if(is_array($a_working_data) && trim($user_answer))
131  {
132  $template->setVariable("TEXT", nl2br($user_answer));
133  }
134  else
135  {
136  $template->setVariable("TEXTBOX_IMAGE", ilUtil::getHtmlPath(ilUtil::getImagePath("textbox.png")));
137  $template->setVariable("TEXTBOX", $this->lng->txt("textbox"));
138  $template->setVariable("TEXTBOX_WIDTH", $this->object->getTextWidth()*16);
139  $template->setVariable("TEXTBOX_HEIGHT", $this->object->getTextHeight()*16);
140  }
141  if ($this->object->getMaxChars())
142  {
143  $template->setVariable("TEXT_MAXCHARS", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxChars()));
144  }
145  return $template->get();
146  }
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
static getHtmlPath($relative_path)
get url of path
getParsedAnswers(array $a_working_data=null, $a_only_user_anwers=false)
+ Here is the call graph for this function:

◆ getWorkingForm()

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

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

157  {
158  $template = new ilTemplate("tpl.il_svy_out_text.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
159  $template->setCurrentBlock("material_text");
160  $template->setVariable("TEXT_MATERIAL", $this->getMaterialOutput());
161  $template->parseCurrentBlock();
162 
163  if ($this->object->getTextHeight() == 1)
164  {
165  $template->setCurrentBlock("textinput");
166  if (is_array($working_data))
167  {
168  if (strlen($working_data[0]["textanswer"]))
169  {
170  $template->setVariable("VALUE_ANSWER", " value=\"" . ilUtil::prepareFormOutput($working_data[0]["textanswer"]) . "\"");
171  }
172  }
173  $template->setVariable("QUESTION_ID", $this->object->getId());
174  $template->setVariable("WIDTH", $this->object->getTextWidth());
175  if ($this->object->getMaxChars())
176  {
177  $template->setVariable("MAXLENGTH", " maxlength=\"" . $this->object->getMaxChars() . "\"");
178  }
179  $template->parseCurrentBlock();
180  }
181  else
182  {
183  $template->setCurrentBlock("textarea");
184  if (is_array($working_data))
185  {
186  $template->setVariable("VALUE_ANSWER", ilUtil::prepareFormOutput($working_data[0]["textanswer"]));
187  }
188  $template->setVariable("QUESTION_ID", $this->object->getId());
189  $template->setVariable("WIDTH", $this->object->getTextWidth());
190  $template->setVariable("HEIGHT", $this->object->getTextHeight());
191  $template->parseCurrentBlock();
192  }
193  $template->setCurrentBlock("question_data_text");
194  if ($show_questiontext)
195  {
196  $this->outQuestionText($template);
197  }
198  if ($question_title)
199  {
200  $template->setVariable("QUESTION_TITLE", $this->object->getTitle());
201  }
202  $template->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
203  $template->setVariable("LABEL_QUESTION_ID", $this->object->getId());
204  if (strcmp($error_message, "") != 0)
205  {
206  $template->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
207  }
208  if ($this->object->getMaxChars())
209  {
210  $template->setVariable("TEXT_MAXCHARS", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxChars()));
211  }
212  $template->parseCurrentBlock();
213  return $template->get();
214  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getMaterialOutput()
Creates the HTML output of the question material(s)
special template class to simplify handling of ITX/PEAR
+ Here is the call graph for this function:

◆ importEditFormValues()

SurveyTextQuestionGUI::importEditFormValues ( ilPropertyFormGUI  $a_form)
protected

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

References ilPropertyFormGUI\getInput().

91  {
92  $max = $a_form->getInput("maxchars");
93  $this->object->setMaxChars(strlen($max) ? $max : null);
94  $this->object->setTextWidth($a_form->getInput("textwidth"));
95  $this->object->setTextHeight($a_form->getInput("textheight"));
96  }
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
+ Here is the call graph for this function:

◆ initObject()

SurveyTextQuestionGUI::initObject ( )
protected

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

40  {
41  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyTextQuestion.php";
42  $this->object = new SurveyTextQuestion();
43  }
Text survey question.

◆ setQuestionTabs()

SurveyTextQuestionGUI::setQuestionTabs ( )

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

References SurveyQuestionGUI\setQuestionTabsForClass().

51  {
52  $this->setQuestionTabsForClass("surveytextquestiongui");
53  }
+ Here is the call graph for this function:

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