Public Member Functions | Data Fields

ilObjSurvey Class Reference

Inheritance diagram for ilObjSurvey:
Collaboration diagram for ilObjSurvey:

Public Member Functions

 ilObjSurvey ($a_id=0, $a_call_by_reference=true)
 Constructor public.
 create ($a_upload=false)
 create survey object
 createMetaData ()
 Create meta data entry.
 update ()
 update object data
 createReference ()
 creates reference for object
 read ($a_force_db=false)
 read object data from db into object
 addQuestion ($question_id)
 Adds a question to the survey.
 delete ()
 delete object and all related data
 deleteSurveyRecord ()
 Deletes the survey from the database.
 deleteAllUserData ()
 Deletes all user data of a survey.
 removeSelectedSurveyResults ($finished_ids)
 Deletes the user data of a given array of survey participants.
getSurveyParticipants ()
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event happend, each object may decide how it reacts.
 isComplete ()
 Returns true, if a survey is complete for use.
 _isComplete ($obj_id)
 Returns true, if a survey is complete for use.
_getGlobalSurveyData ($obj_id)
 Returns an array with data needed in the repository, personal desktop or courses.
 saveCompletionStatus ()
 Saves the completion status of the survey.
 duplicateQuestionForSurvey ($question_id)
 Takes a question and creates a copy of the question for use in the survey.
 insertQuestion ($question_id)
 Inserts a question in the survey and saves the relation to the database.
 insertQuestionblock ($questionblock_id)
 Inserts a questionblock in the survey and saves the relation to the database.
 getAllRTEContent ()
 Returns the content of all RTE enabled text areas in the test.
 cleanupMediaobjectUsage ()
 Cleans up the media objects for all text fields in a test which are using an RTE field.
 saveToDb ()
 Saves a survey object to a database.
 saveQuestionsToDb ()
 Saves the survey questions to the database.
 getAnonymousId ($id)
 Checks for an anomyous survey id in the database an returns the id.
 getQuestionGUI ($questiontype, $question_id)
 Returns a question gui object to a given questiontype and question id.
 getQuestionType ($question_id)
 Returns the question type of a question with a given id.
 getSurveyId ()
 Returns the survey database id.
 setAnonymize ($a_anonymize)
 set anonymize status
 getAnonymize ()
 get anonymize status
 isAccessibleWithoutCode ()
 Checks if the survey is accessable without a survey code.
 loadFromDb ()
 Loads a survey object from a database.
 loadQuestionsFromDb ()
 Loads the survey questions from the database.
 setStartDateEnabled ($enabled=false)
 Sets the enabled state of the start date.
 getStartDateEnabled ()
 Gets the enabled state of the start date.
 setEndDateEnabled ($enabled=false)
 Sets the enabled state of the end date.
 getEndDateEnabled ()
 Gets the enabled state of the end date.
 setAuthor ($author="")
 Sets the authors name.
 saveAuthorToMetadata ($a_author="")
 Saves an authors name into the lifecycle metadata if no lifecycle metadata exists.
 getAuthor ()
 Gets the authors name.
 getShowQuestionTitles ()
 Gets the status of the display_question_titles attribute.
 showQuestionTitles ()
 Sets the question titles visible during the query.
 hideQuestionTitles ()
 Sets the question titles hidden during the query.
 setInvitation ($invitation=0)
 Sets the invitation status.
 setInvitationMode ($invitation_mode=0)
 Sets the invitation mode.
 setInvitationAndMode ($invitation=0, $invitation_mode=0)
 Sets the invitation status and mode (a more performant solution if you change both).
 setIntroduction ($introduction="")
 Sets the introduction text.
 setOutro ($outro="")
 Sets the outro text.
 getInvitation ()
 Gets the invitation status.
 getInvitationMode ()
 Gets the invitation mode.
 getStatus ()
 Gets the survey status.
 isOnline ()
 Gets the survey status.
 isOffline ()
 Gets the survey status.
 setStatus ($status=STATUS_OFFLINE)
 Sets the survey status.
 getStartDate ()
 Gets the start date of the survey.
 canStartSurvey ($anonymous_id=NULL)
 Checks if the survey can be started.
 setStartDate ($start_date="")
 Sets the start date of the survey.
 getStartMonth ()
 Gets the start month of the survey.
 getStartDay ()
 Gets the start day of the survey.
 getStartYear ()
 Gets the start year of the survey.
 getEndDate ()
 Gets the end date of the survey.
 setEndDate ($end_date="")
 Sets the end date of the survey.
 getEndMonth ()
 Gets the end month of the survey.
 getEndDay ()
 Gets the end day of the survey.
 getEndYear ()
 Gets the end year of the survey.
 getEvaluationAccess ()
 Gets the learners evaluation access.
 setEvaluationAccess ($evaluation_access=EVALUATION_ACCESS_OFF)
 Sets the learners evaluation access.
 getIntroduction ()
 Gets the introduction text.
 getOutro ()
 Gets the outro text.
getExistingQuestions ()
 Gets the question id's of the questions which are already in the survey.
getQuestionpoolTitles ($could_be_offline=FALSE, $showPath=FALSE)
 Get the titles of all available survey question pools.
 moveUpQuestion ($question_id)
 Moves a question up in the list of survey questions.
 moveDownQuestion ($question_id)
 Moves a question down in the list of survey questions.
 moveUpQuestionblock ($questionblock_id)
 Moves a questionblock up in the list of survey questions.
 moveDownQuestionblock ($questionblock_id)
 Moves a questionblock down in the list of survey questions.
 moveQuestions ($move_questions, $target_index, $insert_mode)
 Move questions and/or questionblocks to another position.
 removeQuestion ($question_id)
 Remove a question from the survey.
 removeConstraintsConcerningQuestion ($question_id)
 Remove constraints concerning a question with a given question_id.
 removeQuestions ($remove_questions, $remove_questionblocks)
 Remove questions from the survey.
 unfoldQuestionblocks ($questionblocks)
 Unfolds question blocks of a question pool.
getQuestionblockTitles ()
 Returns the titles of all question blocks of the question pool.
getQuestionblockQuestions ($questionblock_id)
 Returns the question titles of all questions of a question block.
getQuestionblockQuestionIds ($questionblock_id)
 Returns the question id's of all questions of a question block.
 getQuestionblock ($questionblock_id)
 Returns the database row for a given question block.
 _getQuestionblock ($questionblock_id)
 Returns the database row for a given question block.
 _addQuestionblock ($title="", $owner=0)
 Adds a questionblock to the database.
 createQuestionblock ($title, $show_questiontext, $questions)
 Creates a question block for the survey.
 modifyQuestionblock ($questionblock_id, $title, $show_questiontext)
 Modifies a question block.
 deleteConstraints ($question_id)
 Deletes the constraints for a question.
 deleteConstraint ($constraint_id, $question_id)
 Deletes a constraint of a question.
getSurveyQuestions ($with_answers=false)
 Returns the survey questions and questionblocks in an array.
getQuestiontypes ()
 Returns an array with all existing question types.
 setObligatoryStates ($obligatory_questions)
 Sets the obligatory states for questions in a survey from the questions form.
getObligatoryStates ()
 Gets specific obligatory states of the survey.
getSurveyPages ()
 Returns the survey pages in an array (a page contains one or more questions).
 getNextPage ($active_page_question_id, $direction)
 Returns the next "page" of a running test.
getAvailableQuestionpools ($use_obj_id=false, $could_be_offline=false, $showPath=FALSE, $permission="read")
 Returns the available question pools for the active user.
 getPrecondition ($id)
 Returns a precondition with a given id.
 getConstraints ($question_id)
 Returns the constraints to a given question or questionblock.
 _getConstraints ($survey_id)
 Returns the constraints to a given question or questionblock.
getVariables ($question_id)
 Returns all variables of a question.
 addConstraint ($to_question_id, $if_question_id, $relation, $value)
 Adds a constraint to a question.
 updateConstraint ($to_question_id, $if_question_id, $relation, $value)
 Updates a precondition.
 getAllRelations ($short_as_key=false)
 Returns all available relations.
 disinviteUser ($user_id)
 Disinvites a user from a survey.
 inviteUser ($user_id)
 Invites a user to a survey.
 inviteGroup ($group_id)
 Invites a group to a survey.
 inviteRole ($role_id)
 Invites a role to a survey.
getInvitedUsers ()
 Returns a list of all invited users in a survey.
getInvitedGroups ()
 Returns a list of all invited groups in a survey.
 deleteWorkingData ($question_id, $active_id)
 Deletes the working data of a question in the database.
 loadWorkingData ($question_id, $active_id)
 Gets the working data of question from the database.
 startSurvey ($user_id, $anonymous_id)
 Starts the survey creating an entry in the database.
 finishSurvey ($user_id, $anonymize_id)
 Finishes the survey creating an entry in the database.
 isAllowedToTakeMultipleSurveys ($userid="")
 Checks if a user is allowed to take multiple survey.
 isSurveyStarted ($user_id, $anonymize_id)
 Checks if a user already started a survey.
 getLastActivePage ($active_id)
 Returns the question id of the last active page a user visited in a survey.
 checkConstraint ($constraint_data, $working_data)
 Checks if a constraint is valid.
 _hasDatasets ($survey_id)
getEvaluationForAllUsers ()
getUserSpecificResults ()
 Calculates the evaluation data for the user specific results.
 getUserDataFromActiveId ($active_id)
 Returns the user information from an active_id (survey_finished.finished_id).
getEvaluationByUser ($questions, $active_id)
 Calculates the evaluation data for a given user or anonymous id.
 getCumulatedResults (&$question)
 Calculates the evaluation data for a question.
 _getNrOfParticipants ($survey_id)
 Returns the number of participants for a survey.
getQuestions ($question_ids)
getQuestionblocks ($questionblock_ids)
 getQuestionsTable ($sort, $sortorder, $filter_text, $sel_filter_type, $startrow=0, $completeonly=0, $filter_question_type="", $filter_questionpool="")
 Calculates the data for the output of the question browser.
 getQuestionblocksTable ($sort, $sortorder, $filter_text, $sel_filter_type, $startrow=0)
 Calculates the data for the output of the questionblock browser.
_getQuestiontypes ()
 Creates a list of all available question types.
 toXML ()
 Returns a QTI xml representation of the survey.
_instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id.
 locateImportFiles ($a_dir)
 Locates the import directory and the xml file in a directory with an unzipped import file.
 importObject ($file_info, $survey_questionpool_id)
 Imports a survey from XML into the ILIAS database.
_getAvailableSurveys ($use_object_id=false)
 Returns the available surveys for the active user.
 cloneObject ($a_target_id, $a_copy_id=0)
 Clone object.
 getTextblock ($question_id)
 cloneTextblocks ($mapping)
 Clones the textblocks of survey questions.
 createExportDirectory ()
 creates data directory for export files (data_dir/svy_data/svy_<id>/export, depending on data directory that is set in ILIAS setup/ini)
 getExportDirectory ()
 get export directory of survey
 getExportFiles ($dir)
 get export files
 createImportDirectory ()
 creates data directory for import files (data_dir/svy_data/svy_<id>/import, depending on data directory that is set in ILIAS setup/ini)
 getImportDirectory ()
 get import directory of survey
 saveHeading ($heading="", $insertbefore)
 _getRefIdFromObjId ($obj_id)
 isAnonymousKey ($key)
 getUserSurveyCode ($user_id)
 isAnonymizedParticipant ($key)
 checkSurveyCode ($code)
 getSurveyCodesCount ()
 Returns the number of generated survey codes for the survey.
 getSurveyCodesForExport ($a_array)
 Returns a list of survey codes for file export.
getSurveyCodesTableData ($lang="en", $offset=0, $limit=10)
 Fetches the data for the survey codes table.
 isSurveyCodeUsed ($code)
 createSurveyCodes ($nrOfCodes)
 deleteSurveyCode ($survey_code)
 Deletes a given survey access code.
 getUserAccessCode ($user_id)
 Returns a survey access code that was saved for a registered user.
 saveUserAccessCode ($user_id, $access_code)
 Saves a survey access code for a registered user to the database.
 createNewAccessCode ()
 Returns a new, unused survey access code.
processCSVRow ($row, $quoteAll=FALSE, $separator=";")
 Convertes an array for CSV usage.
 _getLastAccess ($finished_id)
 prepareTextareaOutput ($txt_output)
 Prepares a string for a text area output in surveys.
 isHTML ($a_text)
 Checks if a given string contains HTML or not.
 addMaterialTag (&$a_xml_writer, $a_material, $close_material_tag=TRUE, $add_mobs=TRUE, $attribs=NULL)
 Creates an XML material tag from a plain text or xhtml text.
 canExportSurveyCode ()
 Checks if the survey code can be exported with the survey evaluation.
 processPrintoutput2FO ($print_output)
 Convert a print output to XSL-FO.
 deliverPDFfromFO ($fo)
 Delivers a PDF file from a XSL-FO string.
 _checkCondition ($a_svy_id, $a_operator, $a_value)

Data Fields

 $survey_id
 $author
 $introduction
 $outro
 $status
 $evaluation_access
 $start_date
 $startdate_enabled
 $end_date
 $enddate_enabled
 $questions
 $invitation
 $invitation_mode
 $anonymize
 $display_question_titles
 $surveyCodeSecurity

Detailed Description

Definition at line 37 of file class.ilObjSurvey.php.


Member Function Documentation

ilObjSurvey::_addQuestionblock ( title = "",
owner = 0 
)

Adds a questionblock to the database.

Adds a questionblock to the database

Parameters:
string $title The questionblock title
integer $owner The database id of the owner
Returns:
integer The database id of the newly created questionblock public

Definition at line 2342 of file class.ilObjSurvey.php.

References ilObject::$owner, and ilObject::$title.

Referenced by cloneObject().

        {
                global $ilDB;
                $query = sprintf("INSERT INTO survey_questionblock (questionblock_id, title, owner_fi, TIMESTAMP) VALUES (NULL, %s, %s, NULL)",
                        $ilDB->quote($title . ""),
                        $ilDB->quote($owner . "")
                );
                $result = $ilDB->query($query);
                return $ilDB->getLastInsertId();
        }

Here is the caller graph for this function:

ilObjSurvey::_checkCondition ( a_svy_id,
a_operator,
a_value 
)

Definition at line 5273 of file class.ilObjSurvey.php.

References ilObjSurveyAccess::_lookupFinished().

        {
                global $ilUser;

                switch($a_operator)
                {
                        case 'finished':
                                //if (ilExerciseMembers::_lookupStatus($a_exc_id, $ilias->account->getId()) == "passed")
                                include_once("./Modules/Survey/classes/class.ilObjSurveyAccess.php");
                                if (ilObjSurveyAccess::_lookupFinished($a_svy_id, $ilUser->getId()))
                                {
                                        return true;
                                }
                                else
                                {
                                        return false;
                                }
                                break;

                        default:
                                return true;
                }
                return true;
        }

Here is the call graph for this function:

& ilObjSurvey::_getAvailableSurveys ( use_object_id = false  ) 

Returns the available surveys for the active user.

Returns the available surveys for the active user

Returns:
array The available surveys public

Definition at line 4387 of file class.ilObjSurvey.php.

References ilUtil::_getObjectsByOperations(), and ilObject::_prepareCloneSelection().

        {
                global $ilUser;
                global $ilDB;

                $result_array = array();
                $surveys = ilUtil::_getObjectsByOperations("svy","write", $ilUser->getId(), -1);
                if (count($surveys))
                {
                        $titles = ilObject::_prepareCloneSelection($surveys, "svy");
                        $query = sprintf("SELECT object_data.*, object_reference.ref_id FROM object_data, object_reference WHERE object_data.obj_id = object_reference.obj_id AND object_reference.ref_id IN ('%s') ORDER BY object_data.title",
                                implode("','", $surveys)
                        );
                        $result = $ilDB->query($query);
                        while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                if ($use_object_id)
                                {
                                        $result_array[$row["obj_id"]] = $titles[$row["ref_id"]];
                                }
                                else
                                {
                                        $result_array[$row["ref_id"]] = $titles[$row["ref_id"]];
                                }
                        }
                }
                return $result_array;
        }       

Here is the call graph for this function:

ilObjSurvey::_getConstraints ( survey_id  ) 

Returns the constraints to a given question or questionblock.

Returns the constraints to a given question or questionblock

public

Definition at line 2853 of file class.ilObjSurvey.php.

References $survey_id.

Referenced by cloneObject().

        {
                global $ilDB;
                $result_array = array();
                $query = sprintf("SELECT survey_question_constraint.question_fi as for_question, survey_constraint.*, survey_relation.* FROM survey_question_constraint, survey_constraint, survey_relation WHERE survey_constraint.relation_fi = survey_relation.relation_id AND survey_question_constraint.constraint_fi = survey_constraint.constraint_id AND survey_question_constraint.survey_fi = %s",
                        $ilDB->quote($survey_id . "")
                );
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {               
                        array_push($result_array, array("id" => $row->constraint_id, "for_question" => $row->for_question, "question" => $row->question_fi, "short" => $row->shortname, "long" => $row->longname, "relation_id" => $row->relation_id, "value" => $row->value));
                }
                return $result_array;
        }

Here is the caller graph for this function:

& ilObjSurvey::_getGlobalSurveyData ( obj_id  ) 

Returns an array with data needed in the repository, personal desktop or courses.

Returns an array with data needed in the repository, personal desktop or courses

Returns:
array resulting array public

Definition at line 580 of file class.ilObjSurvey.php.

References ilObjSurvey().

        {
                $survey = new ilObjSurvey($obj_id, false);
                $survey->loadFromDb();
                $result = array();
                if (($survey->getTitle()) and ($survey->author) and (count($survey->questions)))
                {
                        $result["complete"] = true;
                } 
                        else 
                {
                        $result["complete"] = false;
                }
                $result["evaluation_access"] = $survey->getEvaluationAccess();
                return $result;
        }

Here is the call graph for this function:

ilObjSurvey::_getLastAccess ( finished_id  ) 

Definition at line 5106 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                
                $query = sprintf("SELECT TIMESTAMP+0 AS TIMESTAMP14 FROM survey_answer WHERE active_fi = %s ORDER BY TIMESTAMP DESC",
                        $ilDB->quote($finished_id . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        return $row["TIMESTAMP14"];
                }
                else
                {
                        $query = sprintf("SELECT TIMESTAMP+0 AS TIMESTAMP14 FROM survey_finished WHERE finished_id = %s",
                                $ilDB->quote($finished_id . "")
                        );
                        $result = $ilDB->query($query);
                        if ($result->numRows())
                        {
                                $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                                return $row["TIMESTAMP14"];
                        }
                }
                return "";
        }

ilObjSurvey::_getNrOfParticipants ( survey_id  ) 

Returns the number of participants for a survey.

Returns the number of participants for a survey

Parameters:
integer $survey_id The database ID of the survey
Returns:
integer The number of participants public

Definition at line 3689 of file class.ilObjSurvey.php.

References $survey_id.

Referenced by SurveyTextQuestionGUI::getCumulatedResultRow(), SurveyOrdinalQuestionGUI::getCumulatedResultRow(), SurveyNominalQuestionGUI::getCumulatedResultRow(), SurveyMetricQuestionGUI::getCumulatedResultRow(), SurveyMatrixQuestionGUI::getCumulatedResultRow(), SurveyTextQuestionGUI::getCumulatedResultsDetails(), SurveyOrdinalQuestionGUI::getCumulatedResultsDetails(), SurveyNominalQuestionGUI::getCumulatedResultsDetails(), SurveyMetricQuestionGUI::getCumulatedResultsDetails(), SurveyMatrixQuestionGUI::getCumulatedResultsDetails(), SurveyOrdinalQuestion::outChart(), SurveyNominalQuestion::outChart(), SurveyMetricQuestion::outChart(), and SurveyMatrixQuestion::outChart().

        {
                global $ilDB;
                
                $query = sprintf("SELECT finished_id FROM survey_finished WHERE survey_fi = %s",
                        $ilDB->quote($survey_id . "")
                );
                $result = $ilDB->query($query);
                return $result->numRows();
        }

Here is the caller graph for this function:

ilObjSurvey::_getQuestionblock ( questionblock_id  ) 

Returns the database row for a given question block.

Returns the database row for a given question block

Parameters:
integer $questionblock_id The database id of the question block
Returns:
array The database row of the question block public

Definition at line 2321 of file class.ilObjSurvey.php.

Referenced by cloneObject().

        {
                global $ilDB;
                $query = sprintf("SELECT * FROM survey_questionblock WHERE questionblock_id = %s",
                        $ilDB->quote($questionblock_id)
                );
                $result = $ilDB->query($query);
                $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                return $row;
        }

Here is the caller graph for this function:

& ilObjSurvey::_getQuestiontypes (  ) 

Creates a list of all available question types.

Creates a list of all available question types

Returns:
array An array containing the available questiontypes public

Definition at line 3985 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                
                $questiontypes = array();
                $query = "SELECT * FROM survey_questiontype ORDER BY type_tag";
                $query_result = $ilDB->query($query);
                while ($row = $query_result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        array_push($questiontypes, $row["type_tag"]);
                }
                return $questiontypes;
        }

ilObjSurvey::_getRefIdFromObjId ( obj_id  ) 

Definition at line 4718 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                
                $query = sprintf("SELECT ref_id FROM object_reference WHERE obj_id=%s",
                        $ilDB->quote($obj_id)
                        
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        return $row["ref_id"];
                }
                return 0;
        }

ilObjSurvey::_hasDatasets ( survey_id  ) 

Definition at line 3473 of file class.ilObjSurvey.php.

References $survey_id.

        {
                global $ilDB;
                
                $query = sprintf("SELECT finished_id FROM survey_finished WHERE survey_fi = %s",
                        $ilDB->quote($survey_id . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        return true;
                }
                else
                {
                        return false;
                }
        }

& ilObjSurvey::_instanciateQuestion ( question_id  ) 

Creates an instance of a question with a given question id.

Creates an instance of a question with a given question id

Parameters:
integer $question_id The question id
Returns:
object The question instance public

Definition at line 4185 of file class.ilObjSurvey.php.

References SurveyQuestion::_getQuestionType().

Referenced by cloneObject(), getSurveyQuestions(), removeQuestion(), and toXML().

        {
                if ($question_id < 1) return FALSE;
                include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                $question_type = SurveyQuestion::_getQuestionType($question_id);
                if (strlen($question_type) == 0) return FALSE;
                include_once "./Modules/SurveyQuestionPool/classes/class.$question_type.php";
                $question = new $question_type();
                $question->loadFromDb($question_id);
                return $question;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::_isComplete ( obj_id  ) 

Returns true, if a survey is complete for use.

Returns true, if a survey is complete for use

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

Definition at line 558 of file class.ilObjSurvey.php.

References ilObjSurvey().

        {
                $survey = new ilObjSurvey($obj_id, false);
                $survey->loadFromDb();
                if (($survey->getTitle()) and ($survey->getAuthor()) and (count($survey->questions)))
                {
                        return true;
                } 
                        else 
                {
                        return false;
                }
        }

Here is the call graph for this function:

ilObjSurvey::addConstraint ( to_question_id,
if_question_id,
relation,
value 
)

Adds a constraint to a question.

Adds a constraint to a question

Parameters:
integer $to_question_id The question id of the question where to add the constraint
integer $if_question_id The question id of the question which defines a precondition
integer $relation The database id of the relation
mixed $value The value compared with the relation public

Definition at line 2903 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                
                $query = sprintf("INSERT INTO survey_constraint (constraint_id, question_fi, relation_fi, value) VALUES (NULL, %s, %s, %s)",
                        $ilDB->quote($if_question_id),
                        $ilDB->quote($relation),
                        $ilDB->quote($value)
                );
                $result = $ilDB->query($query);
                if ($result == DB_OK) {
                        $constraint_id = $ilDB->getLastInsertId();
                        $query = sprintf("INSERT INTO survey_question_constraint (question_constraint_id, survey_fi, question_fi, constraint_fi) VALUES (NULL, %s, %s, %s)",
                                $ilDB->quote($this->getSurveyId()),
                                $ilDB->quote($to_question_id),
                                $ilDB->quote($constraint_id)
                        );
                        $result = $ilDB->query($query);
                }
        }

ilObjSurvey::addMaterialTag ( &$  a_xml_writer,
a_material,
close_material_tag = TRUE,
add_mobs = TRUE,
attribs = NULL 
)

Creates an XML material tag from a plain text or xhtml text.

Parameters:
object $a_xml_writer Reference to the ILIAS XML writer
string $a_material plain text or html text containing the material
Returns:
string XML material tag public

Definition at line 5173 of file class.ilObjSurvey.php.

References $mobs, ilObjMediaObject::_getMobsOfObject(), ilRTE::_replaceMediaObjectImageSrc(), ilObject::getId(), and isHTML().

Referenced by toXML().

        {
                include_once "./Services/RTE/classes/class.ilRTE.php";
                include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");

                $a_xml_writer->xmlStartTag("material", $attribs);
                $attrs = array(
                        "type" => "text/plain"
                );
                if ($this->isHTML($a_material))
                {
                        $attrs["type"] = "text/xhtml";
                }
                $mattext = ilRTE::_replaceMediaObjectImageSrc($a_material, 0);
                $a_xml_writer->xmlElement("mattext", $attrs, $mattext);

                if ($add_mobs)
                {
                        $mobs = ilObjMediaObject::_getMobsOfObject("svy:html", $this->getId());
                        foreach ($mobs as $mob)
                        {
                                $mob_id = "il_" . IL_INST_ID . "_mob_" . $mob;
                                if (strpos($mattext, $mob_id) !== FALSE)
                                {
                                        $mob_obj =& new ilObjMediaObject($mob);
                                        $imgattrs = array(
                                                "label" => $mob_id,
                                                "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle()
                                        );
                                        $a_xml_writer->xmlElement("matimage", $imgattrs, NULL);
                                }
                        }
                }               
                if ($close_material_tag) $a_xml_writer->xmlEndTag("material");
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::addQuestion ( question_id  ) 

Adds a question to the survey.

Parameters:
integer $question_id The question id of the question public

Definition at line 278 of file class.ilObjSurvey.php.

        {
                array_push($this->questions, $question_id);
        }

ilObjSurvey::canExportSurveyCode (  ) 

Checks if the survey code can be exported with the survey evaluation.

In some cases this may be necessary but usually you should prevent it because people who sent the survey codes could connect real people with the survey code in the evaluation and undermine the anonymity

Returns:
boolean TRUE if the survey is anonymized and the survey code may be shown in the export file
Author:
Helmut Schottmüller

Definition at line 5217 of file class.ilObjSurvey.php.

References getAnonymize().

        {
                if ($this->getAnonymize() != ANONYMIZE_OFF)
                {
                        if ($this->surveyCodeSecurity == FALSE)
                        {
                                return TRUE;
                        }
                }
                return FALSE;
        }

Here is the call graph for this function:

ilObjSurvey::canStartSurvey ( anonymous_id = NULL  ) 

Checks if the survey can be started.

Checks if the survey can be started

Returns:
array An array containing the following keys: result (boolean) and messages (array) public

Definition at line 1584 of file class.ilObjSurvey.php.

References ilFormat::ftimestamp2dateDB(), getEndDateEnabled(), getEndDay(), getEndMonth(), getEndYear(), getStartDateEnabled(), getStartDay(), getStartMonth(), getStartYear(), getStatus(), and isSurveyStarted().

        {
                global $ilAccess;
                
                $result = TRUE;
                $messages = array();
                // check start date
                if ($this->getStartDateEnabled())
                {
                        $epoch_time = mktime(0, 0, 0, $this->getStartMonth(), $this->getStartDay(), $this->getStartYear());
                        $now = mktime();
                        if ($now < $epoch_time) 
                        {
                                array_push($messages, $this->lng->txt("start_date_not_reached") . " (".ilFormat::formatDate(ilFormat::ftimestamp2dateDB($this->getStartYear().$this->getStartMonth().$this->getStartDay()."000000"), "date") . ")");
                                $result = FALSE;
                        }
                }
                // check end date
                if ($this->getEndDateEnabled())
                {
                        $epoch_time = mktime(0, 0, 0, $this->getEndMonth(), $this->getEndDay(), $this->getEndYear());
                        $now = mktime();
                        if ($now > $epoch_time) 
                        {
                                array_push($messages, $this->lng->txt("end_date_reached") . " (".ilFormat::formatDate(ilFormat::ftimestamp2dateDB($this->getEndYear().$this->getEndMonth().$this->getEndDay()."000000"), "date") . ")");
                                $result = FALSE;
                        }
                }
                // check online status
                if ($this->getStatus() == STATUS_OFFLINE)
                {
                        array_push($messages, $this->lng->txt("survey_is_offline"));
                        $result = FALSE;
                }
                // check rbac permissions
                if (!$ilAccess->checkAccess("read", "", $this->ref_id))
                {
                        array_push($messages, $this->lng->txt("cannot_participate_survey"));
                        $result = FALSE;
                }
                // 2. check previous access
                if (!$result["error"])
                {
                        global $ilUser;
                        $survey_started = $this->isSurveyStarted($ilUser->getId(), $anonymous_id);
                        if ($survey_started === 1)
                        {
                                array_push($messages, $this->lng->txt("already_completed_survey"));
                                $result = FALSE;
                        }
                }
                return array(
                        "result" => $result,
                        "messages" => $messages
                );
        }

Here is the call graph for this function:

ilObjSurvey::checkConstraint ( constraint_data,
working_data 
)

Checks if a constraint is valid.

Checks if a constraint is valid

Parameters:
array $constraint_data The database row containing the constraint data
array $working_data The user input of the related question
Returns:
boolean true if the constraint is valid, otherwise false public

Definition at line 3416 of file class.ilObjSurvey.php.

References $data.

        {
                if (count($working_data) == 0)
                {
                        return 0;
                }
                
                if ((count($working_data) == 1) and (strcmp($working_data[0]["value"], "") == 0))
                {
                        return 0;
                }
                
                foreach ($working_data as $data)
                {
                        switch ($constraint_data["short"])
                        {
                                case "<":
                                        if ($data["value"] < $constraint_data["value"])
                                        {
                                                return 1;
                                        }
                                        break;
                                case "<=":
                                        if ($data["value"] <= $constraint_data["value"])
                                        {
                                                return 1;
                                        }
                                        break;
                                case "=":
                                        if ($data["value"] == $constraint_data["value"])
                                        {
                                                return 1;
                                        }
                                        break;
                                case "<>":
                                        if ($data["value"] != $constraint_data["value"])
                                        {
                                                return 1;
                                        }
                                        break;
                                case ">=":
                                        if ($data["value"] >= $constraint_data["value"])
                                        {
                                                return 1;
                                        }
                                        break;
                                case ">":
                                        if ($data["value"] > $constraint_data["value"])
                                        {
                                                return 1;
                                        }
                                        break;
                        }
                }
                return 0;
        }

ilObjSurvey::checkSurveyCode ( code  ) 

Definition at line 4794 of file class.ilObjSurvey.php.

References isAnonymousKey(), and isSurveyStarted().

        {
                if ($this->isAnonymousKey($code))
                {
                        if ($this->isSurveyStarted("", $code) == 1)
                        {
                                return false;
                        }
                        else
                        {
                                return true;
                        }
                }
                else
                {
                        return false;
                }
        }

Here is the call graph for this function:

ilObjSurvey::cleanupMediaobjectUsage (  ) 

Cleans up the media objects for all text fields in a test which are using an RTE field.

Cleans up the media objects for all text fields in a test which are using an RTE field

private

Definition at line 732 of file class.ilObjSurvey.php.

References ilRTE::_cleanupMediaObjectUsage(), getAllRTEContent(), ilObject::getId(), and ilObject::getType().

Referenced by saveToDb().

        {
                include_once("./Services/RTE/classes/class.ilRTE.php");
                $completecontent = "";
                foreach ($this->getAllRTEContent() as $content)
                {
                        $completecontent .= $content;
                }
                ilRTE::_cleanupMediaObjectUsage($completecontent, $this->getType() . ":html",
                        $this->getId());
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::cloneObject ( a_target_id,
a_copy_id = 0 
)

Clone object.

public

Parameters:
int ref_id of target container
int copy id
Returns:
object new svy object

Reimplemented from ilObject.

Definition at line 4424 of file class.ilObjSurvey.php.

References _addQuestionblock(), _getConstraints(), SurveyQuestion::_getOriginalId(), _getQuestionblock(), _instanciateQuestion(), ilObject::cloneMetaData(), getAnonymize(), getAuthor(), getEndDate(), getEndDateEnabled(), getEvaluationAccess(), getIntroduction(), getInvitation(), getInvitationMode(), getOutro(), getStartDate(), getStartDateEnabled(), getStatus(), getSurveyId(), and loadFromDb().

        {
                global $ilDB;
                
                $this->loadFromDb();
                
                // Copy settings
                $newObj = parent::cloneObject($a_target_id,$a_copy_id);
                $this->cloneMetaData($newObj);
                
                $newObj->author = $this->getAuthor();
                $newObj->introduction = $this->getIntroduction();
                $newObj->outro = $this->getOutro();
                $newObj->status = $this->getStatus();
                $newObj->evaluation_access = $this->getEvaluationAccess();
                $newObj->start_date = $this->getStartDate();
                $newObj->startdate_enabled = $this->getStartDateEnabled();
                $newObj->end_date = $this->getEndDate();
                $newObj->enddate_enabled = $this->getEndDateEnabled();
                $newObj->invitation = $this->getInvitation();
                $newObj->invitation_mode = $this->getInvitationMode();
                $newObj->anonymize = $this->getAnonymize();

                $question_pointer = array();
                // clone the questions
                $mapping = array();
                include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                foreach ($this->questions as $key => $question_id)
                {
                        $question = ilObjSurvey::_instanciateQuestion($question_id);
                        $question->id = -1;
                        $original_id = SurveyQuestion::_getOriginalId($question_id);
                        $question->saveToDb($original_id);
                        $newObj->questions[$key] = $question->getId();
                        $question_pointer[$question_id] = $question->getId();
                        $mapping[$question_id] = $question->getId();
                }

                $newObj->saveToDb();            
                $newObj->cloneTextblocks($mapping);

                // clone the questionblocks
                $questionblocks = array();
                $questionblock_questions = array();
                $query = sprintf("SELECT * FROM survey_questionblock_question WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId() . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows() > 0)
                {
                        while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                array_push($questionblock_questions, $row);
                                $questionblocks[$row["questionblock_fi"]] = $row["questionblock_fi"];
                        }
                }
                // create new questionblocks
                foreach ($questionblocks as $key => $value)
                {
                        $questionblock = ilObjSurvey::_getQuestionblock($key);
                        $questionblock_id = ilObjSurvey::_addQuestionblock($questionblock["title"], $questionblock["owner_fi"]);
                        $questionblocks[$key] = $questionblock_id;
                }
                // create new questionblock questions
                foreach ($questionblock_questions as $key => $value)
                {
                        $clonequery = sprintf("INSERT INTO survey_questionblock_question (questionblock_question_id, survey_fi, questionblock_fi, question_fi) VALUES (NULL, %s, %s, %s)",
                                $ilDB->quote($newObj->getSurveyId() . ""),
                                $ilDB->quote($questionblocks[$value["questionblock_fi"]] . ""),
                                $ilDB->quote($question_pointer[$value["question_fi"]] . "")
                        );
                        $cloneresult = $ilDB->query($clonequery);
                }
                
                // clone the constraints
                $constraints = ilObjSurvey::_getConstraints($this->getSurveyId());
                foreach ($constraints as $key => $constraint)
                {
                        $newObj->addConstraint($question_pointer[$constraint["for_question"]], $question_pointer[$constraint["question"]], $constraint["relation_id"], $constraint["value"]);
                }
                
                // clone the obligatory states
                $query = sprintf("SELECT * FROM survey_question_obligatory WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId() . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows() > 0)
                {
                        while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                $clonequery = sprintf("INSERT INTO survey_question_obligatory (question_obligatory_id, survey_fi, question_fi, obligatory, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)",
                                        $ilDB->quote($newObj->getSurveyId() . ""),
                                        $ilDB->quote($question_pointer[$row["question_fi"]] . ""),
                                        $ilDB->quote($row["obligatory"])
                                );
                                $cloneresult = $ilDB->query($clonequery);
                        }
                }
                return $newObj;
        }

Here is the call graph for this function:

ilObjSurvey::cloneTextblocks ( mapping  ) 

Clones the textblocks of survey questions.

Clones the textblocks of survey questions

public

Definition at line 4550 of file class.ilObjSurvey.php.

References ilObjAdvancedEditing::_getUsedHTMLTagsAsString(), getTextblock(), saveHeading(), and ilUtil::stripSlashes().

        {
                foreach ($mapping as $original_id => $new_id)
                {
                        $textblock = $this->getTextblock($original_id);
                        include_once "./classes/class.ilObjAdvancedEditing.php";
                        $this->saveHeading(ilUtil::stripSlashes($textblock, TRUE, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey")), $new_id);
                }
        }

Here is the call graph for this function:

ilObjSurvey::create ( a_upload = false  ) 

create survey object

Definition at line 212 of file class.ilObjSurvey.php.

References ilObject::create(), and createMetaData().

        {
                parent::create();
                if(!$a_upload)
                {
                        $this->createMetaData();
                }
        }

Here is the call graph for this function:

ilObjSurvey::createExportDirectory (  ) 

creates data directory for export files (data_dir/svy_data/svy_<id>/export, depending on data directory that is set in ILIAS setup/ini)

Definition at line 4565 of file class.ilObjSurvey.php.

References ilUtil::getDataDir(), ilObject::getId(), and ilUtil::makeDir().

        {
                include_once "./Services/Utilities/classes/class.ilUtil.php";
                $svy_data_dir = ilUtil::getDataDir()."/svy_data";
                ilUtil::makeDir($svy_data_dir);
                if(!is_writable($svy_data_dir))
                {
                        $this->ilias->raiseError("Survey Data Directory (".$svy_data_dir
                                .") not writeable.",$this->ilias->error_obj->FATAL);
                }
                
                // create learning module directory (data_dir/lm_data/lm_<id>)
                $svy_dir = $svy_data_dir."/svy_".$this->getId();
                ilUtil::makeDir($svy_dir);
                if(!@is_dir($svy_dir))
                {
                        $this->ilias->raiseError("Creation of Survey Directory failed.",$this->ilias->error_obj->FATAL);
                }
                // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
                $export_dir = $svy_dir."/export";
                ilUtil::makeDir($export_dir);
                if(!@is_dir($export_dir))
                {
                        $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
                }
        }

Here is the call graph for this function:

ilObjSurvey::createImportDirectory (  ) 

creates data directory for import files (data_dir/svy_data/svy_<id>/import, depending on data directory that is set in ILIAS setup/ini)

Definition at line 4646 of file class.ilObjSurvey.php.

References ilUtil::getDataDir(), ilObject::getId(), and ilUtil::makeDir().

        {
                include_once "./Services/Utilities/classes/class.ilUtil.php";
                $svy_data_dir = ilUtil::getDataDir()."/svy_data";
                ilUtil::makeDir($svy_data_dir);
                
                if(!is_writable($svy_data_dir))
                {
                        $this->ilias->raiseError("Survey Data Directory (".$svy_data_dir
                                .") not writeable.",$this->ilias->error_obj->FATAL);
                }

                // create test directory (data_dir/svy_data/svy_<id>)
                $svy_dir = $svy_data_dir."/svy_".$this->getId();
                ilUtil::makeDir($svy_dir);
                if(!@is_dir($svy_dir))
                {
                        $this->ilias->raiseError("Creation of Survey Directory failed.",$this->ilias->error_obj->FATAL);
                }

                // create import subdirectory (data_dir/svy_data/svy_<id>/import)
                $import_dir = $svy_dir."/import";
                ilUtil::makeDir($import_dir);
                if(!@is_dir($import_dir))
                {
                        $this->ilias->raiseError("Creation of Import Directory failed.",$this->ilias->error_obj->FATAL);
                }
        }

Here is the call graph for this function:

ilObjSurvey::createMetaData (  ) 

Create meta data entry.

Create meta data entry

public

Reimplemented from ilObject.

Definition at line 228 of file class.ilObjSurvey.php.

References saveAuthorToMetadata().

Referenced by create().

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::createNewAccessCode (  ) 

Returns a new, unused survey access code.

Returns:
string A new survey access code

Definition at line 5041 of file class.ilObjSurvey.php.

References isSurveyCodeUsed().

Referenced by createSurveyCodes().

        {
                // create a 5 character code
                $codestring = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
                mt_srand();
                $code = "";
                for ($i = 1; $i <=5; $i++)
                {
                        $index = mt_rand(0, strlen($codestring)-1);
                        $code .= substr($codestring, $index, 1);
                }
                // verify it against the database
                while ($this->isSurveyCodeUsed($code))
                {
                        $code = $this->createNewAccessCode();
                }
                return $code;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::createQuestionblock ( title,
show_questiontext,
questions 
)

Creates a question block for the survey.

Creates a question block for the survey

Parameters:
string $title The title of the question block
array $questions An array with the database id's of the question block questions public

Definition at line 2362 of file class.ilObjSurvey.php.

References $questions, ilObject::$title, deleteConstraints(), and moveQuestions().

Referenced by insertQuestionblock().

        {
                global $ilDB;
                // if the selected questions are not in a continous selection, move all questions of the
                // questionblock at the position of the first selected question
                $this->moveQuestions($questions, $questions[0], 0);
                
                // now save the question block
                global $ilUser;
                $query = sprintf("INSERT INTO survey_questionblock (questionblock_id, title, show_questiontext, owner_fi, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)",
                        $ilDB->quote($title),
                        $ilDB->quote($show_questiontext . ""),
                        $ilDB->quote($ilUser->getId())
                );
                $result = $ilDB->query($query);
                if ($result == DB_OK) {
                        $questionblock_id = $ilDB->getLastInsertId();
                        foreach ($questions as $index)
                        {
                                $query = sprintf("INSERT INTO survey_questionblock_question (questionblock_question_id, survey_fi, questionblock_fi, question_fi) VALUES (NULL, %s, %s, %s)",
                                        $ilDB->quote($this->getSurveyId()),
                                        $ilDB->quote($questionblock_id),
                                        $ilDB->quote($index)
                                );
                                $result = $ilDB->query($query);
                                $this->deleteConstraints($index);
                        }
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::createReference (  ) 

creates reference for object

public

Returns:
integer reference_id of object

Reimplemented from ilObject.

Definition at line 254 of file class.ilObjSurvey.php.

References saveToDb().

        {
                $result = parent::createReference();
                $this->saveToDb();
                return $result;
        }

Here is the call graph for this function:

ilObjSurvey::createSurveyCodes ( nrOfCodes  ) 

Definition at line 4957 of file class.ilObjSurvey.php.

References createNewAccessCode(), and getSurveyId().

        {
                global $ilDB;
                for ($i = 0; $i < $nrOfCodes; $i++)
                {
                        $anonymize_key = $this->createNewAccessCode();
                        $query = sprintf("INSERT INTO survey_anonymous (anonymous_id, survey_key, survey_fi, TIMESTAMP) VALUES (NULL, %s, %s, NULL)",
                                $ilDB->quote($anonymize_key . ""),
                                $ilDB->quote($this->getSurveyId() . "")
                        );
                        $result = $ilDB->query($query);
                }
        }

Here is the call graph for this function:

ilObjSurvey::delete (  ) 

delete object and all related data

public

Returns:
boolean true if all object data were removed; false if only a references were removed

Reimplemented from ilObject.

Definition at line 290 of file class.ilObjSurvey.php.

References ilUtil::delDir(), ilObject::deleteMetaData(), deleteSurveyRecord(), getImportDirectory(), and removeQuestion().

        {
                $remove = parent::delete();
                // always call parent delete function first!!
                if (!$remove)
                {
                        return false;
                }

                $this->deleteMetaData();

                // Delete all survey questions, constraints and materials
                foreach ($this->questions as $question_id)
                {
                        $this->removeQuestion($question_id);
                }
                $this->deleteSurveyRecord();
                
                ilUtil::delDir($this->getImportDirectory());
                return true;
        }

Here is the call graph for this function:

ilObjSurvey::deleteAllUserData (  ) 

Deletes all user data of a survey.

Deletes all user data of a survey

public

Definition at line 385 of file class.ilObjSurvey.php.

Referenced by deleteSurveyRecord().

        {
                global $ilDB;
                
                $query = sprintf("SELECT finished_id FROM survey_finished WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                $active_array = array();
                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        array_push($active_array, $row["finished_id"]);
                }

                $query = sprintf("DELETE FROM survey_finished WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);

                foreach ($active_array as $active_fi)
                {
                        $query = sprintf("DELETE FROM survey_answer WHERE active_fi = %s",
                                $ilDB->quote($active_fi)
                        );
                        $result = $ilDB->query($query);
                }
        }

Here is the caller graph for this function:

ilObjSurvey::deleteConstraint ( constraint_id,
question_id 
)

Deletes a constraint of a question.

Deletes a constraint of a question

Parameters:
integer $constraint_id The database id of the constraint
integer $question_id The database id of the question public

Definition at line 2451 of file class.ilObjSurvey.php.

References getSurveyId().

Referenced by moveQuestions().

        {
                global $ilDB;
                $query = sprintf("DELETE FROM survey_constraint WHERE constraint_id = %s",
                        $ilDB->quote($constraint_id)
                );
                $delresult = $ilDB->query($query);
                $query = sprintf("DELETE FROM survey_question_constraint WHERE constraint_fi = %s AND question_fi = %s AND survey_fi = %s",
                        $ilDB->quote($constraint_id),
                        $ilDB->quote($question_id),
                        $ilDB->quote($this->getSurveyId())
                );
                $delresult = $ilDB->query($query);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::deleteConstraints ( question_id  ) 

Deletes the constraints for a question.

Deletes the constraints for a question

Parameters:
integer $question_id The database id of the question public

Definition at line 2420 of file class.ilObjSurvey.php.

References getSurveyId().

Referenced by createQuestionblock().

        {
                global $ilDB;
                $query = sprintf("SELECT * FROM survey_question_constraint WHERE question_fi = %s AND survey_fi = %s",
                        $ilDB->quote($question_id),
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $query = sprintf("DELETE FROM survey_constraint WHERE constraint_id = %s",
                                $ilDB->quote($row->constraint_fi)
                        );
                        $delresult = $ilDB->query($query);
                }
                $query = sprintf("DELETE FROM survey_question_constraint WHERE question_fi = %s AND survey_fi = %s",
                        $ilDB->quote($question_id),
                        $ilDB->quote($this->getSurveyId())
                );
                $delresult = $ilDB->query($query);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::deleteSurveyCode ( survey_code  ) 

Deletes a given survey access code.

Deletes a given survey access code

Parameters:
string $survey_code The survey code that should be deleted

Definition at line 4978 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                
                if (strlen($survey_code) > 0)
                {
                        $query = sprintf("DELETE FROM survey_anonymous WHERE survey_fi = %s AND survey_key = %s",
                                $ilDB->quote($this->getSurveyId() . ""),
                                $ilDB->quote($survey_code)
                        );
                        $ilDB->query($query);
                }
        }

ilObjSurvey::deleteSurveyRecord (  ) 

Deletes the survey from the database.

Deletes the survey from the database

public

Definition at line 319 of file class.ilObjSurvey.php.

References $mobs, ilObjMediaObject::_getMobsOfObject(), ilObjMediaObject::_removeUsage(), ilUtil::delDir(), deleteAllUserData(), ilUtil::getDataDir(), and ilObject::getId().

Referenced by delete().

        {
                global $ilDB;
                
                $query = sprintf("DELETE FROM survey_survey WHERE survey_id = %s",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);

                $query = sprintf("SELECT questionblock_fi FROM survey_questionblock_question WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                $questionblocks = array();
                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        array_push($questionblocks, $row["questionblock_fi"]);
                }
                if (count($questionblocks))
                {
                        $query = "DELETE FROM survey_questionblock WHERE questionblock_id IN ('" . join($questionblocks, "','") . "')";
                        $result = $ilDB->query($query);
                }
                $query = sprintf("DELETE FROM survey_questionblock_question WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                
                $this->deleteAllUserData();

                $query = sprintf("DELETE FROM survey_anonymous WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                
                // delete export files
                include_once "./Services/Utilities/classes/class.ilUtil.php";
                $svy_data_dir = ilUtil::getDataDir()."/svy_data";
                $directory = $svy_data_dir."/svy_".$this->getId();
                if (is_dir($directory))
                {
                        include_once "./Services/Utilities/classes/class.ilUtil.php";
                        ilUtil::delDir($directory);
                }

                include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
                $mobs = ilObjMediaObject::_getMobsOfObject("svy:html", $this->getId());
                // remaining usages are not in text anymore -> delete them
                // and media objects (note: delete method of ilObjMediaObject
                // checks whether object is used in another context; if yes,
                // the object is not deleted!)
                foreach($mobs as $mob)
                {
                        ilObjMediaObject::_removeUsage($mob, "svy:html", $this->getId());
                        $mob_obj =& new ilObjMediaObject($mob);
                        $mob_obj->delete();
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::deleteWorkingData ( question_id,
active_id 
)

Deletes the working data of a question in the database.

Deletes the working data of a question in the database

Parameters:
integer $question_id The database id of the question
integer $active_id The active id of the user who worked through the question public

Definition at line 3173 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                
                $query = "";
                $query = sprintf("DELETE FROM survey_answer WHERE question_fi = %s AND active_fi = %s",
                        $ilDB->quote($question_id),
                        $ilDB->quote($active_id)
                );
                $result = $ilDB->query($query);
        }

ilObjSurvey::deliverPDFfromFO ( fo  ) 

Delivers a PDF file from a XSL-FO string.

Delivers a PDF file from a XSL-FO string

Parameters:
string $fo The XSL-FO string public

Definition at line 5261 of file class.ilObjSurvey.php.

References ilUtil::deliverData(), ilUtil::getASCIIFilename(), ilObject::getTitle(), and ilUtil::ilTempnam().

        {
                include_once "./Services/Utilities/classes/class.ilUtil.php";
                $fo_file = ilUtil::ilTempnam() . ".fo";
                $fp = fopen($fo_file, "w"); fwrite($fp, $fo); fclose($fp);
                include_once "./Services/Transformation/classes/class.ilFO2PDF.php";
                $fo2pdf = new ilFO2PDF();
                $fo2pdf->setFOString($fo);
                $result = $fo2pdf->send();
                ilUtil::deliverData($result, ilUtil::getASCIIFilename($this->getTitle()) . ".pdf", "application/pdf");
        }

Here is the call graph for this function:

ilObjSurvey::disinviteUser ( user_id  ) 

Disinvites a user from a survey.

Disinvites a user from a survey

Parameters:
integer $user_id The database id of the disinvited user public

Definition at line 2993 of file class.ilObjSurvey.php.

References ilObjUser::_lookupLogin(), getInvitation(), and ilObject::getRefId().

        {
                global $ilDB;
                
                $query = sprintf("DELETE FROM survey_invited_user WHERE survey_fi = %s AND user_fi = %s",
                        $ilDB->quote($this->getSurveyId()),
                        $ilDB->quote($user_id)
                );
                $result = $ilDB->query($query);
                if ($this->getInvitation() == INVITATION_ON)
                {
                        include_once './Services/User/classes/class.ilObjUser.php';
                        if (ilObjUser::_lookupLogin($user_id))
                        {
                                $userObj = new ilObjUser($user_id);
                                $userObj->dropDesktopItem($this->getRefId(), "svy");
                        }
                }
        }

Here is the call graph for this function:

ilObjSurvey::duplicateQuestionForSurvey ( question_id  ) 

Takes a question and creates a copy of the question for use in the survey.

Takes a question and creates a copy of the question for use in the survey

Parameters:
integer $question_id The database id of the question
Returns:
integer The database id of the copied question public

Definition at line 632 of file class.ilObjSurvey.php.

References getQuestionGUI(), and getQuestionType().

Referenced by insertQuestion(), and insertQuestionblock().

        {
                global $ilUser;
                
                $questiontype = $this->getQuestionType($question_id);
                $question_gui = $this->getQuestionGUI($questiontype, $question_id);
                $duplicate_id = $question_gui->object->duplicate(true);
                return $duplicate_id;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::finishSurvey ( user_id,
anonymize_id 
)

Finishes the survey creating an entry in the database.

Finishes the survey creating an entry in the database

Parameters:
integer $user_id The database id of the user who finishes the survey public

Definition at line 3272 of file class.ilObjSurvey.php.

References getAnonymize(), and getSurveyId().

        {
                global $ilDB;
                
                if ($this->getAnonymize())
                {
                        $query = sprintf("UPDATE survey_finished SET state = %s, user_fi = %s WHERE survey_fi = %s AND anonymous_id = %s",
                                $ilDB->quote("1"),
                                $ilDB->quote($user_id . ""),
                                $ilDB->quote($this->getSurveyId() . ""),
                                $ilDB->quote($anonymize_id . "")
                        );
                }
                else
                {
                        $query = sprintf("UPDATE survey_finished SET state = %s WHERE survey_fi = %s AND user_fi = %s",
                                $ilDB->quote("1"),
                                $ilDB->quote($this->getSurveyId() . ""),
                                $ilDB->quote($user_id . "")
                        );
                }
                $result = $ilDB->query($query);
        }

Here is the call graph for this function:

ilObjSurvey::getAllRelations ( short_as_key = false  ) 

Returns all available relations.

Returns all available relations

public

Definition at line 2964 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                
                $result_array = array();
                $query = "SELECT * FROM survey_relation";
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        if ($short_as_key)
                        {
                                $result_array[$row->shortname] = array("short" => $row->shortname, "long" => $row->longname, "id" => $row->relation_id);
                        }
                        else
                        {
                                $result_array[$row->relation_id] = array("short" => $row->shortname, "long" => $row->longname);
                        }
                }
                return $result_array;
        }

ilObjSurvey::getAllRTEContent (  ) 

Returns the content of all RTE enabled text areas in the test.

Returns the content of all RTE enabled text areas in the test

private

Definition at line 717 of file class.ilObjSurvey.php.

References getIntroduction(), and getOutro().

Referenced by cleanupMediaobjectUsage().

        {
                $result = array();
                array_push($result, $this->getIntroduction());
                array_push($result, $this->getOutro());
                return $result;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::getAnonymize (  ) 

get anonymize status

Returns:
integer status

Definition at line 976 of file class.ilObjSurvey.php.

Referenced by canExportSurveyCode(), cloneObject(), finishSurvey(), getUserDataFromActiveId(), isAccessibleWithoutCode(), isAllowedToTakeMultipleSurveys(), isSurveyStarted(), saveToDb(), startSurvey(), and toXML().

        {
                return $this->anonymize;
        }

Here is the caller graph for this function:

ilObjSurvey::getAnonymousId ( id  ) 

Checks for an anomyous survey id in the database an returns the id.

Checks for an anomyous survey id in the database an returns the id

Parameters:
string $id A survey access code
Returns:
object Anonymous survey id if found, empty string otherwise public

Definition at line 887 of file class.ilObjSurvey.php.

References ilObject::$id.

        {
                global $ilDB;
                $query = sprintf("SELECT anonymous_id FROM survey_finished WHERE anonymous_id = %s",
                        $ilDB->quote($id)
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        return $row["anonymous_id"];
                }
                else
                {
                        return "";
                }
        }

ilObjSurvey::getAuthor (  ) 

Gets the authors name.

Gets the authors name of the ilObjSurvey object

Returns:
string The string containing the name of the test author public
See also:
$author

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

References $author, ilObject::$id, ilObject::getId(), and ilObject::getType().

Referenced by cloneObject(), isComplete(), loadFromDb(), and toXML().

        {
                $author = array();
                include_once "./Services/MetaData/classes/class.ilMD.php";
                $md =& new ilMD($this->getId(), 0, $this->getType());
                $md_life =& $md->getLifecycle();
                if ($md_life)
                {
                        $ids =& $md_life->getContributeIds();
                        foreach ($ids as $id)
                        {
                                $md_cont =& $md_life->getContribute($id);
                                if (strcmp($md_cont->getRole(), "Author") == 0)
                                {
                                        $entids =& $md_cont->getEntityIds();
                                        foreach ($entids as $entid)
                                        {
                                                $md_ent =& $md_cont->getEntity($entid);
                                                array_push($author, $md_ent->getEntity());
                                        }
                                }
                        }
                }
                return join($author, ",");
  }

Here is the call graph for this function:

Here is the caller graph for this function:

& ilObjSurvey::getAvailableQuestionpools ( use_obj_id = false,
could_be_offline = false,
showPath = FALSE,
permission = "read" 
)

Returns the available question pools for the active user.

Returns the available question pools for the active user

Returns:
array The available question pools public

Definition at line 2786 of file class.ilObjSurvey.php.

References ilObjSurveyQuestionPool::_getAvailableQuestionpools().

Referenced by getQuestionsTable().

        {
                include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
                return ilObjSurveyQuestionPool::_getAvailableQuestionpools($use_obj_id, $could_be_offline, $showPath, $permission);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::getConstraints ( question_id  ) 

Returns the constraints to a given question or questionblock.

Returns the constraints to a given question or questionblock

public

Definition at line 2823 of file class.ilObjSurvey.php.

References SurveyQuestion::_getQuestionType(), and getSurveyId().

Referenced by getSurveyPages(), getSurveyQuestions(), and moveQuestions().

        {
                global $ilDB;
                
                $result_array = array();
                $query = sprintf("SELECT survey_constraint.*, survey_relation.* FROM survey_question_constraint, survey_constraint, survey_relation WHERE survey_constraint.relation_fi = survey_relation.relation_id AND survey_question_constraint.constraint_fi = survey_constraint.constraint_id AND survey_question_constraint.question_fi = %s AND survey_question_constraint.survey_fi = %s",
                        $ilDB->quote($question_id),
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {       
                        include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                        $question_type = SurveyQuestion::_getQuestionType($row->question_fi);
                        include_once "./Modules/SurveyQuestionPool/classes/class.$question_type.php";
                        $question = new $question_type();
                        $question->loadFromDb($row->question_fi);
                        $valueoutput = $question->getPreconditionValueOutput($row->value);
                        array_push($result_array, array("id" => $row->constraint_id, "question" => $row->question_fi, "short" => $row->shortname, "long" => $row->longname, "value" => $row->value, "valueoutput" => $valueoutput));
                }
                return $result_array;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::getCumulatedResults ( &$  question  ) 

Calculates the evaluation data for a question.

Calculates the evaluation data for a question

Parameters:
integer $question_id The database id of the question
integer $user_id The database id of the user
Returns:
array An array containing the evaluation parameters for the question public

Definition at line 3666 of file class.ilObjSurvey.php.

References getSurveyId().

        {
                global $ilDB;
                
                $query = sprintf("SELECT finished_id FROM survey_finished WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                $nr_of_users = $result->numRows();
                
                $result_array =& $question->getCumulatedResults($this->getSurveyId(), $nr_of_users);
                return $result_array;
        }

Here is the call graph for this function:

ilObjSurvey::getEndDate (  ) 

Gets the end date of the survey.

Gets the end date of the survey

Returns:
string Survey end date (YYYY-MM-DD) public
See also:
$end_date

Definition at line 1727 of file class.ilObjSurvey.php.

Referenced by cloneObject(), and saveToDb().

        {
    return $this->end_date;
  }

Here is the caller graph for this function:

ilObjSurvey::getEndDateEnabled (  ) 

Gets the enabled state of the end date.

Gets the enabled state of the end date

Returns:
boolean True for an enabled end date, false otherwise public
See also:
$end_date

Definition at line 1159 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), cloneObject(), and toXML().

        {
                return $this->enddate_enabled;
        }

Here is the caller graph for this function:

ilObjSurvey::getEndDay (  ) 

Gets the end day of the survey.

Gets the end day of the survey

Returns:
string Survey end day public
See also:
$end_date

Definition at line 1776 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), and toXML().

        {
                if (preg_match("/(\d{4})-(\d{2})-(\d{2})/", $this->end_date, $matches))
                {
                        return $matches[3];
                }
                else
                {
                        return "";
                }
  }

Here is the caller graph for this function:

ilObjSurvey::getEndMonth (  ) 

Gets the end month of the survey.

Gets the end month of the survey

Returns:
string Survey end month public
See also:
$end_date

Definition at line 1755 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), and toXML().

        {
                if (preg_match("/(\d{4})-(\d{2})-(\d{2})/", $this->end_date, $matches))
                {
                        return $matches[2];
                }
                else
                {
                        return "";
                }
  }

Here is the caller graph for this function:

ilObjSurvey::getEndYear (  ) 

Gets the end year of the survey.

Gets the end year of the survey

Returns:
string Survey end year public
See also:
$end_date

Definition at line 1797 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), and toXML().

        {
                if (preg_match("/(\d{4})-(\d{2})-(\d{2})/", $this->end_date, $matches))
                {
                        return $matches[1];
                }
                else
                {
                        return "";
                }
  }

Here is the caller graph for this function:

ilObjSurvey::getEvaluationAccess (  ) 

Gets the learners evaluation access.

Gets the learners evaluation access

Returns:
integer The evaluation access public
See also:
$evaluation_access

Definition at line 1818 of file class.ilObjSurvey.php.

Referenced by cloneObject(), and toXML().

        {
    return $this->evaluation_access;
  }

Here is the caller graph for this function:

& ilObjSurvey::getEvaluationByUser ( questions,
active_id 
)

Calculates the evaluation data for a given user or anonymous id.

Calculates the evaluation data for a given user or anonymous id

Parameters:
array $questions An array containing all relevant information on the survey's questions
integer $user_id The database id of the user
string $anonymous_id The unique anonymous id for an anonymous survey
Returns:
array An array containing the evaluation parameters for the user public

Definition at line 3617 of file class.ilObjSurvey.php.

References $questions, and getUserDataFromActiveId().

Referenced by getEvaluationForAllUsers().

        {
                global $ilDB;
                
                // collect all answers
                $answers = array();
                $query = sprintf("SELECT * FROM survey_answer WHERE active_fi = %s",
                        $ilDB->quote($active_id)
                );
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        if (!is_array($answers[$row["question_fi"]]))
                        {
                                $answers[$row["question_fi"]] = array();
                        }
                        array_push($answers[$row["question_fi"]], $row);
                }
                $userdata = $this->getUserDataFromActiveId($active_id);
                $resultset = array(
                        "name" => $userdata["fullname"],
                        "gender" => $userdata["gender"],
                        "answers" => array()
                );
                foreach ($questions as $key => $question)
                {
                        if (array_key_exists($key, $answers))
                        {
                                $resultset["answers"][$key] = $answers[$key];
                        }
                        else
                        {
                                $resultset["answers"][$key] = array();
                        }
                        sort($resultset["answers"][$key]);
                }
                return $resultset;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

& ilObjSurvey::getEvaluationForAllUsers (  ) 

Definition at line 3491 of file class.ilObjSurvey.php.

References $questions, getEvaluationByUser(), and getSurveyQuestions().

        {
                global $ilDB;
                
                $users = array();
                $query = sprintf("SELECT * FROM survey_finished WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId() . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                array_push($users, $row);
                        }
                }
                $evaluation = array();
                $questions =& $this->getSurveyQuestions();
                foreach ($users as $row)
                {
                        $evaluation[$row["finished_id"]] = $this->getEvaluationByUser($questions, $row["finished_id"]);
                }
                return $evaluation;
        }

Here is the call graph for this function:

& ilObjSurvey::getExistingQuestions (  ) 

Gets the question id's of the questions which are already in the survey.

Gets the question id's of the questions which are already in the survey

Returns:
array The questions of the survey public

Definition at line 1873 of file class.ilObjSurvey.php.

References $data.

Referenced by getQuestionsTable().

        {
                global $ilDB;
                $existing_questions = array();
                $query = sprintf("SELECT survey_question.original_id FROM survey_question, survey_survey_question WHERE survey_survey_question.survey_fi = %s AND survey_survey_question.question_fi = survey_question.question_id",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT)) 
                {
                        array_push($existing_questions, $data->original_id);
                }
                return $existing_questions;
        }

Here is the caller graph for this function:

ilObjSurvey::getExportDirectory (  ) 

get export directory of survey

Definition at line 4595 of file class.ilObjSurvey.php.

References ilUtil::getDataDir().

        {
                include_once "./Services/Utilities/classes/class.ilUtil.php";
                $export_dir = ilUtil::getDataDir()."/svy_data"."/svy_".$this->getId()."/export";

                return $export_dir;
        }

Here is the call graph for this function:

ilObjSurvey::getExportFiles ( dir  ) 

get export files

Definition at line 4606 of file class.ilObjSurvey.php.

References $dir, and $file.

        {
                // quit if import dir not available
                if (!@is_dir($dir) or
                        !is_writeable($dir))
                {
                        return array();
                }

                // open directory
                $dir = dir($dir);

                // initialize array
                $file = array();

                // get files and save the in the array
                while ($entry = $dir->read())
                {
                        if ($entry != "." and
                                $entry != ".." and
                                ereg("^[0-9]{10}_{2}[0-9]+_{2}(survey__)*[0-9]+\.xml|zip\$", $entry))
                        {
                                $file[] = $entry;
                        }
                }

                // close import directory
                $dir->close();
                // sort files
                sort ($file);
                reset ($file);

                return $file;
        }

ilObjSurvey::getImportDirectory (  ) 

get import directory of survey

Definition at line 4678 of file class.ilObjSurvey.php.

References ilUtil::getDataDir(), and ilUtil::makeDirParents().

Referenced by delete(), and importObject().

        {
                include_once "./Services/Utilities/classes/class.ilUtil.php";
                $import_dir = ilUtil::getDataDir()."/svy_data".
                        "/svy_".$this->getId()."/import";
                if (!is_dir($import_dir))
                {
                        ilUtil::makeDirParents($import_dir);
                }
                if(@is_dir($import_dir))
                {
                        return $import_dir;
                }
                else
                {
                        return false;
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::getIntroduction (  ) 

Gets the introduction text.

Gets the introduction text

Returns:
string The introduction of the survey object public
See also:
$introduction

Definition at line 1846 of file class.ilObjSurvey.php.

Referenced by cloneObject(), getAllRTEContent(), importObject(), and toXML().

        {
    return $this->introduction;
  }

Here is the caller graph for this function:

ilObjSurvey::getInvitation (  ) 

Gets the invitation status.

Gets the invitation status

Returns:
integer The invitation status public
See also:
$invitation

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

Referenced by cloneObject(), disinviteUser(), inviteGroup(), inviteRole(), inviteUser(), and setInvitationMode().

        {
    return $this->invitation;
  }

Here is the caller graph for this function:

ilObjSurvey::getInvitationMode (  ) 

Gets the invitation mode.

Gets the invitation mode

Returns:
integer The invitation mode public
See also:
$invitation

Definition at line 1476 of file class.ilObjSurvey.php.

Referenced by cloneObject(), and setInvitation().

        {
    return $this->invitation_mode;
  }

Here is the caller graph for this function:

& ilObjSurvey::getInvitedGroups (  ) 

Returns a list of all invited groups in a survey.

Returns a list of all invited groups in a survey

Returns:
array The group id's of the invited groups public

Definition at line 3148 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                
                $result_array = array();
                $query = sprintf("SELECT group_fi FROM survey_invited_group WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        array_push($result_array, $row->group_fi);
                }
                return $result_array;
        }

& ilObjSurvey::getInvitedUsers (  ) 

Returns a list of all invited users in a survey.

Returns a list of all invited users in a survey

Returns:
array The user id's of the invited users public

Definition at line 3124 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                
                $result_array = array();
                $query = sprintf("SELECT user_fi FROM survey_invited_user WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        array_push($result_array, $row->user_fi);
                }
                return $result_array;
        }

ilObjSurvey::getLastActivePage ( active_id  ) 

Returns the question id of the last active page a user visited in a survey.

Returns the question id of the last active page a user visited in a survey

Parameters:
integer $active_id The active id of the user
Returns:
mixed Empty string if the user has not worked through a page, question id of the last page otherwise public

Definition at line 3388 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                $query = sprintf("SELECT question_fi, TIMESTAMP + 0 AS TIMESTAMP14 FROM survey_answer WHERE active_fi = %s ORDER BY TIMESTAMP14 DESC",
                        $ilDB->quote($active_id)
                );
                $result = $ilDB->query($query);
                if ($result->numRows() == 0)
                {
                        return "";
                }
                else
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        return $row["question_fi"];
                }
        }

ilObjSurvey::getNextPage ( active_page_question_id,
direction 
)

Returns the next "page" of a running test.

Returns the next "page" of a running test

Parameters:
integer $active_page_question_id The database id of one of the questions on that page
integer $direction The direction of the next page (-1 = previous page, 1 = next page)
Returns:
mixed An array containing the question id's of the questions on the next page if there is a next page, 0 if the next page is before the start page, 1 if the next page is after the last page public

Definition at line 2740 of file class.ilObjSurvey.php.

References getSurveyPages().

        {
                $foundpage = -1;
                $pages =& $this->getSurveyPages();
                if (strcmp($active_page_question_id, "") == 0)
                {
                        return $pages[0];
                }
                
                foreach ($pages as $key => $question_array)
                {
                        foreach ($question_array as $question)
                        {
                                if ($active_page_question_id == $question["question_id"])
                                {
                                        $foundpage = $key;
                                }
                        }
                }
                if ($foundpage == -1)
                {
                        // error: page not found
                }
                else
                {
                        $foundpage += $direction;
                        if ($foundpage < 0)
                        {
                                return 0;
                        }
                        if ($foundpage >= count($pages))
                        {
                                return 1;
                        }
                        return $pages[$foundpage];
                }
        }

Here is the call graph for this function:

& ilObjSurvey::getObligatoryStates (  ) 

Gets specific obligatory states of the survey.

Gets specific obligatory states of the survey

Returns:
array An array containing the obligatory states for every question found in the database public

Definition at line 2623 of file class.ilObjSurvey.php.

Referenced by getSurveyPages(), getSurveyQuestions(), and toXML().

        {
                global $ilDB;
                $obligatory_states = array();
                $query = sprintf("SELECT * FROM survey_question_obligatory WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId() . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                $obligatory_states[$row["question_fi"]] = $row["obligatory"];
                        }
                }
                return $obligatory_states;
        }

Here is the caller graph for this function:

ilObjSurvey::getOutro (  ) 

Gets the outro text.

Gets the outro text

Returns:
string The outro of the survey object public
See also:
$outro

Definition at line 1860 of file class.ilObjSurvey.php.

Referenced by cloneObject(), getAllRTEContent(), importObject(), saveToDb(), and toXML().

        {
    return $this->outro;
  }

Here is the caller graph for this function:

ilObjSurvey::getPrecondition ( id  ) 

Returns a precondition with a given id.

Returns a precondition with a given id

public

Definition at line 2799 of file class.ilObjSurvey.php.

References ilObject::$id.

        {
                global $ilDB;
                
                $result_array = array();
                $query = sprintf("SELECT survey_constraint.*, survey_relation.* FROM survey_question_constraint, survey_constraint, survey_relation WHERE survey_constraint.relation_fi = survey_relation.relation_id AND survey_question_constraint.constraint_fi = survey_constraint.constraint_id AND survey_constraint.constraint_id = %s",
                        $ilDB->quote($id . "")
                );
                $result = $ilDB->query($query);
                $pc = array();
                if ($result->numRows())
                {
                        $pc = $result->fetchRow(DB_FETCHMODE_ASSOC);
                }
                return $pc;
        }

ilObjSurvey::getQuestionblock ( questionblock_id  ) 

Returns the database row for a given question block.

Returns the database row for a given question block

Parameters:
integer $questionblock_id The database id of the question block
Returns:
array The database row of the question block public

Definition at line 2301 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                $query = sprintf("SELECT * FROM survey_questionblock WHERE questionblock_id = %s",
                        $ilDB->quote($questionblock_id)
                );
                $result = $ilDB->query($query);
                $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                return $row;
        }

& ilObjSurvey::getQuestionblockQuestionIds ( questionblock_id  ) 

Returns the question id's of all questions of a question block.

Returns the question id's of all questions of a question block

Returns:
array The id's of the the question block questions public

Definition at line 2276 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                $ids = array();
                $query = sprintf("SELECT survey_questionblock.*, survey_survey.obj_fi, survey_question.question_id AS questiontitle, survey_survey_question.sequence, object_data.title as surveytitle, survey_question.question_id FROM object_reference, object_data, survey_questionblock, survey_questionblock_question, survey_survey, survey_question, survey_survey_question WHERE survey_questionblock.questionblock_id = survey_questionblock_question.questionblock_fi AND survey_survey.survey_id = survey_questionblock_question.survey_fi AND survey_questionblock_question.question_fi = survey_question.question_id AND survey_survey.obj_fi = object_reference.obj_id AND object_reference.obj_id = object_data.obj_id AND survey_survey_question.survey_fi = survey_survey.survey_id AND survey_survey_question.question_fi = survey_question.question_id AND survey_survey.obj_fi = %s AND survey_questionblock.questionblock_id = %s ORDER BY survey_survey_question.sequence ASC",
                        $ilDB->quote($this->getId()),
                        $ilDB->quote($questionblock_id)
                );
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        array_push($ids, $row->question_id);
                }
                return $ids;
        }

& ilObjSurvey::getQuestionblockQuestions ( questionblock_id  ) 

Returns the question titles of all questions of a question block.

Returns the question titles of all questions of a question block

Returns:
array The titles of the the question block questions public

Definition at line 2238 of file class.ilObjSurvey.php.

References $survey_id.

Referenced by getQuestionblocksTable().

        {
                global $ilDB;
                $titles = array();
                $query = sprintf("SELECT survey_question.title, survey_questionblock_question.question_fi, survey_questionblock_question.survey_fi FROM survey_questionblock, survey_questionblock_question, survey_question WHERE survey_questionblock.questionblock_id = survey_questionblock_question.questionblock_fi AND survey_question.question_id = survey_questionblock_question.question_fi AND survey_questionblock.questionblock_id = %s",
                        $ilDB->quote($questionblock_id)
                );
                $result = $ilDB->query($query);
                $survey_id = "";
                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $titles[$row["question_fi"]] = $row["title"];
                        $survey_id = $row["survey_fi"];
                }
                $query = sprintf("SELECT question_fi, sequence FROM survey_survey_question WHERE survey_fi = %s ORDER BY sequence",
                        $ilDB->quote($survey_id . "")
                );
                $result = $ilDB->query($query);
                $resultarray = array();
                $counter = 1;
                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        if (array_key_exists($row["question_fi"], $titles))
                        {
                                $resultarray[$counter++] = $titles[$row["question_fi"]];
                        }
                }
                return $resultarray;
        }

Here is the caller graph for this function:

& ilObjSurvey::getQuestionblocks ( questionblock_ids  ) 

Definition at line 3712 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                
                $result_array = array();
    $query = "SELECT survey_questionblock.*, survey_survey.obj_fi, survey_question.title AS questiontitle, survey_survey_question.sequence, object_data.title as surveytitle, survey_question.question_id FROM object_reference, object_data, survey_questionblock, survey_questionblock_question, survey_survey, survey_question, survey_survey_question WHERE survey_questionblock.questionblock_id = survey_questionblock_question.questionblock_fi AND survey_survey.survey_id = survey_questionblock_question.survey_fi AND survey_questionblock_question.question_fi = survey_question.question_id AND survey_survey.obj_fi = object_reference.obj_id AND object_reference.obj_id = object_data.obj_id AND survey_survey_question.survey_fi = survey_survey.survey_id AND survey_survey_question.question_fi = survey_question.question_id AND survey_questionblock.questionblock_id IN ('" . join($questionblock_ids, "','") . "') ORDER BY survey_survey.survey_id, survey_survey_question.sequence";
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        if ($row["questionblock_id"] != $qbid)
                        {
                                $sequence = 1;
                        }
                        $row["sequence"] = $sequence++;
                        $result_array[$row["questionblock_id"]][$row["question_id"]] = $row;
                        $qbid = $row["questionblock_id"];
                }
                return $result_array;
        }

ilObjSurvey::getQuestionblocksTable ( sort,
sortorder,
filter_text,
sel_filter_type,
startrow = 0 
)

Calculates the data for the output of the questionblock browser.

Calculates the data for the output of the questionblock browser

public

Definition at line 3875 of file class.ilObjSurvey.php.

References ilUtil::getImagePath(), and getQuestionblockQuestions().

        {
                global $ilDB;
                global $ilUser;
                $where = "";
                if (strlen($filter_text) > 0) {
                        switch($sel_filter_type) {
                                case "title":
                                        $where = " AND survey_questionblock.title LIKE " . $ilDB->quote("%" . $filter_text . "%");
                                        break;
                        }
                }
  
    // build sort order for sql query
                $order = "";
                $images = array();
                include_once "./Services/Utilities/classes/class.ilUtil.php";
                switch($sort) 
                {
                        case "title":
                                $order = " ORDER BY survey_questionblock.title $sortorder";
                                $images["title"] = " <img src=\"" . ilUtil::getImagePath(strtolower($sortorder) . "_order.gif") . "\" alt=\"" . strtolower($sortorder) . "ending order\" />";
                                break;
                        case "svy":
                                $order = " ORDER BY survey_survey_question.survey_fi $sortorder";
                                $images["svy"] = " <img src=\"" . ilUtil::getImagePath(strtolower($sortorder) . "_order.gif") . "\" alt=\"" . strtolower($sortorder) . "ending order\" />";
                                break;
                }
                $maxentries = $ilUser->prefs["hits_per_page"];
                if ($order)
                {
                        $order .=  ",survey_survey_question.sequence ASC";
                }
                else
                {
                        $order = " ORDER BY survey_survey_question.sequence ASC";
                }
                $query = "SELECT survey_questionblock.questionblock_id FROM object_reference, object_data, survey_questionblock, survey_questionblock_question, survey_survey, survey_question, survey_survey_question WHERE survey_questionblock.questionblock_id = survey_questionblock_question.questionblock_fi AND survey_survey.survey_id = survey_questionblock_question.survey_fi AND survey_questionblock_question.question_fi = survey_question.question_id AND survey_survey.obj_fi = object_reference.obj_id AND object_reference.obj_id = object_data.obj_id AND survey_survey_question.survey_fi = survey_survey.survey_id AND survey_survey_question.question_fi = survey_question.question_id$where GROUP BY survey_questionblock.questionblock_id$order$limit";
    $query_result = $ilDB->query($query);
                $questionblock_ids = array();
                if ($query_result->numRows())
                {
                        while ($row = $query_result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                array_push($questionblock_ids, $row["questionblock_id"]);
                        }
                }
                
                $max = $query_result->numRows();
                if ($startrow > $max -1)
                {
                        $startrow = $max - ($max % $maxentries);
                }
                else if ($startrow < 0)
                {
                        $startrow = 0;
                }
                $limit = " LIMIT $startrow, $maxentries";
                $query = "SELECT survey_questionblock.*, object_data.title as surveytitle FROM object_reference, object_data, survey_questionblock, survey_questionblock_question, survey_survey, survey_question, survey_survey_question WHERE survey_questionblock.questionblock_id = survey_questionblock_question.questionblock_fi AND survey_survey.survey_id = survey_questionblock_question.survey_fi AND survey_questionblock_question.question_fi = survey_question.question_id AND survey_survey.obj_fi = object_reference.obj_id AND object_reference.obj_id = object_data.obj_id AND survey_survey_question.survey_fi = survey_survey.survey_id AND survey_survey_question.question_fi = survey_question.question_id$where GROUP BY survey_questionblock.questionblock_id$order$limit";
    $query_result = $ilDB->query($query);
                $rows = array();
                if ($query_result->numRows())
                {
                        while ($row = $query_result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                $questions_array =& $this->getQuestionblockQuestions($row["questionblock_id"]);
                                $counter = 1;
                                foreach ($questions_array as $key => $value)
                                {
                                        $questions_array[$key] = "$counter. $value";
                                        $counter++;
                                }
                                $rows[$row["questionblock_id"]] = array(
                                        "questionblock_id" => $row["questionblock_id"],
                                        "title" => $row["title"], 
                                        "surveytitle" => $row["surveytitle"], 
                                        "questions" => join($questions_array, ", "),
                                        "owner" => $row["owner_fi"]
                                );
                        }
                }
                $nextrow = $startrow + $maxentries;
                if ($nextrow > $max - 1)
                {
                        $nextrow = $startrow;
                }
                $prevrow = $startrow - $maxentries;
                if ($prevrow < 0)
                {
                        $prevrow = 0;
                }
                return array(
                        "rows" => $rows,
                        "images" => $images,
                        "startrow" => $startrow,
                        "nextrow" => $nextrow,
                        "prevrow" => $prevrow,
                        "step" => $maxentries,
                        "rowcount" => $max
                );
        }

Here is the call graph for this function:

& ilObjSurvey::getQuestionblockTitles (  ) 

Returns the titles of all question blocks of the question pool.

Returns the titles of all question blocks of the question pool

Returns:
array The titles of the the question blocks public

Definition at line 2215 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                $titles = array();
                $query = sprintf("SELECT survey_questionblock.* FROM survey_questionblock, survey_question, survey_questionblock_question WHERE survey_questionblock_question.question_fi = survey_question.question_id AND survey_question.obj_fi = %s",
                        $ilDB->quote($this->getId())
                );
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $titles[$row->questionblock_id] = $row->title;
                }
                return $titles;
        }

ilObjSurvey::getQuestionGUI ( questiontype,
question_id 
)

Returns a question gui object to a given questiontype and question id.

Returns a question gui object to a given questiontype and question id

Returns:
object Resulting question gui object public

Definition at line 913 of file class.ilObjSurvey.php.

Referenced by duplicateQuestionForSurvey().

        {
                $questiontypegui = $questiontype . "GUI";
                include_once "./Modules/SurveyQuestionPool/classes/class.$questiontypegui.php";
                $question = new $questiontypegui();
                $question->object->loadFromDb($question_id);
                return $question;
        }

Here is the caller graph for this function:

& ilObjSurvey::getQuestionpoolTitles ( could_be_offline = FALSE,
showPath = FALSE 
)

Get the titles of all available survey question pools.

Get the titles of all available survey question pools

Returns:
array An array of survey question pool titles public

Definition at line 1896 of file class.ilObjSurvey.php.

References ilObjSurveyQuestionPool::_getAvailableQuestionpools().

        {
                include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
                return ilObjSurveyQuestionPool::_getAvailableQuestionpools($use_object_id = TRUE, $could_be_offline, $showPath);
        }

Here is the call graph for this function:

& ilObjSurvey::getQuestions ( question_ids  ) 

Definition at line 3700 of file class.ilObjSurvey.php.

        {
                $result_array = array();
                $query = "SELECT survey_question.*, survey_questiontype.type_tag FROM survey_question, survey_questiontype WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id AND survey_question.question_id IN ('" . join($question_ids, "','") . "')";
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        array_push($result_array, $row);
                }
                return $result_array;
        }

ilObjSurvey::getQuestionsTable ( sort,
sortorder,
filter_text,
sel_filter_type,
startrow = 0,
completeonly = 0,
filter_question_type = "",
filter_questionpool = "" 
)

Calculates the data for the output of the question browser.

Calculates the data for the output of the question browser

public

Definition at line 3739 of file class.ilObjSurvey.php.

References getAvailableQuestionpools(), getExistingQuestions(), and ilUtil::getImagePath().

        {
                global $ilUser;
                global $ilDB;
                
                $where = "";
                if (strlen($filter_text) > 0) 
                {
                        switch($sel_filter_type) 
                        {
                                case "title":
                                        $where = " AND survey_question.title LIKE " . $ilDB->quote("%" . $filter_text . "%");
                                        break;
                                case "description":
                                        $where = " AND survey_question.description LIKE " . $ilDB->quote("%" . $filter_text . "%");
                                        break;
                                case "author":
                                        $where = " AND survey_question.author LIKE " . $ilDB->quote("%" . $filter_text . "%");
                                        break;
                        }
                }
  
                if ($filter_question_type && (strcmp($filter_question_type, "all") != 0))
                {
                        $where .= " AND survey_questiontype.type_tag = " . $ilDB->quote($filter_question_type);
                }
                
                if ($filter_questionpool && (strcmp($filter_questionpool, "all") != 0))
                {
                        $where .= " AND survey_question.obj_fi = $filter_questionpool";
                }
  
    // build sort order for sql query
                $order = "";
                $images = array();
                include_once "./Services/Utilities/classes/class.ilUtil.php";
                switch($sort) 
                {
                        case "title":
                                $order = " ORDER BY title $sortorder";
                                $images["title"] = " <img src=\"" . ilUtil::getImagePath(strtolower($sortorder) . "_order.gif") . "\" alt=\"" . strtolower($sortorder) . "ending order\" />";
                                break;
                        case "description":
                                $order = " ORDER BY description $sortorder";
                                $images["description"] = " <img src=\"" . ilUtil::getImagePath(strtolower($sortorder) . "_order.gif") . "\" alt=\"" . strtolower($sortorder) . "ending order\" />";
                                break;
                        case "type":
                                $order = " ORDER BY questiontype_id $sortorder";
                                $images["type"] = " <img src=\"" . ilUtil::getImagePath(strtolower($sortorder) . "_order.gif") . "\" alt=\"" . strtolower($sortorder) . "ending order\" />";
                                break;
                        case "author":
                                $order = " ORDER BY author $sortorder";
                                $images["author"] = " <img src=\"" . ilUtil::getImagePath(strtolower($sortorder) . "_order.gif") . "\" alt=\"" . strtolower($sortorder) . "ending order\" />";
                                break;
                        case "created":
                                $order = " ORDER BY created $sortorder";
                                $images["created"] = " <img src=\"" . ilUtil::getImagePath(strtolower($sortorder) . "_order.gif") . "\" alt=\"" . strtolower($sortorder) . "ending order\" />";
                                break;
                        case "updated":
                                $order = " ORDER BY TIMESTAMP14 $sortorder";
                                $images["updated"] = " <img src=\"" . ilUtil::getImagePath(strtolower($sortorder) . "_order.gif") . "\" alt=\"" . strtolower($sortorder) . "ending order\" />";
                                break;
                        case "qpl":
                                $order = " ORDER BY obj_fi $sortorder";
                                $images["qpl"] = " <img src=\"" . ilUtil::getImagePath(strtolower($sortorder) . "_order.gif") . "\" alt=\"" . strtolower($sortorder) . "ending order\" />";
                                break;
                }
                $maxentries = $ilUser->prefs["hits_per_page"];
                if ($maxentries < 1)
                {
                        $maxentries = 9999;
                }

                $spls =& $this->getAvailableQuestionpools($use_obj_id = TRUE, $could_be_offline = FALSE, $showPath = FALSE);
                $forbidden = "";
                $forbidden = " AND survey_question.obj_fi IN ('" . join(array_keys($spls), "','") . "')";
                if ($completeonly)
                {
                        $forbidden .= " AND survey_question.complete = " . $ilDB->quote("1");
                }
                $existing = "";
                $existing_questions =& $this->getExistingQuestions();
                if (count($existing_questions))
                {
                        $existing = " AND survey_question.question_id NOT IN ('" . join($existing_questions, "','") . "')";
                }
                $limit = " LIMIT $startrow, $maxentries";
                $query = "SELECT survey_question.*, survey_question.TIMESTAMP + 0 AS TIMESTAMP14, survey_questiontype.type_tag, object_reference.ref_id FROM survey_question, survey_questiontype, object_reference WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id$forbidden$existing AND survey_question.obj_fi = object_reference.obj_id AND ISNULL(survey_question.original_id) " . " $where$order";
                $query_result = $ilDB->query($query);
                $max = $query_result->numRows();
                $query = "SELECT survey_question.*, survey_question.TIMESTAMP + 0 AS TIMESTAMP14, survey_questiontype.type_tag, object_reference.ref_id FROM survey_question, survey_questiontype, object_reference WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id$forbidden$existing AND survey_question.obj_fi = object_reference.obj_id AND ISNULL(survey_question.original_id) " . " $where$order$limit";
                $query_result = $ilDB->query($query);
                if ($startrow > $max -1)
                {
                        $startrow = $max - ($max % $maxentries);
                }
                else if ($startrow < 0)
                {
                        $startrow = 0;
                }
                $rows = array();
                if ($query_result->numRows())
                {
                        while ($row = $query_result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                array_push($rows, $row);
                        }
                }
                $nextrow = $startrow + $maxentries;
                if ($nextrow > $max - 1)
                {
                        $nextrow = $startrow;
                }
                $prevrow = $startrow - $maxentries;
                if ($prevrow < 0)
                {
                        $prevrow = 0;
                }
                return array(
                        "rows" => $rows,
                        "images" => $images,
                        "startrow" => $startrow,
                        "nextrow" => $nextrow,
                        "prevrow" => $prevrow,
                        "step" => $maxentries,
                        "rowcount" => $max
                );
        }

Here is the call graph for this function:

ilObjSurvey::getQuestionType ( question_id  ) 

Returns the question type of a question with a given id.

Returns the question type of a question with a given id

Parameters:
integer $question_id The database id of the question
Returns:
string The question type string private

Definition at line 931 of file class.ilObjSurvey.php.

References $data.

Referenced by duplicateQuestionForSurvey().

        {
                global $ilDB;
    if ($question_id < 1) return -1;
    $query = sprintf("SELECT type_tag FROM survey_question, survey_questiontype WHERE survey_question.question_id = %s AND survey_question.questiontype_fi = survey_questiontype.questiontype_id",
      $ilDB->quote($question_id)
    );
    $result = $ilDB->query($query);
    if ($result->numRows() == 1) 
                {
      $data = $result->fetchRow(DB_FETCHMODE_OBJECT);
      return $data->type_tag;
    } 
                else 
                {
      return "";
    }
  }

Here is the caller graph for this function:

& ilObjSurvey::getQuestiontypes (  ) 

Returns an array with all existing question types.

Returns an array with all existing question types

Returns:
array An array containing the question types public

Definition at line 2558 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                $query = "SELECT type_tag FROM survey_questiontype";
                $result = $ilDB->query($query);
                $result_array = array();
                while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        array_push($result_array, $row->type_tag);
                }
                return $result_array;
        }

ilObjSurvey::getShowQuestionTitles (  ) 

Gets the status of the display_question_titles attribute.

Gets the status of the display_question_titles attribute

Returns:
integer The status of the display_question_titles attribute public
See also:
$display_question_titles

Definition at line 1256 of file class.ilObjSurvey.php.

Referenced by saveToDb(), and toXML().

        {
                return $this->display_question_titles;
  }

Here is the caller graph for this function:

ilObjSurvey::getStartDate (  ) 

Gets the start date of the survey.

Gets the start date of the survey

Returns:
string Survey start date (YYYY-MM-DD) public
See also:
$start_date

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

Referenced by cloneObject(), and saveToDb().

        {
    return $this->start_date;
  }

Here is the caller graph for this function:

ilObjSurvey::getStartDateEnabled (  ) 

Gets the enabled state of the start date.

Gets the enabled state of the start date

Returns:
boolean True for an enabled end date, false otherwise public
See also:
$start_date

Definition at line 1124 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), cloneObject(), and toXML().

        {
                return $this->startdate_enabled;
        }

Here is the caller graph for this function:

ilObjSurvey::getStartDay (  ) 

Gets the start day of the survey.

Gets the start day of the survey

Returns:
string Survey start day public
See also:
$start_date

Definition at line 1685 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), and toXML().

        {
                if (preg_match("/(\d{4})-(\d{2})-(\d{2})/", $this->start_date, $matches))
                {
                        return $matches[3];
                }
                else
                {
                        return "";
                }
  }

Here is the caller graph for this function:

ilObjSurvey::getStartMonth (  ) 

Gets the start month of the survey.

Gets the start month of the survey

Returns:
string Survey start month public
See also:
$start_date

Definition at line 1664 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), and toXML().

        {
                if (preg_match("/(\d{4})-(\d{2})-(\d{2})/", $this->start_date, $matches))
                {
                        return $matches[2];
                }
                else
                {
                        return "";
                }
  }

Here is the caller graph for this function:

ilObjSurvey::getStartYear (  ) 

Gets the start year of the survey.

Gets the start year of the survey

Returns:
string Survey start year public
See also:
$start_date

Definition at line 1706 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), and toXML().

        {
                if (preg_match("/(\d{4})-(\d{2})-(\d{2})/", $this->start_date, $matches))
                {
                        return $matches[1];
                }
                else
                {
                        return "";
                }
  }

Here is the caller graph for this function:

ilObjSurvey::getStatus (  ) 

Gets the survey status.

Gets the survey status

Returns:
integer Survey status public
See also:
$status

Definition at line 1490 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), cloneObject(), and toXML().

        {
    return $this->status;
  }

Here is the caller graph for this function:

ilObjSurvey::getSurveyCodesCount (  ) 

Returns the number of generated survey codes for the survey.

Returns the number of generated survey codes for the survey

Returns:
integer The number of generated survey codes public

Definition at line 4821 of file class.ilObjSurvey.php.

        {
                global $ilDB;

                $query = sprintf("SELECT anonymous_id FROM survey_anonymous WHERE survey_fi = %s AND ISNULL(user_key)",
                        $ilDB->quote($this->getSurveyId() . "")
                );
                $result = $ilDB->query($query);
                return $result->numRows();
        }

ilObjSurvey::getSurveyCodesForExport ( a_array  ) 

Returns a list of survey codes for file export.

Returns a list of survey codes for file export

Parameters:
array $a_array An array of all survey codes that should be exported
Returns:
string A comma separated list of survey codes an URLs for file export public

Definition at line 4841 of file class.ilObjSurvey.php.

References $lang, formatDate(), ilFormat::ftimestamp2dateDB(), ilObject::getRefId(), and isSurveyCodeUsed().

        {
                global $ilDB;

/*              $query = sprintf("SELECT * FROM survey_anonymous WHERE survey_fi = %s AND ISNULL(user_key)",
                        $ilDB->quote($this->getSurveyId() . "")
                );
*/
                $query = sprintf("SELECT survey_anonymous.*, survey_anonymous.TIMESTAMP + 0 AS TIMESTAMP14, survey_finished.state FROM survey_anonymous LEFT JOIN survey_finished ON survey_anonymous.survey_key = survey_finished.anonymous_id WHERE survey_anonymous.survey_fi = %s AND ISNULL(survey_anonymous.user_key)",
                        $ilDB->quote($this->getSurveyId() . "")
                );
                $result = $ilDB->query($query);


                $result = $ilDB->query($query);
                $export = "";
                $lang = ($_POST["lang"] != 1) ? "&amp;lang=" . $_POST["lang"] : "";
                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        if (in_array($row["survey_key"], $a_array) || (count($a_array) == 0))
                        {
                                $export .= $row["survey_key"] . ",";
                                $created = ilFormat::formatDate(ilFormat::ftimestamp2dateDB($row["TIMESTAMP14"]), "date");
                                $export .= "$created,";
                                if ($this->isSurveyCodeUsed($row["survey_key"]))
                                {
                                        $export .= "1,";
                                }
                                else
                                {
                                        $export .= "0,";
                                }
                                $url = ILIAS_HTTP_PATH."/goto.php?cmd=infoScreen&target=svy_".$this->getRefId() . "&amp;client_id=" . CLIENT_ID . "&amp;accesscode=".$row["survey_key"].$lang;
                                $export .= $url . "\n";
                        }
                }
                return $export;
        }

Here is the call graph for this function:

& ilObjSurvey::getSurveyCodesTableData ( lang = "en",
offset = 0,
limit = 10 
)

Fetches the data for the survey codes table.

Fetches the data for the survey codes table

Parameters:
string $lang Language for the survey code URL
integer $offset Offset for the requested data
integer $limit Limit of the requested data
Returns:
array The requested data public

Definition at line 4891 of file class.ilObjSurvey.php.

References $lang, formatDate(), ilFormat::ftimestamp2datetimeDB(), ilObject::getRefId(), and isSurveyCodeUsed().

        {
                global $ilDB;

                include_once "./classes/class.ilFormat.php";
                if (strlen($lang) == 0) $lang = "en";
                if (strlen($offset) == 0) $offset = 0;
                if (strlen($limit) == 0) $limit = 10;
                
                $order = "ORDER BY TIMESTAMP14, survey_key ASC";
                $codes = array();
                $query = sprintf("SELECT survey_anonymous.anonymous_id, survey_anonymous.survey_key, survey_anonymous.survey_fi, survey_anonymous.TIMESTAMP + 0 AS TIMESTAMP14, survey_finished.state FROM survey_anonymous LEFT JOIN survey_finished ON survey_anonymous.survey_key = survey_finished.anonymous_id WHERE survey_anonymous.survey_fi = %s AND ISNULL(survey_anonymous.user_key) $order LIMIT $offset,$limit",
                        $ilDB->quote($this->getSurveyId() . "")
                );
                $result = $ilDB->query($query);
                $counter = $offset+1;
                if ($result->numRows() > 0)
                {
                        while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                $created = ilFormat::formatDate(ilFormat::ftimestamp2datetimeDB($row["TIMESTAMP14"]));

                                $url = "";
                                
                                $state = "<span class=\"smallred\">" . $this->lng->txt("not_used") . "</span>";
                                if ($this->isSurveyCodeUsed($row["survey_key"]))
                                {
                                        $state = "<span class=\"smallgreen\">" . $this->lng->txt("used") . "</span>";
                                }
                                else
                                {
                                        $addlang = "";
                                        if (strlen($lang))
                                        {
                                                $addlang = "&amp;lang=$lang";
                                        }
                                        $url = "<a href=\"" . ILIAS_HTTP_PATH."/goto.php?cmd=infoScreen&target=svy_".$this->getRefId() . "&amp;client_id=" . CLIENT_ID . "&amp;accesscode=".$row["survey_key"].$addlang . "\">";
                                        $url .= $this->lng->txt("survey_code_url_name");
                                        $url .= "</a>";
                                }
                                $counter = "<input type=\"checkbox\" name=\"chb_code[]\" value=\"" . $row["survey_key"] . "\"/>";
                                array_push($codes, array($counter, $row["survey_key"], $created, $state, $url));
                                $counter++;
                        }
                }
                return $codes;
        }

Here is the call graph for this function:

ilObjSurvey::getSurveyId (  ) 

Returns the survey database id.

Returns the survey database id

Returns:
integer survey database id public

Definition at line 958 of file class.ilObjSurvey.php.

Referenced by cloneObject(), createSurveyCodes(), deleteConstraint(), deleteConstraints(), finishSurvey(), getConstraints(), getCumulatedResults(), getUserSpecificResults(), inviteUser(), isAnonymizedParticipant(), isAnonymousKey(), removeConstraintsConcerningQuestion(), removeQuestions(), saveHeading(), saveUserAccessCode(), toXML(), unfoldQuestionblocks(), and updateConstraint().

        {
                return $this->survey_id;
        }

Here is the caller graph for this function:

& ilObjSurvey::getSurveyPages (  ) 

Returns the survey pages in an array (a page contains one or more questions).

Returns the survey pages in an array (a page contains one or more questions)

public

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

References getConstraints(), and getObligatoryStates().

Referenced by getNextPage(), moveDownQuestion(), moveDownQuestionblock(), moveUpQuestion(), moveUpQuestionblock(), and toXML().

        {
                global $ilDB;
                $obligatory_states =& $this->getObligatoryStates();
                // get questionblocks
                $all_questions = array();
                $query = sprintf("SELECT survey_question.*, survey_questiontype.type_tag, survey_survey_question.heading FROM survey_question, survey_questiontype, survey_survey_question WHERE survey_survey_question.survey_fi = %s AND survey_survey_question.question_fi = survey_question.question_id AND survey_question.questiontype_fi = survey_questiontype.questiontype_id ORDER BY survey_survey_question.sequence",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $all_questions[$row["question_id"]] = $row;
                }
                // get all questionblocks
                $questionblocks = array();
                $in = join(array_keys($all_questions), "','");
                if ($in)
                {
                        $query = sprintf("SELECT survey_questionblock.*, survey_questionblock_question.question_fi FROM survey_questionblock, survey_questionblock_question WHERE survey_questionblock.questionblock_id = survey_questionblock_question.questionblock_fi AND survey_questionblock_question.survey_fi = %s AND survey_questionblock_question.question_fi IN ('$in')",
                                $ilDB->quote($this->getSurveyId())
                        );
                        $result = $ilDB->query($query);
                        while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                        {
                                $questionblocks["$row->question_fi"] = $row;
                        }                       
                }
                
                $all_pages = array();
                $pageindex = -1;
                $currentblock = "";
                foreach ($all_questions as $question_id => $row)
                {
                        if (array_key_exists($question_id, $obligatory_states))
                        {
                                $all_questions["$question_id"]["obligatory"] = $obligatory_states["$question_id"];
                        }
                        $constraints = array();
                        if (isset($questionblocks[$question_id]))
                        {
                                if (!$currentblock or ($currentblock != $questionblocks[$question_id]->questionblock_id))
                                {
                                        $pageindex++;
                                }
                                $all_questions[$question_id]["questionblock_title"] = $questionblocks[$question_id]->title;
                                $all_questions[$question_id]["questionblock_id"] = $questionblocks[$question_id]->questionblock_id;
                                $all_questions[$question_id]["questionblock_show_questiontext"] = $questionblocks[$question_id]->show_questiontext;
                                $currentblock = $questionblocks[$question_id]->questionblock_id;
                                $constraints = $this->getConstraints($question_id);
                                $all_questions[$question_id]["constraints"] = $constraints;
                        }
                        else
                        {
                                $pageindex++;
                                $all_questions[$question_id]["questionblock_title"] = "";
                                $all_questions[$question_id]["questionblock_id"] = "";
                                $all_questions[$question_id]["questionblock_show_questiontext"] = 1;
                                $currentblock = "";
                                $constraints = $this->getConstraints($question_id);
                                $all_questions[$question_id]["constraints"] = $constraints;
                        }
                        if (!isset($all_pages[$pageindex]))
                        {
                                $all_pages[$pageindex] = array();
                        }
                        array_push($all_pages[$pageindex], $all_questions[$question_id]);
                }
                // calculate position percentage for every page
                $max = count($all_pages);
                $counter = 1;
                foreach ($all_pages as $index => $block)
                {
                        foreach ($block as $blockindex => $question)
                        {
                                $all_pages[$index][$blockindex][position] = $counter / $max;
                        }
                        $counter++;
                }
                return $all_pages;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

& ilObjSurvey::getSurveyParticipants (  ) 

Definition at line 444 of file class.ilObjSurvey.php.

References getUserDataFromActiveId().

        {
                global $ilDB;
                
                $query = sprintf("SELECT * FROM survey_finished WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId() . "")
                );
                $result = $ilDB->query($query);
                $participants = array();
                if ($result->numRows() > 0)
                {
                        while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                $userdata = $this->getUserDataFromActiveId($row["finished_id"]);
                                $participants[$userdata["sortname"] . $userdata["active_id"]] = $userdata;
                        }
                }
                return $participants;
        }

Here is the call graph for this function:

& ilObjSurvey::getSurveyQuestions ( with_answers = false  ) 

Returns the survey questions and questionblocks in an array.

Returns the survey questions and questionblocks in an array

public

Definition at line 2473 of file class.ilObjSurvey.php.

References $data, _instanciateQuestion(), getConstraints(), and getObligatoryStates().

Referenced by getEvaluationForAllUsers(), getUserSpecificResults(), moveDownQuestion(), moveUpQuestion(), and removeQuestions().

        {
                global $ilDB;
                $obligatory_states =& $this->getObligatoryStates();
                // get questionblocks
                $all_questions = array();
                $query = sprintf("SELECT survey_questiontype.type_tag, survey_question.question_id, survey_survey_question.heading FROM survey_questiontype, survey_question, survey_survey_question WHERE survey_survey_question.survey_fi = %s AND survey_survey_question.question_fi = survey_question.question_id AND survey_question.questiontype_fi = survey_questiontype.questiontype_id ORDER BY survey_survey_question.sequence",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $question =& $this->_instanciateQuestion($row["question_id"]);
                        $questionrow = $question->_getQuestionDataArray($row["question_id"]);
                        foreach ($row as $key => $value)
                        {
                                $questionrow[$key] = $value;
                        }
                        $all_questions[$row["question_id"]] = $questionrow;
                        $all_questions[$row["question_id"]]["usableForPrecondition"] = $question->usableForPrecondition();
                        $all_questions[$row["question_id"]]["availableRelations"] = $question->getAvailableRelations();
                        if (array_key_exists($row["question_id"], $obligatory_states))
                        {
                                $all_questions[$row["question_id"]]["obligatory"] = $obligatory_states[$row["question_id"]];
                        }
                }
                // get all questionblocks
                $questionblocks = array();
                $in = join(array_keys($all_questions), "','");
                if ($in)
                {
                        $query = sprintf("SELECT survey_questionblock.*, survey_questionblock_question.question_fi FROM survey_questionblock, survey_questionblock_question WHERE survey_questionblock.questionblock_id = survey_questionblock_question.questionblock_fi AND survey_questionblock_question.survey_fi = %s AND survey_questionblock_question.question_fi IN ('$in')",
                                $ilDB->quote($this->getSurveyId())
                        );
                        $result = $ilDB->query($query);
                        while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                        {
                                $questionblocks[$row->question_fi] = $row;
                        }                       
                }
                
                foreach ($all_questions as $question_id => $row)
                {
                        $constraints = $this->getConstraints($question_id);
                        if (isset($questionblocks[$question_id]))
                        {
                                $all_questions[$question_id]["questionblock_title"] = $questionblocks[$question_id]->title;
                                $all_questions[$question_id]["questionblock_id"] = $questionblocks[$question_id]->questionblock_id;
                                $all_questions[$question_id]["constraints"] = $constraints;
                        }
                        else
                        {
                                $all_questions[$question_id]["questionblock_title"] = "";
                                $all_questions[$question_id]["questionblock_id"] = "";
                                $all_questions[$question_id]["constraints"] = $constraints;
                        }
                        if ($with_answers)
                        {
                                $answers = array();
                                $query = sprintf("SELECT survey_variable.*, survey_category.title 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($question_id . "")
                                );
                                $result = $ilDB->query($query);
                                if (strcmp(strtolower(get_class($result)), db_result) == 0) 
                                {
                                        while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT)) 
                                        {
                                                array_push($answers, $data->title);
                                        }
                                }
                                $all_questions[$question_id]["answers"] = $answers;                             
                        }
                }
                return $all_questions;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::getTextblock ( question_id  ) 

Definition at line 4525 of file class.ilObjSurvey.php.

Referenced by cloneTextblocks().

        {
                global $ilDB;
                $query = sprintf("SELECT * FROM survey_survey_question WHERE question_fi = %s",
                        $ilDB->quote($question_id . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        return $row["heading"];
                }
                else
                {
                        return "";
                }
        }

Here is the caller graph for this function:

ilObjSurvey::getUserAccessCode ( user_id  ) 

Returns a survey access code that was saved for a registered user.

Returns a survey access code that was saved for a registered user

Parameters:
int $user_id The database id of the user
Returns:
string The survey access code of the user

Definition at line 5000 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                $access_code = "";
                $query = sprintf("SELECT survey_key FROM survey_anonymous WHERE survey_fi = %s AND user_key = %s",
                        $ilDB->quote($this->getSurveyId() . ""),
                        $ilDB->quote(md5($user_id))
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        $access_code = $row["survey_key"];
                }
                return $access_code;
        }

ilObjSurvey::getUserDataFromActiveId ( active_id  ) 

Returns the user information from an active_id (survey_finished.finished_id).

Parameters:
integer $active_id The active id of the user
Returns:
array An array containing the user data public

Definition at line 3562 of file class.ilObjSurvey.php.

References $user, ilObjUser::_lookupLogin(), and getAnonymize().

Referenced by getEvaluationByUser(), and getSurveyParticipants().

        {
                global $ilDB;
                
                $query = sprintf("SELECT * FROM survey_finished WHERE finished_id = %s",
                        $ilDB->quote($active_id)
                );
                $result = $ilDB->query($query);
                $userdata = array(
                        "fullname" => $this->lng->txt("anonymous"),
                        "sortname" => $this->lng->txt("anonymous"),
                        "firstname" => "",
                        "lastname" => "",
                        "login" => "",
                        "gender" => "",
                        "active_id" => "$active_id"
                );
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        if (($row["user_fi"] > 0) && ($row["user_fi"] != ANONYMOUS_USER_ID) && ($this->getAnonymize() == 0))
                        {
                                include_once './Services/User/classes/class.ilObjUser.php';
                                if (strlen(ilObjUser::_lookupLogin($row["user_fi"])) == 0)
                                {
                                        $userdata["fullname"] = $this->lng->txt("deleted_user");
                                }
                                else
                                {
                                        $user = new ilObjUser($row["user_fi"]);
                                        $userdata["fullname"] = $user->getFullname();
                                        $gender = $user->getGender();
                                        if (strlen($gender) == 1) $gender = $this->lng->txt("gender_$gender");
                                        $userdata["gender"] = $gender;
                                        $userdata["firstname"] = $user->getFirstname();
                                        $userdata["lastname"] = $user->getLastname();
                                        $userdata["sortname"] = $user->getLastname() . ", " . $user->getFirstname();
                                        $userdata["login"] = $user->getLogin();
                                }
                        }
                }
                return $userdata;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

& ilObjSurvey::getUserSpecificResults (  ) 

Calculates the evaluation data for the user specific results.

Calculates the evaluation data for the user specific results

Returns:
array An array containing the user specific results public

Definition at line 3524 of file class.ilObjSurvey.php.

References $data, $questions, SurveyQuestion::_getQuestionType(), getSurveyId(), and getSurveyQuestions().

        {
                global $ilDB;
                
                $users = array();
                $query = sprintf("SELECT * FROM survey_finished WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId() . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                array_push($users, $row);
                        }
                }
                $evaluation = array();
                $questions =& $this->getSurveyQuestions();
                foreach ($questions as $question_id => $question_data)
                {
                        include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                        $question_type = SurveyQuestion::_getQuestionType($question_id);
                        include_once "./Modules/SurveyQuestionPool/classes/class.$question_type.php";
                        $question = new $question_type();
                        $question->loadFromDb($question_id);
                        $data =& $question->getUserAnswers($this->getSurveyId());
                        $evaluation[$question_id] = $data;
                }
                return $evaluation;
        }

Here is the call graph for this function:

ilObjSurvey::getUserSurveyCode ( user_id  ) 

Definition at line 4754 of file class.ilObjSurvey.php.

References isAccessibleWithoutCode(), and isAllowedToTakeMultipleSurveys().

        {
                global $ilDB;
                
                if (($user_id == ANONYMOUS_USER_ID) || (($this->isAccessibleWithoutCode() && $this->isAllowedToTakeMultipleSurveys()))) return "";
                $query = sprintf("SELECT anonymous_id FROM survey_finished WHERE survey_fi = %s AND user_fi = %s",
                        $ilDB->quote($this->getSurveyId() . ""),
                        $ilDB->quote($user_id . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows() == 1)
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        return $row["anonymous_id"];
                }
                else
                {
                        return "";
                }
        }

Here is the call graph for this function:

& ilObjSurvey::getVariables ( question_id  ) 

Returns all variables of a question.

Returns all variables of a question

public

Definition at line 2876 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                
                $result_array = array();
                $query = sprintf("SELECT survey_variable.*, survey_category.title FROM survey_variable LEFT JOIN survey_category ON survey_variable.category_fi = survey_category.category_id WHERE survey_variable.question_fi = %s ORDER BY survey_variable.sequence",
                        $ilDB->quote($question_id)
                );
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $result_array[$row->sequence] = $row;
                }
                return $result_array;
        }

ilObjSurvey::hideQuestionTitles (  ) 

Sets the question titles hidden during the query.

Sets the question titles hidden during the query

public

See also:
$display_question_titles

Definition at line 1282 of file class.ilObjSurvey.php.

        {
                $this->display_question_titles = QUESTIONTITLES_HIDDEN;
  }

ilObjSurvey::ilObjSurvey ( a_id = 0,
a_call_by_reference = true 
)

Constructor public.

Parameters:
integer reference_id or object_id
boolean treat the id as reference_id (true) or object_id (false)

Definition at line 187 of file class.ilObjSurvey.php.

References ilObject::ilObject().

Referenced by _getGlobalSurveyData(), and _isComplete().

        {
                global $ilUser;
                $this->type = "svy";
                $this->ilObject($a_id,$a_call_by_reference);

                $this->survey_id = -1;
                $this->introduction = "";
                $this->outro = $this->lng->txt("survey_finished");
                $this->author = $ilUser->fullname;
                $this->status = STATUS_OFFLINE;
                $this->evaluation_access = EVALUATION_ACCESS_OFF;
                $this->startdate_enabled = 0;
                $this->enddate_enabled = 0;
                $this->questions = array();
                $this->invitation = INVITATION_OFF;
                $this->invitation_mode = MODE_PREDEFINED_USERS;
                $this->anonymize = ANONYMIZE_OFF;
                $this->display_question_titles = QUESTIONTITLES_VISIBLE;
                $this->surveyCodeSecurity = TRUE;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::importObject ( file_info,
survey_questionpool_id 
)

Imports a survey from XML into the ILIAS database.

Imports a survey from XML into the ILIAS database

Returns:
boolean True, if the import succeeds, false otherwise public

Definition at line 4259 of file class.ilObjSurvey.php.

References $_SESSION, $ilLog, ilRTE::_replaceMediaObjectImageSrc(), ilObjMediaObject::_saveTempFileAsMediaObject(), ilObjMediaObject::_saveUsage(), ilUtil::delDir(), ilObject::getId(), getImportDirectory(), getIntroduction(), getOutro(), locateImportFiles(), ilUtil::moveUploadedFile(), saveToDb(), setIntroduction(), setOutro(), and ilUtil::unzip().

        {
                // check if file was uploaded
                $source = $file_info["tmp_name"];
                $error = "";
                if (($source == 'none') || (!$source) || $file_info["error"] > UPLOAD_ERR_OK)
                {
                        $error = $this->lng->txt("import_no_file_selected");
                }
                // check correct file type
                $isXml = FALSE;
                $isZip = FALSE;
                if ((strcmp($file_info["type"], "text/xml") == 0) || (strcmp($file_info["type"], "application/xml") == 0))
                {
                        $isXml = TRUE;
                }
                if (strpos($file_info["type"], "zip") !== FALSE)
                {
                        $isZip = TRUE;
                }
                if (!$isXml && !$isZip)
                {
                        $error = $this->lng->txt("import_wrong_file_type");
                        global $ilLog;
                        $ilLog->write("Survey: Import error. Filetype was \"" . $file_info["type"] ."\"");
                }
                if (strlen($error) == 0)
                {
                        // import file as a survey
                        $import_dir = $this->getImportDirectory();
                        $import_subdir = "";
                        $importfile = "";
                        include_once "./Services/Utilities/classes/class.ilUtil.php";
                        if ($isZip)
                        {
                                $importfile = $import_dir."/".$file_info["name"];
                                ilUtil::moveUploadedFile($source, $file_info["name"], $importfile);
                                ilUtil::unzip($importfile);
                                $found = $this->locateImportFiles($import_dir);
                                if (!((strlen($found["dir"]) > 0) && (strlen($found["xml"]) > 0)))
                                {
                                        $error = $this->lng->txt("wrong_import_file_structure");
                                        return $error;
                                }
                                $importfile = $found["xml"];
                                $import_subdir = $found["dir"];
                        }
                        else
                        {
                                $importfile = tempnam($import_dir, "survey_import");
                                ilUtil::moveUploadedFile($source, $file_info["name"], $importfile);
                        }
                        $fh = fopen($importfile, "r");
                        if (!$fh)
                        {
                                $error = $this->lng->txt("import_error_opening_file");
                                return $error;
                        }
                        $xml = fread($fh, filesize($importfile));
                        $result = fclose($fh);
                        if (!$result)
                        {
                                $error = $this->lng->txt("import_error_closing_file");
                                return $error;
                        }

                        unset($_SESSION["import_mob_xhtml"]);
                        if (strpos($xml, "questestinterop"))
                        {
                                include_once "./Services/Survey/classes/class.SurveyImportParserPre38.php";
                                include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
                                $spl = new ilObjSurveyQuestionPool($survey_questionpool_id, FALSE);
                                $import = new SurveyImportParserPre38($spl, "", TRUE);
                                $import->setSurveyObject($this);
                                $import->setXMLContent($xml);
                                $import->startParsing();
                        }
                        else
                        {
                                include_once "./Services/Survey/classes/class.SurveyImportParser.php";
                                include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
                                $spl = new ilObjSurveyQuestionPool($survey_questionpool_id, FALSE);
                                $import = new SurveyImportParser($spl, "", TRUE);
                                $import->setSurveyObject($this);
                                $import->setXMLContent($xml);
                                $import->startParsing();
                        }

                        if (is_array($_SESSION["import_mob_xhtml"]))
                        {
                                include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
                                include_once "./Services/RTE/classes/class.ilRTE.php";
                                include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
                                foreach ($_SESSION["import_mob_xhtml"] as $mob)
                                {
                                        $importfile = $import_subdir . "/" . $mob["uri"];
                                        if (file_exists($importfile))
                                        {
                                                $media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
                                                ilObjMediaObject::_saveUsage($media_object->getId(), "svy:html", $this->getId());
                                                $this->setIntroduction(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $this->getIntroduction()));
                                                $this->setOutro(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $this->getOutro()));
                                        }
                                        else
                                        {
                                                global $ilLog;
                                                $ilLog->write("Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
                                        }
                                }
                                $this->setIntroduction(ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 1));
                                $this->setOutro(ilRTE::_replaceMediaObjectImageSrc($this->getOutro(), 1));
                                $this->saveToDb();
                        }

                        // delete import directory
                        ilUtil::delDir($this->getImportDirectory());
                }
                return $error;
        }

Here is the call graph for this function:

ilObjSurvey::insertQuestion ( question_id  ) 

Inserts a question in the survey and saves the relation to the database.

Inserts a question in the survey and saves the relation to the database

public

Definition at line 649 of file class.ilObjSurvey.php.

References SurveyQuestion::_isComplete(), duplicateQuestionForSurvey(), and loadQuestionsFromDb().

        {
                global $ilDB;
                
                include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                if (!SurveyQuestion::_isComplete($question_id))
                {
                        return FALSE;
                }
                else
                {
                        // get maximum sequence index in test
                        $query = sprintf("SELECT survey_question_id FROM survey_survey_question WHERE survey_fi = %s",
                                $ilDB->quote($this->getSurveyId())
                        );
                        $result = $ilDB->query($query);
                        $sequence = $result->numRows();
                        $duplicate_id = $this->duplicateQuestionForSurvey($question_id);
                        $query = sprintf("INSERT INTO survey_survey_question (survey_question_id, survey_fi, question_fi, sequence, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)",
                                $ilDB->quote($this->getSurveyId()),
                                $ilDB->quote($duplicate_id),
                                $ilDB->quote($sequence)
                        );
                        $result = $ilDB->query($query);
                        if ($result != DB_OK) 
                        {
                                // Error
                        }
                        $this->loadQuestionsFromDb();
                        return TRUE;
                }
        }

Here is the call graph for this function:

ilObjSurvey::insertQuestionblock ( questionblock_id  ) 

Inserts a questionblock in the survey and saves the relation to the database.

Inserts a questionblock in the survey and saves the relation to the database

public

Definition at line 691 of file class.ilObjSurvey.php.

References $questions, ilObject::$title, createQuestionblock(), and duplicateQuestionForSurvey().

        {
                global $ilDB;
                $query = sprintf("SELECT survey_questionblock.title, survey_questionblock.show_questiontext, survey_questionblock_question.question_fi FROM survey_questionblock, survey_questionblock_question, survey_survey_question WHERE survey_questionblock.questionblock_id = survey_questionblock_question.questionblock_fi AND survey_survey_question.question_fi = survey_questionblock_question.question_fi AND survey_questionblock.questionblock_id = %s ORDER BY survey_survey_question.sequence",
                        $ilDB->quote($questionblock_id)
                );
                $result = $ilDB->query($query);
                $questions = array();
                $show_questiontext = 0;
                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $duplicate_id = $this->duplicateQuestionForSurvey($row["question_fi"]);
                        array_push($questions, $duplicate_id);
                        $title = $row["title"];
                        $show_questiontext = $row["show_questiontext"];
                }
                $this->createQuestionblock($title, $show_questiontext, $questions);
        }

Here is the call graph for this function:

ilObjSurvey::inviteGroup ( group_id  ) 

Invites a group to a survey.

Invites a group to a survey

Parameters:
integer $group_id The database id of the invited group public

Definition at line 3057 of file class.ilObjSurvey.php.

References ilObjUser::_lookupLogin(), ilObject::getId(), getInvitation(), ilObject::getRefId(), and inviteUser().

        {
                global $ilAccess;
                $invited = 0;
                include_once "./classes/class.ilObjGroup.php";
                $group = new ilObjGroup($group_id);
                $members = $group->getGroupMemberIds();
                foreach ($members as $user_id)
                {
                        if ($ilAccess->checkAccessOfUser($user_id, "read", "", $this->getRefId(), "svy", $this->getId()))
                        {
                                $this->inviteUser($user_id);
                                if ($this->getInvitation() == INVITATION_ON)
                                {
                                        if (ilObjUser::_lookupLogin($user_id))
                                        {
                                                $userObj = new ilObjUser($user_id);
                                                $userObj->addDesktopItem($this->getRefId(), "svy");
                                                $invited++;
                                        }
                                }
                        }
                }
                return $invited;
        }

Here is the call graph for this function:

ilObjSurvey::inviteRole ( role_id  ) 

Invites a role to a survey.

Invites a role to a survey

Parameters:
integer $role_id The database id of the invited role public

Definition at line 3091 of file class.ilObjSurvey.php.

References ilObjUser::_lookupLogin(), ilObject::getId(), getInvitation(), ilObject::getRefId(), and inviteUser().

        {
                global $rbacreview;
                global $ilAccess;
                $invited = 0;
                $members = $rbacreview->assignedUsers($role_id);
                foreach ($members as $user_id)
                {
                        if ($ilAccess->checkAccessOfUser($user_id, "read", "", $this->getRefId(), "svy", $this->getId()))
                        {
                                $this->inviteUser($user_id);
                                if ($this->getInvitation() == INVITATION_ON)
                                {
                                        if (ilObjUser::_lookupLogin($user_id))
                                        {
                                                $userObj = new ilObjUser($user_id);
                                                $userObj->addDesktopItem($this->getRefId(), "svy");
                                                $invited++;
                                        }
                                }
                        }
                }
                return $invited;
        }

Here is the call graph for this function:

ilObjSurvey::inviteUser ( user_id  ) 

Invites a user to a survey.

Invites a user to a survey

Parameters:
integer $user_id The database id of the invited user public

Definition at line 3021 of file class.ilObjSurvey.php.

References ilObjUser::_lookupLogin(), getInvitation(), ilObject::getRefId(), and getSurveyId().

Referenced by inviteGroup(), and inviteRole().

        {
                global $ilDB;
                
                $query = sprintf("SELECT user_fi FROM survey_invited_user WHERE user_fi = %s AND survey_fi = %s",
                        $ilDB->quote($user_id),
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                if ($result->numRows() < 1)
                {
                        $query = sprintf("INSERT INTO survey_invited_user (invited_user_id, survey_fi, user_fi, TIMESTAMP) VALUES (NULL, %s, %s, NULL)",
                                $ilDB->quote($this->getSurveyId()),
                                $ilDB->quote($user_id)
                        );
                        $result = $ilDB->query($query);
                }
                if ($this->getInvitation() == INVITATION_ON)
                {
                        include_once './Services/User/classes/class.ilObjUser.php';
                        if (ilObjUser::_lookupLogin($user_id))
                        {
                                $userObj = new ilObjUser($user_id);
                                $userObj->addDesktopItem($this->getRefId(), "svy");
                        }
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::isAccessibleWithoutCode (  ) 

Checks if the survey is accessable without a survey code.

Returns:
boolean status

Definition at line 986 of file class.ilObjSurvey.php.

References getAnonymize().

Referenced by getUserSurveyCode(), isAllowedToTakeMultipleSurveys(), and isSurveyStarted().

        {
                if ($this->getAnonymize() == ANONYMIZE_FREEACCESS)
                {
                        return true;
                }
                else
                {
                        return false;
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::isAllowedToTakeMultipleSurveys ( userid = ""  ) 

Checks if a user is allowed to take multiple survey.

Checks if a user is allowed to take multiple survey

Parameters:
int $userid user id of the user
Returns:
boolean TRUE if the user is allowed to take the survey more than once, FALSE otherwise public

Definition at line 3305 of file class.ilObjSurvey.php.

References $ilSetting, getAnonymize(), and isAccessibleWithoutCode().

Referenced by getUserSurveyCode(), and isSurveyStarted().

        {
                $result = FALSE;
                if ($this->getAnonymize())
                {
                        if ($this->isAccessibleWithoutCode())
                        {
                                if (strlen($username) == 0)
                                {
                                        global $ilUser;
                                        $userid = $ilUser->getId();
                                }
                                global $ilSetting;
                                $surveysetting = new ilSetting("survey");
                                $allowedUsers = strlen($surveysetting->get("multiple_survey_users")) ? explode(",",$surveysetting->get("multiple_survey_users")) : array();
                                if (in_array($userid, $allowedUsers))
                                {
                                        $result = TRUE;
                                }
                        }
                }
                return $result;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::isAnonymizedParticipant ( key  ) 

Definition at line 4775 of file class.ilObjSurvey.php.

References getSurveyId().

        {
                global $ilDB;
                
                $query = sprintf("SELECT finished_id FROM survey_finished WHERE anonymous_id = %s AND survey_fi = %s",
                        $ilDB->quote($key . ""),
                        $ilDB->quote($this->getSurveyId() . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows() == 1)
                {
                        return true;
                }
                else
                {
                        return false;
                }
        }

Here is the call graph for this function:

ilObjSurvey::isAnonymousKey ( key  ) 

Definition at line 4735 of file class.ilObjSurvey.php.

References getSurveyId().

Referenced by checkSurveyCode().

        {
                global $ilDB;
                
                $query = sprintf("SELECT anonymous_id FROM survey_anonymous WHERE survey_key = %s AND survey_fi = %s",
                        $ilDB->quote($key . ""),
                        $ilDB->quote($this->getSurveyId() . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows() == 1)
                {
                        return true;
                }
                else
                {
                        return false;
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::isComplete (  ) 

Returns true, if a survey is complete for use.

Returns true, if a survey is complete for use

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

Definition at line 538 of file class.ilObjSurvey.php.

References getAuthor(), and ilObject::getTitle().

Referenced by saveCompletionStatus(), and saveToDb().

        {
                if (($this->getTitle()) and ($this->getAuthor()) and (count($this->questions)))
                {
                        return true;
                } 
                        else 
                {
                        return false;
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::isHTML ( a_text  ) 

Checks if a given string contains HTML or not.

Parameters:
string $a_text Text which should be checked
Returns:
boolean public

Definition at line 5153 of file class.ilObjSurvey.php.

Referenced by addMaterialTag().

        {
                if (preg_match("/<[^>]*?>/", $a_text))
                {
                        return TRUE;
                }
                else
                {
                        return FALSE; 
                }
        }

Here is the caller graph for this function:

ilObjSurvey::isOffline (  ) 

Gets the survey status.

Gets the survey status

Returns:
integer true if status is online, false otherwise public
See also:
$status

Definition at line 1525 of file class.ilObjSurvey.php.

        {
    if ($this->status == STATUS_OFFLINE)
                {
                        return true;
                }
                else
                {
                        return false;
                }
  }

ilObjSurvey::isOnline (  ) 

Gets the survey status.

Gets the survey status

Returns:
integer true if status is online, false otherwise public
See also:
$status

Definition at line 1504 of file class.ilObjSurvey.php.

        {
    if ($this->status == STATUS_ONLINE)
                {
                        return true;
                }
                else
                {
                        return false;
                }
  }

ilObjSurvey::isSurveyCodeUsed ( code  ) 

Definition at line 4939 of file class.ilObjSurvey.php.

Referenced by createNewAccessCode(), getSurveyCodesForExport(), and getSurveyCodesTableData().

        {
                global $ilDB;
                $query = sprintf("SELECT finished_id FROM survey_finished WHERE survey_fi = %s AND anonymous_id = %s",
                        $ilDB->quote($this->getSurveyId() . ""),
                        $ilDB->quote($code)
                );
                $result = $ilDB->query($query);
                if ($result->numRows() > 0)
                {
                        return TRUE;
                }
                else
                {
                        return FALSE;
                }
        }

Here is the caller graph for this function:

ilObjSurvey::isSurveyStarted ( user_id,
anonymize_id 
)

Checks if a user already started a survey.

Checks if a user already started a survey

Parameters:
integer $user_id The database id of the user
Returns:
mixed false, if the user has not started the survey, 0 if the user has started the survey but not finished it, 1 if the user has finished the survey public

Definition at line 3338 of file class.ilObjSurvey.php.

References $_SESSION, getAnonymize(), isAccessibleWithoutCode(), and isAllowedToTakeMultipleSurveys().

Referenced by canStartSurvey(), and checkSurveyCode().

        {
                global $ilDB;

                if ($this->getAnonymize())
                {
                        if ((($user_id != ANONYMOUS_USER_ID) && (strlen($anonymize_id) == 0)) && (!($this->isAccessibleWithoutCode() && $this->isAllowedToTakeMultipleSurveys())))
                        {
                                $query = sprintf("SELECT * FROM survey_finished WHERE survey_fi = %s AND user_fi = %s",
                                        $ilDB->quote($this->getSurveyId()),
                                        $ilDB->quote($user_id)
                                );
                        }
                        else
                        {
                                $query = sprintf("SELECT * FROM survey_finished WHERE survey_fi = %s AND anonymous_id = %s",
                                        $ilDB->quote($this->getSurveyId()),
                                        $ilDB->quote($anonymize_id)
                                );
                        }
                }
                else
                {
                        $query = sprintf("SELECT * FROM survey_finished WHERE survey_fi = %s AND user_fi = %s",
                                $ilDB->quote($this->getSurveyId()),
                                $ilDB->quote($user_id)
                        );
                }
                $result = $ilDB->query($query);
                if ($result->numRows() == 0)
                {
                        return false;
                }                       
                else
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        $_SESSION["finished_id"] = $row["finished_id"];
                        return (int)$row["state"];
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::loadFromDb (  ) 

Loads a survey object from a database.

Loads a survey object from a database

public

Definition at line 1005 of file class.ilObjSurvey.php.

References $data, ilRTE::_replaceMediaObjectImageSrc(), getAuthor(), loadQuestionsFromDb(), saveAuthorToMetadata(), setAnonymize(), and setOutro().

Referenced by cloneObject(), and read().

  {
                global $ilDB;
    $query = sprintf("SELECT * FROM survey_survey WHERE obj_fi = %s",
      $ilDB->quote($this->getId())
    );
    $result = $ilDB->query($query);
    if (strcmp(strtolower(get_class($result)), db_result) == 0) 
                {
      if ($result->numRows() == 1) 
                        {
                                $data = $result->fetchRow(DB_FETCHMODE_OBJECT);
                                $this->survey_id = $data->survey_id;
                                if (strlen($this->getAuthor()) == 0)
                                {
                                        $this->saveAuthorToMetadata($data->author);
                                }
                                $this->author = $this->getAuthor();
                                include_once("./Services/RTE/classes/class.ilRTE.php");
                                $this->introduction = ilRTE::_replaceMediaObjectImageSrc($data->introduction, 1);
                                if (strcmp($data->outro, "survey_finished") == 0)
                                {
                                        $this->setOutro($this->lng->txt("survey_finished"));
                                }
                                else
                                {
                                        $this->setOutro(ilRTE::_replaceMediaObjectImageSrc($data->outro, 1));
                                }
                                $this->status = $data->status;
                                $this->invitation = $data->invitation;
                                $this->invitation_mode = $data->invitation_mode;
                                $this->display_question_titles = $data->show_question_titles;
                                $this->start_date = $data->startdate;
                                if (!$data->startdate)
                                {
                                        $this->startdate_enabled = 0;
                                }
                                else
                                {
                                        $this->startdate_enabled = 1;
                                }
        $this->end_date = $data->enddate;
                                if (!$data->enddate)
                                {
                                        $this->enddate_enabled = 0;
                                }
                                else
                                {
                                        $this->enddate_enabled = 1;
                                }
                                switch ($data->anonymize)
                                {
                                        case ANONYMIZE_OFF:
                                        case ANONYMIZE_ON:
                                        case ANONYMIZE_FREEACCESS:
                                                $this->setAnonymize($data->anonymize);
                                                break;
                                        default:
                                                $this->setAnonymize(ANONYMIZE_OFF);
                                                break;
                                }
        $this->evaluation_access = $data->evaluation_access;
                                $this->loadQuestionsFromDb();
      }
    }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::loadQuestionsFromDb (  ) 

Loads the survey questions from the database.

Loads the survey questions from the database

public

See also:
$questions

Definition at line 1080 of file class.ilObjSurvey.php.

References $data.

Referenced by insertQuestion(), and loadFromDb().

        {
                global $ilDB;
                $this->questions = array();
                $query = sprintf("SELECT * FROM survey_survey_question WHERE survey_fi = %s ORDER BY sequence",
                        $ilDB->quote($this->survey_id)
                );
                $result = $ilDB->query($query);
                while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT)) 
                {
                        $this->questions[$data->sequence] = $data->question_fi;
                }
        }

Here is the caller graph for this function:

ilObjSurvey::loadWorkingData ( question_id,
active_id 
)

Gets the working data of question from the database.

Gets the working data of question from the database

Parameters:
integer $question_id The database id of the question
integer $active_id The active id of the user who worked through the question
Returns:
array The resulting database dataset as an array public

Definition at line 3195 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                $result_array = array();
                $query = sprintf("SELECT * FROM survey_answer WHERE question_fi = %s AND active_fi = %s",
                        $ilDB->quote($question_id. ""),
                        $ilDB->quote($active_id)
                );
                $result = $ilDB->query($query);
                if ($result->numRows() >= 1)
                {
                        while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                array_push($result_array, $row);
                        }
                        return $result_array;
                }
                else
                {
                        return $result_array;
                }
        }

ilObjSurvey::locateImportFiles ( a_dir  ) 

Locates the import directory and the xml file in a directory with an unzipped import file.

Locates the import directory and the xml file in a directory with an unzipped import file

Returns:
array An associative array containing "dir" (import directory) and "xml" (xml file) private

Definition at line 4205 of file class.ilObjSurvey.php.

References $file, and $files.

Referenced by importObject().

        {
                if (!is_dir($a_dir) || is_int(strpos($a_dir, "..")))
                {
                        return;
                }
                $importDirectory = "";
                $xmlFile = "";

                $current_dir = opendir($a_dir);
                $files = array();
                while($entryname = readdir($current_dir))
                {
                        $files[] = $entryname;
                }

                foreach($files as $file)
                {
                        if(is_dir($a_dir."/".$file) and ($file != "." and $file!=".."))
                        {
                                // found directory created by zip
                                $importDirectory = $a_dir."/".$file;
                        }
                }
                closedir($current_dir);
                if (strlen($importDirectory))
                {
                        // find the xml file
                        $current_dir = opendir($importDirectory);
                        $files = array();
                        while($entryname = readdir($current_dir))
                        {
                                $files[] = $entryname;
                        }
                        foreach($files as $file)
                        { 
                                if(@is_file($importDirectory."/".$file) && ($file != "." && $file!="..") && (strcmp(strtolower(substr($file, -4, 4)), ".xml") == 0))
                                {
                                        // found xml file
                                        $xmlFile = $importDirectory."/".$file;
                                }
                        }
                }
                return array("dir" => $importDirectory, "xml" => $xmlFile);
        }

Here is the caller graph for this function:

ilObjSurvey::modifyQuestionblock ( questionblock_id,
title,
show_questiontext 
)

Modifies a question block.

Modifies a question block

Parameters:
integer $questionblock_id The database id of the question block
string $title The title of the question block public

Definition at line 2401 of file class.ilObjSurvey.php.

References ilObject::$title.

        {
                global $ilDB;
                $query = sprintf("UPDATE survey_questionblock SET title = %s, show_questiontext = %s WHERE questionblock_id = %s",
                        $ilDB->quote($title),
                        $ilDB->quote($show_questiontext . ""),
                        $ilDB->quote($questionblock_id)
                );
                $result = $ilDB->query($query);
        }

ilObjSurvey::moveDownQuestion ( question_id  ) 

Moves a question down in the list of survey questions.

Moves a question down in the list of survey questions

Parameters:
integer $question_id The question id of the question which has to be moved down public

Definition at line 1947 of file class.ilObjSurvey.php.

References $questions, getSurveyPages(), getSurveyQuestions(), and moveQuestions().

        {
                $move_questions = array($question_id);
                $pages =& $this->getSurveyPages();
                $pageindex = -1;
                foreach ($pages as $idx => $page)
                {
                        if (($page[0]["question_id"] == $question_id) && (strcmp($page[0]["questionblock_id"], "") == 0))
                        {
                                $pageindex = $idx;
                        }
                }
                if (($pageindex < count($pages)-1) && ($pageindex >= 0))
                {
                        $this->moveQuestions($move_questions, $pages[$pageindex+1][count($pages[$pageindex+1])-1]["question_id"], 1);
                }
                else
                {
                        // move down a question in a questionblock
                        $questions = $this->getSurveyQuestions();
                        $questions = array_keys($questions);
                        $index = array_search($question_id, $questions);
                        if (($index !== FALSE) && ($index < count($questions)-1))
                        {
                                $this->moveQuestions($move_questions, $questions[$index+1], 1);
                        }
                }
        }

Here is the call graph for this function:

ilObjSurvey::moveDownQuestionblock ( questionblock_id  ) 

Moves a questionblock down in the list of survey questions.

Moves a questionblock down in the list of survey questions

Parameters:
integer $questionblock_id The questionblock id of the questionblock which has to be moved down public

Definition at line 2014 of file class.ilObjSurvey.php.

References getSurveyPages(), and moveQuestions().

        {
                $pages =& $this->getSurveyPages();
                $move_questions = array();
                $pageindex = -1;
                foreach ($pages as $idx => $page)
                {
                        if ($page[0]["questionblock_id"] == $questionblock_id)
                        {
                                foreach ($page as $pageidx => $question)
                                {
                                        array_push($move_questions, $question["question_id"]);
                                }
                                $pageindex = $idx;
                        }
                }
                if ($pageindex < count($pages)-1)
                {
                        $this->moveQuestions($move_questions, $pages[$pageindex+1][count($pages[$pageindex+1])-1]["question_id"], 1);
                }
        }

Here is the call graph for this function:

ilObjSurvey::moveQuestions ( move_questions,
target_index,
insert_mode 
)

Move questions and/or questionblocks to another position.

Move questions and/or questionblocks to another position

Parameters:
array $move_questions An array with the question id's of the questions to move
integer $target_index The question id of the target position
integer $insert_mode 0, if insert before the target position, 1 if insert after the target position public

Definition at line 2046 of file class.ilObjSurvey.php.

References deleteConstraint(), getConstraints(), and saveQuestionsToDb().

Referenced by createQuestionblock(), moveDownQuestion(), moveDownQuestionblock(), moveUpQuestion(), and moveUpQuestionblock().

        {
                $array_pos = array_search($target_index, $this->questions);
                if ($insert_mode == 0)
                {
                        $part1 = array_slice($this->questions, 0, $array_pos);
                        $part2 = array_slice($this->questions, $array_pos);
                }
                else if ($insert_mode == 1)
                {
                        $part1 = array_slice($this->questions, 0, $array_pos + 1);
                        $part2 = array_slice($this->questions, $array_pos + 1);
                }
                foreach ($move_questions as $question_id)
                {
                        if (!(array_search($question_id, $part1) === FALSE))
                        {
                                unset($part1[array_search($question_id, $part1)]);
                        }
                        if (!(array_search($question_id, $part2) === FALSE))
                        {
                                unset($part2[array_search($question_id, $part2)]);
                        }
                }
                $part1 = array_values($part1);
                $part2 = array_values($part2);
                $this->questions = array_values(array_merge($part1, $move_questions, $part2));
                foreach ($move_questions as $question_id)
                {
                        $constraints = $this->getConstraints($question_id);
                        foreach ($constraints as $idx => $constraint)
                        {
                                foreach ($part2 as $next_question_id)
                                {
                                        if ($constraint["question"] == $next_question_id)
                                        {
                                                // constraint concerning a question that follows -> delete constraint
                                                $this->deleteConstraint($constraint["id"], $question_id);
                                        }
                                }
                        }
                }
                $this->saveQuestionsToDb();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::moveUpQuestion ( question_id  ) 

Moves a question up in the list of survey questions.

Moves a question up in the list of survey questions

Parameters:
integer $question_id The question id of the question which has to be moved up public

Definition at line 1910 of file class.ilObjSurvey.php.

References $questions, getSurveyPages(), getSurveyQuestions(), and moveQuestions().

        {
                $move_questions = array($question_id);
                $pages =& $this->getSurveyPages();
                $pageindex = -1;
                foreach ($pages as $idx => $page)
                {
                        if ($page[0]["question_id"] == $question_id)
                        {
                                $pageindex = $idx;
                        }
                }
                if ($pageindex > 0)
                {
                        $this->moveQuestions($move_questions, $pages[$pageindex-1][0]["question_id"], 0);
                }
                else
                {
                        // move up a question in a questionblock
                        $questions = $this->getSurveyQuestions();
                        $questions = array_keys($questions);
                        $index = array_search($question_id, $questions);
                        if (($index !== FALSE) && ($index > 0))
                        {
                                $this->moveQuestions($move_questions, $questions[$index-1], 0);
                        }
                }
        }

Here is the call graph for this function:

ilObjSurvey::moveUpQuestionblock ( questionblock_id  ) 

Moves a questionblock up in the list of survey questions.

Moves a questionblock up in the list of survey questions

Parameters:
integer $questionblock_id The questionblock id of the questionblock which has to be moved up public

Definition at line 1984 of file class.ilObjSurvey.php.

References getSurveyPages(), and moveQuestions().

        {
                $pages =& $this->getSurveyPages();
                $move_questions = array();
                $pageindex = -1;
                foreach ($pages as $idx => $page)
                {
                        if ($page[0]["questionblock_id"] == $questionblock_id)
                        {
                                foreach ($page as $pageidx => $question)
                                {
                                        array_push($move_questions, $question["question_id"]);
                                }
                                $pageindex = $idx;
                        }
                }
                if ($pageindex > 0)
                {
                        $this->moveQuestions($move_questions, $pages[$pageindex-1][0]["question_id"], 0);
                }
        }

Here is the call graph for this function:

ilObjSurvey::notify ( a_event,
a_ref_id,
a_parent_non_rbac_id,
a_node_id,
a_params = 0 
)

notifys an object about an event occured Based on the event happend, each object may decide how it reacts.

If you are not required to handle any events related to your module, just delete this method. (For an example how this method is used, look at ilObjGroup)

public

Parameters:
string event
integer reference id of object where the event occured
array passes optional parameters if required
Returns:
boolean

Reimplemented from ilObject.

Definition at line 477 of file class.ilObjSurvey.php.

References $_GET, and ilObject::getType().

        {
                global $tree;
                
                switch ($a_event)
                {
                        case "link":
                                
                                //var_dump("<pre>",$a_params,"</pre>");
                                //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
                                //exit;
                                break;
                        
                        case "cut":
                                
                                //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
                                //exit;
                                break;
                                
                        case "copy":
                        
                                //var_dump("<pre>",$a_params,"</pre>");
                                //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
                                //exit;
                                break;

                        case "paste":
                                
                                //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
                                //exit;
                                break;
                        
                        case "new":
                                
                                //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
                                //exit;
                                break;
                }
                
                // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
                if ($a_node_id==$_GET["ref_id"])
                {       
                        $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
                        $parent_type = $parent_obj->getType();
                        if($parent_type == $this->getType())
                        {
                                $a_node_id = (int) $tree->getParentId($a_node_id);
                        }
                }
                
                parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
        }

Here is the call graph for this function:

ilObjSurvey::prepareTextareaOutput ( txt_output  ) 

Prepares a string for a text area output in surveys.

Parameters:
string $txt_output String which should be prepared for output public

Definition at line 5140 of file class.ilObjSurvey.php.

        {
                include_once "./Services/Utilities/classes/class.ilUtil.php";
                return ilUtil::prepareTextareaOutput($txt_output, $prepare_for_latex_output);
        }

& ilObjSurvey::processCSVRow ( row,
quoteAll = FALSE,
separator = ";" 
)

Convertes an array for CSV usage.

Processes an array as a CSV row and converts the array values to correct CSV values. The "converted" array is returned

Parameters:
array $row The array containing the values for a CSV row
string $quoteAll Indicates to quote every value (=TRUE) or only values containing quotes and separators (=FALSE, default)
string $separator The value separator in the CSV row (used for quoting) (; = default)
Returns:
array The converted array ready for CSV use public

Definition at line 5073 of file class.ilObjSurvey.php.

References $separator.

        {
                $resultarray = array();
                foreach ($row as $rowindex => $entry)
                {
                        $surround = FALSE;
                        if ($quoteAll)
                        {
                                $surround = TRUE;
                        }
                        if (strpos($entry, "\"") !== FALSE)
                        {
                                $entry = str_replace("\"", "\"\"", $entry);
                                $surround = TRUE;
                        }
                        if (strpos($entry, $separator) !== FALSE)
                        {
                                $surround = TRUE;
                        }
                        // replace all CR LF with LF (for Excel for Windows compatibility
                        $entry = str_replace(chr(13).chr(10), chr(10), $entry);
                        if ($surround)
                        {
                                $resultarray[$rowindex] = utf8_decode("\"" . $entry . "\"");
                        }
                        else
                        {
                                $resultarray[$rowindex] = utf8_decode($entry);
                        }
                }
                return $resultarray;
        }

ilObjSurvey::processPrintoutput2FO ( print_output  ) 

Convert a print output to XSL-FO.

Convert a print output to XSL-FO

Parameters:
string $print_output The print output
Returns:
string XSL-FO code public

Definition at line 5238 of file class.ilObjSurvey.php.

References $ilLog, xslt_create(), xslt_error(), xslt_free(), and xslt_process().

        {
                $print_output = str_replace("&nbsp;", "&#160;", $print_output);
                $print_output = str_replace("&otimes;", "X", $print_output);
                $xsl = file_get_contents("./Modules/Survey/xml/question2fo.xsl");
                $args = array( '/_xml' => $print_output, '/_xsl' => $xsl );
                $xh = xslt_create();
                $params = array();
                $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
                xslt_error($xh);
                xslt_free($xh);
                global $ilLog; $ilLog->write($output);
                return $output;
        }

Here is the call graph for this function:

ilObjSurvey::read ( a_force_db = false  ) 

read object data from db into object

Parameters:
boolean public

Reimplemented from ilObject.

Definition at line 266 of file class.ilObjSurvey.php.

References loadFromDb().

        {
                parent::read($a_force_db);
                $this->loadFromDb();
        }

Here is the call graph for this function:

ilObjSurvey::removeConstraintsConcerningQuestion ( question_id  ) 

Remove constraints concerning a question with a given question_id.

Remove constraints concerning a question with a given question_id

Parameters:
integer $question_id The database id of the question public

Definition at line 2115 of file class.ilObjSurvey.php.

References getSurveyId().

Referenced by removeQuestion().

        {
                global $ilDB;
                $query = sprintf("SELECT constraint_fi FROM survey_question_constraint WHERE question_fi = %s AND survey_fi = %s",
                        $ilDB->quote($question_id . ""),
                        $ilDB->quote($this->getSurveyId() . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows() > 0)
                {
                        $remove_constraints = array();
                        while ($row = $result->fetchRow(DB_FETCHMODE_HASHREF))
                        {
                                array_push($remove_constraints, $row["constraint_fi"]);
                        }
                        $query = sprintf("DELETE FROM survey_question_constraint WHERE question_fi = %s AND survey_fi = %s",
                                $ilDB->quote($question_id . ""),
                                $ilDB->quote($this->getSurveyId() . "")
                        );
                        $result = $ilDB->query($query);
                        foreach ($remove_constraints as $key => $constraint_id)
                        {
                                $query = sprintf("DELETE FROM survey_constraint WHERE constraint_id = %s",
                                        $ilDB->quote($constraint_id . "")
                                );
                                $result = $ilDB->query($query);
                        }
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::removeQuestion ( question_id  ) 

Remove a question from the survey.

Remove a question from the survey

Parameters:
integer $question_id The database id of the question public

Definition at line 2099 of file class.ilObjSurvey.php.

References _instanciateQuestion(), and removeConstraintsConcerningQuestion().

Referenced by delete(), and removeQuestions().

        {
                include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                $question =& $this->_instanciateQuestion($question_id);
                $question->delete($question_id);
                $this->removeConstraintsConcerningQuestion($question_id);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::removeQuestions ( remove_questions,
remove_questionblocks 
)

Remove questions from the survey.

Remove questions from the survey

Parameters:
array $remove_questions An array with the question id's of the questions to remove
array $remove_questionblocks An array with the questionblock id's of the questions blocks to remove public

Definition at line 2154 of file class.ilObjSurvey.php.

References $data, $questions, getSurveyId(), getSurveyQuestions(), removeQuestion(), and saveQuestionsToDb().

        {
                global $ilDB;
                $questions =& $this->getSurveyQuestions();
                foreach ($questions as $question_id => $data)
                {
                        if (in_array($question_id, $remove_questions) or in_array($data["questionblock_id"], $remove_questionblocks))
                        {
                                unset($this->questions[array_search($question_id, $this->questions)]);
                                $this->removeQuestion($question_id);
                        }
                }
                foreach ($remove_questionblocks as $questionblock_id)
                {
                        $query = sprintf("DELETE FROM survey_questionblock WHERE questionblock_id = %s",
                                $ilDB->quote($questionblock_id)
                        );
                        $result = $ilDB->query($query);
                        $query = sprintf("DELETE FROM survey_questionblock_question WHERE questionblock_fi = %s AND survey_fi = %s",
                                $ilDB->quote($questionblock_id),
                                $ilDB->quote($this->getSurveyId())
                        );
                        $result = $ilDB->query($query);
                }
                $this->questions = array_values($this->questions);
                $this->saveQuestionsToDb();
        }

Here is the call graph for this function:

ilObjSurvey::removeSelectedSurveyResults ( finished_ids  ) 

Deletes the user data of a given array of survey participants.

Deletes the user data of a given array of survey participants

public

Definition at line 420 of file class.ilObjSurvey.php.

        {
                global $ilDB;
                
                foreach ($finished_ids as $finished_id)
                {
                        $query = sprintf("SELECT finished_id FROM survey_finished WHERE finished_id = %s",
                                $ilDB->quote($finished_id . "")
                        );
                        $result = $ilDB->query($query);
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);

                        $query = sprintf("DELETE FROM survey_answer WHERE active_fi = %s",
                                $ilDB->quote($row["finished_id"] . "")
                        );
                        $result = $ilDB->query($query);

                        $query = sprintf("DELETE FROM survey_finished WHERE finished_id = %s",
                                $ilDB->quote($finished_id . "")
                        );
                        $result = $ilDB->query($query);
                }
        }

ilObjSurvey::saveAuthorToMetadata ( a_author = ""  ) 

Saves an authors name into the lifecycle metadata if no lifecycle metadata exists.

Saves an authors name into the lifecycle metadata if no lifecycle metadata exists This will only be called for conversion of "old" tests where the author hasn't been stored in the lifecycle metadata

Parameters:
string $a_author A string containing the name of the test author private
See also:
$author

Definition at line 1189 of file class.ilObjSurvey.php.

References ilObject::getId(), and ilObject::getType().

Referenced by createMetaData(), and loadFromDb().

        {
                $md =& new ilMD($this->getId(), 0, $this->getType());
                $md_life =& $md->getLifecycle();
                if (!$md_life)
                {
                        if (strlen($a_author) == 0)
                        {
                                global $ilUser;
                                $a_author = $ilUser->getFullname();
                        }
                        
                        $md_life =& $md->addLifecycle();
                        $md_life->save();
                        $con =& $md_life->addContribute();
                        $con->setRole("Author");
                        $con->save();
                        $ent =& $con->addEntity();
                        $ent->setEntity($a_author);
                        $ent->save();
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::saveCompletionStatus (  ) 

Saves the completion status of the survey.

Saves the completion status of the survey

public

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

References isComplete().

        {
                global $ilDB;
                
                $complete = 0;
                if ($this->isComplete()) 
                {
                        $complete = 1;
                }
    if ($this->survey_id > 0) 
                {
                        $query = sprintf("UPDATE survey_survey SET complete = %s WHERE survey_id = %s",
                                $ilDB->quote("$complete"),
                                $ilDB->quote($this->survey_id) 
                        );
      $result = $ilDB->query($query);
                }
        }

Here is the call graph for this function:

ilObjSurvey::saveHeading ( heading = "",
insertbefore 
)

Definition at line 4697 of file class.ilObjSurvey.php.

References getSurveyId().

Referenced by cloneTextblocks().

        {
                global $ilDB;
                if ($heading)
                {
                        $query = sprintf("UPDATE survey_survey_question SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
                                $ilDB->quote($heading),
                                $ilDB->quote($this->getSurveyId() . ""),
                                $ilDB->quote($insertbefore)
                        );
                }
                else
                {
                        $query = sprintf("UPDATE survey_survey_question SET heading=NULL WHERE survey_fi=%s AND question_fi=%s",
                                $ilDB->quote($this->getSurveyId() . ""),
                                $ilDB->quote($insertbefore)
                        );
                }
                $ilDB->query($query);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::saveQuestionsToDb (  ) 

Saves the survey questions to the database.

Saves the survey questions to the database

public

See also:
$questions

Definition at line 843 of file class.ilObjSurvey.php.

Referenced by moveQuestions(), removeQuestions(), and saveToDb().

        {
                global $ilDB;
                // save old questions state
                $old_questions = array();
                $query = sprintf("SELECT * FROM survey_survey_question WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                $old_questions[$row["question_fi"]] = $row;
                        }
                }
                
                // delete existing question relations
    $query = sprintf("DELETE FROM survey_survey_question WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                // create new question relations
                foreach ($this->questions as $key => $value) 
                {
                        $query = sprintf("INSERT INTO survey_survey_question (survey_question_id, survey_fi, question_fi, heading, sequence, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL)",
                                $ilDB->quote($this->getSurveyId() . ""),
                                $ilDB->quote($value . ""),
                                $ilDB->quote($old_questions[$value]["heading"]),
                                $ilDB->quote($key . "")
                        );
                        $result = $ilDB->query($query);
                }
        }

Here is the caller graph for this function:

ilObjSurvey::saveToDb (  ) 

Saves a survey object to a database.

Saves a survey object to a database

public

Definition at line 751 of file class.ilObjSurvey.php.

References ilRTE::_replaceMediaObjectImageSrc(), cleanupMediaobjectUsage(), getAnonymize(), getEndDate(), getOutro(), getShowQuestionTitles(), getStartDate(), isComplete(), and saveQuestionsToDb().

Referenced by createReference(), and importObject().

  {
                global $ilDB;
                $complete = 0;
                if ($this->isComplete()) 
                {
                        $complete = 1;
                }
                $startdate = $this->getStartDate();
                if (!$startdate or !$this->startdate_enabled)
                {
                        $startdate = "NULL";
                }
                else
                {
                        $startdate = $ilDB->quote($startdate);
                }
                $enddate = $this->getEndDate();
                if (!$enddate or !$this->enddate_enabled)
                {
                        $enddate = "NULL";
                }
                else
                {
                        $enddate = $ilDB->quote($enddate);
                }

                // cleanup RTE images
                $this->cleanupMediaobjectUsage();

    if ($this->survey_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_survey (survey_id, obj_fi, author, introduction, outro, status, startdate, enddate, evaluation_access, invitation, invitation_mode, complete, created, anonymize, show_question_titles, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NULL)",
                                $ilDB->quote($this->getId()),
                                $ilDB->quote($this->author . ""),
                                $ilDB->quote(ilRTE::_replaceMediaObjectImageSrc($this->introduction, 0)),
                                $ilDB->quote(ilRTE::_replaceMediaObjectImageSrc($this->getOutro(), 0)),
                                $ilDB->quote($this->status . ""),
                                $startdate,
                                $enddate,
                                $ilDB->quote($this->evaluation_access . ""),
                                $ilDB->quote($this->invitation . ""),
                                $ilDB->quote($this->invitation_mode . ""),
                                $ilDB->quote($complete . ""),
                                $ilDB->quote($this->getAnonymize() . ""),
                                $ilDB->quote($this->getShowQuestionTitles() . ""),
                                $ilDB->quote($created)
      );
      $result = $ilDB->query($query);
      if ($result == DB_OK) 
                        {
        $this->survey_id = $ilDB->getLastInsertId();
      }
    } 
                else 
                {
      // update existing dataset
                        $query = sprintf("UPDATE survey_survey SET author = %s, introduction = %s, outro = %s, status = %s, startdate = %s, enddate = %s, evaluation_access = %s, invitation = %s, invitation_mode = %s, complete = %s, anonymize = %s, show_question_titles = %s WHERE survey_id = %s",
                                $ilDB->quote($this->author . ""),
                                $ilDB->quote(ilRTE::_replaceMediaObjectImageSrc($this->introduction, 0)),
                                $ilDB->quote(ilRTE::_replaceMediaObjectImageSrc($this->getOutro(), 0)),
                                $ilDB->quote($this->status . ""),
                                $startdate,
                                $enddate,
                                $ilDB->quote($this->evaluation_access . ""),
                                $ilDB->quote($this->invitation . ""),
                                $ilDB->quote($this->invitation_mode . ""),
                                $ilDB->quote($complete . ""),
                                $ilDB->quote($this->getAnonymize() . ""),
                                $ilDB->quote($this->getShowQuestionTitles() . ""),
                                $ilDB->quote($this->survey_id)
      );
      $result = $ilDB->query($query);
    }
    if ($result == DB_OK) 
                {
                        // save questions to db
                        $this->saveQuestionsToDb();
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::saveUserAccessCode ( user_id,
access_code 
)

Saves a survey access code for a registered user to the database.

Saves a survey access code for a registered user to the database

Parameters:
int $user_id The database id of the user
string $access_code The survey access code

Definition at line 5025 of file class.ilObjSurvey.php.

References getSurveyId().

        {
                global $ilDB;
                $query = sprintf("INSERT INTO survey_anonymous (survey_key, survey_fi, user_key) VALUES (%s, %s, %s)",
                        $ilDB->quote($access_code . ""),
                        $ilDB->quote($this->getSurveyId() . ""),
                        $ilDB->quote(md5($user_id) . "")
                );
                $result = $ilDB->query($query);
        }

Here is the call graph for this function:

ilObjSurvey::setAnonymize ( a_anonymize  ) 

set anonymize status

Definition at line 966 of file class.ilObjSurvey.php.

Referenced by loadFromDb().

        {
                $this->anonymize = $a_anonymize;
        }

Here is the caller graph for this function:

ilObjSurvey::setAuthor ( author = ""  ) 

Sets the authors name.

Sets the authors name of the ilObjSurvey object

Parameters:
string $author A string containing the name of the test author public
See also:
$author

Definition at line 1173 of file class.ilObjSurvey.php.

References $author.

        {
    $this->author = $author;
  }

ilObjSurvey::setEndDate ( end_date = ""  ) 

Sets the end date of the survey.

Sets the end date of the survey

Parameters:
string $end_date Survey end date (YYYY-MM-DD) public
See also:
$end_date

Definition at line 1741 of file class.ilObjSurvey.php.

References $end_date.

        {
    $this->end_date = $end_date;
  }

ilObjSurvey::setEndDateEnabled ( enabled = false  ) 

Sets the enabled state of the end date.

Sets the enabled state of the end date

Parameters:
boolean $enabled True to enable the end date, false to disable the end date public
See also:
$end_date

Definition at line 1138 of file class.ilObjSurvey.php.

        {
                if ($enabled)
                {
                        $this->enddate_enabled = 1;
                }
                else
                {
                        $this->enddate_enabled = 0;
                }
        }

ilObjSurvey::setEvaluationAccess ( evaluation_access = EVALUATION_ACCESS_OFF  ) 

Sets the learners evaluation access.

Sets the learners evaluation access

Parameters:
integer $evaluation_access The evaluation access public
See also:
$evaluation_access

Definition at line 1832 of file class.ilObjSurvey.php.

References $evaluation_access.

        {
    $this->evaluation_access = $evaluation_access;
  }

ilObjSurvey::setIntroduction ( introduction = ""  ) 

Sets the introduction text.

Sets the introduction text

Parameters:
string $introduction A string containing the introduction public
See also:
$introduction

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

References $introduction.

Referenced by importObject().

        {
    $this->introduction = $introduction;
  }

Here is the caller graph for this function:

ilObjSurvey::setInvitation ( invitation = 0  ) 

Sets the invitation status.

Sets the invitation status

Parameters:
integer $invitation The invitation status public
See also:
$invitation

Definition at line 1296 of file class.ilObjSurvey.php.

References $invitation, $user, ilObjUser::_lookupLogin(), ilObject::getId(), getInvitationMode(), and ilObject::getRefId().

Referenced by setInvitationAndMode(), and setInvitationMode().

        {
                global $ilDB;
                global $ilAccess;
    $this->invitation = $invitation;
                // remove the survey from the personal desktops
                $query = sprintf("DELETE FROM desktop_item WHERE type = %s AND item_id = %s",
                        $ilDB->quote("svy"),
                        $ilDB->quote($this->getRefId())
                );
                $result = $ilDB->query($query);
                if ($invitation == INVITATION_OFF)
                {
                        // already removed prior
                }
                else if ($invitation == INVITATION_ON)
                {
                        if ($this->getInvitationMode() == MODE_UNLIMITED)
                        {
                                $query = "SELECT usr_id FROM usr_data";
                                $result = $ilDB->query($query);
                                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                                {
                                        if ($ilAccess->checkAccessOfUser($row["usr_id"], "read", "", $this->getRefId(), "svy", $this->getId()))
                                        {
                                                $query = sprintf("INSERT INTO desktop_item (user_id, item_id, type, parameters) VALUES (%s, %s, %s, NULL)",
                                                        $ilDB->quote($row["usr_id"]),
                                                        $ilDB->quote($this->getRefId()),
                                                        $ilDB->quote("svy")
                                                );
                                                $insertresult = $ilDB->query($query);
                                        }
                                }
                        }
                        else
                        {
                                $query = sprintf("SELECT user_fi FROM survey_invited_user WHERE survey_fi = %s",
                                        $ilDB->quote($this->getSurveyId())
                                );
                                $result = $ilDB->query($query);
                                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                                {
                                        $query = sprintf("INSERT INTO desktop_item (user_id, item_id, type, parameters) VALUES (%s, %s, %s, NULL)",
                                                $ilDB->quote($row["user_fi"]),
                                                $ilDB->quote($this->getRefId()),
                                                $ilDB->quote("svy")
                                        );
                                        $insertresult = $ilDB->query($query);
                                }
                                $query = sprintf("SELECT group_fi FROM survey_invited_group WHERE survey_fi = %s",
                                        $ilDB->quote($this->getSurveyId())
                                );
                                $result = $ilDB->query($query);
                                include_once "./classes/class.ilObjGroup.php";
                                include_once './Services/User/classes/class.ilObjUser.php';
                                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                                {
                                        $group = new ilObjGroup($row["group_fi"]);
                                        $members = $group->getGroupMemberIds();
                                        foreach ($members as $user_id)
                                        {
                                                if (ilObjUser::_lookupLogin($user_id))
                                                {
                                                        $user = new ilObjUser($user_id);
                                                        $user->addDesktopItem($this->getRefId(), "svy");
                                                }
                                        }
                                }
                        }
                }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::setInvitationAndMode ( invitation = 0,
invitation_mode = 0 
)

Sets the invitation status and mode (a more performant solution if you change both).

Sets the invitation status and mode (a more performant solution if you change both)

Parameters:
integer $invitation The invitation status
integer $invitation_mode The invitation mode public
See also:
$invitation_mode

Definition at line 1406 of file class.ilObjSurvey.php.

References $invitation, $invitation_mode, and setInvitation().

        {
                global $ilDB;
    $this->invitation_mode = $invitation_mode;
                if ($invitation_mode == MODE_UNLIMITED)
                {
                        $query = sprintf("DELETE FROM survey_invited_group WHERE survey_fi = %s",
                                $ilDB->quote($this->getSurveyId())
                        );
                        $result = $ilDB->query($query);
                        $query = sprintf("DELETE FROM survey_invited_user WHERE survey_fi = %s",
                                $ilDB->quote($this->getSurveyId())
                        );
                        $result = $ilDB->query($query);
                }
                // add/remove the survey from personal desktops -> calling getInvitation with the same value makes all changes for the new invitation mode
                $this->setInvitation($invitation);
        }

Here is the call graph for this function:

ilObjSurvey::setInvitationMode ( invitation_mode = 0  ) 

Sets the invitation mode.

Sets the invitation mode

Parameters:
integer $invitation_mode The invitation mode public
See also:
$invitation_mode

Definition at line 1377 of file class.ilObjSurvey.php.

References $invitation_mode, getInvitation(), and setInvitation().

        {
                global $ilDB;
    $this->invitation_mode = $invitation_mode;
                if ($invitation_mode == MODE_UNLIMITED)
                {
                        $query = sprintf("DELETE FROM survey_invited_group WHERE survey_fi = %s",
                                $ilDB->quote($this->getSurveyId())
                        );
                        $result = $ilDB->query($query);
                        $query = sprintf("DELETE FROM survey_invited_user WHERE survey_fi = %s",
                                $ilDB->quote($this->getSurveyId())
                        );
                        $result = $ilDB->query($query);
                }
                // add/remove the survey from personal desktops -> calling getInvitation with the same value makes all changes for the new invitation mode
                $this->setInvitation($this->getInvitation());
  }

Here is the call graph for this function:

ilObjSurvey::setObligatoryStates ( obligatory_questions  ) 

Sets the obligatory states for questions in a survey from the questions form.

Sets the obligatory states for questions in a survey from the questions form

Parameters:
array $obligatory_questions The questions which should be set obligatory from the questions form, the remaining questions should be setted not obligatory public

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

        {
                global $ilDB;
                $query = sprintf("SELECT * FROM survey_survey_question WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId() . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                if (!array_key_exists($row["question_fi"], $obligatory_questions))
                                {
                                        $obligatory_questions[$row["question_fi"]] = 0;
                                }
                        }
                }

          // set the obligatory states in the database
                $query = sprintf("DELETE FROM survey_question_obligatory WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId() . "")
                );
                $result = $ilDB->query($query);

          // set the obligatory states in the database
                foreach ($obligatory_questions as $question_fi => $obligatory)
                {
                        $query = sprintf("INSERT INTO survey_question_obligatory (question_obligatory_id, survey_fi, question_fi, obligatory, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)",
                                $ilDB->quote($this->getSurveyId() . ""),
                                $ilDB->quote($question_fi . ""),
                                $ilDB->quote($obligatory . "")
                        );
                        $result = $ilDB->query($query);
                }
        }

ilObjSurvey::setOutro ( outro = ""  ) 

Sets the outro text.

Sets the outro text

Parameters:
string $outro A string containing the outro public
See also:
$outro

Definition at line 1448 of file class.ilObjSurvey.php.

References $outro.

Referenced by importObject(), and loadFromDb().

        {
    $this->outro = $outro;
  }

Here is the caller graph for this function:

ilObjSurvey::setStartDate ( start_date = ""  ) 

Sets the start date of the survey.

Sets the start date of the survey

Parameters:
string $start_data Survey start date (YYYY-MM-DD) public
See also:
$start_date

Definition at line 1650 of file class.ilObjSurvey.php.

References $start_date.

        {
    $this->start_date = $start_date;
  }

ilObjSurvey::setStartDateEnabled ( enabled = false  ) 

Sets the enabled state of the start date.

Sets the enabled state of the start date

Parameters:
boolean $enabled True to enable the start date, false to disable the start date public
See also:
$start_date

Definition at line 1103 of file class.ilObjSurvey.php.

        {
                if ($enabled)
                {
                        $this->startdate_enabled = 1;
                }
                else
                {
                        $this->startdate_enabled = 0;
                }
        }

ilObjSurvey::setStatus ( status = STATUS_OFFLINE  ) 

Sets the survey status.

Sets the survey status

Parameters:
integer $status Survey status
Returns:
string An error message, if the status cannot be set, otherwise an empty string public
See also:
$status

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

References $status.

        {
                $result = "";
                if (($status == STATUS_ONLINE) && (count($this->questions) == 0))
                {
        $this->status = STATUS_OFFLINE;
                        $result = $this->lng->txt("cannot_switch_to_online_no_questions");
                }
                else
                {
        $this->status = $status;
                }
                return $result;
  }

ilObjSurvey::showQuestionTitles (  ) 

Sets the question titles visible during the query.

Sets the question titles visible during the query

public

See also:
$display_question_titles

Definition at line 1269 of file class.ilObjSurvey.php.

        {
                $this->display_question_titles = QUESTIONTITLES_VISIBLE;
  }

ilObjSurvey::startSurvey ( user_id,
anonymous_id 
)

Starts the survey creating an entry in the database.

Starts the survey creating an entry in the database

Parameters:
integer $user_id The database id of the user who starts the survey public

Definition at line 3226 of file class.ilObjSurvey.php.

References getAnonymize().

        {
                global $ilUser;
                global $ilDB;
                
                if ($this->getAnonymize() && (strlen($anonymous_id) == 0)) return;

                if (strcmp($user_id, "") == 0)
                {
                        if ($user_id == ANONYMOUS_USER_ID)
                        {
                                $user_id = 0;
                        }
                }
                $query = sprintf("INSERT INTO survey_finished (finished_id, survey_fi, user_fi, anonymous_id, state, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL)",
                        $ilDB->quote($this->getSurveyId() . ""),
                        $ilDB->quote($user_id . ""),
                        $ilDB->quote($anonymous_id . ""),
                        $ilDB->quote(0 . "")
                );
                $result = $ilDB->query($query);
                
                // get the insert id, but don't trust last_insert_id since we don't have transactions
                $query = sprintf("SELECT finished_id FROM survey_finished WHERE survey_fi = %s AND user_fi = %s AND anonymous_id = %s",
                        $ilDB->quote($this->getSurveyId() . ""),
                        $ilDB->quote($user_id . ""),
                        $ilDB->quote($anonymous_id . "")
                );
                $result = $ilDB->query($query);
                $insert_id = 0;
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        $insert_id = $row["finished_id"];
                }
                return $insert_id;
        }

Here is the call graph for this function:

ilObjSurvey::toXML (  ) 

Returns a QTI xml representation of the survey.

Returns a QTI xml representation of the survey

Returns:
string The QTI xml representation of the survey public

Definition at line 4007 of file class.ilObjSurvey.php.

References _instanciateQuestion(), addMaterialTag(), getAnonymize(), getAuthor(), ilObject::getDescription(), getEndDateEnabled(), getEndDay(), getEndMonth(), getEndYear(), getEvaluationAccess(), ilObject::getId(), getIntroduction(), getObligatoryStates(), getOutro(), getShowQuestionTitles(), getStartDateEnabled(), getStartDay(), getStartMonth(), getStartYear(), getStatus(), getSurveyId(), getSurveyPages(), ilObject::getTitle(), and ilObject::getType().

        {
                include_once("./classes/class.ilXmlWriter.php");
                $a_xml_writer = new ilXmlWriter;
                // set xml header
                $a_xml_writer->xmlHeader();
                $attrs = array(
                        "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
                        "xsi:noNamespaceSchemaLocation" => "http://www.ilias.de/download/xsd/ilias_survey_3_8.xsd"
                );
                $a_xml_writer->xmlStartTag("surveyobject", $attrs);
                $attrs = array(
                        "id" => $this->getSurveyId(),
                        "title" => $this->getTitle()
                );
                $a_xml_writer->xmlStartTag("survey", $attrs);
                
                $a_xml_writer->xmlElement("description", NULL, $this->getDescription());
                $a_xml_writer->xmlElement("author", NULL, $this->getAuthor());
                $a_xml_writer->xmlStartTag("objectives");
                $attrs = array(
                        "label" => "introduction"
                );
                $this->addMaterialTag($a_xml_writer, $this->getIntroduction(), TRUE, TRUE, $attrs);
                $attrs = array(
                        "label" => "outro"
                );
                $this->addMaterialTag($a_xml_writer, $this->getOutro(), TRUE, TRUE, $attrs);
                $a_xml_writer->xmlEndTag("objectives");

                if ($this->getAnonymize())
                {
                        $attribs = array("enabled" => "1");
                }
                else
                {
                        $attribs = array("enabled" => "0");
                }
                $a_xml_writer->xmlElement("anonymisation", $attribs);
                $a_xml_writer->xmlStartTag("restrictions");
                if ($this->getAnonymize() == 2)
                {
                        $attribs = array("type" => "free");
                }
                else
                {
                        $attribs = array("type" => "restricted");
                }
                $a_xml_writer->xmlElement("access", $attribs);
                if ($this->getStartDateEnabled())
                {
                        $attrs = array("type" => "date");
                        $a_xml_writer->xmlElement("startingtime", $attrs, sprintf("%04d-%02d-%02dT00:00:00", $this->getStartYear(), $this->getStartMonth(), $this->getStartDay()));
                }
                if ($this->getEndDateEnabled())
                {
                        $attrs = array("type" => "date");
                        $a_xml_writer->xmlElement("endingtime", $attrs, sprintf("%04d-%02d-%02dT00:00:00", $this->getEndYear(), $this->getEndMonth(), $this->getEndDay()));
                }
                $a_xml_writer->xmlEndTag("restrictions");
                
                // constraints
                $pages =& $this->getSurveyPages();
                $hasconstraints = FALSE;
                foreach ($pages as $question_array)
                {
                        foreach ($question_array as $question)
                        {
                                if (count($question["constraints"]))
                                {
                                        $hasconstraints = TRUE;
                                }
                        }
                }
                
                if ($hasconstraints)
                {
                        $a_xml_writer->xmlStartTag("constraints");
                        foreach ($pages as $question_array)
                        {
                                foreach ($question_array as $question)
                                {
                                        if (count($question["constraints"]))
                                        {
                                                // found constraints
                                                foreach ($question["constraints"] as $constraint)
                                                {
                                                        $attribs = array(
                                                                "sourceref" => $question["question_id"],
                                                                "destref" => $constraint["question"],
                                                                "relation" => $constraint["short"],
                                                                "value" => $constraint["value"]
                                                        );
                                                        $a_xml_writer->xmlElement("constraint", $attribs);
                                                }
                                        }
                                }
                        }
                        $a_xml_writer->xmlEndTag("constraints");
                }
                
                // add the rest of the preferences in qtimetadata tags, because there is no correspondent definition in QTI
                $a_xml_writer->xmlStartTag("metadata");

                $a_xml_writer->xmlStartTag("metadatafield");
                $a_xml_writer->xmlElement("fieldlabel", NULL, "evaluation_access");
                $a_xml_writer->xmlElement("fieldentry", NULL, $this->getEvaluationAccess());
                $a_xml_writer->xmlEndTag("metadatafield");

                $a_xml_writer->xmlStartTag("metadatafield");
                $a_xml_writer->xmlElement("fieldlabel", NULL, "status");
                $a_xml_writer->xmlElement("fieldentry", NULL, $this->getStatus());
                $a_xml_writer->xmlEndTag("metadatafield");

                $a_xml_writer->xmlStartTag("metadatafield");
                $a_xml_writer->xmlElement("fieldlabel", NULL, "display_question_titles");
                $a_xml_writer->xmlElement("fieldentry", NULL, $this->getShowQuestionTitles());
                $a_xml_writer->xmlEndTag("metadatafield");

                $a_xml_writer->xmlStartTag("metadatafield");
                $a_xml_writer->xmlElement("fieldlabel", NULL, "SCORM");
                include_once "./Services/MetaData/classes/class.ilMD.php";
                $md = new ilMD($this->getId(),0, $this->getType());
                $writer = new ilXmlWriter();
                $md->toXml($writer);
                $metadata = $writer->xmlDumpMem();
                $a_xml_writer->xmlElement("fieldentry", NULL, $metadata);
                $a_xml_writer->xmlEndTag("metadatafield");

                $a_xml_writer->xmlEndTag("metadata");
                $a_xml_writer->xmlEndTag("survey");

                $attribs = array("id" => $this->getId());
                $a_xml_writer->xmlStartTag("surveyquestions", $attribs);
                // add questionblock descriptions
                $obligatory_states =& $this->getObligatoryStates();
                foreach ($pages as $question_array)
                {
                        if (count($question_array) > 1)
                        {
                                $attribs = array("id" => $question_array[0]["question_id"]);
                                $attribs = array("showQuestiontext" => $question_array[0]["questionblock_show_questiontext"]);
                                $a_xml_writer->xmlStartTag("questionblock", $attribs);
                                if (strlen($question_array[0]["questionblock_title"]))
                                {
                                        $a_xml_writer->xmlElement("questionblocktitle", NULL, $question_array[0]["questionblock_title"]);
                                }
                        }
                        foreach ($question_array as $question)
                        {
                                if (strlen($question["heading"]))
                                {
                                        $a_xml_writer->xmlElement("textblock", NULL, $question["heading"]);
                                }
                                $questionObject =& $this->_instanciateQuestion($question["question_id"]);
                                if ($questionObject !== FALSE) $questionObject->insertXML($a_xml_writer, FALSE, $obligatory_states[$question["question_id"]]);
                        }
                        if (count($question_array) > 1)
                        {
                                $a_xml_writer->xmlEndTag("questionblock");
                        }
                }

                $a_xml_writer->xmlEndTag("surveyquestions");
                $a_xml_writer->xmlEndTag("surveyobject");
                $xml = $a_xml_writer->xmlDumpMem(FALSE);
                return $xml;
        }

Here is the call graph for this function:

ilObjSurvey::unfoldQuestionblocks ( questionblocks  ) 

Unfolds question blocks of a question pool.

Unfolds question blocks of a question pool

Parameters:
array $questionblocks An array of question block id's public

Definition at line 2190 of file class.ilObjSurvey.php.

References getSurveyId().

        {
                global $ilDB;
                foreach ($questionblocks as $index)
                {
                        $query = sprintf("DELETE FROM survey_questionblock WHERE questionblock_id = %s",
                                $ilDB->quote($index)
                        );
                        $result = $ilDB->query($query);
                        $query = sprintf("DELETE FROM survey_questionblock_question WHERE questionblock_fi = %s AND survey_fi = %s",
                                $ilDB->quote($index),
                                $ilDB->quote($this->getSurveyId())
                        );
                        $result = $ilDB->query($query);
                }
        }

Here is the call graph for this function:

ilObjSurvey::update (  ) 

update object data

public

Returns:
boolean

Reimplemented from ilObject.

Definition at line 240 of file class.ilObjSurvey.php.

References ilObject::updateMetaData().

        {
                $this->updateMetaData();

                if (!parent::update())
                {
                        return false;
                }

                // put here object specific stuff

                return true;
        }

Here is the call graph for this function:

ilObjSurvey::updateConstraint ( to_question_id,
if_question_id,
relation,
value 
)

Updates a precondition.

Updates a precondition

Parameters:
integer $precondition_id The id of the original precondition
integer $to_question_id The question id of the question where to add the constraint
integer $if_question_id The question id of the question which defines a precondition
integer $relation The database id of the relation
mixed $value The value compared with the relation public

Definition at line 2936 of file class.ilObjSurvey.php.

References getSurveyId().

                {
                        global $ilDB;
                        $query = sprintf("SELECT constraint_fi FROM survey_question_constraint WHERE question_fi = %s AND survey_fi = %s",
                                $ilDB->quote($to_question_id . ""),
                                $ilDB->quote($this->getSurveyId() . "")
                        );
                        $result = $ilDB->query($query);
                        if ($result->numRows())
                        {
                                $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                                $query = sprintf("UPDATE survey_constraint SET question_fi = %s, relation_fi = %s, value = %s WHERE constraint_id = %s",
                                        $ilDB->quote($if_question_id),
                                        $ilDB->quote($relation),
                                        $ilDB->quote($value),
                                        $ilDB->quote($row["constraint_fi"])
                                );
                                $result = $ilDB->query($query);
                        }
                }

Here is the call graph for this function:


Field Documentation

ilObjSurvey::$anonymize

Definition at line 164 of file class.ilObjSurvey.php.

ilObjSurvey::$author

Definition at line 57 of file class.ilObjSurvey.php.

Referenced by getAuthor(), and setAuthor().

ilObjSurvey::$display_question_titles

Definition at line 172 of file class.ilObjSurvey.php.

ilObjSurvey::$end_date

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

Referenced by setEndDate().

ilObjSurvey::$enddate_enabled

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

ilObjSurvey::$evaluation_access

Definition at line 93 of file class.ilObjSurvey.php.

Referenced by setEvaluationAccess().

ilObjSurvey::$introduction

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

Referenced by setIntroduction().

ilObjSurvey::$invitation

Definition at line 147 of file class.ilObjSurvey.php.

Referenced by setInvitation(), and setInvitationAndMode().

ilObjSurvey::$invitation_mode

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

Referenced by setInvitationAndMode(), and setInvitationMode().

ilObjSurvey::$outro

Definition at line 75 of file class.ilObjSurvey.php.

Referenced by setOutro().

ilObjSurvey::$questions
ilObjSurvey::$start_date

Definition at line 102 of file class.ilObjSurvey.php.

Referenced by setStartDate().

ilObjSurvey::$startdate_enabled

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

ilObjSurvey::$status

Definition at line 84 of file class.ilObjSurvey.php.

Referenced by setStatus().

ilObjSurvey::$survey_id
ilObjSurvey::$surveyCodeSecurity

Definition at line 179 of file class.ilObjSurvey.php.


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