ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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, mixed $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 27 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 38 of file class.SurveyMetricQuestion.php.

45 {
46 global $DIC;
47
48 $this->db = $DIC->database();
50
51 $this->subtype = $subtype;
52 $this->minimum = null;
53 $this->maximum = null;
54 }
__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 313 of file class.SurveyMetricQuestion.php.

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

◆ getAdditionalTableName()

SurveyMetricQuestion::getAdditionalTableName ( )

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

295 : string
296 {
297 return "svy_qst_metric";
298 }

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 411 of file class.SurveyMetricQuestion.php.

411 : array
412 {
413 return array("<", "<=", "=", "<>", ">=", ">");
414 }

◆ getMaximum()

SurveyMetricQuestion::getMaximum ( )

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

84 : ?float
85 {
86 return $this->maximum;
87 }

References $maximum.

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ getMinimum()

SurveyMetricQuestion::getMinimum ( )

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

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

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 442 of file class.SurveyMetricQuestion.php.

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

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 429 of file class.SurveyMetricQuestion.php.

434 $step3 = new ilNumberInputGUI($title, $variable);
435 $step3->setValue($default);
436 return $step3;
437 }
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 89 of file class.SurveyMetricQuestion.php.

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

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 290 of file class.SurveyMetricQuestion.php.

290 : string
291 {
292 return "SurveyMetricQuestion";
293 }

◆ getQuestionTypeID()

SurveyMetricQuestion::getQuestionTypeID ( )

Reimplemented from SurveyQuestion.

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

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

References $ilDB.

◆ getSubtype()

SurveyMetricQuestion::getSubtype ( )

Reimplemented from SurveyQuestion.

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

71 : ?int
72 {
73 return $this->subtype;
74 }

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 300 of file class.SurveyMetricQuestion.php.

300 : array
301 {
302 $entered_value = (string) ($post_data[$this->getId() . "_metric_question"] ?? "");
303 $data = array();
304 if (strlen($entered_value ?? "")) {
305 $data[] = array("value" => $entered_value);
306 }
307 return $data;
308 }
$data
Definition: storeScorm.php:45

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 392 of file class.SurveyMetricQuestion.php.

392 : void
393 {
394 foreach ($a_data as $id => $data) {
395 $minimum = $data["min"] ?? null;
396 $maximum = $data["max"] ?? null;
397 $this->setMinimum(
398 $minimum === null || $minimum === '' ? null : (float) str_replace(',', '.', (string) $minimum)
399 );
400 $this->setMaximum(
401 $maximum === null || $maximum === '' ? null : (float) str_replace(',', '.', (string) $maximum)
402 );
403 }
404 }
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 206 of file class.SurveyMetricQuestion.php.

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

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

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 105 of file class.SurveyMetricQuestion.php.

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

418 : void {
419 $template->setCurrentBlock("textfield");
420 $template->setVariable("TEXTFIELD_VALUE", "");
421 $template->parseCurrentBlock();
422 }
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 157 of file class.SurveyMetricQuestion.php.

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

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 357 of file class.SurveyMetricQuestion.php.

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

◆ setMaximum()

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

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

66 : void
67 {
68 $this->maximum = $maximum;
69 }

References $maximum.

◆ setMinimum()

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

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

61 : void
62 {
63 $this->minimum = $minimum;
64 }

References $minimum.

◆ setSubtype()

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

Reimplemented from SurveyQuestion.

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

56 : void
57 {
58 $this->subtype = $a_subtype;
59 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ toXML()

SurveyMetricQuestion::toXML ( bool  $a_include_header = true)

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

194 : string {
195 $a_xml_writer = new ilXmlWriter();
196 $a_xml_writer->xmlHeader();
197 $this->insertXML($a_xml_writer, $a_include_header);
198 $xml = $a_xml_writer->xmlDumpMem(false);
199 if (!$a_include_header) {
200 $pos = strpos($xml, "?>");
201 $xml = substr($xml, $pos + 2);
202 }
203 return $xml;
204 }
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 406 of file class.SurveyMetricQuestion.php.

406 : bool
407 {
408 return true;
409 }

Field Documentation

◆ $maximum

float SurveyMetricQuestion::$maximum

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

Referenced by getMaximum(), and setMaximum().

◆ $minimum

float SurveyMetricQuestion::$minimum

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

Referenced by getMinimum(), and setMinimum().

◆ $subtype

int SurveyMetricQuestion::$subtype

Definition at line 33 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: