ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
SurveyMatrixQuestion Class Reference

Matrix question. More...

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

Public Member Functions

 SurveyMatrixQuestion ($title="", $description="", $author="", $questiontext="", $owner=-1)
 SurveyMatrixQuestion constructor.
 getNeutralColumn ()
 Returns the text of the neutral column.
 getNeutralColumnIndex ()
 Returns the index of the neutral column.
 setNeutralColumn ($a_text)
 Sets the text of the neutral column.
 getColumnCount ()
 Returns the number of columns.
 addColumnAtPosition ($columnname, $position)
 Adds a column at a given position.
 addColumn ($columnname)
 Adds a column.
 addColumnArray ($columns)
 Adds a column array.
 removeColumn ($index)
 Removes a column from the list of columns.
 removeColumns ($array)
 Removes many columns from the list of columns.
 removeColumnWithName ($name)
 Removes a column from the list of columns.
 getColumn ($index)
 Returns the name of a column for a given index.
 getColumnIndex ($name)
 Returns the index of a column with a given name.
 flushColumns ()
 Empties the columns list.
 getRowCount ()
 Returns the number of rows in the question.
 addRow ($a_text)
 Adds a row to the question.
 flushRows ()
 Empties the row list.
 getRow ($a_index)
 Returns a specific row.
 removeRows ($array)
 Removes rows from the question.
 getBipolarAdjective ($a_index)
 Returns one of the bipolar adjectives.
 setBipolarAdjective ($a_index, $a_value)
 Sets one of the bipolar adjectives.
 addPhrase ($phrase_id)
 Adds a phrase to the question.
 _getQuestionDataArray ($id)
 Returns the question data fields from the database.
 loadFromDb ($id)
 Loads a SurveyMatrixQuestion object from the database.
 isComplete ()
 Returns true if the question is complete for use.
 saveToDb ($original_id="", $withanswers=true)
 Saves a SurveyMatrixQuestion object to a database.
 saveBipolarAdjectives ($adjective1, $adjective2)
 saveColumnToDb ($columntext, $neutral=0)
 Saves a column to the database.
 saveColumnsToDb ($original_id="")
 saveRowsToDb ($original_id="")
 toXML ($a_include_header=TRUE, $obligatory_state="")
 Returns an xml representation of the question.
 insertXML (&$a_xml_writer, $a_include_header=TRUE, $obligatory_state="")
 Adds the question XML to a given XMLWriter object.
 syncWithOriginal ()
 addStandardNumbers ($lower_limit, $upper_limit)
 Adds standard numbers as columns.
 savePhrase ($phrases, $title)
 Saves a set of columns to a default phrase.
 getQuestionType ()
 Returns the question type of the question.
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database.
getWorkingDataFromUserInput ($post_data)
 Creates the user data of the survey_answer table from the POST data.
 checkUserInput ($post_data, $survey_id)
 Checks the input of the active user for obligatory status and entered values.
 saveRandomData ($active_id)
 Saves random answers for a given active user in the database.
 saveUserInput ($post_data, $active_id)
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database.
 getNrOfUsersAnswered ($survey_id)
 Returns the number of users that answered the question for a given survey.
getCumulatedResultsForRow ($rowindex, $survey_id, $nr_of_users)
 Returns the cumulated results for a given row.
getCumulatedResults ($survey_id, $nr_of_users)
 Returns the cumulated results for the question.
 setExportCumulatedXLS (&$worksheet, &$format_title, &$format_bold, &$eval_data, $row)
 Creates the Excel output for the cumulated results of this question.
setExportCumulatedCVS (&$eval_data)
 Creates the CSV output for the cumulated results of this question.
 setExportDetailsXLS (&$workbook, &$format_title, &$format_bold, &$eval_data)
 Creates an Excel worksheet for the detailed cumulated results of this question.
 addUserSpecificResultsExportTitles (&$a_array)
 Adds the entries for the title row of the user specific results.
 addUserSpecificResultsData (&$a_array, &$resultset)
 Adds the values for the user specific results export for a given user.
getUserAnswers ($survey_id)
 Returns an array containing all answers to this question in a given survey.
 getSubtype ()
 Returns the subtype of the matrix question.
 setSubtype ($a_subtype=0)
 Sets the subtype of the matrix question.
 setColumnSeparators ($enable=0)
 Enables/Disables separators for the matrix columns.
 getColumnSeparators ()
 Gets the separators enable state for the matrix columns.
 setRowSeparators ($enable=0)
 Enables/Disables separators for the matrix rows.
 getRowSeparators ()
 Gets the separators enable state for the matrix rows.
 setNeutralColumnSeparator ($enable=0)
 Enables/Disables a separator for the neutral column.
 getNeutralColumnSeparator ()
 Gets the separator enable state for the neutral column.
 importAdditionalMetadata ($a_meta)
 Import additional meta data from the question import file.
 importAdjectives ($a_data)
 Import bipolar adjectives from the question import file.
 importMatrix ($a_data)
 Import matrix rows from the question import file.
 importResponses ($a_data)
 Import response data from the question import file.
 usableForPrecondition ()
 Returns if the question is usable for preconditions.
 getPreconditionValueOutput ($value)
 Returns the output for a precondition value.
 outChart ($survey_id, $type="")
 Creates an image visualising the results of the question.
 saveLayout ($percent_row, $percent_columns, $percent_bipolar_adjective1="", $percent_bipolar_adjective2="", $percent_neutral)
 Saves the layout of a matrix question.
 getLayout ()
 setLayout ($layout)
 hasBipolarAdjectives ()
 Returns TRUE if bipolar adjectives exist.
 hasNeutralColumn ()
 Returns TRUE if a neutral column exists.
 setColumnPlaceholders ($a_value=FALSE)
 Set whether placeholders should be used for the column titles or not.
 getColumnPlaceholders ()
 Get whether placeholders should be used for the column titles or not.
 setLegend ($a_value=FALSE)
 Set whether the legend should be shown or not.
 getLegend ()
 Get whether the legend should be shown or not.
 setSingleLineRowCaption ($a_value=FALSE)
 getSingleLineRowCaption ()
 setRepeatColumnHeader ($a_value=FALSE)
 getRepeatColumnHeader ()
 setColumnHeaderPosition ($a_value)
 getColumnHeaderPosition ()
 setRandomRows ($a_value=FALSE)
 getRandomRows ()
 setColumnOrder ($a_value)
 getColumnOrder ()
 setColumnImages ($a_value=FALSE)
 getColumnImages ()
 setRowImages ($a_value=FALSE)
 getRowImages ()
- Public Member Functions inherited from SurveyQuestion
 SurveyQuestion ($title="", $description="", $author="", $questiontext="", $owner=-1)
 SurveyQuestion constructor.
 _SurveyQuestion ()
 questionTitleExists ($title, $questionpool_object="")
 Returns TRUE if the question title exists in the database.
 setTitle ($title="")
 Sets the title string.
 setObligatory ($obligatory=1)
 Sets the obligatory state of the question.
 setOrientation ($orientation=0)
 Sets the orientation of the question output.
 setId ($id=-1)
 Sets the id.
 setSurveyId ($id=-1)
 Sets the survey id.
 setDescription ($description="")
 Sets the description.
 addMaterials ($materials_file, $materials_name="")
 Sets the materials uri.
 keyInArray ($searchkey, $array)
 returns TRUE if the key occurs in an array
 setMaterialsfile ($materials_filename, $materials_tempfilename="", $materials_name="")
 Sets and uploads the materials uri.
 deleteMaterial ($materials_name="")
 Deletes a materials uri.
 flushMaterials ()
 Deletes all materials uris.
 setAuthor ($author="")
 Sets the authors name.
 setQuestiontext ($questiontext="")
 Sets the questiontext.
 setOwner ($owner="")
 Sets the creator/owner.
 getTitle ()
 Gets the title string.
 getId ()
 Gets the id.
 getObligatory ($survey_id="")
 Gets the obligatory state of the question.
 getSurveyId ()
 Gets the survey id.
 getOrientation ()
 Gets the orientation of the question output.
 getDescription ()
 Gets the description.
 getAuthor ()
 Gets the authors name.
 getOwner ()
 Gets the creator/owner.
 getQuestiontext ()
 Gets the questiontext.
 getObjId ()
 Get the reference id of the container object.
 setObjId ($obj_id=0)
 Set the reference id of the container object.
 duplicate ($for_survey=true, $title="", $author="", $owner="")
 Duplicates a survey question.
 copyObject ($target_questionpool, $title="")
 Copies an assOrderingQuestion object.
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 Increases the media object usage counter when a question is duplicated.
 duplicateMaterials ($question_id)
 Duplicates the materials of a question.
 _isComplete ($question_id)
 Checks wheather the question is complete or not.
 saveCompletionStatus ($original_id="")
 Saves the complete flag to the database.
 saveToDb ($original_id="")
 Saves a SurveyQuestion object to a database.
 saveWorkingData ($limit_to=LIMIT_NO_LIMIT)
 Saves the learners input of the question to the database.
 getImagePath ()
 Returns the image path for web accessable images of a question.
 getMaterialsPath ()
 Returns the materials path for web accessable material of a question.
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question.
 getMaterialsPathWeb ()
 Returns the web image path for web accessable images of a question.
 saveMaterialsToDb ()
 Saves a materials to a database.
 loadMaterialFromDb ($question_id)
 Loads materials uris from a database.
 saveCategoryToDb ($categorytext, $neutral=0)
 Saves a category to the database.
 delete ($question_id)
 Deletes a question from the database.
 _getQuestionType ($question_id)
 Returns the question type of a question with a given id.
 _getTitle ($question_id)
 Returns the question title of a question with a given id.
 _getOriginalId ($question_id)
 Returns the original id of a question.
 _getRefIdFromObjId ($obj_id)
 getPhrase ($phrase_id)
 Returns a phrase for a given database id.
 phraseExists ($title)
 Returns true if the phrase title already exists for the current user.
 _questionExists ($question_id)
 Returns true if the question already exists in the database.
 setMaterial ($material_id="", $is_import=false, $material_title="")
 Sets a material link for the question.
 _resolveInternalLink ($internal_link)
 _resolveIntLinks ($question_id)
 _getInternalLinkHref ($target="")
 _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user.
 getQuestionTypeID ()
 Returns the question type ID of the question.
_instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id.
_instanciateQuestionGUI ($question_id)
 Creates an instance of a question GUI with a given question id.
 isHTML ($a_text)
 Checks if a given string contains HTML or not.
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string.
 addMaterialTag (&$a_xml_writer, $a_material, $close_material_tag=TRUE, $add_mobs=TRUE)
 Creates an XML material tag from a plain text or xhtml text.
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=FALSE)
 Prepares a string for a text area output in surveys.
 getAvailableRelations ()
 Returns the available relations for the question.
 getPreconditionSelectValue ($default="")
 Creates a value selection for preconditions.
 setOriginalId ($original_id)
 getOriginalId ()

Data Fields

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

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.
static _getQuestionTypeName ($type_tag)
 Return the translation for a given question type tag.

Detailed Description

Matrix question.

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

Member Function Documentation

SurveyMatrixQuestion::_getQuestionDataArray (   $id)

Returns the question data fields from the database.

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

Reimplemented from SurveyQuestion.

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

References SurveyQuestion\$id, and $result.

{
global $ilDB;
$query = sprintf("SELECT survey_question.*, survey_question_matrix.* FROM survey_question, survey_question_matrix WHERE survey_question.question_id = %s AND survey_question.question_id = survey_question_matrix.question_fi",
$ilDB->quote($id)
);
$result = $ilDB->query($query);
if ($result->numRows() == 1)
{
return $result->fetchRow(MDB2_FETCHMODE_ASSOC);
}
else
{
return array();
}
}
SurveyMatrixQuestion::addColumn (   $columnname)

Adds a column.

Adds a column

Parameters
integer$columnnameThe name of the column
integer$neutralIndicates if the column is a neutral column public
See Also
$columns

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

Referenced by addPhrase(), addStandardNumbers(), importResponses(), and loadFromDb().

{
array_push($this->columns, $columnname);
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::addColumnArray (   $columns)

Adds a column array.

Adds a column array

Parameters
array$columnsAn array with columns public
See Also
$columns

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

References $columns.

{
$this->columns = array_merge($this->columns, $columns);
}
SurveyMatrixQuestion::addColumnAtPosition (   $columnname,
  $position 
)

Adds a column at a given position.

Adds a column at a given position

Parameters
string$columnnameThe name of the column
integer$positionThe position of the column (starting with index 0) public
See Also
$columns

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

{
if (array_key_exists($position, $this->columns))
{
$head = array_slice($this->columns, 0, $position);
$tail = array_slice($this->columns, $position);
$this->columns = array_merge($head, array($columnname), $tail);
}
else
{
array_push($this->columns, $columnname);
}
}
SurveyMatrixQuestion::addPhrase (   $phrase_id)

Adds a phrase to the question.

Adds a phrase to the question

Parameters
integer$phrase_idThe database id of the given phrase public

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

References $result, and addColumn().

{
global $ilUser;
global $ilDB;
$query = sprintf("SELECT survey_category.* FROM survey_category, survey_phrase_category WHERE survey_phrase_category.category_fi = survey_category.category_id AND survey_phrase_category.phrase_fi = %s AND (survey_category.owner_fi = 0 OR survey_category.owner_fi = %s) ORDER BY survey_phrase_category.sequence",
$ilDB->quote($phrase_id),
$ilDB->quote($ilUser->id)
);
$result = $ilDB->query($query);
while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
{
if (($row->defaultvalue == 1) and ($row->owner_fi == 0))
{
$this->addColumn($this->lng->txt($row->title));
}
else
{
$this->addColumn($row->title);
}
}
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::addRow (   $a_text)

Adds a row to the question.

Adds a row to the question

Parameters
string$a_textThe text of the row public

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

Referenced by importMatrix(), and loadFromDb().

{
array_push($this->rows, $a_text);
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::addStandardNumbers (   $lower_limit,
  $upper_limit 
)

Adds standard numbers as columns.

Adds standard numbers as columns

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

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

References addColumn().

{
for ($i = $lower_limit; $i <= $upper_limit; $i++)
{
$this->addColumn($i);
}
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::addUserSpecificResultsData ( $a_array,
$resultset 
)

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

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

Reimplemented from SurveyQuestion.

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

References $result, getColumnCount(), SurveyQuestion\getId(), getNeutralColumn(), getRowCount(), and getSubtype().

{
if (count($resultset["answers"][$this->getId()]))
{
array_push($a_array, "");
switch ($this->getSubtype())
{
case 0:
for ($i = 0; $i < $this->getRowCount(); $i++)
{
$checked = FALSE;
foreach ($resultset["answers"][$this->getId()] as $result)
{
if ($result["row"] == $i)
{
$checked = TRUE;
array_push($a_array, $result["value"] + 1);
}
}
if (!$checked)
{
array_push($a_array, $this->lng->txt("skipped"));
}
}
break;
case 1:
for ($i = 0; $i < $this->getRowCount(); $i++)
{
$checked = FALSE;
$checked_values = array();
foreach ($resultset["answers"][$this->getId()] as $result)
{
if ($result["row"] == $i)
{
$checked = TRUE;
array_push($checked_values, $result["value"] + 1);
}
}
if (!$checked)
{
array_push($a_array, $this->lng->txt("skipped"));
}
else
{
array_push($a_array, "");
}
for ($index = 0; $index < $this->getColumnCount(); $index++)
{
if (!$checked)
{
array_push($a_array, "");
}
else
{
if (in_array($index+1, $checked_values))
{
array_push($a_array, 1);
}
else
{
array_push($a_array, 0);
}
}
}
if (strlen($this->getNeutralColumn()))
{
if (!$checked)
{
array_push($a_array, "");
}
else
{
if (in_array($this->getColumnCount()+1, $checked_values))
{
array_push($a_array, 1);
}
else
{
array_push($a_array, 0);
}
}
}
}
break;
}
}
else
{
array_push($a_array, $this->lng->txt("skipped"));
for ($i = 0; $i < $this->getRowCount(); $i++)
{
array_push($a_array, "");
switch ($this->getSubtype())
{
case 0:
break;
case 1:
for ($index = 0; $index < $this->getColumnCount(); $index++)
{
array_push($a_array, "");
}
if (strlen($this->getNeutralColumn()))
{
array_push($a_array, "");
}
break;
}
}
}
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::addUserSpecificResultsExportTitles ( $a_array)

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

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

Reimplemented from SurveyQuestion.

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

References getColumn(), getColumnCount(), getNeutralColumn(), getRow(), getRowCount(), and getSubtype().

{
for ($i = 0; $i < $this->getRowCount(); $i++)
{
array_push($a_array, $this->getRow($i));
switch ($this->getSubtype())
{
case 0:
break;
case 1:
for ($index = 0; $index < $this->getColumnCount(); $index++)
{
$col = $this->getColumn($index);
array_push($a_array, ($index+1) . " - $col");
}
if (strlen($this->getNeutralColumn()))
{
array_push($a_array, ($this->getColumnCount()+1) . " - " . $this->getNeutralColumn());
}
break;
}
}
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::checkUserInput (   $post_data,
  $survey_id 
)

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

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

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

{
if (!$this->getObligatory($survey_id)) return "";
switch ($this->getSubtype())
{
case 0:
$counter = 0;
foreach ($post_data as $key => $value)
{
if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches))
{
$counter++;
}
}
if ($counter != $this->getRowCount()) return $this->lng->txt("matrix_question_radio_button_not_checked");
break;
case 1:
$counter = 0;
foreach ($post_data as $key => $value)
{
if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches))
{
$counter++;
if ((!is_array($value)) || (count($value) < 1))
{
return $this->lng->txt("matrix_question_checkbox_not_checked");
}
}
}
if ($counter != $this->getRowCount()) return $this->lng->txt("matrix_question_checkbox_not_checked");
break;
}
return "";
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::deleteAdditionalTableData (   $question_id)

Deletes datasets from the additional question table in the database.

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

Reimplemented from SurveyQuestion.

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

References $result.

{
global $ilDB;
$query = sprintf("DELETE FROM survey_question_matrix_rows WHERE question_fi = %s",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
}
SurveyMatrixQuestion::flushColumns ( )

Empties the columns list.

Empties the columns list

public

See Also
$columns

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

Referenced by loadFromDb().

{
$this->columns = array();
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::flushRows ( )

Empties the row list.

Empties the row list

public

See Also
$rows

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

{
$this->rows = array();
}
SurveyMatrixQuestion::getAdditionalTableName ( )

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

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

Returns
string The additional table name public

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

{
return "survey_question_matrix";
}
SurveyMatrixQuestion::getBipolarAdjective (   $a_index)

Returns one of the bipolar adjectives.

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

References $bipolar_adjective1, and $bipolar_adjective2.

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

{
switch ($a_index)
{
case 1:
break;
case 0:
default:
break;
}
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getColumn (   $index)

Returns the name of a column for a given 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 380 of file class.SurveyMatrixQuestion.php.

References getColumnCount(), and getNeutralColumn().

Referenced by addUserSpecificResultsExportTitles(), getCumulatedResults(), getCumulatedResultsForRow(), getUserAnswers(), insertXML(), saveColumnsToDb(), and savePhrase().

{
if (array_key_exists($index, $this->columns))
{
return $this->columns[$index];
}
else
{
if (($index = $this->getColumnCount()) && (strlen($this->getNeutralColumn())))
{
return $this->getNeutralColumn();
}
else
{
return "";
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getColumnCount ( )

Returns the number of columns.

Returns the number of columns

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

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

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

{
return count($this->columns);
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getColumnHeaderPosition ( )

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

References $columnHeaderPosition.

Referenced by loadFromDb(), and saveToDb().

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getColumnImages ( )

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

References $columnImages.

Referenced by loadFromDb(), and saveToDb().

{
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getColumnIndex (   $name)

Returns the index of a column with a given 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 408 of file class.SurveyMatrixQuestion.php.

{
foreach ($this->columns as $index => $column)
{
if (strcmp($column, $name) == 0)
{
return $index;
}
}
return -1;
}
SurveyMatrixQuestion::getColumnOrder ( )

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

References $columnOrder.

Referenced by loadFromDb(), and saveToDb().

{
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getColumnPlaceholders ( )

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

Returns
boolean TRUE for placeholders, FALSE otherwise

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

References $columnPlaceholders.

Referenced by saveToDb().

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getColumnSeparators ( )

Gets the separators enable state for the matrix columns.

Gets the separators enable state for the matrix columns

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

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

References $columnSeparators.

Referenced by insertXML(), and saveToDb().

+ Here is the caller graph for this function:

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

Returns the cumulated results for the question.

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

References $result, SurveyQuestion\$survey_id, $total, getColumn(), getColumnCount(), getCumulatedResultsForRow(), SurveyQuestion\getId(), getNeutralColumn(), getNeutralColumnIndex(), getNrOfUsersAnswered(), getRowCount(), getSubtype(), and hasNeutralColumn().

Referenced by outChart().

{
global $ilDB;
$question_id = $this->getId();
$result_array = array();
$cumulated = array();
$query = sprintf("SELECT survey_answer.* FROM survey_answer, survey_finished WHERE survey_answer.question_fi = %s AND survey_finished.survey_fi = %s AND survey_finished.finished_id = survey_answer.active_fi",
$ilDB->quote($question_id),
$ilDB->quote($survey_id)
);
$result = $ilDB->query($query);
switch ($this->getSubtype())
{
case 0:
case 1:
while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
{
$cumulated[$row->value]++;
}
asort($cumulated, SORT_NUMERIC);
end($cumulated);
break;
}
$numrows = $result->numRows();
$result_array["USERS_ANSWERED"] = $this->getNrOfUsersAnswered($survey_id);
$result_array["USERS_SKIPPED"] = $nr_of_users - $this->getNrOfUsersAnswered($survey_id);
$prefix = "";
if (strcmp(key($cumulated), "") != 0)
{
$prefix = (key($cumulated)+1) . " - ";
}
$cat = $this->getColumn(key($cumulated));
$result_array["MODE"] = $prefix . $cat;
$result_array["MODE_VALUE"] = key($cumulated)+1;
$result_array["MODE_NR_OF_SELECTIONS"] = $cumulated[key($cumulated)];
for ($key = 0; $key < $this->getColumnCount(); $key++)
{
$percentage = 0;
if ($numrows > 0)
{
$percentage = (float)((int)$cumulated[$key]/$numrows);
}
$cat = $this->getColumn($key);
$result_array["variables"][$key] = array("title" => $cat, "selected" => (int)$cumulated[$key], "percentage" => $percentage);
}
if ($this->hasNeutralColumn())
{
$percentage = 0;
if ($numrows > 0)
{
$percentage = (float)((int)$cumulated[$this->getNeutralColumnIndex()]/$numrows);
}
$result_array["variables"][$this->getNeutralColumnIndex()] = array("title" => $this->getNeutralColumn(), "selected" => (int)$cumulated[$this->getNeutralColumnIndex()], "percentage" => $percentage);
}
ksort($cumulated, SORT_NUMERIC);
$median = array();
$total = 0;
foreach ($cumulated as $value => $key)
{
$total += $key;
for ($i = 0; $i < $key; $i++)
{
array_push($median, $value+1);
}
}
if ($total > 0)
{
if (($total % 2) == 0)
{
$median_value = 0.5 * ($median[($total/2)-1] + $median[($total/2)]);
if (round($median_value) != $median_value)
{
$cat = $this->getColumn((int)floor($median_value)-1);
$cat2 = $this->getColumn((int)ceil($median_value)-1);
$median_value = $median_value . "<br />" . "(" . $this->lng->txt("median_between") . " " . (floor($median_value)) . "-" . $cat . " " . $this->lng->txt("and") . " " . (ceil($median_value)) . "-" . $cat2 . ")";
}
}
else
{
$median_value = $median[(($total+1)/2)-1];
}
}
else
{
$median_value = "";
}
$result_array["ARITHMETIC_MEAN"] = "";
$result_array["MEDIAN"] = $median_value;
$result_array["QUESTION_TYPE"] = "SurveyMatrixQuestion";
$cumulated_results = array();
$cumulated_results["TOTAL"] = $result_array;
for ($i = 0; $i < $this->getRowCount(); $i++)
{
$rowresult =& $this->getCumulatedResultsForRow($i, $survey_id, $nr_of_users);
$cumulated_results[$i] = $rowresult;
}
return $cumulated_results;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Returns the cumulated results for a given row.

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

References $result, SurveyQuestion\$survey_id, $total, getColumn(), getColumnCount(), SurveyQuestion\getId(), getNeutralColumn(), getNeutralColumnIndex(), getNrOfUsersAnswered(), getRow(), getSubtype(), and hasNeutralColumn().

Referenced by getCumulatedResults().

{
global $ilDB;
$question_id = $this->getId();
$result_array = array();
$cumulated = array();
$query = sprintf("SELECT survey_answer.* FROM survey_answer, survey_finished WHERE survey_answer.question_fi = %s AND survey_finished.survey_fi = %s AND survey_answer.row = %s AND survey_finished.finished_id = survey_answer.active_fi",
$ilDB->quote($question_id . ""),
$ilDB->quote($survey_id . ""),
$ilDB->quote($rowindex . "")
);
$result = $ilDB->query($query);
switch ($this->getSubtype())
{
case 0:
case 1:
while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
{
$cumulated[$row->value]++;
}
asort($cumulated, SORT_NUMERIC);
end($cumulated);
break;
}
$numrows = $result->numRows();
$result_array["USERS_ANSWERED"] = $this->getNrOfUsersAnswered($survey_id);
$result_array["USERS_SKIPPED"] = $nr_of_users - $this->getNrOfUsersAnswered($survey_id);
$prefix = "";
if (strcmp(key($cumulated), "") != 0)
{
$prefix = (key($cumulated)+1) . " - ";
}
$cat = $this->getColumn(key($cumulated));
$result_array["MODE"] = $prefix . $cat;
$result_array["MODE_VALUE"] = key($cumulated)+1;
$result_array["MODE_NR_OF_SELECTIONS"] = $cumulated[key($cumulated)];
for ($key = 0; $key < $this->getColumnCount(); $key++)
{
$percentage = 0;
if ($numrows > 0)
{
$percentage = (float)((int)$cumulated[$key]/$numrows);
}
$cat = $this->getColumn($key);
$result_array["variables"][$key] = array("title" => $cat, "selected" => (int)$cumulated[$key], "percentage" => $percentage);
}
if ($this->hasNeutralColumn())
{
$percentage = 0;
if ($numrows > 0)
{
$percentage = (float)((int)$cumulated[$this->getNeutralColumnIndex()]/$numrows);
}
$result_array["variables"][$this->getNeutralColumnIndex()] = array("title" => $this->getNeutralColumn(), "selected" => (int)$cumulated[$this->getNeutralColumnIndex()], "percentage" => $percentage);
}
ksort($cumulated, SORT_NUMERIC);
$median = array();
$total = 0;
foreach ($cumulated as $value => $key)
{
$total += $key;
for ($i = 0; $i < $key; $i++)
{
array_push($median, $value+1);
}
}
if ($total > 0)
{
if (($total % 2) == 0)
{
$median_value = 0.5 * ($median[($total/2)-1] + $median[($total/2)]);
if (round($median_value) != $median_value)
{
$cat = $this->getColumn((int)floor($median_value)-1);
$cat2 = $this->getColumn((int)ceil($median_value)-1);
$median_value = $median_value . "<br />" . "(" . $this->lng->txt("median_between") . " " . (floor($median_value)) . "-" . $cat . " " . $this->lng->txt("and") . " " . (ceil($median_value)) . "-" . $cat2 . ")";
}
}
else
{
$median_value = $median[(($total+1)/2)-1];
}
}
else
{
$median_value = "";
}
$result_array["ARITHMETIC_MEAN"] = "";
$result_array["MEDIAN"] = $median_value;
$result_array["QUESTION_TYPE"] = "SurveyMatrixQuestion";
$result_array["ROW"] = $this->getRow($rowindex);
return $result_array;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getLayout ( )

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

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

Referenced by insertXML(), and saveToDb().

{
if (!is_array($this->layout) || count($this->layout) == 0)
{
if ($this->hasBipolarAdjectives() && $this->hasNeutralColumn())
{
$this->layout = array(
"percent_row" => 30,
"percent_columns" => 40,
"percent_bipolar_adjective1" => 10,
"percent_bipolar_adjective2" => 10,
"percent_neutral" => 10
);
}
elseif ($this->hasBipolarAdjectives())
{
$this->layout = array(
"percent_row" => 30,
"percent_columns" => 50,
"percent_bipolar_adjective1" => 10,
"percent_bipolar_adjective2" => 10,
"percent_neutral" => 0
);
}
elseif ($this->hasNeutralColumn())
{
$this->layout = array(
"percent_row" => 30,
"percent_columns" => 50,
"percent_bipolar_adjective1" => 0,
"percent_bipolar_adjective2" => 0,
"percent_neutral" => 20
);
}
else
{
$this->layout = array(
"percent_row" => 30,
"percent_columns" => 70,
"percent_bipolar_adjective1" => 0,
"percent_bipolar_adjective2" => 0,
"percent_neutral" => 0
);
}
}
return $this->layout;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getLegend ( )

Get whether the legend should be shown or not.

Returns
boolean Show legend

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

References $legend.

Referenced by saveToDb().

{
return $this->legend;
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getNeutralColumn ( )

Returns the text of the neutral column.

Returns the text of the neutral column

Returns
string The text of the neutral column public
See Also
$neutralColumn

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

References $neutralColumn.

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

{
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getNeutralColumnIndex ( )

Returns the index of the neutral column.

Returns the index of the neutral column

Returns
integer The index of the neutral column public
See Also
$neutralColumn

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

References getColumnCount(), and getNeutralColumn().

Referenced by getCumulatedResults(), and getCumulatedResultsForRow().

{
if (strlen($this->getNeutralColumn()))
{
return $this->getColumnCount();
}
else
{
return FALSE;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getNeutralColumnSeparator ( )

Gets the separator enable state for the neutral column.

Gets the separator enable state for the neutral column

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

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

References $neutralColumnSeparator.

Referenced by insertXML(), and saveToDb().

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getNrOfUsersAnswered (   $survey_id)

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

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

References $result, and SurveyQuestion\$survey_id.

Referenced by getCumulatedResults(), and getCumulatedResultsForRow().

{
global $ilDB;
$query = sprintf("SELECT DISTINCT(CONCAT(survey_answer.active_fi,survey_answer.question_fi)) AS participants FROM survey_answer, survey_finished WHERE survey_answer.question_fi = %s AND survey_finished.survey_fi = %s AND survey_finished.finished_id = survey_answer.active_fi",
$ilDB->quote($this->getId() . ""),
$ilDB->quote($survey_id . "")
);
$result = $ilDB->query($query);
return $result->numRows();
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getPreconditionValueOutput (   $value)

Returns the output for a precondition value.

Returns the output for a precondition value

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

Reimplemented from SurveyQuestion.

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

{
return $value;
}
SurveyMatrixQuestion::getQuestionType ( )

Returns the question type of the question.

Returns the question type of the question

Returns
integer The question type of the question public

Reimplemented from SurveyQuestion.

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

{
return "SurveyMatrixQuestion";
}
SurveyMatrixQuestion::getRandomRows ( )

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

References $randomRows.

Referenced by loadFromDb(), and saveToDb().

{
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getRepeatColumnHeader ( )

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

References $repeatColumnHeader.

Referenced by loadFromDb(), and saveToDb().

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getRow (   $a_index)

Returns a specific row.

Returns a specific row

Parameters
integer$a_indexThe index position of the row public

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

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

{
if (array_key_exists($a_index, $this->rows))
{
return $this->rows[$a_index];
}
return "";
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getRowCount ( )

Returns the number of rows in the question.

Returns the number of rows in the question

Returns
integer The number of rows public

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

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

{
return count($this->rows);
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getRowImages ( )

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

References $rowImages.

Referenced by loadFromDb(), and saveToDb().

{
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getRowSeparators ( )

Gets the separators enable state for the matrix rows.

Gets the separators enable state for the matrix rows

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

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

References $rowSeparators.

Referenced by insertXML(), and saveToDb().

{
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getSingleLineRowCaption ( )

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

References $singleLineRowCaption.

Referenced by loadFromDb(), and saveToDb().

+ Here is the caller graph for this function:

SurveyMatrixQuestion::getSubtype ( )

Returns the subtype of the matrix question.

Returns the subtype of the matrix question

Returns
integer The subtype of the matrix question public

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

References $subtype.

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

{
}

+ Here is the caller graph for this function:

& SurveyMatrixQuestion::getUserAnswers (   $survey_id)

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

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

Reimplemented from SurveyQuestion.

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

References $result, $results, SurveyQuestion\$survey_id, getColumn(), SurveyQuestion\getId(), and getRow().

{
global $ilDB;
$answers = array();
$query = sprintf("SELECT survey_answer.* FROM survey_answer, survey_finished WHERE survey_finished.survey_fi = %s AND survey_answer.question_fi = %s AND survey_finished.finished_id = survey_answer.active_fi ORDER BY row, value",
$ilDB->quote($survey_id),
$ilDB->quote($this->getId())
);
$result = $ilDB->query($query);
$results = array();
while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
{
$column = $this->getColumn($row["value"]);
if (!is_array($answers[$row["active_fi"]])) $answers[$row["active_fi"]] = array();
array_push($answers[$row["active_fi"]], $this->getRow($row["row"]) . ": " . ($row["value"] + 1) . " - " . $column);
}
foreach ($answers as $key => $value)
{
$answers[$key] = implode("<br />", $value);
}
return $answers;
}

+ Here is the call graph for this function:

& SurveyMatrixQuestion::getWorkingDataFromUserInput (   $post_data)

Creates the user data of the survey_answer table from the POST data.

Creates the user data of the survey_answer table from the POST data

Returns
array User data according to the survey_answer table public

Reimplemented from SurveyQuestion.

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

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

{
$data = array();
foreach ($post_data as $key => $value)
{
switch ($this->getSubtype())
{
case 0:
if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches))
{
if (is_array($value))
{
foreach ($value as $val)
{
array_push($data, array("value" => $val, "row" => $matches[1]));
}
}
else
{
array_push($data, array("value" => $value, "row" => $matches[1]));
}
}
break;
case 1:
if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches))
{
if (is_array($value))
{
foreach ($value as $val)
{
array_push($data, array("value" => $val, "row" => $matches[1]));
}
}
else
{
array_push($data, array("value" => $value, "row" => $matches[1]));
}
}
break;
}
}
return $data;
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::hasBipolarAdjectives ( )

Returns TRUE if bipolar adjectives exist.

Returns TRUE if bipolar adjectives exist

Returns
boolean TRUE if bipolar adjectives exist, FALSE otherwise

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

References getBipolarAdjective().

Referenced by getLayout().

{
if ((strlen($this->getBipolarAdjective(0))) && (strlen($this->getBipolarAdjective(1))))
{
return TRUE;
}
else
{
return FALSE;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyMatrixQuestion::hasNeutralColumn ( )

Returns TRUE if a neutral column exists.

Returns TRUE if a neutral column exists

Returns
boolean TRUE if a neutral column exists, FALSE otherwise

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

References getNeutralColumn().

Referenced by getCumulatedResults(), getCumulatedResultsForRow(), getLayout(), and saveRandomData().

{
if (strlen($this->getNeutralColumn()))
{
return TRUE;
}
else
{
return FALSE;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyMatrixQuestion::importAdditionalMetadata (   $a_meta)

Import additional meta data from the question import file.

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

Reimplemented from SurveyQuestion.

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

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

{
foreach ($a_meta as $key => $value)
{
switch ($value["label"])
{
case "column_separators":
$this->setColumnSeparators($value["entry"]);
break;
case "row_separators":
$this->setRowSeparators($value["entry"]);
break;
case "layout":
$this->setLayout($value["entry"]);
break;
case "neutral_column_separator":
$this->setNeutralColumnSeparator($value["entry"]);
break;
}
}
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::importAdjectives (   $a_data)

Import bipolar adjectives from the question import file.

Import bipolar adjectives from the question import file

Returns
array $a_data Array containing the adjectives public

Reimplemented from SurveyQuestion.

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

References setBipolarAdjective().

{
$i = 0;
foreach ($a_data as $adjective)
{
if (is_numeric($adjective["label"]))
{
$this->setBipolarAdjective($adjective["label"], $adjective["text"]);
}
else
{
$this->setBipolarAdjective($i, $adjective["text"]);
}
$i++;
}
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::importMatrix (   $a_data)

Import matrix rows from the question import file.

Import matrix rows from the question import file

Returns
array $a_data Array containing the matrix rows public

Reimplemented from SurveyQuestion.

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

References addRow().

{
foreach ($a_data as $row)
{
$this->addRow($row);
}
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::importResponses (   $a_data)

Import response data from the question import file.

Import response data from the question import file

Returns
array $a_data Array containing the response data public

Reimplemented from SurveyQuestion.

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

References $data, SurveyQuestion\$id, SurveyQuestion\$material, addColumn(), and setNeutralColumn().

{
foreach ($a_data as $id => $data)
{
$column = "";
foreach ($data["material"] as $material)
{
$column .= $material["text"];
}
if (strcmp($data["label"], "neutral") == 0)
{
$this->setNeutralColumn($column);
}
else
{
$this->addColumn($column);
}
}
}

+ Here is the call graph for this function:

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

Adds the question XML to a given XMLWriter object.

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

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

Referenced by toXML().

{
$attrs = array(
"id" => $this->getId(),
"title" => $this->getTitle(),
"type" => $this->getQuestiontype(),
"subtype" => $this->getSubtype(),
"obligatory" => $this->getObligatory()
);
$a_xml_writer->xmlStartTag("question", $attrs);
$a_xml_writer->xmlElement("description", NULL, $this->getDescription());
$a_xml_writer->xmlElement("author", NULL, $this->getAuthor());
$a_xml_writer->xmlStartTag("questiontext");
$this->addMaterialTag($a_xml_writer, $this->getQuestiontext());
$a_xml_writer->xmlEndTag("questiontext");
$a_xml_writer->xmlStartTag("matrix");
$a_xml_writer->xmlStartTag("matrixrows");
for ($i = 0; $i < $this->getRowCount(); $i++)
{
$attrs = array(
"id" => $i
);
$a_xml_writer->xmlStartTag("matrixrow", $attrs);
$this->addMaterialTag($a_xml_writer, $this->getRow($i));
$a_xml_writer->xmlEndTag("matrixrow");
}
$a_xml_writer->xmlEndTag("matrixrows");
$a_xml_writer->xmlStartTag("responses");
if (strlen($this->getBipolarAdjective(0)) && (strlen($this->getBipolarAdjective(1))))
{
$a_xml_writer->xmlStartTag("bipolar_adjectives");
$attribs = array(
"label" => "0"
);
$a_xml_writer->xmlElement("adjective", $attribs, $this->getBipolarAdjective(0));
$attribs = array(
"label" => "1"
);
$a_xml_writer->xmlElement("adjective", $attribs, $this->getBipolarAdjective(1));
$a_xml_writer->xmlEndTag("bipolar_adjectives");
}
for ($i = 0; $i < $this->getColumnCount(); $i++)
{
$attrs = array(
"id" => $i
);
switch ($this->getSubtype())
{
case 0:
$a_xml_writer->xmlStartTag("response_single", $attrs);
break;
case 1:
$a_xml_writer->xmlStartTag("response_multiple", $attrs);
break;
}
$this->addMaterialTag($a_xml_writer, $this->getColumn($i));
switch ($this->getSubtype())
{
case 0:
$a_xml_writer->xmlEndTag("response_single");
break;
case 1:
$a_xml_writer->xmlEndTag("response_multiple");
break;
}
}
if (strlen($this->getNeutralColumn()))
{
$attrs = array(
"id" => $this->getColumnCount(),
"label" => "neutral"
);
switch ($this->getSubtype())
{
case 0:
$a_xml_writer->xmlStartTag("response_single", $attrs);
break;
case 1:
$a_xml_writer->xmlStartTag("response_multiple", $attrs);
break;
}
$this->addMaterialTag($a_xml_writer, $this->getNeutralColumn());
switch ($this->getSubtype())
{
case 0:
$a_xml_writer->xmlEndTag("response_single");
break;
case 1:
$a_xml_writer->xmlEndTag("response_multiple");
break;
}
}
$a_xml_writer->xmlEndTag("responses");
$a_xml_writer->xmlEndTag("matrix");
if (count($this->material))
{
if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $this->material["internal_link"], $matches))
{
$attrs = array(
"label" => $this->material["title"]
);
$a_xml_writer->xmlStartTag("material", $attrs);
$intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
if (strcmp($matches[1], "") != 0)
{
$intlink = $this->material["internal_link"];
}
$a_xml_writer->xmlElement("mattext", NULL, $intlink);
$a_xml_writer->xmlEndTag("material");
}
}
$a_xml_writer->xmlStartTag("metadata");
$a_xml_writer->xmlStartTag("metadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "column_separators");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getColumnSeparators());
$a_xml_writer->xmlEndTag("metadatafield");
$a_xml_writer->xmlStartTag("metadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "row_separators");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getRowSeparators());
$a_xml_writer->xmlEndTag("metadatafield");
$a_xml_writer->xmlStartTag("metadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "neutral_column_separator");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getNeutralColumnSeparator());
$a_xml_writer->xmlEndTag("metadatafield");
$a_xml_writer->xmlStartTag("metadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "layout");
$a_xml_writer->xmlElement("fieldentry", NULL, serialize($this->getLayout()));
$a_xml_writer->xmlEndTag("metadatafield");
$a_xml_writer->xmlEndTag("metadata");
$a_xml_writer->xmlEndTag("question");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyMatrixQuestion::isComplete ( )

Returns true if the question is complete for use.

Returns true if the question is complete for use

Returns
boolean True if the question is complete for use, otherwise false public

Reimplemented from SurveyQuestion.

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

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

Referenced by saveToDb(), and syncWithOriginal().

{
if (
strlen($this->getTitle()) &&
strlen($this->getAuthor()) &&
strlen($this->getQuestiontext()) &&
$this->getColumnCount() &&
$this->getRowCount()
)
{
return 1;
}
else
{
return 0;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SurveyMatrixQuestion::loadFromDb (   $id)

Loads a SurveyMatrixQuestion object from the database.

Loads a SurveyMatrixQuestion object from the database

Parameters
integer$idThe database id of the matrix question public

Reimplemented from SurveyQuestion.

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

References $data, SurveyQuestion\$id, $result, ilRTE\_replaceMediaObjectImageSrc(), addColumn(), addRow(), flushColumns(), getColumnHeaderPosition(), getColumnImages(), getColumnOrder(), getRandomRows(), getRepeatColumnHeader(), getRowImages(), getSingleLineRowCaption(), SurveyQuestion\loadMaterialFromDb(), setBipolarAdjective(), setColumnPlaceholders(), setColumnSeparators(), setLayout(), setLegend(), setNeutralColumn(), setNeutralColumnSeparator(), setRowSeparators(), and setSubtype().

{
global $ilDB;
$query = sprintf("SELECT survey_question.*, survey_question_matrix.* FROM survey_question, survey_question_matrix WHERE survey_question.question_id = %s AND survey_question.question_id = survey_question_matrix.question_fi",
$ilDB->quote($id)
);
$result = $ilDB->query($query);
if ($result->numRows() == 1)
{
$data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
$this->id = $data->question_id;
$this->title = $data->title;
$this->description = $data->description;
$this->obj_id = $data->obj_fi;
$this->author = $data->author;
$this->owner = $data->owner_fi;
include_once("./Services/RTE/classes/class.ilRTE.php");
$this->questiontext = ilRTE::_replaceMediaObjectImageSrc($data->questiontext, 1);
$this->obligatory = $data->obligatory;
$this->complete = $data->complete;
$this->original_id = $data->original_id;
$this->setSubtype($data->subtype);
$this->setRowSeparators($data->row_separators);
$this->setNeutralColumnSeparator($data->neutral_column_separator);
$this->setColumnSeparators($data->column_separators);
$this->setColumnPlaceholders($data->column_placeholders);
$this->setLegend($data->legend);
$this->getSingleLineRowCaption($data->singleline_row_caption);
$this->getRepeatColumnHeader($data->repeat_column_header);
$this->getColumnHeaderPosition($data->column_header_position);
$this->getRandomRows($data->random_rows);
$this->getColumnOrder($data->column_order);
$this->getColumnImages($data->column_images);
$this->getRowImages($data->row_images);
$this->setBipolarAdjective(0, $data->bipolar_adjective1);
$this->setBipolarAdjective(1, $data->bipolar_adjective2);
$this->setLayout($data->layout);
// loads materials uris from database
$this->flushColumns();
$query = sprintf("SELECT survey_variable.*, survey_category.title, survey_category.neutral FROM survey_variable, survey_category WHERE survey_variable.question_fi = %s AND survey_variable.category_fi = survey_category.category_id ORDER BY sequence ASC",
$ilDB->quote($id)
);
$result = $ilDB->query($query);
if ($result->numRows() > 0)
{
while ($data = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
{
if ($data->neutral == 0)
{
$this->addColumn($data->title);
}
else
{
$this->setNeutralColumn($data->title);
}
}
}
$query = sprintf("SELECT * FROM survey_question_matrix_rows WHERE question_fi = %s ORDER BY sequence",
$ilDB->quote($id . "")
);
$result = $ilDB->query($query);
while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
{
$this->addRow($row["title"]);
}
}
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::outChart (   $survey_id,
  $type = "" 
)

Creates an image visualising the results of the question.

Creates an image visualising the results of the question

Parameters
integer$survey_idThe database ID of the survey
string$typeAn additional parameter to allow to draw more than one chart per question. Must be interpreted by the question. Default is an empty string
Returns
binary Image with the visualisation private

Reimplemented from SurveyQuestion.

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

References $ilLog, SurveyQuestion\$survey_id, SurveyQuestion\$title, ilObjSurvey\_getNrOfParticipants(), getCumulatedResults(), and getRow().

{
if (count($this->cumulated) == 0)
{
include_once "./Modules/Survey/classes/class.ilObjSurvey.php";
$this->cumulated =& $this->getCumulatedResults($survey_id, $nr_of_users);
}
global $ilLog;
if (is_numeric($type))
{
foreach ($this->cumulated[$type]["variables"] as $key => $value)
{
foreach ($value as $key2 => $value2)
{
$this->cumulated["variables"][$key][$key2] = utf8_decode($value2);
}
}
$title = preg_replace("/<[^>]+?>/ims", "", $this->getRow($type));
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyChart.php";
$b1 = new SurveyChart("bars", 400, 250, utf8_decode($title),utf8_decode($this->lng->txt("answers")), utf8_decode($this->lng->txt("users_answered")), $this->cumulated[$type]["variables"]);
}
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::removeColumn (   $index)

Removes a column from the list of columns.

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

Referenced by removeColumnWithName().

{
unset($this->columns[$index]);
$this->columns = array_values($this->columns);
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::removeColumns (   $array)

Removes many columns from the list of columns.

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

{
foreach ($array as $index)
{
unset($this->columns[$index]);
}
$this->columns = array_values($this->columns);
}
SurveyMatrixQuestion::removeColumnWithName (   $name)

Removes a column from the list of columns.

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

References removeColumn().

{
foreach ($this->columns as $index => $column)
{
if (strcmp($column, $name) == 0)
{
return $this->removeColumn($index);
}
}
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::removeRows (   $array)

Removes rows from the question.

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

{
foreach ($array as $index)
{
unset($this->rows[$index]);
}
$this->rows = array_values($this->rows);
}
SurveyMatrixQuestion::saveBipolarAdjectives (   $adjective1,
  $adjective2 
)

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

References $result, and SurveyQuestion\getId().

{
global $ilDB;
$query = sprintf("UPDATE survey_question_matrix SET bipolar_adjective1 = %s, bipolar_adjective2 = %s WHERE question_fi = %s",
$ilDB->quote($adjective1 . ""),
$ilDB->quote($adjective2 . ""),
$ilDB->quote($this->getId() . "")
);
$result = $ilDB->query($query);
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::saveColumnsToDb (   $original_id = "")

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

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

Referenced by saveToDb(), and syncWithOriginal().

{
global $ilDB;
// save columns
$question_id = $this->getId();
if (strlen($original_id))
{
$question_id = $original_id;
}
// delete existing column relations
$query = sprintf("DELETE FROM survey_variable WHERE question_fi = %s",
$ilDB->quote($question_id)
);
$result = $ilDB->query($query);
// create new column relations
for ($i = 0; $i < $this->getColumnCount(); $i++)
{
$cat = $this->getColumn($i);
$column_id = $this->saveColumnToDb($cat);
$query = sprintf("INSERT INTO survey_variable (variable_id, category_fi, question_fi, value1, sequence, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL)",
$ilDB->quote($column_id . ""),
$ilDB->quote($question_id . ""),
$ilDB->quote(($i + 1) . ""),
$ilDB->quote($i . "")
);
$answer_result = $ilDB->query($query);
}
if (strlen($this->getNeutralColumn()))
{
$column_id = $this->saveColumnToDb($this->getNeutralColumn(), 1);
$query = sprintf("INSERT INTO survey_variable (variable_id, category_fi, question_fi, value1, sequence, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL)",
$ilDB->quote($column_id . ""),
$ilDB->quote($question_id . ""),
$ilDB->quote(($i + 1) . ""),
$ilDB->quote($i . "")
);
$answer_result = $ilDB->query($query);
}
$this->saveCompletionStatus($original_id);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Saves a column to the database.

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

References $result.

Referenced by saveColumnsToDb().

{
global $ilUser, $ilDB;
$query = sprintf("SELECT title, category_id FROM survey_category WHERE title = %s AND neutral = %s AND owner_fi = %s",
$ilDB->quote($columntext . ""),
$ilDB->quote($neutral . ""),
$ilDB->quote($ilUser->getId() . "")
);
$result = $ilDB->query($query);
$insert = FALSE;
$returnvalue = "";
if ($result->numRows())
{
$insert = TRUE;
while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
{
if (strcmp($row->title, $columntext) == 0)
{
$returnvalue = $row->category_id;
$insert = FALSE;
}
}
}
else
{
$insert = TRUE;
}
if ($insert)
{
$query = sprintf("INSERT INTO survey_category (category_id, title, neutral, owner_fi, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)",
$ilDB->quote($columntext . ""),
$ilDB->quote($neutral . ""),
$ilDB->quote($ilUser->getId() . "")
);
$result = $ilDB->query($query);
$returnvalue = $ilDB->getLastInsertId();
}
return $returnvalue;
}

+ Here is the caller graph for this function:

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

Saves the layout of a matrix question.

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

References $layout, and SurveyQuestion\getId().

{
global $ilDB;
$layout = array(
"percent_row" => $percent_row,
"percent_columns" => $percent_columns,
"percent_bipolar_adjective1" => $percent_bipolar_adjective1,
"percent_bipolar_adjective2" => $percent_bipolar_adjective2,
"percent_neutral" => $percent_neutral
);
$query = sprintf("UPDATE survey_question_matrix SET layout = %s WHERE question_fi = %s",
$ilDB->quote(serialize($layout) . ""),
$ilDB->quote($this->getId() . "")
);
$ilDB->query($query);
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::savePhrase (   $phrases,
  $title 
)

Saves a set of columns to a default phrase.

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

References $result, SurveyQuestion\$title, and getColumn().

{
global $ilUser;
global $ilDB;
$query = sprintf("INSERT INTO survey_phrase (phrase_id, title, defaultvalue, owner_fi, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)",
$ilDB->quote($title . ""),
$ilDB->quote("1"),
$ilDB->quote($ilUser->id . "")
);
$result = $ilDB->query($query);
$phrase_id = $ilDB->getLastInsertId();
$counter = 1;
foreach ($phrases as $column_index)
{
$column = $this->getColumn($column_index);
$query = sprintf("INSERT INTO survey_category (category_id, title, neutral, defaultvalue, owner_fi, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL)",
$ilDB->quote($column . ""),
$ilDB->quote("0"),
$ilDB->quote("1"),
$ilDB->quote($ilUser->getId() . "")
);
$result = $ilDB->query($query);
$column_id = $ilDB->getLastInsertId();
$query = sprintf("INSERT INTO survey_phrase_category (phrase_category_id, phrase_fi, category_fi, sequence) VALUES (NULL, %s, %s, %s)",
$ilDB->quote($phrase_id . ""),
$ilDB->quote($column_id . ""),
$ilDB->quote($counter . "")
);
$result = $ilDB->query($query);
$counter++;
}
}

+ Here is the call graph for this function:

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

References $result, getColumnCount(), getRowCount(), and hasNeutralColumn().

{
global $ilDB;
$columncount = ($this->hasNeutralColumn()) ? $this->getColumnCount()+1 : $this->getColumnCount();
for ($row = 0; $row < $this->getRowCount(); $row++)
{
if ($this->getSubType() == 1)
{
// multiple responses
for ($i = 0; $i < $columncount; $i++)
{
if (rand(0,1))
{
$query = sprintf("INSERT INTO survey_answer (answer_id, question_fi, active_fi, value, textanswer, row, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL, %s, NULL)",
$ilDB->quote($this->getId() . ""),
$ilDB->quote($active_id . ""),
$ilDB->quote($i . ""),
$ilDB->quote($row . "")
);
$result = $ilDB->query($query);
}
}
}
else
{
// single responses
$category = rand(0, $columncount-1);
$query = sprintf("INSERT INTO survey_answer (answer_id, question_fi, active_fi, value, textanswer, row, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL, %s, NULL)",
$ilDB->quote($this->getId() . ""),
$ilDB->quote($active_id . ""),
$ilDB->quote($category . ""),
$ilDB->quote($row . "")
);
$result = $ilDB->query($query);
}
}
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::saveRowsToDb (   $original_id = "")

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

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

Referenced by saveToDb(), and syncWithOriginal().

{
global $ilDB;
// save rows
$question_id = $this->getId();
if (strlen($original_id))
{
$question_id = $original_id;
}
// delete existing rows
$query = sprintf("DELETE FROM survey_question_matrix_rows WHERE question_fi = %s",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
// create new rows
for ($i = 0; $i < $this->getRowCount(); $i++)
{
$row = $this->getRow($i);
$query = sprintf("INSERT INTO survey_question_matrix_rows (id_survey_question_matrix_rows, title, sequence, question_fi) VALUES (NULL, %s, %s, %s)",
$ilDB->quote($row . ""),
$ilDB->quote($i . ""),
$ilDB->quote($question_id . "")
);
$answer_result = $ilDB->query($query);
}
$this->saveCompletionStatus($original_id);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Saves a SurveyMatrixQuestion object to a database.

Saves a SurveyMatrixQuestion object to a database

public

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

References $result, ilRTE\_cleanupMediaObjectUsage(), ilRTE\_replaceMediaObjectImageSrc(), getBipolarAdjective(), getColumnHeaderPosition(), getColumnImages(), getColumnOrder(), getColumnPlaceholders(), getColumnSeparators(), SurveyQuestion\getId(), getLayout(), getLegend(), getNeutralColumnSeparator(), getRandomRows(), getRepeatColumnHeader(), getRowImages(), getRowSeparators(), getSingleLineRowCaption(), getSubtype(), isComplete(), saveColumnsToDb(), SurveyQuestion\saveMaterialsToDb(), and saveRowsToDb().

{
global $ilDB;
$complete = 0;
if ($this->isComplete())
{
$complete = 1;
}
if ($original_id)
{
$original_id = $ilDB->quote($original_id);
}
else
{
$original_id = "NULL";
}
// cleanup RTE images which are not inserted into the question text
include_once("./Services/RTE/classes/class.ilRTE.php");
ilRTE::_cleanupMediaObjectUsage($this->questiontext, "spl:html",
$this->getId());
if ($this->id == -1)
{
// Write new dataset
$now = getdate();
$created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']);
$query = sprintf("INSERT INTO survey_question (question_id, questiontype_fi, obj_fi, owner_fi, title, description, author, questiontext, obligatory, complete, created, original_id, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NULL)",
$ilDB->quote($this->getQuestionTypeID()),
$ilDB->quote($this->obj_id),
$ilDB->quote($this->owner),
$ilDB->quote($this->title),
$ilDB->quote($this->description),
$ilDB->quote($this->author),
$ilDB->quote(ilRTE::_replaceMediaObjectImageSrc($this->questiontext, 0)),
$ilDB->quote(sprintf("%d", $this->obligatory)),
$ilDB->quote("$complete"),
$ilDB->quote($created),
$original_id
);
$result = $ilDB->query($query);
if (!PEAR::isError($result))
{
$this->id = $ilDB->getLastInsertId();
$query = sprintf("INSERT INTO survey_question_matrix (
question_fi,
subtype,
column_separators,
row_separators,
neutral_column_separator,
column_placeholders,
legend,
singleline_row_caption,
repeat_column_header,
column_header_position,
random_rows,
column_order,
column_images,
row_images,
bipolar_adjective1,
bipolar_adjective2,
layout
)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
$ilDB->quote($this->id . ""),
$ilDB->quote(sprintf("%d", $this->getSubtype())),
$ilDB->quote($this->getColumnSeparators() . ""),
$ilDB->quote($this->getRowSeparators() . ""),
$ilDB->quote($this->getNeutralColumnSeparator() . ""),
$ilDB->quote($this->getColumnPlaceholders() . ""),
$ilDB->quote($this->getLegend() . ""),
$ilDB->quote($this->getSingleLineRowCaption() . ""),
$ilDB->quote($this->getRepeatColumnHeader() . ""),
$ilDB->quote($this->getColumnHeaderPosition() . ""),
$ilDB->quote($this->getRandomRows() . ""),
$ilDB->quote($this->getColumnOrder() . ""),
$ilDB->quote($this->getColumnImages() . ""),
$ilDB->quote($this->getRowImages() . ""),
$ilDB->quote($this->getBipolarAdjective(0) . ""),
$ilDB->quote($this->getBipolarAdjective(1) . ""),
$ilDB->quote(serialize($this->getLayout()) . "")
);
$ilDB->query($query);
}
}
else
{
// update existing dataset
$query = sprintf("UPDATE survey_question SET title = %s, description = %s, author = %s, questiontext = %s, obligatory = %s, complete = %s WHERE question_id = %s",
$ilDB->quote($this->title),
$ilDB->quote($this->description),
$ilDB->quote($this->author),
$ilDB->quote(ilRTE::_replaceMediaObjectImageSrc($this->questiontext, 0)),
$ilDB->quote(sprintf("%d", $this->obligatory)),
$ilDB->quote("$complete"),
$ilDB->quote($this->id)
);
$result = $ilDB->query($query);
$query = sprintf("UPDATE survey_question_matrix SET
subtype = %s,
column_separators = %s,
row_separators = %s,
neutral_column_separator = %s,
column_placeholders = %s,
legend = %s,
singleline_row_caption = %s,
repeat_column_header = %s,
column_header_position = %s,
random_rows = %s,
column_order = %s,
column_images = %s,
row_images = %s,
bipolar_adjective1 = %s,
bipolar_adjective2 = %s,
layout = %s
WHERE question_fi = %s",
$ilDB->quote(sprintf("%d", $this->getSubtype())),
$ilDB->quote($this->getColumnSeparators() . ""),
$ilDB->quote($this->getRowSeparators() . ""),
$ilDB->quote($this->getNeutralColumnSeparator() . ""),
$ilDB->quote($this->getColumnPlaceholders() . ""),
$ilDB->quote($this->getLegend() . ""),
$ilDB->quote($this->getSingleLineRowCaption() . ""),
$ilDB->quote($this->getRepeatColumnHeader() . ""),
$ilDB->quote($this->getColumnHeaderPosition() . ""),
$ilDB->quote($this->getRandomRows() . ""),
$ilDB->quote($this->getColumnOrder() . ""),
$ilDB->quote($this->getColumnImages() . ""),
$ilDB->quote($this->getRowImages() . ""),
$ilDB->quote($this->getBipolarAdjective(0) . ""),
$ilDB->quote($this->getBipolarAdjective(1) . ""),
$ilDB->quote(serialize($this->getLayout()) . ""),
$ilDB->quote($this->id . "")
);
$result = $ilDB->query($query);
}
if (!PEAR::isError($result))
{
// saving material uris in the database
if ($withanswers)
{
$this->saveColumnsToDb();
$this->saveRowsToDb();
}
}
parent::saveToDb($original_id);
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::saveUserInput (   $post_data,
  $active_id 
)

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

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

{
global $ilDB;
switch ($this->getSubtype())
{
case 0:
foreach ($post_data as $key => $value)
{
if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches))
{
$query = sprintf("INSERT INTO survey_answer (answer_id, question_fi, active_fi, value, textanswer, row, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, NULL)",
$ilDB->quote($this->getId() . ""),
$ilDB->quote($active_id . ""),
$ilDB->quote($value . ""),
"NULL",
$ilDB->quote($matches[1] . "")
);
$result = $ilDB->query($query);
}
}
break;
case 1:
foreach ($post_data as $key => $value)
{
if (preg_match("/matrix_" . $this->getId() . "_(\d+)/", $key, $matches))
{
foreach ($value as $checked)
{
if (strlen($checked))
{
$query = sprintf("INSERT INTO survey_answer (answer_id, question_fi, active_fi, value, textanswer, row, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, NULL)",
$ilDB->quote($this->getId() . ""),
$ilDB->quote($active_id . ""),
$ilDB->quote($checked . ""),
"NULL",
$ilDB->quote($matches[1] . "")
);
$result = $ilDB->query($query);
}
}
}
}
break;
}
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::setBipolarAdjective (   $a_index,
  $a_value 
)

Sets one of the bipolar adjectives.

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

Referenced by importAdjectives(), and loadFromDb().

{
switch ($a_index)
{
case 1:
$this->bipolar_adjective2 = $a_value;
break;
case 0:
default:
$this->bipolar_adjective1 = $a_value;
break;
}
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::setColumnHeaderPosition (   $a_value)

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

{
$this->columnHeaderPosition = $a_value;
}
SurveyMatrixQuestion::setColumnImages (   $a_value = FALSE)

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

{
if ($a_value)
{
$this->columnImages = TRUE;
}
else
{
$this->columnImages = FALSE;
}
}
SurveyMatrixQuestion::setColumnOrder (   $a_value)

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

{
$this->columnOrder = $a_value;
}
SurveyMatrixQuestion::setColumnPlaceholders (   $a_value = FALSE)

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

Parameters
boolean$a_valueTRUE for placeholders, FALSE otherwise

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

Referenced by loadFromDb().

{
if ($a_value)
{
$this->columnPlaceholders = TRUE;
}
else
{
$this->columnPlaceholders = FALSE;
}
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::setColumnSeparators (   $enable = 0)

Enables/Disables separators for the matrix columns.

Enables/Disables separators for the matrix columns

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

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

Referenced by importAdditionalMetadata(), and loadFromDb().

{
switch ($enable)
{
case 1:
$this->columnSeparators = 1;
break;
case 0:
default:
$this->columnSeparators = 0;
break;
}
}

+ Here is the caller graph for this function:

& SurveyMatrixQuestion::setExportCumulatedCVS ( $eval_data)

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

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

Reimplemented from SurveyQuestion.

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

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

{
$result = array();
foreach ($eval_data as $evalkey => $evalvalue)
{
$csvrow = array();
if (is_numeric($evalkey))
{
array_push($csvrow, "");
array_push($csvrow, $evalvalue["ROW"]);
array_push($csvrow, "");
}
else
{
array_push($csvrow, $this->getTitle());
array_push($csvrow, $this->getQuestiontext());
array_push($csvrow, $this->lng->txt($evalvalue["QUESTION_TYPE"]));
}
array_push($csvrow, $evalvalue["USERS_ANSWERED"]);
array_push($csvrow, $evalvalue["USERS_SKIPPED"]);
array_push($csvrow, $evalvalue["MODE"]);
array_push($csvrow, $evalvalue["MODE_NR_OF_SELECTIONS"]);
array_push($csvrow, $evalvalue["MEDIAN"]);
array_push($csvrow, $evalvalue["ARITHMETIC_MEAN"]);
array_push($result, $csvrow);
}
return $result;
}

+ Here is the call graph for this function:

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

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

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

Reimplemented from SurveyQuestion.

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

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

{
include_once ("./classes/class.ilExcelUtils.php");
$worksheet->writeString($row, 0, ilExcelUtils::_convert_text($this->getTitle()));
$worksheet->writeString($row, 1, ilExcelUtils::_convert_text($this->getQuestiontext()));
$worksheet->writeString($row, 2, ilExcelUtils::_convert_text($this->lng->txt($eval_data["TOTAL"]["QUESTION_TYPE"])));
$worksheet->write($row, 3, $eval_data["TOTAL"]["USERS_ANSWERED"]);
$worksheet->write($row, 4, $eval_data["TOTAL"]["USERS_SKIPPED"]);
$worksheet->write($row, 5, ilExcelUtils::_convert_text($eval_data["TOTAL"]["MODE_VALUE"]));
$worksheet->write($row, 6, ilExcelUtils::_convert_text($eval_data["TOTAL"]["MODE"]));
$worksheet->write($row, 7, $eval_data["TOTAL"]["MODE_NR_OF_SELECTIONS"]);
$worksheet->write($row, 8, ilExcelUtils::_convert_text(str_replace("<br />", " ", $eval_data["TOTAL"]["MEDIAN"])));
$worksheet->write($row, 9, $eval_data["TOTAL"]["ARITHMETIC_MEAN"]);
$row++;
foreach ($eval_data as $evalkey => $evalvalue)
{
if (is_numeric($evalkey))
{
$worksheet->writeString($row, 1, ilExcelUtils::_convert_text($evalvalue["ROW"]));
$worksheet->write($row, 3, $evalvalue["USERS_ANSWERED"]);
$worksheet->write($row, 4, $evalvalue["USERS_SKIPPED"]);
$worksheet->write($row, 5, ilExcelUtils::_convert_text($evalvalue["MODE_VALUE"]));
$worksheet->write($row, 6, ilExcelUtils::_convert_text($evalvalue["MODE"]));
$worksheet->write($row, 7, $evalvalue["MODE_NR_OF_SELECTIONS"]);
$worksheet->write($row, 8, ilExcelUtils::_convert_text(str_replace("<br />", " ", $evalvalue["MEDIAN"])));
$worksheet->write($row, 9, $evalvalue["ARITHMETIC_MEAN"]);
$row++;
}
}
return $row;
}

+ Here is the call graph for this function:

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

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

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

Reimplemented from SurveyQuestion.

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

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

{
include_once ("./classes/class.ilExcelUtils.php");
$worksheet =& $workbook->addWorksheet();
$worksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_bold);
$worksheet->writeString(0, 1, ilExcelUtils::_convert_text($this->getTitle()));
$worksheet->writeString(1, 0, ilExcelUtils::_convert_text($this->lng->txt("question")), $format_bold);
$worksheet->writeString(1, 1, ilExcelUtils::_convert_text($this->getQuestiontext()));
$worksheet->writeString(2, 0, ilExcelUtils::_convert_text($this->lng->txt("question_type")), $format_bold);
$worksheet->writeString(2, 1, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())));
$worksheet->writeString(3, 0, ilExcelUtils::_convert_text($this->lng->txt("users_answered")), $format_bold);
$worksheet->write(3, 1, $eval_data["TOTAL"]["USERS_ANSWERED"]);
$worksheet->writeString(4, 0, ilExcelUtils::_convert_text($this->lng->txt("users_skipped")), $format_bold);
$worksheet->write(4, 1, $eval_data["TOTAL"]["USERS_SKIPPED"]);
$rowcounter = 5;
preg_match("/(.*?)\s+-\s+(.*)/", $eval_data["TOTAL"]["MODE"], $matches);
$worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode")), $format_bold);
$worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[1]));
$worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_text")), $format_bold);
$worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[2]));
$worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_nr_of_selections")), $format_bold);
$worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval_data["TOTAL"]["MODE_NR_OF_SELECTIONS"]));
$worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("median")), $format_bold);
$worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text(str_replace("<br />", " ", $eval_data["TOTAL"]["MEDIAN"])));
$worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("categories")), $format_bold);
$worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_title);
$worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($this->lng->txt("value")), $format_title);
$worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($this->lng->txt("category_nr_selected")), $format_title);
$worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($this->lng->txt("percentage_of_selections")), $format_title);
foreach ($eval_data["TOTAL"]["variables"] as $key => $value)
{
$worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($value["title"]));
$worksheet->write($rowcounter, 2, $key+1);
$worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($value["selected"]));
$worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($value["percentage"]), $format_percent);
}
foreach ($eval_data as $evalkey => $evalvalue)
{
if (is_numeric($evalkey))
{
$worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("row")), $format_bold);
$worksheet->writeString($rowcounter, 1, ilExcelUtils::_convert_text($evalvalue["ROW"]));
$worksheet->writeString($rowcounter + 1, 0, ilExcelUtils::_convert_text($this->lng->txt("users_answered")), $format_bold);
$worksheet->write($rowcounter + 1, 1, $evalvalue["USERS_ANSWERED"]);
$worksheet->writeString($rowcounter + 2, 0, ilExcelUtils::_convert_text($this->lng->txt("users_skipped")), $format_bold);
$worksheet->write($rowcounter + 2, 1, $evalvalue["USERS_SKIPPED"]);
$rowcounter = $rowcounter + 3;
preg_match("/(.*?)\s+-\s+(.*)/", $evalvalue["MODE"], $matches);
$worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode")), $format_bold);
$worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[1]));
$worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_text")), $format_bold);
$worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($matches[2]));
$worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_nr_of_selections")), $format_bold);
$worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($evalvalue["MODE_NR_OF_SELECTIONS"]));
$worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("median")), $format_bold);
$worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text(str_replace("<br />", " ", $evalvalue["MEDIAN"])));
$worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("categories")), $format_bold);
$worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_title);
$worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($this->lng->txt("value")), $format_title);
$worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($this->lng->txt("category_nr_selected")), $format_title);
$worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($this->lng->txt("percentage_of_selections")), $format_title);
foreach ($evalvalue["variables"] as $key => $value)
{
$worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($value["title"]));
$worksheet->write($rowcounter, 2, $key+1);
$worksheet->write($rowcounter, 3, ilExcelUtils::_convert_text($value["selected"]));
$worksheet->write($rowcounter++, 4, ilExcelUtils::_convert_text($value["percentage"]), $format_percent);
}
}
}
// out compressed 2D-Matrix
$format_center =& $workbook->addFormat();
$format_center->setColor('black');
$format_center->setAlign('center');
$worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("overview")), $format_bold);
// title row with variables
$rowcounter++;
$counter = 0;
$worksheet->write($rowcounter, $counter, "", $format_title);
foreach ($eval_data["TOTAL"]["variables"] as $variable)
{
$worksheet->write($rowcounter, 1+$counter, ilExcelUtils::_convert_text($variable["title"]), $format_title);
$counter++;
}
$rowcounter++;
// rows with variable values
foreach ($eval_data as $index => $data)
{
if (is_numeric($index))
{
$worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($data["ROW"]), $format_title);
$counter = 1;
foreach ($data["variables"] as $vardata)
{
$worksheet->write($rowcounter, $counter, $vardata["selected"], $format_center);
$counter++;
}
$rowcounter++;
}
}
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::setLayout (   $layout)

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

References $layout.

Referenced by importAdditionalMetadata(), and loadFromDb().

{
if (is_array($layout))
{
$this->layout = $layout;
}
else
{
$this->layout = unserialize($layout);
}
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::setLegend (   $a_value = FALSE)

Set whether the legend should be shown or not.

Parameters
boolean$a_valueShow legend

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

Referenced by loadFromDb().

{
if ($a_value)
{
$this->legend = TRUE;
}
else
{
$this->legend = FALSE;
}
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::setNeutralColumn (   $a_text)

Sets the text of the neutral column.

Sets the text of the neutral column

Parameters
string$a_textThe text of the neutral column public
See Also
$neutralColumn

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

Referenced by importResponses(), and loadFromDb().

{
$this->neutralColumn = $a_text;
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::setNeutralColumnSeparator (   $enable = 0)

Enables/Disables a separator for the neutral column.

Enables/Disables a separator for the neutral column

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

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

Referenced by importAdditionalMetadata(), and loadFromDb().

{
switch ($enable)
{
case 1:
$this->neutralColumnSeparator = 1;
break;
case 0:
default:
$this->neutralColumnSeparator = 0;
break;
}
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::setRandomRows (   $a_value = FALSE)

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

{
if ($a_value)
{
$this->randomRows = TRUE;
}
else
{
$this->randomRows = FALSE;
}
}
SurveyMatrixQuestion::setRepeatColumnHeader (   $a_value = FALSE)

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

{
if ($a_value)
{
$this->repeatColumnHeader = TRUE;
}
else
{
$this->repeatColumnHeader = FALSE;
}
}
SurveyMatrixQuestion::setRowImages (   $a_value = FALSE)

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

{
if ($a_value)
{
$this->rowImages = TRUE;
}
else
{
$this->rowImages = FALSE;
}
}
SurveyMatrixQuestion::setRowSeparators (   $enable = 0)

Enables/Disables separators for the matrix rows.

Enables/Disables separators for the matrix rows

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

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

Referenced by importAdditionalMetadata(), and loadFromDb().

{
switch ($enable)
{
case 1:
$this->rowSeparators = 1;
break;
case 0:
default:
$this->rowSeparators = 0;
break;
}
}

+ Here is the caller graph for this function:

SurveyMatrixQuestion::setSingleLineRowCaption (   $a_value = FALSE)

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

{
if ($a_value)
{
$this->singleLineRowCaption = TRUE;
}
else
{
$this->singleLineRowCaption = FALSE;
}
}
SurveyMatrixQuestion::setSubtype (   $a_subtype = 0)

Sets the subtype of the matrix question.

Sets the subtype of the matrix question

Returns
integer $a_subtype The subtype of the matrix question public

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

Referenced by loadFromDb().

{
switch ($a_subtype)
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
$this->subtype = $a_subtype;
break;
case 0:
default:
$this->subtype = 0;
break;
}
}

+ Here is the caller graph for this function:

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

References SurveyQuestion\$author, SurveyQuestion\$description, SurveyQuestion\$owner, SurveyQuestion\$questiontext, SurveyQuestion\$title, and SurveyQuestion\SurveyQuestion().

{
$this->subtype = 0;
$this->columns = array();
$this->rows = array();
$this->neutralColumn = "";
$this->bipolar_adjective1 = "";
$this->bipolar_adjective2 = "";
$this->rowSeparators = 0;
$this->columnSeparators = 0;
$this->neutralColumnSeparator = 1;
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::syncWithOriginal ( )

Reimplemented from SurveyQuestion.

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

References SurveyQuestion\$ilias, $result, isComplete(), saveColumnsToDb(), and saveRowsToDb().

{
global $ilDB;
if ($this->original_id)
{
$complete = 0;
if ($this->isComplete())
{
$complete = 1;
}
$query = sprintf("UPDATE survey_question SET title = %s, description = %s, author = %s, questiontext = %s, obligatory = %s, complete = %s WHERE question_id = %s",
$ilDB->quote($this->title . ""),
$ilDB->quote($this->description . ""),
$ilDB->quote($this->author . ""),
$ilDB->quote($this->questiontext . ""),
$ilDB->quote(sprintf("%d", $this->obligatory) . ""),
$ilDB->quote($complete . ""),
$ilDB->quote($this->original_id . "")
);
$result = $ilDB->query($query);
$query = sprintf("UPDATE survey_question_matrix SET row_separators = %s, column_separators = %s, neutral_column_separator = %s, bipolar_adjective1 = %s, bipolar_adjective2 = %s WHERE question_fi = %s",
$ilDB->quote($this->getRowSeparators() . ""),
$ilDB->quote($this->getColumnSeparators() . ""),
$ilDB->quote($this->getNeutralColumnSeparator() . ""),
$ilDB->quote($this->getBipolarAdjective(0) . ""),
$ilDB->quote($this->getBipolarAdjective(1) . ""),
$ilDB->quote($this->original_id . "")
);
$result = $ilDB->query($query);
if (PEAR::isError($result))
{
global $ilias;
$ilias->raiseError($result->getMessage());
}
else
{
// sync columns
$this->saveColumnsToDb($this->original_id);
// sync rows
$this->saveRowsToDb($this->original_id);
}
}
}

+ Here is the call graph for this function:

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

Returns an xml representation of the question.

Returns an xml representation of the question

Returns
string The xml representation of the question public

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

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

{
include_once("./classes/class.ilXmlWriter.php");
$a_xml_writer = new ilXmlWriter;
$a_xml_writer->xmlHeader();
$this->insertXML($a_xml_writer, $a_include_header, $obligatory_state);
$xml = $a_xml_writer->xmlDumpMem(FALSE);
if (!$a_include_header)
{
$pos = strpos($xml, "?>");
$xml = substr($xml, $pos + 2);
}
return $xml;
}

+ Here is the call graph for this function:

SurveyMatrixQuestion::usableForPrecondition ( )

Returns if the question is usable for preconditions.

Returns if the question is usable for preconditions

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

Reimplemented from SurveyQuestion.

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

{
return FALSE;
}

Field Documentation

SurveyMatrixQuestion::$bipolar_adjective1

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

Referenced by getBipolarAdjective().

SurveyMatrixQuestion::$bipolar_adjective2

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

Referenced by getBipolarAdjective().

SurveyMatrixQuestion::$columnHeaderPosition

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

Referenced by getColumnHeaderPosition().

SurveyMatrixQuestion::$columnImages

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

Referenced by getColumnImages().

SurveyMatrixQuestion::$columnOrder

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

Referenced by getColumnOrder().

SurveyMatrixQuestion::$columnPlaceholders

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

Referenced by getColumnPlaceholders().

SurveyMatrixQuestion::$columns

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

Referenced by addColumnArray().

SurveyMatrixQuestion::$columnSeparators

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

Referenced by getColumnSeparators().

SurveyMatrixQuestion::$layout

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

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

SurveyMatrixQuestion::$legend

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

Referenced by getLegend().

SurveyMatrixQuestion::$neutralColumn

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

Referenced by getNeutralColumn().

SurveyMatrixQuestion::$neutralColumnSeparator

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

Referenced by getNeutralColumnSeparator().

SurveyMatrixQuestion::$randomRows

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

Referenced by getRandomRows().

SurveyMatrixQuestion::$repeatColumnHeader

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

Referenced by getRepeatColumnHeader().

SurveyMatrixQuestion::$rowImages

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

Referenced by getRowImages().

SurveyMatrixQuestion::$rows

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

SurveyMatrixQuestion::$rowSeparators

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

Referenced by getRowSeparators().

SurveyMatrixQuestion::$singleLineRowCaption

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

Referenced by getSingleLineRowCaption().

SurveyMatrixQuestion::$subtype

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

Referenced by getSubtype().


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