ILIAS  release_8 Revision v8.24
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)
 
 addPhrase (int $phrase_id)
 Adds a phrase to the question. More...
 
 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...
 
 savePhrase (string $title)
 Saves a set of columns to a default phrase (data currently comes from session) 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...
 
 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...
 

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 24 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 57 of file class.SurveyMatrixQuestion.php.

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

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

◆ addPhrase()

SurveyMatrixQuestion::addPhrase ( int  $phrase_id)

Adds a phrase to the question.

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

208 : void
209 {
212
213 $result = $ilDB->queryF(
214 "SELECT svy_category.* FROM svy_category, svy_phrase_cat WHERE svy_phrase_cat.category_fi = svy_category.category_id AND svy_phrase_cat.phrase_fi = %s AND (svy_category.owner_fi = %s OR svy_category.owner_fi = %s) ORDER BY svy_phrase_cat.sequence",
215 array('integer', 'integer', 'integer'),
216 array($phrase_id, 0, $ilUser->getId())
217 );
218 while ($row = $ilDB->fetchAssoc($result)) {
219 $neutral = $row["neutral"];
220 if ((int) $row["defaultvalue"] === 1 && (int) $row["owner_fi"] === 0) {
221 $this->columns->addCategory($this->lng->txt($row["title"]), 0, $neutral);
222 } else {
223 $this->columns->addCategory($row["title"], 0, $neutral);
224 }
225 }
226 }
$ilUser
Definition: imgupload.php:34

References $ilDB, $ilUser, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ addRow()

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

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

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

◆ addRowAtPosition()

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

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

145 : void {
146 $this->rows->addCategoryAtPosition($a_text, $a_position, $a_other);
147 }

◆ addStandardNumbers()

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

Adds standard numbers as columns.

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

631 : void {
632 for ($i = $lower_limit; $i <= $upper_limit; $i++) {
633 $this->columns->addCategory($i);
634 }
635 }
$i
Definition: metadata.php:41

References $i.

◆ 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 723 of file class.SurveyMatrixQuestion.php.

726 : string {
727 if (!$this->getObligatory()) {
728 return "";
729 }
730 switch ($this->getSubtype()) {
731 case 0:
732 $counter = 0;
733 foreach ($post_data as $key => $value) {
734 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
735 if (array_key_exists('matrix_other_' . $this->getId() . "_" . $matches[1], $post_data) && strlen($post_data['matrix_other_' . $this->getId() . "_" . $matches[1]]) == 0) {
736 return $this->lng->txt("question_mr_no_other_answer");
737 }
738 $counter++;
739 }
740 }
741 if ($counter !== $this->getRowCount()) {
742 return $this->lng->txt("matrix_question_radio_button_not_checked");
743 }
744 break;
745 case 1:
746 $counter = 0;
747 foreach ($post_data as $key => $value) {
748 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
749 if (array_key_exists('matrix_other_' . $this->getId() . "_" . $matches[1], $post_data) && strlen($post_data['matrix_other_' . $this->getId() . "_" . $matches[1]]) == 0) {
750 return $this->lng->txt("question_mr_no_other_answer");
751 }
752 $counter++;
753 if ((!is_array($value)) || (count($value) < 1)) {
754 return $this->lng->txt("matrix_question_checkbox_not_checked");
755 }
756 }
757 }
758 if ($counter !== $this->getRowCount()) {
759 return $this->lng->txt("matrix_question_checkbox_not_checked");
760 }
761 break;
762 }
763 return "";
764 }
getSubtype()
Returns the subtype of the matrix question.
string $key
Consumer key/client ID value.
Definition: System.php:193

◆ deleteAdditionalTableData()

SurveyMatrixQuestion::deleteAdditionalTableData ( int  $question_id)

Delete question data from additional table.

Reimplemented from SurveyQuestion.

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

838 : void {
839 parent::deleteAdditionalTableData($question_id);
840
842 $ilDB->manipulateF(
843 "DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
844 array('integer'),
845 array($question_id)
846 );
847 }

◆ flushColumns()

SurveyMatrixQuestion::flushColumns ( )

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

123 : void
124 {
125 $this->columns->flushCategories();
126 }

◆ flushRows()

SurveyMatrixQuestion::flushRows ( )

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

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

◆ getAdditionalTableName()

SurveyMatrixQuestion::getAdditionalTableName ( )

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

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

683 : string
684 {
685 return "svy_qst_matrix";
686 }

◆ 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 186 of file class.SurveyMatrixQuestion.php.

186 : string
187 {
188 if ($a_index === 1) {
190 }
192 }

◆ getColumn()

SurveyMatrixQuestion::getColumn ( int  $index)

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

109 {
110 return $this->columns->getCategory($index);
111 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$index
Definition: metadata.php:145

References $index.

◆ getColumnCount()

SurveyMatrixQuestion::getColumnCount ( )

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

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

◆ getColumnForScale()

SurveyMatrixQuestion::getColumnForScale ( int  $scale)

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

114 {
115 return $this->columns->getCategoryForScale($scale);
116 }

◆ getColumnIndex()

SurveyMatrixQuestion::getColumnIndex ( string  $name)

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

118 : int
119 {
120 return $this->columns->getCategoryIndex($name);
121 }
if($format !==null) $name
Definition: metadata.php:247

References $name.

◆ getColumnPlaceholders()

SurveyMatrixQuestion::getColumnPlaceholders ( )

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

1123 : bool
1124 {
1126 }

◆ getColumns()

SurveyMatrixQuestion::getColumns ( )

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

104 {
105 return $this->columns;
106 }

References $columns.

◆ getColumnSeparators()

SurveyMatrixQuestion::getColumnSeparators ( )

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

886 : bool
887 {
889 }

◆ getLayout()

SurveyMatrixQuestion::getLayout ( )

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

1041 : array
1042 {
1043 if (count($this->layout) === 0) {
1044 if ($this->hasBipolarAdjectives() && $this->hasNeutralColumn()) {
1045 $this->layout = array(
1046 "percent_row" => 30,
1047 "percent_columns" => 40,
1048 "percent_bipolar_adjective1" => 10,
1049 "percent_bipolar_adjective2" => 10,
1050 "percent_neutral" => 10
1051 );
1052 } elseif ($this->hasBipolarAdjectives()) {
1053 $this->layout = array(
1054 "percent_row" => 30,
1055 "percent_columns" => 50,
1056 "percent_bipolar_adjective1" => 10,
1057 "percent_bipolar_adjective2" => 10,
1058 "percent_neutral" => 0
1059 );
1060 } elseif ($this->hasNeutralColumn()) {
1061 $this->layout = array(
1062 "percent_row" => 30,
1063 "percent_columns" => 50,
1064 "percent_bipolar_adjective1" => 0,
1065 "percent_bipolar_adjective2" => 0,
1066 "percent_neutral" => 20
1067 );
1068 } else {
1069 $this->layout = array(
1070 "percent_row" => 30,
1071 "percent_columns" => 70,
1072 "percent_bipolar_adjective1" => 0,
1073 "percent_bipolar_adjective2" => 0,
1074 "percent_neutral" => 0
1075 );
1076 }
1077 }
1078 return $this->layout;
1079 }
hasNeutralColumn()
Returns TRUE if a neutral column exists.
hasBipolarAdjectives()
Returns TRUE if bipolar adjectives exist.

◆ getLegend()

SurveyMatrixQuestion::getLegend ( )

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

1136 : bool
1137 {
1138 return $this->legend;
1139 }

◆ 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 1167 of file class.SurveyMatrixQuestion.php.

1167 : int
1168 {
1169 global $DIC;
1170
1171 // we need max scale values of matrix rows * number of rows (type 5)
1172 $db = $DIC->database();
1173
1174 $set = $db->queryF(
1175 "SELECT MAX(scale) max_sum_score, q.question_id FROM svy_svy_qst sq " .
1176 "JOIN svy_question q ON (sq.question_fi = q.question_id) " .
1177 "JOIN svy_variable v ON (v.question_fi = q.question_id) " .
1178 "WHERE sq.survey_fi = %s AND q.questiontype_fi = %s " .
1179 "GROUP BY (q.question_id)",
1180 ["integer", "integer"],
1181 [$survey_id, 5]
1182 );
1183 $max_score = [];
1184 while ($rec = $db->fetchAssoc($set)) {
1185 $max_score[$rec["question_id"]] = $rec["max_sum_score"];
1186 }
1187
1188 $set = $db->queryF(
1189 "SELECT COUNT(mr.id_svy_qst_matrixrows) cnt_rows, q.question_id FROM svy_svy_qst sq " .
1190 "JOIN svy_question q ON (sq.question_fi = q.question_id) " .
1191 "JOIN svy_qst_matrixrows mr ON (mr.question_fi = q.question_id) " .
1192 "WHERE sq.survey_fi = %s AND q.questiontype_fi = %s " .
1193 "GROUP BY (q.question_id)",
1194 ["integer", "integer"],
1195 [$survey_id, 5]
1196 );
1197 $cnt_rows = [];
1198 while ($rec = $db->fetchAssoc($set)) {
1199 $cnt_rows[$rec["question_id"]] = $rec["cnt_rows"];
1200 }
1201
1202 $sum_sum_score = 0;
1203 foreach ($max_score as $qid => $s) {
1204 $sum_sum_score += $s * $cnt_rows[$qid];
1205 }
1206
1207 return $sum_sum_score;
1208 }
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)

References $DIC.

◆ getNeutralColumnSeparator()

SurveyMatrixQuestion::getNeutralColumnSeparator ( )

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

909 : bool
910 {
912 }

◆ getPreconditionSelectValue()

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

Creates a form property for the precondition value.

Reimplemented from SurveyQuestion.

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

1002 $step3 = new ilSelectInputGUI($title, $variable);
1003 $options = $this->getPreconditionOptions();
1004 $step3->setOptions($options);
1005 $step3->setValue($default);
1006 return $step3;
1007 }
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 989 of file class.SurveyMatrixQuestion.php.

989 : string
990 {
991 return $value;
992 }

◆ getQuestionDataArray()

SurveyMatrixQuestion::getQuestionDataArray ( int  $id)

Returns the question data fields from the database.

Reimplemented from SurveyQuestion.

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

231 : array
232 {
234
235 $result = $ilDB->queryF(
236 "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",
237 array('integer'),
238 array($id)
239 );
240 if ($result->numRows() === 1) {
241 return $ilDB->fetchAssoc($result);
242 }
243
244 return array();
245 }
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 675 of file class.SurveyMatrixQuestion.php.

675 : string
676 {
677 return "SurveyMatrixQuestion";
678 }

◆ getRepeatColumnHeader()

SurveyMatrixQuestion::getRepeatColumnHeader ( )

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

1156 : bool
1157 {
1159 }

◆ getRow()

SurveyMatrixQuestion::getRow ( int  $a_index)

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

155 {
156 return $this->rows->getCategory($a_index);
157 }

◆ getRowCount()

SurveyMatrixQuestion::getRowCount ( )

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

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

◆ getRows()

SurveyMatrixQuestion::getRows ( )

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

1163 {
1164 return $this->rows;
1165 }

References $rows.

◆ getRowSeparators()

SurveyMatrixQuestion::getRowSeparators ( )

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

899 : bool
900 {
902 }

◆ getSingleLineRowCaption()

SurveyMatrixQuestion::getSingleLineRowCaption ( )

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

1146 : bool
1147 {
1149 }

◆ getSubtype()

SurveyMatrixQuestion::getSubtype ( )

Returns the subtype of the matrix question.

Reimplemented from SurveyQuestion.

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

852 : ?int
853 {
854 return $this->subtype;
855 }
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 688 of file class.SurveyMatrixQuestion.php.

688 : array
689 {
690 $data = array();
691 foreach ($post_data as $key => $value) {
692 switch ($this->getSubtype()) {
693 case 1:
694 case 0:
695 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
696 if (is_array($value)) {
697 foreach ($value as $val) {
698 $data[] = array("value" => $val,
699 "rowvalue" => $matches[1],
700 "textanswer" => $post_data['matrix_other_' . $this->getId(
701 ) . '_' . $matches[1]] ?? ""
702 );
703 }
704 } else {
705 $data[] = array("value" => $value,
706 "rowvalue" => $matches[1],
707 "textanswer" => $post_data['matrix_other_' . $this->getId(
708 ) . '_' . $matches[1]] ?? ""
709 );
710 }
711 }
712 break;
713 }
714 }
715 return $data;
716 }

References $data, ILIAS\LTI\ToolProvider\$key, 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 1096 of file class.SurveyMatrixQuestion.php.

1096 : bool
1097 {
1098 return $this->getBipolarAdjective(0) !== '' && $this->getBipolarAdjective(1) !== '';
1099 }
getBipolarAdjective(int $a_index)
Returns one of the bipolar adjectives.

◆ hasNeutralColumn()

SurveyMatrixQuestion::hasNeutralColumn ( )

Returns TRUE if a neutral column exists.

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

1104 : bool
1105 {
1106 for ($i = 0; $i < $this->getColumnCount(); $i++) {
1107 $column = $this->getColumn($i);
1108 if ($column->neutral && strlen($column->title)) {
1109 return true;
1110 }
1111 }
1112 return false;
1113 }

References $i.

◆ importAdditionalMetadata()

SurveyMatrixQuestion::importAdditionalMetadata ( array  $a_meta)

Import additional meta data from the question import file.

Reimplemented from SurveyQuestion.

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

917 : void
918 {
919 foreach ($a_meta as $key => $value) {
920 switch ($value["label"]) {
921 case "column_separators":
922 $this->setColumnSeparators($value["entry"]);
923 break;
924 case "row_separators":
925 $this->setRowSeparators($value["entry"]);
926 break;
927 case "layout":
928 $this->setLayout($value["entry"]);
929 break;
930 case "neutral_column_separator":
931 $this->setNeutralColumnSeparator($value["entry"]);
932 break;
933 }
934 }
935 }
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)

References ILIAS\LTI\ToolProvider\$key.

◆ importAdjectives()

SurveyMatrixQuestion::importAdjectives ( array  $a_data)

Import bipolar adjectives from the question import file.

Reimplemented from SurveyQuestion.

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

940 : void
941 {
942 $i = 0;
943 foreach ($a_data as $adjective) {
944 if (is_numeric($adjective["label"])) {
945 $this->setBipolarAdjective($adjective["label"], $adjective["text"]);
946 } else {
947 $this->setBipolarAdjective($i, $adjective["text"]);
948 }
949 $i++;
950 }
951 }
setBipolarAdjective(int $a_index, string $a_value)

References $i.

◆ importMatrix()

SurveyMatrixQuestion::importMatrix ( array  $a_data)

Import matrix rows from the question import file.

Reimplemented from SurveyQuestion.

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

958 : void {
959 foreach ($a_data as $row) {
960 $this->addRow($row['title'], $row['other'], $row['label']);
961 }
962 }
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 967 of file class.SurveyMatrixQuestion.php.

967 : void
968 {
969 foreach ($a_data as $id => $data) {
970 $column = "";
971 foreach ($data["material"] as $material) {
972 $column .= $material["text"];
973 }
974 $this->columns->addCategory($column, 0, strcmp($data["label"], "neutral") == 0);
975 }
976 }

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

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

304 : bool
305 {
306 return (
307 $this->getTitle() !== '' &&
308 $this->getAuthor() !== '' &&
309 $this->getQuestiontext() !== '' &&
310 $this->getColumnCount() &&
311 $this->getRowCount()
312 );
313 }

◆ 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 247 of file class.SurveyMatrixQuestion.php.

247 : void
248 {
250 $result = $ilDB->queryF(
251 "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",
252 array('integer'),
253 array($question_id)
254 );
255 if ($result->numRows() === 1) {
256 $data = $ilDB->fetchAssoc($result);
257 $this->setId((int) $data["question_id"]);
258 $this->setTitle((string) $data["title"]);
259 $this->label = (string) $data['label'];
260 $this->setDescription((string) $data["description"]);
261 $this->setObjId((int) $data["obj_fi"]);
262 $this->setAuthor((string) $data["author"]);
263 $this->setOwner((int) $data["owner_fi"]);
264 $this->setQuestiontext(ilRTE::_replaceMediaObjectImageSrc((string) $data["questiontext"], 1));
265 $this->setObligatory((bool) $data["obligatory"]);
266 $this->setComplete((bool) $data["complete"]);
267 $this->setOriginalId((int) $data["original_id"]);
268 $this->setSubtype((int) $data["subtype"]);
269 $this->setRowSeparators((bool) $data["row_separators"]);
270 $this->setNeutralColumnSeparator((bool) $data["neutral_column_separator"]);
271 $this->setColumnSeparators((bool) $data["column_separators"]);
272 $this->setColumnPlaceholders((bool) $data["column_placeholders"]);
273 $this->setLegend((bool) $data["legend"]);
274 $this->setSingleLineRowCaption((string) $data["singleline_row_caption"]);
275 $this->setRepeatColumnHeader((bool) $data["repeat_column_header"]);
276 $this->setBipolarAdjective(0, (string) $data["bipolar_adjective1"]);
277 $this->setBipolarAdjective(1, (string) $data["bipolar_adjective2"]);
278 $this->setLayout($data["layout"]);
279 $this->flushColumns();
280
281 $result = $ilDB->queryF(
282 "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",
283 array('integer'),
284 array($question_id)
285 );
286 if ($result->numRows() > 0) {
287 while ($data = $ilDB->fetchAssoc($result)) {
288 $this->columns->addCategory((string) $data["title"], (int) $data["other"], (int) $data["neutral"], null, ($data['scale']) ?: ($data['sequence'] + 1));
289 }
290 }
291
292 $result = $ilDB->queryF(
293 "SELECT * FROM svy_qst_matrixrows WHERE question_fi = %s ORDER BY sequence",
294 array('integer'),
295 array($question_id)
296 );
297 while ($row = $ilDB->fetchAssoc($result)) {
298 $this->addRow((string) $row["title"], (string) $row['other'], (string) ($row['label'] ?? ""));
299 }
300 }
301 parent::loadFromDb($question_id);
302 }
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 164 of file class.SurveyMatrixQuestion.php.

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

References $index.

◆ moveRowUp()

SurveyMatrixQuestion::moveRowUp ( int  $index)

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

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

References $index.

◆ removeColumn()

SurveyMatrixQuestion::removeColumn ( int  $index)

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

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

References $index.

◆ removeColumns()

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

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

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

◆ removeColumnWithName()

SurveyMatrixQuestion::removeColumnWithName ( string  $name)

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

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

References $name.

◆ removeRow()

SurveyMatrixQuestion::removeRow ( int  $index)

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

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

References $index.

◆ removeRows()

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

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

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

◆ saveBipolarAdjectives()

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

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

366 : void {
368
369 $ilDB->manipulateF(
370 "UPDATE " . $this->getAdditionalTableName() . " SET bipolar_adjective1 = %s, bipolar_adjective2 = %s WHERE question_fi = %s",
371 array('text', 'text', 'integer'),
372 array(($adjective1 !== '') ? $adjective1 : null, ($adjective2 !== '') ? $adjective2 : null, $this->getId())
373 );
374 }

◆ saveColumnsToDb()

SurveyMatrixQuestion::saveColumnsToDb ( int  $original_id = 0)

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

413 : void {
415
416 // save columns
417 $question_id = $this->getId();
418 if ($original_id > 0) {
419 $question_id = $original_id;
420 }
421
422 // delete existing column relations
423 $affectedRows = $ilDB->manipulateF(
424 "DELETE FROM svy_variable WHERE question_fi = %s",
425 array('integer'),
426 array($question_id)
427 );
428 // create new column relations
429 for ($i = 0; $i < $this->getColumnCount(); $i++) {
430 $cat = $this->getColumn($i);
431 $column_id = $this->saveColumnToDb($cat->title, $cat->neutral);
432 $next_id = $ilDB->nextId('svy_variable');
433 $affectedRows = $ilDB->manipulateF(
434 "INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, other, sequence, scale, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
435 array('integer','integer','integer','float','integer','integer', 'integer','integer'),
436 array($next_id, $column_id, $question_id, ($i + 1), $cat->other, $i, ($cat->scale > 0) ? $cat->scale : null, time())
437 );
438 }
440 }
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 376 of file class.SurveyMatrixQuestion.php.

379 : int {
382
383 $result = $ilDB->queryF(
384 "SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
385 array('text', 'text', 'integer'),
386 array($columntext, $neutral, $ilUser->getId())
387 );
388 $insert = false;
389 $returnvalue = "";
390 $insert = true;
391 if ($result->numRows()) {
392 while ($row = $ilDB->fetchAssoc($result)) {
393 if (strcmp($row["title"] ?? '', $columntext) === 0) {
394 $returnvalue = $row["category_id"];
395 $insert = false;
396 }
397 }
398 }
399 if ($insert) {
400 $next_id = $ilDB->nextId('svy_category');
401 $affectedRows = $ilDB->manipulateF(
402 "INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, neutral, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
403 array('integer', 'text', 'text', 'integer', 'text', 'integer'),
404 array($next_id, $columntext, 0, $ilUser->getId(), $neutral, time())
405 );
406 $returnvalue = $next_id;
407 }
408 return $returnvalue;
409 }

References $ilDB.

◆ 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 1018 of file class.SurveyMatrixQuestion.php.

1024 : void {
1025 $ilDB = $this->db;
1026
1027 $layout = array(
1028 "percent_row" => $percent_row,
1029 "percent_columns" => $percent_columns,
1030 "percent_bipolar_adjective1" => $percent_bipolar_adjective1,
1031 "percent_bipolar_adjective2" => $percent_bipolar_adjective2,
1032 "percent_neutral" => $percent_neutral
1033 );
1034 $affectedRows = $ilDB->manipulateF(
1035 "UPDATE " . $this->getAdditionalTableName() . " SET layout = %s WHERE question_fi = %s",
1036 array('text', 'integer'),
1037 array(serialize($layout), $this->getId())
1038 );
1039 }

◆ savePhrase()

SurveyMatrixQuestion::savePhrase ( string  $title)

Saves a set of columns to a default phrase (data currently comes from session)

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

643 : void {
646
647 $next_id = $ilDB->nextId('svy_phrase');
648 $ilDB->manipulateF(
649 "INSERT INTO svy_phrase (phrase_id, title, defaultvalue, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
650 array('integer','text','text','integer','integer'),
651 array($next_id, $title, 1, $ilUser->getId(), time())
652 );
653 $phrase_id = $next_id;
654
655 $counter = 1;
656 $phrase_data = $this->edit_manager->getPhraseData();
657 foreach ($phrase_data as $data) {
658 $next_id = $ilDB->nextId('svy_category');
659 $affectedRows = $ilDB->manipulateF(
660 "INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, tstamp, neutral) VALUES (%s, %s, %s, %s, %s, %s)",
661 array('integer','text','text','integer','integer','text'),
662 array($next_id, $data['answer'], 1, $ilUser->getId(), time(), $data['neutral'])
663 );
664 $category_id = $next_id;
665 $next_id = $ilDB->nextId('svy_phrase_cat');
666 $affectedRows = $ilDB->manipulateF(
667 "INSERT INTO svy_phrase_cat (phrase_category_id, phrase_fi, category_fi, sequence, other, scale) VALUES (%s, %s, %s, %s, %s, %s)",
668 array('integer', 'integer', 'integer','integer', 'integer', 'integer'),
669 array($next_id, $phrase_id, $category_id, $counter, ($data['other']) ? 1 : 0, $data['scale'])
670 );
671 $counter++;
672 }
673 }

References $data, $ilDB, and $ilUser.

◆ saveRowsToDb()

SurveyMatrixQuestion::saveRowsToDb ( int  $original_id = 0)

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

444 : void {
446
447 // save rows
448 $question_id = $this->getId();
449 if ($original_id > 0) {
450 $question_id = $original_id;
451 }
452
453 // delete existing rows
454 $affectedRows = $ilDB->manipulateF(
455 "DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
456 array('integer'),
457 array($question_id)
458 );
459 // create new rows
460 for ($i = 0; $i < $this->getRowCount(); $i++) {
461 $row = $this->getRow($i);
462 $next_id = $ilDB->nextId('svy_qst_matrixrows');
463 $affectedRows = $ilDB->manipulateF(
464 "INSERT INTO svy_qst_matrixrows (id_svy_qst_matrixrows, title, label, other, sequence, question_fi) VALUES (%s, %s, %s, %s, %s, %s)",
465 array('integer','text','text','integer','integer','integer'),
466 array($next_id, $row->title, $row->label, ($row->other) ? 1 : 0, $i, $question_id)
467 );
468 }
470 }

◆ saveToDb()

SurveyMatrixQuestion::saveToDb ( int  $original_id = 0)

Saves a SurveyQuestion object to a database.

Reimplemented from SurveyQuestion.

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

315 : int
316 {
318
319 $affectedRows = parent::saveToDb($original_id);
320
321 if ($affectedRows === 1) {
322 $ilDB->manipulateF(
323 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
324 array('integer'),
325 array($this->getId())
326 );
327 $ilDB->manipulateF(
328 "INSERT INTO " . $this->getAdditionalTableName() . " (
329 question_fi, subtype, column_separators, row_separators, neutral_column_separator,column_placeholders,
330 legend, singleline_row_caption, repeat_column_header,
331 bipolar_adjective1, bipolar_adjective2, layout, tstamp)
332 VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
333 array(
334 'integer', 'integer', 'text', 'text', 'text', 'integer', 'text', 'text', 'text',
335 'text', 'text', 'text', 'integer'
336 ),
337 array(
338 $this->getId(),
339 $this->getSubtype(),
340 $this->getColumnSeparators(),
341 $this->getRowSeparators(),
343 $this->getColumnPlaceholders(),
344 $this->getLegend(),
346 $this->getRepeatColumnHeader(),
347 $this->getBipolarAdjective(0),
348 $this->getBipolarAdjective(1),
349 serialize($this->getLayout()),
350 time()
351 )
352 );
353
354 // saving material uris in the database
355 $this->saveMaterial();
356
357 $this->saveColumnsToDb();
358 $this->saveRowsToDb();
359 }
360 return $affectedRows;
361 }
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 766 of file class.SurveyMatrixQuestion.php.

770 : ?array {
772
773 $answer_data = array();
774
775 // gather data
776 switch ($this->getSubtype()) {
777 case 0:
778 foreach ($post_data as $key => $value) {
779 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
780 if (strlen($value)) {
781 $other_value = (array_key_exists('matrix_other_' . $this->getId() . '_' . $matches[1], $post_data))
782 ? $this->stripSlashesAddSpaceFallback($post_data['matrix_other_' . $this->getId() . '_' . $matches[1]])
783 : null;
784 $answer_data[] = array("value" => $value,
785 "textanswer" => $other_value,
786 "rowvalue" => $matches[1]);
787 }
788 }
789 }
790 break;
791
792 case 1:
793 foreach ($post_data as $key => $value) {
794 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
795 $other_value = (array_key_exists('matrix_other_' . $this->getId() . '_' . $matches[1], $post_data))
796 ? $this->stripSlashesAddSpaceFallback($post_data['matrix_other_' . $this->getId() . '_' . $matches[1]])
797 : null;
798 foreach ($value as $checked) {
799 $answer_data[] = array("value" => $checked,
800 "textanswer" => $other_value,
801 "rowvalue" => $matches[1]);
802 }
803 }
804 }
805 break;
806 }
807
808 if ($a_return) {
809 return $answer_data;
810 }
811
812 // #16387 - only if any input
813 if (count($answer_data)) {
814 // save data
815 foreach ($answer_data as $item) {
816 $next_id = $ilDB->nextId('svy_answer');
817 #20216
818 $fields = array();
819 $fields['answer_id'] = array("integer", $next_id);
820 $fields['question_fi'] = array("integer", $this->getId());
821 $fields['active_fi'] = array("integer", $active_id);
822 $fields['value'] = array("float", $item['value']);
823 $fields['textanswer'] = array("clob", $item['textanswer']);
824 $fields['rowvalue'] = array("integer", $item['rowvalue']);
825 $fields['tstamp'] = array("integer", time());
826
827 $affectedRows = $ilDB->insert("svy_answer", $fields);
828 }
829 }
830 return null;
831 }
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 194 of file class.SurveyMatrixQuestion.php.

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

◆ setColumnPlaceholders()

SurveyMatrixQuestion::setColumnPlaceholders ( bool  $a_value = false)

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

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

1118 : void
1119 {
1120 $this->columnPlaceholders = $a_value;
1121 }

◆ setColumnSeparators()

SurveyMatrixQuestion::setColumnSeparators ( bool  $enable = false)

Enables/Disables separators for the matrix columns.

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

881 : void
882 {
883 $this->columnSeparators = $enable;
884 }

◆ setLayout()

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

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

1084 : void
1085 {
1086 if (is_array($layout)) {
1087 $this->layout = $layout;
1088 } else {
1089 $this->layout = unserialize($layout, ['allowed_classes' => false]) ?: [];
1090 }
1091 }

◆ setLegend()

SurveyMatrixQuestion::setLegend ( bool  $a_value = false)

Set whether the legend should be shown or not.

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

1131 : void
1132 {
1133 $this->legend = $a_value;
1134 }

◆ setNeutralColumnSeparator()

SurveyMatrixQuestion::setNeutralColumnSeparator ( bool  $enable = true)

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

904 : void
905 {
906 $this->neutralColumnSeparator = $enable;
907 }

◆ setRepeatColumnHeader()

SurveyMatrixQuestion::setRepeatColumnHeader ( bool  $a_value = false)

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

1151 : void
1152 {
1153 $this->repeatColumnHeader = $a_value;
1154 }

◆ setRowSeparators()

SurveyMatrixQuestion::setRowSeparators ( bool  $enable = false)

Enables/Disables separators for the matrix rows.

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

894 : void
895 {
896 $this->rowSeparators = $enable;
897 }

◆ setSingleLineRowCaption()

SurveyMatrixQuestion::setSingleLineRowCaption ( bool  $a_value = false)

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

1141 : void
1142 {
1143 $this->singleLineRowCaption = $a_value;
1144 }

◆ setSubtype()

SurveyMatrixQuestion::setSubtype ( int  $a_subtype = 0)

Sets the subtype of the matrix question.

Reimplemented from SurveyQuestion.

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

860 : void
861 {
862 switch ($a_subtype) {
863 case 1:
864 case 2:
865 case 3:
866 case 4:
867 case 5:
868 case 6:
869 $this->subtype = $a_subtype;
870 break;
871 case 0:
872 default:
873 $this->subtype = 0;
874 break;
875 }
876 }

◆ syncWithOriginal()

SurveyMatrixQuestion::syncWithOriginal ( )

Reimplemented from SurveyQuestion.

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

616 : void
617 {
618 if ($this->getOriginalId()) {
619 parent::syncWithOriginal();
620 $this->saveColumnsToDb($this->getOriginalId());
621 $this->saveRowsToDb($this->getOriginalId());
622 }
623 }

◆ 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 478 of file class.SurveyMatrixQuestion.php.

481 : string {
482 $a_xml_writer = new ilXmlWriter();
483 $a_xml_writer->xmlHeader();
484 $this->insertXML($a_xml_writer, $a_include_header);
485 $xml = $a_xml_writer->xmlDumpMem(false);
486 if (!$a_include_header) {
487 $pos = strpos($xml, "?>");
488 $xml = substr($xml, $pos + 2);
489 }
490 return $xml;
491 }
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...
$xml
Definition: metadata.php:351

◆ usableForPrecondition()

SurveyMatrixQuestion::usableForPrecondition ( )

Returns if the question is usable for preconditions.

Reimplemented from SurveyQuestion.

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

981 : bool
982 {
983 return false;
984 }

Field Documentation

◆ $bipolar_adjective1

string SurveyMatrixQuestion::$bipolar_adjective1 = ""

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

◆ $bipolar_adjective2

string SurveyMatrixQuestion::$bipolar_adjective2 = ""

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

◆ $columnPlaceholders

bool SurveyMatrixQuestion::$columnPlaceholders = false

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

◆ $columns

SurveyCategories SurveyMatrixQuestion::$columns

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

Referenced by getColumns().

◆ $columnSeparators

bool SurveyMatrixQuestion::$columnSeparators = false

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

◆ $layout

array SurveyMatrixQuestion::$layout

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

◆ $legend

bool SurveyMatrixQuestion::$legend = false

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

◆ $neutralColumnSeparator

bool SurveyMatrixQuestion::$neutralColumnSeparator = false

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

◆ $repeatColumnHeader

bool SurveyMatrixQuestion::$repeatColumnHeader = false

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

◆ $rows

SurveyCategories SurveyMatrixQuestion::$rows

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

◆ $rowSeparators

bool SurveyMatrixQuestion::$rowSeparators = false

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

◆ $singleLineRowCaption

bool SurveyMatrixQuestion::$singleLineRowCaption = false

Definition at line 42 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 55 of file class.SurveyMatrixQuestion.php.


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