24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
56 $this->db = $DIC->database();
60 $this->textwidth = 50;
61 $this->textheight = 5;
105 $this->label =
$data[
'label'];
110 include_once(
"./Services/RTE/classes/class.ilRTE.php");
120 parent::loadFromDb(
$id);
159 return ($this->maxchars) ? $this->maxchars : null;
171 $affectedRows = parent::saveToDb($original_id);
172 if ($affectedRows == 1) {
173 $affectedRows =
$ilDB->manipulateF(
176 array($this->
getId())
178 $affectedRows =
$ilDB->manipulateF(
179 "INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, maxchars, width, height) VALUES (%s, %s, %s, %s)",
180 array(
'integer',
'integer',
'integer',
'integer'),
194 public function toXML($a_include_header =
true, $obligatory_state =
"")
196 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
199 $this->
insertXML($a_xml_writer, $a_include_header, $obligatory_state);
200 $xml = $a_xml_writer->xmlDumpMem(
false);
201 if (!$a_include_header) {
202 $pos = strpos(
$xml,
"?>");
215 public function insertXML(&$a_xml_writer, $a_include_header =
true)
218 "id" => $this->
getId(),
220 "type" => $this->getQuestiontype(),
223 $a_xml_writer->xmlStartTag(
"question", $attrs);
225 $a_xml_writer->xmlElement(
"description", null, $this->
getDescription());
226 $a_xml_writer->xmlElement(
"author", null, $this->
getAuthor());
227 if (strlen($this->label)) {
229 "label" => $this->label,
234 $a_xml_writer->xmlStartTag(
"questiontext", $attrs);
236 $a_xml_writer->xmlEndTag(
"questiontext");
238 $a_xml_writer->xmlStartTag(
"responses");
247 $a_xml_writer->xmlElement(
"response_text", $attrs);
248 $a_xml_writer->xmlEndTag(
"responses");
250 if (count($this->material)) {
251 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches)) {
253 "label" => $this->material[
"title"]
255 $a_xml_writer->xmlStartTag(
"material", $attrs);
256 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
257 if (strcmp($matches[1],
"") != 0) {
258 $intlink = $this->material[
"internal_link"];
260 $a_xml_writer->xmlElement(
"mattext", null, $intlink);
261 $a_xml_writer->xmlEndTag(
"material");
265 $a_xml_writer->xmlEndTag(
"question");
276 return "SurveyTextQuestion";
287 return "svy_qst_text";
298 $entered_value = $post_data[$this->
getId() .
"_text_question"];
300 if (strlen($entered_value)) {
301 array_push(
$data, array(
"textanswer" => $entered_value));
317 $entered_value = $post_data[$this->
getId() .
"_text_question"];
323 if (strlen($entered_value) == 0) {
324 return $this->lng->txt(
"text_question_not_filled_out");
328 include_once(
"./Services/Utilities/classes/class.ilStr.php");
330 return str_replace(
"%s",
ilStr::strLen($entered_value), $this->lng->txt(
"svy_answer_too_long"));
343 include_once(
"./Services/Utilities/classes/class.ilStr.php");
349 return array(array(
"value" => null,
"textanswer" => $entered_value));
351 if (strlen($entered_value) == 0) {
355 $next_id =
$ilDB->nextId(
'svy_answer');
358 $fields[
'answer_id'] = array(
"integer", $next_id);
359 $fields[
'question_fi'] = array(
"integer", $this->
getId());
360 $fields[
'active_fi'] = array(
"integer", $active_id);
361 $fields[
'value'] = array(
"float", null);
362 $fields[
'textanswer'] = array(
"clob", (strlen($entered_value)) ? $entered_value : null);
363 $fields[
'tstamp'] = array(
"integer", time());
365 $affectedRows =
$ilDB->insert(
"svy_answer", $fields);
377 if (
$data[
"maxlength"] > 0) {
380 if (
$data[
"rows"] > 0) {
383 if (
$data[
"columns"] > 0) {
408 return ($this->textwidth) ? $this->textwidth : null;
419 return ($this->textheight) ? $this->textheight : null;
430 if ($a_textwidth < 1) {
431 $this->textwidth = 50;
433 $this->textwidth = $a_textwidth;
445 if ($a_textheight < 1) {
446 $this->textheight = 5;
448 $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.
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 subStr($a_str, $a_start, $a_length=null)
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.
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.
Basic class for all survey question types.
saveMaterial()
save material to db
loadFromDb($id)
Loads a SurveyTextQuestion object from the database.
xmlHeader()
Writes xml header public.
insertXML(&$a_xml_writer, $a_include_header=true)
Adds the question XML to a given XMLWriter object.
usableForPrecondition()
Returns if the question is usable for preconditions.
setAuthor($author="")
Sets the authors name of the SurveyQuestion object.
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.
toXML($a_include_header=true, $obligatory_state="")
Returns an xml representation of the question.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getDescription()
Gets the description string of the SurveyQuestion object.
setObjId($obj_id=0)
Set the reference id of the container object.
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.