24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
57 $this->textwidth = 50;
58 $this->textheight = 5;
77 return $ilDB->fetchAssoc(
$result);
104 $this->label =
$data[
'label'];
109 include_once(
"./Services/RTE/classes/class.ilRTE.php");
120 parent::loadFromDb(
$id);
162 return ($this->maxchars) ? $this->maxchars : NULL;
174 $affectedRows = parent::saveToDb($original_id);
175 if ($affectedRows == 1)
177 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
181 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, maxchars, width, height) VALUES (%s, %s, %s, %s)",
182 array(
'integer',
'integer',
'integer',
'integer'),
196 function toXML($a_include_header = TRUE, $obligatory_state =
"")
198 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
201 $this->
insertXML($a_xml_writer, $a_include_header, $obligatory_state);
202 $xml = $a_xml_writer->xmlDumpMem(FALSE);
203 if (!$a_include_header)
205 $pos = strpos($xml,
"?>");
206 $xml = substr($xml, $pos + 2);
218 function insertXML(&$a_xml_writer, $a_include_header = TRUE)
221 "id" => $this->
getId(),
223 "type" => $this->getQuestiontype(),
226 $a_xml_writer->xmlStartTag(
"question", $attrs);
228 $a_xml_writer->xmlElement(
"description", NULL, $this->
getDescription());
229 $a_xml_writer->xmlElement(
"author", NULL, $this->
getAuthor());
230 if (strlen($this->label))
233 "label" => $this->label,
240 $a_xml_writer->xmlStartTag(
"questiontext", $attrs);
242 $a_xml_writer->xmlEndTag(
"questiontext");
244 $a_xml_writer->xmlStartTag(
"responses");
254 $a_xml_writer->xmlElement(
"response_text", $attrs);
255 $a_xml_writer->xmlEndTag(
"responses");
257 if (count($this->material))
259 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches))
262 "label" => $this->material[
"title"]
264 $a_xml_writer->xmlStartTag(
"material", $attrs);
265 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
266 if (strcmp($matches[1],
"") != 0)
268 $intlink = $this->material[
"internal_link"];
270 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
271 $a_xml_writer->xmlEndTag(
"material");
275 $a_xml_writer->xmlEndTag(
"question");
286 return "SurveyTextQuestion";
297 return "svy_qst_text";
308 $entered_value = $post_data[$this->
getId() .
"_text_question"];
310 if (strlen($entered_value))
312 array_push(
$data,
array(
"textanswer" => $entered_value));
328 $entered_value = $post_data[$this->
getId() .
"_text_question"];
332 if (strlen($entered_value) == 0)
return $this->lng->txt(
"text_question_not_filled_out");
335 include_once(
"./Services/Utilities/classes/class.ilStr.php");
338 return str_replace(
"%s",
ilStr::strLen($entered_value), $this->lng->txt(
"svy_answer_too_long"));
351 include_once(
"./Services/Utilities/classes/class.ilStr.php");
354 $entered_value =
ilStr::subStr($entered_value, 0, $maxchars);
359 return array(
array(
"value"=>null,
"textanswer"=>$entered_value));
361 if (strlen($entered_value) == 0)
return;
363 $next_id = $ilDB->nextId(
'svy_answer');
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());
373 $affectedRows = $ilDB->insert(
"svy_answer", $fields);
387 if (
$data[
"maxlength"] > 0)
391 if (
$data[
"rows"] > 0)
395 if (
$data[
"columns"] > 0)
421 return ($this->textwidth) ? $this->textwidth : NULL;
432 return ($this->textheight) ? $this->textheight : NULL;
443 if ($a_textwidth < 1)
445 $this->textwidth = 50;
449 $this->textwidth = $a_textwidth;
461 if ($a_textheight < 1)
463 $this->textheight = 5;
467 $this->textheight = $a_textheight;
setTextHeight($a_textheight)
Sets the height of the answer field.
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.
stripSlashesAddSpaceFallback($a_str)
Strip slashes with add space fallback, see https://mantis.ilias.de/view.php?id=19727 and https://mant...
setObligatory($obligatory=1)
Sets the obligatory state of the question.
toXML($a_include_header=TRUE, $obligatory_state="")
Returns an xml representation of the question.
saveToDb($original_id="")
Saves a SurveyTextQuestion object to a database.
setId($id=-1)
Sets the id of the SurveyQuestion object.
isComplete()
Returns true if the question is complete for use.
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
getQuestionType()
Returns the question type of the question.
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.
getQuestionDataArray($id)
Returns the question data fields from the database.
setOriginalId($original_id)
checkUserInput($post_data, $survey_id)
Checks the input of the active user for obligatory status and entered values.
setQuestiontext($questiontext="")
Sets the questiontext of the SurveyQuestion object.
saveUserInput($post_data, $active_id, $a_return=false)
getId()
Gets the id of the SurveyQuestion object.
importResponses($a_data)
Import response data from the question import file.
Basic class for all survey question types.
insertXML(&$a_xml_writer, $a_include_header=TRUE)
Adds the question XML to a given XMLWriter object.
saveMaterial()
save material to db
loadFromDb($id)
Loads a SurveyTextQuestion object from the database.
xmlHeader()
Writes xml header public.
Create styles array
The data for the language used.
usableForPrecondition()
Returns if the question is usable for preconditions.
setAuthor($author="")
Sets the authors name of the SurveyQuestion object.
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.
setDescription($description="")
Sets the description string of the SurveyQuestion object.
& getWorkingDataFromUserInput($post_data)
Creates the user data of the svy_answer table from the POST data.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getDescription()
Gets the description string of the SurveyQuestion object.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
setObjId($obj_id=0)
Set the reference id of the container object.
static subStr($a_str, $a_start, $a_length=NULL)
getMaxChars()
Returns the maximum number of allowed characters for the text answer.
getTextHeight()
Returns the height of the answer field.
setTextWidth($a_textwidth)
Sets the width of the answer field.
__construct($title="", $description="", $author="", $questiontext="", $owner=-1)
The constructor takes possible arguments an creates an instance of the SurveyTextQuestion object...
setTitle($title="")
Sets the title string of the SurveyQuestion object.