32        $this->db = 
$DIC->database();
 
   36        $this->textwidth = 50;
 
   37        $this->textheight = 5;
 
   81            $this->label = 
$data[
'label'];
 
   95        parent::loadFromDb(
$id);
 
  134        return ($this->maxchars) ? $this->maxchars : 
null;
 
  146        $affectedRows = parent::saveToDb($original_id);
 
  147        if ($affectedRows == 1) {
 
  148            $affectedRows = 
$ilDB->manipulateF(
 
  151                array($this->
getId())
 
  153            $affectedRows = 
$ilDB->manipulateF(
 
  154                "INSERT INTO " . $this->
getAdditionalTableName() . 
" (question_fi, maxchars, width, height) VALUES (%s, %s, %s, %s)",
 
  155                array(
'integer', 
'integer', 
'integer', 
'integer'),
 
  169    public function toXML($a_include_header = 
true, $obligatory_state = 
"")
 
  173        $this->
insertXML($a_xml_writer, $a_include_header, $obligatory_state);
 
  174        $xml = $a_xml_writer->xmlDumpMem(
false);
 
  175        if (!$a_include_header) {
 
  176            $pos = strpos(
$xml, 
"?>");
 
  189    public function insertXML(&$a_xml_writer, $a_include_header = 
true)
 
  192            "id" => $this->
getId(),
 
  194            "type" => $this->getQuestiontype(),
 
  197        $a_xml_writer->xmlStartTag(
"question", $attrs);
 
  199        $a_xml_writer->xmlElement(
"description", 
null, $this->
getDescription());
 
  200        $a_xml_writer->xmlElement(
"author", 
null, $this->
getAuthor());
 
  201        if (strlen($this->label)) {
 
  203                "label" => $this->label,
 
  208        $a_xml_writer->xmlStartTag(
"questiontext", $attrs);
 
  210        $a_xml_writer->xmlEndTag(
"questiontext");
 
  212        $a_xml_writer->xmlStartTag(
"responses");
 
  221        $a_xml_writer->xmlElement(
"response_text", $attrs);
 
  222        $a_xml_writer->xmlEndTag(
"responses");
 
  224        if (count($this->material)) {
 
  225            if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches)) {
 
  227                    "label" => $this->material[
"title"]
 
  229                $a_xml_writer->xmlStartTag(
"material", $attrs);
 
  230                $intlink = 
"il_" . 
IL_INST_ID . 
"_" . $matches[2] . 
"_" . $matches[3];
 
  231                if (strcmp($matches[1], 
"") != 0) {
 
  232                    $intlink = $this->material[
"internal_link"];
 
  234                $a_xml_writer->xmlElement(
"mattext", 
null, $intlink);
 
  235                $a_xml_writer->xmlEndTag(
"material");
 
  239        $a_xml_writer->xmlEndTag(
"question");
 
  250        return "SurveyTextQuestion";
 
  261        return "svy_qst_text";
 
  272        $entered_value = $post_data[$this->
getId() . 
"_text_question"];
 
  274        if (strlen($entered_value)) {
 
  275            array_push(
$data, array(
"textanswer" => $entered_value));
 
  291        $entered_value = $post_data[$this->
getId() . 
"_text_question"];
 
  297        if (strlen($entered_value) == 0) {
 
  298            return $this->lng->txt(
"text_question_not_filled_out");
 
  303            return str_replace(
"%s", 
ilStr::strLen($entered_value), $this->lng->txt(
"svy_answer_too_long"));
 
  321            return array(array(
"value" => 
null, 
"textanswer" => $entered_value));
 
  323        if (strlen($entered_value) == 0) {
 
  327        $next_id = 
$ilDB->nextId(
'svy_answer');
 
  330        $fields[
'answer_id'] = array(
"integer", $next_id);
 
  331        $fields[
'question_fi'] = array(
"integer", $this->
getId());
 
  332        $fields[
'active_fi'] = array(
"integer", $active_id);
 
  333        $fields[
'value'] = array(
"float", 
null);
 
  334        $fields[
'textanswer'] = array(
"clob", (strlen($entered_value)) ? $entered_value : 
null);
 
  335        $fields[
'tstamp'] = array(
"integer", time());
 
  337        $affectedRows = 
$ilDB->insert(
"svy_answer", $fields);
 
  349            if (
$data[
"maxlength"] > 0) {
 
  352            if (
$data[
"rows"] > 0) {
 
  355            if (
$data[
"columns"] > 0) {
 
  380        return ($this->textwidth) ? $this->textwidth : 
null;
 
  391        return ($this->textheight) ? $this->textheight : 
null;
 
  402        if ($a_textwidth < 1) {
 
  403            $this->textwidth = 50;
 
  405            $this->textwidth = $a_textwidth;
 
  417        if ($a_textheight < 1) {
 
  418            $this->textheight = 5;
 
  420            $this->textheight = $a_textheight;
 
An exception for terminatinating execution or to throw for unit testing.
Basic class for all survey question types.
setQuestiontext($questiontext="")
Sets the questiontext of the SurveyQuestion object.
setId($id=-1)
Sets the id of the SurveyQuestion object.
setAuthor($author="")
Sets the authors name of the SurveyQuestion object.
stripSlashesAddSpaceFallback($a_str)
Strip slashes with add space fallback, see https://mantis.ilias.de/view.php?id=19727 and https://mant...
getDescription()
Gets the description string of the SurveyQuestion object.
getId()
Gets the id of the SurveyQuestion object.
setDescription($description="")
Sets the description string of the SurveyQuestion object.
setObjId($obj_id=0)
Set the reference id of the container object.
getAuthor()
Gets the authors name of the SurveyQuestion object.
setOriginalId($original_id)
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
getObligatory($survey_id="")
Gets the obligatory state of the question.
getTitle()
Gets the title string of the SurveyQuestion object.
setComplete($a_complete)
Sets the complete state of the question.
saveMaterial()
save material to db
setOwner($owner="")
Sets the creator/owner ID of the SurveyQuestion object.
setTitle($title="")
Sets the title string 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.
setObligatory($obligatory=1)
Sets the obligatory state of the question.
getTextWidth()
Returns the width of the answer field.
insertXML(&$a_xml_writer, $a_include_header=true)
Adds the question XML to a given XMLWriter object.
checkUserInput($post_data, $survey_id)
Checks the input of the active user for obligatory status and entered values.
saveUserInput($post_data, $active_id, $a_return=false)
setMaxChars($maxchars=0)
Sets the maximum number of allowed characters for the text answer.
& getWorkingDataFromUserInput($post_data)
Creates the user data of the svy_answer table from the POST data.
isComplete()
Returns true if the question is complete for use.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
saveToDb($original_id="")
Saves a SurveyTextQuestion object to a database.
importResponses($a_data)
Import response data from the question import file.
getMaxChars()
Returns the maximum number of allowed characters for the text answer.
toXML($a_include_header=true, $obligatory_state="")
Returns an xml representation of the question.
setTextWidth($a_textwidth)
Sets the width of the answer field.
usableForPrecondition()
Returns if the question is usable for preconditions.
getQuestionType()
Returns the question type of the question.
__construct($title="", $description="", $author="", $questiontext="", $owner=-1)
The constructor takes possible arguments an creates an instance of the SurveyTextQuestion object.
getTextHeight()
Returns the height of the answer field.
loadFromDb($id)
Loads a SurveyTextQuestion object from the database.
setTextHeight($a_textheight)
Sets the height of the answer field.
getQuestionDataArray($id)
Returns the question data fields from the database.
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...
static subStr($a_str, $a_start, $a_length=null)
xmlHeader()
Writes xml header @access public.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc