ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 

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
 
 $tpl
 
 $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
 

Additional Inherited Members

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

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
Version
$Id$

Definition at line 35 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 public

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

References SurveyQuestion\$author, SurveyQuestion\$description, $DIC, SurveyQuestion\$owner, SurveyQuestion\$questiontext, SurveyQuestion\$title, columns, rows, and user().

169  {
170  global $DIC;
171 
172  $this->user = $DIC->user();
173  $this->db = $DIC->database();
174  parent::__construct($title, $description, $author, $questiontext, $owner);
175 
176  $this->subtype = 0;
177  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
178  $this->columns = new SurveyCategories();
179  $this->rows = new SurveyCategories();
180  $this->bipolar_adjective1 = "";
181  $this->bipolar_adjective2 = "";
182  $this->rowSeparators = 0;
183  $this->columnSeparators = 0;
184  $this->neutralColumnSeparator = 1;
185  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
Class SurveyCategories.
Play around with inserting and removing rows and columns
Remove unnecessary rows
+ 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 public

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

References $db, $ilDB, $ilUser, $result, $row, $user, array, and columns.

419  {
421  $ilDB = $this->db;
422 
423  $result = $ilDB->queryF(
424  "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",
425  array('integer', 'integer', 'integer'),
426  array($phrase_id, 0, $ilUser->getId())
427  );
428  while ($row = $ilDB->fetchAssoc($result)) {
429  $neutral = $row["neutral"];
430  if (($row["defaultvalue"] == 1) && ($row["owner_fi"] == 0)) {
431  $this->columns->addCategory($this->lng->txt($row["title"]), 0, $neutral);
432  } else {
433  $this->columns->addCategory($row["title"], 0, $neutral);
434  }
435  }
436  }
$result
Play around with inserting and removing rows and columns
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB

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

References rows.

Referenced by importMatrix(), and loadFromDb().

302  {
303  $this->rows->addCategory($a_text, $a_other, 0, $a_label);
304  }
Remove unnecessary rows
+ 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 312 of file class.SurveyMatrixQuestion.php.

References rows.

313  {
314  $this->rows->addCategoryAtPosition($a_text, $a_position, $a_other);
315  }
Remove unnecessary rows

◆ addStandardNumbers()

SurveyMatrixQuestion::addStandardNumbers (   $lower_limit,
  $upper_limit 
)

Adds standard numbers as columns.

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

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

References $i, and columns.

884  {
885  for ($i = $lower_limit; $i <= $upper_limit; $i++) {
886  $this->columns->addCategory($i);
887  }
888  }
Play around with inserting and removing rows and columns
$i
Definition: disco.tpl.php:19

◆ 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 public

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

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

999  {
1000  if (!$this->getObligatory($survey_id)) {
1001  return "";
1002  }
1003  switch ($this->getSubtype()) {
1004  case 0:
1005  $counter = 0;
1006  foreach ($post_data as $key => $value) {
1007  if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
1008  if (array_key_exists('matrix_other_' . $this->getId() . "_" . $matches[1], $post_data) && strlen($post_data['matrix_other_' . $this->getId() . "_" . $matches[1]]) == 0) {
1009  return $this->lng->txt("question_mr_no_other_answer");
1010  }
1011  $counter++;
1012  }
1013  }
1014  if ($counter != $this->getRowCount()) {
1015  return $this->lng->txt("matrix_question_radio_button_not_checked");
1016  }
1017  break;
1018  case 1:
1019  $counter = 0;
1020  foreach ($post_data as $key => $value) {
1021  if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
1022  if (array_key_exists('matrix_other_' . $this->getId() . "_" . $matches[1], $post_data) && strlen($post_data['matrix_other_' . $this->getId() . "_" . $matches[1]]) == 0) {
1023  return $this->lng->txt("question_mr_no_other_answer");
1024  }
1025  $counter++;
1026  if ((!is_array($value)) || (count($value) < 1)) {
1027  return $this->lng->txt("matrix_question_checkbox_not_checked");
1028  }
1029  }
1030  }
1031  if ($counter != $this->getRowCount()) {
1032  return $this->lng->txt("matrix_question_checkbox_not_checked");
1033  }
1034  break;
1035  }
1036  return "";
1037  }
getObligatory($survey_id="")
Gets the obligatory state of the question.
$counter
getId()
Gets the id of the SurveyQuestion object.
getSubtype()
Returns the subtype of the matrix question.
$key
Definition: croninfo.php:18
getRowCount()
Returns the number of rows in the question.
+ 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 public

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

References $db, $ilDB, and array.

1109  {
1110  parent::deleteAdditionalTableData($question_id);
1111 
1112  $ilDB = $this->db;
1113  $affectedRows = $ilDB->manipulateF(
1114  "DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
1115  array('integer'),
1116  array($question_id)
1117  );
1118  }
Create styles array
The data for the language used.
global $ilDB

◆ flushColumns()

SurveyMatrixQuestion::flushColumns ( )

Empties the columns list.

public

See also
$columns

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

References columns.

Referenced by loadFromDb().

281  {
282  $this->columns->flushCategories();
283  }
Play around with inserting and removing rows and columns
+ Here is the caller graph for this function:

◆ flushRows()

SurveyMatrixQuestion::flushRows ( )

Empties the row list.

public

See also
$rows

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

References rows.

324  {
325  $this->rows = new SurveyCategories();
326  }
Class SurveyCategories.
Remove unnecessary rows

◆ getAdditionalTableName()

SurveyMatrixQuestion::getAdditionalTableName ( )

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

Returns
string The additional table name public

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

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

947  {
948  return "svy_qst_matrix";
949  }
+ 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 public

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

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

379  {
380  switch ($a_index) {
381  case 1:
382  return (strlen($this->bipolar_adjective2)) ? $this->bipolar_adjective2 : null;
383  break;
384  case 0:
385  default:
386  return (strlen($this->bipolar_adjective1)) ? $this->bipolar_adjective1 : null;
387  break;
388  }
389  return null;
390  }
+ 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 public
See also
$columns

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

References $index, and columns.

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

252  {
253  return $this->columns->getCategory($index);
254  }
$index
Definition: metadata.php:60
Play around with inserting and removing rows and columns
+ Here is the caller graph for this function:

◆ getColumnCount()

SurveyMatrixQuestion::getColumnCount ( )

Returns the number of columns.

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

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

References columns.

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

195  {
196  return $this->columns->getCategoryCount();
197  }
Play around with inserting and removing rows and columns
+ Here is the caller graph for this function:

◆ getColumnForScale()

SurveyMatrixQuestion::getColumnForScale (   $scale)

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

References columns.

257  {
258  return $this->columns->getCategoryForScale($scale);
259  }
Play around with inserting and removing rows and columns

◆ getColumnHeaderPosition()

SurveyMatrixQuestion::getColumnHeaderPosition ( )

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

Referenced by saveToDb().

1533  {
1534  return ($this->columnHeaderPosition) ? $this->columnHeaderPosition : 0;
1535  }
+ Here is the caller graph for this function:

◆ getColumnImages()

SurveyMatrixQuestion::getColumnImages ( )

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

Referenced by saveToDb().

1563  {
1564  return ($this->columnImages) ? 1 : 0;
1565  }
+ 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 public
See also
$columns

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

References $name, and columns.

269  {
270  return $this->columns->getCategoryIndex($name);
271  }
if($format !==null) $name
Definition: metadata.php:146
Play around with inserting and removing rows and columns

◆ getColumnOrder()

SurveyMatrixQuestion::getColumnOrder ( )

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

Referenced by saveToDb().

1553  {
1554  return ($this->columnOrder) ? $this->columnOrder : 0;
1555  }
+ 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 1482 of file class.SurveyMatrixQuestion.php.

Referenced by saveToDb().

1483  {
1484  return ($this->columnPlaceholders) ? 1 : 0;
1485  }
+ Here is the caller graph for this function:

◆ getColumns()

SurveyMatrixQuestion::getColumns ( )

Return the columns.

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

References $columns.

239  {
240  return $this->columns;
241  }

◆ getColumnSeparators()

SurveyMatrixQuestion::getColumnSeparators ( )

Gets the separators enable state for the matrix columns.

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

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

Referenced by insertXML(), and saveToDb().

1181  {
1182  return ($this->columnSeparators) ? 1 : 0;
1183  }
+ Here is the caller graph for this function:

◆ getLayout()

SurveyMatrixQuestion::getLayout ( )

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

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

Referenced by insertXML(), and saveToDb().

1389  {
1390  if (!is_array($this->layout) || count($this->layout) == 0) {
1391  if ($this->hasBipolarAdjectives() && $this->hasNeutralColumn()) {
1392  $this->layout = array(
1393  "percent_row" => 30,
1394  "percent_columns" => 40,
1395  "percent_bipolar_adjective1" => 10,
1396  "percent_bipolar_adjective2" => 10,
1397  "percent_neutral" => 10
1398  );
1399  } elseif ($this->hasBipolarAdjectives()) {
1400  $this->layout = array(
1401  "percent_row" => 30,
1402  "percent_columns" => 50,
1403  "percent_bipolar_adjective1" => 10,
1404  "percent_bipolar_adjective2" => 10,
1405  "percent_neutral" => 0
1406  );
1407  } elseif ($this->hasNeutralColumn()) {
1408  $this->layout = array(
1409  "percent_row" => 30,
1410  "percent_columns" => 50,
1411  "percent_bipolar_adjective1" => 0,
1412  "percent_bipolar_adjective2" => 0,
1413  "percent_neutral" => 20
1414  );
1415  } else {
1416  $this->layout = array(
1417  "percent_row" => 30,
1418  "percent_columns" => 70,
1419  "percent_bipolar_adjective1" => 0,
1420  "percent_bipolar_adjective2" => 0,
1421  "percent_neutral" => 0
1422  );
1423  }
1424  }
1425  return $this->layout;
1426  }
hasBipolarAdjectives()
Returns TRUE if bipolar adjectives exist.
hasNeutralColumn()
Returns TRUE if a neutral column exists.
Create styles array
The data for the language used.
+ 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 1502 of file class.SurveyMatrixQuestion.php.

Referenced by saveToDb().

1503  {
1504  return ($this->legend) ? 1 : 0;
1505  }
+ Here is the caller graph for this function:

◆ getNeutralColumnSeparator()

SurveyMatrixQuestion::getNeutralColumnSeparator ( )

Gets the separator enable state for the neutral column.

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

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

Referenced by insertXML(), and saveToDb().

1241  {
1242  return ($this->neutralColumnSeparator) ? 1 : 0;
1243  }
+ 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 public

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

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

1352  {
1353  include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
1354  $step3 = new ilSelectInputGUI($title, $variable);
1355  $options = $this->getPreconditionOptions();
1356  $step3->setOptions($options);
1357  $step3->setValue($default);
1358  return $step3;
1359  }
This class represents a selection list property in a property form.
getPreconditionOptions()
Returns the options for preconditions.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ 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 public

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

1341  {
1342  return $value;
1343  }

◆ 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 public

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

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

446  {
447  $ilDB = $this->db;
448 
449  $result = $ilDB->queryF(
450  "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",
451  array('integer'),
452  array($id)
453  );
454  if ($result->numRows() == 1) {
455  return $ilDB->fetchAssoc($result);
456  } else {
457  return array();
458  }
459  }
$result
Create styles array
The data for the language used.
global $ilDB
getAdditionalTableName()
Returns the name of the additional question data table in the database.
+ 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 public

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

936  {
937  return "SurveyMatrixQuestion";
938  }

◆ getRandomRows()

SurveyMatrixQuestion::getRandomRows ( )

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

Referenced by saveToDb().

1543  {
1544  return ($this->randomRows) ? 1 : 0;
1545  }
+ Here is the caller graph for this function:

◆ getRepeatColumnHeader()

SurveyMatrixQuestion::getRepeatColumnHeader ( )

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

Referenced by saveToDb().

1523  {
1524  return ($this->repeatColumnHeader) ? 1 : 0;
1525  }
+ 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 public

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

References rows.

Referenced by insertXML(), and saveRowsToDb().

335  {
336  return $this->rows->getCategory($a_index);
337  }
Remove unnecessary rows
+ 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 public

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

References rows.

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

292  {
293  return $this->rows->getCategoryCount();
294  }
Remove unnecessary rows
+ Here is the caller graph for this function:

◆ getRowImages()

SurveyMatrixQuestion::getRowImages ( )

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

Referenced by saveToDb().

1573  {
1574  return ($this->rowImages) ? 1 : 0;
1575  }
+ Here is the caller graph for this function:

◆ getRows()

SurveyMatrixQuestion::getRows ( )

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

References $rows.

1578  {
1579  return $this->rows;
1580  }

◆ getRowSeparators()

SurveyMatrixQuestion::getRowSeparators ( )

Gets the separators enable state for the matrix rows.

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

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

Referenced by insertXML(), and saveToDb().

1211  {
1212  return ($this->rowSeparators) ? 1 : 0;
1213  }
+ Here is the caller graph for this function:

◆ getSingleLineRowCaption()

SurveyMatrixQuestion::getSingleLineRowCaption ( )

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

Referenced by saveToDb().

1513  {
1514  return ($this->singleLineRowCaption) ? 1 : 0;
1515  }
+ 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 public

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

References $subtype.

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

1127  {
1128  return $this->subtype;
1129  }
+ 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 public

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

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

958  {
959  $data = array();
960  foreach ($post_data as $key => $value) {
961  switch ($this->getSubtype()) {
962  case 0:
963  if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
964  if (is_array($value)) {
965  foreach ($value as $val) {
966  array_push($data, array("value" => $val, "rowvalue" => $matches[1], "textanswer" => $post_data['matrix_other_' . $this->getId() . '_' . $matches[1]]));
967  }
968  } else {
969  array_push($data, array("value" => $value, "rowvalue" => $matches[1], "textanswer" => $post_data['matrix_other_' . $this->getId() . '_' . $matches[1]]));
970  }
971  }
972  break;
973  case 1:
974  if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
975  if (is_array($value)) {
976  foreach ($value as $val) {
977  array_push($data, array("value" => $val, "rowvalue" => $matches[1], "textanswer" => $post_data['matrix_other_' . $this->getId() . '_' . $matches[1]]));
978  }
979  } else {
980  array_push($data, array("value" => $value, "rowvalue" => $matches[1], "textanswer" => $post_data['matrix_other_' . $this->getId() . '_' . $matches[1]]));
981  }
982  }
983  break;
984  }
985  }
986  return $data;
987  }
getId()
Gets the id of the SurveyQuestion object.
Create styles array
The data for the language used.
getSubtype()
Returns the subtype of the matrix question.
$key
Definition: croninfo.php:18
+ 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 1442 of file class.SurveyMatrixQuestion.php.

References getBipolarAdjective().

Referenced by getLayout().

1443  {
1444  if ((strlen($this->getBipolarAdjective(0))) && (strlen($this->getBipolarAdjective(1)))) {
1445  return true;
1446  } else {
1447  return false;
1448  }
1449  }
getBipolarAdjective($a_index)
Returns one of the bipolar adjectives.
+ 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 1456 of file class.SurveyMatrixQuestion.php.

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

Referenced by getLayout().

1457  {
1458  for ($i = 0; $i < $this->getColumnCount(); $i++) {
1459  $column = $this->getColumn($i);
1460  if ($column->neutral && strlen($column->title)) {
1461  return true;
1462  }
1463  }
1464  return false;
1465  }
getColumn($index)
Returns the name of a column for a given index.
$column
Definition: 39dropdown.php:62
$i
Definition: disco.tpl.php:19
getColumnCount()
Returns the number of columns.
+ 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 public

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

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

1254  {
1255  foreach ($a_meta as $key => $value) {
1256  switch ($value["label"]) {
1257  case "column_separators":
1258  $this->setColumnSeparators($value["entry"]);
1259  break;
1260  case "row_separators":
1261  $this->setRowSeparators($value["entry"]);
1262  break;
1263  case "layout":
1264  $this->setLayout($value["entry"]);
1265  break;
1266  case "neutral_column_separator":
1267  $this->setNeutralColumnSeparator($value["entry"]);
1268  break;
1269  }
1270  }
1271  }
setNeutralColumnSeparator($enable=0)
Enables/Disables a separator for the neutral column.
setColumnSeparators($enable=0)
Enables/Disables separators for the matrix columns.
setRowSeparators($enable=0)
Enables/Disables separators for the matrix rows.
$key
Definition: croninfo.php:18
+ 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 public

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

References $i, and setBipolarAdjective().

1280  {
1281  $i = 0;
1282  foreach ($a_data as $adjective) {
1283  if (is_numeric($adjective["label"])) {
1284  $this->setBipolarAdjective($adjective["label"], $adjective["text"]);
1285  } else {
1286  $this->setBipolarAdjective($i, $adjective["text"]);
1287  }
1288  $i++;
1289  }
1290  }
$i
Definition: disco.tpl.php:19
setBipolarAdjective($a_index, $a_value)
Sets one of the bipolar adjectives.
+ 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 public

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

References $row, and addRow().

1299  {
1300  foreach ($a_data as $row) {
1301  $this->addRow($row['title'], $row['other'], $row['label']);
1302  }
1303  }
addRow($a_text, $a_other, $a_label)
Adds a row to the question.
+ 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 public

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

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

1312  {
1313  foreach ($a_data as $id => $data) {
1314  $column = "";
1315  foreach ($data["material"] as $material) {
1316  $column .= $material["text"];
1317  }
1318  $this->columns->addCategory($column, null, (strcmp($data["label"], "neutral") == 0) ? true : false);
1319  }
1320  }
$column
Definition: 39dropdown.php:62
Play around with inserting and removing rows and columns

◆ 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 public

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

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

Referenced by toXML().

749  {
750  $attrs = array(
751  "id" => $this->getId(),
752  "title" => $this->getTitle(),
753  "type" => $this->getQuestiontype(),
754  "subtype" => $this->getSubtype(),
755  "obligatory" => $this->getObligatory()
756  );
757  $a_xml_writer->xmlStartTag("question", $attrs);
758 
759  $a_xml_writer->xmlElement("description", null, $this->getDescription());
760  $a_xml_writer->xmlElement("author", null, $this->getAuthor());
761  $a_xml_writer->xmlStartTag("questiontext");
762  $this->addMaterialTag($a_xml_writer, $this->getQuestiontext());
763  $a_xml_writer->xmlEndTag("questiontext");
764 
765  $a_xml_writer->xmlStartTag("matrix");
766  $a_xml_writer->xmlStartTag("matrixrows");
767  for ($i = 0; $i < $this->getRowCount(); $i++) {
768  $attrs = array(
769  "id" => $i
770  );
771  if (strlen($this->getRow($i)->label)) {
772  $attrs['label'] = $this->getRow($i)->label;
773  }
774  if ($this->getRow($i)->other) {
775  $attrs['other'] = 1;
776  }
777  $a_xml_writer->xmlStartTag("matrixrow", $attrs);
778  $this->addMaterialTag($a_xml_writer, $this->getRow($i)->title);
779  $a_xml_writer->xmlEndTag("matrixrow");
780  }
781  $a_xml_writer->xmlEndTag("matrixrows");
782 
783  $a_xml_writer->xmlStartTag("responses");
784  if (strlen($this->getBipolarAdjective(0)) && (strlen($this->getBipolarAdjective(1)))) {
785  $a_xml_writer->xmlStartTag("bipolar_adjectives");
786  $attribs = array(
787  "label" => "0"
788  );
789  $a_xml_writer->xmlElement("adjective", $attribs, $this->getBipolarAdjective(0));
790  $attribs = array(
791  "label" => "1"
792  );
793  $a_xml_writer->xmlElement("adjective", $attribs, $this->getBipolarAdjective(1));
794  $a_xml_writer->xmlEndTag("bipolar_adjectives");
795  }
796  for ($i = 0; $i < $this->getColumnCount(); $i++) {
797  $attrs = array(
798  "id" => $i
799  );
800  if ($this->getColumn($i)->neutral) {
801  $attrs['label'] = 'neutral';
802  }
803  switch ($this->getSubtype()) {
804  case 0:
805  $a_xml_writer->xmlStartTag("response_single", $attrs);
806  break;
807  case 1:
808  $a_xml_writer->xmlStartTag("response_multiple", $attrs);
809  break;
810  }
811  $this->addMaterialTag($a_xml_writer, $this->getColumn($i)->title);
812  switch ($this->getSubtype()) {
813  case 0:
814  $a_xml_writer->xmlEndTag("response_single");
815  break;
816  case 1:
817  $a_xml_writer->xmlEndTag("response_multiple");
818  break;
819  }
820  }
821 
822  $a_xml_writer->xmlEndTag("responses");
823  $a_xml_writer->xmlEndTag("matrix");
824 
825  if (count($this->material)) {
826  if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $this->material["internal_link"], $matches)) {
827  $attrs = array(
828  "label" => $this->material["title"]
829  );
830  $a_xml_writer->xmlStartTag("material", $attrs);
831  $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
832  if (strcmp($matches[1], "") != 0) {
833  $intlink = $this->material["internal_link"];
834  }
835  $a_xml_writer->xmlElement("mattext", null, $intlink);
836  $a_xml_writer->xmlEndTag("material");
837  }
838  }
839 
840  $a_xml_writer->xmlStartTag("metadata");
841  $a_xml_writer->xmlStartTag("metadatafield");
842  $a_xml_writer->xmlElement("fieldlabel", null, "column_separators");
843  $a_xml_writer->xmlElement("fieldentry", null, $this->getColumnSeparators());
844  $a_xml_writer->xmlEndTag("metadatafield");
845 
846  $a_xml_writer->xmlStartTag("metadatafield");
847  $a_xml_writer->xmlElement("fieldlabel", null, "row_separators");
848  $a_xml_writer->xmlElement("fieldentry", null, $this->getRowSeparators());
849  $a_xml_writer->xmlEndTag("metadatafield");
850 
851  $a_xml_writer->xmlStartTag("metadatafield");
852  $a_xml_writer->xmlElement("fieldlabel", null, "neutral_column_separator");
853  $a_xml_writer->xmlElement("fieldentry", null, $this->getNeutralColumnSeparator());
854  $a_xml_writer->xmlEndTag("metadatafield");
855 
856  $a_xml_writer->xmlStartTag("metadatafield");
857  $a_xml_writer->xmlElement("fieldlabel", null, "layout");
858  $a_xml_writer->xmlElement("fieldentry", null, serialize($this->getLayout()));
859  $a_xml_writer->xmlEndTag("metadatafield");
860 
861  $a_xml_writer->xmlEndTag("metadata");
862 
863  $a_xml_writer->xmlEndTag("question");
864  }
getAuthor()
Gets the authors name of the SurveyQuestion object.
getTitle()
Gets the title string of the SurveyQuestion object.
getBipolarAdjective($a_index)
Returns one of the bipolar adjectives.
getObligatory($survey_id="")
Gets the obligatory state of the question.
getRow($a_index)
Returns a specific row.
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
getRowSeparators()
Gets the separators enable state for the matrix rows.
getColumn($index)
Returns the name of a column for a given index.
getId()
Gets the id 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.
Create styles array
The data for the language used.
getSubtype()
Returns the subtype of the matrix question.
$i
Definition: disco.tpl.php:19
getDescription()
Gets the description string of the SurveyQuestion object.
getColumnCount()
Returns the number of columns.
getColumnSeparators()
Gets the separators enable state for the matrix columns.
getRowCount()
Returns the number of rows in the question.
getNeutralColumnSeparator()
Gets the separator enable state for the neutral column.
+ 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 public

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

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

537  {
538  if (
539  strlen($this->getTitle()) &&
540  strlen($this->getAuthor()) &&
541  strlen($this->getQuestiontext()) &&
542  $this->getColumnCount() &&
543  $this->getRowCount()
544  ) {
545  return 1;
546  } else {
547  return 0;
548  }
549  }
getAuthor()
Gets the authors name of the SurveyQuestion object.
getTitle()
Gets the title string of the SurveyQuestion object.
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
getColumnCount()
Returns the number of columns.
getRowCount()
Returns the number of rows in the question.
+ 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 public

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

References $data, $db, SurveyQuestion\$id, $ilDB, $result, $row, ilRTE\_replaceMediaObjectImageSrc(), addRow(), array, columns, 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().

468  {
469  $ilDB = $this->db;
470  $result = $ilDB->queryF(
471  "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",
472  array('integer'),
473  array($id)
474  );
475  if ($result->numRows() == 1) {
476  $data = $ilDB->fetchAssoc($result);
477  $this->setId($data["question_id"]);
478  $this->setTitle($data["title"]);
479  $this->label = $data['label'];
480  $this->setDescription($data["description"]);
481  $this->setObjId($data["obj_fi"]);
482  $this->setAuthor($data["author"]);
483  $this->setOwner($data["owner_fi"]);
484  include_once("./Services/RTE/classes/class.ilRTE.php");
485  $this->setQuestiontext(ilRTE::_replaceMediaObjectImageSrc($data["questiontext"], 1));
486  $this->setObligatory($data["obligatory"]);
487  $this->setComplete($data["complete"]);
488  $this->setOriginalId($data["original_id"]);
489  $this->setSubtype($data["subtype"]);
490  $this->setRowSeparators($data["row_separators"]);
491  $this->setNeutralColumnSeparator($data["neutral_column_separator"]);
492  $this->setColumnSeparators($data["column_separators"]);
493  $this->setColumnPlaceholders($data["column_placeholders"]);
494  $this->setLegend($data["legend"]);
495  $this->setSingleLineRowCaption($data["singleline_row_caption"]);
496  $this->setRepeatColumnHeader($data["repeat_column_header"]);
497  $this->setColumnHeaderPosition($data["column_header_position"]);
498  $this->setRandomRows($data["random_rows"]);
499  $this->setColumnOrder($data["column_order"]);
500  $this->setColumnImages($data["column_images"]);
501  $this->setRowImages($data["row_images"]);
502  $this->setBipolarAdjective(0, $data["bipolar_adjective1"]);
503  $this->setBipolarAdjective(1, $data["bipolar_adjective2"]);
504  $this->setLayout($data["layout"]);
505  $this->flushColumns();
506 
507  $result = $ilDB->queryF(
508  "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",
509  array('integer'),
510  array($id)
511  );
512  if ($result->numRows() > 0) {
513  while ($data = $ilDB->fetchAssoc($result)) {
514  $this->columns->addCategory($data["title"], $data["other"], $data["neutral"], null, ($data['scale']) ? $data['scale'] : ($data['sequence'] + 1));
515  }
516  }
517 
518  $result = $ilDB->queryF(
519  "SELECT * FROM svy_qst_matrixrows WHERE question_fi = %s ORDER BY sequence",
520  array('integer'),
521  array($id)
522  );
523  while ($row = $ilDB->fetchAssoc($result)) {
524  $this->addRow($row["title"], $row['other'], $row['label']);
525  }
526  }
527  parent::loadFromDb($id);
528  }
$result
setObligatory($obligatory=1)
Sets the obligatory state of the question.
setColumnPlaceholders($a_value=0)
Set whether placeholders should be used for the column titles or not.
setId($id=-1)
Sets the id of the SurveyQuestion object.
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...
setOwner($owner="")
Sets the creator/owner ID of the SurveyQuestion object.
setComplete($a_complete)
Sets the complete state of the question.
flushColumns()
Empties the columns list.
setOriginalId($original_id)
setQuestiontext($questiontext="")
Sets the questiontext of the SurveyQuestion object.
setNeutralColumnSeparator($enable=0)
Enables/Disables a separator for the neutral column.
Play around with inserting and removing rows and columns
setLegend($a_value=0)
Set whether the legend should be shown or not.
setColumnSeparators($enable=0)
Enables/Disables separators for the matrix columns.
setSubtype($a_subtype=0)
Sets the subtype of the matrix question.
Create styles array
The data for the language used.
setAuthor($author="")
Sets the authors name of the SurveyQuestion object.
setRowSeparators($enable=0)
Enables/Disables separators for the matrix rows.
setDescription($description="")
Sets the description string of the SurveyQuestion object.
addRow($a_text, $a_other, $a_label)
Adds a row to the question.
global $ilDB
setObjId($obj_id=0)
Set the reference id of the container object.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setBipolarAdjective($a_index, $a_value)
Sets one of the bipolar adjectives.
setTitle($title="")
Sets the title string of the SurveyQuestion object.
+ Here is the call graph for this function:

◆ moveRowDown()

SurveyMatrixQuestion::moveRowDown (   $index)

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

References $index, and rows.

345  {
346  $this->rows->moveCategoryDown($index);
347  }
$index
Definition: metadata.php:60
Remove unnecessary rows

◆ moveRowUp()

SurveyMatrixQuestion::moveRowUp (   $index)

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

References $index, and rows.

340  {
341  $this->rows->moveCategoryUp($index);
342  }
$index
Definition: metadata.php:60
Remove unnecessary rows

◆ removeColumn()

SurveyMatrixQuestion::removeColumn (   $index)

Removes a column from the list of columns.

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

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

References $index, and columns.

207  {
208  $this->columns->removeCategory($index);
209  }
$index
Definition: metadata.php:60
Play around with inserting and removing rows and columns

◆ 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 public
See also
$columns

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

References columns.

219  {
220  $this->columns->removeCategories($array);
221  }
Play around with inserting and removing rows and columns

◆ removeColumnWithName()

SurveyMatrixQuestion::removeColumnWithName (   $name)

Removes a column from the list of columns.

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

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

References $name, and columns.

231  {
232  $this->columns->removeCategoryWithName($name);
233  }
if($format !==null) $name
Definition: metadata.php:146
Play around with inserting and removing rows and columns

◆ removeRow()

SurveyMatrixQuestion::removeRow (   $index)

Removes a row.

Parameters
integer$indexThe index of the row to be removed

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

References $index, and rows.

367  {
368  $this->rows->removeCategory($index);
369  }
$index
Definition: metadata.php:60
Remove unnecessary rows

◆ removeRows()

SurveyMatrixQuestion::removeRows (   $array)

Removes rows from the question.

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

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

References rows.

357  {
358  $this->rows->removeCategories($array);
359  }
Remove unnecessary rows

◆ saveBipolarAdjectives()

SurveyMatrixQuestion::saveBipolarAdjectives (   $adjective1,
  $adjective2 
)

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

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

609  {
610  $ilDB = $this->db;
611 
612  $affectedRows = $ilDB->manipulateF(
613  "UPDATE " . $this->getAdditionalTableName() . " SET bipolar_adjective1 = %s, bipolar_adjective2 = %s WHERE question_fi = %s",
614  array('text', 'text', 'integer'),
615  array((strlen($adjective1)) ? $adjective1 : null, (strlen($adjective2)) ? $adjective2 : null, $this->getId())
616  );
617  }
getId()
Gets the id of the SurveyQuestion object.
Create styles array
The data for the language used.
global $ilDB
getAdditionalTableName()
Returns the name of the additional question data table in the database.
+ Here is the call graph for this function:

◆ saveColumnsToDb()

SurveyMatrixQuestion::saveColumnsToDb (   $original_id = "")

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

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

Referenced by saveToDb(), and syncWithOriginal().

663  {
664  $ilDB = $this->db;
665 
666  // save columns
667  $question_id = $this->getId();
668  if (strlen($original_id)) {
669  $question_id = $original_id;
670  }
671 
672  // delete existing column relations
673  $affectedRows = $ilDB->manipulateF(
674  "DELETE FROM svy_variable WHERE question_fi = %s",
675  array('integer'),
676  array($question_id)
677  );
678  // create new column relations
679  for ($i = 0; $i < $this->getColumnCount(); $i++) {
680  $cat = $this->getColumn($i);
681  $column_id = $this->saveColumnToDb($cat->title, $cat->neutral);
682  $next_id = $ilDB->nextId('svy_variable');
683  $affectedRows = $ilDB->manipulateF(
684  "INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, other, sequence, scale, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
685  array('integer','integer','integer','float','integer','integer', 'integer','integer'),
686  array($next_id, $column_id, $question_id, ($i + 1), $cat->other, $i, ($cat->scale > 0) ? $cat->scale : null, time())
687  );
688  }
689  $this->saveCompletionStatus($original_id);
690  }
saveCompletionStatus($original_id="")
Saves the complete flag to the database.
getColumn($index)
Returns the name of a column for a given index.
getId()
Gets the id of the SurveyQuestion object.
saveColumnToDb($columntext, $neutral=0)
Saves a column to the database.
Create styles array
The data for the language used.
global $ilDB
$i
Definition: disco.tpl.php:19
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
getColumnCount()
Returns the number of columns.
+ 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 public
See also
$columns

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

References $db, $ilDB, $ilUser, $insert, $result, $row, $user, array, and time.

Referenced by saveColumnsToDb().

628  {
630  $ilDB = $this->db;
631 
632  $result = $ilDB->queryF(
633  "SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
634  array('text', 'text', 'integer'),
635  array($columntext, $neutral, $ilUser->getId())
636  );
637  $insert = false;
638  $returnvalue = "";
639  if ($result->numRows()) {
640  $insert = true;
641  while ($row = $ilDB->fetchAssoc($result)) {
642  if (strcmp($row["title"], $columntext) == 0) {
643  $returnvalue = $row["category_id"];
644  $insert = false;
645  }
646  }
647  } else {
648  $insert = true;
649  }
650  if ($insert) {
651  $next_id = $ilDB->nextId('svy_category');
652  $affectedRows = $ilDB->manipulateF(
653  "INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, neutral, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
654  array('integer', 'text', 'text', 'integer', 'text', 'integer'),
655  array($next_id, $columntext, 0, $ilUser->getId(), $neutral, time())
656  );
657  $returnvalue = $next_id;
658  }
659  return $returnvalue;
660  }
$result
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
$insert
+ 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 1370 of file class.SurveyMatrixQuestion.php.

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

1371  {
1372  $ilDB = $this->db;
1373 
1374  $layout = array(
1375  "percent_row" => $percent_row,
1376  "percent_columns" => $percent_columns,
1377  "percent_bipolar_adjective1" => $percent_bipolar_adjective1,
1378  "percent_bipolar_adjective2" => $percent_bipolar_adjective2,
1379  "percent_neutral" => $percent_neutral
1380  );
1381  $affectedRows = $ilDB->manipulateF(
1382  "UPDATE " . $this->getAdditionalTableName() . " SET layout = %s WHERE question_fi = %s",
1383  array('text', 'integer'),
1384  array(serialize($layout), $this->getId())
1385  );
1386  }
getId()
Gets the id of the SurveyQuestion object.
Create styles array
The data for the language used.
global $ilDB
getAdditionalTableName()
Returns the name of the additional question data table in the database.
+ 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 public

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

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

898  {
900  $ilDB = $this->db;
901 
902  $next_id = $ilDB->nextId('svy_phrase');
903  $affectedRows = $ilDB->manipulateF(
904  "INSERT INTO svy_phrase (phrase_id, title, defaultvalue, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
905  array('integer','text','text','integer','integer'),
906  array($next_id, $title, 1, $ilUser->getId(), time())
907  );
908  $phrase_id = $next_id;
909 
910  $counter = 1;
911  foreach ($_SESSION['save_phrase_data'] as $data) {
912  $next_id = $ilDB->nextId('svy_category');
913  $affectedRows = $ilDB->manipulateF(
914  "INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, tstamp, neutral) VALUES (%s, %s, %s, %s, %s, %s)",
915  array('integer','text','text','integer','integer','text'),
916  array($next_id, $data['answer'], 1, $ilUser->getId(), time(), $data['neutral'])
917  );
918  $category_id = $next_id;
919  $next_id = $ilDB->nextId('svy_phrase_cat');
920  $affectedRows = $ilDB->manipulateF(
921  "INSERT INTO svy_phrase_cat (phrase_category_id, phrase_fi, category_fi, sequence, other, scale) VALUES (%s, %s, %s, %s, %s, %s)",
922  array('integer', 'integer', 'integer','integer', 'integer', 'integer'),
923  array($next_id, $phrase_id, $category_id, $counter, ($data['other']) ? 1 : 0, $data['scale'])
924  );
925  $counter++;
926  }
927  }
$_SESSION["AccountId"]
$counter
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ saveRowsToDb()

SurveyMatrixQuestion::saveRowsToDb (   $original_id = "")

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

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

Referenced by saveToDb(), and syncWithOriginal().

693  {
694  $ilDB = $this->db;
695 
696  // save rows
697  $question_id = $this->getId();
698  if (strlen($original_id)) {
699  $question_id = $original_id;
700  }
701 
702  // delete existing rows
703  $affectedRows = $ilDB->manipulateF(
704  "DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
705  array('integer'),
706  array($question_id)
707  );
708  // create new rows
709  for ($i = 0; $i < $this->getRowCount(); $i++) {
710  $row = $this->getRow($i);
711  $next_id = $ilDB->nextId('svy_qst_matrixrows');
712  $affectedRows = $ilDB->manipulateF(
713  "INSERT INTO svy_qst_matrixrows (id_svy_qst_matrixrows, title, label, other, sequence, question_fi) VALUES (%s, %s, %s, %s, %s, %s)",
714  array('integer','text','text','integer','integer','integer'),
715  array($next_id, $row->title, $row->label, ($row->other) ? 1 : 0, $i, $question_id)
716  );
717  }
718  $this->saveCompletionStatus($original_id);
719  }
saveCompletionStatus($original_id="")
Saves the complete flag to the database.
getRow($a_index)
Returns a specific row.
getId()
Gets the id of the SurveyQuestion object.
Create styles array
The data for the language used.
global $ilDB
$i
Definition: disco.tpl.php:19
getRowCount()
Returns the number of rows in the question.
+ 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.

public

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

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

557  {
558  $ilDB = $this->db;
559 
560  $affectedRows = parent::saveToDb($original_id);
561 
562  if ($affectedRows == 1) {
563  $affectedRows = $ilDB->manipulateF(
564  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
565  array('integer'),
566  array($this->getId())
567  );
568  $affectedRows = $ilDB->manipulateF(
569  "INSERT INTO " . $this->getAdditionalTableName() . " (
570  question_fi, subtype, column_separators, row_separators, neutral_column_separator,column_placeholders,
571  legend, singleline_row_caption, repeat_column_header, column_header_position, random_rows,
572  column_order, column_images, row_images, bipolar_adjective1, bipolar_adjective2, layout, tstamp)
573  VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
574  array(
575  'integer', 'integer', 'text', 'text', 'text', 'integer', 'text', 'text', 'text',
576  'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer'
577  ),
578  array(
579  $this->getId(),
580  $this->getSubtype(),
581  $this->getColumnSeparators(),
582  $this->getRowSeparators(),
583  $this->getNeutralColumnSeparator(),
584  $this->getColumnPlaceholders(),
585  $this->getLegend(),
586  $this->getSingleLineRowCaption(),
587  $this->getRepeatColumnHeader(),
588  $this->getColumnHeaderPosition(),
589  $this->getRandomRows(),
590  $this->getColumnOrder(),
591  $this->getColumnImages(),
592  $this->getRowImages(),
593  $this->getBipolarAdjective(0),
594  $this->getBipolarAdjective(1),
595  serialize($this->getLayout()),
596  time()
597  )
598  );
599 
600  // saving material uris in the database
601  $this->saveMaterial();
602 
603  $this->saveColumnsToDb();
604  $this->saveRowsToDb();
605  }
606  }
getBipolarAdjective($a_index)
Returns one of the bipolar adjectives.
getRowSeparators()
Gets the separators enable state for the matrix rows.
getLegend()
Get whether the legend should be shown or not.
getId()
Gets the id of the SurveyQuestion object.
saveMaterial()
save material to db
Create styles array
The data for the language used.
getSubtype()
Returns the subtype of the matrix question.
global $ilDB
getColumnPlaceholders()
Get whether placeholders should be used for the column titles or not.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
getColumnSeparators()
Gets the separators enable state for the matrix columns.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getNeutralColumnSeparator()
Gets the separator enable state for the neutral column.
+ Here is the call graph for this function:

◆ saveUserInput()

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

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

References $db, $ilDB, $key, array, SurveyQuestion\getId(), getSubtype(), and time.

1040  {
1041  $ilDB = $this->db;
1042 
1043  $answer_data = array();
1044 
1045  // gather data
1046  switch ($this->getSubtype()) {
1047  case 0:
1048  foreach ($post_data as $key => $value) {
1049  if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
1050  if (strlen($value)) {
1051  $other_value = (array_key_exists('matrix_other_' . $this->getId() . '_' . $matches[1], $post_data))
1052  ? ($post_data['matrix_other_' . $this->getId() . '_' . $matches[1]])
1053  : null;
1054  $answer_data[] = array("value"=>$value,
1055  "textanswer"=>$other_value,
1056  "rowvalue"=>$matches[1]);
1057  }
1058  }
1059  }
1060  break;
1061 
1062  case 1:
1063  foreach ($post_data as $key => $value) {
1064  if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches)) {
1065  $other_value = (array_key_exists('matrix_other_' . $this->getId() . '_' . $matches[1], $post_data))
1066  ? ($post_data['matrix_other_' . $this->getId() . '_' . $matches[1]])
1067  : null;
1068  foreach ($value as $checked) {
1069  $answer_data[] = array("value"=>$checked,
1070  "textanswer"=>$other_value,
1071  "rowvalue"=>$matches[1]);
1072  }
1073  }
1074  }
1075  break;
1076  }
1077 
1078  if ($a_return) {
1079  return $answer_data;
1080  }
1081 
1082  // #16387 - only if any input
1083  if (sizeof($answer_data)) {
1084  // save data
1085  foreach ($answer_data as $item) {
1086  $next_id = $ilDB->nextId('svy_answer');
1087  #20216
1088  $fields = array();
1089  $fields['answer_id'] = array("integer", $next_id);
1090  $fields['question_fi'] = array("integer", $this->getId());
1091  $fields['active_fi'] = array("integer", $active_id);
1092  $fields['value'] = array("float", $item['value']);
1093  $fields['textanswer'] = array("clob", $item['textanswer']);
1094  $fields['rowvalue'] = array("integer", $item['rowvalue']);
1095  $fields['tstamp'] = array("integer", time());
1096 
1097  $affectedRows = $ilDB->insert("svy_answer", $fields);
1098  }
1099  }
1100  }
getId()
Gets the id of the SurveyQuestion object.
Create styles array
The data for the language used.
getSubtype()
Returns the subtype of the matrix question.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
$key
Definition: croninfo.php:18
+ 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 public

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

Referenced by importAdjectives(), and loadFromDb().

400  {
401  switch ($a_index) {
402  case 1:
403  $this->bipolar_adjective2 = $a_value;
404  break;
405  case 0:
406  default:
407  $this->bipolar_adjective1 = $a_value;
408  break;
409  }
410  }
+ Here is the caller graph for this function:

◆ setColumnHeaderPosition()

SurveyMatrixQuestion::setColumnHeaderPosition (   $a_value)

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

Referenced by loadFromDb().

1528  {
1529  $this->columnHeaderPosition = $a_value;
1530  }
+ Here is the caller graph for this function:

◆ setColumnImages()

SurveyMatrixQuestion::setColumnImages (   $a_value = 0)

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

Referenced by loadFromDb().

1558  {
1559  $this->columnImages = ($a_value) ? 1 : 0;
1560  }
+ Here is the caller graph for this function:

◆ setColumnOrder()

SurveyMatrixQuestion::setColumnOrder (   $a_value)

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

Referenced by loadFromDb().

1548  {
1549  $this->columnOrder = $a_value;
1550  }
+ 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 1472 of file class.SurveyMatrixQuestion.php.

Referenced by loadFromDb().

1473  {
1474  $this->columnPlaceholders = ($a_value) ? 1 : 0;
1475  }
+ 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 public

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

Referenced by importAdditionalMetadata(), and loadFromDb().

1162  {
1163  switch ($enable) {
1164  case 1:
1165  $this->columnSeparators = 1;
1166  break;
1167  case 0:
1168  default:
1169  $this->columnSeparators = 0;
1170  break;
1171  }
1172  }
+ Here is the caller graph for this function:

◆ setLayout()

SurveyMatrixQuestion::setLayout (   $layout)

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

References $layout.

Referenced by importAdditionalMetadata(), and loadFromDb().

1429  {
1430  if (is_array($layout)) {
1431  $this->layout = $layout;
1432  } else {
1433  $this->layout = unserialize($layout);
1434  }
1435  }
+ 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 1492 of file class.SurveyMatrixQuestion.php.

Referenced by loadFromDb().

1493  {
1494  $this->legend = ($a_value) ? 1 : 0;
1495  }
+ 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 public

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

Referenced by importAdditionalMetadata(), and loadFromDb().

1222  {
1223  switch ($enable) {
1224  case 1:
1225  $this->neutralColumnSeparator = 1;
1226  break;
1227  case 0:
1228  default:
1229  $this->neutralColumnSeparator = 0;
1230  break;
1231  }
1232  }
+ Here is the caller graph for this function:

◆ setRandomRows()

SurveyMatrixQuestion::setRandomRows (   $a_value = 0)

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

Referenced by loadFromDb().

1538  {
1539  $this->randomRows = ($a_value) ? 1 : 0;
1540  }
+ Here is the caller graph for this function:

◆ setRepeatColumnHeader()

SurveyMatrixQuestion::setRepeatColumnHeader (   $a_value = 0)

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

Referenced by loadFromDb().

1518  {
1519  $this->repeatColumnHeader = ($a_value) ? 1 : 0;
1520  }
+ Here is the caller graph for this function:

◆ setRowImages()

SurveyMatrixQuestion::setRowImages (   $a_value = 0)

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

Referenced by loadFromDb().

1568  {
1569  $this->rowImages = ($a_value) ? 1 : 0;
1570  }
+ 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 public

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

Referenced by importAdditionalMetadata(), and loadFromDb().

1192  {
1193  switch ($enable) {
1194  case 1:
1195  $this->rowSeparators = 1;
1196  break;
1197  case 0:
1198  default:
1199  $this->rowSeparators = 0;
1200  break;
1201  }
1202  }
+ Here is the caller graph for this function:

◆ setSingleLineRowCaption()

SurveyMatrixQuestion::setSingleLineRowCaption (   $a_value = 0)

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

Referenced by loadFromDb().

1508  {
1509  $this->singleLineRowCaption = ($a_value) ? 1 : 0;
1510  }
+ 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 public

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

Referenced by loadFromDb().

1138  {
1139  switch ($a_subtype) {
1140  case 1:
1141  case 2:
1142  case 3:
1143  case 4:
1144  case 5:
1145  case 6:
1146  $this->subtype = $a_subtype;
1147  break;
1148  case 0:
1149  default:
1150  $this->subtype = 0;
1151  break;
1152  }
1153  }
+ Here is the caller graph for this function:

◆ syncWithOriginal()

SurveyMatrixQuestion::syncWithOriginal ( )

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

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

867  {
868  if ($this->getOriginalId()) {
869  parent::syncWithOriginal();
870  $this->saveColumnsToDb($this->getOriginalId());
871  $this->saveRowsToDb($this->getOriginalId());
872  }
873  }
+ 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 public

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

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

728  {
729  include_once("./Services/Xml/classes/class.ilXmlWriter.php");
730  $a_xml_writer = new ilXmlWriter;
731  $a_xml_writer->xmlHeader();
732  $this->insertXML($a_xml_writer, $a_include_header, $obligatory_state);
733  $xml = $a_xml_writer->xmlDumpMem(false);
734  if (!$a_include_header) {
735  $pos = strpos($xml, "?>");
736  $xml = substr($xml, $pos + 2);
737  }
738  return $xml;
739  }
XML writer class.
$xml
Definition: metadata.php:240
xmlHeader()
Writes xml header public.
insertXML(&$a_xml_writer, $a_include_header=true)
Adds the question XML to a given XMLWriter object.
+ 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 public

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

1329  {
1330  return false;
1331  }

Field Documentation

◆ $bipolar_adjective1

SurveyMatrixQuestion::$bipolar_adjective1

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

◆ $bipolar_adjective2

SurveyMatrixQuestion::$bipolar_adjective2

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

◆ $columnHeaderPosition

SurveyMatrixQuestion::$columnHeaderPosition

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

◆ $columnImages

SurveyMatrixQuestion::$columnImages

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

◆ $columnOrder

SurveyMatrixQuestion::$columnOrder

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

◆ $columnPlaceholders

SurveyMatrixQuestion::$columnPlaceholders

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

◆ $columns

SurveyMatrixQuestion::$columns

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

Referenced by getColumns().

◆ $columnSeparators

SurveyMatrixQuestion::$columnSeparators

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

◆ $db

◆ $layout

SurveyMatrixQuestion::$layout

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

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

◆ $legend

SurveyMatrixQuestion::$legend

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

◆ $neutralColumnSeparator

SurveyMatrixQuestion::$neutralColumnSeparator

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

◆ $openRows

SurveyMatrixQuestion::$openRows

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

◆ $randomRows

SurveyMatrixQuestion::$randomRows

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

◆ $repeatColumnHeader

SurveyMatrixQuestion::$repeatColumnHeader

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

◆ $rowImages

SurveyMatrixQuestion::$rowImages

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

◆ $rows

SurveyMatrixQuestion::$rows

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

Referenced by getRows().

◆ $rowSeparators

SurveyMatrixQuestion::$rowSeparators

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

◆ $singleLineRowCaption

SurveyMatrixQuestion::$singleLineRowCaption

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

◆ $subtype

SurveyMatrixQuestion::$subtype

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

Referenced by getSubtype().

◆ $user

SurveyMatrixQuestion::$user
protected

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

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


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