ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 
 loadFromDb (int $question_id)
 
 isComplete ()
 
 saveToDb (int $original_id=0)
 
 toXML (bool $a_include_header=true)
 
 insertXML (ilXmlWriter $a_xml_writer, bool $a_include_header=true)
 
 getQuestionTypeID ()
 
 getQuestionType ()
 
 getAdditionalTableName ()
 
 getWorkingDataFromUserInput (array $post_data)
 
 checkUserInput (array $post_data, int $survey_id)
 
 saveUserInput (array $post_data, int $active_id, bool $a_return=false)
 
 importResponses (array $a_data)
 
 usableForPrecondition ()
 
 getAvailableRelations ()
 
 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...
 
 saveMaterial ()
 
 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 ()
 
 getPhrase (int $phrase_id)
 Returns a phrase title for phrase id. More...
 
 phraseExists (string $title)
 Returns true if the phrase title already exists for the current user(!) More...
 
 deleteMaterials (array $a_array)
 
 duplicateMaterials (int $question_id)
 Duplicates the materials of a question. More...
 
 addMaterial (ilSurveyMaterial $obj_material)
 
 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.

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

43  {
44  global $DIC;
45 
46  $this->db = $DIC->database();
48 
49  $this->subtype = $subtype;
50  $this->minimum = null;
51  $this->maximum = null;
52  }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
+ 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 318 of file class.SurveyMetricQuestion.php.

References SurveyQuestion\getId(), getMaximum(), getMinimum(), SurveyQuestion\getObligatory(), getSubtype(), and ILIAS\Repository\lng().

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

◆ getAdditionalTableName()

SurveyMetricQuestion::getAdditionalTableName ( )

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

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

300  : string
301  {
302  return "svy_qst_metric";
303  }
+ Here is the caller graph for this function:

◆ getAvailableRelations()

SurveyMetricQuestion::getAvailableRelations ( )

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

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

◆ getMaximum()

SurveyMetricQuestion::getMaximum ( )

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

References $maximum.

Referenced by checkUserInput(), getMinMaxText(), insertXML(), and saveToDb().

82  : ?float
83  {
84  return $this->maximum;
85  }
+ Here is the caller graph for this function:

◆ getMinimum()

SurveyMetricQuestion::getMinimum ( )

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

References $minimum, and getSubtype().

Referenced by checkUserInput(), getMinMaxText(), insertXML(), and saveToDb().

74  : ?float
75  {
76  if (is_null($this->minimum) && $this->getSubtype() > 3) {
77  $this->minimum = 0;
78  }
79  return $this->minimum;
80  }
+ 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 437 of file class.SurveyMetricQuestion.php.

References getMaximum(), getMinimum(), and ILIAS\Repository\lng().

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

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

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

◆ getQuestionDataArray()

SurveyMetricQuestion::getQuestionDataArray ( int  $id)

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

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

87  : array
88  {
89  $ilDB = $this->db;
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  }
+ Here is the call graph for this function:

◆ getQuestionType()

SurveyMetricQuestion::getQuestionType ( )

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

Referenced by getQuestionTypeID(), and insertXML().

295  : string
296  {
297  return "SurveyMetricQuestion";
298  }
+ Here is the caller graph for this function:

◆ getQuestionTypeID()

SurveyMetricQuestion::getQuestionTypeID ( )

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

References SurveyQuestion\$db, $ilDB, and getQuestionType().

283  : int
284  {
285  $ilDB = $this->db;
286  $result = $ilDB->queryF(
287  "SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
288  array('text'),
289  array($this->getQuestionType())
290  );
291  $row = $ilDB->fetchAssoc($result);
292  return (int) $row["questiontype_id"];
293  }
+ Here is the call graph for this function:

◆ getSubtype()

SurveyMetricQuestion::getSubtype ( )

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

References $subtype.

Referenced by checkUserInput(), getMinimum(), insertXML(), and saveToDb().

69  : ?int
70  {
71  return $this->subtype;
72  }
+ Here is the caller graph for this function:

◆ getWorkingDataFromUserInput()

SurveyMetricQuestion::getWorkingDataFromUserInput ( array  $post_data)

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

References $data, and SurveyQuestion\getId().

305  : array
306  {
307  $entered_value = $post_data[$this->getId() . "_metric_question"] ?? "";
308  $data = array();
309  if (strlen($entered_value)) {
310  $data[] = array("value" => $entered_value);
311  }
312  return $data;
313  }
+ Here is the call graph for this function:

◆ importResponses()

SurveyMetricQuestion::importResponses ( array  $a_data)

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

References $data, SurveyQuestion\$id, setMaximum(), and setMinimum().

393  : void
394  {
395  foreach ($a_data as $id => $data) {
396  $this->setMinimum($data["min"]);
397  $this->setMaximum($data["max"]);
398  }
399  }
setMaximum(?float $maximum=null)
setMinimum(?float $minimum=null)
+ Here is the call graph for this function:

◆ insertXML()

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

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

References SurveyQuestion\addMaterialTag(), SurveyQuestion\getAuthor(), SurveyQuestion\getDescription(), SurveyQuestion\getId(), getMaximum(), getMinimum(), SurveyQuestion\getObligatory(), SurveyQuestion\getQuestiontext(), getQuestionType(), getSubtype(), SurveyQuestion\getTitle(), IL_INST_ID, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by toXML().

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

◆ isComplete()

SurveyMetricQuestion::isComplete ( )

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

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

146  : bool
147  {
148  return (
149  $this->getTitle() !== '' &&
150  $this->getAuthor() !== '' &&
151  $this->getQuestiontext() !== ''
152  );
153  }
+ Here is the call graph for this function:

◆ loadFromDb()

SurveyMetricQuestion::loadFromDb ( int  $question_id)

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

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().

103  : void
104  {
105  $ilDB = $this->db;
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($data["value2"], "") == 0)) {
136  $this->maximum = null;
137  } else {
138  $this->maximum = is_null($data["value2"]) ? null : (float) $data["value2"];
139  }
140  }
141  }
142  }
143  parent::loadFromDb($question_id);
144  }
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="")
setObligatory(bool $obligatory=true)
setOriginalId(?int $original_id)
setComplete(bool $a_complete)
setAuthor(string $author="")
setTitle(string $title="")
setOwner(int $owner=0)
setSubtype(int $a_subtype=self::SUBTYPE_NON_RATIO)
setDescription(string $description="")
setObjId(int $obj_id=0)
Set the reference(?) id of the container object.
+ Here is the call graph for this function:

◆ outPreconditionSelectValue()

SurveyMetricQuestion::outPreconditionSelectValue ( ilTemplate  $template)

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

References ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

413  : void {
414  $template->setCurrentBlock("textfield");
415  $template->setVariable("TEXTFIELD_VALUE", "");
416  $template->parseCurrentBlock();
417  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:

◆ saveToDb()

SurveyMetricQuestion::saveToDb ( int  $original_id = 0)

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

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

155  : int
156  {
157  $ilDB = $this->db;
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  // saving material uris in the database
173  $this->saveMaterial();
174 
175  // save categories
176  $ilDB->manipulateF(
177  "DELETE FROM svy_variable WHERE question_fi = %s",
178  array('integer'),
179  array($this->getId())
180  );
181 
182  if (preg_match("/[\D]/", $this->maximum) or (strcmp($this->maximum, "&infin;") == 0)) {
183  $max = -1;
184  } else {
185  $max = $this->getMaximum();
186  }
187  $next_id = $ilDB->nextId('svy_variable');
188  $ilDB->manipulateF(
189  "INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, value2, sequence, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
190  array('integer','integer','integer','float','float','integer','integer'),
191  array($next_id, 0, $this->getId(), $this->getMinimum(), $max, 0, time())
192  );
193  }
194  return $affectedRows;
195  }
+ Here is the call graph for this function:

◆ saveUserInput()

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

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

References SurveyQuestion\$db, $ilDB, and SurveyQuestion\getId().

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

◆ setMaximum()

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

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

References $maximum.

Referenced by importResponses().

64  : void
65  {
66  $this->maximum = $maximum;
67  }
+ Here is the caller graph for this function:

◆ setMinimum()

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

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

References $minimum.

Referenced by importResponses().

59  : void
60  {
61  $this->minimum = $minimum;
62  }
+ Here is the caller graph for this function:

◆ setSubtype()

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

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

Referenced by loadFromDb().

54  : void
55  {
56  $this->subtype = $a_subtype;
57  }
+ Here is the caller graph for this function:

◆ toXML()

SurveyMetricQuestion::toXML ( bool  $a_include_header = true)

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

References $xml, and insertXML().

199  : string {
200  $a_xml_writer = new ilXmlWriter();
201  $a_xml_writer->xmlHeader();
202  $this->insertXML($a_xml_writer, $a_include_header);
203  $xml = $a_xml_writer->xmlDumpMem(false);
204  if (!$a_include_header) {
205  $pos = strpos($xml, "?>");
206  $xml = substr($xml, $pos + 2);
207  }
208  return $xml;
209  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$xml
Definition: metadata.php:351
insertXML(ilXmlWriter $a_xml_writer, bool $a_include_header=true)
+ Here is the call graph for this function:

◆ usableForPrecondition()

SurveyMetricQuestion::usableForPrecondition ( )

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

401  : bool
402  {
403  return true;
404  }

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: