ILIAS  release_7 Revision v7.30-3-g800a261c036
SurveyMatrixQuestion Class Reference

The SurveyMatrixQuestion class defines and encapsulates basic methods and attributes for matrix question types. More...

+ Inheritance diagram for SurveyMatrixQuestion:
+ Collaboration diagram for SurveyMatrixQuestion:

Public Member Functions

 __construct ($title="", $description="", $author="", $questiontext="", $owner=-1)
 SurveyMatrixQuestion constructor The constructor takes possible arguments an creates an instance of the SurveyMatrixQuestion object. More...
 
 getColumnCount ()
 Returns the number of columns. More...
 
 removeColumn ($index)
 Removes a column from the list of columns. More...
 
 removeColumns ($array)
 Removes many columns from the list of columns. More...
 
 removeColumnWithName ($name)
 Removes a column from the list of columns. More...
 
 getColumns ()
 Return the columns. More...
 
 getColumn ($index)
 Returns the name of a column for a given index. More...
 
 getColumnForScale ($scale)
 
 getColumnIndex ($name)
 Returns the index of a column with a given name. More...
 
 flushColumns ()
 Empties the columns list. More...
 
 getRowCount ()
 Returns the number of rows in the question. More...
 
 addRow ($a_text, $a_other, $a_label)
 Adds a row to the question. More...
 
 addRowAtPosition ($a_text, $a_other, $a_position)
 Adds a row at a given position. More...
 
 flushRows ()
 Empties the row list. More...
 
 getRow ($a_index)
 Returns a specific row. More...
 
 moveRowUp ($index)
 
 moveRowDown ($index)
 
 removeRows ($array)
 Removes rows from the question. More...
 
 removeRow ($index)
 Removes a row. More...
 
 getBipolarAdjective ($a_index)
 Returns one of the bipolar adjectives. More...
 
 setBipolarAdjective ($a_index, $a_value)
 Sets one of the bipolar adjectives. More...
 
 addPhrase ($phrase_id)
 Adds a phrase to the question. More...
 
 getQuestionDataArray ($id)
 Returns the question data fields from the database. More...
 
 loadFromDb ($id)
 Loads a SurveyMatrixQuestion object from the database. More...
 
 isComplete ()
 Returns 1 if the question is complete for use. More...
 
 saveToDb ($original_id=null, $withanswers=true)
 Saves a SurveyMatrixQuestion object to a database. More...
 
 saveBipolarAdjectives ($adjective1, $adjective2)
 
 saveColumnToDb ($columntext, $neutral=0)
 Saves a column to the database. More...
 
 saveColumnsToDb ($original_id="")
 
 saveRowsToDb ($original_id="")
 
 toXML ($a_include_header=true, $obligatory_state="")
 Returns an xml representation of the question. More...
 
 insertXML (&$a_xml_writer, $a_include_header=true)
 Adds the question XML to a given XMLWriter object. More...
 
 syncWithOriginal ()
 
 addStandardNumbers ($lower_limit, $upper_limit)
 Adds standard numbers as columns. More...
 
 savePhrase ($title)
 Saves a set of columns to a default phrase. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
getWorkingDataFromUserInput ($post_data)
 Creates the user data of the svy_answer table from the POST data. More...
 
 checkUserInput ($post_data, $survey_id)
 Checks the input of the active user for obligatory status and entered values. More...
 
 saveUserInput ($post_data, $active_id, $a_return=false)
 
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database. More...
 
 getSubtype ()
 Returns the subtype of the matrix question. More...
 
 setSubtype ($a_subtype=0)
 Sets the subtype of the matrix question. More...
 
 setColumnSeparators ($enable=0)
 Enables/Disables separators for the matrix columns. More...
 
 getColumnSeparators ()
 Gets the separators enable state for the matrix columns. More...
 
 setRowSeparators ($enable=0)
 Enables/Disables separators for the matrix rows. More...
 
 getRowSeparators ()
 Gets the separators enable state for the matrix rows. More...
 
 setNeutralColumnSeparator ($enable=0)
 Enables/Disables a separator for the neutral column. More...
 
 getNeutralColumnSeparator ()
 Gets the separator enable state for the neutral column. More...
 
 importAdditionalMetadata ($a_meta)
 Import additional meta data from the question import file. More...
 
 importAdjectives ($a_data)
 Import bipolar adjectives from the question import file. More...
 
 importMatrix ($a_data)
 Import matrix rows from the question import file. More...
 
 importResponses ($a_data)
 Import response data from the question import file. More...
 
 usableForPrecondition ()
 Returns if the question is usable for preconditions. More...
 
 getPreconditionValueOutput ($value)
 Returns the output for a precondition value. More...
 
 getPreconditionSelectValue ($default="", $title, $variable)
 Creates a form property for the precondition value. More...
 
 saveLayout ($percent_row, $percent_columns, $percent_bipolar_adjective1="", $percent_bipolar_adjective2="", $percent_neutral)
 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 ($a_value=0)
 Set whether placeholders should be used for the column titles or not. More...
 
 getColumnPlaceholders ()
 Get whether placeholders should be used for the column titles or not. More...
 
 setLegend ($a_value=0)
 Set whether the legend should be shown or not. More...
 
 getLegend ()
 Get whether the legend should be shown or not. More...
 
 setSingleLineRowCaption ($a_value=0)
 
 getSingleLineRowCaption ()
 
 setRepeatColumnHeader ($a_value=0)
 
 getRepeatColumnHeader ()
 
 setColumnHeaderPosition ($a_value)
 
 getColumnHeaderPosition ()
 
 setRandomRows ($a_value=0)
 
 getRandomRows ()
 
 setColumnOrder ($a_value)
 
 getColumnOrder ()
 
 setColumnImages ($a_value=0)
 
 getColumnImages ()
 
 setRowImages ($a_value=0)
 
 getRowImages ()
 
 getRows ()
 
- Public Member Functions inherited from SurveyQuestion
 __construct ($title="", $description="", $author="", $questiontext="", $owner=-1)
 SurveyQuestion constructor The constructor takes possible arguments an creates an instance of the SurveyQuestion object. More...
 
 setComplete ($a_complete)
 Sets the complete state of the question. More...
 
 isComplete ()
 Returns 1, if a question is complete for use. More...
 
 questionTitleExists ($title, $questionpool_object="")
 Returns TRUE if the question title exists in the database. More...
 
 setTitle ($title="")
 Sets the title string of the SurveyQuestion object. More...
 
 setObligatory ($obligatory=1)
 Sets the obligatory state of the question. More...
 
 setOrientation ($orientation=0)
 Sets the orientation of the question output. More...
 
 setId ($id=-1)
 Sets the id of the SurveyQuestion object. More...
 
 setSurveyId ($id=-1)
 Sets the survey id of the SurveyQuestion object. More...
 
 setDescription ($description="")
 Sets the description string of the SurveyQuestion object. More...
 
 addMaterials ($materials_file, $materials_name="")
 Sets the materials uri. More...
 
 setMaterialsfile ($materials_filename, $materials_tempfilename="", $materials_name="")
 Sets and uploads the materials uri. More...
 
 deleteMaterial ($materials_name="")
 Deletes a materials uri with a given name. More...
 
 flushMaterials ()
 Deletes all materials uris. More...
 
 setAuthor ($author="")
 Sets the authors name of the SurveyQuestion object. More...
 
 setQuestiontext ($questiontext="")
 Sets the questiontext of the SurveyQuestion object. More...
 
 setOwner ($owner="")
 Sets the creator/owner ID of the SurveyQuestion object. More...
 
 getTitle ()
 Gets the title string of the SurveyQuestion object. More...
 
 getLabel ()
 
 getId ()
 Gets the id of the SurveyQuestion object. More...
 
 getObligatory ($survey_id="")
 Gets the obligatory state of the question. More...
 
 getSurveyId ()
 Gets the survey id of the SurveyQuestion object. More...
 
 getOrientation ()
 Gets the orientation of the question output. More...
 
 getDescription ()
 Gets the description string of the SurveyQuestion object. More...
 
 getAuthor ()
 Gets the authors name of the SurveyQuestion object. More...
 
 getOwner ()
 Gets the creator/owner ID of the SurveyQuestion object. More...
 
 getQuestiontext ()
 Gets the questiontext of the SurveyQuestion object. More...
 
 getObjId ()
 Get the reference id of the container object. More...
 
 setObjId ($obj_id=0)
 Set the reference id of the container object. More...
 
 duplicate ($for_survey=true, $title="", $author="", $owner="", $a_survey_id=0)
 Duplicates a survey question. More...
 
 copyObject ($target_questionpool, $title="")
 Copies an assOrderingQuestion object. More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 Increases the media object usage counter when a question is duplicated. More...
 
 loadFromDb ($question_id)
 Loads a SurveyQuestion object from the database. More...
 
 saveCompletionStatus ($original_id="")
 Saves the complete flag to the database. More...
 
 saveToDb ($original_id="")
 Saves a SurveyQuestion object to a database. More...
 
 saveMaterial ()
 save material to db 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...
 
 saveWorkingData ($limit_to=LIMIT_NO_LIMIT)
 Saves the learners input of the question to the database. More...
 
 getImagePath ()
 Returns the image path for web accessable images of a question. More...
 
 getMaterialsPath ()
 Returns the materials path for web accessable materials of a question. More...
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getMaterialsPathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 saveCategoryToDb ($categorytext, $neutral=0)
 Saves a category to the database. More...
 
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database. More...
 
 delete ($question_id)
 Deletes a question and all materials from the database. More...
 
 syncWithOriginal ()
 
 getPhrase ($phrase_id)
 Returns a phrase for a given database id. More...
 
 phraseExists ($title)
 Returns true if the phrase title already exists for the current user. More...
 
 addInternalLink ($material_id, $title="")
 
 deleteMaterials ($a_array)
 Deletes materials. More...
 
 duplicateMaterials ($question_id)
 Duplicates the materials of a question. More...
 
 addMaterial ($obj_material)
 
 setMaterial ($material_id="", $is_import=false, $material_title="")
 Sets a material link for the question. More...
 
 getQuestionTypeID ()
 Returns the question type ID of the question. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 isHTML ($a_text)
 Checks if a given string contains HTML or not. More...
 
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string. More...
 
 addMaterialTag (&$a_xml_writer, $a_material, $close_material_tag=true, $add_mobs=true, $a_attrs=null)
 Creates an XML material tag from a plain text or xhtml text. More...
 
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=false)
 Prepares a string for a text area output in surveys. More...
 
 getQuestionDataArray ($id)
 Returns the question data fields from the database. More...
 
getWorkingDataFromUserInput ($post_data)
 Creates the user data of the svy_answer table from the POST data. More...
 
 importAdditionalMetadata ($a_meta)
 Import additional meta data from the question import file. More...
 
 importResponses ($a_data)
 Import response data from the question import file. More...
 
 importAdjectives ($a_data)
 Import bipolar adjectives from the question import file. More...
 
 importMatrix ($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 ($value)
 Returns the output for a precondition value. More...
 
 getPreconditionSelectValue ($default="", $title, $variable)
 Creates a form property for the precondition value. More...
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 getMaterial ()
 
 setSubtype ($a_subtype)
 
 getSubtype ()
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 getCopyIds ($a_group_by_survey=false)
 
 hasCopies ()
 
 stripSlashesAddSpaceFallback ($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)
 @inheritDoc More...
 
- Static Public Member Functions inherited from SurveyQuestion
static _isComplete ($question_id)
 Checks whether the question is complete or not. More...
 
static _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
static _getTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
static _getOriginalId ($question_id, $a_return_question_id_if_no_original=true)
 Returns the original id of a question. More...
 
static _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
static _resolveInternalLink ($internal_link)
 
static _resolveIntLinks ($question_id)
 
static _getInternalLinkHref ($target="", $a_parent_ref_id=null)
 
static _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
static _includeClass ($question_type, $gui=0)
 Include the php class file for a given question type. More...
 
static _getQuestionTypeName ($type_tag)
 Return the translation for a given question type tag. More...
 
static _instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id. More...
 
static _instanciateQuestionGUI ($question_id)
 Creates an instance of a question GUI with a given question id. More...
 
static _instanciateQuestionEvaluation ($question_id, array $a_finished_ids=null)
 Creates an instance of a question evaluation with a given question id. More...
 
static _changeOriginalId ($a_question_id, $a_original_id, $a_object_id)
 Change original id of existing question in db. More...
 
static _lookupSurveyObjId ($a_question_id)
 
static lookupObjFi ($a_qid)
 Lookip obj fi. More...
 
static getMaxSumScore (int $survey_id)
 Get max sum score for specific survey (and this question type) More...
 

Data Fields

 $columns
 
 $rows
 
 $bipolar_adjective1
 
 $bipolar_adjective2
 
 $columnSeparators
 
 $rowSeparators
 
 $neutralColumnSeparator
 
 $layout
 
 $columnPlaceholders
 
 $legend
 
 $singleLineRowCaption
 
 $repeatColumnHeader
 
 $columnHeaderPosition
 
 $randomRows
 
 $columnOrder
 
 $columnImages
 
 $rowImages
 
 $openRows
 
 $subtype
 
- Data Fields inherited from SurveyQuestion
 $id
 
 $title
 
 $description
 
 $owner
 
 $author
 
 $materials
 
 $survey_id
 
 $obj_id
 
 $questiontext
 
 $obligatory
 
 $lng
 
 $orientation
 
 $material
 
 $complete
 

Protected Attributes

 $user
 
 $db
 
- Protected Attributes inherited from SurveyQuestion
 $user
 
 $db
 
 $cumulated
 An array containing the cumulated results of the question for a given survey. More...
 
 $log
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

SurveyMatrixQuestion constructor The constructor takes possible arguments an creates an instance of the SurveyMatrixQuestion object.

Parameters
string$titleA title string to describe the question
string$descriptionA description string to describe the question
string$authorA string containing the name of the questions author
integer$ownerA numerical ID to identify the owner/creator @access public

Reimplemented from SurveyQuestion.

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

145 {
146 global $DIC;
147
148 $this->user = $DIC->user();
149 $this->db = $DIC->database();
151
152 $this->subtype = 0;
153 $this->columns = new SurveyCategories();
154 $this->rows = new SurveyCategories();
155 $this->bipolar_adjective1 = "";
156 $this->bipolar_adjective2 = "";
157 $this->rowSeparators = 0;
158 $this->columnSeparators = 0;
159 $this->neutralColumnSeparator = 1;
160 }
user()
Definition: user.php:4
Class SurveyCategories.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addPhrase()

SurveyMatrixQuestion::addPhrase (   $phrase_id)

Adds a phrase to the question.

Parameters
integer$phrase_idThe database id of the given phrase @access public

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

394 {
397
398 $result = $ilDB->queryF(
399 "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",
400 array('integer', 'integer', 'integer'),
401 array($phrase_id, 0, $ilUser->getId())
402 );
403 while ($row = $ilDB->fetchAssoc($result)) {
404 $neutral = $row["neutral"];
405 if (($row["defaultvalue"] == 1) && ($row["owner_fi"] == 0)) {
406 $this->columns->addCategory($this->lng->txt($row["title"]), 0, $neutral);
407 } else {
408 $this->columns->addCategory($row["title"], 0, $neutral);
409 }
410 }
411 }
$result
$ilUser
Definition: imgupload.php:18
global $ilDB

References $db, $ilDB, $ilUser, $result, and $user.

◆ addRow()

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

Adds a row to the question.

Parameters
string$a_textThe text of the row

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

277 {
278 $this->rows->addCategory($a_text, $a_other, 0, $a_label);
279 }

Referenced by importMatrix(), and loadFromDb().

+ Here is the caller graph for this function:

◆ addRowAtPosition()

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

Adds a row at a given position.

Parameters
string$a_textThe text of the row
integer$a_positionThe row position

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

288 {
289 $this->rows->addCategoryAtPosition($a_text, $a_position, $a_other);
290 }

◆ addStandardNumbers()

SurveyMatrixQuestion::addStandardNumbers (   $lower_limit,
  $upper_limit 
)

Adds standard numbers as columns.

Parameters
integer$lower_limitThe lower limit
integer$upper_limitThe upper limit @access public

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

857 {
858 for ($i = $lower_limit; $i <= $upper_limit; $i++) {
859 $this->columns->addCategory($i);
860 }
861 }
$i
Definition: metadata.php:24

References $i.

◆ checkUserInput()

SurveyMatrixQuestion::checkUserInput (   $post_data,
  $survey_id 
)

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

Parameters
array$post_dataThe contents of the $_POST array
integer$survey_idThe database ID of the active survey
Returns
string Empty string if the input is ok, an error message otherwise @access public

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

972 {
973 if (!$this->getObligatory($survey_id)) {
974 return "";
975 }
976 switch ($this->getSubtype()) {
977 case 0:
978 $counter = 0;
979 foreach ($post_data as $key => $value) {
980 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
981 if (array_key_exists('matrix_other_' . $this->getId() . "_" . $matches[1], $post_data) && strlen($post_data['matrix_other_' . $this->getId() . "_" . $matches[1]]) == 0) {
982 return $this->lng->txt("question_mr_no_other_answer");
983 }
984 $counter++;
985 }
986 }
987 if ($counter != $this->getRowCount()) {
988 return $this->lng->txt("matrix_question_radio_button_not_checked");
989 }
990 break;
991 case 1:
992 $counter = 0;
993 foreach ($post_data as $key => $value) {
994 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
995 if (array_key_exists('matrix_other_' . $this->getId() . "_" . $matches[1], $post_data) && strlen($post_data['matrix_other_' . $this->getId() . "_" . $matches[1]]) == 0) {
996 return $this->lng->txt("question_mr_no_other_answer");
997 }
998 $counter++;
999 if ((!is_array($value)) || (count($value) < 1)) {
1000 return $this->lng->txt("matrix_question_checkbox_not_checked");
1001 }
1002 }
1003 }
1004 if ($counter != $this->getRowCount()) {
1005 return $this->lng->txt("matrix_question_checkbox_not_checked");
1006 }
1007 break;
1008 }
1009 return "";
1010 }
getSubtype()
Returns the subtype of the matrix question.
getRowCount()
Returns the number of rows in the question.
getId()
Gets the id of the SurveyQuestion object.
getObligatory($survey_id="")
Gets the obligatory state of the question.

References SurveyQuestion\$survey_id, SurveyQuestion\getId(), SurveyQuestion\getObligatory(), getRowCount(), and getSubtype().

+ Here is the call graph for this function:

◆ deleteAdditionalTableData()

SurveyMatrixQuestion::deleteAdditionalTableData (   $question_id)

Deletes datasets from the additional question table in the database.

Parameters
integer$question_idThe question id which should be deleted in the additional question table @access public

Reimplemented from SurveyQuestion.

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

1082 {
1083 parent::deleteAdditionalTableData($question_id);
1084
1085 $ilDB = $this->db;
1086 $affectedRows = $ilDB->manipulateF(
1087 "DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
1088 array('integer'),
1089 array($question_id)
1090 );
1091 }

References $db, and $ilDB.

◆ flushColumns()

SurveyMatrixQuestion::flushColumns ( )

Empties the columns list.

@access public

See also
$columns

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

256 {
257 $this->columns->flushCategories();
258 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ flushRows()

SurveyMatrixQuestion::flushRows ( )

Empties the row list.

@access public

See also
$rows

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

299 {
300 $this->rows = new SurveyCategories();
301 }

◆ getAdditionalTableName()

SurveyMatrixQuestion::getAdditionalTableName ( )

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

Returns
string The additional table name @access public

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

920 {
921 return "svy_qst_matrix";
922 }

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

+ Here is the caller graph for this function:

◆ getBipolarAdjective()

SurveyMatrixQuestion::getBipolarAdjective (   $a_index)

Returns one of the bipolar adjectives.

Parameters
integer$a_indexThe number of the bipolar adjective (0 for the first and 1 for the second adjective)
Returns
string The text of the bipolar adjective @access public

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

354 {
355 switch ($a_index) {
356 case 1:
357 return (strlen($this->bipolar_adjective2)) ? $this->bipolar_adjective2 : null;
358 break;
359 case 0:
360 default:
361 return (strlen($this->bipolar_adjective1)) ? $this->bipolar_adjective1 : null;
362 break;
363 }
364 return null;
365 }

Referenced by hasBipolarAdjectives(), insertXML(), and saveToDb().

+ Here is the caller graph for this function:

◆ getColumn()

SurveyMatrixQuestion::getColumn (   $index)

Returns the name of a column for a given index.

Parameters
integer$indexThe index of the column
Returns
array column @access public
See also
$columns

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

227 {
228 return $this->columns->getCategory($index);
229 }
$index
Definition: metadata.php:128

References $index.

Referenced by hasNeutralColumn(), insertXML(), and saveColumnsToDb().

+ Here is the caller graph for this function:

◆ getColumnCount()

SurveyMatrixQuestion::getColumnCount ( )

Returns the number of columns.

Returns
integer The number of contained columns @access public
See also
$columns

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

170 {
171 return $this->columns->getCategoryCount();
172 }

Referenced by hasNeutralColumn(), insertXML(), isComplete(), and saveColumnsToDb().

+ Here is the caller graph for this function:

◆ getColumnForScale()

SurveyMatrixQuestion::getColumnForScale (   $scale)

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

232 {
233 return $this->columns->getCategoryForScale($scale);
234 }

◆ getColumnHeaderPosition()

SurveyMatrixQuestion::getColumnHeaderPosition ( )

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

1505 {
1506 return ($this->columnHeaderPosition) ? $this->columnHeaderPosition : 0;
1507 }

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ getColumnImages()

SurveyMatrixQuestion::getColumnImages ( )

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

1535 {
1536 return ($this->columnImages) ? 1 : 0;
1537 }

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ getColumnIndex()

SurveyMatrixQuestion::getColumnIndex (   $name)

Returns the index of a column with a given name.

Parameters
string$nameThe name of the column @access public
See also
$columns

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

244 {
245 return $this->columns->getCategoryIndex($name);
246 }
if($format !==null) $name
Definition: metadata.php:230

References $name.

◆ getColumnOrder()

SurveyMatrixQuestion::getColumnOrder ( )

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

1525 {
1526 return ($this->columnOrder) ? $this->columnOrder : 0;
1527 }

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ getColumnPlaceholders()

SurveyMatrixQuestion::getColumnPlaceholders ( )

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

Returns
integer 1 for placeholders, 0 otherwise

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

1455 {
1456 return ($this->columnPlaceholders) ? 1 : 0;
1457 }

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ getColumns()

SurveyMatrixQuestion::getColumns ( )

Return the columns.

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

References $columns.

◆ getColumnSeparators()

SurveyMatrixQuestion::getColumnSeparators ( )

Gets the separators enable state for the matrix columns.

Returns
integer 1 if the separators are enabled, 0 otherwise @access public

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

1154 {
1155 return ($this->columnSeparators) ? 1 : 0;
1156 }

Referenced by insertXML(), and saveToDb().

+ Here is the caller graph for this function:

◆ getLayout()

SurveyMatrixQuestion::getLayout ( )

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

1361 {
1362 if (!is_array($this->layout) || count($this->layout) == 0) {
1363 if ($this->hasBipolarAdjectives() && $this->hasNeutralColumn()) {
1364 $this->layout = array(
1365 "percent_row" => 30,
1366 "percent_columns" => 40,
1367 "percent_bipolar_adjective1" => 10,
1368 "percent_bipolar_adjective2" => 10,
1369 "percent_neutral" => 10
1370 );
1371 } elseif ($this->hasBipolarAdjectives()) {
1372 $this->layout = array(
1373 "percent_row" => 30,
1374 "percent_columns" => 50,
1375 "percent_bipolar_adjective1" => 10,
1376 "percent_bipolar_adjective2" => 10,
1377 "percent_neutral" => 0
1378 );
1379 } elseif ($this->hasNeutralColumn()) {
1380 $this->layout = array(
1381 "percent_row" => 30,
1382 "percent_columns" => 50,
1383 "percent_bipolar_adjective1" => 0,
1384 "percent_bipolar_adjective2" => 0,
1385 "percent_neutral" => 20
1386 );
1387 } else {
1388 $this->layout = array(
1389 "percent_row" => 30,
1390 "percent_columns" => 70,
1391 "percent_bipolar_adjective1" => 0,
1392 "percent_bipolar_adjective2" => 0,
1393 "percent_neutral" => 0
1394 );
1395 }
1396 }
1397 return $this->layout;
1398 }
hasNeutralColumn()
Returns TRUE if a neutral column exists.
hasBipolarAdjectives()
Returns TRUE if bipolar adjectives exist.

References $layout, hasBipolarAdjectives(), and hasNeutralColumn().

Referenced by insertXML(), and saveToDb().

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

◆ getLegend()

SurveyMatrixQuestion::getLegend ( )

Get whether the legend should be shown or not.

Returns
integer Show legend

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

1475 {
1476 return ($this->legend) ? 1 : 0;
1477 }

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ getMaxSumScore()

static SurveyMatrixQuestion::getMaxSumScore ( int  $survey_id)
static

@inheritDoc

Reimplemented from SurveyQuestion.

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

1557 : int
1558 {
1559 global $DIC;
1560
1561 // we need max scale values of matrix rows * number of rows (type 5)
1562 $db = $DIC->database();
1563
1564 $set = $db->queryF(
1565 "SELECT MAX(scale) max_sum_score, q.question_id FROM svy_svy_qst sq " .
1566 "JOIN svy_question q ON (sq.question_fi = q.question_id) " .
1567 "JOIN svy_variable v ON (v.question_fi = q.question_id) " .
1568 "WHERE sq.survey_fi = %s AND q.questiontype_fi = %s " .
1569 "GROUP BY (q.question_id)",
1570 ["integer", "integer"],
1571 [$survey_id, 5]
1572 );
1573 $max_score = [];
1574 while ($rec = $db->fetchAssoc($set)) {
1575 $max_score[$rec["question_id"]] = $rec["max_sum_score"];
1576 }
1577
1578 $set = $db->queryF(
1579 "SELECT COUNT(mr.id_svy_qst_matrixrows) cnt_rows, q.question_id FROM svy_svy_qst sq " .
1580 "JOIN svy_question q ON (sq.question_fi = q.question_id) " .
1581 "JOIN svy_qst_matrixrows mr ON (mr.question_fi = q.question_id) " .
1582 "WHERE sq.survey_fi = %s AND q.questiontype_fi = %s " .
1583 "GROUP BY (q.question_id)",
1584 ["integer", "integer"],
1585 [$survey_id, 5]
1586 );
1587 $cnt_rows = [];
1588 while ($rec = $db->fetchAssoc($set)) {
1589 $cnt_rows[$rec["question_id"]] = $rec["cnt_rows"];
1590 }
1591
1592 $sum_sum_score = 0;
1593 foreach ($max_score as $qid => $s) {
1594 $sum_sum_score += $s * $cnt_rows[$qid];
1595 }
1596
1597 return $sum_sum_score;
1598 }

References $db, $DIC, and SurveyQuestion\$survey_id.

◆ getNeutralColumnSeparator()

SurveyMatrixQuestion::getNeutralColumnSeparator ( )

Gets the separator enable state for the neutral column.

Returns
integer 1 if the separator is enabled, 0 otherwise @access public

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

1214 {
1215 return ($this->neutralColumnSeparator) ? 1 : 0;
1216 }

Referenced by insertXML(), and saveToDb().

+ Here is the caller graph for this function:

◆ getPreconditionSelectValue()

SurveyMatrixQuestion::getPreconditionSelectValue (   $default = "",
  $title,
  $variable 
)

Creates a form property for the precondition value.

Returns
The ILIAS form element @access public

Reimplemented from SurveyQuestion.

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

1325 {
1326 $step3 = new ilSelectInputGUI($title, $variable);
1327 $options = $this->getPreconditionOptions();
1328 $step3->setOptions($options);
1329 $step3->setValue($default);
1330 return $step3;
1331 }
getPreconditionOptions()
Returns the options for preconditions.
This class represents a selection list property in a property form.

References SurveyQuestion\$title, and SurveyQuestion\getPreconditionOptions().

+ Here is the call graph for this function:

◆ getPreconditionValueOutput()

SurveyMatrixQuestion::getPreconditionValueOutput (   $value)

Returns the output for a precondition value.

Parameters
string$valueThe precondition value
Returns
string The output of the precondition value @access public

Reimplemented from SurveyQuestion.

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

1314 {
1315 return $value;
1316 }

◆ getQuestionDataArray()

SurveyMatrixQuestion::getQuestionDataArray (   $id)

Returns the question data fields from the database.

Parameters
integer$idThe question ID from the database
Returns
array Array containing the question fields and data from the database @access public

Reimplemented from SurveyQuestion.

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

421 {
423
424 $result = $ilDB->queryF(
425 "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",
426 array('integer'),
427 array($id)
428 );
429 if ($result->numRows() == 1) {
430 return $ilDB->fetchAssoc($result);
431 } else {
432 return array();
433 }
434 }
getAdditionalTableName()
Returns the name of the additional question data table in the database.

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

+ Here is the call graph for this function:

◆ getQuestionType()

SurveyMatrixQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question @access public

Reimplemented from SurveyQuestion.

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

909 {
910 return "SurveyMatrixQuestion";
911 }

◆ getRandomRows()

SurveyMatrixQuestion::getRandomRows ( )

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

1515 {
1516 return ($this->randomRows) ? 1 : 0;
1517 }

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ getRepeatColumnHeader()

SurveyMatrixQuestion::getRepeatColumnHeader ( )

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

1495 {
1496 return ($this->repeatColumnHeader) ? 1 : 0;
1497 }

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ getRow()

SurveyMatrixQuestion::getRow (   $a_index)

Returns a specific row.

Parameters
integer$a_indexThe index position of the row @access public

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

310 {
311 return $this->rows->getCategory($a_index);
312 }

Referenced by insertXML(), and saveRowsToDb().

+ Here is the caller graph for this function:

◆ getRowCount()

SurveyMatrixQuestion::getRowCount ( )

Returns the number of rows in the question.

Returns
integer The number of rows @access public

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

267 {
268 return $this->rows->getCategoryCount();
269 }

Referenced by checkUserInput(), insertXML(), isComplete(), and saveRowsToDb().

+ Here is the caller graph for this function:

◆ getRowImages()

SurveyMatrixQuestion::getRowImages ( )

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

1545 {
1546 return ($this->rowImages) ? 1 : 0;
1547 }

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ getRows()

SurveyMatrixQuestion::getRows ( )

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

1550 {
1551 return $this->rows;
1552 }

References $rows.

◆ getRowSeparators()

SurveyMatrixQuestion::getRowSeparators ( )

Gets the separators enable state for the matrix rows.

Returns
integer 1 if the separators are enabled, 0 otherwise @access public

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

1184 {
1185 return ($this->rowSeparators) ? 1 : 0;
1186 }

Referenced by insertXML(), and saveToDb().

+ Here is the caller graph for this function:

◆ getSingleLineRowCaption()

SurveyMatrixQuestion::getSingleLineRowCaption ( )

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

1485 {
1486 return ($this->singleLineRowCaption) ? 1 : 0;
1487 }

Referenced by saveToDb().

+ Here is the caller graph for this function:

◆ getSubtype()

SurveyMatrixQuestion::getSubtype ( )

Returns the subtype of the matrix question.

Returns
integer The subtype of the matrix question @access public

Reimplemented from SurveyQuestion.

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

References $subtype.

Referenced by checkUserInput(), getWorkingDataFromUserInput(), insertXML(), saveToDb(), and saveUserInput().

+ Here is the caller graph for this function:

◆ getWorkingDataFromUserInput()

& SurveyMatrixQuestion::getWorkingDataFromUserInput (   $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 @access public

Reimplemented from SurveyQuestion.

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

931 {
932 $data = array();
933 foreach ($post_data as $key => $value) {
934 switch ($this->getSubtype()) {
935 case 0:
936 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
937 if (is_array($value)) {
938 foreach ($value as $val) {
939 array_push($data, array("value" => $val, "rowvalue" => $matches[1], "textanswer" => $post_data['matrix_other_' . $this->getId() . '_' . $matches[1]]));
940 }
941 } else {
942 array_push($data, array("value" => $value, "rowvalue" => $matches[1], "textanswer" => $post_data['matrix_other_' . $this->getId() . '_' . $matches[1]]));
943 }
944 }
945 break;
946 case 1:
947 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
948 if (is_array($value)) {
949 foreach ($value as $val) {
950 array_push($data, array("value" => $val, "rowvalue" => $matches[1], "textanswer" => $post_data['matrix_other_' . $this->getId() . '_' . $matches[1]]));
951 }
952 } else {
953 array_push($data, array("value" => $value, "rowvalue" => $matches[1], "textanswer" => $post_data['matrix_other_' . $this->getId() . '_' . $matches[1]]));
954 }
955 }
956 break;
957 }
958 }
959 return $data;
960 }
$data
Definition: storeScorm.php:23

References $data, SurveyQuestion\getId(), and getSubtype().

+ Here is the call graph for this function:

◆ hasBipolarAdjectives()

SurveyMatrixQuestion::hasBipolarAdjectives ( )

Returns TRUE if bipolar adjectives exist.

Returns
boolean TRUE if bipolar adjectives exist, FALSE otherwise

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

1415 {
1416 if ((strlen($this->getBipolarAdjective(0))) && (strlen($this->getBipolarAdjective(1)))) {
1417 return true;
1418 } else {
1419 return false;
1420 }
1421 }
getBipolarAdjective($a_index)
Returns one of the bipolar adjectives.

References getBipolarAdjective().

Referenced by getLayout().

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

◆ hasNeutralColumn()

SurveyMatrixQuestion::hasNeutralColumn ( )

Returns TRUE if a neutral column exists.

Returns
boolean TRUE if a neutral column exists, FALSE otherwise

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

1429 {
1430 for ($i = 0; $i < $this->getColumnCount(); $i++) {
1431 $column = $this->getColumn($i);
1432 if ($column->neutral && strlen($column->title)) {
1433 return true;
1434 }
1435 }
1436 return false;
1437 }
getColumn($index)
Returns the name of a column for a given index.
getColumnCount()
Returns the number of columns.

References $i, getColumn(), and getColumnCount().

Referenced by getLayout().

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

◆ importAdditionalMetadata()

SurveyMatrixQuestion::importAdditionalMetadata (   $a_meta)

Import additional meta data from the question import file.

Usually the meta data section is used to store question elements which are not part of the standard XML schema.

Returns
array $a_meta Array containing the additional meta data @access public

Reimplemented from SurveyQuestion.

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

1227 {
1228 foreach ($a_meta as $key => $value) {
1229 switch ($value["label"]) {
1230 case "column_separators":
1231 $this->setColumnSeparators($value["entry"]);
1232 break;
1233 case "row_separators":
1234 $this->setRowSeparators($value["entry"]);
1235 break;
1236 case "layout":
1237 $this->setLayout($value["entry"]);
1238 break;
1239 case "neutral_column_separator":
1240 $this->setNeutralColumnSeparator($value["entry"]);
1241 break;
1242 }
1243 }
1244 }
setRowSeparators($enable=0)
Enables/Disables separators for the matrix rows.
setColumnSeparators($enable=0)
Enables/Disables separators for the matrix columns.
setNeutralColumnSeparator($enable=0)
Enables/Disables a separator for the neutral column.

References setColumnSeparators(), setLayout(), setNeutralColumnSeparator(), and setRowSeparators().

+ Here is the call graph for this function:

◆ importAdjectives()

SurveyMatrixQuestion::importAdjectives (   $a_data)

Import bipolar adjectives from the question import file.

Returns
array $a_data Array containing the adjectives @access public

Reimplemented from SurveyQuestion.

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

1253 {
1254 $i = 0;
1255 foreach ($a_data as $adjective) {
1256 if (is_numeric($adjective["label"])) {
1257 $this->setBipolarAdjective($adjective["label"], $adjective["text"]);
1258 } else {
1259 $this->setBipolarAdjective($i, $adjective["text"]);
1260 }
1261 $i++;
1262 }
1263 }
setBipolarAdjective($a_index, $a_value)
Sets one of the bipolar adjectives.

References $i, and setBipolarAdjective().

+ Here is the call graph for this function:

◆ importMatrix()

SurveyMatrixQuestion::importMatrix (   $a_data)

Import matrix rows from the question import file.

Returns
array $a_data Array containing the matrix rows @access public

Reimplemented from SurveyQuestion.

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

1272 {
1273 foreach ($a_data as $row) {
1274 $this->addRow($row['title'], $row['other'], $row['label']);
1275 }
1276 }
addRow($a_text, $a_other, $a_label)
Adds a row to the question.

References addRow().

+ Here is the call graph for this function:

◆ importResponses()

SurveyMatrixQuestion::importResponses (   $a_data)

Import response data from the question import file.

Returns
array $a_data Array containing the response data @access public

Reimplemented from SurveyQuestion.

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

1285 {
1286 foreach ($a_data as $id => $data) {
1287 $column = "";
1288 foreach ($data["material"] as $material) {
1289 $column .= $material["text"];
1290 }
1291 $this->columns->addCategory($column, null, (strcmp($data["label"], "neutral") == 0) ? true : false);
1292 }
1293 }

References $data, SurveyQuestion\$id, and SurveyQuestion\$material.

◆ insertXML()

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

Adds the question XML to a given XMLWriter object.

Parameters
object$a_xml_writerThe XMLWriter object
boolean$a_include_headerDetermines wheather or not the XML should be used @access public

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

722 {
723 $attrs = array(
724 "id" => $this->getId(),
725 "title" => $this->getTitle(),
726 "type" => $this->getQuestiontype(),
727 "subtype" => $this->getSubtype(),
728 "obligatory" => $this->getObligatory()
729 );
730 $a_xml_writer->xmlStartTag("question", $attrs);
731
732 $a_xml_writer->xmlElement("description", null, $this->getDescription());
733 $a_xml_writer->xmlElement("author", null, $this->getAuthor());
734 $a_xml_writer->xmlStartTag("questiontext");
735 $this->addMaterialTag($a_xml_writer, $this->getQuestiontext());
736 $a_xml_writer->xmlEndTag("questiontext");
737
738 $a_xml_writer->xmlStartTag("matrix");
739 $a_xml_writer->xmlStartTag("matrixrows");
740 for ($i = 0; $i < $this->getRowCount(); $i++) {
741 $attrs = array(
742 "id" => $i
743 );
744 if (strlen($this->getRow($i)->label)) {
745 $attrs['label'] = $this->getRow($i)->label;
746 }
747 if ($this->getRow($i)->other) {
748 $attrs['other'] = 1;
749 }
750 $a_xml_writer->xmlStartTag("matrixrow", $attrs);
751 $this->addMaterialTag($a_xml_writer, $this->getRow($i)->title);
752 $a_xml_writer->xmlEndTag("matrixrow");
753 }
754 $a_xml_writer->xmlEndTag("matrixrows");
755
756 $a_xml_writer->xmlStartTag("responses");
757 if (strlen($this->getBipolarAdjective(0)) && (strlen($this->getBipolarAdjective(1)))) {
758 $a_xml_writer->xmlStartTag("bipolar_adjectives");
759 $attribs = array(
760 "label" => "0"
761 );
762 $a_xml_writer->xmlElement("adjective", $attribs, $this->getBipolarAdjective(0));
763 $attribs = array(
764 "label" => "1"
765 );
766 $a_xml_writer->xmlElement("adjective", $attribs, $this->getBipolarAdjective(1));
767 $a_xml_writer->xmlEndTag("bipolar_adjectives");
768 }
769 for ($i = 0; $i < $this->getColumnCount(); $i++) {
770 $attrs = array(
771 "id" => $i
772 );
773 if ($this->getColumn($i)->neutral) {
774 $attrs['label'] = 'neutral';
775 }
776 switch ($this->getSubtype()) {
777 case 0:
778 $a_xml_writer->xmlStartTag("response_single", $attrs);
779 break;
780 case 1:
781 $a_xml_writer->xmlStartTag("response_multiple", $attrs);
782 break;
783 }
784 $this->addMaterialTag($a_xml_writer, $this->getColumn($i)->title);
785 switch ($this->getSubtype()) {
786 case 0:
787 $a_xml_writer->xmlEndTag("response_single");
788 break;
789 case 1:
790 $a_xml_writer->xmlEndTag("response_multiple");
791 break;
792 }
793 }
794
795 $a_xml_writer->xmlEndTag("responses");
796 $a_xml_writer->xmlEndTag("matrix");
797
798 if (count($this->material)) {
799 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $this->material["internal_link"], $matches)) {
800 $attrs = array(
801 "label" => $this->material["title"]
802 );
803 $a_xml_writer->xmlStartTag("material", $attrs);
804 $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
805 if (strcmp($matches[1], "") != 0) {
806 $intlink = $this->material["internal_link"];
807 }
808 $a_xml_writer->xmlElement("mattext", null, $intlink);
809 $a_xml_writer->xmlEndTag("material");
810 }
811 }
812
813 $a_xml_writer->xmlStartTag("metadata");
814 $a_xml_writer->xmlStartTag("metadatafield");
815 $a_xml_writer->xmlElement("fieldlabel", null, "column_separators");
816 $a_xml_writer->xmlElement("fieldentry", null, $this->getColumnSeparators());
817 $a_xml_writer->xmlEndTag("metadatafield");
818
819 $a_xml_writer->xmlStartTag("metadatafield");
820 $a_xml_writer->xmlElement("fieldlabel", null, "row_separators");
821 $a_xml_writer->xmlElement("fieldentry", null, $this->getRowSeparators());
822 $a_xml_writer->xmlEndTag("metadatafield");
823
824 $a_xml_writer->xmlStartTag("metadatafield");
825 $a_xml_writer->xmlElement("fieldlabel", null, "neutral_column_separator");
826 $a_xml_writer->xmlElement("fieldentry", null, $this->getNeutralColumnSeparator());
827 $a_xml_writer->xmlEndTag("metadatafield");
828
829 $a_xml_writer->xmlStartTag("metadatafield");
830 $a_xml_writer->xmlElement("fieldlabel", null, "layout");
831 $a_xml_writer->xmlElement("fieldentry", null, serialize($this->getLayout()));
832 $a_xml_writer->xmlEndTag("metadatafield");
833
834 $a_xml_writer->xmlEndTag("metadata");
835
836 $a_xml_writer->xmlEndTag("question");
837 }
getNeutralColumnSeparator()
Gets the separator enable state for the neutral column.
getColumnSeparators()
Gets the separators enable state for the matrix columns.
getRow($a_index)
Returns a specific row.
getRowSeparators()
Gets the separators enable state for the matrix rows.
getDescription()
Gets the description string of the SurveyQuestion object.
getAuthor()
Gets the authors name of the SurveyQuestion object.
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
getTitle()
Gets the title string of the SurveyQuestion object.
addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag=true, $add_mobs=true, $a_attrs=null)
Creates an XML material tag from a plain text or xhtml text.
const IL_INST_ID
Definition: constants.php:38

References $i, SurveyQuestion\addMaterialTag(), SurveyQuestion\getAuthor(), getBipolarAdjective(), getColumn(), getColumnCount(), getColumnSeparators(), SurveyQuestion\getDescription(), SurveyQuestion\getId(), getLayout(), getNeutralColumnSeparator(), SurveyQuestion\getObligatory(), SurveyQuestion\getQuestiontext(), getRow(), getRowCount(), getRowSeparators(), getSubtype(), SurveyQuestion\getTitle(), and IL_INST_ID.

Referenced by toXML().

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

◆ isComplete()

SurveyMatrixQuestion::isComplete ( )

Returns 1 if the question is complete for use.

Returns
integer 1 if the question is complete for use, otherwise 0 @access public

Reimplemented from SurveyQuestion.

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

511 {
512 if (
513 strlen($this->getTitle()) &&
514 strlen($this->getAuthor()) &&
515 strlen($this->getQuestiontext()) &&
516 $this->getColumnCount() &&
517 $this->getRowCount()
518 ) {
519 return 1;
520 } else {
521 return 0;
522 }
523 }

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

+ Here is the call graph for this function:

◆ loadFromDb()

SurveyMatrixQuestion::loadFromDb (   $id)

Loads a SurveyMatrixQuestion object from the database.

Parameters
integer$idThe database id of the matrix question @access public

Reimplemented from SurveyQuestion.

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

443 {
445 $result = $ilDB->queryF(
446 "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",
447 array('integer'),
448 array($id)
449 );
450 if ($result->numRows() == 1) {
451 $data = $ilDB->fetchAssoc($result);
452 $this->setId($data["question_id"]);
453 $this->setTitle($data["title"]);
454 $this->label = $data['label'];
455 $this->setDescription($data["description"]);
456 $this->setObjId($data["obj_fi"]);
457 $this->setAuthor($data["author"]);
458 $this->setOwner($data["owner_fi"]);
459 $this->setQuestiontext(ilRTE::_replaceMediaObjectImageSrc($data["questiontext"], 1));
460 $this->setObligatory($data["obligatory"]);
461 $this->setComplete($data["complete"]);
462 $this->setOriginalId($data["original_id"]);
463 $this->setSubtype($data["subtype"]);
464 $this->setRowSeparators($data["row_separators"]);
465 $this->setNeutralColumnSeparator($data["neutral_column_separator"]);
466 $this->setColumnSeparators($data["column_separators"]);
467 $this->setColumnPlaceholders($data["column_placeholders"]);
468 $this->setLegend($data["legend"]);
469 $this->setSingleLineRowCaption($data["singleline_row_caption"]);
470 $this->setRepeatColumnHeader($data["repeat_column_header"]);
471 $this->setColumnHeaderPosition($data["column_header_position"]);
472 $this->setRandomRows($data["random_rows"]);
473 $this->setColumnOrder($data["column_order"]);
474 $this->setColumnImages($data["column_images"]);
475 $this->setRowImages($data["row_images"]);
476 $this->setBipolarAdjective(0, $data["bipolar_adjective1"]);
477 $this->setBipolarAdjective(1, $data["bipolar_adjective2"]);
478 $this->setLayout($data["layout"]);
479 $this->flushColumns();
480
481 $result = $ilDB->queryF(
482 "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",
483 array('integer'),
484 array($id)
485 );
486 if ($result->numRows() > 0) {
487 while ($data = $ilDB->fetchAssoc($result)) {
488 $this->columns->addCategory($data["title"], $data["other"], $data["neutral"], null, ($data['scale']) ? $data['scale'] : ($data['sequence'] + 1));
489 }
490 }
491
492 $result = $ilDB->queryF(
493 "SELECT * FROM svy_qst_matrixrows WHERE question_fi = %s ORDER BY sequence",
494 array('integer'),
495 array($id)
496 );
497 while ($row = $ilDB->fetchAssoc($result)) {
498 $this->addRow($row["title"], $row['other'], $row['label']);
499 }
500 }
501 parent::loadFromDb($id);
502 }
setSubtype($a_subtype=0)
Sets the subtype of the matrix question.
flushColumns()
Empties the columns list.
setColumnPlaceholders($a_value=0)
Set whether placeholders should be used for the column titles or not.
setLegend($a_value=0)
Set whether the legend should be shown or not.
setQuestiontext($questiontext="")
Sets the questiontext of the SurveyQuestion object.
setId($id=-1)
Sets the id of the SurveyQuestion object.
setAuthor($author="")
Sets the authors name of the SurveyQuestion object.
setDescription($description="")
Sets the description string of the SurveyQuestion object.
setObjId($obj_id=0)
Set the reference id of the container object.
setOriginalId($original_id)
setComplete($a_complete)
Sets the complete state of the question.
setOwner($owner="")
Sets the creator/owner ID of the SurveyQuestion object.
setTitle($title="")
Sets the title string of the SurveyQuestion object.
setObligatory($obligatory=1)
Sets the obligatory state of the question.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...

References $data, $db, SurveyQuestion\$id, $ilDB, $result, ilRTE\_replaceMediaObjectImageSrc(), addRow(), flushColumns(), getAdditionalTableName(), SurveyQuestion\setAuthor(), setBipolarAdjective(), setColumnHeaderPosition(), setColumnImages(), setColumnOrder(), setColumnPlaceholders(), setColumnSeparators(), SurveyQuestion\setComplete(), SurveyQuestion\setDescription(), SurveyQuestion\setId(), setLayout(), setLegend(), setNeutralColumnSeparator(), SurveyQuestion\setObjId(), SurveyQuestion\setObligatory(), SurveyQuestion\setOriginalId(), SurveyQuestion\setOwner(), SurveyQuestion\setQuestiontext(), setRandomRows(), setRepeatColumnHeader(), setRowImages(), setRowSeparators(), setSingleLineRowCaption(), setSubtype(), and SurveyQuestion\setTitle().

+ Here is the call graph for this function:

◆ moveRowDown()

SurveyMatrixQuestion::moveRowDown (   $index)

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

320 {
321 $this->rows->moveCategoryDown($index);
322 }

References $index.

◆ moveRowUp()

SurveyMatrixQuestion::moveRowUp (   $index)

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

315 {
316 $this->rows->moveCategoryUp($index);
317 }

References $index.

◆ removeColumn()

SurveyMatrixQuestion::removeColumn (   $index)

Removes a column from the list of columns.

Parameters
integer$indexThe index of the column to be removed @access public
See also
$columns

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

182 {
183 $this->columns->removeCategory($index);
184 }

References $index.

◆ removeColumns()

SurveyMatrixQuestion::removeColumns (   $array)

Removes many columns from the list of columns.

Parameters
array$arrayAn array containing the index positions of the columns to be removed @access public
See also
$columns

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

194 {
195 $this->columns->removeCategories($array);
196 }

◆ removeColumnWithName()

SurveyMatrixQuestion::removeColumnWithName (   $name)

Removes a column from the list of columns.

Parameters
string$nameThe name of the column to be removed @access public
See also
$columns

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

206 {
207 $this->columns->removeCategoryWithName($name);
208 }

References $name.

◆ removeRow()

SurveyMatrixQuestion::removeRow (   $index)

Removes a row.

Parameters
integer$indexThe index of the row to be removed

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

342 {
343 $this->rows->removeCategory($index);
344 }

References $index.

◆ removeRows()

SurveyMatrixQuestion::removeRows (   $array)

Removes rows from the question.

Parameters
array$arrayAn array containing the index positions of the rows to be removed @access public
See also
$rows

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

332 {
333 $this->rows->removeCategories($array);
334 }

◆ saveBipolarAdjectives()

SurveyMatrixQuestion::saveBipolarAdjectives (   $adjective1,
  $adjective2 
)

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

583 {
585
586 $affectedRows = $ilDB->manipulateF(
587 "UPDATE " . $this->getAdditionalTableName() . " SET bipolar_adjective1 = %s, bipolar_adjective2 = %s WHERE question_fi = %s",
588 array('text', 'text', 'integer'),
589 array((strlen($adjective1)) ? $adjective1 : null, (strlen($adjective2)) ? $adjective2 : null, $this->getId())
590 );
591 }

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

+ Here is the call graph for this function:

◆ saveColumnsToDb()

SurveyMatrixQuestion::saveColumnsToDb (   $original_id = "")

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

637 {
639
640 // save columns
641 $question_id = $this->getId();
642 if (strlen($original_id)) {
643 $question_id = $original_id;
644 }
645
646 // delete existing column relations
647 $affectedRows = $ilDB->manipulateF(
648 "DELETE FROM svy_variable WHERE question_fi = %s",
649 array('integer'),
650 array($question_id)
651 );
652 // create new column relations
653 for ($i = 0; $i < $this->getColumnCount(); $i++) {
654 $cat = $this->getColumn($i);
655 $column_id = $this->saveColumnToDb($cat->title, $cat->neutral);
656 $next_id = $ilDB->nextId('svy_variable');
657 $affectedRows = $ilDB->manipulateF(
658 "INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, other, sequence, scale, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
659 array('integer','integer','integer','float','integer','integer', 'integer','integer'),
660 array($next_id, $column_id, $question_id, ($i + 1), $cat->other, $i, ($cat->scale > 0) ? $cat->scale : null, time())
661 );
662 }
663 $this->saveCompletionStatus($original_id);
664 }
saveColumnToDb($columntext, $neutral=0)
Saves a column to the database.
saveCompletionStatus($original_id="")
Saves the complete flag to the database.

References $db, $i, $ilDB, getColumn(), getColumnCount(), SurveyQuestion\getId(), saveColumnToDb(), and SurveyQuestion\saveCompletionStatus().

Referenced by saveToDb(), and syncWithOriginal().

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

◆ saveColumnToDb()

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

Saves a column to the database.

Parameters
string$columntextThe text of the column
Returns
integer The database ID of the column @access public
See also
$columns

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

602 {
605
606 $result = $ilDB->queryF(
607 "SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
608 array('text', 'text', 'integer'),
609 array($columntext, $neutral, $ilUser->getId())
610 );
611 $insert = false;
612 $returnvalue = "";
613 if ($result->numRows()) {
614 $insert = true;
615 while ($row = $ilDB->fetchAssoc($result)) {
616 if (strcmp($row["title"], $columntext) == 0) {
617 $returnvalue = $row["category_id"];
618 $insert = false;
619 }
620 }
621 } else {
622 $insert = true;
623 }
624 if ($insert) {
625 $next_id = $ilDB->nextId('svy_category');
626 $affectedRows = $ilDB->manipulateF(
627 "INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, neutral, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
628 array('integer', 'text', 'text', 'integer', 'text', 'integer'),
629 array($next_id, $columntext, 0, $ilUser->getId(), $neutral, time())
630 );
631 $returnvalue = $next_id;
632 }
633 return $returnvalue;
634 }

References $db, $ilDB, $ilUser, $result, and $user.

Referenced by saveColumnsToDb().

+ Here is the caller graph for this function:

◆ saveLayout()

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

Saves the layout of a matrix question.

Parameters
double$percent_rowThe width in percent for the matrix rows
double$percent_columnsThe width in percent for the matrix columns
double$percent_bipolar_adjective1The width in percent for the first bipolar adjective
double$percent_bipolar_adjective2The width in percent for the second bipolar adjective
Returns
void

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

1343 {
1344 $ilDB = $this->db;
1345
1346 $layout = array(
1347 "percent_row" => $percent_row,
1348 "percent_columns" => $percent_columns,
1349 "percent_bipolar_adjective1" => $percent_bipolar_adjective1,
1350 "percent_bipolar_adjective2" => $percent_bipolar_adjective2,
1351 "percent_neutral" => $percent_neutral
1352 );
1353 $affectedRows = $ilDB->manipulateF(
1354 "UPDATE " . $this->getAdditionalTableName() . " SET layout = %s WHERE question_fi = %s",
1355 array('text', 'integer'),
1356 array(serialize($layout), $this->getId())
1357 );
1358 }

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

+ Here is the call graph for this function:

◆ savePhrase()

SurveyMatrixQuestion::savePhrase (   $title)

Saves a set of columns to a default phrase.

Parameters
array$phrasesThe database ids of the seleted phrases
string$titleThe title of the default phrase @access public

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

871 {
874
875 $next_id = $ilDB->nextId('svy_phrase');
876 $affectedRows = $ilDB->manipulateF(
877 "INSERT INTO svy_phrase (phrase_id, title, defaultvalue, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
878 array('integer','text','text','integer','integer'),
879 array($next_id, $title, 1, $ilUser->getId(), time())
880 );
881 $phrase_id = $next_id;
882
883 $counter = 1;
884 foreach ($_SESSION['save_phrase_data'] as $data) {
885 $next_id = $ilDB->nextId('svy_category');
886 $affectedRows = $ilDB->manipulateF(
887 "INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, tstamp, neutral) VALUES (%s, %s, %s, %s, %s, %s)",
888 array('integer','text','text','integer','integer','text'),
889 array($next_id, $data['answer'], 1, $ilUser->getId(), time(), $data['neutral'])
890 );
891 $category_id = $next_id;
892 $next_id = $ilDB->nextId('svy_phrase_cat');
893 $affectedRows = $ilDB->manipulateF(
894 "INSERT INTO svy_phrase_cat (phrase_category_id, phrase_fi, category_fi, sequence, other, scale) VALUES (%s, %s, %s, %s, %s, %s)",
895 array('integer', 'integer', 'integer','integer', 'integer', 'integer'),
896 array($next_id, $phrase_id, $category_id, $counter, ($data['other']) ? 1 : 0, $data['scale'])
897 );
898 $counter++;
899 }
900 }
$_SESSION["AccountId"]

References $_SESSION, $data, $db, $ilDB, $ilUser, SurveyQuestion\$title, and $user.

◆ saveRowsToDb()

SurveyMatrixQuestion::saveRowsToDb (   $original_id = "")

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

667 {
669
670 // save rows
671 $question_id = $this->getId();
672 if (strlen($original_id)) {
673 $question_id = $original_id;
674 }
675
676 // delete existing rows
677 $affectedRows = $ilDB->manipulateF(
678 "DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
679 array('integer'),
680 array($question_id)
681 );
682 // create new rows
683 for ($i = 0; $i < $this->getRowCount(); $i++) {
684 $row = $this->getRow($i);
685 $next_id = $ilDB->nextId('svy_qst_matrixrows');
686 $affectedRows = $ilDB->manipulateF(
687 "INSERT INTO svy_qst_matrixrows (id_svy_qst_matrixrows, title, label, other, sequence, question_fi) VALUES (%s, %s, %s, %s, %s, %s)",
688 array('integer','text','text','integer','integer','integer'),
689 array($next_id, $row->title, $row->label, ($row->other) ? 1 : 0, $i, $question_id)
690 );
691 }
692 $this->saveCompletionStatus($original_id);
693 }

References $db, $i, $ilDB, SurveyQuestion\getId(), getRow(), getRowCount(), and SurveyQuestion\saveCompletionStatus().

Referenced by saveToDb(), and syncWithOriginal().

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

◆ saveToDb()

SurveyMatrixQuestion::saveToDb (   $original_id = null,
  $withanswers = true 
)

Saves a SurveyMatrixQuestion object to a database.

@access public

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

531 {
533
534 $affectedRows = parent::saveToDb($original_id);
535
536 if ($affectedRows == 1) {
537 $affectedRows = $ilDB->manipulateF(
538 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
539 array('integer'),
540 array($this->getId())
541 );
542 $affectedRows = $ilDB->manipulateF(
543 "INSERT INTO " . $this->getAdditionalTableName() . " (
544 question_fi, subtype, column_separators, row_separators, neutral_column_separator,column_placeholders,
545 legend, singleline_row_caption, repeat_column_header, column_header_position, random_rows,
546 column_order, column_images, row_images, bipolar_adjective1, bipolar_adjective2, layout, tstamp)
547 VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
548 array(
549 'integer', 'integer', 'text', 'text', 'text', 'integer', 'text', 'text', 'text',
550 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer'
551 ),
552 array(
553 $this->getId(),
554 $this->getSubtype(),
555 $this->getColumnSeparators(),
556 $this->getRowSeparators(),
558 $this->getColumnPlaceholders(),
559 $this->getLegend(),
561 $this->getRepeatColumnHeader(),
563 $this->getRandomRows(),
564 $this->getColumnOrder(),
565 $this->getColumnImages(),
566 $this->getRowImages(),
567 $this->getBipolarAdjective(0),
568 $this->getBipolarAdjective(1),
569 serialize($this->getLayout()),
570 time()
571 )
572 );
573
574 // saving material uris in the database
575 $this->saveMaterial();
576
577 $this->saveColumnsToDb();
578 $this->saveRowsToDb();
579 }
580 }
getLegend()
Get whether the legend should be shown or not.
getColumnPlaceholders()
Get whether placeholders should be used for the column titles or not.
saveMaterial()
save material to db

References $db, $ilDB, getAdditionalTableName(), getBipolarAdjective(), getColumnHeaderPosition(), getColumnImages(), getColumnOrder(), getColumnPlaceholders(), getColumnSeparators(), SurveyQuestion\getId(), getLayout(), getLegend(), getNeutralColumnSeparator(), getRandomRows(), getRepeatColumnHeader(), getRowImages(), getRowSeparators(), getSingleLineRowCaption(), getSubtype(), saveColumnsToDb(), SurveyQuestion\saveMaterial(), and saveRowsToDb().

+ Here is the call graph for this function:

◆ saveUserInput()

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

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

1013 {
1014 $ilDB = $this->db;
1015
1016 $answer_data = array();
1017
1018 // gather data
1019 switch ($this->getSubtype()) {
1020 case 0:
1021 foreach ($post_data as $key => $value) {
1022 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
1023 if (strlen($value)) {
1024 $other_value = (array_key_exists('matrix_other_' . $this->getId() . '_' . $matches[1], $post_data))
1025 ? $this->stripSlashesAddSpaceFallback($post_data['matrix_other_' . $this->getId() . '_' . $matches[1]])
1026 : null;
1027 $answer_data[] = array("value" => $value,
1028 "textanswer" => $other_value,
1029 "rowvalue" => $matches[1]);
1030 }
1031 }
1032 }
1033 break;
1034
1035 case 1:
1036 foreach ($post_data as $key => $value) {
1037 if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
1038 $other_value = (array_key_exists('matrix_other_' . $this->getId() . '_' . $matches[1], $post_data))
1039 ? $this->stripSlashesAddSpaceFallback($post_data['matrix_other_' . $this->getId() . '_' . $matches[1]])
1040 : null;
1041 foreach ($value as $checked) {
1042 $answer_data[] = array("value" => $checked,
1043 "textanswer" => $other_value,
1044 "rowvalue" => $matches[1]);
1045 }
1046 }
1047 }
1048 break;
1049 }
1050
1051 if ($a_return) {
1052 return $answer_data;
1053 }
1054
1055 // #16387 - only if any input
1056 if (sizeof($answer_data)) {
1057 // save data
1058 foreach ($answer_data as $item) {
1059 $next_id = $ilDB->nextId('svy_answer');
1060 #20216
1061 $fields = array();
1062 $fields['answer_id'] = array("integer", $next_id);
1063 $fields['question_fi'] = array("integer", $this->getId());
1064 $fields['active_fi'] = array("integer", $active_id);
1065 $fields['value'] = array("float", $item['value']);
1066 $fields['textanswer'] = array("clob", $item['textanswer']);
1067 $fields['rowvalue'] = array("integer", $item['rowvalue']);
1068 $fields['tstamp'] = array("integer", time());
1069
1070 $affectedRows = $ilDB->insert("svy_answer", $fields);
1071 }
1072 }
1073 }
stripSlashesAddSpaceFallback($a_str)
Strip slashes with add space fallback, see https://mantis.ilias.de/view.php?id=19727 and https://mant...

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

+ Here is the call graph for this function:

◆ setBipolarAdjective()

SurveyMatrixQuestion::setBipolarAdjective (   $a_index,
  $a_value 
)

Sets one of the bipolar adjectives.

Parameters
integer$a_indexThe number of the bipolar adjective (0 for the first and 1 for the second adjective)
string$a_valueThe text of the bipolar adjective @access public

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

375 {
376 switch ($a_index) {
377 case 1:
378 $this->bipolar_adjective2 = $a_value;
379 break;
380 case 0:
381 default:
382 $this->bipolar_adjective1 = $a_value;
383 break;
384 }
385 }

Referenced by importAdjectives(), and loadFromDb().

+ Here is the caller graph for this function:

◆ setColumnHeaderPosition()

SurveyMatrixQuestion::setColumnHeaderPosition (   $a_value)

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

1500 {
1501 $this->columnHeaderPosition = $a_value;
1502 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setColumnImages()

SurveyMatrixQuestion::setColumnImages (   $a_value = 0)

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

1530 {
1531 $this->columnImages = ($a_value) ? 1 : 0;
1532 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setColumnOrder()

SurveyMatrixQuestion::setColumnOrder (   $a_value)

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

1520 {
1521 $this->columnOrder = $a_value;
1522 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setColumnPlaceholders()

SurveyMatrixQuestion::setColumnPlaceholders (   $a_value = 0)

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

Parameters
integer$a_value1 for placeholders, 0 otherwise

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

1445 {
1446 $this->columnPlaceholders = ($a_value) ? 1 : 0;
1447 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setColumnSeparators()

SurveyMatrixQuestion::setColumnSeparators (   $enable = 0)

Enables/Disables separators for the matrix columns.

Parameters
integer$enable1 if the separators should be enabled, 0 otherwise @access public

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

1135 {
1136 switch ($enable) {
1137 case 1:
1138 $this->columnSeparators = 1;
1139 break;
1140 case 0:
1141 default:
1142 $this->columnSeparators = 0;
1143 break;
1144 }
1145 }

Referenced by importAdditionalMetadata(), and loadFromDb().

+ Here is the caller graph for this function:

◆ setLayout()

SurveyMatrixQuestion::setLayout (   $layout)

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

1401 {
1402 if (is_array($layout)) {
1403 $this->layout = $layout;
1404 } else {
1405 $this->layout = unserialize($layout);
1406 }
1407 }

References $layout.

Referenced by importAdditionalMetadata(), and loadFromDb().

+ Here is the caller graph for this function:

◆ setLegend()

SurveyMatrixQuestion::setLegend (   $a_value = 0)

Set whether the legend should be shown or not.

Parameters
integer$a_valueShow legend

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

1465 {
1466 $this->legend = ($a_value) ? 1 : 0;
1467 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setNeutralColumnSeparator()

SurveyMatrixQuestion::setNeutralColumnSeparator (   $enable = 0)

Enables/Disables a separator for the neutral column.

Parameters
integer$enable1 if the separator should be enabled, 0 otherwise @access public

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

1195 {
1196 switch ($enable) {
1197 case 1:
1198 $this->neutralColumnSeparator = 1;
1199 break;
1200 case 0:
1201 default:
1202 $this->neutralColumnSeparator = 0;
1203 break;
1204 }
1205 }

Referenced by importAdditionalMetadata(), and loadFromDb().

+ Here is the caller graph for this function:

◆ setRandomRows()

SurveyMatrixQuestion::setRandomRows (   $a_value = 0)

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

1510 {
1511 $this->randomRows = ($a_value) ? 1 : 0;
1512 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setRepeatColumnHeader()

SurveyMatrixQuestion::setRepeatColumnHeader (   $a_value = 0)

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

1490 {
1491 $this->repeatColumnHeader = ($a_value) ? 1 : 0;
1492 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setRowImages()

SurveyMatrixQuestion::setRowImages (   $a_value = 0)

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

1540 {
1541 $this->rowImages = ($a_value) ? 1 : 0;
1542 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setRowSeparators()

SurveyMatrixQuestion::setRowSeparators (   $enable = 0)

Enables/Disables separators for the matrix rows.

Parameters
integer$enable1 if the separators should be enabled, 0 otherwise @access public

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

1165 {
1166 switch ($enable) {
1167 case 1:
1168 $this->rowSeparators = 1;
1169 break;
1170 case 0:
1171 default:
1172 $this->rowSeparators = 0;
1173 break;
1174 }
1175 }

Referenced by importAdditionalMetadata(), and loadFromDb().

+ Here is the caller graph for this function:

◆ setSingleLineRowCaption()

SurveyMatrixQuestion::setSingleLineRowCaption (   $a_value = 0)

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

1480 {
1481 $this->singleLineRowCaption = ($a_value) ? 1 : 0;
1482 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setSubtype()

SurveyMatrixQuestion::setSubtype (   $a_subtype = 0)

Sets the subtype of the matrix question.

Returns
integer $a_subtype The subtype of the matrix question @access public

Reimplemented from SurveyQuestion.

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

1111 {
1112 switch ($a_subtype) {
1113 case 1:
1114 case 2:
1115 case 3:
1116 case 4:
1117 case 5:
1118 case 6:
1119 $this->subtype = $a_subtype;
1120 break;
1121 case 0:
1122 default:
1123 $this->subtype = 0;
1124 break;
1125 }
1126 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ syncWithOriginal()

SurveyMatrixQuestion::syncWithOriginal ( )

Reimplemented from SurveyQuestion.

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

840 {
841 if ($this->getOriginalId()) {
842 parent::syncWithOriginal();
843 $this->saveColumnsToDb($this->getOriginalId());
844 $this->saveRowsToDb($this->getOriginalId());
845 }
846 }

References SurveyQuestion\getOriginalId(), saveColumnsToDb(), and saveRowsToDb().

+ Here is the call graph for this function:

◆ toXML()

SurveyMatrixQuestion::toXML (   $a_include_header = true,
  $obligatory_state = "" 
)

Returns an xml representation of the question.

Returns
string The xml representation of the question @access public

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

702 {
703 $a_xml_writer = new ilXmlWriter;
704 $a_xml_writer->xmlHeader();
705 $this->insertXML($a_xml_writer, $a_include_header, $obligatory_state);
706 $xml = $a_xml_writer->xmlDumpMem(false);
707 if (!$a_include_header) {
708 $pos = strpos($xml, "?>");
709 $xml = substr($xml, $pos + 2);
710 }
711 return $xml;
712 }
insertXML(&$a_xml_writer, $a_include_header=true)
Adds the question XML to a given XMLWriter object.
XML writer class.
xmlHeader()
Writes xml header @access public.
$xml
Definition: metadata.php:332

References $xml, insertXML(), and ilXmlWriter\xmlHeader().

+ Here is the call graph for this function:

◆ usableForPrecondition()

SurveyMatrixQuestion::usableForPrecondition ( )

Returns if the question is usable for preconditions.

Returns
boolean TRUE if the question is usable for a precondition, FALSE otherwise @access public

Reimplemented from SurveyQuestion.

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

1302 {
1303 return false;
1304 }

Field Documentation

◆ $bipolar_adjective1

SurveyMatrixQuestion::$bipolar_adjective1

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

◆ $bipolar_adjective2

SurveyMatrixQuestion::$bipolar_adjective2

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

◆ $columnHeaderPosition

SurveyMatrixQuestion::$columnHeaderPosition

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

◆ $columnImages

SurveyMatrixQuestion::$columnImages

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

◆ $columnOrder

SurveyMatrixQuestion::$columnOrder

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

◆ $columnPlaceholders

SurveyMatrixQuestion::$columnPlaceholders

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

◆ $columns

SurveyMatrixQuestion::$columns

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

Referenced by getColumns().

◆ $columnSeparators

SurveyMatrixQuestion::$columnSeparators

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

◆ $db

◆ $layout

SurveyMatrixQuestion::$layout

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

Referenced by getLayout(), saveLayout(), and setLayout().

◆ $legend

SurveyMatrixQuestion::$legend

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

◆ $neutralColumnSeparator

SurveyMatrixQuestion::$neutralColumnSeparator

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

◆ $openRows

SurveyMatrixQuestion::$openRows

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

◆ $randomRows

SurveyMatrixQuestion::$randomRows

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

◆ $repeatColumnHeader

SurveyMatrixQuestion::$repeatColumnHeader

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

◆ $rowImages

SurveyMatrixQuestion::$rowImages

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

◆ $rows

SurveyMatrixQuestion::$rows

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

Referenced by getRows().

◆ $rowSeparators

SurveyMatrixQuestion::$rowSeparators

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

◆ $singleLineRowCaption

SurveyMatrixQuestion::$singleLineRowCaption

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

◆ $subtype

SurveyMatrixQuestion::$subtype

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

Referenced by getSubtype().

◆ $user

SurveyMatrixQuestion::$user
protected

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

Referenced by addPhrase(), saveColumnToDb(), and savePhrase().


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