42 $this->db = $DIC->database();
46 $this->textwidth = 50;
47 $this->textheight = 5;
53 $result =
$ilDB->queryF(
58 if ($result->numRows() === 1) {
59 return $ilDB->fetchAssoc($result);
69 $result =
$ilDB->queryF(
74 if ($result->numRows() === 1) {
77 $this->
setTitle((
string) $data[
"title"]);
78 $this->label = (string) $data[
'label'];
80 $this->
setObjId((
int) $data[
"obj_fi"]);
81 $this->
setAuthor((
string) $data[
"author"]);
82 $this->
setOwner((
int) $data[
"owner_fi"]);
89 $this->
setTextWidth($data[
"width"] ? (
int) $data[
"width"] : null);
90 $this->
setTextHeight($data[
"height"] ? (
int) $data[
"height"] : null);
92 parent::loadFromDb($question_id);
123 if ($affectedRows === 1) {
127 array($this->
getId())
130 "INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, maxchars, width, height) VALUES (%s, %s, %s, %s)",
131 array(
'integer',
'integer',
'integer',
'integer'),
135 return $affectedRows;
139 bool $a_include_header =
true,
140 bool $obligatory_state =
false 143 $a_xml_writer->xmlHeader();
144 $this->
insertXML($a_xml_writer, $a_include_header);
145 $xml = $a_xml_writer->xmlDumpMem(
false);
146 if (!$a_include_header) {
147 $pos = strpos($xml,
"?>");
148 $xml = substr($xml, $pos + 2);
155 $a_include_header =
true 158 "id" => $this->
getId(),
167 if (strlen($this->label ??
"")) {
169 "label" => $this->label,
174 $a_xml_writer->
xmlStartTag(
"questiontext", $attrs);
176 $a_xml_writer->
xmlEndTag(
"questiontext");
187 $a_xml_writer->
xmlElement(
"response_text", $attrs);
190 if (count($this->material)) {
191 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches)) {
193 "label" => $this->material[
"title"]
196 $intlink =
"il_" .
IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
197 if (strcmp($matches[1],
"") != 0) {
198 $intlink = $this->material[
"internal_link"];
200 $a_xml_writer->
xmlElement(
"mattext", null, $intlink);
210 return "SurveyTextQuestion";
215 return "svy_qst_text";
221 $entered_value = $post_data[$this->
getId() .
"_text_question"] ??
"";
223 if (strlen($entered_value ??
"")) {
224 $data[] = array(
"textanswer" => $entered_value);
237 $entered_value = $post_data[$this->
getId() .
"_text_question"];
239 if ((!$this->
getObligatory()) && (strlen($entered_value ??
"") == 0)) {
243 if (strlen($entered_value ??
"") == 0) {
244 return $this->
lng->txt(
"text_question_not_filled_out");
249 return str_replace(
"%s",
ilStr::strLen($entered_value), $this->
lng->txt(
"svy_answer_too_long"));
258 bool $a_return =
false 266 $entered_value =
ilStr::subStr($entered_value, 0, $maxchars);
270 return array(array(
"value" => null,
"textanswer" => $entered_value));
272 if (strlen($entered_value ??
"") == 0) {
276 $next_id =
$ilDB->nextId(
'svy_answer');
279 $fields[
'answer_id'] = array(
"integer", $next_id);
280 $fields[
'question_fi'] = array(
"integer", $this->
getId());
281 $fields[
'active_fi'] = array(
"integer", $active_id);
282 $fields[
'value'] = array(
"float", null);
283 $fields[
'textanswer'] = array(
"clob", (strlen($entered_value ??
"")) ? $entered_value : null);
284 $fields[
'tstamp'] = array(
"integer", time());
286 $ilDB->insert(
"svy_answer", $fields);
294 if (
$data[
"maxlength"] > 0) {
297 if (
$data[
"rows"] > 0) {
300 if (
$data[
"columns"] > 0) {
323 if ($a_textwidth < 1) {
324 $this->textwidth = 50;
326 $this->textwidth = $a_textwidth;
332 if ($a_textheight < 1) {
333 $this->textheight = 5;
335 $this->textheight = $a_textheight;
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
setQuestiontext(string $questiontext="")
loadFromDb(int $question_id)
__construct(string $title="", string $description="", string $author="", string $questiontext="", int $owner=-1)
setTextHeight(?int $a_textheight=null)
setObligatory(bool $obligatory=true)
setOriginalId(?int $original_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setComplete(bool $a_complete)
importResponses(array $a_data)
static subStr(string $a_str, int $a_start, ?int $a_length=null)
toXML(bool $a_include_header=true, bool $obligatory_state=false)
stripSlashesAddSpaceFallback(string $a_str)
Strip slashes with add space fallback, see https://mantis.ilias.de/view.php?id=19727 and https://mant...
xmlEndTag(string $tag)
Writes an endtag.
static strLen(string $a_string)
getQuestionDataArray(int $id)
setAuthor(string $author="")
addMaterialTag(ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true, ?array $a_attrs=null)
Creates an XML material tag from a plain text or xhtml text.
checkUserInput(array $post_data, int $survey_id)
Checks the input of the active user for obligatory status and entered values.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setMaxChars(int $maxchars=0)
insertXML(ilXmlWriter $a_xml_writer, $a_include_header=true)
setTitle(string $title="")
setTextWidth(?int $a_textwidth=null)
saveUserInput(array $post_data, int $active_id, bool $a_return=false)
saveToDb(int $original_id=0)
getWorkingDataFromUserInput(array $post_data)
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
setDescription(string $description="")
setObjId(int $obj_id=0)
Set the reference(?) id of the container object.