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
 update ()
 update object data
 createReference ()
 creates reference for object
 read ($a_force_db=false)
 read object data from db into object
 ilClone ($a_parent_ref)
 copy all entries of your object.
 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.
 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.
 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.
 getAuthor ()
 Gets the authors name.
 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)
 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 ()
 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, $questions)
 Creates a question block for the survey.
 modifyQuestionblock ($questionblock_id, $title)
 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)
 Returns the available question pools for the active user.
 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.
 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, $user_id)
 Deletes the working data of a question in the database.
 saveWorkingData ($question_id, $user_id, $anonymize_id, $value="", $text="")
 Saves the working data of a question to the database.
 loadWorkingData ($question_id, $user_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.
 isSurveyStarted ($user_id, $anonymize_id)
 Checks if a user already started a survey.
 getLastActivePage ($user_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 ()
getEvaluationByUser ($questions, $user_id, $anonymous_id="")
 Calculates the evaluation data for a given user or anonymous id.
 getCumulatedResults (&$question)
 Calculates the evaluation data for a question.
getQuestions ($question_ids)
getQuestionblocks ($questionblock_ids)
getForbiddenQuestionpools ()
 getQuestionsTable ($sortoptions, $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 ($sortoptions, $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.
 to_xml ()
 Returns a QTI xml representation of the survey.
_instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id.
 importObject ($file_info, $survey_questionpool_id)
 Imports a survey from XML into the ILIAS database.
 from_xml ($xml_text)
 Imports the survey properties from XML into the survey object.
_getAvailableSurveys ($use_object_id=false)
 Returns the available surveys for the active user.
 _clone ($obj_id)
 Creates a 1:1 copy of the object and places the copy in a given repository.
 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 ()
getSurveyCodesTableData ($lang="en", $offset=0, $limit=10, $sort_by="counter", $sort_order="asc")
 isSurveyCodeUsed ($code)
 createSurveyCodes ($nrOfCodes)
 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.

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

Detailed Description

Definition at line 38 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 2279 of file class.ilObjSurvey.php.

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

Referenced by _clone().

        {
                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::_clone ( obj_id  ) 

Creates a 1:1 copy of the object and places the copy in a given repository.

Creates a 1:1 copy of the object and places the copy in a given repository

public

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

References $_GET, $key, $obj_id, $query, $result, $row, _addQuestionblock(), _getConstraints(), SurveyQuestion::_getOriginalId(), _getQuestionblock(), _instanciateQuestion(), and ilObjSurvey().

Referenced by ilObjSurveyGUI::cloneAllObject().

        {
                global $ilDB;
                
                $original = new ilObjSurvey($obj_id, false);
                $original->loadFromDb();
                
                $newObj = new ilObjSurvey();
                $newObj->setType("svy");
                $newObj->setTitle($original->getTitle());
                $newObj->setDescription($original->getDescription());
                $newObj->create(true);
                $newObj->createReference();
                $newObj->putInTree($_GET["ref_id"]);
                $newObj->setPermissions($_GET["ref_id"]);
//              $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
                
                $newObj->author = $original->getAuthor();
                $newObj->introduction = $original->getIntroduction();
                $newObj->outro = $original->getOutro();
                $newObj->status = $original->getStatus();
                $newObj->evaluation_access = $original->getEvaluationAccess();
                $newObj->start_date = $original->getStartDate();
                $newObj->startdate_enabled = $original->getStartDateEnabled();
                $newObj->end_date = $original->getEndDate();
                $newObj->enddate_enabled = $original->getEndDateEnabled();
                $newObj->invitation = $original->getInvitation();
                $newObj->invitation_mode = $original->getInvitationMode();
                $newObj->anonymize = $original->getAnonymize();

                $question_pointer = array();
                // clone the questions
                include_once "./survey/classes/class.SurveyQuestion.php";
                foreach ($original->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();
                }

                $newObj->saveToDb();            

                // clone the questionblocks
                $questionblocks = array();
                $questionblock_questions = array();
                $query = sprintf("SELECT * FROM survey_questionblock_question WHERE survey_fi = %s",
                        $ilDB->quote($original->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($original->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($original->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);
                        }
                }

                // clone meta data
                include_once "./Services/MetaData/classes/class.ilMD.php";
                $md = new ilMD($original->getId(),0,$original->getType());
                $new_md =& $md->cloneMD($newObj->getId(),0,$newObj->getType());
                return $newObj->getRefId();
        }

Here is the call graph for this function:

Here is the caller 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 4365 of file class.ilObjSurvey.php.

References $query, $rbacsystem, $result, $row, and ilObject::_hasUntrashedReference().

Referenced by ilObjSurveyGUI::createObject().

        {
                global $rbacsystem;
                global $ilDB;
                
                $result_array = array();
                $query = "SELECT object_data.*, object_data.obj_id, object_reference.ref_id FROM object_data, object_reference WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'svy' ORDER BY object_data.title";
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {               
                        include_once "./classes/class.ilObject.php";
                        if ($rbacsystem->checkAccess("write", $row->ref_id) && (ilObject::_hasUntrashedReference($row->obj_id)))
                        {
                                if ($use_object_id)
                                {
                                        $result_array[$row->obj_id] = $row->title;
                                }
                                else
                                {
                                        $result_array[$row->ref_id] = $row->title;
                                }
                        }
                }
                return $result_array;
        }

Here is the call graph for this function:

Here is the caller 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 2776 of file class.ilObjSurvey.php.

References $query, $result, $row, and $survey_id.

Referenced by _clone().

        {
                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 594 of file class.ilObjSurvey.php.

References $obj_id, $result, and 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 4982 of file class.ilObjSurvey.php.

References $query, $result, and $row.

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

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 2258 of file class.ilObjSurvey.php.

References $query, $result, and $row.

Referenced by _clone().

        {
                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 3866 of file class.ilObjSurvey.php.

References $query, and $row.

        {
                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 4667 of file class.ilObjSurvey.php.

References $obj_id, $query, $result, and $row.

        {
                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 3391 of file class.ilObjSurvey.php.

References $query, $result, and $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 4049 of file class.ilObjSurvey.php.

References SurveyQuestion::_getQuestionType().

Referenced by _clone(), getSurveyQuestions(), removeQuestion(), and to_xml().

        {
                if ($question_id < 1) return FALSE;
                include_once "./survey/classes/class.SurveyQuestion.php";
                $question_type = SurveyQuestion::_getQuestionType($question_id);
                if (strlen($question_type) == 0) return FALSE;
                include_once "./survey/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 572 of file class.ilObjSurvey.php.

References $obj_id, and ilObjSurvey().

        {
                $survey = new ilObjSurvey($obj_id, false);
                $survey->loadFromDb();
                if (($survey->getTitle()) and ($survey->author) 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 2826 of file class.ilObjSurvey.php.

References $query, and $result.

Referenced by importObject().

        {
                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);
                }
        }

Here is the caller graph for this function:

ilObjSurvey::canStartSurvey ( anonymous_id  ) 

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 1503 of file class.ilObjSurvey.php.

References $result, 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)) || (!$ilAccess->checkAccess("participate", "", $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 3334 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 4743 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::create ( a_upload = false  ) 

create survey object

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

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

        {
                parent::create();
                $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 4513 of file class.ilObjSurvey.php.

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

        {
                include_once "./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 4595 of file class.ilObjSurvey.php.

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

        {
                include_once "./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::createNewAccessCode (  ) 

Returns a new, unused survey access code.

Returns:
string A new survey access code

Definition at line 4918 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,
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 2299 of file class.ilObjSurvey.php.

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

Referenced by importObject(), and 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, owner_fi, TIMESTAMP) VALUES (NULL, %s, %s, NULL)",
                        $ilDB->quote($title),
                        $ilDB->quote($ilUser->id)
                );
                $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 231 of file class.ilObjSurvey.php.

References $result, and saveToDb().

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

Here is the call graph for this function:

ilObjSurvey::createSurveyCodes ( nrOfCodes  ) 

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

References $query, $result, 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 285 of file class.ilObjSurvey.php.

References ilObject::deleteMetaData(), deleteSurveyRecord(), 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();
                
                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 374 of file class.ilObjSurvey.php.

References $ilLog, $query, and $result.

Referenced by deleteSurveyRecord().

        {
                global $ilDB, $ilLog;
                
                $query = sprintf("DELETE FROM survey_finished WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                if ($result != DB_OK)
                {
                        $ilLog->write("SURVEY MAINTENANCE ERROR: $query failed!");
                }

                $query = sprintf("DELETE FROM survey_answer WHERE survey_fi = %s",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                if ($result != DB_OK)
                {
                        $ilLog->write("SURVEY MAINTENANCE ERROR: $query failed!");
                }
        }

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 2386 of file class.ilObjSurvey.php.

References $query, and 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 2355 of file class.ilObjSurvey.php.

References $query, $result, $row, and 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::deleteSurveyRecord (  ) 

Deletes the survey from the database.

Deletes the survey from the database

public

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

References $mobs, $query, $result, $row, 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();

                // delete export files
                include_once "./classes/class.ilUtil.php";
                $svy_data_dir = ilUtil::getDataDir()."/svy_data";
                $directory = $svy_data_dir."/svy_".$this->getId();
                if (is_dir($directory))
                {
                        include_once "./classes/class.ilUtil.php";
                        ilUtil::delDir($directory);
                }

                include_once("./content/classes/Media/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,
user_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 $user_id The database id of the user who worked through the question public

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

References $_SESSION, $query, $result, $user_id, and getAnonymize().

        {
                global $ilDB;
                
                $query = "";
                if ($this->getAnonymize())
                {
                        $query = sprintf("DELETE FROM survey_answer WHERE survey_fi = %s AND question_fi = %s AND anonymous_id = %s",
                                $ilDB->quote($this->getSurveyId()),
                                $ilDB->quote($question_id),
                                $ilDB->quote($_SESSION["anonymous_id"])
                        );
                }
                else
                {
                        $query = sprintf("DELETE FROM survey_answer WHERE survey_fi = %s AND question_fi = %s AND user_fi = %s",
                                $ilDB->quote($this->getSurveyId()),
                                $ilDB->quote($question_id),
                                $ilDB->quote($user_id)
                        );
                }
                $result = $ilDB->query($query);
        }

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 2883 of file class.ilObjSurvey.php.

References $query, $result, $user_id, 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 "./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 646 of file class.ilObjSurvey.php.

References getQuestionGUI(), and getQuestionType().

Referenced by insertQuestion().

        {
                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 3211 of file class.ilObjSurvey.php.

References $query, $result, $user_id, 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::from_xml ( xml_text  ) 

Imports the survey properties from XML into the survey object.

Imports the survey properties from XML into the survey object

Returns:
mixed An array containing the constraints and questionblocks, false otherwise public

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

References $result, domxml_open_mem(), hideQuestionTitles(), setAnonymize(), setAuthor(), ilObject::setDescription(), setEndDate(), setEndDateEnabled(), setEvaluationAccess(), setIntroduction(), setOutro(), setStartDate(), setStartDateEnabled(), setStatus(), ilObject::setTitle(), and showQuestionTitles().

Referenced by importObject().

        {
                $result = false;
                $xml_text = preg_replace("/>\s*?</", "><", $xml_text);
                $domxml = domxml_open_mem($xml_text);
                $constraints = array();
                $headings = array();
                $questionblocks = array();
                if (!empty($domxml))
                {
                        $root = $domxml->document_element();
                        $this->setTitle($root->get_attribute("title"));
                        $item = $root;
                        $itemnodes = $item->child_nodes();
                        foreach ($itemnodes as $index => $node)
                        {
                                switch ($node->node_name())
                                {
                                        case "qticomment":
                                                $comment = $node->get_content();
                                                if (strpos($comment, "ILIAS Version=") !== false)
                                                {
                                                }
                                                elseif (strpos($comment, "Questiontype=") !== false)
                                                {
                                                }
                                                elseif (strpos($comment, "Author=") !== false)
                                                {
                                                        $comment = str_replace("Author=", "", $comment);
                                                        $this->setAuthor($comment);
                                                }
                                                else
                                                {
                                                        $this->setDescription($comment);
                                                }
                                                break;
                                        case "objectives":
                                                $materials = $node->child_nodes();
                                                foreach ($materials as $material)
                                                {
                                                        if (strcmp($material->get_attribute("label"), "introduction") == 0)
                                                        {
                                                                $mattext = $material->first_child();
                                                                $this->setIntroduction($mattext->get_content());
                                                        }
                                                        else if (strcmp($material->get_attribute("label"), "outro") == 0)
                                                        {
                                                                $mattext = $material->first_child();
                                                                $this->setOutro($mattext->get_content());
                                                        }
                                                }
                                                break;
                                        case "qtimetadata":
                                                $metadata_fields = $node->child_nodes();
                                                foreach ($metadata_fields as $index => $metadata_field)
                                                {
                                                        $fieldlabel = $metadata_field->first_child();
                                                        $fieldentry = $fieldlabel->next_sibling();
                                                        switch ($fieldlabel->get_content())
                                                        {
                                                                case "evaluation_access":
                                                                        $this->setEvaluationAccess($fieldentry->get_content());
                                                                        break;
                                                                case "author":
                                                                        $this->setAuthor($fieldentry->get_content());
                                                                        break;
                                                                case "description":
                                                                        $this->setDescription($fieldentry->get_content());
                                                                        break;
                                                                case "anonymize":
                                                                        $this->setAnonymize($fieldentry->get_content());
                                                                        break;
                                                                case "startdate":
                                                                        $iso8601period = $fieldentry->get_content();
                                                                        if (preg_match("/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
                                                                        {
                                                                                $this->setStartDateEnabled(true);
                                                                                $this->setStartDate(sprintf("%04d-%02d-%02d", $matches[1], $matches[2], $matches[3]));
                                                                        }
                                                                        break;
                                                                case "enddate":
                                                                        $iso8601period = $fieldentry->get_content();
                                                                        if (preg_match("/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches))
                                                                        {
                                                                                $this->setEndDateEnabled(true);
                                                                                $this->setEndDate(sprintf("%04d-%02d-%02d", $matches[1], $matches[2], $matches[3]));
                                                                        }
                                                                        break;
                                                                case "status":
                                                                        $this->setStatus($fieldentry->get_content());
                                                                        break;
                                                                case "display_question_titles":
                                                                        if ($fieldentry->get_content() == QUESTIONTITLES_HIDDEN)
                                                                        {
                                                                                $this->hideQuestionTitles();
                                                                        }
                                                                        else
                                                                        {
                                                                                $this->showQuestionTitles();
                                                                        }
                                                        }
                                                        if (preg_match("/questionblock_\d+/", $fieldlabel->get_content()))
                                                        {
                                                                $qb = $fieldentry->get_content();
                                                                preg_match("/<title>(.*?)<\/title>/", $qb, $matches);
                                                                $qb_title = $matches[1];
                                                                preg_match("/<questions>(.*?)<\/questions>/", $qb, $matches);
                                                                $qb_questions = $matches[1];
                                                                $qb_questions_array = explode(",", $qb_questions);
                                                                array_push($questionblocks, array(
                                                                        "title" => $qb_title,
                                                                        "questions" => $qb_questions_array
                                                                ));
                                                        }
                                                        if (preg_match("/constraint_(\d+)/", $fieldlabel->get_content(), $matches))
                                                        {
                                                                $constraint = $fieldentry->get_content();
                                                                $constraint_array = explode(",", $constraint);
                                                                if (count($constraint_array) == 3)
                                                                {
                                                                        array_push($constraints, array(
                                                                                "for"      => $matches[1], 
                                                                                "question" => $constraint_array[0],
                                                                                "relation" => $constraint_array[1],
                                                                                "value"    => $constraint_array[2]
                                                                        ));
                                                                }
                                                        }
                                                        if (preg_match("/heading_(\d+)/", $fieldlabel->get_content(), $matches))
                                                        {
                                                                $heading = $fieldentry->get_content();
                                                                $headings[$matches[1]] = $heading;
                                                        }
                                                }
                                                break;
                                }
                        }
                        $result["questionblocks"] = $questionblocks;
                        $result["constraints"] = $constraints;
                        $result["headings"] = $headings;
                }
                return $result;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::getAllRelations ( short_as_key = false  ) 

Returns all available relations.

Returns all available relations

public

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

References $query, $result, and $row.

Referenced by importObject().

        {
                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;
        }

Here is the caller graph for this function:

ilObjSurvey::getAnonymize (  ) 

get anonymize status

Returns:
integer status

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

Referenced by deleteWorkingData(), finishSurvey(), getEvaluationByUser(), getEvaluationForAllUsers(), getLastActivePage(), isAccessibleWithoutCode(), isSurveyStarted(), loadWorkingData(), saveToDb(), saveWorkingData(), startSurvey(), and to_xml().

        {
                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 865 of file class.ilObjSurvey.php.

References ilObject::$id, $query, $result, and $row.

        {
                global $ilDB;
                $query = sprintf("SELECT anonymous_id FROM survey_answer 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 SurveyQuestion object

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

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

Referenced by to_xml().

        {
    return $this->author;
  }

Here is the caller graph for this function:

& ilObjSurvey::getAvailableQuestionpools ( use_obj_id = false,
could_be_offline = false 
)

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 2716 of file class.ilObjSurvey.php.

References $query, $rbacsystem, $result, $row, ilObject::_hasUntrashedReference(), and ilObjSurveyQuestionPool::_lookupOnline().

        {
                global $rbacsystem;
                global $ilDB;
                
                $result_array = array();
                $query = "SELECT object_data.*, object_data.obj_id, object_reference.ref_id FROM object_data, object_reference WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'spl'";
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {               
                        if ($rbacsystem->checkAccess("write", $row->ref_id) && ($this->_hasUntrashedReference($row->obj_id)))
                        {
                                include_once("./survey/classes/class.ilObjSurveyQuestionPool.php");
                                if (ilObjSurveyQuestionPool::_lookupOnline($row->obj_id) || $could_be_offline)
                                {
                                        if ($use_obj_id)
                                        {
                                                $result_array[$row->obj_id] = $row->title;
                                        }
                                        else
                                        {
                                                $result_array[$row->ref_id] = $row->title;
                                        }
                                }
                        }
                }
                return $result_array;
        }

Here is the call 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 2752 of file class.ilObjSurvey.php.

References $query, $result, $row, 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))
                {               
                        array_push($result_array, array("id" => $row->constraint_id, "question" => $row->question_fi, "short" => $row->shortname, "long" => $row->longname, "value" => $row->value));
                }
                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 3534 of file class.ilObjSurvey.php.

References $query, $result, and 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 1647 of file class.ilObjSurvey.php.

Referenced by 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 1133 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), and to_xml().

        {
                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 1696 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), and to_xml().

        {
                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 1675 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), and to_xml().

        {
                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 1717 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), and to_xml().

        {
                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 1738 of file class.ilObjSurvey.php.

Referenced by to_xml().

        {
    return $this->evaluation_access;
  }

Here is the caller graph for this function:

& ilObjSurvey::getEvaluationByUser ( questions,
user_id,
anonymous_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 3455 of file class.ilObjSurvey.php.

References $key, $query, $questions, $result, $row, $user, $user_id, ilObjUser::_lookupLogin(), getAnonymize(), and getSurveyId().

Referenced by getEvaluationForAllUsers().

        {
                global $ilDB;
                
                $wherecond = "";
                $wherevalue = "";
                if (strcmp($anonymous_id, "") != 0)
                {
                        $wherecond = "anonymous_id = %s";
                        $wherevalue = $anonymous_id;
                }
                else
                {
                        $wherecond = "user_fi = %s";
                        $wherevalue = $user_id;
                }
                // collect all answers
                $answers = array();
                $query = sprintf("SELECT * FROM survey_answer WHERE $wherecond AND survey_fi = %s",
                        $ilDB->quote($wherevalue),
                        $ilDB->quote($this->getSurveyId())
                );
                $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);
                }
                $username = $this->lng->txt("anonymous");
                $gender = "";
                if (($user_id > 0) && ($user_id != ANONYMOUS_USER_ID) && ($this->getAnonymize() == 0))
                {
                        include_once "./classes/class.ilObjUser.php";
                        if (strlen(ilObjUser::_lookupLogin($user_id)) == 0)
                        {
                                $username = $this->lng->txt("deleted_user");
                                $gender = "";
                        }
                        else
                        {
                                $user = new ilObjUser($user_id);
                                $username = $user->getFullname();
                                $gender = $user->getGender();
                                if (strlen($gender) == 1) $gender = $this->lng->txt("gender_$gender");
                        }
                }
                $resultset = array(
                        "name" => $username,
                        "gender" => $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 3409 of file class.ilObjSurvey.php.

References $query, $questions, $result, $row, $users, getAnonymize(), 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)
                {
                        if (($row["user_fi"] > 0) && ($row["user_fi"] != ANONYMOUS_USER_ID) && ($this->getAnonymize() == 0))
                        {
                                $evaluation[$row["user_fi"]] = $this->getEvaluationByUser($questions, $row["user_fi"], $row["anonymous_id"]);
                        }
                        else
                        {
                                if (strlen($row["anonymous_id"]) > 0)
                                {
                                        $evaluation[$row["anonymous_id"]] = $this->getEvaluationByUser($questions, $row["user_fi"], $row["anonymous_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 1793 of file class.ilObjSurvey.php.

References $data, $query, and $result.

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 4543 of file class.ilObjSurvey.php.

References ilUtil::getDataDir().

        {
                include_once "./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 4554 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
                                substr($entry, -4) == ".xml" and
                                ereg("^[0-9]{10}_{2}[0-9]+_{2}(survey__)*[0-9]+\.xml\$", $entry))
                        {
                                $file[] = $entry;
                        }
                }

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

                return $file;
        }

& ilObjSurvey::getForbiddenQuestionpools (  ) 

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

References $query, $rbacsystem, $result, $row, ilObject::_hasUntrashedReference(), and ilObjSurveyQuestionPool::_lookupOnline().

Referenced by getQuestionsTable().

        {
                global $rbacsystem;
                global $ilDB;
                
                // get all available questionpools and remove the trashed questionspools
                $forbidden_pools = array();
                $query = "SELECT object_data.*, object_data.obj_id, object_reference.ref_id FROM object_data, object_reference WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'spl'";
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {               
                        include_once("./survey/classes/class.ilObjSurveyQuestionPool.php");
                        if (!$rbacsystem->checkAccess("write", $row->ref_id) || (!$this->_hasUntrashedReference($row->obj_id)) || (!ilObjSurveyQuestionPool::_lookupOnline($row->obj_id)))
                        {
                                array_push($forbidden_pools, $row->obj_id);
                        }
                }
                return $forbidden_pools;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::getImportDirectory (  ) 

get import directory of survey

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

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

Referenced by importObject().

        {
                include_once "./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 1766 of file class.ilObjSurvey.php.

Referenced by to_xml().

        {
    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 1381 of file class.ilObjSurvey.php.

Referenced by 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 1395 of file class.ilObjSurvey.php.

Referenced by 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 3024 of file class.ilObjSurvey.php.

References $query, $result, and $row.

        {
                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 3000 of file class.ilObjSurvey.php.

References $query, $result, and $row.

        {
                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 ( user_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 $user_id The database 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 3294 of file class.ilObjSurvey.php.

References $_SESSION, $query, $result, $row, $user_id, and getAnonymize().

        {
                global $ilDB;
                $query = "";
                if ($this->getAnonymize())
                {
                        $query = sprintf("SELECT question_fi, TIMESTAMP + 0 AS TIMESTAMP14 FROM survey_answer WHERE survey_fi = %s AND anonymous_id = %s ORDER BY TIMESTAMP14 DESC",
                                $ilDB->quote($this->getSurveyId() . ""),
                                $ilDB->quote($_SESSION["anonymous_id"])
                        );
                }
                else
                {
                        $query = sprintf("SELECT question_fi, TIMESTAMP + 0 AS TIMESTAMP14 FROM survey_answer WHERE survey_fi = %s AND user_fi = %s ORDER BY TIMESTAMP14 DESC",
                                $ilDB->quote($this->getSurveyId() . ""),
                                $ilDB->quote($user_id . "")
                        );
                }
                $result = $ilDB->query($query);
                if ($result->numRows() == 0)
                {
                        return "";
                }
                else
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        return $row["question_fi"];
                }
        }

Here is the call graph for this function:

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 2670 of file class.ilObjSurvey.php.

References $key, and 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 2555 of file class.ilObjSurvey.php.

References $query, $result, and $row.

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

        {
                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 1780 of file class.ilObjSurvey.php.

Referenced by saveToDb(), and to_xml().

        {
    return $this->outro;
  }

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 2238 of file class.ilObjSurvey.php.

References $query, $result, and $row.

        {
                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 2213 of file class.ilObjSurvey.php.

References $query, $result, and $row.

        {
                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 2175 of file class.ilObjSurvey.php.

References $counter, $query, $result, $row, and $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 3560 of file class.ilObjSurvey.php.

References $query, $result, and $row.

        {
                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 ( sortoptions,
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 3750 of file class.ilObjSurvey.php.

References $counter, $key, $query, $row, 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();
    if (count($sortoptions)) 
                {
                        include_once "./classes/class.ilUtil.php";
      foreach ($sortoptions as $key => $value) 
                        {
        switch($key) 
                                {
          case "title":
                                                $order = " ORDER BY survey_questionblock.title $value";
            $images["title"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
            break;
                                        case "svy":
                                                $order = " ORDER BY survey_survey_question.survey_fi $value";
            $images["svy"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "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 2152 of file class.ilObjSurvey.php.

References $query, $result, and $row.

        {
                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 891 of file class.ilObjSurvey.php.

Referenced by duplicateQuestionForSurvey().

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

Here is the caller graph for this function:

& ilObjSurvey::getQuestionpoolTitles (  ) 

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 1816 of file class.ilObjSurvey.php.

References $query, $rbacsystem, $result, $row, ilObject::_hasUntrashedReference(), and ilObjSurveyQuestionPool::_lookupOnline().

        {
                global $rbacsystem;
                global $ilDB;
                
                $qpl_titles = array();
                // get all available questionpools and remove the trashed questionspools
                $query = "SELECT object_data.*, object_data.obj_id, object_reference.ref_id FROM object_data, object_reference WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'spl'";
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {               
                        if ($rbacsystem->checkAccess("write", $row->ref_id) && ($this->_hasUntrashedReference($row->obj_id)))
                        {
                                include_once("./survey/classes/class.ilObjSurveyQuestionPool.php");
                                if (ilObjSurveyQuestionPool::_lookupOnline($row->obj_id))
                                {
                                        $qpl_titles["$row->obj_id"] = $row->title;
                                }
                        }
                }
                return $qpl_titles;
        }

Here is the call graph for this function:

& ilObjSurvey::getQuestions ( question_ids  ) 

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

References $query, $result, and $row.

        {
                $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 ( sortoptions,
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 3607 of file class.ilObjSurvey.php.

References $key, $query, $row, getExistingQuestions(), getForbiddenQuestionpools(), 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();
    if (count($sortoptions)) 
                {
                        include_once "./classes/class.ilUtil.php";
      foreach ($sortoptions as $key => $value) 
                        {
        switch($key) 
                                {
          case "title":
            $order = " ORDER BY title $value";
            $images["title"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
            break;
          case "description":
            $order = " ORDER BY description $value";
            $images["description"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
            break;
          case "type":
            $order = " ORDER BY questiontype_id $value";
            $images["type"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
            break;
          case "author":
            $order = " ORDER BY author $value";
            $images["author"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
            break;
          case "created":
            $order = " ORDER BY created $value";
            $images["created"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
            break;
          case "updated":
            $order = " ORDER BY TIMESTAMP14 $value";
            $images["updated"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
            break;
                                        case "qpl":
                                                $order = " ORDER BY obj_fi $value";
            $images["qpl"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
                                                break;
        }
      }
    }
                $maxentries = $ilUser->prefs["hits_per_page"];
                if ($maxentries < 1)
                {
                        $maxentries = 9999;
                }

                $forbidden_pools =& $this->getForbiddenQuestionpools();
                $forbidden = "";
                if (count($forbidden_pools))
                {
                        $forbidden = " AND survey_question.obj_fi NOT IN (" . join($forbidden_pools, ",") . ")";
                }
                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, ",") . ")";
                }
          $query = "SELECT survey_question.question_id, survey_question.TIMESTAMP + 0 AS TIMESTAMP14 FROM survey_question, survey_questiontype WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id$forbidden$existing AND ISNULL(survey_question.original_id) " . " $where$order$limit";
    $query_result = $ilDB->query($query);
                $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_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);
                $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 909 of file class.ilObjSurvey.php.

References $data, $query, and $result.

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 2490 of file class.ilObjSurvey.php.

References $query, $result, and $row.

        {
                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 1165 of file class.ilObjSurvey.php.

Referenced by saveToDb(), and to_xml().

        {
                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 1490 of file class.ilObjSurvey.php.

Referenced by 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 1098 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), and to_xml().

        {
                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 1605 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), and to_xml().

        {
                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 1584 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), and to_xml().

        {
                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 1626 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), and to_xml().

        {
                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 1409 of file class.ilObjSurvey.php.

Referenced by canStartSurvey(), and to_xml().

        {
    return $this->status;
  }

Here is the caller graph for this function:

ilObjSurvey::getSurveyCodesCount (  ) 

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

References $query, and $result.

        {
                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::getSurveyCodesTableData ( lang = "en",
offset = 0,
limit = 10,
sort_by = "counter",
sort_order = "asc" 
)

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

References $counter, $lang, $query, $result, $row, formatDate(), ilFormat::ftimestamp2dateDB(), 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;
                if (strlen($sort_by) == 0) $sort_by = "counter";
                if (strlen($sort_order) == 0) $sort_order = "asc";
                
                switch ($sort_by)
                {
                        case "counter":
                                $order = "ORDER BY survey_finished.anonymous_id $sort_order";
                                break;
                        case "date":
                                $order = "ORDER BY survey_finished.anonymous_id $sort_order";
                                break;
                        case "used":
                                $order = "ORDER BY survey_finished.anonymous_id $sort_order";
                                break;
                        case "url":
                                $order = "ORDER BY survey_finished.anonymous_id $sort_order";
                                break;
                }
                
                $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::ftimestamp2dateDB($row["TIMESTAMP14"]), "date");

                                $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>";
                                }
                                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 936 of file class.ilObjSurvey.php.

Referenced by createSurveyCodes(), deleteConstraint(), deleteConstraints(), finishSurvey(), getConstraints(), getCumulatedResults(), getEvaluationByUser(), inviteUser(), isAnonymizedParticipant(), isAnonymousKey(), removeConstraintsConcerningQuestion(), removeQuestions(), saveHeading(), saveUserAccessCode(), to_xml(), and unfoldQuestionblocks().

        {
                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 2580 of file class.ilObjSurvey.php.

References $counter, $query, $result, $row, getConstraints(), and getObligatoryStates().

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

        {
                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;
                                $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"] = "";
                                $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 440 of file class.ilObjSurvey.php.

References $query, $result, $row, ilObjUser::_lookupLogin(), and ilObjUser::_lookupName().

        {
                global $ilDB;
                
                $query = sprintf("SELECT * FROM survey_finished WHERE survey_fi = %s ORDER BY user_fi",
                        $ilDB->quote($this->getSurveyId() . "")
                );
                $result = $ilDB->query($query);
                $participants = array();
                if ($result->numRows() > 0)
                {
                        while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                if (($row["user_fi"] > 0) && ($row["user_fi"] != ANONYMOUS_USER_ID) && (!strlen($row["anonymous_id"])))
                                {
                                        $uname = ilObjUser::_lookupName($row["user_fi"]);
                                        if (strlen($uname["user_id"]))
                                        {
                                                $login = ilObjUser::_lookupLogin($row["user_fi"]);
                                                $participants[$row["finished_id"]] = array("name" => $uname["lastname"] . ", " . $uname["firstname"], "login" => $login);
                                        }
                                        else
                                        {
                                                $participants[$row["finished_id"]] = array("name" => $this->lng->txt("deleted_user"));
                                        }
                                }
                                else
                                {
                                        if (strlen($row["anonymous_id"]) > 0)
                                        {
                                                $participants[$row["finished_id"]] = array("name" => $this->lng->txt("anonymous"));
                                        }
                                }
                        }
                }
                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 2408 of file class.ilObjSurvey.php.

References $data, $key, $query, $result, $row, _instanciateQuestion(), getConstraints(), and getObligatoryStates().

Referenced by getEvaluationForAllUsers(), 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",
//              $query = sprintf("SELECT survey_question.question_id, survey_survey_question.heading FROM survey_question, survey_survey_question WHERE survey_survey_question.survey_fi = %s AND survey_survey_question.question_fi = survey_question.question_id ORDER BY survey_survey_question.sequence",
                        $ilDB->quote($this->getSurveyId())
                );
                $result = $ilDB->query($query);
                include_once "./survey/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;
                        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::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 4877 of file class.ilObjSurvey.php.

References $query, $result, $row, and $user_id.

        {
                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::getUserSurveyCode ( user_id  ) 

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

References $query, $result, $row, and $user_id.

        {
                global $ilDB;
                
                if ($user_id == ANONYMOUS_USER_ID) 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 "";
                }
        }

& ilObjSurvey::getVariables ( question_id  ) 

Returns all variables of a question.

Returns all variables of a question

public

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

References $query, $result, and $row.

        {
                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 1191 of file class.ilObjSurvey.php.

Referenced by from_xml().

        {
                $this->display_question_titles = QUESTIONTITLES_HIDDEN;
  }

Here is the caller graph for this function:

ilObjSurvey::ilClone ( a_parent_ref  ) 

copy all entries of your object.

public

Parameters:
integer ref_id of parent object
Returns:
integer new ref id

Reimplemented from ilObject.

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

References $rbacadmin.

        {               
                global $rbacadmin;

                // always call parent ilClone function first!!
                $new_ref_id = parent::ilClone($a_parent_ref);
                
                // get object instance of ilCloned object
                //$newObj =& $this->ilias->obj_factory->getInstanceByRefId($new_ref_id);

                // create a local role folder & default roles
                //$roles = $newObj->initDefaultRoles();

                // ...finally assign role to creator of object
                //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "n");          

                // always destroy objects in ilClone method because ilClone() is recursive and creates instances for each object in subtree!
                //unset($newObj);

                // ... and finally always return new reference ID!!
                return $new_ref_id;
        }

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 181 of file class.ilObjSurvey.php.

References ilObject::ilObject().

Referenced by _clone(), _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;
        }

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 4069 of file class.ilObjSurvey.php.

References $key, $result, addConstraint(), createQuestionblock(), ilUtil::delDir(), from_xml(), getAllRelations(), getImportDirectory(), ilUtil::moveUploadedFile(), saveHeading(), and saveToDb().

        {
                // check if file was uploaded
                $source = $file_info["tmp_name"];
                $error = 0;
                if (($source == 'none') || (!$source) || $file_info["error"] > UPLOAD_ERR_OK)
                {
                        $this->ilias->raiseError($this->lng->txt("import_no_file_selected"),$this->ilias->error_obj->MESSAGE);
                        $error = 1;
                }
                // check correct file type
                if (!((strcmp($file_info["type"], "text/xml") == 0) || (strcmp($file_info["type"], "application/xml") == 0)))
                {
                        $this->ilias->raiseError($this->lng->txt("import_wrong_file_type"),$this->ilias->error_obj->MESSAGE);
                        $error = 1;
                }
                if (!$error)
                {
                        // import file as a survey
                        $import_dir = $this->getImportDirectory();
                        $importfile = tempnam($import_dir, "survey_import");
                        //move_uploaded_file($source, $importfile);
                        include_once "./classes/class.ilUtil.php";
                        ilUtil::moveUploadedFile($source, "survey_import", $importfile);
                        $fh = fopen($importfile, "r");
                        if (!$fh)
                        {
                                $this->ilias->raiseError($this->lng->txt("import_error_opening_file"),$this->ilias->error_obj->MESSAGE);
                                $error = 1;
                                return $error;
                        }
                        $xml = fread($fh, filesize($importfile));
                        $result = fclose($fh);

                        // delete import directory
                        ilUtil::delDir($this->getImportDirectory());
        
                        if (!$result)
                        {
                                $this->ilias->raiseError($this->lng->txt("import_error_closing_file"),$this->ilias->error_obj->MESSAGE);
                                $error = 1;
                                return $error;
                        }
                        if (preg_match("/(<survey[^>]*>.*?<\/survey>)/si", $xml, $matches))
                        {
                                // read survey properties
                                $import_results = $this->from_xml($matches[1]);
                                if ($import_results === false)
                                {
                                        $this->ilias->raiseError($this->lng->txt("import_error_survey_no_proper_values"),$this->ilias->error_obj->MESSAGE);
                                        $error = 1;
                                        return $error;
                                }
                        }
                        else
                        {
                                $this->ilias->raiseError($this->lng->txt("import_error_survey_no_properties"),$this->ilias->error_obj->MESSAGE);
                                $error = 1;
                                return $error;
                        }
                        $question_counter = 0;
                        $new_question_ids = array();
                        if (preg_match_all("/(<item[^>]*>.*?<\/item>)/si", $xml, $matches))
                        {
                                foreach ($matches[1] as $index => $item)
                                {
                                        $question = "";
                                        if (preg_match("/<qticomment>Questiontype\=(.*?)<\/qticomment>/is", $item, $questiontype))
                                        {
                                                include_once "./survey/classes/class.SurveyNominalQuestion.php";
                                                include_once "./survey/classes/class.SurveyOrdinalQuestion.php";
                                                include_once "./survey/classes/class.SurveyMetricQuestion.php";
                                                include_once "./survey/classes/class.SurveyTextQuestion.php";
                                                switch ($questiontype[1])
                                                {
                                                        case NOMINAL_QUESTION_IDENTIFIER:
                                                                $question = new SurveyNominalQuestion();
                                                                break;
                                                        case ORDINAL_QUESTION_IDENTIFIER:
                                                                $question = new SurveyOrdinalQuestion();
                                                                break;
                                                        case METRIC_QUESTION_IDENTIFIER:
                                                                $question = new SurveyMetricQuestion();
                                                                break;
                                                        case TEXT_QUESTION_IDENTIFIER:
                                                                $question = new SurveyTextQuestion();
                                                                break;
                                                }
                                                if ($question)
                                                {
                                                        $question->from_xml("<questestinterop>$item</questestinterop>");
                                                        if ($import_results !== false)
                                                        {
                                                                $question->setObjId($survey_questionpool_id);
                                                                $question->saveToDb();
                                                                $question_id = $question->duplicate(true);
                                                                $this->questions[$question_counter++] = $question_id;
                                                                if (preg_match("/<item\s+ident\=\"(\d+)\"/", $item, $matches))
                                                                {
                                                                        $original_question_id = $matches[1];
                                                                        $new_question_ids[$original_question_id] = $question_id;
                                                                }
                                                        }
                                                        else
                                                        {
                                                                $this->ilias->raiseError($this->lng->txt("error_importing_question"), $this->ilias->error_obj->MESSAGE);
                                                        }
                                                }
                                        }
                                }
                        }

                        $this->saveToDb();
                        // add question blocks
                        foreach ($import_results["questionblocks"] as $questionblock)
                        {
                                foreach ($questionblock["questions"] as $key => $value)
                                {
                                        $questionblock["questions"][$key] = $new_question_ids[$value];
                                }
                                $this->createQuestionblock($questionblock["title"], $questionblock["questions"]);
                        }
                        // add constraints
                        $relations = $this->getAllRelations(true);
                        foreach ($import_results["constraints"] as $constraint)
                        {
                                $this->addConstraint($new_question_ids[$constraint["for"]], $new_question_ids[$constraint["question"]], $relations[$constraint["relation"]]["id"], $constraint["value"]);
                        }
                        foreach ($import_results["headings"] as $qid => $heading)
                        {
                                $this->saveHeading($heading, $new_question_ids[$qid]);
                        }
                }
                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 663 of file class.ilObjSurvey.php.

References $query, $result, SurveyQuestion::_isComplete(), duplicateQuestionForSurvey(), and loadQuestionsFromDb().

        {
                global $ilDB;
                
                include_once "./survey/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 705 of file class.ilObjSurvey.php.

References $query, $questions, $result, $row, ilObject::$title, and createQuestionblock().

        {
                global $ilDB;
                $query = sprintf("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 =%s ORDER BY survey_survey_question.sequence",
                        $ilDB->quote($questionblock_id)
                );
                $result = $ilDB->query($query);
                $questions = array();
                while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        array_push($questions, $row["question_id"]);
                        $title = $row["title"];
                }
                $this->createQuestionblock($title, $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 2947 of file class.ilObjSurvey.php.

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

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

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 2974 of file class.ilObjSurvey.php.

References $rbacreview, $role_id, $user_id, ilObjUser::_lookupLogin(), getInvitation(), ilObject::getRefId(), and inviteUser().

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

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 2911 of file class.ilObjSurvey.php.

References $query, $result, $user_id, 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 "./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 964 of file class.ilObjSurvey.php.

References getAnonymize().

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

Here is the call graph for this function:

ilObjSurvey::isAnonymizedParticipant ( key  ) 

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

References $key, $query, $result, and 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 4684 of file class.ilObjSurvey.php.

References $key, $query, $result, and 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 552 of file class.ilObjSurvey.php.

References ilObject::getTitle().

Referenced by saveCompletionStatus(), and saveToDb().

        {
                if (($this->getTitle()) and ($this->author) 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 5050 of file class.ilObjSurvey.php.

Referenced by prepareTextareaOutput().

        {
                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 1444 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 1423 of file class.ilObjSurvey.php.

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

ilObjSurvey::isSurveyCodeUsed ( code  ) 

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

References $query, and $result.

Referenced by createNewAccessCode(), 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 3244 of file class.ilObjSurvey.php.

References $query, $result, $row, $user_id, and getAnonymize().

Referenced by canStartSurvey(), checkSurveyCode(), and saveWorkingData().

        {
                global $ilDB;
                
                if ($this->getAnonymize())
                {
                        if (strlen($anonymize_id) == 0) return FALSE;
                        if (($user_id != ANONYMOUS_USER_ID) && (strlen($anonymize_id) == 0))
                        {
                                $query = sprintf("SELECT state FROM survey_finished WHERE survey_fi = %s AND user_fi = %s",
                                        $ilDB->quote($this->getSurveyId()),
                                        $ilDB->quote($user_id)
                                );
                        }
                        else
                        {
                                $query = sprintf("SELECT state FROM survey_finished WHERE survey_fi = %s AND anonymous_id = %s",
                                        $ilDB->quote($this->getSurveyId()),
                                        $ilDB->quote($anonymize_id)
                                );
                        }
                }
                else
                {
                        $query = sprintf("SELECT state 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);
                        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 983 of file class.ilObjSurvey.php.

References $data, $query, $result, ilRTE::_replaceMediaObjectImageSrc(), loadQuestionsFromDb(), setAnonymize(), and setOutro().

Referenced by 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;
                                $this->author = $data->author;
                                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 1054 of file class.ilObjSurvey.php.

References $data, $query, and $result.

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,
user_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 $user_id The database id of the user who worked through the question
Returns:
array The resulting database dataset as an array public

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

References $_SESSION, $query, $result, $row, $user_id, and getAnonymize().

        {
                global $ilDB;
                $result_array = array();
                $query = "";
                if ($this->getAnonymize())
                {
                        $query = sprintf("SELECT * FROM survey_answer WHERE survey_fi = %s AND question_fi = %s AND anonymous_id = %s",
                                $ilDB->quote($this->getSurveyId() . ""),
                                $ilDB->quote($question_id. ""),
                                $ilDB->quote($_SESSION["anonymous_id"])
                        );
                }
                else
                {
                        $query = sprintf("SELECT * FROM survey_answer WHERE survey_fi = %s AND question_fi = %s AND user_fi = %s",
                                $ilDB->quote($this->getSurveyId() . ""),
                                $ilDB->quote($question_id . ""),
                                $ilDB->quote($user_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;
                }
        }

Here is the call graph for this function:

ilObjSurvey::modifyQuestionblock ( questionblock_id,
title 
)

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 2337 of file class.ilObjSurvey.php.

References $query, $result, and ilObject::$title.

        {
                global $ilDB;
                $query = sprintf("UPDATE survey_questionblock SET title = %s WHERE questionblock_id = %s",
                        $ilDB->quote($title),
                        $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 1884 of file class.ilObjSurvey.php.

References $idx, $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 1951 of file class.ilObjSurvey.php.

References $idx, 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 1983 of file class.ilObjSurvey.php.

References $idx, 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 1847 of file class.ilObjSurvey.php.

References $idx, $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 1921 of file class.ilObjSurvey.php.

References $idx, 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 491 of file class.ilObjSurvey.php.

References $_GET, $tree, 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 5004 of file class.ilObjSurvey.php.

References $result, ilUtil::insertLatexImages(), and isHTML().

        {
                include_once "./classes/class.ilObjAdvancedEditing.php";
                $result = $txt_output;
                if ($prepare_for_latex_output)
                {
                        $result = ilUtil::insertLatexImages($result, "<span class\=\"latex\">", "<\/span>", URL_TO_LATEX);
                }
                // removed: did not work with magic_quotes_gpc = On
                //$result = ilUtil::stripSlashes($result, true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey"));
                if (!$this->isHTML($result))
                {
                        // if the string does not contain HTML code, replace the newlines with HTML line breaks
                        $result = preg_replace("/[\n]/", "<br />", $result);
                }
                else
                {
                        // patch for problems with the <pre> tags in tinyMCE
                        if (preg_match_all("/(<pre>.*?<\/pre>)/ims", $result, $matches))
                        {
                                foreach ($matches[0] as $found)
                                {
                                        $replacement = "";
                                        if (strpos("\n", $found) === FALSE)
                                        {
                                                $replacement = "\n";
                                        }
                                        $removed = preg_replace("/<br\s*?\/>/ims", $replacement, $found);
                                        $result = str_replace($found, $removed, $result);
                                }
                        }
                }
                $result = str_replace("{", "&#123;", $result);
                $result = str_replace("}", "&#125;", $result);
                $result = str_replace("\\", "&#92;", $result);
                return $result;
        }

Here is the call graph for this function:

& 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 4949 of file class.ilObjSurvey.php.

References $row, and $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::read ( a_force_db = false  ) 

read object data from db into object

Parameters:
boolean public

Reimplemented from ilObject.

Definition at line 243 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 2052 of file class.ilObjSurvey.php.

References $key, $query, $result, $row, and 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 2036 of file class.ilObjSurvey.php.

References _instanciateQuestion(), and removeConstraintsConcerningQuestion().

Referenced by delete(), and removeQuestions().

        {
                include_once "./survey/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 2091 of file class.ilObjSurvey.php.

References $data, $query, $questions, $result, 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 404 of file class.ilObjSurvey.php.

References $query, $result, and $row.

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

                        if (strlen($row["anonymous_id"]) > 0)
                        {
                                $query = sprintf("DELETE FROM survey_answer WHERE survey_fi = %s AND anonymous_id = %s",
                                        $ilDB->quote($this->getSurveyId()),
                                        $ilDB->quote($row["anonymous_id"] . "")
                                );
                        }
                        else
                        {
                                $query = sprintf("DELETE FROM survey_answer WHERE survey_fi = %s AND user_fi = %s AND anonymous_id = %s",
                                        $ilDB->quote($this->getSurveyId()),
                                        $ilDB->quote($row["user_fi"] . ""),
                                        $ilDB->quote($row["anonymous_id"] . "")
                                );
                        }
                        $result = $ilDB->query($query);

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

ilObjSurvey::saveCompletionStatus (  ) 

Saves the completion status of the survey.

Saves the completion status of the survey

public

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

References $query, $result, and 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 4646 of file class.ilObjSurvey.php.

References $query, and getSurveyId().

Referenced by importObject().

        {
                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 821 of file class.ilObjSurvey.php.

References $key, $query, $result, and $row.

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 728 of file class.ilObjSurvey.php.

References $query, $result, ilRTE::_cleanupMediaObjectUsage(), ilRTE::_replaceMediaObjectImageSrc(), getAnonymize(), getEndDate(), ilObject::getId(), getOutro(), getShowQuestionTitles(), getStartDate(), ilObject::getType(), 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 which are not inserted into the question text
                include_once("./Services/RTE/classes/class.ilRTE.php");
                ilRTE::_cleanupMediaObjectUsage($this->introduction . $this->getOutro(), $this->getType() . ":html", $this->getId());

    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 4902 of file class.ilObjSurvey.php.

References $query, $result, $user_id, and 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::saveWorkingData ( question_id,
user_id,
anonymize_id,
value = "",
text = "" 
)

Saves the working data of a question to the database.

Saves the working data of a question to the database

Parameters:
integer $question_id The database id of the question
integer $user_id The database id of the user who worked through the question
mixed $value The value the user entered for the question
string $text The answer text of a text question public

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

References $query, $result, $user_id, getAnonymize(), isSurveyStarted(), and startSurvey().

        {
                global $ilDB;
                if ($this->isSurveyStarted($user_id, $anonymize_id) === false)
                {
                        $this->startSurvey($user_id, $anonymize_id);
                }
                if (strcmp($value, "") == 0)
                {
                        $value = "NULL";
                }
                else
                {
                        $value = $ilDB->quote($value);
                }
                if (strcmp($text, "") == 0)
                {
                        $text = "NULL";
                }
                else
                {
                        $text = $ilDB->quote($text);
                }
                if ($this->getAnonymize())
                {
                        $user_id = 0;
                }
                $query = sprintf("INSERT INTO survey_answer (answer_id, survey_fi, question_fi, user_fi, anonymous_id, value, textanswer, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, NULL)",
                        $ilDB->quote($this->getSurveyId() . ""),
                        $ilDB->quote($question_id . ""),
                        $ilDB->quote($user_id . ""),
                        $ilDB->quote($anonymize_id),
                        $value,
                        $text
                );
                $result = $ilDB->query($query);
        }

Here is the call graph for this function:

ilObjSurvey::setAnonymize ( a_anonymize  ) 

set anonymize status

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

Referenced by from_xml(), and 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 SurveyQuestion object

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

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

References $author.

Referenced by from_xml().

        {
    if (!$author) 
                {
      $author = $this->ilias->account->fullname;
    }
    $this->author = $author;
  }

Here is the caller graph for this function:

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 1661 of file class.ilObjSurvey.php.

References $end_date.

Referenced by from_xml().

        {
    $this->end_date = $end_date;
  }

Here is the caller graph for this function:

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 1112 of file class.ilObjSurvey.php.

Referenced by from_xml().

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

Here is the caller graph for this function:

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 1752 of file class.ilObjSurvey.php.

References $evaluation_access.

Referenced by from_xml().

        {
    $this->evaluation_access = $evaluation_access;
  }

Here is the caller graph for this function:

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 1339 of file class.ilObjSurvey.php.

References $introduction.

Referenced by from_xml().

        {
    $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 1205 of file class.ilObjSurvey.php.

References $invitation, $query, $result, $row, $user, $user_id, ilObjUser::_lookupLogin(), getInvitationMode(), and ilObject::getRefId().

Referenced by setInvitationAndMode(), and setInvitationMode().

        {
                global $ilDB;
    $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))
                                {
                                        $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 "./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 1311 of file class.ilObjSurvey.php.

References $invitation, $invitation_mode, $query, $result, 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 1282 of file class.ilObjSurvey.php.

References $invitation_mode, $query, $result, 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 2511 of file class.ilObjSurvey.php.

References $query, $result, and $row.

        {
                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 1353 of file class.ilObjSurvey.php.

References $outro.

Referenced by from_xml(), 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 1570 of file class.ilObjSurvey.php.

References $start_date.

Referenced by from_xml().

        {
    $this->start_date = $start_date;
  }

Here is the caller graph for this function:

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 1077 of file class.ilObjSurvey.php.

Referenced by from_xml().

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

Here is the caller graph for this function:

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 1466 of file class.ilObjSurvey.php.

References $result, and $status.

Referenced by from_xml().

        {
                $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;
  }

Here is the caller graph for this function:

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 1178 of file class.ilObjSurvey.php.

Referenced by from_xml().

        {
                $this->display_question_titles = QUESTIONTITLES_VISIBLE;
  }

Here is the caller graph for this function:

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 3176 of file class.ilObjSurvey.php.

References $query, $result, $user_id, and getAnonymize().

Referenced by saveWorkingData().

        {
                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;
                        }
                }
                // only write the entry if there is valid data!
                if (($user_id > 0) || (strlen($anonymous_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);
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjSurvey::to_xml (  ) 

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 3888 of file class.ilObjSurvey.php.

References _instanciateQuestion(), 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();
                $a_xml_writer->xmlStartTag("questestinterop");
                $attrs = array(
                        "ident" => $this->getSurveyId(),
                        "title" => $this->getTitle()
                );
                $a_xml_writer->xmlStartTag("survey", $attrs);
                
                $a_xml_writer->xmlElement("qticomment", NULL, $this->getDescription());
                $a_xml_writer->xmlElement("qticomment", NULL, "ILIAS Version=".$this->ilias->getSetting("ilias_version"));
                $a_xml_writer->xmlElement("qticomment", NULL, "Author=".$this->getAuthor());
                // add ILIAS specific metadata
                $a_xml_writer->xmlStartTag("objectives");
                $attrs = array(
                        "label" => "introduction"
                );
                $a_xml_writer->xmlStartTag("material", $attrs);
                $a_xml_writer->xmlElement("mattext", NULL, $this->getIntroduction());
                $a_xml_writer->xmlEndTag("material");
                $attrs = array(
                        "label" => "outro"
                );
                $a_xml_writer->xmlStartTag("material", $attrs);
                $a_xml_writer->xmlElement("mattext", NULL, $this->getOutro());
                $a_xml_writer->xmlEndTag("material");
                $a_xml_writer->xmlEndTag("objectives");

                // add the rest of the preferences in qtimetadata tags, because there is no correspondent definition in QTI
                $a_xml_writer->xmlStartTag("qtimetadata");
                $a_xml_writer->xmlStartTag("qtimetadatafield");
                $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("qtimetadatafield");
                $a_xml_writer->xmlStartTag("qtimetadatafield");
                $a_xml_writer->xmlElement("fieldlabel", NULL, "author");
                $a_xml_writer->xmlElement("fieldentry", NULL, $this->getAuthor());
                $a_xml_writer->xmlEndTag("qtimetadatafield");
                $a_xml_writer->xmlStartTag("qtimetadatafield");
                $a_xml_writer->xmlElement("fieldlabel", NULL, "description");
                $a_xml_writer->xmlElement("fieldentry", NULL, $this->getDescription());
                $a_xml_writer->xmlEndTag("qtimetadatafield");
                $a_xml_writer->xmlStartTag("qtimetadatafield");
                $a_xml_writer->xmlElement("fieldlabel", NULL, "evaluation_access");
                $a_xml_writer->xmlElement("fieldentry", NULL, $this->getEvaluationAccess());
                $a_xml_writer->xmlEndTag("qtimetadatafield");
                $a_xml_writer->xmlStartTag("qtimetadatafield");
                $a_xml_writer->xmlElement("fieldlabel", NULL, "anonymize");
                $a_xml_writer->xmlElement("fieldentry", NULL, $this->getAnonymize());
                $a_xml_writer->xmlEndTag("qtimetadatafield");
                $a_xml_writer->xmlStartTag("qtimetadatafield");
                $a_xml_writer->xmlElement("fieldlabel", NULL, "status");
                $a_xml_writer->xmlElement("fieldentry", NULL, $this->getStatus());
                $a_xml_writer->xmlEndTag("qtimetadatafield");
                if ($this->getStartDateEnabled())
                {
                        $a_xml_writer->xmlStartTag("qtimetadatafield");
                        $a_xml_writer->xmlElement("fieldlabel", NULL, "startdate");
                        $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("P%dY%dM%dDT0H0M0S", $this->getStartYear(), $this->getStartMonth(), $this->getStartDay()));
                        $a_xml_writer->xmlEndTag("qtimetadatafield");
                }
                if ($this->getEndDateEnabled())
                {
                        $a_xml_writer->xmlStartTag("qtimetadatafield");
                        $a_xml_writer->xmlElement("fieldlabel", NULL, "enddate");
                        $a_xml_writer->xmlElement("fieldentry", NULL, sprintf("P%dY%dM%dDT0H0M0S", $this->getEndYear(), $this->getEndMonth(), $this->getEndDay()));
                        $a_xml_writer->xmlEndTag("qtimetadatafield");
                }
                $a_xml_writer->xmlStartTag("qtimetadatafield");
                $a_xml_writer->xmlElement("fieldlabel", NULL, "display_question_titles");
                $a_xml_writer->xmlElement("fieldentry", NULL, $this->getShowQuestionTitles());
                $a_xml_writer->xmlEndTag("qtimetadatafield");

                // add questionblock descriptions
                $pages =& $this->getSurveyPages();
                foreach ($pages as $question_array)
                {
                        if (count($question_array) > 1)
                        {
                                $question_ids = array();
                                // found a questionblock
                                foreach ($question_array as $question)
                                {
                                        array_push($question_ids, $question["question_id"]);
                                }
                                $a_xml_writer->xmlStartTag("qtimetadatafield");
                                $a_xml_writer->xmlElement("fieldlabel", NULL, "questionblock_" . $question_array[0]["questionblock_id"]);
                                $a_xml_writer->xmlElement("fieldentry", NULL, "<title>" . $question["questionblock_title"]. "</title><questions>" . join($question_ids, ",") . "</questions>");
                                $a_xml_writer->xmlEndTag("qtimetadatafield");
                        }
                }
                // add constraints
                foreach ($pages as $question_array)
                {
                        foreach ($question_array as $question)
                        {
                                if (count($question["constraints"]))
                                {
                                        // found constraints
                                        foreach ($question["constraints"] as $constraint)
                                        {
                                                $a_xml_writer->xmlStartTag("qtimetadatafield");
                                                $a_xml_writer->xmlElement("fieldlabel", NULL, "constraint_" . $question["question_id"]);
                                                $a_xml_writer->xmlElement("fieldentry", NULL, $constraint["question"] . "," . $constraint["short"] . "," . $constraint["value"]);
                                                $a_xml_writer->xmlEndTag("qtimetadatafield");
                                        }
                                }
                        }
                }
                // add headings
                foreach ($pages as $question_array)
                {
                        foreach ($question_array as $question)
                        {
                                if ($question["heading"])
                                {
                                        $a_xml_writer->xmlStartTag("qtimetadatafield");
                                        $a_xml_writer->xmlElement("fieldlabel", NULL, "heading_" . $question["question_id"]);
                                        $a_xml_writer->xmlElement("fieldentry", NULL, $question["heading"]);
                                        $a_xml_writer->xmlEndTag("qtimetadatafield");
                                }
                        }
                }
                $a_xml_writer->xmlEndTag("qtimetadata");
                $a_xml_writer->xmlEndTag("survey");
                $a_xml_writer->xmlEndTag("questestinterop");
                $xml = $a_xml_writer->xmlDumpMem(FALSE);

                $obligatory_states =& $this->getObligatoryStates();
                foreach ($this->questions as $question_id) 
                {
                        $question =& $this->_instanciateQuestion($question_id);
                        if ($question !== FALSE)
                        {
                                $qti_question = $question->to_xml(false, $obligatory_states[$question_id]);
                                $qti_question = preg_replace("/<questestinterop>/", "", $qti_question);
                                $qti_question = preg_replace("/<\/questestinterop>/", "", $qti_question);
                                $xml = str_replace("</questestinterop>", "$qti_question</questestinterop>", $xml);
                        }
                }
                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 2127 of file class.ilObjSurvey.php.

References $query, $result, and 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 217 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:


Field Documentation

ilObjSurvey::$anonymize

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

ilObjSurvey::$author

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

Referenced by setAuthor().

ilObjSurvey::$display_question_titles

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

ilObjSurvey::$end_date

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

Referenced by setEndDate().

ilObjSurvey::$enddate_enabled

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

ilObjSurvey::$evaluation_access

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

Referenced by setEvaluationAccess().

ilObjSurvey::$introduction

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

Referenced by setIntroduction().

ilObjSurvey::$invitation

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

Referenced by setInvitation(), and setInvitationAndMode().

ilObjSurvey::$invitation_mode

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

Referenced by setInvitationAndMode(), and setInvitationMode().

ilObjSurvey::$outro

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

Referenced by setOutro().

ilObjSurvey::$questions
ilObjSurvey::$start_date

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

Referenced by setStartDate().

ilObjSurvey::$startdate_enabled

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

ilObjSurvey::$status

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

Referenced by setStatus().

ilObjSurvey::$survey_id

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

Referenced by _getConstraints(), _hasDatasets(), and getQuestionblockQuestions().


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