ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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

 SurveyMatrixQuestion ( $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, $obligatory_state="")
 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...
 
 saveRandomData ($active_id)
 Saves random answers for a given active user in the database. More...
 
 saveUserInput ($post_data, $active_id, $a_return=false)
 
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database. More...
 
 getNrOfUsersAnswered ($survey_id, $finished_ids=null, $rowindex=null)
 Returns the number of users that answered the question for a given survey. More...
 
getCumulatedResultsForRow ($rowindex, $survey_id, $nr_of_users, $finished_ids)
 Returns the cumulated results for a given row. More...
 
getCumulatedResults ($survey_id, $nr_of_users, $finished_ids)
 Returns the cumulated results for the question. More...
 
 setExportCumulatedXLS (&$worksheet, &$format_title, &$format_bold, &$eval_data, $row, $export_label)
 Creates the Excel output for the cumulated results of this question. More...
 
setExportCumulatedCVS (&$eval_data, $export_label)
 Creates the CSV output for the cumulated results of this question. More...
 
 setExportDetailsXLS (&$workbook, &$format_title, &$format_bold, &$eval_data, $export_label)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 addUserSpecificResultsExportTitles (&$a_array, $a_use_label=false, $a_substitute=true)
 Adds the entries for the title row of the user specific results. More...
 
 addUserSpecificResultsData (&$a_array, &$resultset)
 Adds the values for the user specific results export for a given user. More...
 
getUserAnswers ($survey_id, $finished_ids)
 Returns an array containing all answers to this question in a given survey. 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 ()
 
 getCumulatedResultData ($survey_id, $counter, $finished_ids)
 Creates a the cumulated results data for the question. More...
 
- Public Member Functions inherited from SurveyQuestion
 SurveyQuestion ( $title="", $description="", $author="", $questiontext="", $owner=-1)
 SurveyQuestion constructor The constructor takes possible arguments an creates an instance of the SurveyQuestion object. More...
 
 _SurveyQuestion ()
 
 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...
 
 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="")
 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...
 
 _isComplete ($question_id)
 Checks whether the question is complete or not. 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...
 
 _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
 _getTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
 _getOriginalId ($question_id, $a_return_question_id_if_no_original=true)
 Returns the original id of a question. 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...
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. 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...
 
 _resolveInternalLink ($internal_link)
 
 _resolveIntLinks ($question_id)
 
 _getInternalLinkHref ($target="", $a_parent_ref_id=null)
 
 _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
 getQuestionTypeID ()
 Returns the question type ID of the question. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
_instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id. More...
 
_instanciateQuestionGUI ($question_id)
 Creates an instance of a question GUI with a given question id. 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...
 
 addUserSpecificResultsExportTitles (&$a_array, $a_use_label=false, $a_substitute=true)
 Adds the entries for the title row of the user specific results. More...
 
 addUserSpecificResultsData (&$a_array, &$resultset)
 Adds the values for the user specific results export for a given user. More...
 
getUserAnswers ($survey_id)
 Returns an array containing all answers to this question in a given survey. 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...
 
 setExportCumulatedXLS (&$worksheet, &$format_title, &$format_bold, &$eval_data, $row, $export_label)
 Creates the Excel output for the cumulated results of this question. More...
 
setExportCumulatedCVS (&$eval_data, $export_label)
 Creates the CSV output for the cumulated results of this question. More...
 
 setExportDetailsXLS (&$workbook, &$format_title, &$format_bold, &$eval_data, $export_label)
 Creates an Excel worksheet for the detailed cumulated results of this question. 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...
 
 outChart ($survey_id, $type="")
 Creates an image visualising the results of the question. More...
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 saveRandomData ($active_id)
 Saves random answers for a given active user in the database. More...
 
 getMaterial ()
 
 setSubtype ($a_subtype)
 
 getSubtype ()
 
 getCumulatedResultData ($survey_id, $counter, $finished_ids)
 Creates a the cumulated results data for the question. More...
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 getCopyIds ($a_group_by_survey=false)
 
 hasCopies ()
 
 getSkippedValue ()
 

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 _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 _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 Member Functions inherited from SurveyQuestion
calculateCumulatedResults ($survey_id, $finished_ids)
 
- Protected Attributes inherited from SurveyQuestion
 $cumulated
 An array containing the cumulated results of the question for a given survey. 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.

Member Function Documentation

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

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

442  {
443  global $ilDB;
444 
445  $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",
446  array('integer'),
447  array($id)
448  );
449  if ($result->numRows() == 1)
450  {
451  return $ilDB->fetchAssoc($result);
452  }
453  else
454  {
455  return array();
456  }
457  }
$result
global $ilDB
getAdditionalTableName()
Returns the name of the additional question data table in the database.
+ Here is the call graph for this function:

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

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

412  {
413  global $ilUser;
414  global $ilDB;
415 
416  $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",
417  array('integer', 'integer', 'integer'),
418  array($phrase_id, 0, $ilUser->getId())
419  );
420  while ($row = $ilDB->fetchAssoc($result))
421  {
422  $neutral = $row["neutral"];
423  if (($row["defaultvalue"] == 1) && ($row["owner_fi"] == 0))
424  {
425  $this->columns->addCategory($this->lng->txt($row["title"]), 0, $neutral);
426  }
427  else
428  {
429  $this->columns->addCategory($row["title"], 0, $neutral);
430  }
431  }
432  }
$result
global $ilUser
Definition: imgupload.php:15
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 292 of file class.SurveyMatrixQuestion.php.

Referenced by importMatrix(), and loadFromDb().

293  {
294  $this->rows->addCategory($a_text, $a_other, 0, $a_label);
295  }
+ 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 303 of file class.SurveyMatrixQuestion.php.

304  {
305  $this->rows->addCategoryAtPosition($a_text, $a_position, $a_other);
306  }

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

901  {
902  for ($i = $lower_limit; $i <= $upper_limit; $i++)
903  {
904  $this->columns->addCategory($i);
905  }
906  }

◆ addUserSpecificResultsData()

SurveyMatrixQuestion::addUserSpecificResultsData ( $a_array,
$resultset 
)

Adds the values for the user specific results export for a given user.

Parameters
array$a_arrayAn array which is used to append the values
array$resultsetThe evaluation data for a given user public

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

References $result, $row, getColumn(), getColumnCount(), SurveyQuestion\getId(), getRow(), getRowCount(), SurveyQuestion\getSkippedValue(), and getSubtype().

1815  {
1816  if (count($resultset["answers"][$this->getId()]))
1817  {
1818  array_push($a_array, "");
1819  switch ($this->getSubtype())
1820  {
1821  case 0:
1822  for ($i = 0; $i < $this->getRowCount(); $i++)
1823  {
1824  // add textanswer column for single choice mode
1825  $row = $this->getRow($i);
1826  $textanswer = "";
1827  $checked = FALSE;
1828  foreach ($resultset["answers"][$this->getId()] as $result)
1829  {
1830  if ($result["rowvalue"] == $i)
1831  {
1832  $checked = TRUE;
1833  array_push($a_array, $result["value"] + 1);
1834 
1835  if ($result["textanswer"])
1836  {
1837  $textanswer = $result["textanswer"];
1838  }
1839  }
1840  }
1841  if (!$checked)
1842  {
1843  array_push($a_array, $this->getSkippedValue());
1844  }
1845  if ($row->other)
1846  {
1847  array_push($a_array, $textanswer);
1848  }
1849  }
1850  break;
1851  case 1:
1852  for ($i = 0; $i < $this->getRowCount(); $i++)
1853  {
1854  // add textanswer column for multiple choice mode
1855  $row = $this->getRow($i);
1856  $textanswer = "";
1857  $checked = FALSE;
1858  $checked_values = array();
1859  foreach ($resultset["answers"][$this->getId()] as $result)
1860  {
1861  if ($result["rowvalue"] == $i)
1862  {
1863  $checked = TRUE;
1864  array_push($checked_values, $result["value"] + 1);
1865 
1866  if ($result["textanswer"])
1867  {
1868  $textanswer = $result["textanswer"];
1869  }
1870  }
1871  }
1872  if (!$checked)
1873  {
1874  array_push($a_array, $this->getSkippedValue());
1875  }
1876  else
1877  {
1878  array_push($a_array, "");
1879  }
1880  if ($row->other)
1881  {
1882  array_push($a_array, $textanswer);
1883  }
1884  for ($index = 0; $index < $this->getColumnCount(); $index++)
1885  {
1886  if (!$checked)
1887  {
1888  array_push($a_array, "");
1889  }
1890  else
1891  {
1892  $cat = $this->getColumn($index);
1893  $scale = $cat->scale;
1894  if (in_array($scale, $checked_values))
1895  {
1896  array_push($a_array, $scale);
1897  }
1898  else
1899  {
1900  array_push($a_array, 0);
1901  }
1902  }
1903  }
1904  }
1905  break;
1906  }
1907  }
1908  else
1909  {
1910  array_push($a_array, $this->getSkippedValue());
1911  for ($i = 0; $i < $this->getRowCount(); $i++)
1912  {
1913  array_push($a_array, "");
1914 
1915  // add empty "other" column if not answered
1916  $row = $this->getRow($i);
1917  if ($row->other)
1918  {
1919  array_push($a_array, "");
1920  }
1921 
1922  switch ($this->getSubtype())
1923  {
1924  case 0:
1925  break;
1926  case 1:
1927  for ($index = 0; $index < $this->getColumnCount(); $index++)
1928  {
1929  array_push($a_array, "");
1930  }
1931  break;
1932  }
1933  }
1934  }
1935  }
$result
getRow($a_index)
Returns a specific row.
getColumn($index)
Returns the name of a column for a given index.
getId()
Gets the id of the SurveyQuestion object.
getSubtype()
Returns the subtype of the matrix question.
getColumnCount()
Returns the number of columns.
getRowCount()
Returns the number of rows in the question.
+ Here is the call graph for this function:

◆ addUserSpecificResultsExportTitles()

SurveyMatrixQuestion::addUserSpecificResultsExportTitles ( $a_array,
  $a_use_label = false,
  $a_substitute = true 
)

Adds the entries for the title row of the user specific results.

Parameters
array$a_arrayAn array which is used to append the title row entries public

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

References $row, SurveyQuestion\$title, getColumn(), getColumnCount(), getRow(), getRowCount(), and getSubtype().

1748  {
1749  parent::addUserSpecificResultsExportTitles($a_array, $a_use_label, $a_substitute);
1750 
1751  for ($i = 0; $i < $this->getRowCount(); $i++)
1752  {
1753  // create row title according label, add 'other column'
1754  $row = $this->getRow($i);
1755 
1756  if(!$a_use_label)
1757  {
1758  $title = $row->title;
1759  }
1760  else
1761  {
1762  if($a_substitute)
1763  {
1764  $title = $row->label ? $row->label : $row->title;
1765  }
1766  else
1767  {
1768  $title = $row->label;
1769  }
1770  }
1771  array_push($a_array, $title);
1772 
1773  if ($row->other)
1774  {
1775  if(!$a_use_label || $a_substitute)
1776  {
1777  array_push($a_array, $title. ' - '. $this->lng->txt('other'));
1778  }
1779  else
1780  {
1781  array_push($a_array, "");
1782  }
1783  }
1784 
1785  switch ($this->getSubtype())
1786  {
1787  case 0:
1788  break;
1789  case 1:
1790  for ($index = 0; $index < $this->getColumnCount(); $index++)
1791  {
1792  $col = $this->getColumn($index);
1793  if(!$a_use_label || $a_substitute)
1794  {
1795  array_push($a_array, ($index+1) . " - " . $col->title);
1796  }
1797  else
1798  {
1799  array_push($a_array, "");
1800  }
1801  }
1802  break;
1803  }
1804  }
1805  }
getRow($a_index)
Returns a specific row.
getColumn($index)
Returns the name of a column for a given index.
getSubtype()
Returns the subtype of the matrix question.
getColumnCount()
Returns the number of columns.
getRowCount()
Returns the number of rows in the question.
+ Here is the call graph for this function:

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

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

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

References $ilDB.

1181  {
1182  parent::deleteAdditionalTableData($question_id);
1183 
1184  global $ilDB;
1185  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_qst_matrixrows WHERE question_fi = %s",
1186  array('integer'),
1187  array($question_id)
1188  );
1189  }
global $ilDB

◆ flushColumns()

SurveyMatrixQuestion::flushColumns ( )

Empties the columns list.

public

See also
$columns

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

Referenced by loadFromDb().

272  {
273  $this->columns->flushCategories();
274  }
+ Here is the caller graph for this function:

◆ flushRows()

SurveyMatrixQuestion::flushRows ( )

Empties the row list.

public

See also
$rows

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

315  {
316  $this->rows = new SurveyCategories();
317  }
Class SurveyCategories.

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

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

963  {
964  return "svy_qst_matrix";
965  }
+ 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 369 of file class.SurveyMatrixQuestion.php.

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

370  {
371  switch ($a_index)
372  {
373  case 1:
374  return (strlen($this->bipolar_adjective2)) ? $this->bipolar_adjective2 : NULL;
375  break;
376  case 0:
377  default:
378  return (strlen($this->bipolar_adjective1)) ? $this->bipolar_adjective1 : NULL;
379  break;
380  }
381  return NULL;
382  }
+ 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 242 of file class.SurveyMatrixQuestion.php.

Referenced by addUserSpecificResultsData(), addUserSpecificResultsExportTitles(), getCumulatedResults(), getCumulatedResultsForRow(), hasNeutralColumn(), insertXML(), and saveColumnsToDb().

243  {
244  return $this->columns->getCategory($index);
245  }
+ 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 185 of file class.SurveyMatrixQuestion.php.

Referenced by addUserSpecificResultsData(), addUserSpecificResultsExportTitles(), getCumulatedResults(), getCumulatedResultsForRow(), hasNeutralColumn(), insertXML(), isComplete(), saveColumnsToDb(), and saveRandomData().

186  {
187  return $this->columns->getCategoryCount();
188  }
+ Here is the caller graph for this function:

◆ getColumnForScale()

SurveyMatrixQuestion::getColumnForScale (   $scale)

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

Referenced by getCumulatedResults(), getCumulatedResultsForRow(), and getUserAnswers().

248  {
249  return $this->columns->getCategoryForScale($scale);
250  }
+ Here is the caller graph for this function:

◆ getColumnHeaderPosition()

SurveyMatrixQuestion::getColumnHeaderPosition ( )

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

Referenced by saveToDb().

2413  {
2414  return ($this->columnHeaderPosition) ? $this->columnHeaderPosition : 0;
2415  }
+ Here is the caller graph for this function:

◆ getColumnImages()

SurveyMatrixQuestion::getColumnImages ( )

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

Referenced by saveToDb().

2443  {
2444  return ($this->columnImages) ? 1 : 0;
2445  }
+ 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 259 of file class.SurveyMatrixQuestion.php.

260  {
261  return $this->columns->getCategoryIndex($name);
262  }

◆ getColumnOrder()

SurveyMatrixQuestion::getColumnOrder ( )

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

Referenced by saveToDb().

2433  {
2434  return ($this->columnOrder) ? $this->columnOrder : 0;
2435  }
+ 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 2362 of file class.SurveyMatrixQuestion.php.

Referenced by saveToDb().

2363  {
2364  return ($this->columnPlaceholders) ? 1 : 0;
2365  }
+ Here is the caller graph for this function:

◆ getColumns()

SurveyMatrixQuestion::getColumns ( )

Return the columns.

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

References $columns.

230  {
231  return $this->columns;
232  }

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

Referenced by insertXML(), and saveToDb().

2038  {
2039  return ($this->columnSeparators) ? 1 : 0;
2040  }
+ Here is the caller graph for this function:

◆ getCumulatedResultData()

SurveyMatrixQuestion::getCumulatedResultData (   $survey_id,
  $counter,
  $finished_ids 
)

Creates a the cumulated results data for the question.

Returns
array Data

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

References SurveyQuestion\$cumulated, SurveyQuestion\$questiontext, $result, $row, SurveyQuestion\$survey_id, SurveyQuestion\calculateCumulatedResults(), and SurveyQuestion\getQuestiontext().

2468  {
2469  $cumulated =& $this->calculateCumulatedResults($survey_id, $finished_ids);
2470  $questiontext = preg_replace("/<[^>]+?>/ims", "", $this->getQuestiontext());
2471 
2472  include_once "./Services/Utilities/classes/class.ilStr.php";
2473  $maxlen = 75;
2474  if (strlen($questiontext) > $maxlen + 3)
2475  {
2476  $questiontext = ilStr::substr($questiontext, 0, $maxlen) . "...";
2477  }
2478 
2479  $result = array();
2480  $row = array(
2481  'counter' => $counter,
2482  'title' => $counter.'. '.$this->getTitle(),
2483  'question' => $questiontext,
2484  'users_answered' => $cumulated['TOTAL']['USERS_ANSWERED'],
2485  'users_skipped' => $cumulated['TOTAL']['USERS_SKIPPED'],
2486  'question_type' => $this->lng->txt($cumulated['TOTAL']['QUESTION_TYPE']),
2487  'mode' => $cumulated['TOTAL']['MODE'],
2488  'mode_nr_of_selections' => $cumulated['TOTAL']['MODE_NR_OF_SELECTIONS'],
2489  'median' => $cumulated['TOTAL']['MEDIAN'],
2490  'arithmetic_mean' => $cumulated['TOTAL']['ARITHMETIC_MEAN']
2491  );
2492  array_push($result, $row);
2493  $maxlen -= 3;
2494  foreach ($cumulated as $key => $value)
2495  {
2496  if (is_numeric($key))
2497  {
2498  if (strlen($value['ROW']) > $maxlen + 3)
2499  {
2500  $value['ROW'] = ilStr::substr($value['ROW'], 0, $maxlen) . "...";
2501  }
2502 
2503  $row = array(
2504  'title' => '',
2505  'question' => ($key+1) . ". " . $value['ROW'],
2506  'users_answered' => $value['USERS_ANSWERED'],
2507  'users_skipped' => $value['USERS_SKIPPED'],
2508  'question_type' => '',
2509  'mode' => $value["MODE"],
2510  'mode_nr_of_selections' => $value["MODE_NR_OF_SELECTIONS"],
2511  'median' => $value["MEDIAN"],
2512  'arithmetic_mean' => $value["ARITHMETIC_MEAN"]
2513  );
2514  array_push($result, $row);
2515  }
2516  }
2517  return $result;
2518  }
$cumulated
An array containing the cumulated results of the question for a given survey.
$result
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
& calculateCumulatedResults($survey_id, $finished_ids)
+ Here is the call graph for this function:

◆ getCumulatedResults()

& SurveyMatrixQuestion::getCumulatedResults (   $survey_id,
  $nr_of_users,
  $finished_ids 
)

Returns the cumulated results for the question.

Parameters
integer$survey_idThe database ID of the survey
Returns
integer The number of users who took part in the survey public

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

References SurveyQuestion\$cumulated, $ilDB, $result, $row, SurveyQuestion\$survey_id, $total, getColumn(), getColumnCount(), getColumnForScale(), getCumulatedResultsForRow(), SurveyQuestion\getId(), getNrOfUsersAnswered(), getRowCount(), and getSubtype().

1352  {
1353  global $ilDB;
1354 
1355  $question_id = $this->getId();
1356 
1357  $result_array = array();
1358  $cumulated = array();
1359 
1360  $sql = "SELECT svy_answer.* FROM svy_answer".
1361  " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
1362  " WHERE svy_answer.question_fi = ".$ilDB->quote($question_id, "integer").
1363  " AND svy_finished.survey_fi = ".$ilDB->quote($survey_id, "integer");
1364  if($finished_ids)
1365  {
1366  $sql .= " AND ".$ilDB->in("svy_finished.finished_id", $finished_ids, "", "integer");
1367  }
1368  $result = $ilDB->query($sql);
1369 
1370  switch ($this->getSubtype())
1371  {
1372  case 0:
1373  case 1:
1374  while ($row = $ilDB->fetchAssoc($result))
1375  {
1376  $cumulated[$row["value"]]++;
1377  }
1378  asort($cumulated, SORT_NUMERIC);
1379  end($cumulated);
1380  break;
1381  }
1382  $numrows = $result->numRows();
1383  $result_array["USERS_ANSWERED"] = $this->getNrOfUsersAnswered($survey_id, $finished_ids);
1384  $result_array["USERS_SKIPPED"] = $nr_of_users - $this->getNrOfUsersAnswered($survey_id, $finished_ids);
1385 
1386  if(sizeof($cumulated))
1387  {
1388  $prefix = "";
1389  if (strcmp(key($cumulated), "") != 0)
1390  {
1391  $prefix = (key($cumulated)+1) . " - ";
1392  }
1393  $cat = $this->getColumnForScale(key($cumulated)+1);
1394  $result_array["MODE"] = $prefix . $cat->title;
1395  $result_array["MODE_VALUE"] = key($cumulated)+1;
1396  $result_array["MODE_NR_OF_SELECTIONS"] = $cumulated[key($cumulated)];
1397  }
1398  for ($key = 0; $key < $this->getColumnCount(); $key++)
1399  {
1400  $cat = $this->getColumn($key);
1401  $scale = $cat->scale-1;
1402 
1403  $percentage = 0;
1404  if ($numrows > 0)
1405  {
1406  $percentage = (float)((int)$cumulated[$scale]/$numrows);
1407  }
1408 
1409  $result_array["variables"][$key] = array("title" => $cat->title, "selected" => (int)$cumulated[$scale], "percentage" => $percentage);
1410  }
1411  ksort($cumulated, SORT_NUMERIC);
1412  $median = array();
1413  $total = 0;
1414  foreach ($cumulated as $value => $key)
1415  {
1416  $total += $key;
1417  for ($i = 0; $i < $key; $i++)
1418  {
1419  array_push($median, $value+1);
1420  }
1421  }
1422  if ($total > 0)
1423  {
1424  if (($total % 2) == 0)
1425  {
1426  $median_value = 0.5 * ($median[($total/2)-1] + $median[($total/2)]);
1427  if (round($median_value) != $median_value)
1428  {
1429  $cat = $this->getColumnForScale((int)floor($median_value));
1430  $cat2 = $this->getColumnForScale((int)ceil($median_value));
1431  $median_value = $median_value . "<br />" . "(" . $this->lng->txt("median_between") . " " . (floor($median_value)) . "-" . $cat->title . " " . $this->lng->txt("and") . " " . (ceil($median_value)) . "-" . $cat2->title . ")";
1432  }
1433  }
1434  else
1435  {
1436  $median_value = $median[(($total+1)/2)-1];
1437  }
1438  }
1439  else
1440  {
1441  $median_value = "";
1442  }
1443  $result_array["ARITHMETIC_MEAN"] = "";
1444  $result_array["MEDIAN"] = $median_value;
1445  $result_array["QUESTION_TYPE"] = "SurveyMatrixQuestion";
1446 
1447  $cumulated_results = array();
1448  $cumulated_results["TOTAL"] = $result_array;
1449  for ($i = 0; $i < $this->getRowCount(); $i++)
1450  {
1451  $rowresult =& $this->getCumulatedResultsForRow($i, $survey_id, $nr_of_users, $finished_ids);
1452  $cumulated_results[$i] = $rowresult;
1453  }
1454  return $cumulated_results;
1455  }
$cumulated
An array containing the cumulated results of the question for a given survey.
$result
getNrOfUsersAnswered($survey_id, $finished_ids=null, $rowindex=null)
Returns the number of users that answered the question for a given survey.
getColumn($index)
Returns the name of a column for a given index.
getId()
Gets the id of the SurveyQuestion object.
getSubtype()
Returns the subtype of the matrix question.
& getCumulatedResultsForRow($rowindex, $survey_id, $nr_of_users, $finished_ids)
Returns the cumulated results for a given row.
global $ilDB
getColumnCount()
Returns the number of columns.
getRowCount()
Returns the number of rows in the question.
+ Here is the call graph for this function:

◆ getCumulatedResultsForRow()

& SurveyMatrixQuestion::getCumulatedResultsForRow (   $rowindex,
  $survey_id,
  $nr_of_users,
  $finished_ids 
)

Returns the cumulated results for a given row.

Parameters
integer$rowThe index of the row
integer$survey_idThe database ID of the survey
Returns
integer The number of users who took part in the survey public

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

References SurveyQuestion\$cumulated, $ilDB, $result, $row, SurveyQuestion\$survey_id, $total, getColumn(), getColumnCount(), getColumnForScale(), SurveyQuestion\getId(), getNrOfUsersAnswered(), getRow(), and getSubtype().

Referenced by getCumulatedResults().

1234  {
1235  global $ilDB;
1236 
1237  $question_id = $this->getId();
1238 
1239  $result_array = array();
1240  $cumulated = array();
1241 
1242  $sql = "SELECT svy_answer.* FROM svy_answer".
1243  " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
1244  " WHERE svy_answer.question_fi = ".$ilDB->quote($question_id, "integer").
1245  " AND svy_answer.rowvalue = ".$ilDB->quote($rowindex, "integer").
1246  " AND svy_finished.survey_fi = ".$ilDB->quote($survey_id, "integer");
1247  if($finished_ids)
1248  {
1249  $sql .= " AND ".$ilDB->in("svy_finished.finished_id", $finished_ids, "", "integer");
1250  }
1251  $result = $ilDB->query($sql);
1252 
1253  switch ($this->getSubtype())
1254  {
1255  case 0:
1256  case 1:
1257  while ($row = $ilDB->fetchAssoc($result))
1258  {
1259  $cumulated[$row["value"]]++;
1260 
1261  // add text value to result array
1262  if ($row["textanswer"])
1263  {
1264  $result_array["textanswers"][$row["value"]][] = $row["textanswer"];
1265  }
1266  }
1267  // sort textanswers by value
1268  if (is_array($result_array["textanswers"]))
1269  {
1270  ksort($result_array["textanswers"], SORT_NUMERIC);
1271  }
1272  asort($cumulated, SORT_NUMERIC);
1273  end($cumulated);
1274  break;
1275  }
1276  $numrows = $result->numRows();
1277  $result_array["USERS_ANSWERED"] = $this->getNrOfUsersAnswered($survey_id, $finished_ids, $rowindex);
1278  $result_array["USERS_SKIPPED"] = $nr_of_users - $result_array["USERS_ANSWERED"];
1279 
1280  if(sizeof($cumulated))
1281  {
1282  $prefix = "";
1283  if (strcmp(key($cumulated), "") != 0)
1284  {
1285  $prefix = (key($cumulated)+1) . " - ";
1286  }
1287  $cat = $this->getColumnForScale(key($cumulated)+1);
1288  $result_array["MODE"] = $prefix . $cat->title;
1289  $result_array["MODE_VALUE"] = key($cumulated)+1;
1290  $result_array["MODE_NR_OF_SELECTIONS"] = $cumulated[key($cumulated)];
1291  }
1292  for ($key = 0; $key < $this->getColumnCount(); $key++)
1293  {
1294  $cat = $this->getColumn($key);
1295  $scale = $cat->scale-1;
1296 
1297  $percentage = 0;
1298  if ($numrows > 0)
1299  {
1300  $percentage = (float)((int)$cumulated[$scale]/$numrows);
1301  }
1302 
1303  $result_array["variables"][$key] = array("title" => $cat->title, "selected" => (int)$cumulated[$scale], "percentage" => $percentage);
1304  }
1305  ksort($cumulated, SORT_NUMERIC);
1306  $median = array();
1307  $total = 0;
1308  foreach ($cumulated as $value => $key)
1309  {
1310  $total += $key;
1311  for ($i = 0; $i < $key; $i++)
1312  {
1313  array_push($median, $value+1);
1314  }
1315  }
1316  if ($total > 0)
1317  {
1318  if (($total % 2) == 0)
1319  {
1320  $median_value = 0.5 * ($median[($total/2)-1] + $median[($total/2)]);
1321  if (round($median_value) != $median_value)
1322  {
1323  $cat = $this->getColumnForScale((int)floor($median_value));
1324  $cat2 = $this->getColumnForScale((int)ceil($median_value));
1325  $median_value = $median_value . "<br />" . "(" . $this->lng->txt("median_between") . " " . (floor($median_value)) . "-" . $cat->title . " " . $this->lng->txt("and") . " " . (ceil($median_value)) . "-" . $cat2->title . ")";
1326  }
1327  }
1328  else
1329  {
1330  $median_value = $median[(($total+1)/2)-1];
1331  }
1332  }
1333  else
1334  {
1335  $median_value = "";
1336  }
1337  $result_array["ARITHMETIC_MEAN"] = "";
1338  $result_array["MEDIAN"] = $median_value;
1339  $result_array["QUESTION_TYPE"] = "SurveyMatrixQuestion";
1340  $result_array["ROW"] = $this->getRow($rowindex)->title;
1341  return $result_array;
1342  }
$cumulated
An array containing the cumulated results of the question for a given survey.
$result
getRow($a_index)
Returns a specific row.
getNrOfUsersAnswered($survey_id, $finished_ids=null, $rowindex=null)
Returns the number of users that answered the question for a given survey.
getColumn($index)
Returns the name of a column for a given index.
getId()
Gets the id of the SurveyQuestion object.
getSubtype()
Returns the subtype of the matrix question.
global $ilDB
getColumnCount()
Returns the number of columns.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLayout()

SurveyMatrixQuestion::getLayout ( )

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

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

Referenced by insertXML(), and saveToDb().

2256  {
2257  if (!is_array($this->layout) || count($this->layout) == 0)
2258  {
2259  if ($this->hasBipolarAdjectives() && $this->hasNeutralColumn())
2260  {
2261  $this->layout = array(
2262  "percent_row" => 30,
2263  "percent_columns" => 40,
2264  "percent_bipolar_adjective1" => 10,
2265  "percent_bipolar_adjective2" => 10,
2266  "percent_neutral" => 10
2267  );
2268  }
2269  elseif ($this->hasBipolarAdjectives())
2270  {
2271  $this->layout = array(
2272  "percent_row" => 30,
2273  "percent_columns" => 50,
2274  "percent_bipolar_adjective1" => 10,
2275  "percent_bipolar_adjective2" => 10,
2276  "percent_neutral" => 0
2277  );
2278  }
2279  elseif ($this->hasNeutralColumn())
2280  {
2281  $this->layout = array(
2282  "percent_row" => 30,
2283  "percent_columns" => 50,
2284  "percent_bipolar_adjective1" => 0,
2285  "percent_bipolar_adjective2" => 0,
2286  "percent_neutral" => 20
2287  );
2288  }
2289  else
2290  {
2291  $this->layout = array(
2292  "percent_row" => 30,
2293  "percent_columns" => 70,
2294  "percent_bipolar_adjective1" => 0,
2295  "percent_bipolar_adjective2" => 0,
2296  "percent_neutral" => 0
2297  );
2298  }
2299  }
2300  return $this->layout;
2301  }
hasBipolarAdjectives()
Returns TRUE if bipolar adjectives exist.
hasNeutralColumn()
Returns TRUE if a neutral column exists.
+ 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 2382 of file class.SurveyMatrixQuestion.php.

Referenced by saveToDb().

2383  {
2384  return ($this->legend) ? 1 : 0;
2385  }
+ 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 2099 of file class.SurveyMatrixQuestion.php.

Referenced by insertXML(), and saveToDb().

2100  {
2101  return ($this->neutralColumnSeparator) ? 1 : 0;
2102  }
+ Here is the caller graph for this function:

◆ getNrOfUsersAnswered()

SurveyMatrixQuestion::getNrOfUsersAnswered (   $survey_id,
  $finished_ids = null,
  $rowindex = null 
)

Returns the number of users that answered the question for a given survey.

Parameters
integer$survey_idThe database ID of the survey
Returns
integer The number of users public

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

References $ilDB, $result, $row, SurveyQuestion\$survey_id, and SurveyQuestion\getId().

Referenced by getCumulatedResults(), and getCumulatedResultsForRow().

1199  {
1200  global $ilDB;
1201 
1202  $sql = "SELECT svy_answer.active_fi, svy_answer.question_fi".
1203  " FROM svy_answer".
1204  " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
1205  " WHERE svy_answer.question_fi = ".$ilDB->quote($this->getId(), "integer").
1206  " AND svy_finished.survey_fi = ".$ilDB->quote($survey_id, "integer");
1207  if($finished_ids)
1208  {
1209  $sql .= " AND ".$ilDB->in("svy_finished.finished_id", $finished_ids, "", "integer");
1210  }
1211  if($rowindex)
1212  {
1213  $sql .= " AND rowvalue = ".$ilDB->quote($rowindex, "integer");
1214  }
1215 
1216  $result = $ilDB->query($sql);
1217  $found = array();
1218  while ($row = $ilDB->fetchAssoc($result))
1219  {
1220  $found[$row["active_fi"].$row["question_fi"]] = 1;
1221  }
1222  return count($found);
1223  }
$result
getId()
Gets the id of the SurveyQuestion object.
global $ilDB
+ Here is the call graph for this function:
+ 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 2219 of file class.SurveyMatrixQuestion.php.

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

2220  {
2221  include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
2222  $step3 = new ilSelectInputGUI($title, $variable);
2223  $options = $this->getPreconditionOptions();
2224  $step3->setOptions($options);
2225  $step3->setValue($default);
2226  return $step3;
2227  }
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 2208 of file class.SurveyMatrixQuestion.php.

2209  {
2210  return $value;
2211  }

◆ getQuestionType()

SurveyMatrixQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

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

952  {
953  return "SurveyMatrixQuestion";
954  }

◆ getRandomRows()

SurveyMatrixQuestion::getRandomRows ( )

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

Referenced by saveToDb().

2423  {
2424  return ($this->randomRows) ? 1 : 0;
2425  }
+ Here is the caller graph for this function:

◆ getRepeatColumnHeader()

SurveyMatrixQuestion::getRepeatColumnHeader ( )

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

Referenced by saveToDb().

2403  {
2404  return ($this->repeatColumnHeader) ? 1 : 0;
2405  }
+ 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 325 of file class.SurveyMatrixQuestion.php.

Referenced by addUserSpecificResultsData(), addUserSpecificResultsExportTitles(), getCumulatedResultsForRow(), getUserAnswers(), insertXML(), and saveRowsToDb().

326  {
327  return $this->rows->getCategory($a_index);
328  }
+ 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 282 of file class.SurveyMatrixQuestion.php.

Referenced by addUserSpecificResultsData(), addUserSpecificResultsExportTitles(), checkUserInput(), getCumulatedResults(), insertXML(), isComplete(), saveRandomData(), and saveRowsToDb().

283  {
284  return $this->rows->getCategoryCount();
285  }
+ Here is the caller graph for this function:

◆ getRowImages()

SurveyMatrixQuestion::getRowImages ( )

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

Referenced by saveToDb().

2453  {
2454  return ($this->rowImages) ? 1 : 0;
2455  }
+ Here is the caller graph for this function:

◆ getRows()

SurveyMatrixQuestion::getRows ( )

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

References $rows.

2458  {
2459  return $this->rows;
2460  }

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

Referenced by insertXML(), and saveToDb().

2069  {
2070  return ($this->rowSeparators) ? 1 : 0;
2071  }
+ Here is the caller graph for this function:

◆ getSingleLineRowCaption()

SurveyMatrixQuestion::getSingleLineRowCaption ( )

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

Referenced by saveToDb().

2393  {
2394  return ($this->singleLineRowCaption) ? 1 : 0;
2395  }
+ 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 1981 of file class.SurveyMatrixQuestion.php.

References $subtype.

Referenced by addUserSpecificResultsData(), addUserSpecificResultsExportTitles(), checkUserInput(), getCumulatedResults(), getCumulatedResultsForRow(), getWorkingDataFromUserInput(), insertXML(), saveToDb(), and saveUserInput().

1982  {
1983  return $this->subtype;
1984  }
+ Here is the caller graph for this function:

◆ getUserAnswers()

& SurveyMatrixQuestion::getUserAnswers (   $survey_id,
  $finished_ids 
)

Returns an array containing all answers to this question in a given survey.

Parameters
integer$survey_idThe database ID of the survey
Returns
array An array containing the answers to the question. The keys are either the user id or the anonymous id public

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

References $ilDB, $result, $row, SurveyQuestion\$survey_id, getColumnForScale(), SurveyQuestion\getId(), and getRow().

1945  {
1946  global $ilDB;
1947 
1948  $answers = array();
1949 
1950  $sql = "SELECT svy_answer.* FROM svy_answer".
1951  " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
1952  " WHERE svy_answer.question_fi = ".$ilDB->quote($this->getId(), "integer").
1953  " AND svy_finished.survey_fi = ".$ilDB->quote($survey_id, "integer");
1954  if($finished_ids)
1955  {
1956  $sql .= " AND ".$ilDB->in("svy_finished.finished_id", $finished_ids, "", "integer");
1957  }
1958  $sql .= " ORDER BY rowvalue, value";
1959  $result = $ilDB->query($sql);
1960 
1961  while ($row = $ilDB->fetchAssoc($result))
1962  {
1963  $column = $this->getColumnForScale($row["value"]+1);
1964  if (!is_array($answers[$row["active_fi"]])) $answers[$row["active_fi"]] = array();
1965  $rowobj = $this->getRow($row["rowvalue"]);
1966  array_push($answers[$row["active_fi"]], $rowobj->title . (($rowobj->other) ? (" " . $row["textanswer"]) : "") . ": " . ($row["value"] + 1) . " - " . $column->title);
1967  }
1968  foreach ($answers as $key => $value)
1969  {
1970  $answers[$key] = implode("<br />", $value);
1971  }
1972  return $answers;
1973  }
$result
getRow($a_index)
Returns a specific row.
getId()
Gets the id of the SurveyQuestion object.
global $ilDB
+ Here is the call 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 973 of file class.SurveyMatrixQuestion.php.

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

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

References getBipolarAdjective().

Referenced by getLayout().

2321  {
2322  if ((strlen($this->getBipolarAdjective(0))) && (strlen($this->getBipolarAdjective(1))))
2323  {
2324  return TRUE;
2325  }
2326  else
2327  {
2328  return FALSE;
2329  }
2330  }
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 2337 of file class.SurveyMatrixQuestion.php.

References getColumn(), and getColumnCount().

Referenced by getLayout().

2338  {
2339  for ($i = 0; $i < $this->getColumnCount(); $i++)
2340  {
2341  $column = $this->getColumn($i);
2342  if ($column->neutral && strlen($column->title)) return true;
2343  }
2344  return FALSE;
2345  }
getColumn($index)
Returns the name of a column for a given index.
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 2112 of file class.SurveyMatrixQuestion.php.

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

2113  {
2114  foreach ($a_meta as $key => $value)
2115  {
2116  switch ($value["label"])
2117  {
2118  case "column_separators":
2119  $this->setColumnSeparators($value["entry"]);
2120  break;
2121  case "row_separators":
2122  $this->setRowSeparators($value["entry"]);
2123  break;
2124  case "layout":
2125  $this->setLayout($value["entry"]);
2126  break;
2127  case "neutral_column_separator":
2128  $this->setNeutralColumnSeparator($value["entry"]);
2129  break;
2130  }
2131  }
2132  }
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 2140 of file class.SurveyMatrixQuestion.php.

References setBipolarAdjective().

2141  {
2142  $i = 0;
2143  foreach ($a_data as $adjective)
2144  {
2145  if (is_numeric($adjective["label"]))
2146  {
2147  $this->setBipolarAdjective($adjective["label"], $adjective["text"]);
2148  }
2149  else
2150  {
2151  $this->setBipolarAdjective($i, $adjective["text"]);
2152  }
2153  $i++;
2154  }
2155  }
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 2163 of file class.SurveyMatrixQuestion.php.

References $row, and addRow().

2164  {
2165  foreach ($a_data as $row)
2166  {
2167  $this->addRow($row['title'], $row['other'], $row['label']);
2168  }
2169  }
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 2177 of file class.SurveyMatrixQuestion.php.

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

2178  {
2179  foreach ($a_data as $id => $data)
2180  {
2181  $column = "";
2182  foreach ($data["material"] as $material)
2183  {
2184  $column .= $material["text"];
2185  }
2186  $this->columns->addCategory($column, null, (strcmp($data["label"], "neutral") == 0) ? true : false);
2187  }
2188  }

◆ insertXML()

SurveyMatrixQuestion::insertXML ( $a_xml_writer,
  $a_include_header = TRUE,
  $obligatory_state = "" 
)

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
string$obligatory_stateThe value of the obligatory state public

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

References SurveyQuestion\addMaterialTag(), 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().

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

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

536  {
537  if (
538  strlen($this->getTitle()) &&
539  strlen($this->getAuthor()) &&
540  strlen($this->getQuestiontext()) &&
541  $this->getColumnCount() &&
542  $this->getRowCount()
543  )
544  {
545  return 1;
546  }
547  else
548  {
549  return 0;
550  }
551  }
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 465 of file class.SurveyMatrixQuestion.php.

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

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

336  {
337  $this->rows->moveCategoryDown($index);
338  }

◆ moveRowUp()

SurveyMatrixQuestion::moveRowUp (   $index)

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

331  {
332  $this->rows->moveCategoryUp($index);
333  }

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

198  {
199  $this->columns->removeCategory($index);
200  }

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

210  {
211  $this->columns->removeCategories($array);
212  }

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

222  {
223  $this->columns->removeCategoryWithName($name);
224  }

◆ removeRow()

SurveyMatrixQuestion::removeRow (   $index)

Removes a row.

Parameters
integer$indexThe index of the row to be removed

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

358  {
359  $this->rows->removeCategory($index);
360  }

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

348  {
349  $this->rows->removeCategories($array);
350  }

◆ saveBipolarAdjectives()

SurveyMatrixQuestion::saveBipolarAdjectives (   $adjective1,
  $adjective2 
)

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

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

610  {
611  global $ilDB;
612 
613  $affectedRows = $ilDB->manipulateF("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.
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 665 of file class.SurveyMatrixQuestion.php.

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

Referenced by saveToDb(), and syncWithOriginal().

666  {
667  global $ilDB;
668 
669  // save columns
670  $question_id = $this->getId();
671  if (strlen($original_id))
672  {
673  $question_id = $original_id;
674  }
675 
676  // delete existing column relations
677  $affectedRows = $ilDB->manipulateF("DELETE FROM svy_variable WHERE question_fi = %s",
678  array('integer'),
679  array($question_id)
680  );
681  // create new column relations
682  for ($i = 0; $i < $this->getColumnCount(); $i++)
683  {
684  $cat = $this->getColumn($i);
685  $column_id = $this->saveColumnToDb($cat->title, $cat->neutral);
686  $next_id = $ilDB->nextId('svy_variable');
687  $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)",
688  array('integer','integer','integer','float','integer','integer', 'integer','integer'),
689  array($next_id, $column_id, $question_id, ($i + 1), $cat->other, $i, ($cat->scale > 0) ? $cat->scale : null, time())
690  );
691  }
692  $this->saveCompletionStatus($original_id);
693  }
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.
global $ilDB
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 $ilDB, $ilUser, $result, and $row.

Referenced by saveColumnsToDb().

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

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

2239  {
2240  global $ilDB;
2241 
2242  $layout = array(
2243  "percent_row" => $percent_row,
2244  "percent_columns" => $percent_columns,
2245  "percent_bipolar_adjective1" => $percent_bipolar_adjective1,
2246  "percent_bipolar_adjective2" => $percent_bipolar_adjective2,
2247  "percent_neutral" => $percent_neutral
2248  );
2249  $affectedRows = $ilDB->manipulateF("UPDATE " . $this->getAdditionalTableName() . " SET layout = %s WHERE question_fi = %s",
2250  array('text', 'integer'),
2251  array(serialize($layout), $this->getId())
2252  );
2253  }
getId()
Gets the id of the SurveyQuestion object.
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 915 of file class.SurveyMatrixQuestion.php.

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

916  {
917  global $ilUser;
918  global $ilDB;
919 
920  $next_id = $ilDB->nextId('svy_phrase');
921  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_phrase (phrase_id, title, defaultvalue, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
922  array('integer','text','text','integer','integer'),
923  array($next_id, $title, 1, $ilUser->getId(), time())
924  );
925  $phrase_id = $next_id;
926 
927  $counter = 1;
928  foreach ($_SESSION['save_phrase_data'] as $data)
929  {
930  $next_id = $ilDB->nextId('svy_category');
931  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, tstamp, neutral) VALUES (%s, %s, %s, %s, %s, %s)",
932  array('integer','text','text','integer','integer','text'),
933  array($next_id, $data['answer'], 1, $ilUser->getId(), time(), $data['neutral'])
934  );
935  $category_id = $next_id;
936  $next_id = $ilDB->nextId('svy_phrase_cat');
937  $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)",
938  array('integer', 'integer', 'integer','integer', 'integer', 'integer'),
939  array($next_id, $phrase_id, $category_id, $counter, ($data['other']) ? 1 : 0, $data['scale'])
940  );
941  $counter++;
942  }
943  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
global $ilUser
Definition: imgupload.php:15
global $ilDB

◆ saveRandomData()

SurveyMatrixQuestion::saveRandomData (   $active_id)

Saves random answers for a given active user in the database.

Parameters
integer$active_idThe database ID of the active user

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

References $ilDB, $row, getColumnCount(), SurveyQuestion\getId(), and getRowCount().

1075  {
1076  global $ilDB;
1077  $columncount = $this->getColumnCount();
1078  for ($row = 0; $row < $this->getRowCount(); $row++)
1079  {
1080  if ($this->getSubType() == 1)
1081  {
1082  // multiple responses
1083  for ($i = 0; $i < $columncount; $i++)
1084  {
1085  if (rand(0,1))
1086  {
1087  $next_id = $ilDB->nextId('svy_answer');
1088  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, rowvalue, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
1089  array('integer','integer','integer','float','text','integer','integer'),
1090  array($next_id, $this->getId(), $active_id, $i, NULL, $row, time())
1091  );
1092  }
1093  }
1094  }
1095  else
1096  {
1097  // single responses
1098  $category = rand(0, $columncount-1);
1099  $next_id = $ilDB->nextId('svy_answer');
1100  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, rowvalue, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
1101  array('integer','integer','integer','float','text','integer','integer'),
1102  array($next_id, $this->getId(), $active_id, $category, NULL, $row, time())
1103  );
1104  }
1105  }
1106  }
getId()
Gets the id of the SurveyQuestion object.
global $ilDB
getColumnCount()
Returns the number of columns.
getRowCount()
Returns the number of rows in the question.
+ Here is the call graph for this function:

◆ saveRowsToDb()

SurveyMatrixQuestion::saveRowsToDb (   $original_id = "")

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

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

Referenced by saveToDb(), and syncWithOriginal().

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

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

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

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

1109  {
1110  global $ilDB;
1111 
1112  $answer_data = array();
1113 
1114  // gather data
1115  switch ($this->getSubtype())
1116  {
1117  case 0:
1118  foreach ($post_data as $key => $value)
1119  {
1120  if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches))
1121  {
1122  if(strlen($value))
1123  {
1124  $other_value = (array_key_exists('matrix_other_' . $this->getId() . '_' . $matches[1], $post_data))
1125  ? ($post_data['matrix_other_' . $this->getId() . '_' . $matches[1]])
1126  : null;
1127  $answer_data[] = array("value"=>$value,
1128  "textanswer"=>$other_value,
1129  "rowvalue"=>$matches[1]);
1130  }
1131  }
1132  }
1133  break;
1134 
1135  case 1:
1136  foreach ($post_data as $key => $value)
1137  {
1138  if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches))
1139  {
1140  $other_value = (array_key_exists('matrix_other_' . $this->getId() . '_' . $matches[1], $post_data))
1141  ? ($post_data['matrix_other_' . $this->getId() . '_' . $matches[1]])
1142  : null;
1143  foreach ($value as $checked)
1144  {
1145  $answer_data[] = array("value"=>$checked,
1146  "textanswer"=>$other_value,
1147  "rowvalue"=>$matches[1]);
1148  }
1149  }
1150  }
1151  break;
1152  }
1153 
1154  if ($a_return)
1155  {
1156  return $answer_data;
1157  }
1158 
1159  // #16387 - only if any input
1160  if(sizeof($answer_data))
1161  {
1162  // save data
1163  foreach ($answer_data as $item)
1164  {
1165  $next_id = $ilDB->nextId('svy_answer');
1166  $affectedRows = $ilDB->manipulateF("INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, rowvalue, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
1167  array('integer','integer','integer','float','text','integer','integer'),
1168  array($next_id, $this->getId(), $active_id, $item['value'], $item['textanswer'], $item['rowvalue'], time())
1169  );
1170  }
1171  }
1172  }
getId()
Gets the id of the SurveyQuestion object.
getSubtype()
Returns the subtype of the matrix question.
global $ilDB
+ 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 391 of file class.SurveyMatrixQuestion.php.

Referenced by importAdjectives(), and loadFromDb().

392  {
393  switch ($a_index)
394  {
395  case 1:
396  $this->bipolar_adjective2 = $a_value;
397  break;
398  case 0:
399  default:
400  $this->bipolar_adjective1 = $a_value;
401  break;
402  }
403  }
+ Here is the caller graph for this function:

◆ setColumnHeaderPosition()

SurveyMatrixQuestion::setColumnHeaderPosition (   $a_value)

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

Referenced by loadFromDb().

2408  {
2409  $this->columnHeaderPosition = $a_value;
2410  }
+ Here is the caller graph for this function:

◆ setColumnImages()

SurveyMatrixQuestion::setColumnImages (   $a_value = 0)

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

Referenced by loadFromDb().

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

◆ setColumnOrder()

SurveyMatrixQuestion::setColumnOrder (   $a_value)

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

Referenced by loadFromDb().

2428  {
2429  $this->columnOrder = $a_value;
2430  }
+ 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 2352 of file class.SurveyMatrixQuestion.php.

Referenced by loadFromDb().

2353  {
2354  $this->columnPlaceholders = ($a_value) ? 1 : 0;
2355  }
+ 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 2017 of file class.SurveyMatrixQuestion.php.

Referenced by importAdditionalMetadata(), and loadFromDb().

2018  {
2019  switch ($enable)
2020  {
2021  case 1:
2022  $this->columnSeparators = 1;
2023  break;
2024  case 0:
2025  default:
2026  $this->columnSeparators = 0;
2027  break;
2028  }
2029  }
+ Here is the caller graph for this function:

◆ setExportCumulatedCVS()

& SurveyMatrixQuestion::setExportCumulatedCVS ( $eval_data,
  $export_label 
)

Creates the CSV output for the cumulated results of this question.

Parameters
object$worksheetReference to the excel worksheet
object$format_titleExcel title format
object$format_boldExcel bold format
array$eval_dataCumulated evaluation data
integer$rowActual row in the worksheet
Returns
integer The next row which should be used for the export public

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

References $result, SurveyQuestion\getQuestiontext(), and SurveyQuestion\getTitle().

1545  {
1546  $result = array();
1547  foreach ($eval_data as $evalkey => $evalvalue)
1548  {
1549  $csvrow = array();
1550  if (is_numeric($evalkey))
1551  {
1552  array_push($csvrow, "");
1553  array_push($csvrow, $evalvalue["ROW"]);
1554  array_push($csvrow, "");
1555  }
1556  else
1557  {
1558  switch ($export_label)
1559  {
1560  case 'label_only':
1561  array_push($csvrow, $this->label);
1562  break;
1563  case 'title_only':
1564  array_push($csvrow, $this->getTitle());
1565  break;
1566  default:
1567  array_push($csvrow, $this->getTitle());
1568  array_push($csvrow, $this->label);
1569  break;
1570  }
1571  array_push($csvrow, strip_tags($this->getQuestiontext()));
1572  array_push($csvrow, $this->lng->txt($evalvalue["QUESTION_TYPE"]));
1573  }
1574  array_push($csvrow, $evalvalue["USERS_ANSWERED"]);
1575  array_push($csvrow, $evalvalue["USERS_SKIPPED"]);
1576  array_push($csvrow, $evalvalue["MODE"]);
1577  array_push($csvrow, $evalvalue["MODE_NR_OF_SELECTIONS"]);
1578  array_push($csvrow, $evalvalue["MEDIAN"]);
1579  array_push($csvrow, $evalvalue["ARITHMETIC_MEAN"]);
1580  array_push($result, $csvrow);
1581  }
1582  return $result;
1583  }
getTitle()
Gets the title string of the SurveyQuestion object.
$result
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
+ Here is the call graph for this function:

◆ setExportCumulatedXLS()

SurveyMatrixQuestion::setExportCumulatedXLS ( $worksheet,
$format_title,
$format_bold,
$eval_data,
  $row,
  $export_label 
)

Creates the Excel output for the cumulated results of this question.

Parameters
object$worksheetReference to the excel worksheet
object$format_titleExcel title format
object$format_boldExcel bold format
array$eval_dataCumulated evaluation data
integer$rowActual row in the worksheet
Returns
integer The next row which should be used for the export public

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

References $row, ilExcelUtils\_convert_text(), SurveyQuestion\getQuestiontext(), and SurveyQuestion\getTitle().

1469  {
1470  include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
1471  $column = 0;
1472  switch ($export_label)
1473  {
1474  case 'label_only':
1475  $worksheet->writeString($row, $column, ilExcelUtils::_convert_text($this->label));
1476  break;
1477  case 'title_only':
1478  $worksheet->writeString($row, $column, ilExcelUtils::_convert_text($this->getTitle()));
1479  break;
1480  default:
1481  $worksheet->writeString($row, $column, ilExcelUtils::_convert_text($this->getTitle()));
1482  $column++;
1483  $worksheet->writeString($row, $column, ilExcelUtils::_convert_text($this->label));
1484  break;
1485  }
1486  $column++;
1487  $worksheet->writeString($row, $column, ilExcelUtils::_convert_text(strip_tags($this->getQuestiontext())));
1488  $column++;
1489  $worksheet->writeString($row, $column, ilExcelUtils::_convert_text($this->lng->txt($eval_data["TOTAL"]["QUESTION_TYPE"])));
1490  $column++;
1491  $worksheet->write($row, $column, $eval_data["TOTAL"]["USERS_ANSWERED"]);
1492  $column++;
1493  $worksheet->write($row, $column, $eval_data["TOTAL"]["USERS_SKIPPED"]);
1494  $column++;
1495  $worksheet->write($row, $column, ilExcelUtils::_convert_text($eval_data["TOTAL"]["MODE_VALUE"]));
1496  $column++;
1497  $worksheet->write($row, $column, ilExcelUtils::_convert_text($eval_data["TOTAL"]["MODE"]));
1498  $column++;
1499  $worksheet->write($row, $column, $eval_data["TOTAL"]["MODE_NR_OF_SELECTIONS"]);
1500  $column++;
1501  $worksheet->write($row, $column, ilExcelUtils::_convert_text(str_replace("<br />", " ", $eval_data["TOTAL"]["MEDIAN"])));
1502  $column++;
1503  $worksheet->write($row, $column, $eval_data["TOTAL"]["ARITHMETIC_MEAN"]);
1504  $row++;
1505  $add = 0;
1506  switch ($export_label)
1507  {
1508  case 'label_only':
1509  case 'title_only':
1510  break;
1511  default:
1512  $add = 1;
1513  break;
1514  }
1515  foreach ($eval_data as $evalkey => $evalvalue)
1516  {
1517  if (is_numeric($evalkey))
1518  {
1519  $worksheet->writeString($row, 1+$add, ilExcelUtils::_convert_text($evalvalue["ROW"]));
1520  $worksheet->write($row, 3+$add, $evalvalue["USERS_ANSWERED"]);
1521  $worksheet->write($row, 4+$add, $evalvalue["USERS_SKIPPED"]);
1522  $worksheet->write($row, 5+$add, ilExcelUtils::_convert_text($evalvalue["MODE_VALUE"]));
1523  $worksheet->write($row, 6+$add, ilExcelUtils::_convert_text($evalvalue["MODE"]));
1524  $worksheet->write($row, 7+$add, $evalvalue["MODE_NR_OF_SELECTIONS"]);
1525  $worksheet->write($row, 8+$add, ilExcelUtils::_convert_text(str_replace("<br />", " ", $evalvalue["MEDIAN"])));
1526  $worksheet->write($row, 9+$add, $evalvalue["ARITHMETIC_MEAN"]);
1527  $row++;
1528  }
1529  }
1530  return $row;
1531  }
getTitle()
Gets the title string of the SurveyQuestion object.
_convert_text($a_text, $a_target="has been removed")
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
+ Here is the call graph for this function:

◆ setExportDetailsXLS()

SurveyMatrixQuestion::setExportDetailsXLS ( $workbook,
$format_title,
$format_bold,
$eval_data,
  $export_label 
)

Creates an Excel worksheet for the detailed cumulated results of this question.

Parameters
object$workbookReference to the parent excel workbook
object$format_titleExcel title format
object$format_boldExcel bold format
array$eval_dataCumulated evaluation data public

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

References $data, SurveyQuestion\$title, ilExcelUtils\_convert_text(), SurveyQuestion\getQuestiontext(), and SurveyQuestion\getTitle().

1595  {
1596  include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
1597  $worksheet =& $workbook->addWorksheet();
1598  $rowcounter = 0;
1599  switch ($export_label)
1600  {
1601  case 'label_only':
1602  $worksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("label")), $format_bold);
1603  $worksheet->writeString(0, 1, ilExcelUtils::_convert_text($this->label));
1604  break;
1605  case 'title_only':
1606  $worksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_bold);
1607  $worksheet->writeString(0, 1, ilExcelUtils::_convert_text($this->getTitle()));
1608  break;
1609  default:
1610  $worksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_bold);
1611  $worksheet->writeString(0, 1, ilExcelUtils::_convert_text($this->getTitle()));
1612  $rowcounter++;
1613  $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("label")), $format_bold);
1614  $worksheet->writeString($rowcounter, 1, ilExcelUtils::_convert_text($this->label));
1615  break;
1616  }
1617  $rowcounter++;
1618  $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("question")), $format_bold);
1619  $worksheet->writeString($rowcounter, 1, ilExcelUtils::_convert_text($this->getQuestiontext()));
1620  $rowcounter++;
1621  $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("question_type")), $format_bold);
1622  $worksheet->writeString($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())));
1623  $rowcounter++;
1624  $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("users_answered")), $format_bold);
1625  $worksheet->write($rowcounter, 1, $eval_data["TOTAL"]["USERS_ANSWERED"]);
1626  $rowcounter++;
1627  $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("users_skipped")), $format_bold);
1628  $worksheet->write($rowcounter, 1, $eval_data["TOTAL"]["USERS_SKIPPED"]);
1629  $rowcounter++;
1630 
1631  preg_match("/(.*?)\s+-\s+(.*)/", $eval_data["TOTAL"]["MODE"], $matches);
1632  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode")), $format_bold);
1633  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[1]));
1634  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_text")), $format_bold);
1635  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[2]));
1636  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_nr_of_selections")), $format_bold);
1637  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval_data["TOTAL"]["MODE_NR_OF_SELECTIONS"]));
1638  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("median")), $format_bold);
1639  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text(str_replace("<br />", " ", $eval_data["TOTAL"]["MEDIAN"])));
1640  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("categories")), $format_bold);
1641  $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_title);
1642  $worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($this->lng->txt("value")), $format_title);
1643  $worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($this->lng->txt("category_nr_selected")), $format_title);
1644  $worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($this->lng->txt("percentage_of_selections")), $format_title);
1645 
1646  foreach ($eval_data["TOTAL"]["variables"] as $key => $value)
1647  {
1648  $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($value["title"]));
1649  $worksheet->write($rowcounter, 2, $key+1);
1650  $worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($value["selected"]));
1651  $worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($value["percentage"]), $format_percent);
1652  }
1653 
1654  foreach ($eval_data as $evalkey => $evalvalue)
1655  {
1656  if (is_numeric($evalkey))
1657  {
1658  $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("row")), $format_bold);
1659  $worksheet->writeString($rowcounter, 1, ilExcelUtils::_convert_text($evalvalue["ROW"]));
1660  $worksheet->writeString($rowcounter + 1, 0, ilExcelUtils::_convert_text($this->lng->txt("users_answered")), $format_bold);
1661  $worksheet->write($rowcounter + 1, 1, $evalvalue["USERS_ANSWERED"]);
1662  $worksheet->writeString($rowcounter + 2, 0, ilExcelUtils::_convert_text($this->lng->txt("users_skipped")), $format_bold);
1663  $worksheet->write($rowcounter + 2, 1, $evalvalue["USERS_SKIPPED"]);
1664  $rowcounter = $rowcounter + 3;
1665 
1666  preg_match("/(.*?)\s+-\s+(.*)/", $evalvalue["MODE"], $matches);
1667  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode")), $format_bold);
1668  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[1]));
1669  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_text")), $format_bold);
1670  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[2]));
1671  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_nr_of_selections")), $format_bold);
1672  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($evalvalue["MODE_NR_OF_SELECTIONS"]));
1673  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("median")), $format_bold);
1674  $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text(str_replace("<br />", " ", $evalvalue["MEDIAN"])));
1675  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("categories")), $format_bold);
1676  $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_title);
1677  $worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($this->lng->txt("value")), $format_title);
1678  $worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($this->lng->txt("category_nr_selected")), $format_title);
1679  $worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($this->lng->txt("percentage_of_selections")), $format_title);
1680 
1681  foreach ($evalvalue["variables"] as $key => $value)
1682  {
1683  $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($value["title"]));
1684  $worksheet->write($rowcounter, 2, $key+1);
1685  $worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($value["selected"]));
1686  $worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($value["percentage"]), $format_percent);
1687  }
1688 
1689  // add text answers to detailed results
1690  if (is_array($evalvalue["textanswers"]))
1691  {
1692  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("freetext_answers")), $format_bold);
1693  $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_title);
1694  $worksheet->write($rowcounter++, 2, ilExcelUtils::_convert_text($this->lng->txt("answer")), $format_title);
1695 
1696  foreach ($evalvalue["textanswers"] as $key => $answers)
1697  {
1698  $title = $evalvalue["variables"][$key]["title"];
1699  foreach ($answers as $answer)
1700  {
1701  $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($title));
1702  $worksheet->write($rowcounter++, 2, ilExcelUtils::_convert_text($answer));
1703  }
1704  }
1705  }
1706  }
1707  }
1708  // out compressed 2D-Matrix
1709  $format_center =& $workbook->addFormat();
1710  $format_center->setColor('black');
1711  $format_center->setAlign('center');
1712 
1713  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("overview")), $format_bold);
1714  // title row with variables
1715  $rowcounter++;
1716  $counter = 0;
1717  $worksheet->write($rowcounter, $counter, "", $format_title);
1718  foreach ($eval_data["TOTAL"]["variables"] as $variable)
1719  {
1720  $worksheet->write($rowcounter, 1+$counter, ilExcelUtils::_convert_text($variable["title"]), $format_title);
1721  $counter++;
1722  }
1723  $rowcounter++;
1724  // rows with variable values
1725  foreach ($eval_data as $index => $data)
1726  {
1727  if (is_numeric($index))
1728  {
1729  $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($data["ROW"]), $format_title);
1730  $counter = 1;
1731  foreach ($data["variables"] as $vardata)
1732  {
1733  $worksheet->write($rowcounter, $counter, $vardata["selected"], $format_center);
1734  $counter++;
1735  }
1736  $rowcounter++;
1737  }
1738  }
1739  }
getTitle()
Gets the title string of the SurveyQuestion object.
_convert_text($a_text, $a_target="has been removed")
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
+ Here is the call graph for this function:

◆ setLayout()

SurveyMatrixQuestion::setLayout (   $layout)

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

References $layout.

Referenced by importAdditionalMetadata(), and loadFromDb().

2304  {
2305  if (is_array($layout))
2306  {
2307  $this->layout = $layout;
2308  }
2309  else
2310  {
2311  $this->layout = unserialize($layout);
2312  }
2313  }
+ 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 2372 of file class.SurveyMatrixQuestion.php.

Referenced by loadFromDb().

2373  {
2374  $this->legend = ($a_value) ? 1 : 0;
2375  }
+ 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 2079 of file class.SurveyMatrixQuestion.php.

Referenced by importAdditionalMetadata(), and loadFromDb().

2080  {
2081  switch ($enable)
2082  {
2083  case 1:
2084  $this->neutralColumnSeparator = 1;
2085  break;
2086  case 0:
2087  default:
2088  $this->neutralColumnSeparator = 0;
2089  break;
2090  }
2091  }
+ Here is the caller graph for this function:

◆ setRandomRows()

SurveyMatrixQuestion::setRandomRows (   $a_value = 0)

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

Referenced by loadFromDb().

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

◆ setRepeatColumnHeader()

SurveyMatrixQuestion::setRepeatColumnHeader (   $a_value = 0)

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

Referenced by loadFromDb().

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

◆ setRowImages()

SurveyMatrixQuestion::setRowImages (   $a_value = 0)

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

Referenced by loadFromDb().

2448  {
2449  $this->rowImages = ($a_value) ? 1 : 0;
2450  }
+ 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 2048 of file class.SurveyMatrixQuestion.php.

Referenced by importAdditionalMetadata(), and loadFromDb().

2049  {
2050  switch ($enable)
2051  {
2052  case 1:
2053  $this->rowSeparators = 1;
2054  break;
2055  case 0:
2056  default:
2057  $this->rowSeparators = 0;
2058  break;
2059  }
2060  }
+ Here is the caller graph for this function:

◆ setSingleLineRowCaption()

SurveyMatrixQuestion::setSingleLineRowCaption (   $a_value = 0)

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

Referenced by loadFromDb().

2388  {
2389  $this->singleLineRowCaption = ($a_value) ? 1 : 0;
2390  }
+ 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 1992 of file class.SurveyMatrixQuestion.php.

Referenced by loadFromDb().

1993  {
1994  switch ($a_subtype)
1995  {
1996  case 1:
1997  case 2:
1998  case 3:
1999  case 4:
2000  case 5:
2001  case 6:
2002  $this->subtype = $a_subtype;
2003  break;
2004  case 0:
2005  default:
2006  $this->subtype = 0;
2007  break;
2008  }
2009  }
+ Here is the caller graph for this function:

◆ SurveyMatrixQuestion()

SurveyMatrixQuestion::SurveyMatrixQuestion (   $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, and SurveyQuestion\SurveyQuestion().

165  {
167  $this->subtype = 0;
168  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
169  $this->columns = new SurveyCategories();
170  $this->rows = new SurveyCategories();
171  $this->bipolar_adjective1 = "";
172  $this->bipolar_adjective2 = "";
173  $this->rowSeparators = 0;
174  $this->columnSeparators = 0;
175  $this->neutralColumnSeparator = 1;
176  }
SurveyQuestion( $title="", $description="", $author="", $questiontext="", $owner=-1)
SurveyQuestion constructor The constructor takes possible arguments an creates an instance of the Sur...
Class SurveyCategories.
+ Here is the call graph for this function:

◆ syncWithOriginal()

SurveyMatrixQuestion::syncWithOriginal ( )

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

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

883  {
884  if ($this->getOriginalId())
885  {
886  parent::syncWithOriginal();
887  $this->saveColumnsToDb($this->getOriginalId());
888  $this->saveRowsToDb($this->getOriginalId());
889  }
890  }
+ 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 730 of file class.SurveyMatrixQuestion.php.

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

731  {
732  include_once("./Services/Xml/classes/class.ilXmlWriter.php");
733  $a_xml_writer = new ilXmlWriter;
734  $a_xml_writer->xmlHeader();
735  $this->insertXML($a_xml_writer, $a_include_header, $obligatory_state);
736  $xml = $a_xml_writer->xmlDumpMem(FALSE);
737  if (!$a_include_header)
738  {
739  $pos = strpos($xml, "?>");
740  $xml = substr($xml, $pos + 2);
741  }
742  return $xml;
743  }
XML writer class.
xmlHeader()
Writes xml header public.
insertXML(&$a_xml_writer, $a_include_header=TRUE, $obligatory_state="")
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 2196 of file class.SurveyMatrixQuestion.php.

2197  {
2198  return FALSE;
2199  }

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: