Public Member Functions | Data Fields

SurveyMatrixQuestion Class Reference
[Modules/SurveyQuestionPool]

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.
 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.
 getColumnPlaceholders ()
 setColumnPlaceholders ($columnplaceholders)
 getLegend ()
 setLegend ($legend)
 getSingleLineRowCaption ()
 setSingleLineRowCaption ($singleLineRowCaption)
 getRepeatColumnHeader ()
 setRepeatColumnHeader ($repeatColumnHeader)
 getColumnHeaderPosition ()
 setColumnHeaderPosition ($columnHeaderPosition)
 getRandomRows ()
 setRandomRows ($randomRows)
 getColumnOrder ()
 setColumnOrder ($columnOrder)
 getColumnImages ()
 setColumnImages ($columnImages)
 getRowImages ()
 setRowImages ($rowImages)

Data Fields

 $columns
 $neutralColumn
 $rows
 $bipolar_adjective1
 $bipolar_adjective2
 $columnSeparators
 $rowSeparators
 $neutralColumnSeparator
 $layout
 $columnPlaceholders
 $legend
 $singleLineRowCaption
 $repeatColumnHeader
 $columnHeaderPosition
 $randomRows
 $columnOrder
 $columnImages
 $rowImages
 $subtype

Detailed Description

Matrix question.

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

Author:
Helmut Schottmüller <helmut.schottmueller@mac.com>
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 $id The 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.

        {
                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(DB_FETCHMODE_ASSOC);
                }
                else
                {
                        return array();
                }
        }

SurveyMatrixQuestion::addColumn ( columnname  ) 

Adds a column.

Adds a column

Parameters:
integer $columnname The name of the column
integer $neutral Indicates 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 $columns An 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 $columnname The name of the column
integer $position The 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_id The database id of the given phrase public

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

References 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(DB_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_text The 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_limit The lower limit
integer $upper_limit The upper limit public

Definition at line 1240 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_array An array which is used to append the values
array $resultset The evaluation data for a given user public

Reimplemented from SurveyQuestion.

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

References 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_array An array which is used to append the title row entries public

Reimplemented from SurveyQuestion.

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

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

        {
                parent::addUserSpecificResultsExportTitles($a_array);
                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_data The contents of the $_POST array
integer $survey_id The database ID of the active survey
Returns:
string Empty string if the input is ok, an error message otherwise public

Definition at line 1382 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_id The question id which should be deleted in the additional question table public

Reimplemented from SurveyQuestion.

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

        {
                parent::deleteAdditionalTableData($question_id);
                
                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 1313 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_index The 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.

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

        {
                switch ($a_index)
                {
                        case 1:
                                return $this->bipolar_adjective2;
                                break;
                        case 0:
                        default:
                                return $this->bipolar_adjective1;
                                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 $index The 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(), and saveColumnsToDb().

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

Here is the caller graph for this function:

SurveyMatrixQuestion::getColumnHeaderPosition (  ) 

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

Referenced by loadFromDb(), and saveToDb().

        {
                return $this->columnHeaderPosition;
        }

Here is the caller graph for this function:

SurveyMatrixQuestion::getColumnImages (  ) 

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

Referenced by loadFromDb(), and saveToDb().

        {
                return $this->columnImages;
        }

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 $name The 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 2614 of file class.SurveyMatrixQuestion.php.

Referenced by loadFromDb(), and saveToDb().

        {
                return $this->columnOrder;
        }

Here is the caller graph for this function:

SurveyMatrixQuestion::getColumnPlaceholders (  ) 

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

Referenced by saveToDb().

        {
                return $this->columnPlaceholders;
        }

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

Referenced by insertXML(), and saveToDb().

        {
                return $this->columnSeparators;
        }

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_id The database ID of the survey
Returns:
integer The number of users who took part in the survey public

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

References 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(DB_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 $row The index of the row
integer $survey_id The database ID of the survey
Returns:
integer The number of users who took part in the survey public

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

References 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(DB_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 2456 of file class.SurveyMatrixQuestion.php.

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

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

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.

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

        {
                return $this->neutralColumn;
        }

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

Referenced by insertXML(), and saveToDb().

        {
                return $this->neutralColumnSeparator;
        }

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_id The database ID of the survey
Returns:
integer The number of users public

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

References 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 $value The precondition value
Returns:
string The output of the precondition value public

Reimplemented from SurveyQuestion.

Definition at line 2388 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 1300 of file class.SurveyMatrixQuestion.php.

        {
                return "SurveyMatrixQuestion";
        }

SurveyMatrixQuestion::getRandomRows (  ) 

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

Referenced by loadFromDb(), and saveToDb().

        {
                return $this->randomRows;
        }

Here is the caller graph for this function:

SurveyMatrixQuestion::getRepeatColumnHeader (  ) 

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

Referenced by loadFromDb(), and saveToDb().

        {
                return $this->repeatColumnHeader;
        }

Here is the caller graph for this function:

SurveyMatrixQuestion::getRow ( a_index  ) 

Returns a specific row.

Returns a specific row

Parameters:
integer $a_index The 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(), and saveRowsToDb().

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

Here is the caller graph for this function:

SurveyMatrixQuestion::getRowImages (  ) 

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

Referenced by loadFromDb(), and saveToDb().

        {
                return $this->rowImages;
        }

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

Referenced by insertXML(), and saveToDb().

        {
                return $this->rowSeparators;
        }

Here is the caller graph for this function:

SurveyMatrixQuestion::getSingleLineRowCaption (  ) 

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

Referenced by loadFromDb(), and saveToDb().

        {
                return $this->singleLineRowCaption;
        }

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

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

        {
                return $this->subtype;
        }

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_id The 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 2095 of file class.SurveyMatrixQuestion.php.

References $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(DB_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 1326 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 2523 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 2542 of file class.SurveyMatrixQuestion.php.

References getNeutralColumn().

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

        {
                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 2275 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 2305 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 2330 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 2346 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_writer The XMLWriter object
boolean $a_include_header Determines wheather or not the XML should be used
string $obligatory_state The value of the obligatory state public

Definition at line 1048 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 704 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 $id The database id of the matrix question public

Reimplemented from SurveyQuestion.

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

References $data, SurveyQuestion::$id, 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 (strcmp(strtolower(get_class($result)), db_result) == 0) 
                {
      if ($result->numRows() == 1) 
                        {
                                $data = $result->fetchRow(DB_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->loadMaterialFromDb($id);

                        $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 (strcmp(strtolower(get_class($result)), db_result) == 0) 
                        {
        while ($data = $result->fetchRow(DB_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(DB_FETCHMODE_ASSOC))
                        {
                                $this->addRow($row["title"]);
                        }
    }
                parent::loadFromDb($id);
  }

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_id The database ID of the survey
string $type An 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 2403 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";
                        $nr_of_users = ilObjSurvey::_getNrOfParticipants($survey_id);
                        $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 $index The 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 $array An 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 $name The 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 $array An 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 878 of file class.SurveyMatrixQuestion.php.

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

References 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 $columntext The text of the column
Returns:
integer The database ID of the column public
See also:
$columns

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

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(DB_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_row The width in percent for the matrix rows
double $percent_columns The width in percent for the matrix columns
double $percent_bipolar_adjective1 The width in percent for the first bipolar adjective
double $percent_bipolar_adjective2 The width in percent for the second bipolar adjective
Returns:
void

Definition at line 2438 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 $phrases The database ids of the seleted phrases
string $title The title of the default phrase public

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

References 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::saveRowsToDb ( original_id = ""  ) 

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

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

References 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 ($result == DB_OK) 
                        {
                                $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 ($result == DB_OK) 
                {
                        // saving material uris in the database
                        $this->saveMaterialsToDb();
                        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 1417 of file class.SurveyMatrixQuestion.php.

References 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_index The number of the bipolar adjective (0 for the first and 1 for the second adjective)
string $a_value The 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 ( columnHeaderPosition  ) 

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

References $columnHeaderPosition.

        {
                $this->columnHeaderPosition = $columnHeaderPosition;
        }

SurveyMatrixQuestion::setColumnImages ( columnImages  ) 

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

References $columnImages.

        {
                $this->columnImages = $columnImages;
        }

SurveyMatrixQuestion::setColumnOrder ( columnOrder  ) 

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

References $columnOrder.

        {
                $this->columnOrder = $columnOrder;
        }

SurveyMatrixQuestion::setColumnPlaceholders ( columnplaceholders  ) 

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

Referenced by loadFromDb().

        {
                $this->columnPlaceholders = $columnplaceholders;
        }

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 $enable 1 if the separators should be enabled, 0 otherwise public

Definition at line 2168 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 $worksheet Reference to the excel worksheet
object $format_title Excel title format
object $format_bold Excel bold format
array $eval_data Cumulated evaluation data
integer $row Actual 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 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 $worksheet Reference to the excel worksheet
object $format_title Excel title format
object $format_bold Excel bold format
array $eval_data Cumulated evaluation data
integer $row Actual row in the worksheet
Returns:
integer The next row which should be used for the export public

Reimplemented from SurveyQuestion.

Definition at line 1740 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 $workbook Reference to the parent excel workbook
object $format_title Excel title format
object $format_bold Excel bold format
array $eval_data Cumulated evaluation data public

Reimplemented from SurveyQuestion.

Definition at line 1825 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 2504 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 ( legend  ) 

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

References $legend.

Referenced by loadFromDb().

        {
                $this->legend = $legend;
        }

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_text The 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 $enable 1 if the separator should be enabled, 0 otherwise public

Definition at line 2238 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 ( randomRows  ) 

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

References $randomRows.

        {
                $this->randomRows = $randomRows;
        }

SurveyMatrixQuestion::setRepeatColumnHeader ( repeatColumnHeader  ) 

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

References $repeatColumnHeader.

        {
                $this->repeatColumnHeader = $repeatColumnHeader;
        }

SurveyMatrixQuestion::setRowImages ( rowImages  ) 

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

References $rowImages.

        {
                $this->rowImages = $rowImages;
        }

SurveyMatrixQuestion::setRowSeparators ( enable = 0  ) 

Enables/Disables separators for the matrix rows.

Enables/Disables separators for the matrix rows

Parameters:
integer $enable 1 if the separators should be enabled, 0 otherwise public

Definition at line 2203 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 ( singleLineRowCaption  ) 

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

References $singleLineRowCaption.

        {
                $this->singleLineRowCaption = $singleLineRowCaption;
        }

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 2141 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 $title A title string to describe the question
string $description A description string to describe the question
string $author A string containing the name of the questions author
integer $owner A 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->SurveyQuestion($title, $description, $author, $questiontext, $owner);
                $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 1191 of file class.SurveyMatrixQuestion.php.

References 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 ($result == DB_OK) 
                        {
                                // sync columns
                                $this->saveColumnsToDb($this->original_id);
                                // sync rows
                                $this->saveRowsToDb($this->original_id);
                        }
                }
                parent::syncWithOriginal();
        }

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

References insertXML().

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

        {
                return FALSE;
        }


Field Documentation

SurveyMatrixQuestion::$bipolar_adjective1

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

SurveyMatrixQuestion::$bipolar_adjective2

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

SurveyMatrixQuestion::$columnHeaderPosition

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

Referenced by setColumnHeaderPosition().

SurveyMatrixQuestion::$columnImages

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

Referenced by setColumnImages().

SurveyMatrixQuestion::$columnOrder

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

Referenced by setColumnOrder().

SurveyMatrixQuestion::$columnPlaceholders

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

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.

SurveyMatrixQuestion::$layout

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

Referenced by saveLayout(), and setLayout().

SurveyMatrixQuestion::$legend

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

Referenced by setLegend().

SurveyMatrixQuestion::$neutralColumn

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

SurveyMatrixQuestion::$neutralColumnSeparator

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

SurveyMatrixQuestion::$randomRows

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

Referenced by setRandomRows().

SurveyMatrixQuestion::$repeatColumnHeader

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

Referenced by setRepeatColumnHeader().

SurveyMatrixQuestion::$rowImages

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

Referenced by setRowImages().

SurveyMatrixQuestion::$rows

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

SurveyMatrixQuestion::$rowSeparators

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

SurveyMatrixQuestion::$singleLineRowCaption

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

Referenced by setSingleLineRowCaption().

SurveyMatrixQuestion::$subtype

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


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