ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
SurveyMatrixQuestion 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 SurveyMatrixQuestion:
+ Collaboration diagram for SurveyMatrixQuestion:

Public Member Functions

 __construct (string $title="", string $description="", string $author="", string $questiontext="", int $owner=-1)
 
 getColumnCount ()
 
 removeColumn (int $index)
 
 removeColumns (array $array)
 
 removeColumnWithName (string $name)
 
 getColumns ()
 
 getColumn (int $index)
 
 getColumnForScale (int $scale)
 
 getColumnIndex (string $name)
 
 flushColumns ()
 
 getRowCount ()
 
 addRow (string $a_text, string $a_other, string $a_label)
 
 addRowAtPosition (string $a_text, string $a_other, int $a_position)
 
 flushRows ()
 
 getRow (int $a_index)
 
 moveRowUp (int $index)
 
 moveRowDown (int $index)
 
 removeRows (array $array)
 
 removeRow (int $index)
 
 getBipolarAdjective (int $a_index)
 Returns one of the bipolar adjectives. More...
 
 setBipolarAdjective (int $a_index, string $a_value)
 
 getQuestionDataArray (int $id)
 Returns the question data fields from the database. 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...
 
 saveBipolarAdjectives (string $adjective1, string $adjective2)
 
 saveColumnToDb (string $columntext, int $neutral=0)
 
 saveColumnsToDb (int $original_id=0)
 
 saveRowsToDb (int $original_id=0)
 
 toXML (bool $a_include_header=true, bool $obligatory_state=false)
 Returns an xml representation of the question. More...
 
 insertXML (ilXmlWriter $a_xml_writer, bool $a_include_header=true)
 Adds the question XML to a given XMLWriter object. More...
 
 syncWithOriginal ()
 
 addStandardNumbers (int $lower_limit, int $upper_limit)
 Adds standard numbers as columns. More...
 
 getQuestionType ()
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 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)
 Checks the input of the active user for obligatory status and entered values. More...
 
 saveUserInput (array $post_data, int $active_id, bool $a_return=false)
 
 deleteAdditionalTableData (int $question_id)
 Delete question data from additional table. More...
 
 getSubtype ()
 Returns the subtype of the matrix question. More...
 
 setSubtype (int $a_subtype=0)
 Sets the subtype of the matrix question. More...
 
 setColumnSeparators (bool $enable=false)
 Enables/Disables separators for the matrix columns. More...
 
 getColumnSeparators ()
 
 setRowSeparators (bool $enable=false)
 Enables/Disables separators for the matrix rows. More...
 
 getRowSeparators ()
 
 setNeutralColumnSeparator (bool $enable=true)
 
 getNeutralColumnSeparator ()
 
 importAdditionalMetadata (array $a_meta)
 Import additional meta 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...
 
 importResponses (array $a_data)
 Import response data from the question import file. More...
 
 usableForPrecondition ()
 Returns if the question is usable 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...
 
 saveLayout (float $percent_row, float $percent_columns, float $percent_bipolar_adjective1=0, float $percent_bipolar_adjective2=0, float $percent_neutral=0)
 Saves the layout of a matrix question. More...
 
 getLayout ()
 
 setLayout ($layout)
 
 hasBipolarAdjectives ()
 Returns TRUE if bipolar adjectives exist. More...
 
 hasNeutralColumn ()
 Returns TRUE if a neutral column exists. More...
 
 setColumnPlaceholders (bool $a_value=false)
 Set whether placeholders should be used for the column titles or not. More...
 
 getColumnPlaceholders ()
 
 setLegend (bool $a_value=false)
 Set whether the legend should be shown or not. More...
 
 getLegend ()
 
 setSingleLineRowCaption (bool $a_value=false)
 
 getSingleLineRowCaption ()
 
 setRepeatColumnHeader (bool $a_value=false)
 
 getRepeatColumnHeader ()
 
 getRows ()
 
- 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...
 

Static Public Member Functions

static getMaxSumScore (int $survey_id)
 Get max sum score for specific survey (and this question type) More...
 
- 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...
 

Data Fields

SurveyCategories $columns
 
SurveyCategories $rows
 
string $bipolar_adjective1 = ""
 
string $bipolar_adjective2 = ""
 
bool $columnSeparators = false
 
bool $rowSeparators = false
 
bool $neutralColumnSeparator = false
 
array $layout
 
bool $columnPlaceholders = false
 
bool $legend = false
 
bool $singleLineRowCaption = false
 
bool $repeatColumnHeader = false
 
int $subtype
 Matrix question subtype 0 = Single choice 1 = Multiple choice 2 = Text 3 = Integer 4 = Double 5 = Date 6 = Time. More...
 
- 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

- 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 The SurveyMatrixQuestion class defines and encapsulates basic methods and attributes for matrix 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 26 of file class.SurveyMatrixQuestion.php.

Constructor & Destructor Documentation

◆ __construct()

SurveyMatrixQuestion::__construct ( string  $title = "",
string  $description = "",
string  $author = "",
string  $questiontext = "",
int  $owner = -1 
)

Reimplemented from SurveyQuestion.

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

65 {
66 global $DIC;
67
68 $this->user = $DIC->user();
69 $this->db = $DIC->database();
71
72 $this->subtype = 0;
73 $this->columns = new SurveyCategories();
74 $this->rows = new SurveyCategories();
75 $this->bipolar_adjective1 = "";
76 $this->bipolar_adjective2 = "";
77 $this->rowSeparators = false;
78 $this->columnSeparators = false;
79 $this->neutralColumnSeparator = true;
80 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addRow()

SurveyMatrixQuestion::addRow ( string  $a_text,
string  $a_other,
string  $a_label 
)

Definition at line 135 of file class.SurveyMatrixQuestion.php.

139 : void {
140 $this->rows->addCategory($a_text, (int) $a_other, 0, $a_label);
141 }

◆ addRowAtPosition()

SurveyMatrixQuestion::addRowAtPosition ( string  $a_text,
string  $a_other,
int  $a_position 
)

Definition at line 143 of file class.SurveyMatrixQuestion.php.

147 : void {
148 $this->rows->addCategoryAtPosition($a_text, $a_position, (int) $a_other);
149 }

◆ addStandardNumbers()

SurveyMatrixQuestion::addStandardNumbers ( int  $lower_limit,
int  $upper_limit 
)

Adds standard numbers as columns.

Definition at line 610 of file class.SurveyMatrixQuestion.php.

613 : void {
614 for ($i = $lower_limit; $i <= $upper_limit; $i++) {
615 $this->columns->addCategory((string) $i);
616 }
617 }

◆ checkUserInput()

SurveyMatrixQuestion::checkUserInput ( array  $post_data,
int  $survey_id 
)

Checks the input of the active user for obligatory status and entered values.

Returns
string Empty string if the input is ok, an error message otherwise

Definition at line 669 of file class.SurveyMatrixQuestion.php.

672 : string {
673 if (!$this->getObligatory()) {
674 return "";
675 }
676 switch ($this->getSubtype()) {
677 case 0:
678 $counter = 0;
679 foreach ($post_data as $key => $value) {
680 $key = (string) $key;
681 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
682 if (array_key_exists('matrix_other_' . $this->getId() . "_" . $matches[1], $post_data) && strlen((string) ($post_data['matrix_other_' . $this->getId() . "_" . $matches[1]] ?? "")) === 0) {
683 return $this->lng->txt("question_mr_no_other_answer");
684 }
685 $counter++;
686 }
687 }
688 if ($counter !== $this->getRowCount()) {
689 return $this->lng->txt("matrix_question_radio_button_not_checked");
690 }
691 break;
692 case 1:
693 $counter = 0;
694 foreach ($post_data as $key => $value) {
695 $key = (string) $key;
696 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
697 if (array_key_exists('matrix_other_' . $this->getId() . "_" . $matches[1], $post_data) && strlen((string) ($post_data['matrix_other_' . $this->getId() . "_" . $matches[1]] ?? "")) === 0) {
698 return $this->lng->txt("question_mr_no_other_answer");
699 }
700 $counter++;
701 if ((!is_array($value)) || (count($value) < 1)) {
702 return $this->lng->txt("matrix_question_checkbox_not_checked");
703 }
704 }
705 }
706 if ($counter !== $this->getRowCount()) {
707 return $this->lng->txt("matrix_question_checkbox_not_checked");
708 }
709 break;
710 }
711 return "";
712 }
getSubtype()
Returns the subtype of the matrix question.

◆ deleteAdditionalTableData()

SurveyMatrixQuestion::deleteAdditionalTableData ( int  $question_id)

Delete question data from additional table.

Reimplemented from SurveyQuestion.

Definition at line 787 of file class.SurveyMatrixQuestion.php.

789 : void {
790 parent::deleteAdditionalTableData($question_id);
791
793 $ilDB->manipulateF(
794 "DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
795 array('integer'),
796 array($question_id)
797 );
798 }

◆ flushColumns()

SurveyMatrixQuestion::flushColumns ( )

Definition at line 125 of file class.SurveyMatrixQuestion.php.

125 : void
126 {
127 $this->columns->flushCategories();
128 }

◆ flushRows()

SurveyMatrixQuestion::flushRows ( )

Definition at line 151 of file class.SurveyMatrixQuestion.php.

151 : void
152 {
153 $this->rows = new SurveyCategories();
154 }

◆ getAdditionalTableName()

SurveyMatrixQuestion::getAdditionalTableName ( )

Returns the name of the additional question data table in the database.

Definition at line 628 of file class.SurveyMatrixQuestion.php.

628 : string
629 {
630 return "svy_qst_matrix";
631 }

◆ getBipolarAdjective()

SurveyMatrixQuestion::getBipolarAdjective ( int  $a_index)

Returns one of the bipolar adjectives.

Parameters
int$a_indexbipolar adjective (0 first, and 1 for the second)

Definition at line 188 of file class.SurveyMatrixQuestion.php.

188 : string
189 {
190 if ($a_index === 1) {
192 }
194 }

◆ getColumn()

SurveyMatrixQuestion::getColumn ( int  $index)

Definition at line 110 of file class.SurveyMatrixQuestion.php.

111 {
112 return $this->columns->getCategory($index);
113 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getColumnCount()

SurveyMatrixQuestion::getColumnCount ( )

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

82 : int
83 {
84 return $this->columns->getCategoryCount();
85 }

◆ getColumnForScale()

SurveyMatrixQuestion::getColumnForScale ( int  $scale)

Definition at line 115 of file class.SurveyMatrixQuestion.php.

116 {
117 return $this->columns->getCategoryForScale($scale);
118 }

◆ getColumnIndex()

SurveyMatrixQuestion::getColumnIndex ( string  $name)

Definition at line 120 of file class.SurveyMatrixQuestion.php.

120 : int
121 {
122 return $this->columns->getCategoryIndex($name);
123 }

◆ getColumnPlaceholders()

SurveyMatrixQuestion::getColumnPlaceholders ( )

Definition at line 1082 of file class.SurveyMatrixQuestion.php.

1082 : bool
1083 {
1085 }

◆ getColumns()

SurveyMatrixQuestion::getColumns ( )

Definition at line 105 of file class.SurveyMatrixQuestion.php.

106 {
107 return $this->columns;
108 }

References $columns.

◆ getColumnSeparators()

SurveyMatrixQuestion::getColumnSeparators ( )

Definition at line 837 of file class.SurveyMatrixQuestion.php.

837 : bool
838 {
840 }

◆ getLayout()

SurveyMatrixQuestion::getLayout ( )

Definition at line 1000 of file class.SurveyMatrixQuestion.php.

1000 : array
1001 {
1002 if (count($this->layout) === 0) {
1003 if ($this->hasBipolarAdjectives() && $this->hasNeutralColumn()) {
1004 $this->layout = array(
1005 "percent_row" => 30,
1006 "percent_columns" => 40,
1007 "percent_bipolar_adjective1" => 10,
1008 "percent_bipolar_adjective2" => 10,
1009 "percent_neutral" => 10
1010 );
1011 } elseif ($this->hasBipolarAdjectives()) {
1012 $this->layout = array(
1013 "percent_row" => 30,
1014 "percent_columns" => 50,
1015 "percent_bipolar_adjective1" => 10,
1016 "percent_bipolar_adjective2" => 10,
1017 "percent_neutral" => 0
1018 );
1019 } elseif ($this->hasNeutralColumn()) {
1020 $this->layout = array(
1021 "percent_row" => 30,
1022 "percent_columns" => 50,
1023 "percent_bipolar_adjective1" => 0,
1024 "percent_bipolar_adjective2" => 0,
1025 "percent_neutral" => 20
1026 );
1027 } else {
1028 $this->layout = array(
1029 "percent_row" => 30,
1030 "percent_columns" => 70,
1031 "percent_bipolar_adjective1" => 0,
1032 "percent_bipolar_adjective2" => 0,
1033 "percent_neutral" => 0
1034 );
1035 }
1036 }
1037 return $this->layout;
1038 }
hasNeutralColumn()
Returns TRUE if a neutral column exists.
hasBipolarAdjectives()
Returns TRUE if bipolar adjectives exist.

◆ getLegend()

SurveyMatrixQuestion::getLegend ( )

Definition at line 1095 of file class.SurveyMatrixQuestion.php.

1095 : bool
1096 {
1097 return $this->legend;
1098 }

◆ getMaxSumScore()

static SurveyMatrixQuestion::getMaxSumScore ( int  $survey_id)
static

Get max sum score for specific survey (and this question type)

Reimplemented from SurveyQuestion.

Definition at line 1126 of file class.SurveyMatrixQuestion.php.

1126 : int
1127 {
1128 global $DIC;
1129
1130 // we need max scale values of matrix rows * number of rows (type 5)
1131 $db = $DIC->database();
1132
1133 $set = $db->queryF(
1134 "SELECT MAX(scale) max_sum_score, q.question_id FROM svy_svy_qst sq " .
1135 "JOIN svy_question q ON (sq.question_fi = q.question_id) " .
1136 "JOIN svy_variable v ON (v.question_fi = q.question_id) " .
1137 "WHERE sq.survey_fi = %s AND q.questiontype_fi = %s " .
1138 "GROUP BY (q.question_id)",
1139 ["integer", "integer"],
1140 [$survey_id, 5]
1141 );
1142 $max_score = [];
1143 while ($rec = $db->fetchAssoc($set)) {
1144 $max_score[(int) $rec["question_id"]] = (int) $rec["max_sum_score"];
1145 }
1146
1147 $set = $db->queryF(
1148 "SELECT COUNT(mr.id_svy_qst_matrixrows) cnt_rows, q.question_id FROM svy_svy_qst sq " .
1149 "JOIN svy_question q ON (sq.question_fi = q.question_id) " .
1150 "JOIN svy_qst_matrixrows mr ON (mr.question_fi = q.question_id) " .
1151 "WHERE sq.survey_fi = %s AND q.questiontype_fi = %s " .
1152 "GROUP BY (q.question_id)",
1153 ["integer", "integer"],
1154 [$survey_id, 5]
1155 );
1156 $cnt_rows = [];
1157 while ($rec = $db->fetchAssoc($set)) {
1158 $cnt_rows[(int) $rec["question_id"]] = (int) $rec["cnt_rows"];
1159 }
1160
1161 $sum_sum_score = 0;
1162 foreach ($max_score as $qid => $s) {
1163 $sum_sum_score += $s * $cnt_rows[$qid];
1164 }
1165
1166 return $sum_sum_score;
1167 }
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)

References $DIC, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getNeutralColumnSeparator()

SurveyMatrixQuestion::getNeutralColumnSeparator ( )

Definition at line 860 of file class.SurveyMatrixQuestion.php.

860 : bool
861 {
863 }

◆ getPreconditionSelectValue()

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

Creates a form property for the precondition value.

Reimplemented from SurveyQuestion.

Definition at line 956 of file class.SurveyMatrixQuestion.php.

961 $step3 = new ilSelectInputGUI($title, $variable);
963 $step3->setOptions($options);
964 $step3->setValue($default);
965 return $step3;
966 }
getPreconditionOptions()
Returns the options for preconditions.
This class represents a property in a property form.
This class represents a selection list property in a property form.

◆ getPreconditionValueOutput()

SurveyMatrixQuestion::getPreconditionValueOutput ( string  $value)

Returns the output for a precondition value.

Reimplemented from SurveyQuestion.

Definition at line 948 of file class.SurveyMatrixQuestion.php.

948 : string
949 {
950 return $value;
951 }

◆ getQuestionDataArray()

SurveyMatrixQuestion::getQuestionDataArray ( int  $id)

Returns the question data fields from the database.

Reimplemented from SurveyQuestion.

Definition at line 210 of file class.SurveyMatrixQuestion.php.

210 : array
211 {
213
214 $result = $ilDB->queryF(
215 "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",
216 array('integer'),
217 array($id)
218 );
219 if ($result->numRows() === 1) {
220 return $ilDB->fetchAssoc($result);
221 }
222
223 return array();
224 }
getAdditionalTableName()
Returns the name of the additional question data table in the database.

References $id, and $ilDB.

◆ getQuestionType()

SurveyMatrixQuestion::getQuestionType ( )

Reimplemented from SurveyQuestion.

Definition at line 620 of file class.SurveyMatrixQuestion.php.

620 : string
621 {
622 return "SurveyMatrixQuestion";
623 }

◆ getRepeatColumnHeader()

SurveyMatrixQuestion::getRepeatColumnHeader ( )

Definition at line 1115 of file class.SurveyMatrixQuestion.php.

1115 : bool
1116 {
1118 }

◆ getRow()

SurveyMatrixQuestion::getRow ( int  $a_index)

Definition at line 156 of file class.SurveyMatrixQuestion.php.

157 {
158 return $this->rows->getCategory($a_index);
159 }

◆ getRowCount()

SurveyMatrixQuestion::getRowCount ( )

Definition at line 130 of file class.SurveyMatrixQuestion.php.

130 : int
131 {
132 return $this->rows->getCategoryCount();
133 }

◆ getRows()

SurveyMatrixQuestion::getRows ( )

Definition at line 1121 of file class.SurveyMatrixQuestion.php.

1122 {
1123 return $this->rows;
1124 }

References ILIAS\Scripts\PHPStan\$rows.

◆ getRowSeparators()

SurveyMatrixQuestion::getRowSeparators ( )

Definition at line 850 of file class.SurveyMatrixQuestion.php.

850 : bool
851 {
853 }

◆ getSingleLineRowCaption()

SurveyMatrixQuestion::getSingleLineRowCaption ( )

Definition at line 1105 of file class.SurveyMatrixQuestion.php.

1105 : bool
1106 {
1108 }

◆ getSubtype()

SurveyMatrixQuestion::getSubtype ( )

Returns the subtype of the matrix question.

Reimplemented from SurveyQuestion.

Definition at line 803 of file class.SurveyMatrixQuestion.php.

803 : ?int
804 {
805 return $this->subtype;
806 }
int $subtype
Matrix question subtype 0 = Single choice 1 = Multiple choice 2 = Text 3 = Integer 4 = Double 5 = Dat...

◆ getWorkingDataFromUserInput()

SurveyMatrixQuestion::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 633 of file class.SurveyMatrixQuestion.php.

633 : array
634 {
635 $data = array();
636 foreach ($post_data as $key => $value) {
637 $key = (string) $key;
638 switch ($this->getSubtype()) {
639 case 1:
640 case 0:
641 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
642 if (is_array($value)) {
643 foreach ($value as $val) {
644 $data[] = array("value" => (string) $val,
645 "rowvalue" => (int) $matches[1],
646 "textanswer" => (string) ($post_data['matrix_other_' . $this->getId(
647 ) . '_' . $matches[1]] ?? "")
648 );
649 }
650 } else {
651 $data[] = array("value" => (string) $value,
652 "rowvalue" => (int) $matches[1],
653 "textanswer" => (string) ($post_data['matrix_other_' . $this->getId(
654 ) . '_' . $matches[1]] ?? "")
655 );
656 }
657 }
658 break;
659 }
660 }
661 return $data;
662 }
$data
Definition: storeScorm.php:45

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

+ Here is the call graph for this function:

◆ hasBipolarAdjectives()

SurveyMatrixQuestion::hasBipolarAdjectives ( )

Returns TRUE if bipolar adjectives exist.

Definition at line 1055 of file class.SurveyMatrixQuestion.php.

1055 : bool
1056 {
1057 return $this->getBipolarAdjective(0) !== '' && $this->getBipolarAdjective(1) !== '';
1058 }
getBipolarAdjective(int $a_index)
Returns one of the bipolar adjectives.

◆ hasNeutralColumn()

SurveyMatrixQuestion::hasNeutralColumn ( )

Returns TRUE if a neutral column exists.

Definition at line 1063 of file class.SurveyMatrixQuestion.php.

1063 : bool
1064 {
1065 for ($i = 0; $i < $this->getColumnCount(); $i++) {
1066 $column = $this->getColumn($i);
1067 if ($column->neutral && strlen($column->title ?? "")) {
1068 return true;
1069 }
1070 }
1071 return false;
1072 }

◆ importAdditionalMetadata()

SurveyMatrixQuestion::importAdditionalMetadata ( array  $a_meta)

Import additional meta data from the question import file.

Reimplemented from SurveyQuestion.

Definition at line 868 of file class.SurveyMatrixQuestion.php.

868 : void
869 {
870 foreach ($a_meta as $key => $value) {
871 switch ($value["label"]) {
872 case "column_separators":
873 $this->setColumnSeparators((bool) filter_var($value["entry"], FILTER_VALIDATE_BOOLEAN));
874 break;
875 case "row_separators":
876 $this->setRowSeparators((bool) filter_var($value["entry"], FILTER_VALIDATE_BOOLEAN));
877 break;
878 case "layout":
879 $this->setLayout($value["entry"]);
880 break;
881 case "neutral_column_separator":
882 $this->setNeutralColumnSeparator((bool) filter_var($value["entry"], FILTER_VALIDATE_BOOLEAN));
883 break;
884 }
885 }
886 }
setRowSeparators(bool $enable=false)
Enables/Disables separators for the matrix rows.
setColumnSeparators(bool $enable=false)
Enables/Disables separators for the matrix columns.
setNeutralColumnSeparator(bool $enable=true)

◆ importAdjectives()

SurveyMatrixQuestion::importAdjectives ( array  $a_data)

Import bipolar adjectives from the question import file.

Reimplemented from SurveyQuestion.

Definition at line 891 of file class.SurveyMatrixQuestion.php.

891 : void
892 {
893 $i = 0;
894 foreach ($a_data as $adjective) {
895 if (is_numeric($adjective["label"])) {
896 $this->setBipolarAdjective((int) $adjective["label"], (string) $adjective["text"]);
897 } else {
898 $this->setBipolarAdjective($i, (string) $adjective["text"]);
899 }
900 $i++;
901 }
902 }
setBipolarAdjective(int $a_index, string $a_value)

◆ importMatrix()

SurveyMatrixQuestion::importMatrix ( array  $a_data)

Import matrix rows from the question import file.

Reimplemented from SurveyQuestion.

Definition at line 907 of file class.SurveyMatrixQuestion.php.

909 : void {
910 foreach ($a_data as $row) {
911 $this->addRow(
912 (string) $row['title'],
913 (string) ($row['other'] ?? ''),
914 (string) ($row['label'] ?? '')
915 );
916 }
917 }
addRow(string $a_text, string $a_other, string $a_label)

◆ importResponses()

SurveyMatrixQuestion::importResponses ( array  $a_data)

Import response data from the question import file.

Reimplemented from SurveyQuestion.

Definition at line 922 of file class.SurveyMatrixQuestion.php.

922 : void
923 {
924 foreach ($a_data as $id => $data) {
925 $column = "";
926 foreach ($data["material"] as $material) {
927 $column .= $material["text"];
928 }
929 $this->columns->addCategory(
930 (string) $column,
931 0,
932 strcmp((string) ($data["label"] ?? ''), "neutral") === 0 ? 1 : 0
933 );
934 }
935 }

References $data, and $id.

◆ insertXML()

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

Adds the question XML to a given XMLWriter object.

Definition at line 478 of file class.SurveyMatrixQuestion.php.

481 : void {
482 $attrs = array(
483 "id" => $this->getId(),
484 "title" => $this->getTitle(),
485 "type" => $this->getQuestionType(),
486 "subtype" => $this->getSubtype(),
487 "obligatory" => $this->getObligatory()
488 );
489 $a_xml_writer->xmlStartTag("question", $attrs);
490
491 $a_xml_writer->xmlElement("description", null, $this->getDescription());
492 $a_xml_writer->xmlElement("author", null, $this->getAuthor());
493 $a_xml_writer->xmlStartTag("questiontext");
494 $this->addMaterialTag($a_xml_writer, $this->getQuestiontext());
495 $a_xml_writer->xmlEndTag("questiontext");
496
497 $a_xml_writer->xmlStartTag("matrix");
498 $a_xml_writer->xmlStartTag("matrixrows");
499 for ($i = 0; $i < $this->getRowCount(); $i++) {
500 $attrs = array(
501 "id" => $i
502 );
503 if (strlen($this->getRow($i)->label ?? "")) {
504 $attrs['label'] = $this->getRow($i)->label;
505 }
506 if ($this->getRow($i)->other) {
507 $attrs['other'] = 1;
508 }
509 $a_xml_writer->xmlStartTag("matrixrow", $attrs);
510 $this->addMaterialTag($a_xml_writer, (string) $this->getRow($i)->title);
511 $a_xml_writer->xmlEndTag("matrixrow");
512 }
513 $a_xml_writer->xmlEndTag("matrixrows");
514
515 $a_xml_writer->xmlStartTag("responses");
516 if ($this->getBipolarAdjective(0) !== '' && ($this->getBipolarAdjective(1) !== '')) {
517 $a_xml_writer->xmlStartTag("bipolar_adjectives");
518 $attribs = array(
519 "label" => "0"
520 );
521 $a_xml_writer->xmlElement("adjective", $attribs, $this->getBipolarAdjective(0));
522 $attribs = array(
523 "label" => "1"
524 );
525 $a_xml_writer->xmlElement("adjective", $attribs, $this->getBipolarAdjective(1));
526 $a_xml_writer->xmlEndTag("bipolar_adjectives");
527 }
528 for ($i = 0; $i < $this->getColumnCount(); $i++) {
529 $attrs = array(
530 "id" => $i
531 );
532 if ($this->getColumn($i)->neutral) {
533 $attrs['label'] = 'neutral';
534 }
535 switch ($this->getSubtype()) {
536 case 0:
537 $a_xml_writer->xmlStartTag("response_single", $attrs);
538 break;
539 case 1:
540 $a_xml_writer->xmlStartTag("response_multiple", $attrs);
541 break;
542 }
543 $this->addMaterialTag($a_xml_writer, (string) $this->getColumn($i)->title);
544 switch ($this->getSubtype()) {
545 case 0:
546 $a_xml_writer->xmlEndTag("response_single");
547 break;
548 case 1:
549 $a_xml_writer->xmlEndTag("response_multiple");
550 break;
551 }
552 }
553
554 $a_xml_writer->xmlEndTag("responses");
555 $a_xml_writer->xmlEndTag("matrix");
556
557 if (count($this->material)) {
558 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", (string) $this->material["internal_link"], $matches)) {
559 $attrs = array(
560 "label" => $this->material["title"]
561 );
562 $a_xml_writer->xmlStartTag("material", $attrs);
563 $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
564 if (strcmp($matches[1], "") !== 0) {
565 $intlink = $this->material["internal_link"];
566 }
567 $a_xml_writer->xmlElement("mattext", null, $intlink);
568 $a_xml_writer->xmlEndTag("material");
569 }
570 }
571
572 $a_xml_writer->xmlStartTag("metadata");
573 $a_xml_writer->xmlStartTag("metadatafield");
574 $a_xml_writer->xmlElement("fieldlabel", null, "column_separators");
575 $a_xml_writer->xmlElement("fieldentry", null, (int) $this->getColumnSeparators());
576 $a_xml_writer->xmlEndTag("metadatafield");
577
578 $a_xml_writer->xmlStartTag("metadatafield");
579 $a_xml_writer->xmlElement("fieldlabel", null, "row_separators");
580 $a_xml_writer->xmlElement("fieldentry", null, (int) $this->getRowSeparators());
581 $a_xml_writer->xmlEndTag("metadatafield");
582
583 $a_xml_writer->xmlStartTag("metadatafield");
584 $a_xml_writer->xmlElement("fieldlabel", null, "neutral_column_separator");
585 $a_xml_writer->xmlElement("fieldentry", null, (int) $this->getNeutralColumnSeparator());
586 $a_xml_writer->xmlEndTag("metadatafield");
587
588 $a_xml_writer->xmlStartTag("metadatafield");
589 $a_xml_writer->xmlElement("fieldlabel", null, "layout");
590 $a_xml_writer->xmlElement("fieldentry", null, serialize($this->getLayout()));
591 $a_xml_writer->xmlEndTag("metadatafield");
592
593 $a_xml_writer->xmlEndTag("metadata");
594
595 $a_xml_writer->xmlEndTag("question");
596 }
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()

SurveyMatrixQuestion::isComplete ( )

Reimplemented from SurveyQuestion.

Definition at line 289 of file class.SurveyMatrixQuestion.php.

289 : bool
290 {
291 return (
292 $this->getTitle() !== '' &&
293 $this->getAuthor() !== '' &&
294 $this->getQuestiontext() !== '' &&
295 $this->getColumnCount() &&
296 $this->getRowCount()
297 );
298 }

References ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle().

+ Here is the call graph for this function:

◆ loadFromDb()

SurveyMatrixQuestion::loadFromDb ( int  $question_id)

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

Reimplemented from SurveyQuestion.

Definition at line 226 of file class.SurveyMatrixQuestion.php.

226 : void
227 {
229 $result = $ilDB->queryF(
230 "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",
231 array('integer'),
232 array($question_id)
233 );
234 if ($result->numRows() === 1) {
235 $data = $ilDB->fetchAssoc($result);
236 $this->setId((int) $data["question_id"]);
237 $this->setTitle((string) $data["title"]);
238 $this->label = (string) $data['label'];
239 $this->setDescription((string) $data["description"]);
240 $this->setObjId((int) $data["obj_fi"]);
241 $this->setAuthor((string) $data["author"]);
242 $this->setOwner((int) $data["owner_fi"]);
243 $this->setQuestiontext(ilRTE::_replaceMediaObjectImageSrc((string) $data["questiontext"], 1));
244 $this->setObligatory((bool) $data["obligatory"]);
245 $this->setComplete((bool) $data["complete"]);
246 $this->setOriginalId((int) $data["original_id"]);
247 $this->setSubtype((int) $data["subtype"]);
248 $this->setRowSeparators((bool) $data["row_separators"]);
249 $this->setNeutralColumnSeparator((bool) $data["neutral_column_separator"]);
250 $this->setColumnSeparators((bool) $data["column_separators"]);
251 $this->setColumnPlaceholders((bool) $data["column_placeholders"]);
252 $this->setLegend((bool) $data["legend"]);
253 $this->setSingleLineRowCaption((bool) $data["singleline_row_caption"]);
254 $this->setRepeatColumnHeader((bool) $data["repeat_column_header"]);
255 $this->setBipolarAdjective(0, (string) $data["bipolar_adjective1"]);
256 $this->setBipolarAdjective(1, (string) $data["bipolar_adjective2"]);
257 $this->setLayout($data["layout"]);
258 $this->flushColumns();
259
260 $result = $ilDB->queryF(
261 "SELECT svy_variable.*, svy_category.title, svy_category.neutral FROM svy_variable, svy_category WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id ORDER BY sequence ASC",
262 array('integer'),
263 array($question_id)
264 );
265 if ($result->numRows() > 0) {
266 while ($data = $ilDB->fetchAssoc($result)) {
267 $this->columns->addCategory(
268 (string) $data["title"],
269 (int) $data["other"],
270 (int) $data["neutral"],
271 null,
272 (int) (($data['scale']) ?: ($data['sequence'] + 1))
273 );
274 }
275 }
276
277 $result = $ilDB->queryF(
278 "SELECT * FROM svy_qst_matrixrows WHERE question_fi = %s ORDER BY sequence",
279 array('integer'),
280 array($question_id)
281 );
282 while ($row = $ilDB->fetchAssoc($result)) {
283 $this->addRow((string) $row["title"], (string) $row['other'], (string) ($row['label'] ?? ""));
284 }
285 }
286 parent::loadFromDb($question_id);
287 }
setRepeatColumnHeader(bool $a_value=false)
setLegend(bool $a_value=false)
Set whether the legend should be shown or not.
setSingleLineRowCaption(bool $a_value=false)
setColumnPlaceholders(bool $a_value=false)
Set whether placeholders should be used for the column titles or not.
setSubtype(int $a_subtype=0)
Sets the subtype of the matrix question.
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, $ilDB, and ilRTE\_replaceMediaObjectImageSrc().

+ Here is the call graph for this function:

◆ moveRowDown()

SurveyMatrixQuestion::moveRowDown ( int  $index)

Definition at line 166 of file class.SurveyMatrixQuestion.php.

166 : void
167 {
168 $this->rows->moveCategoryDown($index);
169 }

◆ moveRowUp()

SurveyMatrixQuestion::moveRowUp ( int  $index)

Definition at line 161 of file class.SurveyMatrixQuestion.php.

161 : void
162 {
163 $this->rows->moveCategoryUp($index);
164 }

◆ removeColumn()

SurveyMatrixQuestion::removeColumn ( int  $index)

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

87 : void
88 {
89 $this->columns->removeCategory($index);
90 }

◆ removeColumns()

SurveyMatrixQuestion::removeColumns ( array  $array)
Parameters
int[]$arrayindex positions

Definition at line 95 of file class.SurveyMatrixQuestion.php.

95 : void
96 {
97 $this->columns->removeCategories($array);
98 }

◆ removeColumnWithName()

SurveyMatrixQuestion::removeColumnWithName ( string  $name)

Definition at line 100 of file class.SurveyMatrixQuestion.php.

100 : void
101 {
102 $this->columns->removeCategoryWithName($name);
103 }

◆ removeRow()

SurveyMatrixQuestion::removeRow ( int  $index)

Definition at line 179 of file class.SurveyMatrixQuestion.php.

179 : void
180 {
181 $this->rows->removeCategory($index);
182 }

◆ removeRows()

SurveyMatrixQuestion::removeRows ( array  $array)
Parameters
int[]$arrayindex positions

Definition at line 174 of file class.SurveyMatrixQuestion.php.

174 : void
175 {
176 $this->rows->removeCategories($array);
177 }

◆ saveBipolarAdjectives()

SurveyMatrixQuestion::saveBipolarAdjectives ( string  $adjective1,
string  $adjective2 
)

Definition at line 345 of file class.SurveyMatrixQuestion.php.

348 : void {
350
351 $ilDB->manipulateF(
352 "UPDATE " . $this->getAdditionalTableName() . " SET bipolar_adjective1 = %s, bipolar_adjective2 = %s WHERE question_fi = %s",
353 array('text', 'text', 'integer'),
354 array(($adjective1 !== '') ? $adjective1 : null, ($adjective2 !== '') ? $adjective2 : null, $this->getId())
355 );
356 }

◆ saveColumnsToDb()

SurveyMatrixQuestion::saveColumnsToDb ( int  $original_id = 0)

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

395 : void {
397
398 // save columns
399 $question_id = $this->getId();
400 if ($original_id > 0) {
401 $question_id = $original_id;
402 }
403
404 // delete existing column relations
405 $affectedRows = $ilDB->manipulateF(
406 "DELETE FROM svy_variable WHERE question_fi = %s",
407 array('integer'),
408 array($question_id)
409 );
410 // create new column relations
411 for ($i = 0; $i < $this->getColumnCount(); $i++) {
412 $cat = $this->getColumn($i);
413 $column_id = $this->saveColumnToDb($cat->title, $cat->neutral);
414 $next_id = $ilDB->nextId('svy_variable');
415 $affectedRows = $ilDB->manipulateF(
416 "INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, other, sequence, scale, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
417 array('integer','integer','integer','float','integer','integer', 'integer','integer'),
418 array($next_id, $column_id, $question_id, ($i + 1), $cat->other, $i, ($cat->scale > 0) ? $cat->scale : null, time())
419 );
420 }
422 }
saveColumnToDb(string $columntext, int $neutral=0)
saveCompletionStatus(int $original_id=0)
Saves the complete flag to the database.

◆ saveColumnToDb()

SurveyMatrixQuestion::saveColumnToDb ( string  $columntext,
int  $neutral = 0 
)

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

361 : int {
362 $ilUser = $this->user;
364
365 $result = $ilDB->queryF(
366 "SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
367 array('text', 'text', 'integer'),
368 array($columntext, $neutral, $ilUser->getId())
369 );
370 $insert = false;
371 $returnvalue = 0;
372 $insert = true;
373 if ($result->numRows()) {
374 while ($row = $ilDB->fetchAssoc($result)) {
375 if (strcmp((string) ($row["title"] ?? ''), $columntext) === 0) {
376 $returnvalue = (int) $row["category_id"];
377 $insert = false;
378 }
379 }
380 }
381 if ($insert) {
382 $next_id = $ilDB->nextId('svy_category');
383 $affectedRows = $ilDB->manipulateF(
384 "INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, neutral, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
385 array('integer', 'text', 'text', 'integer', 'text', 'integer'),
386 array($next_id, $columntext, 0, $ilUser->getId(), $neutral, time())
387 );
388 $returnvalue = $next_id;
389 }
390 return $returnvalue;
391 }

References $ilDB, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ saveLayout()

SurveyMatrixQuestion::saveLayout ( float  $percent_row,
float  $percent_columns,
float  $percent_bipolar_adjective1 = 0,
float  $percent_bipolar_adjective2 = 0,
float  $percent_neutral = 0 
)

Saves the layout of a matrix question.

Deprecated:
?
Parameters
float$percent_rowwidth in percent for the matrix rows
float$percent_columnswidth in percent for the matrix columns
float | int$percent_bipolar_adjective1width in percent for the first bipolar adjective
float | int$percent_bipolar_adjective2width in percent for the second bipolar adjective
float | int$percent_neutral

Definition at line 977 of file class.SurveyMatrixQuestion.php.

983 : void {
985
986 $layout = array(
987 "percent_row" => $percent_row,
988 "percent_columns" => $percent_columns,
989 "percent_bipolar_adjective1" => $percent_bipolar_adjective1,
990 "percent_bipolar_adjective2" => $percent_bipolar_adjective2,
991 "percent_neutral" => $percent_neutral
992 );
993 $affectedRows = $ilDB->manipulateF(
994 "UPDATE " . $this->getAdditionalTableName() . " SET layout = %s WHERE question_fi = %s",
995 array('text', 'integer'),
996 array(serialize($layout), $this->getId())
997 );
998 }

◆ saveRowsToDb()

SurveyMatrixQuestion::saveRowsToDb ( int  $original_id = 0)

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

426 : void {
428
429 // save rows
430 $question_id = $this->getId();
431 if ($original_id > 0) {
432 $question_id = $original_id;
433 }
434
435 // delete existing rows
436 $affectedRows = $ilDB->manipulateF(
437 "DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
438 array('integer'),
439 array($question_id)
440 );
441 // create new rows
442 for ($i = 0; $i < $this->getRowCount(); $i++) {
443 $row = $this->getRow($i);
444 $next_id = $ilDB->nextId('svy_qst_matrixrows');
445 $affectedRows = $ilDB->manipulateF(
446 "INSERT INTO svy_qst_matrixrows (id_svy_qst_matrixrows, title, label, other, sequence, question_fi) VALUES (%s, %s, %s, %s, %s, %s)",
447 array('integer','text','text','integer','integer','integer'),
448 array($next_id, $row->title, $row->label, ($row->other) ? 1 : 0, $i, $question_id)
449 );
450 }
452 }

◆ saveToDb()

SurveyMatrixQuestion::saveToDb ( int  $original_id = 0)

Saves a SurveyQuestion object to a database.

Reimplemented from SurveyQuestion.

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

300 : int
301 {
303
304 $affectedRows = parent::saveToDb($original_id);
305
306 if ($affectedRows === 1) {
307 $ilDB->manipulateF(
308 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
309 array('integer'),
310 array($this->getId())
311 );
312 $ilDB->manipulateF(
313 "INSERT INTO " . $this->getAdditionalTableName() . " (
314 question_fi, subtype, column_separators, row_separators, neutral_column_separator,column_placeholders,
315 legend, singleline_row_caption, repeat_column_header,
316 bipolar_adjective1, bipolar_adjective2, layout, tstamp)
317 VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
318 array(
319 'integer', 'integer', 'text', 'text', 'text', 'integer', 'text', 'text', 'text',
320 'text', 'text', 'text', 'integer'
321 ),
322 array(
323 $this->getId(),
324 $this->getSubtype(),
325 $this->getColumnSeparators(),
326 $this->getRowSeparators(),
328 $this->getColumnPlaceholders(),
329 $this->getLegend(),
331 $this->getRepeatColumnHeader(),
332 $this->getBipolarAdjective(0),
333 $this->getBipolarAdjective(1),
334 serialize($this->getLayout()),
335 time()
336 )
337 );
338
339 $this->saveColumnsToDb();
340 $this->saveRowsToDb();
341 }
342 return $affectedRows;
343 }
saveColumnsToDb(int $original_id=0)

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

+ Here is the call graph for this function:

◆ saveUserInput()

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

Definition at line 714 of file class.SurveyMatrixQuestion.php.

718 : ?array {
720
721 $answer_data = array();
722
723 // gather data
724 switch ($this->getSubtype()) {
725 case 0:
726 foreach ($post_data as $key => $value) {
727 $key = (string) $key;
728 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
729 $value = (string) $value;
730 if ($value !== '') {
731 $other_value = (array_key_exists('matrix_other_' . $this->getId() . '_' . $matches[1], $post_data))
732 ? $this->stripSlashesAddSpaceFallback((string) $post_data['matrix_other_' . $this->getId() . '_' . $matches[1]])
733 : null;
734 $answer_data[] = array("value" => $value,
735 "textanswer" => $other_value,
736 "rowvalue" => (int) $matches[1]);
737 }
738 }
739 }
740 break;
741
742 case 1:
743 foreach ($post_data as $key => $value) {
744 $key = (string) $key;
745 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
746 $other_value = (array_key_exists('matrix_other_' . $this->getId() . '_' . $matches[1], $post_data))
747 ? $this->stripSlashesAddSpaceFallback((string) $post_data['matrix_other_' . $this->getId() . '_' . $matches[1]])
748 : null;
749 foreach ((array) $value as $checked) {
750 $answer_data[] = array("value" => (string) $checked,
751 "textanswer" => $other_value,
752 "rowvalue" => (int) $matches[1]);
753 }
754 }
755 }
756 break;
757 }
758
759 if ($a_return) {
760 return $answer_data;
761 }
762
763 // #16387 - only if any input
764 if (count($answer_data)) {
765 // save data
766 foreach ($answer_data as $item) {
767 $next_id = $ilDB->nextId('svy_answer');
768 #20216
769 $fields = array();
770 $fields['answer_id'] = array("integer", $next_id);
771 $fields['question_fi'] = array("integer", $this->getId());
772 $fields['active_fi'] = array("integer", $active_id);
773 $fields['value'] = array("float", $item['value']);
774 $fields['textanswer'] = array("clob", $item['textanswer']);
775 $fields['rowvalue'] = array("integer", $item['rowvalue']);
776 $fields['tstamp'] = array("integer", time());
777
778 $affectedRows = $ilDB->insert("svy_answer", $fields);
779 }
780 }
781 return null;
782 }
stripSlashesAddSpaceFallback(string $a_str)
Strip slashes with add space fallback, see https://mantis.ilias.de/view.php?id=19727 and https://mant...

◆ setBipolarAdjective()

SurveyMatrixQuestion::setBipolarAdjective ( int  $a_index,
string  $a_value 
)

Definition at line 196 of file class.SurveyMatrixQuestion.php.

199 : void {
200 if ($a_index === 1) {
201 $this->bipolar_adjective2 = $a_value;
202 } else {
203 $this->bipolar_adjective1 = $a_value;
204 }
205 }

◆ setColumnPlaceholders()

SurveyMatrixQuestion::setColumnPlaceholders ( bool  $a_value = false)

Set whether placeholders should be used for the column titles or not.

Definition at line 1077 of file class.SurveyMatrixQuestion.php.

1077 : void
1078 {
1079 $this->columnPlaceholders = $a_value;
1080 }

◆ setColumnSeparators()

SurveyMatrixQuestion::setColumnSeparators ( bool  $enable = false)

Enables/Disables separators for the matrix columns.

Definition at line 832 of file class.SurveyMatrixQuestion.php.

832 : void
833 {
834 $this->columnSeparators = $enable;
835 }

◆ setLayout()

SurveyMatrixQuestion::setLayout (   $layout)
Parameters
array | string$layout

Definition at line 1043 of file class.SurveyMatrixQuestion.php.

1043 : void
1044 {
1045 if (is_array($layout)) {
1046 $this->layout = $layout;
1047 } else {
1048 $this->layout = unserialize((string) $layout, ['allowed_classes' => false]) ?: [];
1049 }
1050 }

◆ setLegend()

SurveyMatrixQuestion::setLegend ( bool  $a_value = false)

Set whether the legend should be shown or not.

Definition at line 1090 of file class.SurveyMatrixQuestion.php.

1090 : void
1091 {
1092 $this->legend = $a_value;
1093 }

◆ setNeutralColumnSeparator()

SurveyMatrixQuestion::setNeutralColumnSeparator ( bool  $enable = true)

Definition at line 855 of file class.SurveyMatrixQuestion.php.

855 : void
856 {
857 $this->neutralColumnSeparator = $enable;
858 }

◆ setRepeatColumnHeader()

SurveyMatrixQuestion::setRepeatColumnHeader ( bool  $a_value = false)

Definition at line 1110 of file class.SurveyMatrixQuestion.php.

1110 : void
1111 {
1112 $this->repeatColumnHeader = $a_value;
1113 }

◆ setRowSeparators()

SurveyMatrixQuestion::setRowSeparators ( bool  $enable = false)

Enables/Disables separators for the matrix rows.

Definition at line 845 of file class.SurveyMatrixQuestion.php.

845 : void
846 {
847 $this->rowSeparators = $enable;
848 }

◆ setSingleLineRowCaption()

SurveyMatrixQuestion::setSingleLineRowCaption ( bool  $a_value = false)

Definition at line 1100 of file class.SurveyMatrixQuestion.php.

1100 : void
1101 {
1102 $this->singleLineRowCaption = $a_value;
1103 }

◆ setSubtype()

SurveyMatrixQuestion::setSubtype ( int  $a_subtype = 0)

Sets the subtype of the matrix question.

Reimplemented from SurveyQuestion.

Definition at line 811 of file class.SurveyMatrixQuestion.php.

811 : void
812 {
813 switch ($a_subtype) {
814 case 1:
815 case 2:
816 case 3:
817 case 4:
818 case 5:
819 case 6:
820 $this->subtype = $a_subtype;
821 break;
822 case 0:
823 default:
824 $this->subtype = 0;
825 break;
826 }
827 }

◆ syncWithOriginal()

SurveyMatrixQuestion::syncWithOriginal ( )

Reimplemented from SurveyQuestion.

Definition at line 598 of file class.SurveyMatrixQuestion.php.

598 : void
599 {
600 if ($this->getOriginalId()) {
601 parent::syncWithOriginal();
602 $this->saveColumnsToDb($this->getOriginalId());
603 $this->saveRowsToDb($this->getOriginalId());
604 }
605 }

◆ toXML()

SurveyMatrixQuestion::toXML ( bool  $a_include_header = true,
bool  $obligatory_state = false 
)

Returns an xml representation of the question.

Returns
string The xml representation of the question @access public

Definition at line 460 of file class.SurveyMatrixQuestion.php.

463 : string {
464 $a_xml_writer = new ilXmlWriter();
465 $a_xml_writer->xmlHeader();
466 $this->insertXML($a_xml_writer, $a_include_header);
467 $xml = $a_xml_writer->xmlDumpMem(false);
468 if (!$a_include_header) {
469 $pos = strpos($xml, "?>");
470 $xml = substr($xml, $pos + 2);
471 }
472 return $xml;
473 }
insertXML(ilXmlWriter $a_xml_writer, bool $a_include_header=true)
Adds the question XML to a given XMLWriter object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ usableForPrecondition()

SurveyMatrixQuestion::usableForPrecondition ( )

Returns if the question is usable for preconditions.

Reimplemented from SurveyQuestion.

Definition at line 940 of file class.SurveyMatrixQuestion.php.

940 : bool
941 {
942 return false;
943 }

Field Documentation

◆ $bipolar_adjective1

string SurveyMatrixQuestion::$bipolar_adjective1 = ""

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

◆ $bipolar_adjective2

string SurveyMatrixQuestion::$bipolar_adjective2 = ""

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

◆ $columnPlaceholders

bool SurveyMatrixQuestion::$columnPlaceholders = false

Definition at line 42 of file class.SurveyMatrixQuestion.php.

◆ $columns

SurveyCategories SurveyMatrixQuestion::$columns

Definition at line 28 of file class.SurveyMatrixQuestion.php.

Referenced by getColumns().

◆ $columnSeparators

bool SurveyMatrixQuestion::$columnSeparators = false

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

◆ $layout

array SurveyMatrixQuestion::$layout

Definition at line 40 of file class.SurveyMatrixQuestion.php.

◆ $legend

bool SurveyMatrixQuestion::$legend = false

Definition at line 43 of file class.SurveyMatrixQuestion.php.

◆ $neutralColumnSeparator

bool SurveyMatrixQuestion::$neutralColumnSeparator = false

Definition at line 39 of file class.SurveyMatrixQuestion.php.

◆ $repeatColumnHeader

bool SurveyMatrixQuestion::$repeatColumnHeader = false

Definition at line 45 of file class.SurveyMatrixQuestion.php.

◆ $rows

SurveyCategories SurveyMatrixQuestion::$rows

Definition at line 29 of file class.SurveyMatrixQuestion.php.

◆ $rowSeparators

bool SurveyMatrixQuestion::$rowSeparators = false

Definition at line 37 of file class.SurveyMatrixQuestion.php.

◆ $singleLineRowCaption

bool SurveyMatrixQuestion::$singleLineRowCaption = false

Definition at line 44 of file class.SurveyMatrixQuestion.php.

◆ $subtype

int SurveyMatrixQuestion::$subtype

Matrix question subtype 0 = Single choice 1 = Multiple choice 2 = Text 3 = Integer 4 = Double 5 = Date 6 = Time.

Definition at line 57 of file class.SurveyMatrixQuestion.php.


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