ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
 
 $ilias
 
 $tpl
 
 $lng
 
 $orientation
 
 $material
 
 $complete
 

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...
 
- Protected Attributes inherited from SurveyQuestion
 $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
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 158 of file class.SurveyMatrixQuestion.php.

References SurveyQuestion\$author, SurveyQuestion\$description, SurveyQuestion\$owner, SurveyQuestion\$questiontext, SurveyQuestion\$title, columns, and rows.

159  {
160  parent::__construct($title, $description, $author, $questiontext, $owner);
161 
162  $this->subtype = 0;
163  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
164  $this->columns = new SurveyCategories();
165  $this->rows = new SurveyCategories();
166  $this->bipolar_adjective1 = "";
167  $this->bipolar_adjective2 = "";
168  $this->rowSeparators = 0;
169  $this->columnSeparators = 0;
170  $this->neutralColumnSeparator = 1;
171  }
Class SurveyCategories.
Play around with inserting and removing rows and columns
Remove unnecessary rows

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

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

407  {
408  global $ilUser;
409  global $ilDB;
410 
411  $result = $ilDB->queryF("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",
412  array('integer', 'integer', 'integer'),
413  array($phrase_id, 0, $ilUser->getId())
414  );
415  while ($row = $ilDB->fetchAssoc($result))
416  {
417  $neutral = $row["neutral"];
418  if (($row["defaultvalue"] == 1) && ($row["owner_fi"] == 0))
419  {
420  $this->columns->addCategory($this->lng->txt($row["title"]), 0, $neutral);
421  }
422  else
423  {
424  $this->columns->addCategory($row["title"], 0, $neutral);
425  }
426  }
427  }
$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 287 of file class.SurveyMatrixQuestion.php.

References rows.

Referenced by importMatrix(), and loadFromDb().

288  {
289  $this->rows->addCategory($a_text, $a_other, 0, $a_label);
290  }
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 298 of file class.SurveyMatrixQuestion.php.

References rows.

299  {
300  $this->rows->addCategoryAtPosition($a_text, $a_position, $a_other);
301  }
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 894 of file class.SurveyMatrixQuestion.php.

References columns.

895  {
896  for ($i = $lower_limit; $i <= $upper_limit; $i++)
897  {
898  $this->columns->addCategory($i);
899  }
900  }
Play around with inserting and removing rows and columns

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

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

1021  {
1022  if (!$this->getObligatory($survey_id)) return "";
1023  switch ($this->getSubtype())
1024  {
1025  case 0:
1026  $counter = 0;
1027  foreach ($post_data as $key => $value)
1028  {
1029  if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches))
1030  {
1031  if (array_key_exists('matrix_other_' . $this->getId() . "_" . $matches[1], $post_data) && strlen($post_data['matrix_other_' . $this->getId() . "_" . $matches[1]]) == 0)
1032  {
1033  return $this->lng->txt("question_mr_no_other_answer");
1034  }
1035  $counter++;
1036  }
1037  }
1038  if ($counter != $this->getRowCount()) return $this->lng->txt("matrix_question_radio_button_not_checked");
1039  break;
1040  case 1:
1041  $counter = 0;
1042  foreach ($post_data as $key => $value)
1043  {
1044  if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches))
1045  {
1046  if (array_key_exists('matrix_other_' . $this->getId() . "_" . $matches[1], $post_data) && strlen($post_data['matrix_other_' . $this->getId() . "_" . $matches[1]]) == 0)
1047  {
1048  return $this->lng->txt("question_mr_no_other_answer");
1049  }
1050  $counter++;
1051  if ((!is_array($value)) || (count($value) < 1))
1052  {
1053  return $this->lng->txt("matrix_question_checkbox_not_checked");
1054  }
1055  }
1056  }
1057  if ($counter != $this->getRowCount()) return $this->lng->txt("matrix_question_checkbox_not_checked");
1058  break;
1059  }
1060  return "";
1061  }
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.
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 1143 of file class.SurveyMatrixQuestion.php.

References $ilDB, and array.

1144  {
1145  parent::deleteAdditionalTableData($question_id);
1146 
1147  global $ilDB;
1148  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
1149  array('integer'),
1150  array($question_id)
1151  );
1152  }
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 266 of file class.SurveyMatrixQuestion.php.

References columns.

Referenced by loadFromDb().

267  {
268  $this->columns->flushCategories();
269  }
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 309 of file class.SurveyMatrixQuestion.php.

References rows.

310  {
311  $this->rows = new SurveyCategories();
312  }
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 956 of file class.SurveyMatrixQuestion.php.

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

957  {
958  return "svy_qst_matrix";
959  }
+ 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 364 of file class.SurveyMatrixQuestion.php.

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

365  {
366  switch ($a_index)
367  {
368  case 1:
369  return (strlen($this->bipolar_adjective2)) ? $this->bipolar_adjective2 : NULL;
370  break;
371  case 0:
372  default:
373  return (strlen($this->bipolar_adjective1)) ? $this->bipolar_adjective1 : NULL;
374  break;
375  }
376  return NULL;
377  }
+ 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 237 of file class.SurveyMatrixQuestion.php.

References columns.

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

238  {
239  return $this->columns->getCategory($index);
240  }
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 180 of file class.SurveyMatrixQuestion.php.

References columns.

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

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

◆ getColumnForScale()

SurveyMatrixQuestion::getColumnForScale (   $scale)

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

References columns.

243  {
244  return $this->columns->getCategoryForScale($scale);
245  }
Play around with inserting and removing rows and columns

◆ getColumnHeaderPosition()

SurveyMatrixQuestion::getColumnHeaderPosition ( )

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

Referenced by saveToDb().

1592  {
1593  return ($this->columnHeaderPosition) ? $this->columnHeaderPosition : 0;
1594  }
+ Here is the caller graph for this function:

◆ getColumnImages()

SurveyMatrixQuestion::getColumnImages ( )

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

Referenced by saveToDb().

1622  {
1623  return ($this->columnImages) ? 1 : 0;
1624  }
+ 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 254 of file class.SurveyMatrixQuestion.php.

References columns.

255  {
256  return $this->columns->getCategoryIndex($name);
257  }
Play around with inserting and removing rows and columns

◆ getColumnOrder()

SurveyMatrixQuestion::getColumnOrder ( )

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

Referenced by saveToDb().

1612  {
1613  return ($this->columnOrder) ? $this->columnOrder : 0;
1614  }
+ 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 1541 of file class.SurveyMatrixQuestion.php.

Referenced by saveToDb().

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

◆ getColumns()

SurveyMatrixQuestion::getColumns ( )

Return the columns.

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

References $columns.

225  {
226  return $this->columns;
227  }

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

Referenced by insertXML(), and saveToDb().

1217  {
1218  return ($this->columnSeparators) ? 1 : 0;
1219  }
+ Here is the caller graph for this function:

◆ getLayout()

SurveyMatrixQuestion::getLayout ( )

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

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

Referenced by insertXML(), and saveToDb().

1435  {
1436  if (!is_array($this->layout) || count($this->layout) == 0)
1437  {
1438  if ($this->hasBipolarAdjectives() && $this->hasNeutralColumn())
1439  {
1440  $this->layout = array(
1441  "percent_row" => 30,
1442  "percent_columns" => 40,
1443  "percent_bipolar_adjective1" => 10,
1444  "percent_bipolar_adjective2" => 10,
1445  "percent_neutral" => 10
1446  );
1447  }
1448  elseif ($this->hasBipolarAdjectives())
1449  {
1450  $this->layout = array(
1451  "percent_row" => 30,
1452  "percent_columns" => 50,
1453  "percent_bipolar_adjective1" => 10,
1454  "percent_bipolar_adjective2" => 10,
1455  "percent_neutral" => 0
1456  );
1457  }
1458  elseif ($this->hasNeutralColumn())
1459  {
1460  $this->layout = array(
1461  "percent_row" => 30,
1462  "percent_columns" => 50,
1463  "percent_bipolar_adjective1" => 0,
1464  "percent_bipolar_adjective2" => 0,
1465  "percent_neutral" => 20
1466  );
1467  }
1468  else
1469  {
1470  $this->layout = array(
1471  "percent_row" => 30,
1472  "percent_columns" => 70,
1473  "percent_bipolar_adjective1" => 0,
1474  "percent_bipolar_adjective2" => 0,
1475  "percent_neutral" => 0
1476  );
1477  }
1478  }
1479  return $this->layout;
1480  }
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 1561 of file class.SurveyMatrixQuestion.php.

Referenced by saveToDb().

1562  {
1563  return ($this->legend) ? 1 : 0;
1564  }
+ 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 1278 of file class.SurveyMatrixQuestion.php.

Referenced by insertXML(), and saveToDb().

1279  {
1280  return ($this->neutralColumnSeparator) ? 1 : 0;
1281  }
+ 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 1398 of file class.SurveyMatrixQuestion.php.

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

1399  {
1400  include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
1401  $step3 = new ilSelectInputGUI($title, $variable);
1402  $options = $this->getPreconditionOptions();
1403  $step3->setOptions($options);
1404  $step3->setValue($default);
1405  return $step3;
1406  }
This class represents a selection list property in a property form.
getPreconditionOptions()
Returns the options for preconditions.
if(!is_array($argv)) $options
+ 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 1387 of file class.SurveyMatrixQuestion.php.

1388  {
1389  return $value;
1390  }

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

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

437  {
438  global $ilDB;
439 
440  $result = $ilDB->queryF("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",
441  array('integer'),
442  array($id)
443  );
444  if ($result->numRows() == 1)
445  {
446  return $ilDB->fetchAssoc($result);
447  }
448  else
449  {
450  return array();
451  }
452  }
$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 945 of file class.SurveyMatrixQuestion.php.

946  {
947  return "SurveyMatrixQuestion";
948  }

◆ getRandomRows()

SurveyMatrixQuestion::getRandomRows ( )

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

Referenced by saveToDb().

1602  {
1603  return ($this->randomRows) ? 1 : 0;
1604  }
+ Here is the caller graph for this function:

◆ getRepeatColumnHeader()

SurveyMatrixQuestion::getRepeatColumnHeader ( )

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

Referenced by saveToDb().

1582  {
1583  return ($this->repeatColumnHeader) ? 1 : 0;
1584  }
+ 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 320 of file class.SurveyMatrixQuestion.php.

References rows.

Referenced by insertXML(), and saveRowsToDb().

321  {
322  return $this->rows->getCategory($a_index);
323  }
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 277 of file class.SurveyMatrixQuestion.php.

References rows.

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

278  {
279  return $this->rows->getCategoryCount();
280  }
Remove unnecessary rows
+ Here is the caller graph for this function:

◆ getRowImages()

SurveyMatrixQuestion::getRowImages ( )

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

Referenced by saveToDb().

1632  {
1633  return ($this->rowImages) ? 1 : 0;
1634  }
+ Here is the caller graph for this function:

◆ getRows()

SurveyMatrixQuestion::getRows ( )

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

References $rows.

1637  {
1638  return $this->rows;
1639  }

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

Referenced by insertXML(), and saveToDb().

1248  {
1249  return ($this->rowSeparators) ? 1 : 0;
1250  }
+ Here is the caller graph for this function:

◆ getSingleLineRowCaption()

SurveyMatrixQuestion::getSingleLineRowCaption ( )

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

Referenced by saveToDb().

1572  {
1573  return ($this->singleLineRowCaption) ? 1 : 0;
1574  }
+ 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 1160 of file class.SurveyMatrixQuestion.php.

References $subtype.

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

1161  {
1162  return $this->subtype;
1163  }
+ 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 967 of file class.SurveyMatrixQuestion.php.

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

968  {
969  $data = array();
970  foreach ($post_data as $key => $value)
971  {
972  switch ($this->getSubtype())
973  {
974  case 0:
975  if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches))
976  {
977  if (is_array($value))
978  {
979  foreach ($value as $val)
980  {
981  array_push($data, array("value" => $val, "rowvalue" => $matches[1], "textanswer" => $post_data['matrix_other_' . $this->getId() . '_' . $matches[1]]));
982  }
983  }
984  else
985  {
986  array_push($data, array("value" => $value, "rowvalue" => $matches[1], "textanswer" => $post_data['matrix_other_' . $this->getId() . '_' . $matches[1]]));
987  }
988  }
989  break;
990  case 1:
991  if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches))
992  {
993  if (is_array($value))
994  {
995  foreach ($value as $val)
996  {
997  array_push($data, array("value" => $val, "rowvalue" => $matches[1], "textanswer" => $post_data['matrix_other_' . $this->getId() . '_' . $matches[1]]));
998  }
999  }
1000  else
1001  {
1002  array_push($data, array("value" => $value, "rowvalue" => $matches[1], "textanswer" => $post_data['matrix_other_' . $this->getId() . '_' . $matches[1]]));
1003  }
1004  }
1005  break;
1006  }
1007  }
1008  return $data;
1009  }
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.
+ 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 1499 of file class.SurveyMatrixQuestion.php.

References getBipolarAdjective().

Referenced by getLayout().

1500  {
1501  if ((strlen($this->getBipolarAdjective(0))) && (strlen($this->getBipolarAdjective(1))))
1502  {
1503  return TRUE;
1504  }
1505  else
1506  {
1507  return FALSE;
1508  }
1509  }
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 1516 of file class.SurveyMatrixQuestion.php.

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

Referenced by getLayout().

1517  {
1518  for ($i = 0; $i < $this->getColumnCount(); $i++)
1519  {
1520  $column = $this->getColumn($i);
1521  if ($column->neutral && strlen($column->title)) return true;
1522  }
1523  return FALSE;
1524  }
getColumn($index)
Returns the name of a column for a given index.
$column
Definition: 39dropdown.php:62
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 1291 of file class.SurveyMatrixQuestion.php.

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

1292  {
1293  foreach ($a_meta as $key => $value)
1294  {
1295  switch ($value["label"])
1296  {
1297  case "column_separators":
1298  $this->setColumnSeparators($value["entry"]);
1299  break;
1300  case "row_separators":
1301  $this->setRowSeparators($value["entry"]);
1302  break;
1303  case "layout":
1304  $this->setLayout($value["entry"]);
1305  break;
1306  case "neutral_column_separator":
1307  $this->setNeutralColumnSeparator($value["entry"]);
1308  break;
1309  }
1310  }
1311  }
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.
+ 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 1319 of file class.SurveyMatrixQuestion.php.

References setBipolarAdjective().

1320  {
1321  $i = 0;
1322  foreach ($a_data as $adjective)
1323  {
1324  if (is_numeric($adjective["label"]))
1325  {
1326  $this->setBipolarAdjective($adjective["label"], $adjective["text"]);
1327  }
1328  else
1329  {
1330  $this->setBipolarAdjective($i, $adjective["text"]);
1331  }
1332  $i++;
1333  }
1334  }
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 1342 of file class.SurveyMatrixQuestion.php.

References $row, and addRow().

1343  {
1344  foreach ($a_data as $row)
1345  {
1346  $this->addRow($row['title'], $row['other'], $row['label']);
1347  }
1348  }
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 1356 of file class.SurveyMatrixQuestion.php.

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

1357  {
1358  foreach ($a_data as $id => $data)
1359  {
1360  $column = "";
1361  foreach ($data["material"] as $material)
1362  {
1363  $column .= $material["text"];
1364  }
1365  $this->columns->addCategory($column, null, (strcmp($data["label"], "neutral") == 0) ? true : false);
1366  }
1367  }
$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 747 of file class.SurveyMatrixQuestion.php.

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

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

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

531  {
532  if (
533  strlen($this->getTitle()) &&
534  strlen($this->getAuthor()) &&
535  strlen($this->getQuestiontext()) &&
536  $this->getColumnCount() &&
537  $this->getRowCount()
538  )
539  {
540  return 1;
541  }
542  else
543  {
544  return 0;
545  }
546  }
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 460 of file class.SurveyMatrixQuestion.php.

References $data, 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().

461  {
462  global $ilDB;
463  $result = $ilDB->queryF("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",
464  array('integer'),
465  array($id)
466  );
467  if ($result->numRows() == 1)
468  {
469  $data = $ilDB->fetchAssoc($result);
470  $this->setId($data["question_id"]);
471  $this->setTitle($data["title"]);
472  $this->label = $data['label'];
473  $this->setDescription($data["description"]);
474  $this->setObjId($data["obj_fi"]);
475  $this->setAuthor($data["author"]);
476  $this->setOwner($data["owner_fi"]);
477  include_once("./Services/RTE/classes/class.ilRTE.php");
478  $this->setQuestiontext(ilRTE::_replaceMediaObjectImageSrc($data["questiontext"], 1));
479  $this->setObligatory($data["obligatory"]);
480  $this->setComplete($data["complete"]);
481  $this->setOriginalId($data["original_id"]);
482  $this->setSubtype($data["subtype"]);
483  $this->setRowSeparators($data["row_separators"]);
484  $this->setNeutralColumnSeparator($data["neutral_column_separator"]);
485  $this->setColumnSeparators($data["column_separators"]);
486  $this->setColumnPlaceholders($data["column_placeholders"]);
487  $this->setLegend($data["legend"]);
488  $this->setSingleLineRowCaption($data["singleline_row_caption"]);
489  $this->setRepeatColumnHeader($data["repeat_column_header"]);
490  $this->setColumnHeaderPosition($data["column_header_position"]);
491  $this->setRandomRows($data["random_rows"]);
492  $this->setColumnOrder($data["column_order"]);
493  $this->setColumnImages($data["column_images"]);
494  $this->setRowImages($data["row_images"]);
495  $this->setBipolarAdjective(0, $data["bipolar_adjective1"]);
496  $this->setBipolarAdjective(1, $data["bipolar_adjective2"]);
497  $this->setLayout($data["layout"]);
498  $this->flushColumns();
499 
500  $result = $ilDB->queryF("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",
501  array('integer'),
502  array($id)
503  );
504  if ($result->numRows() > 0)
505  {
506  while ($data = $ilDB->fetchAssoc($result))
507  {
508  $this->columns->addCategory($data["title"], $data["other"], $data["neutral"], null, ($data['scale']) ? $data['scale'] : ($data['sequence'] + 1));
509  }
510  }
511 
512  $result = $ilDB->queryF("SELECT * FROM svy_qst_matrixrows WHERE question_fi = %s ORDER BY sequence",
513  array('integer'),
514  array($id)
515  );
516  while ($row = $ilDB->fetchAssoc($result))
517  {
518  $this->addRow($row["title"], $row['other'], $row['label']);
519  }
520  }
521  parent::loadFromDb($id);
522  }
$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 330 of file class.SurveyMatrixQuestion.php.

References rows.

331  {
332  $this->rows->moveCategoryDown($index);
333  }
Remove unnecessary rows

◆ moveRowUp()

SurveyMatrixQuestion::moveRowUp (   $index)

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

References rows.

326  {
327  $this->rows->moveCategoryUp($index);
328  }
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 192 of file class.SurveyMatrixQuestion.php.

References columns.

193  {
194  $this->columns->removeCategory($index);
195  }
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 204 of file class.SurveyMatrixQuestion.php.

References columns.

205  {
206  $this->columns->removeCategories($array);
207  }
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 216 of file class.SurveyMatrixQuestion.php.

References columns.

217  {
218  $this->columns->removeCategoryWithName($name);
219  }
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 352 of file class.SurveyMatrixQuestion.php.

References rows.

353  {
354  $this->rows->removeCategory($index);
355  }
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 342 of file class.SurveyMatrixQuestion.php.

References rows.

343  {
344  $this->rows->removeCategories($array);
345  }
Remove unnecessary rows

◆ saveBipolarAdjectives()

SurveyMatrixQuestion::saveBipolarAdjectives (   $adjective1,
  $adjective2 
)

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

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

605  {
606  global $ilDB;
607 
608  $affectedRows = $ilDB->manipulateF("UPDATE " . $this->getAdditionalTableName() . " SET bipolar_adjective1 = %s, bipolar_adjective2 = %s WHERE question_fi = %s",
609  array('text', 'text', 'integer'),
610  array((strlen($adjective1)) ? $adjective1 : NULL, (strlen($adjective2)) ? $adjective2 : NULL, $this->getId())
611  );
612  }
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 660 of file class.SurveyMatrixQuestion.php.

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

Referenced by saveToDb(), and syncWithOriginal().

661  {
662  global $ilDB;
663 
664  // save columns
665  $question_id = $this->getId();
666  if (strlen($original_id))
667  {
668  $question_id = $original_id;
669  }
670 
671  // delete existing column relations
672  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_variable WHERE question_fi = %s",
673  array('integer'),
674  array($question_id)
675  );
676  // create new column relations
677  for ($i = 0; $i < $this->getColumnCount(); $i++)
678  {
679  $cat = $this->getColumn($i);
680  $column_id = $this->saveColumnToDb($cat->title, $cat->neutral);
681  $next_id = $ilDB->nextId('svy_variable');
682  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, other, sequence, scale, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
683  array('integer','integer','integer','float','integer','integer', 'integer','integer'),
684  array($next_id, $column_id, $question_id, ($i + 1), $cat->other, $i, ($cat->scale > 0) ? $cat->scale : null, time())
685  );
686  }
687  $this->saveCompletionStatus($original_id);
688  }
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
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 622 of file class.SurveyMatrixQuestion.php.

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

Referenced by saveColumnsToDb().

623  {
624  global $ilUser, $ilDB;
625 
626  $result = $ilDB->queryF("SELECT title, category_id FROM svy_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
627  array('text', 'text', 'integer'),
628  array($columntext, $neutral, $ilUser->getId())
629  );
630  $insert = FALSE;
631  $returnvalue = "";
632  if ($result->numRows())
633  {
634  $insert = TRUE;
635  while ($row = $ilDB->fetchAssoc($result))
636  {
637  if (strcmp($row["title"], $columntext) == 0)
638  {
639  $returnvalue = $row["category_id"];
640  $insert = FALSE;
641  }
642  }
643  }
644  else
645  {
646  $insert = TRUE;
647  }
648  if ($insert)
649  {
650  $next_id = $ilDB->nextId('svy_category');
651  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, neutral, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
652  array('integer', 'text', 'text', 'integer', 'text', 'integer'),
653  array($next_id, $columntext, 0, $ilUser->getId(), $neutral, time())
654  );
655  $returnvalue = $next_id;
656  }
657  return $returnvalue;
658  }
$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 1417 of file class.SurveyMatrixQuestion.php.

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

1418  {
1419  global $ilDB;
1420 
1421  $layout = array(
1422  "percent_row" => $percent_row,
1423  "percent_columns" => $percent_columns,
1424  "percent_bipolar_adjective1" => $percent_bipolar_adjective1,
1425  "percent_bipolar_adjective2" => $percent_bipolar_adjective2,
1426  "percent_neutral" => $percent_neutral
1427  );
1428  $affectedRows = $ilDB->manipulateF("UPDATE " . $this->getAdditionalTableName() . " SET layout = %s WHERE question_fi = %s",
1429  array('text', 'integer'),
1430  array(serialize($layout), $this->getId())
1431  );
1432  }
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 909 of file class.SurveyMatrixQuestion.php.

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

910  {
911  global $ilUser;
912  global $ilDB;
913 
914  $next_id = $ilDB->nextId('svy_phrase');
915  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_phrase (phrase_id, title, defaultvalue, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
916  array('integer','text','text','integer','integer'),
917  array($next_id, $title, 1, $ilUser->getId(), time())
918  );
919  $phrase_id = $next_id;
920 
921  $counter = 1;
922  foreach ($_SESSION['save_phrase_data'] as $data)
923  {
924  $next_id = $ilDB->nextId('svy_category');
925  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, tstamp, neutral) VALUES (%s, %s, %s, %s, %s, %s)",
926  array('integer','text','text','integer','integer','text'),
927  array($next_id, $data['answer'], 1, $ilUser->getId(), time(), $data['neutral'])
928  );
929  $category_id = $next_id;
930  $next_id = $ilDB->nextId('svy_phrase_cat');
931  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_phrase_cat (phrase_category_id, phrase_fi, category_fi, sequence, other, scale) VALUES (%s, %s, %s, %s, %s, %s)",
932  array('integer', 'integer', 'integer','integer', 'integer', 'integer'),
933  array($next_id, $phrase_id, $category_id, $counter, ($data['other']) ? 1 : 0, $data['scale'])
934  );
935  $counter++;
936  }
937  }
$_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 690 of file class.SurveyMatrixQuestion.php.

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

Referenced by saveToDb(), and syncWithOriginal().

691  {
692  global $ilDB;
693 
694  // save rows
695  $question_id = $this->getId();
696  if (strlen($original_id))
697  {
698  $question_id = $original_id;
699  }
700 
701  // delete existing rows
702  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
703  array('integer'),
704  array($question_id)
705  );
706  // create new rows
707  for ($i = 0; $i < $this->getRowCount(); $i++)
708  {
709  $row = $this->getRow($i);
710  $next_id = $ilDB->nextId('svy_qst_matrixrows');
711  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_qst_matrixrows (id_svy_qst_matrixrows, title, label, other, sequence, question_fi) VALUES (%s, %s, %s, %s, %s, %s)",
712  array('integer','text','text','integer','integer','integer'),
713  array($next_id, $row->title, $row->label, ($row->other) ? 1 : 0, $i, $question_id)
714  );
715  }
716  $this->saveCompletionStatus($original_id);
717  }
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
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 553 of file class.SurveyMatrixQuestion.php.

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

554  {
555  global $ilDB;
556 
557  $affectedRows = parent::saveToDb($original_id);
558 
559  if ($affectedRows == 1)
560  {
561  $affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
562  array('integer'),
563  array($this->getId())
564  );
565  $affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (
566  question_fi, subtype, column_separators, row_separators, neutral_column_separator,column_placeholders,
567  legend, singleline_row_caption, repeat_column_header, column_header_position, random_rows,
568  column_order, column_images, row_images, bipolar_adjective1, bipolar_adjective2, layout, tstamp)
569  VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
570  array(
571  'integer', 'integer', 'text', 'text', 'text', 'integer', 'text', 'text', 'text',
572  'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer'
573  ),
574  array(
575  $this->getId(),
576  $this->getSubtype(),
577  $this->getColumnSeparators(),
578  $this->getRowSeparators(),
579  $this->getNeutralColumnSeparator(),
580  $this->getColumnPlaceholders(),
581  $this->getLegend(),
582  $this->getSingleLineRowCaption(),
583  $this->getRepeatColumnHeader(),
584  $this->getColumnHeaderPosition(),
585  $this->getRandomRows(),
586  $this->getColumnOrder(),
587  $this->getColumnImages(),
588  $this->getRowImages(),
589  $this->getBipolarAdjective(0),
590  $this->getBipolarAdjective(1),
591  serialize($this->getLayout()),
592  time()
593  )
594  );
595 
596  // saving material uris in the database
597  $this->saveMaterial();
598 
599  $this->saveColumnsToDb();
600  $this->saveRowsToDb();
601  }
602  }
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 1063 of file class.SurveyMatrixQuestion.php.

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

1064  {
1065  global $ilDB;
1066 
1067  $answer_data = array();
1068 
1069  // gather data
1070  switch ($this->getSubtype())
1071  {
1072  case 0:
1073  foreach ($post_data as $key => $value)
1074  {
1075  if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches))
1076  {
1077  if(strlen($value))
1078  {
1079  $other_value = (array_key_exists('matrix_other_' . $this->getId() . '_' . $matches[1], $post_data))
1080  ? ($post_data['matrix_other_' . $this->getId() . '_' . $matches[1]])
1081  : null;
1082  $answer_data[] = array("value"=>$value,
1083  "textanswer"=>$other_value,
1084  "rowvalue"=>$matches[1]);
1085  }
1086  }
1087  }
1088  break;
1089 
1090  case 1:
1091  foreach ($post_data as $key => $value)
1092  {
1093  if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches))
1094  {
1095  $other_value = (array_key_exists('matrix_other_' . $this->getId() . '_' . $matches[1], $post_data))
1096  ? ($post_data['matrix_other_' . $this->getId() . '_' . $matches[1]])
1097  : null;
1098  foreach ($value as $checked)
1099  {
1100  $answer_data[] = array("value"=>$checked,
1101  "textanswer"=>$other_value,
1102  "rowvalue"=>$matches[1]);
1103  }
1104  }
1105  }
1106  break;
1107  }
1108 
1109  if ($a_return)
1110  {
1111  return $answer_data;
1112  }
1113 
1114  // #16387 - only if any input
1115  if(sizeof($answer_data))
1116  {
1117  // save data
1118  foreach ($answer_data as $item)
1119  {
1120  $next_id = $ilDB->nextId('svy_answer');
1121  #20216
1122  $fields = array();
1123  $fields['answer_id'] = array("integer", $next_id);
1124  $fields['question_fi'] = array("integer", $this->getId());
1125  $fields['active_fi'] = array("integer", $active_id);
1126  $fields['value'] = array("float", $item['value']);
1127  $fields['textanswer'] = array("clob", $item['textanswer']);
1128  $fields['rowvalue'] = array("integer", $item['rowvalue']);
1129  $fields['tstamp'] = array("integer", time());
1130 
1131  $affectedRows = $ilDB->insert("svy_answer", $fields);
1132 
1133  }
1134  }
1135  }
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.
+ 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 386 of file class.SurveyMatrixQuestion.php.

Referenced by importAdjectives(), and loadFromDb().

387  {
388  switch ($a_index)
389  {
390  case 1:
391  $this->bipolar_adjective2 = $a_value;
392  break;
393  case 0:
394  default:
395  $this->bipolar_adjective1 = $a_value;
396  break;
397  }
398  }
+ Here is the caller graph for this function:

◆ setColumnHeaderPosition()

SurveyMatrixQuestion::setColumnHeaderPosition (   $a_value)

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

Referenced by loadFromDb().

1587  {
1588  $this->columnHeaderPosition = $a_value;
1589  }
+ Here is the caller graph for this function:

◆ setColumnImages()

SurveyMatrixQuestion::setColumnImages (   $a_value = 0)

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

Referenced by loadFromDb().

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

◆ setColumnOrder()

SurveyMatrixQuestion::setColumnOrder (   $a_value)

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

Referenced by loadFromDb().

1607  {
1608  $this->columnOrder = $a_value;
1609  }
+ 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 1531 of file class.SurveyMatrixQuestion.php.

Referenced by loadFromDb().

1532  {
1533  $this->columnPlaceholders = ($a_value) ? 1 : 0;
1534  }
+ 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 1196 of file class.SurveyMatrixQuestion.php.

Referenced by importAdditionalMetadata(), and loadFromDb().

1197  {
1198  switch ($enable)
1199  {
1200  case 1:
1201  $this->columnSeparators = 1;
1202  break;
1203  case 0:
1204  default:
1205  $this->columnSeparators = 0;
1206  break;
1207  }
1208  }
+ Here is the caller graph for this function:

◆ setLayout()

SurveyMatrixQuestion::setLayout (   $layout)

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

References $layout.

Referenced by importAdditionalMetadata(), and loadFromDb().

1483  {
1484  if (is_array($layout))
1485  {
1486  $this->layout = $layout;
1487  }
1488  else
1489  {
1490  $this->layout = unserialize($layout);
1491  }
1492  }
+ 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 1551 of file class.SurveyMatrixQuestion.php.

Referenced by loadFromDb().

1552  {
1553  $this->legend = ($a_value) ? 1 : 0;
1554  }
+ 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 1258 of file class.SurveyMatrixQuestion.php.

Referenced by importAdditionalMetadata(), and loadFromDb().

1259  {
1260  switch ($enable)
1261  {
1262  case 1:
1263  $this->neutralColumnSeparator = 1;
1264  break;
1265  case 0:
1266  default:
1267  $this->neutralColumnSeparator = 0;
1268  break;
1269  }
1270  }
+ Here is the caller graph for this function:

◆ setRandomRows()

SurveyMatrixQuestion::setRandomRows (   $a_value = 0)

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

Referenced by loadFromDb().

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

◆ setRepeatColumnHeader()

SurveyMatrixQuestion::setRepeatColumnHeader (   $a_value = 0)

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

Referenced by loadFromDb().

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

◆ setRowImages()

SurveyMatrixQuestion::setRowImages (   $a_value = 0)

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

Referenced by loadFromDb().

1627  {
1628  $this->rowImages = ($a_value) ? 1 : 0;
1629  }
+ 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 1227 of file class.SurveyMatrixQuestion.php.

Referenced by importAdditionalMetadata(), and loadFromDb().

1228  {
1229  switch ($enable)
1230  {
1231  case 1:
1232  $this->rowSeparators = 1;
1233  break;
1234  case 0:
1235  default:
1236  $this->rowSeparators = 0;
1237  break;
1238  }
1239  }
+ Here is the caller graph for this function:

◆ setSingleLineRowCaption()

SurveyMatrixQuestion::setSingleLineRowCaption (   $a_value = 0)

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

Referenced by loadFromDb().

1567  {
1568  $this->singleLineRowCaption = ($a_value) ? 1 : 0;
1569  }
+ 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 1171 of file class.SurveyMatrixQuestion.php.

Referenced by loadFromDb().

1172  {
1173  switch ($a_subtype)
1174  {
1175  case 1:
1176  case 2:
1177  case 3:
1178  case 4:
1179  case 5:
1180  case 6:
1181  $this->subtype = $a_subtype;
1182  break;
1183  case 0:
1184  default:
1185  $this->subtype = 0;
1186  break;
1187  }
1188  }
+ Here is the caller graph for this function:

◆ syncWithOriginal()

SurveyMatrixQuestion::syncWithOriginal ( )

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

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

877  {
878  if ($this->getOriginalId())
879  {
880  parent::syncWithOriginal();
881  $this->saveColumnsToDb($this->getOriginalId());
882  $this->saveRowsToDb($this->getOriginalId());
883  }
884  }
+ 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 725 of file class.SurveyMatrixQuestion.php.

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

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

1376  {
1377  return FALSE;
1378  }

Field Documentation

◆ $bipolar_adjective1

SurveyMatrixQuestion::$bipolar_adjective1

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

◆ $bipolar_adjective2

SurveyMatrixQuestion::$bipolar_adjective2

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

◆ $columnHeaderPosition

SurveyMatrixQuestion::$columnHeaderPosition

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

◆ $columnImages

SurveyMatrixQuestion::$columnImages

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

◆ $columnOrder

SurveyMatrixQuestion::$columnOrder

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

◆ $columnPlaceholders

SurveyMatrixQuestion::$columnPlaceholders

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

◆ $columns

SurveyMatrixQuestion::$columns

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

Referenced by getColumns().

◆ $columnSeparators

SurveyMatrixQuestion::$columnSeparators

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

◆ $layout

SurveyMatrixQuestion::$layout

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

Referenced by getLayout(), and setLayout().

◆ $legend

SurveyMatrixQuestion::$legend

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

◆ $neutralColumnSeparator

SurveyMatrixQuestion::$neutralColumnSeparator

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

◆ $openRows

SurveyMatrixQuestion::$openRows

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

◆ $randomRows

SurveyMatrixQuestion::$randomRows

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

◆ $repeatColumnHeader

SurveyMatrixQuestion::$repeatColumnHeader

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

◆ $rowImages

SurveyMatrixQuestion::$rowImages

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

◆ $rows

SurveyMatrixQuestion::$rows

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

Referenced by getRows().

◆ $rowSeparators

SurveyMatrixQuestion::$rowSeparators

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

◆ $singleLineRowCaption

SurveyMatrixQuestion::$singleLineRowCaption

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

◆ $subtype

SurveyMatrixQuestion::$subtype

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

Referenced by getSubtype().


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