ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SurveyMetricQuestion Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for SurveyMetricQuestion:
+ Collaboration diagram for SurveyMetricQuestion:

Public Member Functions

 __construct (string $title="", string $description="", string $author="", string $questiontext="", int $owner=-1, int $subtype=self::SUBTYPE_NON_RATIO)
 
 setSubtype (int $a_subtype=self::SUBTYPE_NON_RATIO)
 
 setMinimum (?float $minimum=null)
 
 setMaximum (?float $maximum=null)
 
 getSubtype ()
 
 getMinimum ()
 
 getMaximum ()
 
 getQuestionDataArray (int $id)
 Returns the question data. More...
 
 loadFromDb (int $question_id)
 load question data into object note: this base implementation only loads the material data More...
 
 isComplete ()
 
 saveToDb (int $original_id=0)
 Saves a SurveyQuestion object to a database. More...
 
 toXML (bool $a_include_header=true)
 
 insertXML (ilXmlWriter $a_xml_writer, bool $a_include_header=true)
 
 getQuestionTypeID ()
 
 getQuestionType ()
 
 getAdditionalTableName ()
 
 getWorkingDataFromUserInput (array $post_data)
 Creates the user data of the svy_answer table from the POST data. More...
 
 checkUserInput (array $post_data, int $survey_id)
 
 saveUserInput (array $post_data, int $active_id, bool $a_return=false)
 
 importResponses (array $a_data)
 Import response data 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...
 
 outPreconditionSelectValue (ilTemplate $template)
 
 getPreconditionSelectValue (string $default, string $title, string $variable)
 Creates a form property for the precondition value. More...
 
 getMinMaxText ()
 Creates a text for the input range of the metric question. More...
 
- Public Member Functions inherited from SurveyQuestion
 __construct (string $title="", string $description="", string $author="", string $questiontext="", int $owner=-1)
 
 setComplete (bool $a_complete)
 
 isComplete ()
 
 questionTitleExists (string $title, int $questionpool_object=0)
 
 setTitle (string $title="")
 
 setObligatory (bool $obligatory=true)
 
 setOrientation (int $orientation=0)
 
 setId (int $id=-1)
 
 setSurveyId (int $id=-1)
 
 setDescription (string $description="")
 
 addMaterials (string $materials_file, string $materials_name="")
 
 setMaterialsfile (string $materials_filename, string $materials_tempfilename="", string $materials_name="")
 Uploads and adds a material. More...
 
 deleteMaterial (string $materials_name="")
 
 flushMaterials ()
 Deletes all materials uris. More...
 
 setAuthor (string $author="")
 
 setQuestiontext (string $questiontext="")
 
 setOwner (int $owner=0)
 
 getTitle ()
 
 getLabel ()
 
 getId ()
 
 getObligatory ()
 
 getSurveyId ()
 
 getOrientation ()
 
 getDescription ()
 
 getAuthor ()
 
 getOwner ()
 
 getQuestiontext ()
 
 getObjId ()
 Get the reference(?) id of the container object. More...
 
 setObjId (int $obj_id=0)
 Set the reference(?) id of the container object. More...
 
 duplicate (bool $for_survey=true, string $title="", string $author="", int $owner=0, int $a_survey_id=0)
 
 copyObject (int $target_questionpool, string $title="")
 
 copyXHTMLMediaObjectsOfQuestion (int $a_q_id)
 Copy media object usages from other question. More...
 
 loadFromDb (int $question_id)
 load question data into object note: this base implementation only loads the material data More...
 
 saveCompletionStatus (int $original_id=0)
 Saves the complete flag to the database. More...
 
 saveToDb (int $original_id=0)
 Saves a SurveyQuestion object to a database. 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...
 
 getImagePath ()
 Returns the image path for web accessible images of a question. More...
 
 getMaterialsPath ()
 Returns the materials path for web accessible materials of a question. More...
 
 getImagePathWeb ()
 Returns the web image path for web accessible images of a question. More...
 
 getMaterialsPathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 saveCategoryToDb (string $categorytext, int $neutral=0)
 Saves a category to the database. More...
 
 deleteAdditionalTableData (int $question_id)
 Deletes datasets from the additional question table in the database. More...
 
 delete (int $question_id)
 Deletes a question and all materials from the database. More...
 
 syncWithOriginal ()
 
 getQuestionTypeID ()
 
 getQuestionType ()
 
 isHTML (string $a_text)
 
 QTIMaterialToString (ilQTIMaterial $a_material)
 Reads an QTI material tag an creates a text string. More...
 
 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. More...
 
 prepareTextareaOutput (string $txt_output, bool $prepare_for_latex_output=false)
 Prepares string for a text area output in surveys. More...
 
 getQuestionDataArray (int $id)
 Returns the question data. More...
 
 getWorkingDataFromUserInput (array $post_data)
 Creates the user data of the svy_answer table from the POST data. More...
 
 importAdditionalMetadata (array $a_meta)
 Import additional meta data from the question import file. More...
 
 importResponses (array $a_data)
 Import response data from the question import file. More...
 
 importAdjectives (array $a_data)
 Import bipolar adjectives from the question import file. More...
 
 importMatrix (array $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 (string $value)
 Returns the output for a precondition value. More...
 
 getPreconditionSelectValue (string $default, string $title, string $variable)
 Creates a form property for the precondition value. More...
 
 setOriginalId (?int $original_id)
 
 getOriginalId ()
 
 getMaterial ()
 
 setSubtype (int $a_subtype)
 
 getSubtype ()
 
 __get (string $value)
 
 __set (string $key, string $value)
 
 getCopyIds (bool $a_group_by_survey=false)
 
 hasCopies ()
 
 stripSlashesAddSpaceFallback (string $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

const SUBTYPE_NON_RATIO = 3
 
const SUBTYPE_RATIO_NON_ABSOLUTE = 4
 
const SUBTYPE_RATIO_ABSOLUTE = 5
 
int $subtype
 
float $minimum
 
float $maximum
 
- Data Fields inherited from SurveyQuestion
int $id
 
string $title
 
string $description
 
int $owner
 
string $author
 
array $materials
 
int $survey_id
 
int $obj_id
 
string $questiontext
 
bool $obligatory
 
ilLanguage $lng
 
int $orientation
 
array $material
 
bool $complete
 

Additional Inherited Members

- Static Public Member Functions inherited from SurveyQuestion
static _isComplete (int $question_id)
 Checks whether the question is complete or not. More...
 
static _getQuestionType (int $question_id)
 Returns the question type of a question with a given id. More...
 
static _getTitle (int $question_id)
 Returns the question title of a question with a given id. More...
 
static _getOriginalId (int $question_id, bool $a_return_question_id_if_no_original=true)
 Returns the original id of a question. More...
 
static _questionExists (int $question_id)
 
static _resolveInternalLink (string $internal_link)
 
static _resolveIntLinks (int $question_id)
 
static _getInternalLinkHref (string $target="", ?int $a_parent_ref_id=null)
 
static _isWriteable (int $question_id, int $user_id)
 is question writeable by a certain user More...
 
static _includeClass (string $question_type, int $gui=0)
 Include the php class file for a given question type. More...
 
static _getQuestionTypeName (string $type_tag)
 Return the translation for a given question type. More...
 
static _instanciateQuestion (int $question_id)
 Get question object. More...
 
static _instanciateQuestionGUI (int $question_id)
 Get question gui object. More...
 
static _instanciateQuestionEvaluation (int $question_id, ?array $a_finished_ids=null)
 
static _changeOriginalId (int $a_question_id, int $a_original_id, int $a_object_id)
 Change original id of existing question in db. More...
 
static _lookupSurveyObjId (int $a_question_id)
 
static lookupObjFi (int $a_qid)
 
static getMaxSumScore (int $survey_id)
 Get max sum score for specific survey (and this question type) More...
 
- Protected Attributes inherited from SurveyQuestion
int $original_id
 
ILIAS SurveyQuestionPool Editing EditSessionRepository $edit_manager
 
ilObjUser $user
 
ilDBInterface $db
 
array $cumulated
 
ilLogger $log
 
ILIAS SurveyQuestionPool Export ImportSessionRepository $import_manager
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Metric survey question The SurveyMetricQuestion class defines and encapsulates basic methods and attributes for metric 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

Definition at line 25 of file class.SurveyMetricQuestion.php.

Constructor & Destructor Documentation

◆ __construct()

SurveyMetricQuestion::__construct ( string  $title = "",
string  $description = "",
string  $author = "",
string  $questiontext = "",
int  $owner = -1,
int  $subtype = self::SUBTYPE_NON_RATIO 
)

Definition at line 36 of file class.SurveyMetricQuestion.php.

43 {
44 global $DIC;
45
46 $this->db = $DIC->database();
48
49 $this->subtype = $subtype;
50 $this->minimum = null;
51 $this->maximum = null;
52 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References SurveyQuestion\$author, SurveyQuestion\$description, $DIC, SurveyQuestion\$owner, SurveyQuestion\$questiontext, $subtype, SurveyQuestion\$title, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ checkUserInput()

SurveyMetricQuestion::checkUserInput ( array  $post_data,
int  $survey_id 
)
Returns
string Empty string if the input is ok, an error message otherwise

Definition at line 315 of file class.SurveyMetricQuestion.php.

318 : string {
319 $entered_value = $post_data[$this->getId() . "_metric_question"];
320 // replace german notation with international notation
321 $entered_value = str_replace(",", ".", $entered_value);
322
323 if ((!$this->getObligatory()) && (strlen($entered_value ?? "") == 0)) {
324 return "";
325 }
326
327 if (strlen($entered_value ?? "") == 0) {
328 return $this->lng->txt("survey_question_obligatory");
329 }
330
331 if (!is_numeric(trim($entered_value))) {
332 return $this->lng->txt("metric_question_not_a_value");
333 }
334
335 if (strlen($this->getMinimum() ?? "")) {
336 if ($entered_value < $this->getMinimum()) {
337 return $this->lng->txt("metric_question_out_of_bounds");
338 }
339 }
340
341 if (strlen($this->getMaximum() ?? "")) {
342 if (($this->getMaximum() == 1) && ($this->getMaximum() < $this->getMinimum())) {
343 // old &infty; values as maximum
344 } elseif ($entered_value > $this->getMaximum()) {
345 return $this->lng->txt("metric_question_out_of_bounds");
346 }
347 }
348
349 if (!is_numeric($entered_value)) {
350 return $this->lng->txt("metric_question_not_a_value");
351 }
352
353 if ($this->getSubtype() === self::SUBTYPE_RATIO_ABSOLUTE && ((int) $entered_value != (float) $entered_value)) {
354 return $this->lng->txt("metric_question_floating_point");
355 }
356 return "";
357 }

◆ getAdditionalTableName()

SurveyMetricQuestion::getAdditionalTableName ( )

Definition at line 297 of file class.SurveyMetricQuestion.php.

297 : string
298 {
299 return "svy_qst_metric";
300 }

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

+ Here is the caller graph for this function:

◆ getAvailableRelations()

SurveyMetricQuestion::getAvailableRelations ( )

Returns the available relations for the question.

Reimplemented from SurveyQuestion.

Definition at line 407 of file class.SurveyMetricQuestion.php.

407 : array
408 {
409 return array("<", "<=", "=", "<>", ">=", ">");
410 }

◆ getMaximum()

SurveyMetricQuestion::getMaximum ( )

Definition at line 82 of file class.SurveyMetricQuestion.php.

82 : ?float
83 {
84 return $this->maximum;
85 }

References $maximum.

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ getMinimum()

SurveyMetricQuestion::getMinimum ( )

Definition at line 74 of file class.SurveyMetricQuestion.php.

74 : ?float
75 {
76 if (is_null($this->minimum) && $this->getSubtype() > 3) {
77 $this->minimum = 0;
78 }
79 return $this->minimum;
80 }

References $minimum, and getSubtype().

Referenced by saveToDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMinMaxText()

SurveyMetricQuestion::getMinMaxText ( )

Creates a text for the input range of the metric question.

Definition at line 438 of file class.SurveyMetricQuestion.php.

438 : string
439 {
440 $min = (string) $this->getMinimum();
441 $max = (string) $this->getMaximum();
442 if ($min !== '' && $max !== '') {
443 return "(" . $min . " " . strtolower($this->lng->txt("to")) . " " . $max . ")";
444 } elseif ($min !== '') {
445 return "(&gt;= " . $min . ")";
446 } elseif ($max !== '') {
447 return "(&lt;= " . $max . ")";
448 } else {
449 return "";
450 }
451 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getPreconditionSelectValue()

SurveyMetricQuestion::getPreconditionSelectValue ( string  $default,
string  $title,
string  $variable 
)

Creates a form property for the precondition value.

Returns
ilFormPropertyGUI|null ILIAS form element @access public

Reimplemented from SurveyQuestion.

Definition at line 425 of file class.SurveyMetricQuestion.php.

430 $step3 = new ilNumberInputGUI($title, $variable);
431 $step3->setValue($default);
432 return $step3;
433 }
This class represents a property in a property form.
This class represents a number property in a property form.

◆ getQuestionDataArray()

SurveyMetricQuestion::getQuestionDataArray ( int  $id)

Returns the question data.

Reimplemented from SurveyQuestion.

Definition at line 87 of file class.SurveyMetricQuestion.php.

87 : array
88 {
90
91 $result = $ilDB->queryF(
92 "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",
93 array('integer'),
94 array($id)
95 );
96 if ($result->numRows() === 1) {
97 return $ilDB->fetchAssoc($result);
98 } else {
99 return array();
100 }
101 }

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

+ Here is the call graph for this function:

◆ getQuestionType()

SurveyMetricQuestion::getQuestionType ( )

Reimplemented from SurveyQuestion.

Definition at line 292 of file class.SurveyMetricQuestion.php.

292 : string
293 {
294 return "SurveyMetricQuestion";
295 }

◆ getQuestionTypeID()

SurveyMetricQuestion::getQuestionTypeID ( )

Reimplemented from SurveyQuestion.

Definition at line 280 of file class.SurveyMetricQuestion.php.

280 : int
281 {
283 $result = $ilDB->queryF(
284 "SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
285 array('text'),
286 array($this->getQuestionType())
287 );
288 $row = $ilDB->fetchAssoc($result);
289 return (int) $row["questiontype_id"];
290 }

References $ilDB.

◆ getSubtype()

SurveyMetricQuestion::getSubtype ( )

Reimplemented from SurveyQuestion.

Definition at line 69 of file class.SurveyMetricQuestion.php.

69 : ?int
70 {
71 return $this->subtype;
72 }

References $subtype.

Referenced by getMinimum(), and saveToDb().

+ Here is the caller graph for this function:

◆ getWorkingDataFromUserInput()

SurveyMetricQuestion::getWorkingDataFromUserInput ( array  $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

Reimplemented from SurveyQuestion.

Definition at line 302 of file class.SurveyMetricQuestion.php.

302 : array
303 {
304 $entered_value = $post_data[$this->getId() . "_metric_question"] ?? "";
305 $data = array();
306 if (strlen($entered_value ?? "")) {
307 $data[] = array("value" => $entered_value);
308 }
309 return $data;
310 }

References $data, and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ importResponses()

SurveyMetricQuestion::importResponses ( array  $a_data)

Import response data from the question import file.

Reimplemented from SurveyQuestion.

Definition at line 394 of file class.SurveyMetricQuestion.php.

394 : void
395 {
396 foreach ($a_data as $id => $data) {
397 $this->setMinimum($data["min"]);
398 $this->setMaximum($data["max"]);
399 }
400 }
setMaximum(?float $maximum=null)
setMinimum(?float $minimum=null)

References $data, and $id.

◆ insertXML()

SurveyMetricQuestion::insertXML ( ilXmlWriter  $a_xml_writer,
bool  $a_include_header = true 
)

Definition at line 208 of file class.SurveyMetricQuestion.php.

211 : void {
212 $attrs = array(
213 "id" => $this->getId(),
214 "title" => $this->getTitle(),
215 "type" => $this->getQuestionType(),
216 "subtype" => $this->getSubtype(),
217 "obligatory" => $this->getObligatory()
218 );
219 $a_xml_writer->xmlStartTag("question", $attrs);
220
221 $a_xml_writer->xmlElement("description", null, $this->getDescription());
222 $a_xml_writer->xmlElement("author", null, $this->getAuthor());
223 $a_xml_writer->xmlStartTag("questiontext");
224 $this->addMaterialTag($a_xml_writer, $this->getQuestiontext());
225 $a_xml_writer->xmlEndTag("questiontext");
226
227 $a_xml_writer->xmlStartTag("responses");
228 switch ($this->getSubtype()) {
229 case 4:
230 case 3:
231 $attrs = array(
232 "id" => "0",
233 "format" => "double"
234 );
235 if ((string) $this->getMinimum() !== '') {
236 $attrs["min"] = $this->getMinimum();
237 }
238 if ((string) $this->getMaximum() !== '') {
239 $attrs["max"] = $this->getMaximum();
240 }
241 break;
242 case 5:
243 $attrs = array(
244 "id" => "0",
245 "format" => "integer"
246 );
247 if ((string) $this->getMinimum() !== '') {
248 $attrs["min"] = $this->getMinimum();
249 }
250 if ((string) $this->getMaximum() !== '') {
251 $attrs["max"] = $this->getMaximum();
252 }
253 break;
254 }
255 $a_xml_writer->xmlStartTag("response_num", $attrs);
256 $a_xml_writer->xmlEndTag("response_num");
257
258 $a_xml_writer->xmlEndTag("responses");
259
260 if (count($this->material) && preg_match(
261 "/il_(\d*?)_(\w+)_(\d+)/",
262 $this->material["internal_link"],
263 $matches
264 )) {
265 $attrs = array(
266 "label" => $this->material["title"]
267 );
268 $a_xml_writer->xmlStartTag("material", $attrs);
269 $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
270 if (strcmp($matches[1], "") !== 0) {
271 $intlink = $this->material["internal_link"];
272 }
273 $a_xml_writer->xmlElement("mattext", null, $intlink);
274 $a_xml_writer->xmlEndTag("material");
275 }
276
277 $a_xml_writer->xmlEndTag("question");
278 }
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.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
const IL_INST_ID
Definition: constants.php:40

◆ isComplete()

SurveyMetricQuestion::isComplete ( )

Reimplemented from SurveyQuestion.

Definition at line 146 of file class.SurveyMetricQuestion.php.

146 : bool
147 {
148 return (
149 $this->getTitle() !== '' &&
150 $this->getAuthor() !== '' &&
151 $this->getQuestiontext() !== ''
152 );
153 }

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

+ Here is the call graph for this function:

◆ loadFromDb()

SurveyMetricQuestion::loadFromDb ( int  $question_id)

load question data into object note: this base implementation only loads the material data

Reimplemented from SurveyQuestion.

Definition at line 103 of file class.SurveyMetricQuestion.php.

103 : void
104 {
106
107 $result = $ilDB->queryF(
108 "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",
109 array('integer'),
110 array($question_id)
111 );
112 if ($result->numRows() === 1) {
113 $data = $ilDB->fetchAssoc($result);
114 $this->setId((int) $data["question_id"]);
115 $this->setTitle((string) $data["title"]);
116 $this->setDescription((string) $data["description"]);
117 $this->setObjId((int) $data["obj_fi"]);
118 $this->setAuthor((string) $data["author"]);
119 $this->setOwner((int) $data["owner_fi"]);
120 $this->label = (string) $data['label'];
121 $this->setQuestiontext(ilRTE::_replaceMediaObjectImageSrc((string) $data["questiontext"], 1));
122 $this->setObligatory((bool) $data["obligatory"]);
123 $this->setComplete((bool) $data["complete"]);
124 $this->setOriginalId((int) $data["original_id"]);
125 $this->setSubtype((int) $data["subtype"]);
126
127 $result = $ilDB->queryF(
128 "SELECT svy_variable.* FROM svy_variable WHERE svy_variable.question_fi = %s",
129 array('integer'),
130 array($question_id)
131 );
132 if ($result->numRows() > 0) {
133 if ($data = $ilDB->fetchAssoc($result)) {
134 $this->minimum = is_null($data["value1"]) ? null : (float) $data["value1"];
135 if (($data["value2"] < 0) or (strcmp((string) $data["value2"], "") == 0)) {
136 $this->maximum = null;
137 } else {
138 $this->maximum = is_null($data["value2"] ?? null) ? null : (float) $data["value2"];
139 }
140 }
141 }
142 }
143 parent::loadFromDb($question_id);
144 }
setSubtype(int $a_subtype=self::SUBTYPE_NON_RATIO)
setTitle(string $title="")
setQuestiontext(string $questiontext="")
setDescription(string $description="")
setObjId(int $obj_id=0)
Set the reference(?) id of the container object.
setOwner(int $owner=0)
setComplete(bool $a_complete)
setOriginalId(?int $original_id)
setObligatory(bool $obligatory=true)
setAuthor(string $author="")
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...

References $data, SurveyQuestion\$db, $ilDB, ilRTE\_replaceMediaObjectImageSrc(), getAdditionalTableName(), SurveyQuestion\setAuthor(), SurveyQuestion\setComplete(), SurveyQuestion\setDescription(), SurveyQuestion\setId(), SurveyQuestion\setObjId(), SurveyQuestion\setObligatory(), SurveyQuestion\setOriginalId(), SurveyQuestion\setOwner(), SurveyQuestion\setQuestiontext(), setSubtype(), and SurveyQuestion\setTitle().

+ Here is the call graph for this function:

◆ outPreconditionSelectValue()

SurveyMetricQuestion::outPreconditionSelectValue ( ilTemplate  $template)

Definition at line 412 of file class.SurveyMetricQuestion.php.

414 : void {
415 $template->setCurrentBlock("textfield");
416 $template->setVariable("TEXTFIELD_VALUE", "");
417 $template->parseCurrentBlock();
418 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)

◆ saveToDb()

SurveyMetricQuestion::saveToDb ( int  $original_id = 0)

Saves a SurveyQuestion object to a database.

Reimplemented from SurveyQuestion.

Definition at line 155 of file class.SurveyMetricQuestion.php.

155 : int
156 {
158
159 $affectedRows = parent::saveToDb($original_id);
160 if ($affectedRows === 1) {
161 $ilDB->manipulateF(
162 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
163 array('integer'),
164 array($this->getId())
165 );
166 $ilDB->manipulateF(
167 "INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, subtype) VALUES (%s, %s)",
168 array('integer', 'text'),
169 array($this->getId(), $this->getSubtype())
170 );
171
172 // save categories
173 $ilDB->manipulateF(
174 "DELETE FROM svy_variable WHERE question_fi = %s",
175 array('integer'),
176 array($this->getId())
177 );
178
179 if (preg_match("/[\D]/", $this->maximum) or (strcmp($this->maximum, "&infin;") == 0)) {
180 $max = -1;
181 } else {
182 $max = $this->getMaximum();
183 }
184 $next_id = $ilDB->nextId('svy_variable');
185 $ilDB->manipulateF(
186 "INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, value2, sequence, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
187 array('integer','integer','integer','float','float','integer','integer'),
188 array($next_id, 0, $this->getId(), $this->getMinimum(), $max, 0, time())
189 );
190 }
191 return $affectedRows;
192 }

References SurveyQuestion\$db, $ilDB, SurveyQuestion\$original_id, getAdditionalTableName(), SurveyQuestion\getId(), getMaximum(), getMinimum(), and getSubtype().

+ Here is the call graph for this function:

◆ saveUserInput()

SurveyMetricQuestion::saveUserInput ( array  $post_data,
int  $active_id,
bool  $a_return = false 
)

Definition at line 359 of file class.SurveyMetricQuestion.php.

363 : ?array {
365
366 $entered_value = $post_data[$this->getId() . "_metric_question"];
367
368 // replace german notation with international notation
369 $entered_value = str_replace(",", ".", $entered_value);
370
371 if ($a_return) {
372 return array(array("value" => $entered_value, "textanswer" => null));
373 }
374
375 if ($entered_value === '') {
376 return null;
377 }
378
379 $next_id = $ilDB->nextId('svy_answer');
380 #20216
381 $fields = array();
382 $fields['answer_id'] = array("integer", $next_id);
383 $fields['question_fi'] = array("integer", $this->getId());
384 $fields['active_fi'] = array("integer", $active_id);
385 $fields['value'] = array("float", $entered_value);
386 $fields['textanswer'] = array("clob", null);
387 $fields['tstamp'] = array("integer", time());
388
389 $ilDB->insert("svy_answer", $fields);
390
391 return null;
392 }

◆ setMaximum()

SurveyMetricQuestion::setMaximum ( ?float  $maximum = null)

Definition at line 64 of file class.SurveyMetricQuestion.php.

64 : void
65 {
66 $this->maximum = $maximum;
67 }

References $maximum.

◆ setMinimum()

SurveyMetricQuestion::setMinimum ( ?float  $minimum = null)

Definition at line 59 of file class.SurveyMetricQuestion.php.

59 : void
60 {
61 $this->minimum = $minimum;
62 }

References $minimum.

◆ setSubtype()

SurveyMetricQuestion::setSubtype ( int  $a_subtype = self::SUBTYPE_NON_RATIO)

Reimplemented from SurveyQuestion.

Definition at line 54 of file class.SurveyMetricQuestion.php.

54 : void
55 {
56 $this->subtype = $a_subtype;
57 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ toXML()

SurveyMetricQuestion::toXML ( bool  $a_include_header = true)

Definition at line 194 of file class.SurveyMetricQuestion.php.

196 : string {
197 $a_xml_writer = new ilXmlWriter();
198 $a_xml_writer->xmlHeader();
199 $this->insertXML($a_xml_writer, $a_include_header);
200 $xml = $a_xml_writer->xmlDumpMem(false);
201 if (!$a_include_header) {
202 $pos = strpos($xml, "?>");
203 $xml = substr($xml, $pos + 2);
204 }
205 return $xml;
206 }
insertXML(ilXmlWriter $a_xml_writer, bool $a_include_header=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ usableForPrecondition()

SurveyMetricQuestion::usableForPrecondition ( )

Returns if the question is usable for preconditions.

Reimplemented from SurveyQuestion.

Definition at line 402 of file class.SurveyMetricQuestion.php.

402 : bool
403 {
404 return true;
405 }

Field Documentation

◆ $maximum

float SurveyMetricQuestion::$maximum

Definition at line 34 of file class.SurveyMetricQuestion.php.

Referenced by getMaximum(), and setMaximum().

◆ $minimum

float SurveyMetricQuestion::$minimum

Definition at line 33 of file class.SurveyMetricQuestion.php.

Referenced by getMinimum(), and setMinimum().

◆ $subtype

int SurveyMetricQuestion::$subtype

Definition at line 31 of file class.SurveyMetricQuestion.php.

Referenced by __construct(), and getSubtype().

◆ SUBTYPE_NON_RATIO

const SurveyMetricQuestion::SUBTYPE_NON_RATIO = 3

◆ SUBTYPE_RATIO_ABSOLUTE

const SurveyMetricQuestion::SUBTYPE_RATIO_ABSOLUTE = 5

◆ SUBTYPE_RATIO_NON_ABSOLUTE

const SurveyMetricQuestion::SUBTYPE_RATIO_NON_ABSOLUTE = 4

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