ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
SurveyTextQuestion Class Reference

Text survey question. More...

+ Inheritance diagram for SurveyTextQuestion:
+ Collaboration diagram for SurveyTextQuestion:

Public Member Functions

 __construct ($title="", $description="", $author="", $questiontext="", $owner=-1)
 The constructor takes possible arguments an creates an instance of the SurveyTextQuestion object. More...
 
 getQuestionDataArray ($id)
 Returns the question data fields from the database. More...
 
 loadFromDb ($id)
 Loads a SurveyTextQuestion object from the database. More...
 
 isComplete ()
 Returns true if the question is complete for use. More...
 
 setMaxChars ($maxchars=0)
 Sets the maximum number of allowed characters for the text answer. More...
 
 getMaxChars ()
 Returns the maximum number of allowed characters for the text answer. More...
 
 saveToDb ($original_id="")
 Saves a SurveyTextQuestion object to a database. More...
 
 toXML ($a_include_header=TRUE, $obligatory_state="")
 Returns an xml representation of the question. More...
 
 insertXML (&$a_xml_writer, $a_include_header=TRUE)
 Adds the question XML to a given XMLWriter object. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
getWorkingDataFromUserInput ($post_data)
 Creates the user data of the svy_answer table from the POST data. More...
 
 checkUserInput ($post_data, $survey_id)
 Checks the input of the active user for obligatory status and entered values. More...
 
 saveUserInput ($post_data, $active_id, $a_return=false)
 
 importResponses ($a_data)
 Import response data from the question import file. More...
 
 usableForPrecondition ()
 Returns if the question is usable for preconditions. More...
 
 getTextWidth ()
 Returns the width of the answer field. More...
 
 getTextHeight ()
 Returns the height of the answer field. More...
 
 setTextWidth ($a_textwidth)
 Sets the width of the answer field. More...
 
 setTextHeight ($a_textheight)
 Sets the height of the answer field. More...
 
- Public Member Functions inherited from SurveyQuestion
 __construct ($title="", $description="", $author="", $questiontext="", $owner=-1)
 SurveyQuestion constructor The constructor takes possible arguments an creates an instance of the SurveyQuestion object. More...
 
 setComplete ($a_complete)
 Sets the complete state of the question. More...
 
 isComplete ()
 Returns 1, if a question is complete for use. More...
 
 questionTitleExists ($title, $questionpool_object="")
 Returns TRUE if the question title exists in the database. More...
 
 setTitle ($title="")
 Sets the title string of the SurveyQuestion object. More...
 
 setObligatory ($obligatory=1)
 Sets the obligatory state of the question. More...
 
 setOrientation ($orientation=0)
 Sets the orientation of the question output. More...
 
 setId ($id=-1)
 Sets the id of the SurveyQuestion object. More...
 
 setSurveyId ($id=-1)
 Sets the survey id of the SurveyQuestion object. More...
 
 setDescription ($description="")
 Sets the description string of the SurveyQuestion object. More...
 
 addMaterials ($materials_file, $materials_name="")
 Sets the materials uri. More...
 
 setMaterialsfile ($materials_filename, $materials_tempfilename="", $materials_name="")
 Sets and uploads the materials uri. More...
 
 deleteMaterial ($materials_name="")
 Deletes a materials uri with a given name. More...
 
 flushMaterials ()
 Deletes all materials uris. More...
 
 setAuthor ($author="")
 Sets the authors name of the SurveyQuestion object. More...
 
 setQuestiontext ($questiontext="")
 Sets the questiontext of the SurveyQuestion object. More...
 
 setOwner ($owner="")
 Sets the creator/owner ID of the SurveyQuestion object. More...
 
 getTitle ()
 Gets the title string of the SurveyQuestion object. More...
 
 getLabel ()
 
 getId ()
 Gets the id of the SurveyQuestion object. More...
 
 getObligatory ($survey_id="")
 Gets the obligatory state of the question. More...
 
 getSurveyId ()
 Gets the survey id of the SurveyQuestion object. More...
 
 getOrientation ()
 Gets the orientation of the question output. More...
 
 getDescription ()
 Gets the description string of the SurveyQuestion object. More...
 
 getAuthor ()
 Gets the authors name of the SurveyQuestion object. More...
 
 getOwner ()
 Gets the creator/owner ID of the SurveyQuestion object. More...
 
 getQuestiontext ()
 Gets the questiontext of the SurveyQuestion object. More...
 
 getObjId ()
 Get the reference id of the container object. More...
 
 setObjId ($obj_id=0)
 Set the reference id of the container object. More...
 
 duplicate ($for_survey=true, $title="", $author="", $owner="", $a_survey_id=0)
 Duplicates a survey question. More...
 
 copyObject ($target_questionpool, $title="")
 Copies an assOrderingQuestion object. More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 Increases the media object usage counter when a question is duplicated. More...
 
 loadFromDb ($question_id)
 Loads a SurveyQuestion object from the database. More...
 
 saveCompletionStatus ($original_id="")
 Saves the complete flag to the database. More...
 
 saveToDb ($original_id="")
 Saves a SurveyQuestion object to a database. More...
 
 saveMaterial ()
 save material to db More...
 
 createNewQuestion ()
 Creates a new question with a 0 timestamp when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveWorkingData ($limit_to=LIMIT_NO_LIMIT)
 Saves the learners input of the question to the database. More...
 
 getImagePath ()
 Returns the image path for web accessable images of a question. More...
 
 getMaterialsPath ()
 Returns the materials path for web accessable materials of a question. More...
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getMaterialsPathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 saveCategoryToDb ($categorytext, $neutral=0)
 Saves a category to the database. More...
 
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database. More...
 
 delete ($question_id)
 Deletes a question and all materials from the database. More...
 
 syncWithOriginal ()
 
 getPhrase ($phrase_id)
 Returns a phrase for a given database id. More...
 
 phraseExists ($title)
 Returns true if the phrase title already exists for the current user. More...
 
 addInternalLink ($material_id, $title="")
 
 deleteMaterials ($a_array)
 Deletes materials. More...
 
 duplicateMaterials ($question_id)
 Duplicates the materials of a question. More...
 
 addMaterial ($obj_material)
 
 setMaterial ($material_id="", $is_import=false, $material_title="")
 Sets a material link for the question. More...
 
 getQuestionTypeID ()
 Returns the question type ID of the question. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 isHTML ($a_text)
 Checks if a given string contains HTML or not. More...
 
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string. More...
 
 addMaterialTag (&$a_xml_writer, $a_material, $close_material_tag=TRUE, $add_mobs=TRUE, $a_attrs=null)
 Creates an XML material tag from a plain text or xhtml text. More...
 
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=FALSE)
 Prepares a string for a text area output in surveys. More...
 
 getQuestionDataArray ($id)
 Returns the question data fields from the database. More...
 
getWorkingDataFromUserInput ($post_data)
 Creates the user data of the svy_answer table from the POST data. More...
 
 importAdditionalMetadata ($a_meta)
 Import additional meta data from the question import file. More...
 
 importResponses ($a_data)
 Import response data from the question import file. More...
 
 importAdjectives ($a_data)
 Import bipolar adjectives from the question import file. More...
 
 importMatrix ($a_data)
 Import matrix rows from the question import file. More...
 
 usableForPrecondition ()
 Returns if the question is usable for preconditions. More...
 
 getAvailableRelations ()
 Returns the available relations for the question. More...
 
 getPreconditionOptions ()
 Returns the options for preconditions. More...
 
 getPreconditionValueOutput ($value)
 Returns the output for a precondition value. More...
 
 getPreconditionSelectValue ($default="", $title, $variable)
 Creates a form property for the precondition value. More...
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 getMaterial ()
 
 setSubtype ($a_subtype)
 
 getSubtype ()
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 getCopyIds ($a_group_by_survey=false)
 
 hasCopies ()
 
 stripSlashesAddSpaceFallback ($a_str)
 Strip slashes with add space fallback, see https://mantis.ilias.de/view.php?id=19727 and https://mantis.ilias.de/view.php?id=24200. More...
 

Data Fields

 $maxchars
 
 $textwidth
 
 $textheight
 
- Data Fields inherited from SurveyQuestion
 $id
 
 $title
 
 $description
 
 $owner
 
 $author
 
 $materials
 
 $survey_id
 
 $obj_id
 
 $questiontext
 
 $obligatory
 
 $ilias
 
 $tpl
 
 $lng
 
 $orientation
 
 $material
 
 $complete
 

Additional Inherited Members

- Static Public Member Functions inherited from SurveyQuestion
static _isComplete ($question_id)
 Checks whether the question is complete or not. More...
 
static _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
static _getTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
static _getOriginalId ($question_id, $a_return_question_id_if_no_original=true)
 Returns the original id of a question. More...
 
static _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
static _resolveInternalLink ($internal_link)
 
static _resolveIntLinks ($question_id)
 
static _getInternalLinkHref ($target="", $a_parent_ref_id=null)
 
static _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
static _includeClass ($question_type, $gui=0)
 Include the php class file for a given question type. More...
 
static _getQuestionTypeName ($type_tag)
 Return the translation for a given question type tag. More...
 
static _instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id. More...
 
static _instanciateQuestionGUI ($question_id)
 Creates an instance of a question GUI with a given question id. More...
 
static _instanciateQuestionEvaluation ($question_id, array $a_finished_ids=null)
 Creates an instance of a question evaluation with a given question id. More...
 
static _changeOriginalId ($a_question_id, $a_original_id, $a_object_id)
 Change original id of existing question in db. More...
 
static _lookupSurveyObjId ($a_question_id)
 
static lookupObjFi ($a_qid)
 Lookip obj fi. More...
 
- Protected Attributes inherited from SurveyQuestion
 $cumulated
 An array containing the cumulated results of the question for a given survey. More...
 
 $log
 

Detailed Description

Text survey question.

The SurveyTextQuestion class defines and encapsulates basic methods and attributes 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.SurveyTextQuestion.php.

Constructor & Destructor Documentation

◆ __construct()

SurveyTextQuestion::__construct (   $title = "",
  $description = "",
  $author = "",
  $questiontext = "",
  $owner = -1 
)

The constructor takes possible arguments an creates an instance of the SurveyTextQuestion object.

Parameters
string$titleA title string to describe the question
string$descriptionA description string to describe the question
string$authorA string containing the name of the questions author
integer$ownerA numerical ID to identify the owner/creator public

Definition at line 52 of file class.SurveyTextQuestion.php.

References SurveyQuestion\$author, SurveyQuestion\$description, SurveyQuestion\$owner, SurveyQuestion\$questiontext, and SurveyQuestion\$title.

53  {
54  parent::__construct($title, $description, $author, $questiontext, $owner);
55 
56  $this->maxchars = 0;
57  $this->textwidth = 50;
58  $this->textheight = 5;
59  }

Member Function Documentation

◆ checkUserInput()

SurveyTextQuestion::checkUserInput (   $post_data,
  $survey_id 
)

Checks the input of the active user for obligatory status and entered values.

Parameters
array$post_dataThe contents of the $_POST array
integer$survey_idThe database ID of the active survey
Returns
string Empty string if the input is ok, an error message otherwise public

Definition at line 326 of file class.SurveyTextQuestion.php.

References SurveyQuestion\$survey_id, SurveyQuestion\getId(), getMaxChars(), SurveyQuestion\getObligatory(), and ilStr\strLen().

327  {
328  $entered_value = $post_data[$this->getId() . "_text_question"];
329 
330  if ((!$this->getObligatory($survey_id)) && (strlen($entered_value) == 0)) return "";
331 
332  if (strlen($entered_value) == 0) return $this->lng->txt("text_question_not_filled_out");
333 
334  // see bug #22648
335  include_once("./Services/Utilities/classes/class.ilStr.php");
336  if ($this->getMaxChars() > 0 && ilStr::strLen($entered_value) > $this->getMaxChars())
337  {
338  return str_replace("%s", ilStr::strLen($entered_value), $this->lng->txt("svy_answer_too_long"));
339  }
340 
341  return "";
342  }
static strLen($a_string)
Definition: class.ilStr.php:91
getObligatory($survey_id="")
Gets the obligatory state of the question.
getId()
Gets the id of the SurveyQuestion object.
getMaxChars()
Returns the maximum number of allowed characters for the text answer.
+ Here is the call graph for this function:

◆ getAdditionalTableName()

SurveyTextQuestion::getAdditionalTableName ( )

Returns the name of the additional question data table in the database.

Returns
string The additional table name public

Definition at line 295 of file class.SurveyTextQuestion.php.

Referenced by getQuestionDataArray(), loadFromDb(), and saveToDb().

296  {
297  return "svy_qst_text";
298  }
+ Here is the caller graph for this function:

◆ getMaxChars()

SurveyTextQuestion::getMaxChars ( )

Returns the maximum number of allowed characters for the text answer.

public

Definition at line 160 of file class.SurveyTextQuestion.php.

Referenced by checkUserInput(), insertXML(), saveToDb(), and saveUserInput().

161  {
162  return ($this->maxchars) ? $this->maxchars : NULL;
163  }
+ Here is the caller graph for this function:

◆ getQuestionDataArray()

SurveyTextQuestion::getQuestionDataArray (   $id)

Returns the question data fields from the database.

Parameters
integer$idThe question ID from the database
Returns
array Array containing the question fields and data from the database public

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

References SurveyQuestion\$id, $ilDB, $result, array, and getAdditionalTableName().

69  {
70  global $ilDB;
71  $result = $ilDB->queryF("SELECT svy_question.*, " . $this->getAdditionalTableName() . ".* FROM svy_question, " . $this->getAdditionalTableName() . " WHERE svy_question.question_id = %s AND svy_question.question_id = " . $this->getAdditionalTableName() . ".question_fi",
72  array('integer'),
73  array($id)
74  );
75  if ($result->numRows() == 1)
76  {
77  return $ilDB->fetchAssoc($result);
78  }
79  else
80  {
81  return array();
82  }
83  }
$result
Create styles array
The data for the language used.
global $ilDB
getAdditionalTableName()
Returns the name of the additional question data table in the database.
+ Here is the call graph for this function:

◆ getQuestionType()

SurveyTextQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

Definition at line 284 of file class.SurveyTextQuestion.php.

285  {
286  return "SurveyTextQuestion";
287  }

◆ getTextHeight()

SurveyTextQuestion::getTextHeight ( )

Returns the height of the answer field.

Returns
integer The height of the answer field in characters public

Definition at line 430 of file class.SurveyTextQuestion.php.

Referenced by insertXML(), and saveToDb().

431  {
432  return ($this->textheight) ? $this->textheight : NULL;
433  }
+ Here is the caller graph for this function:

◆ getTextWidth()

SurveyTextQuestion::getTextWidth ( )

Returns the width of the answer field.

Returns
integer The width of the answer field in characters public

Definition at line 419 of file class.SurveyTextQuestion.php.

Referenced by insertXML(), and saveToDb().

420  {
421  return ($this->textwidth) ? $this->textwidth : NULL;
422  }
+ Here is the caller graph for this function:

◆ getWorkingDataFromUserInput()

& SurveyTextQuestion::getWorkingDataFromUserInput (   $post_data)

Creates the user data of the svy_answer table from the POST data.

Returns
array User data according to the svy_answer table public

Definition at line 306 of file class.SurveyTextQuestion.php.

References $data, array, and SurveyQuestion\getId().

307  {
308  $entered_value = $post_data[$this->getId() . "_text_question"];
309  $data = array();
310  if (strlen($entered_value))
311  {
312  array_push($data, array("textanswer" => $entered_value));
313  }
314  return $data;
315  }
getId()
Gets the id of the SurveyQuestion object.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ importResponses()

SurveyTextQuestion::importResponses (   $a_data)

Import response data from the question import file.

Returns
array $a_data Array containing the response data public

Definition at line 383 of file class.SurveyTextQuestion.php.

References $data, SurveyQuestion\$id, setMaxChars(), setTextHeight(), and setTextWidth().

384  {
385  foreach ($a_data as $id => $data)
386  {
387  if ($data["maxlength"] > 0)
388  {
389  $this->setMaxChars($data["maxlength"]);
390  }
391  if ($data["rows"] > 0)
392  {
393  $this->setTextHeight($data["rows"]);
394  }
395  if ($data["columns"] > 0)
396  {
397  $this->setTextWidth($data["columns"]);
398  }
399  }
400  }
setTextHeight($a_textheight)
Sets the height of the answer field.
setMaxChars($maxchars=0)
Sets the maximum number of allowed characters for the text answer.
setTextWidth($a_textwidth)
Sets the width of the answer field.
+ Here is the call graph for this function:

◆ insertXML()

SurveyTextQuestion::insertXML ( $a_xml_writer,
  $a_include_header = TRUE 
)

Adds the question XML to a given XMLWriter object.

Parameters
object$a_xml_writerThe XMLWriter object
boolean$a_include_headerDetermines wheather or not the XML should be used public

Definition at line 218 of file class.SurveyTextQuestion.php.

References SurveyQuestion\addMaterialTag(), array, SurveyQuestion\getAuthor(), SurveyQuestion\getDescription(), SurveyQuestion\getId(), getMaxChars(), SurveyQuestion\getObligatory(), SurveyQuestion\getQuestiontext(), getTextHeight(), getTextWidth(), and SurveyQuestion\getTitle().

Referenced by toXML().

219  {
220  $attrs = array(
221  "id" => $this->getId(),
222  "title" => $this->getTitle(),
223  "type" => $this->getQuestiontype(),
224  "obligatory" => $this->getObligatory()
225  );
226  $a_xml_writer->xmlStartTag("question", $attrs);
227 
228  $a_xml_writer->xmlElement("description", NULL, $this->getDescription());
229  $a_xml_writer->xmlElement("author", NULL, $this->getAuthor());
230  if (strlen($this->label))
231  {
232  $attrs = array(
233  "label" => $this->label,
234  );
235  }
236  else
237  {
238  $attrs = array();
239  }
240  $a_xml_writer->xmlStartTag("questiontext", $attrs);
241  $this->addMaterialTag($a_xml_writer, $this->getQuestiontext());
242  $a_xml_writer->xmlEndTag("questiontext");
243 
244  $a_xml_writer->xmlStartTag("responses");
245  $attrs = array(
246  "id" => "0",
247  "rows" => $this->getTextHeight(),
248  "columns" => $this->getTextWidth()
249  );
250  if ($this->getMaxChars() > 0)
251  {
252  $attrs["maxlength"] = $this->getMaxChars();
253  }
254  $a_xml_writer->xmlElement("response_text", $attrs);
255  $a_xml_writer->xmlEndTag("responses");
256 
257  if (count($this->material))
258  {
259  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $this->material["internal_link"], $matches))
260  {
261  $attrs = array(
262  "label" => $this->material["title"]
263  );
264  $a_xml_writer->xmlStartTag("material", $attrs);
265  $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
266  if (strcmp($matches[1], "") != 0)
267  {
268  $intlink = $this->material["internal_link"];
269  }
270  $a_xml_writer->xmlElement("mattext", NULL, $intlink);
271  $a_xml_writer->xmlEndTag("material");
272  }
273  }
274 
275  $a_xml_writer->xmlEndTag("question");
276  }
getTextWidth()
Returns the width of the answer field.
getAuthor()
Gets the authors name of the SurveyQuestion object.
getTitle()
Gets the title string of the SurveyQuestion object.
getObligatory($survey_id="")
Gets the obligatory state of the question.
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
getId()
Gets the id of the SurveyQuestion object.
Create styles array
The data for the language used.
addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag=TRUE, $add_mobs=TRUE, $a_attrs=null)
Creates an XML material tag from a plain text or xhtml text.
getDescription()
Gets the description string of the SurveyQuestion object.
getMaxChars()
Returns the maximum number of allowed characters for the text answer.
getTextHeight()
Returns the height of the answer field.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isComplete()

SurveyTextQuestion::isComplete ( )

Returns true if the question is complete for use.

Returns
boolean True if the question is complete for use, otherwise false public

Definition at line 129 of file class.SurveyTextQuestion.php.

References SurveyQuestion\getAuthor(), SurveyQuestion\getQuestiontext(), and SurveyQuestion\getTitle().

130  {
131  if (
132  strlen($this->getTitle()) &&
133  strlen($this->getAuthor()) &&
134  strlen($this->getQuestiontext())
135  )
136  {
137  return 1;
138  }
139  else
140  {
141  return 0;
142  }
143  }
getAuthor()
Gets the authors name of the SurveyQuestion object.
getTitle()
Gets the title string of the SurveyQuestion object.
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
+ Here is the call graph for this function:

◆ loadFromDb()

SurveyTextQuestion::loadFromDb (   $id)

Loads a SurveyTextQuestion object from the database.

Parameters
integer$idThe database id of the text survey question public

Definition at line 91 of file class.SurveyTextQuestion.php.

References $data, SurveyQuestion\$id, $ilDB, $result, ilRTE\_replaceMediaObjectImageSrc(), array, getAdditionalTableName(), SurveyQuestion\setAuthor(), SurveyQuestion\setComplete(), SurveyQuestion\setDescription(), SurveyQuestion\setId(), setMaxChars(), SurveyQuestion\setObjId(), SurveyQuestion\setObligatory(), SurveyQuestion\setOriginalId(), SurveyQuestion\setOwner(), SurveyQuestion\setQuestiontext(), setTextHeight(), setTextWidth(), and SurveyQuestion\setTitle().

92  {
93  global $ilDB;
94 
95  $result = $ilDB->queryF("SELECT svy_question.*, " . $this->getAdditionalTableName() . ".* FROM svy_question LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = svy_question.question_id WHERE svy_question.question_id = %s",
96  array('integer'),
97  array($id)
98  );
99  if ($result->numRows() == 1)
100  {
101  $data = $ilDB->fetchAssoc($result);
102  $this->setId($data["question_id"]);
103  $this->setTitle($data["title"]);
104  $this->label = $data['label'];
105  $this->setDescription($data["description"]);
106  $this->setObjId($data["obj_fi"]);
107  $this->setAuthor($data["author"]);
108  $this->setOwner($data["owner_fi"]);
109  include_once("./Services/RTE/classes/class.ilRTE.php");
110  $this->setQuestiontext(ilRTE::_replaceMediaObjectImageSrc($data["questiontext"], 1));
111  $this->setObligatory($data["obligatory"]);
112  $this->setComplete($data["complete"]);
113  $this->setOriginalId($data["original_id"]);
114 
115  $this->setMaxChars($data["maxchars"]);
116  $this->setTextWidth($data["width"]);
117  $this->setTextHeight($data["height"]);
118 
119  }
120  parent::loadFromDb($id);
121  }
setTextHeight($a_textheight)
Sets the height of the answer field.
$result
setObligatory($obligatory=1)
Sets the obligatory state of the question.
setId($id=-1)
Sets the id of the SurveyQuestion object.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
setOwner($owner="")
Sets the creator/owner ID of the SurveyQuestion object.
setComplete($a_complete)
Sets the complete state of the question.
setMaxChars($maxchars=0)
Sets the maximum number of allowed characters for the text answer.
setOriginalId($original_id)
setQuestiontext($questiontext="")
Sets the questiontext of the SurveyQuestion object.
Create styles array
The data for the language used.
setAuthor($author="")
Sets the authors name of the SurveyQuestion object.
setDescription($description="")
Sets the description string of the SurveyQuestion object.
global $ilDB
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setObjId($obj_id=0)
Set the reference id of the container object.
setTextWidth($a_textwidth)
Sets the width of the answer field.
setTitle($title="")
Sets the title string of the SurveyQuestion object.
+ Here is the call graph for this function:

◆ saveToDb()

SurveyTextQuestion::saveToDb (   $original_id = "")

Saves a SurveyTextQuestion object to a database.

public

Definition at line 170 of file class.SurveyTextQuestion.php.

References $ilDB, array, getAdditionalTableName(), SurveyQuestion\getId(), getMaxChars(), getTextHeight(), getTextWidth(), and SurveyQuestion\saveMaterial().

171  {
172  global $ilDB;
173 
174  $affectedRows = parent::saveToDb($original_id);
175  if ($affectedRows == 1)
176  {
177  $affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
178  array('integer'),
179  array($this->getId())
180  );
181  $affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, maxchars, width, height) VALUES (%s, %s, %s, %s)",
182  array('integer', 'integer', 'integer', 'integer'),
183  array($this->getId(), $this->getMaxChars(), $this->getTextWidth(), $this->getTextHeight())
184  );
185 
186  $this->saveMaterial();
187  }
188  }
getTextWidth()
Returns the width of the answer field.
getId()
Gets the id of the SurveyQuestion object.
saveMaterial()
save material to db
Create styles array
The data for the language used.
global $ilDB
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getMaxChars()
Returns the maximum number of allowed characters for the text answer.
getTextHeight()
Returns the height of the answer field.
+ Here is the call graph for this function:

◆ saveUserInput()

SurveyTextQuestion::saveUserInput (   $post_data,
  $active_id,
  $a_return = false 
)

Definition at line 344 of file class.SurveyTextQuestion.php.

References $ilDB, array, SurveyQuestion\getId(), getMaxChars(), SurveyQuestion\stripSlashesAddSpaceFallback(), ilStr\subStr(), and time.

345  {
346  global $ilDB;
347 
348  $entered_value = $this->stripSlashesAddSpaceFallback($post_data[$this->getId() . "_text_question"]);
349  $maxchars = $this->getMaxChars();
350 
351  include_once("./Services/Utilities/classes/class.ilStr.php");
352  if ($maxchars > 0)
353  {
354  $entered_value = ilStr::subStr($entered_value, 0, $maxchars);
355  }
356 
357  if($a_return)
358  {
359  return array(array("value"=>null, "textanswer"=>$entered_value));
360  }
361  if (strlen($entered_value) == 0) return;
362 
363  $next_id = $ilDB->nextId('svy_answer');
364  #20216
365  $fields = array();
366  $fields['answer_id'] = array("integer", $next_id);
367  $fields['question_fi'] = array("integer", $this->getId());
368  $fields['active_fi'] = array("integer", $active_id);
369  $fields['value'] = array("float", NULL);
370  $fields['textanswer'] = array("clob", (strlen($entered_value)) ? $entered_value : NULL);
371  $fields['tstamp'] = array("integer", time());
372 
373  $affectedRows = $ilDB->insert("svy_answer", $fields);
374 
375  }
stripSlashesAddSpaceFallback($a_str)
Strip slashes with add space fallback, see https://mantis.ilias.de/view.php?id=19727 and https://mant...
getId()
Gets the id of the SurveyQuestion object.
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static subStr($a_str, $a_start, $a_length=NULL)
Definition: class.ilStr.php:15
getMaxChars()
Returns the maximum number of allowed characters for the text answer.
+ Here is the call graph for this function:

◆ setMaxChars()

SurveyTextQuestion::setMaxChars (   $maxchars = 0)

Sets the maximum number of allowed characters for the text answer.

public

Definition at line 150 of file class.SurveyTextQuestion.php.

References $maxchars.

Referenced by importResponses(), and loadFromDb().

151  {
152  $this->maxchars = $maxchars;
153  }
+ Here is the caller graph for this function:

◆ setTextHeight()

SurveyTextQuestion::setTextHeight (   $a_textheight)

Sets the height of the answer field.

Parameters
integer$a_textheightThe height of the answer field in characters public

Definition at line 459 of file class.SurveyTextQuestion.php.

Referenced by importResponses(), and loadFromDb().

460  {
461  if ($a_textheight < 1)
462  {
463  $this->textheight = 5;
464  }
465  else
466  {
467  $this->textheight = $a_textheight;
468  }
469  }
+ Here is the caller graph for this function:

◆ setTextWidth()

SurveyTextQuestion::setTextWidth (   $a_textwidth)

Sets the width of the answer field.

Parameters
integer$a_textwidthThe width of the answer field in characters public

Definition at line 441 of file class.SurveyTextQuestion.php.

Referenced by importResponses(), and loadFromDb().

442  {
443  if ($a_textwidth < 1)
444  {
445  $this->textwidth = 50;
446  }
447  else
448  {
449  $this->textwidth = $a_textwidth;
450  }
451  }
+ Here is the caller graph for this function:

◆ toXML()

SurveyTextQuestion::toXML (   $a_include_header = TRUE,
  $obligatory_state = "" 
)

Returns an xml representation of the question.

Returns
string The xml representation of the question public

Definition at line 196 of file class.SurveyTextQuestion.php.

References insertXML(), and ilXmlWriter\xmlHeader().

197  {
198  include_once("./Services/Xml/classes/class.ilXmlWriter.php");
199  $a_xml_writer = new ilXmlWriter;
200  $a_xml_writer->xmlHeader();
201  $this->insertXML($a_xml_writer, $a_include_header, $obligatory_state);
202  $xml = $a_xml_writer->xmlDumpMem(FALSE);
203  if (!$a_include_header)
204  {
205  $pos = strpos($xml, "?>");
206  $xml = substr($xml, $pos + 2);
207  }
208  return $xml;
209  }
XML writer class.
insertXML(&$a_xml_writer, $a_include_header=TRUE)
Adds the question XML to a given XMLWriter object.
xmlHeader()
Writes xml header public.
+ Here is the call graph for this function:

◆ usableForPrecondition()

SurveyTextQuestion::usableForPrecondition ( )

Returns if the question is usable for preconditions.

Returns
boolean TRUE if the question is usable for a precondition, FALSE otherwise public

Definition at line 408 of file class.SurveyTextQuestion.php.

409  {
410  return FALSE;
411  }

Field Documentation

◆ $maxchars

SurveyTextQuestion::$maxchars

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

Referenced by setMaxChars().

◆ $textheight

SurveyTextQuestion::$textheight

Definition at line 41 of file class.SurveyTextQuestion.php.

◆ $textwidth

SurveyTextQuestion::$textwidth

Definition at line 40 of file class.SurveyTextQuestion.php.


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