ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjSurvey Class Reference
+ Inheritance diagram for ilObjSurvey:
+ Collaboration diagram for ilObjSurvey:

Public Member Functions

 ilObjSurvey ($a_id=0, $a_call_by_reference=true)
 Constructor public.
 create ($a_upload=false)
 create survey object
 createMetaData ()
 Create meta data entry.
 update ()
 update object data
 createReference ()
 creates reference for object
 read ($a_force_db=false)
 read object data from db into object
 addQuestion ($question_id)
 Adds a question to the survey.
 delete ()
 delete object and all related data
 deleteSurveyRecord ()
 Deletes the survey from the database.
 deleteAllUserData ()
 Deletes all user data of a survey.
 removeSelectedSurveyResults ($finished_ids)
 Deletes the user data of a given array of survey participants.
getSurveyParticipants ()
getSurveyParticipantsState ()
 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 1, if a survey is complete for use.
 _isComplete ($obj_id)
 Returns 1, if a survey is complete for use.
_getGlobalSurveyData ($obj_id)
 Returns an array with data needed in the repository, personal desktop or courses.
 saveCompletionStatus ()
 Saves the completion status of the survey.
 duplicateQuestionForSurvey ($question_id)
 Takes a question and creates a copy of the question for use in the survey.
 insertQuestion ($question_id)
 Inserts a question in the survey and saves the relation to the database.
 insertQuestionblock ($questionblock_id)
 Inserts a questionblock in the survey and saves the relation to the database.
 getAllRTEContent ()
 Returns the content of all RTE enabled text areas in the test.
 cleanupMediaobjectUsage ()
 Cleans up the media objects for all text fields in a test which are using an RTE field.
 saveUserSettings ($usr_id, $key, $title, $value)
 deleteUserSettings ($id)
 getUserSettings ($usr_id, $key)
 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 of the ilObjSurvey object.
 saveAuthorToMetadata ($a_author="")
 Saves an authors name into the lifecycle metadata if no lifecycle metadata exists This will only be called for conversion of "old" tests where the author hasn't been stored in the lifecycle metadata.
 getAuthor ()
 Gets the authors name of the ilObjSurvey object.
 getShowQuestionTitles ()
 Gets the status of the display_question_titles attribute.
 setShowQuestionTitles ($a_show)
 Sets 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.
 setRedirectAfterSurvey ($a_url="")
 Sets the redirect after survey.
 setRedirectOnlyKioskMode ($a_int=1)
 Sets the redirection only in kiosk mode.
 setMailConfirmation ($a_int=0)
 Sets the mail confirmation.
 setMailConfirmationSubject ($a_subject="")
 Sets the mail confirmation subject.
 setMailConfirmationBody ($a_body="")
 Sets the mail confirmation body.
 getInvitation ()
 Gets the invitation status.
 getInvitationMode ()
 Gets the invitation mode.
 getStatus ()
 Gets the survey status.
 isOnline ()
 Gets the survey status.
 isOffline ()
 Gets the survey status.
 setStatus ($status=STATUS_OFFLINE)
 Sets the survey status.
 getStartDate ()
 Gets the start date of the survey.
 canStartSurvey ($anonymous_id=NULL)
 Checks if the survey can be started.
 setStartDate ($start_date="")
 Sets the start date of the survey.
 setStartDateAndTime ($start_date="", $start_time)
 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.
 getStartHour ()
 Gets the start hour of the survey.
 getStartMinute ()
 Gets the start minute of the survey.
 getEndDate ()
 Gets the end date of the survey.
 setEndDate ($end_date="")
 Sets the end date of the survey.
 setEndDateAndTime ($end_date="", $end_time)
 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.
 getEndHour ()
 Gets the end hour of the survey.
 getEndMinute ()
 Gets the end minute 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.
 getRedirectAfterSurvey ()
 Gets redirect after survey.
 getRedirectOnlyKioskMode ()
 Gets the redirect only in kiosk mode.
 getMailConfirmation ()
 Gets the mail confirmation.
 getMailConfirmationSubject ()
 Gets mail confirmation subject.
 getMailConfirmationBody ()
 Gets mail confirmation body.
getExistingQuestions ()
 Gets the question id's of the questions which are already in the survey.
getQuestionpoolTitles ($could_be_offline=FALSE, $showPath=FALSE)
 Get the titles of all available survey question pools.
 moveUpQuestion ($question_id)
 Moves a question up in the list of survey questions.
 moveDownQuestion ($question_id)
 Moves a question down in the list of survey questions.
 moveUpQuestionblock ($questionblock_id)
 Moves a questionblock up in the list of survey questions.
 moveDownQuestionblock ($questionblock_id)
 Moves a questionblock down in the list of survey questions.
 moveQuestions ($move_questions, $target_index, $insert_mode)
 Move questions and/or questionblocks to another position.
 removeQuestion ($question_id)
 Remove a question from the survey.
 removeConstraintsConcerningQuestion ($question_id)
 Remove constraints concerning a question with a given question_id.
 removeQuestions ($remove_questions, $remove_questionblocks)
 Remove questions from the survey.
 unfoldQuestionblocks ($questionblocks)
 Unfolds question blocks of a question pool.
getQuestionblockQuestions ($questionblock_id)
 Returns the question titles of all questions of a question block.
getQuestionblockQuestionIds ($questionblock_id)
 Returns the question id's of all questions of a question block.
 getQuestionblock ($questionblock_id)
 Returns the database row for a given question block.
 _getQuestionblock ($questionblock_id)
 Returns the database row for a given question block.
 _addQuestionblock ($title="", $owner=0)
 Adds a questionblock to the database.
 createQuestionblock ($title, $show_questiontext, $questions)
 Creates a question block for the survey.
 modifyQuestionblock ($questionblock_id, $title, $show_questiontext)
 Modifies a question block.
 deleteConstraints ($question_id)
 Deletes the constraints for a question.
 deleteConstraint ($constraint_id)
 Deletes a constraint of a question.
getSurveyQuestions ($with_answers=false)
 Returns the survey questions and questionblocks in an array.
 setObligatoryStates ($obligatory_questions)
 Sets the obligatory states for questions in a survey from the questions form.
getObligatoryStates ()
 Gets specific obligatory states of the survey.
getSurveyPages ()
 Returns the survey pages in an array (a page contains one or more questions)
 getNextPage ($active_page_question_id, $direction)
 Returns the next "page" of a running test.
getAvailableQuestionpools ($use_obj_id=false, $could_be_offline=false, $showPath=FALSE, $permission="read")
 Returns the available question pools for the active user.
 getPrecondition ($id)
 Returns a precondition with a given id.
 getConstraints ($question_id)
 Returns the constraints to a given question or questionblock.
 _getConstraints ($survey_id)
 Returns the constraints to a given question or questionblock.
getVariables ($question_id)
 Returns all variables of a question.
 addConstraint ($if_question_id, $relation, $value, $conjunction)
 Adds a constraint.
 addConstraintToQuestion ($to_question_id, $constraint_id)
 Adds a constraint to a question.
 updateConstraint ($precondition_id, $if_question_id, $relation, $value, $conjunction)
 Updates a precondition.
 updateConjunctionForQuestions ($questions, $conjunction)
 getAllRelations ($short_as_key=false)
 Returns all available relations.
 disinviteAllUsers ()
 Disinvite all users.
 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.
 deleteWorkingData ($question_id, $active_id)
 Deletes the working data of a question in the database.
 loadWorkingData ($question_id, $active_id)
 Gets the working data of question from the database.
 fillSurveyForUser ($user_id=ANONYMOUS_USER_ID)
 Fills a survey randomly with data for a given user.
 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.
 setPage ($finished_id, $page_id)
 Sets the number of the active survey page.
 sendNotificationMail ($user_id, $anonymize_id)
 getDetailedParticipantResultsAsText ()
 isAllowedToTakeMultipleSurveys ($userid="")
 Checks if a user is allowed to take multiple survey.
 isSurveyStarted ($user_id, $anonymize_id)
 Checks if a user already started a survey.
 getActiveID ($user_id, $anonymize_id)
 Checks if a user already started a survey.
 getLastActivePage ($active_id)
 Returns the question id of the last active page a user visited in a survey.
 checkConstraint ($constraint_data, $working_data)
 Checks if a constraint is valid.
 _hasDatasets ($survey_id)
getSurveyFinishedIds ()
 Get the finished id's of all survey participants.
getUserSpecificResults ()
 Calculates the evaluation data for the user specific results.
 getUserDataFromActiveId ($active_id)
 Returns the user information from an active_id (survey_finished.finished_id)
 getUserStateFromActiveId ($active_id)
getEvaluationByUser ($questions, $active_id)
 Calculates the evaluation data for a given user or anonymous id.
 getCumulatedResults (&$question)
 Calculates the evaluation data for a question.
 _getNrOfParticipants ($survey_id)
 Returns the number of participants for a survey.
getQuestions ($question_ids)
 getQuestionsTable ($arrFilter)
 Calculates the data for the output of the question browser.
 getQuestionblocksTable ($arrFilter)
 Calculates the data for the output of the questionblock browser.
 toXML ()
 Returns a QTI xml representation of the survey.
_instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id.
 locateImportFiles ($a_dir)
 Locates the import directory and the xml file in a directory with an unzipped import file.
 importObject ($file_info, $svy_qpl_id)
 Imports a survey from XML into the ILIAS database.
 cloneObject ($a_target_id, $a_copy_id=0)
 Clone object.
 getTextblock ($question_id)
 cloneTextblocks ($mapping)
 Clones the textblocks of survey questions.
 createExportDirectory ()
 creates data directory for export files (data_dir/svy_data/svy_<id>/export, depending on data directory that is set in ILIAS setup/ini)
 getExportDirectory ()
 get export directory of survey
 getExportFiles ($dir)
 get export files
 createImportDirectory ()
 creates data directory for import files (data_dir/svy_data/svy_<id>/import, depending on data directory that is set in ILIAS setup/ini)
 getImportDirectory ()
 get import directory of survey
 saveHeading ($heading="", $insertbefore)
 isAnonymousKey ($key)
 getUserSurveyCode ($user_id)
 isAnonymizedParticipant ($key)
 checkSurveyCode ($code)
 getSurveyCodesCount ()
 Returns the number of generated survey codes for the survey.
 getSurveyCodesForExport ($a_array)
 Returns a list of survey codes for file export.
getSurveyCodesTableData ($lang="en")
 Fetches the data for the survey codes table.
 isSurveyCodeUsed ($code)
 isSurveyCodeUnique ($code)
 createSurveyCodes ($nrOfCodes)
 createSurveyCodesForExternalData ($data)
 sendCodes ($not_sent, $subject, $message)
 getExternalCodeRecipients ()
 deleteSurveyCode ($survey_code)
 Deletes a given survey access code.
 getUserAccessCode ($user_id)
 Returns a survey access code that was saved for a registered user.
 saveUserAccessCode ($user_id, $access_code)
 Saves a survey access code for a registered user to the database.
 createNewAccessCode ()
 Returns a new, unused survey access code.
processCSVRow ($row, $quoteAll=FALSE, $separator=";")
 Processes an array as a CSV row and converts the array values to correct CSV values.
 _getLastAccess ($finished_id)
 prepareTextareaOutput ($txt_output)
 Prepares a string for a text area output in surveys.
 isHTML ($a_text)
 Checks if a given string contains HTML or not.
 addMaterialTag (&$a_xml_writer, $a_material, $close_material_tag=TRUE, $add_mobs=TRUE, $attribs=NULL)
 Creates an XML material tag from a plain text or xhtml text.
 canExportSurveyCode ()
 Checks if the survey code can be exported with the survey evaluation.
 _checkCondition ($a_svy_id, $a_operator, $a_value, $a_usr_id=0)
 isPluginActive ($a_pname)
 Checks whether or not a question plugin with a given name is active.
 setSurveyId ($survey_id)
 Sets the survey id.
getUserData ($ids)
 Returns a data of all users specified by id list.
getGroupData ($ids)
getRoleData ($ids)
 getMailNotification ()
 setMailNotification ($a_notification)
 getMailAddresses ()
 setMailAddresses ($a_addresses)
 getMailParticipantData ()
 setMailParticipantData ($a_data)
 getSurveyTimes ()
 setStartTime ($finished_id, $first_question)
 setEndTime ($finished_id)
 getWorkingtimeForParticipant ($finished_id)
- Public Member Functions inherited from ilObject
 ilObject ($a_id=0, $a_reference=true)
 Constructor public.
 withReferences ()
 determines wehter objects are referenced or not (got ref ids or not)
 getId ()
 get object id public
 setId ($a_id)
 set object id public
 setRefId ($a_id)
 set reference id public
 getRefId ()
 get reference id public
 getType ()
 get object type public
 setType ($a_type)
 set object type public
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions
 getTitle ()
 get object title public
 getUntranslatedTitle ()
 get untranslated object title public
 setTitle ($a_title)
 set object title
 getDescription ()
 get object description
 setDescription ($a_desc)
 set object description
 getLongDescription ()
 get object long description (stored in object_description)
 getImportId ()
 get import id
 setImportId ($a_import_id)
 set import id
 _lookupObjIdByImportId ($a_import_id)
 getOwner ()
 get object owner
 getOwnerName ()
 _lookupOwnerName ($a_owner_id)
 lookup owner name for owner id
 setOwner ($a_owner)
 set object owner
 getCreateDate ()
 get create date public
 getLastUpdateDate ()
 get last update date public
 getDiskUsage ()
 Gets the disk usage of the object in bytes.
 setObjDataRecord ($a_record)
 set object_data record (note: this method should only be called from the ilObjectFactory class)
 create ()
 create
 MDUpdateListener ($a_element)
 Meta data update listener.
 updateMetaData ()
 update meta data entry
 deleteMetaData ()
 delete meta data entry
 updateOwner ()
 update owner of object in db
 _getIdForImportId ($a_import_id)
 get current object id for import id (static)
 _lookupOwner ($a_id)
 lookup object owner
 _lookupDescription ($a_id)
 lookup object description
 _lookupLastUpdate ($a_id, $a_as_string=false)
 lookup last update
 _getLastUpdateOfObjects ($a_objs)
 Get last update for a set of media objects.
 _setDeletedDate ($a_ref_id)
 only called in ilTree::saveSubTree
 _resetDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes
 _lookupDeletedDate ($a_ref_id)
 only called in ilObjectGUI::insertSavedNodes
 _writeTitle ($a_obj_id, $a_title)
 write title to db (static)
 _writeDescription ($a_obj_id, $a_desc)
 write description to db (static)
 _writeImportId ($a_obj_id, $a_import_id)
 write import id to db (static)
 _isInTrash ($a_ref_id)
 checks wether object is in trash
 _hasUntrashedReference ($a_obj_id)
 checks wether an object has at least one reference that is not in trash
 _lookupObjectId ($a_ref_id)
 lookup object id
 _getObjectsDataForType ($a_type, $a_omit_trash=false)
 get all objects of a certain type
 putInTree ($a_parent_ref)
 maybe this method should be in tree object!?
 setPermissions ($a_parent_ref)
 set permissions of object
 countReferences ()
 count references of object
 initDefaultRoles ()
 init default roles settings Purpose of this function is to create a local role folder and local roles, that are needed depending on the object type If you want to setup default local roles you MUST overwrite this method in derived object classes (see ilObjForum for an example) public
 createRoleFolder ()
 creates a local role folder
 setRegisterMode ($a_bool)
 isUserRegistered ($a_user_id=0)
 requireRegistration ()
 getXMLZip ()
 getHTMLDirectory ()
 appendCopyInfo ($a_target_id, $a_copy_id)
 Prepend Copy info if object with same name exists in that container.
 cloneDependencies ($a_target_id, $a_copy_id)
 Clone object dependencies.
 cloneMetaData ($target_obj)
 Copy meta data.

Data Fields

 $survey_id
 $author
 $introduction
 $outro
 $status
 $evaluation_access
 $start_date
 $startdate_enabled
 $end_date
 $enddate_enabled
 $questions
 $invitation
 $invitation_mode
 $anonymize
 $display_question_titles
 $surveyCodeSecurity
 $mailnotification
 $mailaddresses
 $mailparticipantdata
- Data Fields inherited from ilObject
const TITLE_LENGTH = 128
 max length of object title
 $ilias
 $lng
 $id
 $ref_id
 $type
 $title
 $untranslatedTitle
 $desc
 $long_desc
 $owner
 $create_date
 $last_update
 $import_id
 $register = false
 $referenced
 $objectList
 $max_title
 $max_desc
 $add_dots
 $obj_data_record
 object_data record

Protected Member Functions

 getParticipantTextResults ($active_id)

Private Attributes

 $_redirect_after_survey
 $_redirect_only_kiosk_mode
 $_mail_confirmation
 $_mail_confirmation_subject
 $_mail_confirmation_body

Additional Inherited Members

- Static Public Member Functions inherited from ilObject
static _getAllReferences ($a_id)
 get all reference ids of object
static _lookupTitle ($a_id)
 lookup object title
static _getIdsForTitle ($title, $type= '', $partialmatch=false)
static _lookupObjId ($a_id)
static _lookupType ($a_id, $a_reference=false)
 lookup object type
 _exists ($a_id, $a_reference=false)
 checks if an object exists in object_data
static _getObjectsByType ($a_obj_type="", $a_owner="")
 Get objects by type.
static _prepareCloneSelection ($a_ref_ids, $new_type)
 Prepare copy wizard object selection.
static _getIcon ($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
 Get icon for repository item.
static collectDeletionDependencies (&$deps, $a_ref_id, $a_obj_id, $a_type, $a_depth=0)
 Collect deletion dependencies.
static getDeletionDependencies ($a_obj_id)
 Get deletion dependencies.

Detailed Description

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

Member Function Documentation

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

Adds a questionblock to the database.

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

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

References $ilDB, ilObject\$owner, and ilObject\$title.

Referenced by cloneObject().

{
global $ilDB;
$next_id = $ilDB->nextId('svy_qblk');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_qblk (questionblock_id, title, owner_fi, tstamp) " .
"VALUES (%s, %s, %s, %s)",
array('integer','text','integer','integer'),
array($next_id, $title, $owner, time())
);
return $next_id;
}

+ Here is the caller graph for this function:

ilObjSurvey::_checkCondition (   $a_svy_id,
  $a_operator,
  $a_value,
  $a_usr_id = 0 
)

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

References ilObjSurveyAccess\_lookupFinished().

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

+ Here is the call graph for this function:

ilObjSurvey::_getConstraints (   $survey_id)

Returns the constraints to a given question or questionblock.

public

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

References $ilDB, $row, and $survey_id.

Referenced by cloneObject().

{
global $ilDB;
$result_array = array();
$result = $ilDB->queryF("SELECT svy_qst_constraint.question_fi as for_question, svy_constraint.*, svy_relation.* ".
"FROM svy_qst_constraint, svy_constraint, svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id ".
"AND svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.survey_fi = %s",
array('integer'),
array($survey_id)
);
while ($row = $ilDB->fetchAssoc($result))
{
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"], 'conjunction' => $row['conjunction']));
}
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
array resulting array public

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

References ilObjSurvey().

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

+ Here is the call graph for this function:

ilObjSurvey::_getLastAccess (   $finished_id)

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

References $ilDB, and $row.

{
global $ilDB;
$result = $ilDB->queryF("SELECT tstamp FROM svy_answer WHERE active_fi = %s ORDER BY tstamp DESC",
array('integer'),
array($finished_id)
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
return $row["tstamp"];
}
else
{
$result = $ilDB->queryF("SELECT tstamp FROM svy_finished WHERE finished_id = %s",
array('integer'),
array($finished_id)
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
return $row["tstamp"];
}
}
return "";
}
ilObjSurvey::_getNrOfParticipants (   $survey_id)

Returns the number of participants for a survey.

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

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

References $ilDB, and $survey_id.

Referenced by SurveyQuestion\calculateCumulatedResults(), SurveyTextQuestionGUI\getCumulatedResultsDetails(), SurveyMetricQuestionGUI\getCumulatedResultsDetails(), SurveyMultipleChoiceQuestionGUI\getCumulatedResultsDetails(), SurveySingleChoiceQuestionGUI\getCumulatedResultsDetails(), SurveyMatrixQuestionGUI\getCumulatedResultsDetails(), SurveyMetricQuestion\outChart(), SurveyMultipleChoiceQuestion\outChart(), SurveySingleChoiceQuestion\outChart(), and SurveyMatrixQuestion\outChart().

{
global $ilDB;
$result = $ilDB->queryF("SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
array('integer'),
array($survey_id)
);
return $result->numRows();
}

+ Here is the caller graph for this function:

ilObjSurvey::_getQuestionblock (   $questionblock_id)

Returns the database row for a given question block.

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

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

References $ilDB, and $row.

Referenced by cloneObject().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM svy_qblk WHERE questionblock_id = %s",
array('integer'),
array($questionblock_id)
);
$row = $ilDB->fetchAssoc($result);
return $row;
}

+ Here is the caller graph for this function:

ilObjSurvey::_hasDatasets (   $survey_id)

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

References $ilDB, and $survey_id.

{
global $ilDB;
$result = $ilDB->queryF("SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
array('integer'),
array($survey_id)
);
return ($result->numRows()) ? true : false;
}
& ilObjSurvey::_instanciateQuestion (   $question_id)

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

Parameters
integer$question_idThe question id
Returns
object The question instance public

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

References SurveyQuestion\_getQuestionType(), and SurveyQuestion\_includeClass().

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

{
if ($question_id < 1) return FALSE;
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
$question_type = SurveyQuestion::_getQuestionType($question_id);
if (strlen($question_type) == 0) return FALSE;
$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 1, if a survey is complete for use.

Returns
boolean 1, if the survey is complete for use, otherwise 0 public

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

References ilObjSurvey().

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

+ Here is the call graph for this function:

ilObjSurvey::addConstraint (   $if_question_id,
  $relation,
  $value,
  $conjunction 
)

Adds a constraint.

Parameters
integer$if_question_idThe question id of the question which defines a precondition
integer$relationThe database id of the relation
mixed$valueThe value compared with the relation public

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

References $ilDB.

{
global $ilDB;
$next_id = $ilDB->nextId('svy_constraint');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_constraint (constraint_id, question_fi, relation_fi, value, conjunction) VALUES ".
"(%s, %s, %s, %s, %s)",
array('integer','integer','integer','float', 'integer'),
array($next_id, $if_question_id, $relation, $value, $conjunction)
);
if ($affectedRows)
{
return $next_id;
}
else
{
return null;
}
}
ilObjSurvey::addConstraintToQuestion (   $to_question_id,
  $constraint_id 
)

Adds a constraint to a question.

Parameters
integer$to_question_idThe question id of the question where to add the constraint
integer$constraint_idThe id of the constraint

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

References $ilDB, and getSurveyId().

{
global $ilDB;
$next_id = $ilDB->nextId('svy_qst_constraint');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_qst_constraint (question_constraint_id, survey_fi, question_fi, ".
"constraint_fi) VALUES (%s, %s, %s, %s)",
array('integer','integer','integer','integer'),
array($next_id, $this->getSurveyId(), $to_question_id, $constraint_id)
);
}

+ Here is the call graph for this function:

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

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

Parameters
object$a_xml_writerReference to the ILIAS XML writer
string$a_materialplain text or html text containing the material
Returns
string XML material tag public

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

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

Referenced by toXML().

{
include_once "./Services/RTE/classes/class.ilRTE.php";
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
$a_xml_writer->xmlStartTag("material", $attribs);
$attrs = array(
"type" => "text/plain"
);
if ($this->isHTML($a_material))
{
$attrs["type"] = "text/xhtml";
}
$mattext = ilRTE::_replaceMediaObjectImageSrc($a_material, 0);
$a_xml_writer->xmlElement("mattext", $attrs, $mattext);
if ($add_mobs)
{
foreach ($mobs as $mob)
{
$mob_id = "il_" . IL_INST_ID . "_mob_" . $mob;
if (strpos($mattext, $mob_id) !== FALSE)
{
$mob_obj =& new ilObjMediaObject($mob);
$imgattrs = array(
"label" => $mob_id,
"uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle()
);
$a_xml_writer->xmlElement("matimage", $imgattrs, NULL);
}
}
}
if ($close_material_tag) $a_xml_writer->xmlEndTag("material");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::addQuestion (   $question_id)

Adds a question to the survey.

Parameters
integer$question_idThe question id of the question public

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

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

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

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

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

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

References ANONYMIZE_OFF, and getAnonymize().

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

+ Here is the call graph for this function:

ilObjSurvey::canStartSurvey (   $anonymous_id = NULL)

Checks if the survey can be started.

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

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

References $messages, ilDatePresentation\formatDate(), getEndDate(), getEndDateEnabled(), getStartDate(), getStartDateEnabled(), getStatus(), IL_CAL_TIMESTAMP, isSurveyStarted(), and STATUS_OFFLINE.

{
global $ilAccess;
$result = TRUE;
$messages = array();
// check start date
if ($this->getStartDateEnabled())
{
if (preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->getStartDate(), $matches))
{
$epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
$now = mktime();
if ($now < $epoch_time)
{
array_push($messages,$this->lng->txt('start_date_not_reached').' ('.
$result = FALSE;
}
}
}
// check end date
if ($this->getEndDateEnabled())
{
if (preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->getEndDate(), $matches))
{
$epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
$now = mktime();
if ($now > $epoch_time)
{
array_push($messages,$this->lng->txt('end_date_reached').' ('.
$result = FALSE;
}
}
}
// check online status
if ($this->getStatus() == STATUS_OFFLINE)
{
array_push($messages, $this->lng->txt("survey_is_offline"));
$result = FALSE;
}
// check rbac permissions
if (!$ilAccess->checkAccess("read", "", $this->ref_id))
{
array_push($messages, $this->lng->txt("cannot_participate_survey"));
$result = FALSE;
}
// 2. check previous access
if (!$result["error"])
{
global $ilUser;
$survey_started = $this->isSurveyStarted($ilUser->getId(), $anonymous_id);
if ($survey_started === 1)
{
array_push($messages, $this->lng->txt("already_completed_survey"));
$result = FALSE;
}
}
return array(
"result" => $result,
"messages" => $messages
);
}

+ Here is the call graph for this function:

ilObjSurvey::checkConstraint (   $constraint_data,
  $working_data 
)

Checks if a constraint is valid.

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

Definition at line 3526 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;
}
switch ($constraint_data["short"])
{
case "<":
$all = true;
foreach ($working_data as $data)
{
if (!($data["value"] < $constraint_data["value"]))
{
$all = false;
}
}
if ($all) return 1;
break;
case "<=":
$all = true;
foreach ($working_data as $data)
{
if (!($data["value"] <= $constraint_data["value"]))
{
$all = false;
}
}
if ($all) return 1;
break;
case "=":
$found = false;
foreach ($working_data as $data)
{
if ($data["value"] == $constraint_data["value"])
{
$found = true;
}
}
if ($found) return 1;
break;
case "<>":
$all = true;
foreach ($working_data as $data)
{
if (!($data["value"] <> $constraint_data["value"]))
{
$all = false;
}
}
if ($all) return 1;
break;
case ">=":
$all = true;
foreach ($working_data as $data)
{
if (!($data["value"] >= $constraint_data["value"]))
{
$all = false;
}
}
if ($all) return 1;
break;
case ">":
$all = true;
foreach ($working_data as $data)
{
if (!($data["value"] > $constraint_data["value"]))
{
$all = false;
}
}
if ($all) return 1;
break;
}
return 0;
}
ilObjSurvey::checkSurveyCode (   $code)

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

References isAnonymousKey(), and isSurveyStarted().

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

+ Here is the call graph for this function:

ilObjSurvey::cleanupMediaobjectUsage ( )

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

private

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

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

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

+ Here is the call graph for this function:

ilObjSurvey::cloneObject (   $a_target_id,
  $a_copy_id = 0 
)

Clone object.

public

Parameters
intref_id of target container
intcopy id
Returns
object new svy object

Reimplemented from ilObject.

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

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

{
global $ilDB;
$this->loadFromDb();
// Copy settings
$newObj = parent::cloneObject($a_target_id,$a_copy_id);
$this->cloneMetaData($newObj);
$newObj->setAuthor($this->getAuthor());
$newObj->setIntroduction($this->getIntroduction());
$newObj->setOutro($this->getOutro());
$newObj->setStatus($this->getStatus());
$newObj->setEvaluationAccess($this->getEvaluationAccess());
$newObj->setStartDate($this->getStartDate());
$newObj->setStartDateEnabled($this->getStartDateEnabled());
$newObj->setEndDate($this->getEndDate());
$newObj->setEndDateEnabled($this->getEndDateEnabled());
$newObj->setInvitation($this->getInvitation());
$newObj->setInvitationMode($this->getInvitationMode());
$newObj->setAnonymize($this->getAnonymize());
$newObj->setShowQuestionTitles($this->getShowQuestionTitles());
$question_pointer = array();
// clone the questions
$mapping = array();
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
foreach ($this->questions as $key => $question_id)
{
$question = ilObjSurvey::_instanciateQuestion($question_id);
$question->id = -1;
$original_id = SurveyQuestion::_getOriginalId($question_id);
$question->saveToDb($original_id);
$newObj->questions[$key] = $question->getId();
$question_pointer[$question_id] = $question->getId();
$mapping[$question_id] = $question->getId();
}
$newObj->saveToDb();
$newObj->cloneTextblocks($mapping);
// clone the questionblocks
$questionblocks = array();
$questionblock_questions = array();
$result = $ilDB->queryF("SELECT * FROM svy_qblk_qst WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
if ($result->numRows() > 0)
{
while ($row = $ilDB->fetchAssoc($result))
{
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)
{
$next_id = $ilDB->nextId('svy_qblk_qst');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, question_fi) ".
"VALUES (%s, %s, %s, %s)",
array('integer','integer','integer','integer'),
array($next_id, $newObj->getSurveyId(), $questionblocks[$value["questionblock_fi"]], $question_pointer[$value["question_fi"]])
);
}
// clone the constraints
$constraints = ilObjSurvey::_getConstraints($this->getSurveyId());
$newConstraints = array();
foreach ($constraints as $key => $constraint)
{
if (!array_key_exists($constraint['id'], $newConstraints))
{
$constraint_id = $newObj->addConstraint($question_pointer[$constraint["question"]], $constraint["relation_id"], $constraint["value"], $constraint['conjunction']);
$newConstraints[$constraint['id']] = $constraint_id;
}
$newObj->addConstraintToQuestion($question_pointer[$constraint["for_question"]], $newConstraints[$constraint['id']]);
}
// clone the obligatory states
$result = $ilDB->queryF("SELECT * FROM svy_qst_oblig WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
if ($result->numRows() > 0)
{
while ($row = $ilDB->fetchAssoc($result))
{
$next_id = $ilDB->nextId('svy_qst_oblig');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, ".
"obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)",
array('integer','integer','integer','text','integer'),
array($next_id, $newObj->getSurveyId(), $question_pointer[$row["question_fi"]], $row["obligatory"], time())
);
}
}
return $newObj;
}

+ Here is the call graph for this function:

ilObjSurvey::cloneTextblocks (   $mapping)

Clones the textblocks of survey questions.

public

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

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

{
foreach ($mapping as $original_id => $new_id)
{
$textblock = $this->getTextblock($original_id);
include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
}
}

+ Here is the call graph for this function:

ilObjSurvey::create (   $a_upload = false)

create survey object

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

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

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

+ Here is the call graph for this function:

ilObjSurvey::createExportDirectory ( )

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

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

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

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

+ Here is the call graph for this function:

ilObjSurvey::createImportDirectory ( )

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

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

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

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

+ Here is the call graph for this function:

ilObjSurvey::createMetaData ( )

Create meta data entry.

public

Reimplemented from ilObject.

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

References saveAuthorToMetadata().

Referenced by create().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::createNewAccessCode ( )

Returns a new, unused survey access code.

Returns
string A new survey access code

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

References isSurveyCodeUnique().

Referenced by createSurveyCodes(), createSurveyCodesForExternalData(), and fillSurveyForUser().

{
// 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->isSurveyCodeUnique($code))
{
$code = $this->createNewAccessCode();
}
return $code;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::createQuestionblock (   $title,
  $show_questiontext,
  $questions 
)

Creates a question block for the survey.

Parameters
string$titleThe title of the question block
array$questionsAn array with the database id's of the question block questions public

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

References $ilDB, $questions, ilObject\$title, deleteConstraints(), getSurveyId(), and moveQuestions().

Referenced by insertQuestionblock().

{
global $ilDB;
// if the selected questions are not in a continous selection, move all questions of the
// questionblock at the position of the first selected question
// now save the question block
global $ilUser;
$next_id = $ilDB->nextId('svy_qblk');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_qblk (questionblock_id, title, show_questiontext, owner_fi, ".
"tstamp) VALUES (%s, %s, %s, %s, %s)",
array('integer','text','text','integer','integer'),
array($next_id, $title, $show_questiontext, $ilUser->getId(), time())
);
if ($affectedRows)
{
$questionblock_id = $next_id;
foreach ($questions as $index)
{
$next_id = $ilDB->nextId('svy_qblk_qst');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
"question_fi) VALUES (%s, %s, %s, %s)",
array('integer','integer','integer','integer'),
array($next_id, $this->getSurveyId(), $questionblock_id, $index)
);
$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 273 of file class.ilObjSurvey.php.

References saveToDb().

{
$this->saveToDb();
return $result;
}

+ Here is the call graph for this function:

ilObjSurvey::createSurveyCodes (   $nrOfCodes)

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

References $ilDB, createNewAccessCode(), and getSurveyId().

{
global $ilDB;
for ($i = 0; $i < $nrOfCodes; $i++)
{
$anonymize_key = $this->createNewAccessCode();
$next_id = $ilDB->nextId('svy_anonymous');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, tstamp) ".
"VALUES (%s, %s, %s, %s)",
array('integer','text','integer','integer'),
array($next_id, $anonymize_key, $this->getSurveyId(), time())
);
}
}

+ Here is the call graph for this function:

ilObjSurvey::createSurveyCodesForExternalData (   $data)

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

References $data, $ilDB, createNewAccessCode(), and getSurveyId().

{
global $ilDB;
foreach ($data as $dataset)
{
$anonymize_key = $this->createNewAccessCode();
$next_id = $ilDB->nextId('svy_anonymous');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) ".
"VALUES (%s, %s, %s, %s, %s)",
array('integer','text','integer','text','integer'),
array($next_id, $anonymize_key, $this->getSurveyId(), serialize($dataset), time())
);
}
}

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

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

{
$remove = parent::delete();
// always call parent delete function first!!
if (!$remove)
{
return false;
}
$this->deleteMetaData();
// Delete all survey questions, constraints and materials
foreach ($this->questions as $question_id)
{
$this->removeQuestion($question_id);
}
return true;
}

+ Here is the call graph for this function:

ilObjSurvey::deleteAllUserData ( )

Deletes all user data of a survey.

public

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

References $ilDB, $row, and getSurveyId().

Referenced by deleteSurveyRecord().

{
global $ilDB;
$result = $ilDB->queryF("SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
$active_array = array();
while ($row = $ilDB->fetchAssoc($result))
{
array_push($active_array, $row["finished_id"]);
}
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_finished WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
foreach ($active_array as $active_fi)
{
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_answer WHERE active_fi = %s",
array('integer'),
array($active_fi)
);
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_times WHERE finished_fi = %s",
array('integer'),
array($active_fi)
);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::deleteConstraint (   $constraint_id)

Deletes a constraint of a question.

Parameters
integer$constraint_idThe database id of the constraint
integer$question_idThe database id of the question public

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

References $ilDB.

Referenced by deleteConstraints(), and moveQuestions().

{
global $ilDB;
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_constraint WHERE constraint_id = %s",
array('integer'),
array($constraint_id)
);
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_qst_constraint WHERE constraint_fi = %s",
array('integer'),
array($constraint_id)
);
}

+ Here is the caller graph for this function:

ilObjSurvey::deleteConstraints (   $question_id)

Deletes the constraints for a question.

Parameters
integer$question_idThe database id of the question public

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

References $ilDB, $row, deleteConstraint(), and getSurveyId().

Referenced by createQuestionblock().

{
global $ilDB;
$result = $ilDB->queryF("SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
array('integer','integer'),
array($question_id, $this->getSurveyId())
);
$constraints = array();
while ($row = $ilDB->fetchAssoc($result))
{
array_push($constraints, $row["constraint_fi"]);
}
foreach ($constraints as $constraint_id)
{
$this->deleteConstraint($constraint_id);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::deleteSurveyCode (   $survey_code)

Deletes a given survey access code.

Parameters
string$survey_codeThe survey code that should be deleted

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

References $ilDB, and getSurveyId().

{
global $ilDB;
if (strlen($survey_code) > 0)
{
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
array('integer', 'text'),
array($this->getSurveyId(), $survey_code)
);
}
}

+ Here is the call graph for this function:

ilObjSurvey::deleteSurveyRecord ( )

Deletes the survey from the database.

public

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

References $ilDB, $mobs, $row, ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), ilUtil\delDir(), deleteAllUserData(), ilUtil\getDataDir(), ilObject\getId(), and getSurveyId().

Referenced by delete().

{
global $ilDB;
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_svy WHERE survey_id = %s",
array('integer'),
array($this->getSurveyId())
);
$result = $ilDB->queryF("SELECT questionblock_fi FROM svy_qblk_qst WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
$questionblocks = array();
while ($row = $ilDB->fetchAssoc($result))
{
array_push($questionblocks, $row["questionblock_fi"]);
}
if (count($questionblocks))
{
$affectedRows = $ilDB->manipulate("DELETE FROM svy_qblk WHERE " . $ilDB->in('questionblock_id', $questionblocks, false, 'integer'));
}
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_qblk_qst WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_anonymous WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
// delete export files
include_once "./Services/Utilities/classes/class.ilUtil.php";
$svy_data_dir = ilUtil::getDataDir()."/svy_data";
$directory = $svy_data_dir."/svy_".$this->getId();
if (is_dir($directory))
{
include_once "./Services/Utilities/classes/class.ilUtil.php";
ilUtil::delDir($directory);
}
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
// 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::deleteUserSettings (   $id)

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

References ilObject\$id, and $ilDB.

{
global $ilDB;
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_settings WHERE settings_id = %s",
array('integer'),
array($id)
);
return $affectedRows;
}
ilObjSurvey::deleteWorkingData (   $question_id,
  $active_id 
)

Deletes the working data of a question in the database.

Parameters
integer$question_idThe database id of the question
integer$active_idThe active id of the user who worked through the question public

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

References $ilDB.

{
global $ilDB;
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
array('integer','integer'),
array($question_id, $active_id)
);
}
ilObjSurvey::disinviteAllUsers ( )

Disinvite all users.

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

References $ilDB, $row, disinviteUser(), and getSurveyId().

Referenced by setInvitation().

{
global $ilDB;
$result = $ilDB->queryF("SELECT user_fi FROM svy_inv_usr WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
while ($row = $ilDB->fetchAssoc($result))
{
$this->disinviteUser($row['user_fi']);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::disinviteUser (   $user_id)

Disinvites a user from a survey.

Parameters
integer$user_idThe database id of the disinvited user

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

References $ilDB, ilObjUser\_dropDesktopItem(), ilObject\getRefId(), and getSurveyId().

Referenced by disinviteAllUsers().

{
global $ilDB;
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_inv_usr WHERE survey_fi = %s AND user_fi = %s",
array('integer','integer'),
array($this->getSurveyId(), $user_id)
);
include_once './Services/User/classes/class.ilObjUser.php';
ilObjUser::_dropDesktopItem($user_id, $this->getRefId(), "svy");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::duplicateQuestionForSurvey (   $question_id)

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

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

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

References getQuestionGUI(), and getQuestionType().

Referenced by insertQuestion(), and insertQuestionblock().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::fillSurveyForUser (   $user_id = ANONYMOUS_USER_ID)

Fills a survey randomly with data for a given user.

Parameters
integer$user_idThe database id of the user. If empty an anonymous user will be taken public

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

References $ilDB, _instanciateQuestion(), createNewAccessCode(), getSurveyId(), getSurveyPages(), and saveUserAccessCode().

{
global $ilDB;
// create an anonymous key
$anonymous_id = $this->createNewAccessCode();
$this->saveUserAccessCode($user_id, $anonymous_id);
// create the survey_finished dataset and set the survey finished already
$active_id = $ilDB->nextId('svy_finished');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_finished (finished_id, survey_fi, user_fi, anonymous_id, state, tstamp) ".
"VALUES (%s, %s, %s, %s, %s, %s)",
array('integer','integer','integer','text','text','integer'),
array($active_id, $this->getSurveyId(), $user_id, $anonymous_id, 1, time())
);
// fill the questions randomly
$pages =& $this->getSurveyPages();
foreach ($pages as $key => $question_array)
{
foreach ($question_array as $question)
{
// instanciate question
require_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
$question =& SurveyQuestion::_instanciateQuestion($question["question_id"]);
$question->saveRandomData($active_id);
}
}
}

+ Here is the call graph for this function:

ilObjSurvey::finishSurvey (   $user_id,
  $anonymize_id 
)

Finishes the survey creating an entry in the database.

Parameters
integer$user_idThe database id of the user who finishes the survey public

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

References $ilDB, getAnonymize(), getMailNotification(), getSurveyId(), and sendNotificationMail().

{
global $ilDB;
if ($this->getAnonymize())
{
$affectedRows = $ilDB->manipulateF("UPDATE svy_finished SET state = %s, user_fi = %s, tstamp = %s ".
"WHERE survey_fi = %s AND anonymous_id = %s",
array('text','integer','integer','integer','text'),
array(1, $user_id, time(), $this->getSurveyId(), $anonymize_id)
);
}
else
{
$affectedRows = $ilDB->manipulateF("UPDATE svy_finished SET state = %s, tstamp = %s WHERE survey_fi = %s AND user_fi = %s",
array('text','integer','integer','integer'),
array(1, time(), $this->getSurveyId(), $user_id)
);
}
if ($this->getMailNotification())
{
$this->sendNotificationMail($user_id, $anonymize_id);
}
}

+ Here is the call graph for this function:

ilObjSurvey::getActiveID (   $user_id,
  $anonymize_id 
)

Checks if a user already started a survey.

Parameters
integer$user_idThe 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 3454 of file class.ilObjSurvey.php.

References $ilDB, $row, getAnonymize(), getSurveyId(), isAccessibleWithoutCode(), and isAllowedToTakeMultipleSurveys().

Referenced by sendNotificationMail().

{
global $ilDB;
if ($this->getAnonymize())
{
if ((($user_id != ANONYMOUS_USER_ID) && (strlen($anonymize_id) == 0)) && (!($this->isAccessibleWithoutCode() && $this->isAllowedToTakeMultipleSurveys())))
{
$result = $ilDB->queryF("SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
array('integer','integer'),
array($this->getSurveyId(), $user_id)
);
}
else
{
$result = $ilDB->queryF("SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
array('integer','text'),
array($this->getSurveyId(), $anonymize_id)
);
}
}
else
{
$result = $ilDB->queryF("SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
array('integer','integer'),
array($this->getSurveyId(), $user_id)
);
}
if ($result->numRows() == 0)
{
return false;
}
else
{
$row = $ilDB->fetchAssoc($result);
return $row["finished_id"];
}
}

+ 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.

public

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

References $ilDB, and $row.

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

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

private

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

References getIntroduction(), and getOutro().

Referenced by cleanupMediaobjectUsage().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getAnonymize ( )

get anonymize status

Returns
integer status

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

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

{
return ($this->anonymize) ? $this->anonymize : 0;
}

+ Here is the caller graph for this function:

ilObjSurvey::getAnonymousId (   $id)

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

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

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

References ilObject\$id, $ilDB, and $row.

{
global $ilDB;
$result = $ilDB->queryF("SELECT anonymous_id FROM svy_finished WHERE anonymous_id = %s",
array('text'),
array($id)
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
return $row["anonymous_id"];
}
else
{
return "";
}
}
ilObjSurvey::getAuthor ( )

Gets the authors name of the ilObjSurvey object.

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

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

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

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Returns the available question pools for the active user.

Returns
array The available question pools public

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

References ilObjSurveyQuestionPool\_getAvailableQuestionpools().

Referenced by getQuestionsTable().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getConstraints (   $question_id)

Returns the constraints to a given question or questionblock.

public

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

References $ilDB, $row, SurveyQuestion\_getQuestionType(), SurveyQuestion\_includeClass(), and getSurveyId().

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

{
global $ilDB;
$result_array = array();
$result = $ilDB->queryF("SELECT svy_constraint.*, svy_relation.* FROM svy_qst_constraint, svy_constraint, svy_relation ".
"WHERE svy_constraint.relation_fi = svy_relation.relation_id AND ".
"svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.question_fi = %s ".
"AND svy_qst_constraint.survey_fi = %s",
array('integer','integer'),
array($question_id, $this->getSurveyId())
);
while ($row = $ilDB->fetchAssoc($result))
{
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
$question_type = SurveyQuestion::_getQuestionType($row["question_fi"]);
$question = new $question_type();
$question->loadFromDb($row["question_fi"]);
$valueoutput = $question->getPreconditionValueOutput($row["value"]);
array_push($result_array, array("id" => $row["constraint_id"], "question" => $row["question_fi"], "short" => $row["shortname"], "long" => $row["longname"], "value" => $row["value"], "conjunction" => $row["conjunction"], "valueoutput" => $valueoutput));
}
return $result_array;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getCumulatedResults ( $question)

Calculates the evaluation data for a question.

Parameters
integer$question_idThe database id of the question
integer$user_idThe database id of the user
Returns
array An array containing the evaluation parameters for the question public

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

References $ilDB, and getSurveyId().

Referenced by getDetailedParticipantResultsAsText().

{
global $ilDB;
$result = $ilDB->queryF("SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
$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:

+ Here is the caller graph for this function:

ilObjSurvey::getDetailedParticipantResultsAsText ( )

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

References $data, $questions, _instanciateQuestion(), getCumulatedResults(), and getSurveyQuestions().

{
$counter = 0;
$counter++;
foreach ($questions as $data)
{
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
$question = SurveyQuestion::_instanciateQuestion($data["question_id"]);
$eval = $this->getCumulatedResults($question);
}
}

+ Here is the call graph for this function:

ilObjSurvey::getEndDate ( )

Gets the end date of the survey.

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

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

Referenced by canStartSurvey(), cloneObject(), getEndDay(), getEndHour(), getEndMinute(), getEndMonth(), getEndYear(), and saveToDb().

{
return (strlen($this->end_date)) ? $this->end_date : NULL;
}

+ Here is the caller graph for this function:

ilObjSurvey::getEndDateEnabled ( )

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

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

{
return ($this->enddate_enabled) ? $this->enddate_enabled : 0;
}

+ Here is the caller graph for this function:

ilObjSurvey::getEndDay ( )

Gets the end day of the survey.

Returns
string Survey end day public
See Also
$end_date

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

References getEndDate(), IL_CAL_FKT_DATE, and IL_CAL_TIMESTAMP.

Referenced by toXML().

{
$dt = new ilDateTime($this->getEndDate(), IL_CAL_TIMESTAMP);
return $dt->get(IL_CAL_FKT_DATE, 'd');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getEndHour ( )

Gets the end hour of the survey.

Returns
string Survey end hour public
See Also
$end_date

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

References getEndDate(), IL_CAL_FKT_DATE, and IL_CAL_TIMESTAMP.

Referenced by toXML().

{
$dt = new ilDateTime($this->getEndDate(), IL_CAL_TIMESTAMP);
return $dt->get(IL_CAL_FKT_DATE, 'H');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getEndMinute ( )

Gets the end minute of the survey.

Returns
string Survey end minute public
See Also
$end_date

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

References getEndDate(), IL_CAL_FKT_DATE, and IL_CAL_TIMESTAMP.

Referenced by toXML().

{
$dt = new ilDateTime($this->getEndDate(), IL_CAL_TIMESTAMP);
return $dt->get(IL_CAL_FKT_DATE, 'i');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getEndMonth ( )

Gets the end month of the survey.

Returns
string Survey end month public
See Also
$end_date

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

References getEndDate(), IL_CAL_FKT_DATE, and IL_CAL_TIMESTAMP.

Referenced by toXML().

{
$dt = new ilDateTime($this->getEndDate(), IL_CAL_TIMESTAMP);
return $dt->get(IL_CAL_FKT_DATE, 'm');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getEndYear ( )

Gets the end year of the survey.

Returns
string Survey end year public
See Also
$end_date

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

References getEndDate(), IL_CAL_FKT_DATE, and IL_CAL_TIMESTAMP.

Referenced by toXML().

{
$dt = new ilDateTime($this->getEndDate(), IL_CAL_TIMESTAMP);
return $dt->get(IL_CAL_FKT_DATE, 'Y');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getEvaluationAccess ( )

Gets the learners evaluation access.

Returns
integer The evaluation access public
See Also
$evaluation_access

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

References EVALUATION_ACCESS_OFF.

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

{
return ($this->evaluation_access) ? $this->evaluation_access : EVALUATION_ACCESS_OFF;
}

+ Here is the caller graph for this function:

& ilObjSurvey::getEvaluationByUser (   $questions,
  $active_id 
)

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

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

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

References $ilDB, $questions, $row, and getUserDataFromActiveId().

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

+ Here is the call graph for this function:

& ilObjSurvey::getExistingQuestions ( )

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

References $data, $ilDB, and getSurveyId().

Referenced by getQuestionsTable().

{
global $ilDB;
$existing_questions = array();
$result = $ilDB->queryF("SELECT svy_question.original_id FROM svy_question, svy_svy_qst WHERE " .
"svy_svy_qst.survey_fi = %s AND svy_svy_qst.question_fi = svy_question.question_id",
array('integer'),
array($this->getSurveyId())
);
while ($data = $ilDB->fetchAssoc($result))
{
array_push($existing_questions, $data["original_id"]);
}
return $existing_questions;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getExportDirectory ( )

get export directory of survey

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

References ilUtil\getDataDir().

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

+ Here is the call graph for this function:

ilObjSurvey::getExportFiles (   $dir)

get export files

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

References $dir, and $file.

{
// quit if import dir not available
if (!@is_dir($dir) or
!is_writeable($dir))
{
return array();
}
// open directory
$dir = dir($dir);
// initialize array
$file = array();
// get files and save the in the array
while ($entry = $dir->read())
{
if ($entry != "." and
$entry != ".." and
ereg("^[0-9]{10}_{2}[0-9]+_{2}(survey__)*[0-9]+\.xml|zip\$", $entry))
{
$file[] = $entry;
}
}
// close import directory
$dir->close();
// sort files
sort ($file);
reset ($file);
return $file;
}
ilObjSurvey::getExternalCodeRecipients ( )

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

References $ilDB, $res, $row, and getSurveyId().

Referenced by sendCodes().

{
global $ilDB;
$result = $ilDB->queryF("SELECT survey_key code, externaldata, sent FROM svy_anonymous WHERE survey_fi = %s AND externaldata IS NOT NULL",
array('integer'),
array($this->getSurveyId())
);
$res = array();
while ($row = $ilDB->fetchAssoc($result))
{
$externaldata = unserialize($row['externaldata']);
$externaldata['code'] = $row['code'];
$externaldata['sent'] = $row['sent'];
array_push($res, $externaldata);
}
return $res;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& ilObjSurvey::getGroupData (   $ids)

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

References ilObject\$ref_id, ilObject\_lookupDescription(), ilObject\_lookupObjId(), and ilObject\_lookupTitle().

{
if (!is_array($ids) || count($ids) ==0) return array();
$result = array();
foreach ($ids as $ref_id)
{
$obj_id = ilObject::_lookupObjId($ref_id);
$result[$ref_id] = array("ref_id" => $ref_id, "title" => ilObject::_lookupTitle($obj_id), "description" => ilObject::_lookupDescription($obj_id));
}
return $result;
}

+ Here is the call graph for this function:

ilObjSurvey::getImportDirectory ( )

get import directory of survey

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

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

Referenced by delete(), and importObject().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getIntroduction ( )

Gets the introduction text.

Returns
string The introduction of the survey object public
See Also
$introduction

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

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

{
return (strlen($this->introduction)) ? $this->introduction : NULL;
}

+ Here is the caller graph for this function:

ilObjSurvey::getInvitation ( )

Gets the invitation status.

Returns
integer The invitation status public
See Also
$invitation

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

References INVITATION_OFF.

Referenced by cloneObject(), inviteGroup(), inviteRole(), inviteUser(), and saveToDb().

{
return ($this->invitation) ? $this->invitation : INVITATION_OFF;
}

+ Here is the caller graph for this function:

ilObjSurvey::getInvitationMode ( )

Gets the invitation mode.

Returns
integer The invitation mode public
See Also
$invitation

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

References MODE_PREDEFINED_USERS, and MODE_UNLIMITED.

Referenced by cloneObject(), saveToDb(), and setInvitation().

{
include_once "./Services/Administration/classes/class.ilSetting.php";
$surveySetting = new ilSetting("survey");
$unlimited_invitation = $surveySetting->get("unlimited_invitation");
if (!$unlimited_invitation && $this->invitation_mode == MODE_UNLIMITED)
{
}
else
{
return ($this->invitation_mode) ? $this->invitation_mode : MODE_UNLIMITED;
}
}

+ Here is the caller graph for this function:

& ilObjSurvey::getInvitedUsers ( )

Returns a list of all invited users in a survey.

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

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

References $ilDB, $row, and getSurveyId().

{
global $ilDB;
$result_array = array();
$result = $ilDB->queryF("SELECT user_fi FROM svy_inv_usr WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
while ($row = $ilDB->fetchAssoc($result))
{
array_push($result_array, $row["user_fi"]);
}
return $result_array;
}

+ Here is the call graph for this function:

ilObjSurvey::getLastActivePage (   $active_id)

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

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

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

References $ilDB, and $row.

{
global $ilDB;
$result = $ilDB->queryF("SELECT lastpage FROM svy_finished WHERE finished_id = %s",
array('integer'),
array($active_id)
);
if ($result->numRows() == 0)
{
return "";
}
else
{
$row = $ilDB->fetchAssoc($result);
return ($row["lastpage"]) ? $row["lastpage"] : '';
}
}
ilObjSurvey::getMailAddresses ( )

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

References $mailaddresses.

Referenced by saveToDb().

{
}

+ Here is the caller graph for this function:

ilObjSurvey::getMailConfirmation ( )

Gets the mail confirmation.

Returns
integer mail confirmation public
See Also
$_mail_confirmation

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

References $_mail_confirmation.

Referenced by saveToDb().

+ Here is the caller graph for this function:

ilObjSurvey::getMailConfirmationBody ( )

Gets mail confirmation body.

Returns
string the mail confirmation body public
See Also
$_mail_confirmation_body

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

References $_mail_confirmation_body.

Referenced by saveToDb().

+ Here is the caller graph for this function:

ilObjSurvey::getMailConfirmationSubject ( )

Gets mail confirmation subject.

Returns
string the mail confirmation subject public
See Also
$_mail_confirmation_subject

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

References $_mail_confirmation_subject.

Referenced by saveToDb().

+ Here is the caller graph for this function:

ilObjSurvey::getMailNotification ( )

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

References $mailnotification.

Referenced by finishSurvey(), and saveToDb().

+ Here is the caller graph for this function:

ilObjSurvey::getMailParticipantData ( )

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

References $mailparticipantdata.

Referenced by saveToDb().

+ Here is the caller graph for this function:

ilObjSurvey::getNextPage (   $active_page_question_id,
  $direction 
)

Returns the next "page" of a running test.

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

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

References getSurveyPages().

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

+ Here is the call graph for this function:

& ilObjSurvey::getObligatoryStates ( )

Gets specific obligatory states of the survey.

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

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

References $ilDB, $row, and getSurveyId().

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

{
global $ilDB;
$obligatory_states = array();
$result = $ilDB->queryF("SELECT * FROM svy_qst_oblig WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
if ($result->numRows())
{
while ($row = $ilDB->fetchAssoc($result))
{
$obligatory_states[$row["question_fi"]] = $row["obligatory"];
}
}
return $obligatory_states;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getOutro ( )

Gets the outro text.

Returns
string The outro of the survey object public
See Also
$outro

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

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

{
return (strlen($this->outro)) ? $this->outro : NULL;
}

+ Here is the caller graph for this function:

ilObjSurvey::getParticipantTextResults (   $active_id)
protected

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

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

Referenced by sendNotificationMail().

{
$textresult = "";
$userResults =& $this->getUserSpecificResults();
$questions =& $this->getSurveyQuestions(true);
$questioncounter = 1;
foreach ($questions as $question_id => $question_data)
{
$textresult .= $questioncounter++ . ". " . $question_data["title"] . "\n";
$found = $userResults[$question_id][$active_id];
$text = "";
if (is_array($found))
{
$text = implode("\n", $found);
}
else
{
$text = $found;
}
if (strlen($text) == 0) $text = $this->lng->txt("skipped");
$text = str_replace("<br />", "\n", $text);
$textresult .= $text . "\n\n";
}
return $textresult;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getPrecondition (   $id)

Returns a precondition with a given id.

public

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

References ilObject\$id, and $ilDB.

{
global $ilDB;
$result_array = array();
$result = $ilDB->queryF("SELECT svy_constraint.*, svy_relation.* FROM svy_qst_constraint, svy_constraint, ".
"svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id AND ".
"svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_constraint.constraint_id = %s",
array('integer'),
array($id)
);
$pc = array();
if ($result->numRows())
{
$pc = $ilDB->fetchAssoc($result);
}
return $pc;
}
ilObjSurvey::getQuestionblock (   $questionblock_id)

Returns the database row for a given question block.

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

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

References $ilDB.

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM svy_qblk WHERE questionblock_id = %s",
array('integer'),
array($questionblock_id)
);
return $ilDB->fetchAssoc($result);
}
& ilObjSurvey::getQuestionblockQuestionIds (   $questionblock_id)

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

References $data, and $ilDB.

{
global $ilDB;
$result = $ilDB->queryF("SELECT question_fi FROM svy_qblk_qst WHERE questionblock_fi = %s",
array("integer"),
array($questionblock_id)
);
$ids = array();
if ($result->numRows())
{
while ($data = $ilDB->fetchAssoc($result))
{
array_push($ids, $data['question_fi']);
}
}
return $ids;
}
& ilObjSurvey::getQuestionblockQuestions (   $questionblock_id)

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

References $ilDB, $row, and $survey_id.

Referenced by getQuestionblocksTable().

{
global $ilDB;
$titles = array();
$result = $ilDB->queryF("SELECT svy_question.title, svy_qblk_qst.question_fi, svy_qblk_qst.survey_fi FROM ".
"svy_qblk, svy_qblk_qst, svy_question WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND " .
"svy_question.question_id = svy_qblk_qst.question_fi AND svy_qblk.questionblock_id = %s",
array('integer'),
array($questionblock_id)
);
$survey_id = "";
while ($row = $ilDB->fetchAssoc($result))
{
$titles[$row["question_fi"]] = $row["title"];
$survey_id = $row["survey_fi"];
}
$result = $ilDB->queryF("SELECT question_fi, sequence FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
array('integer'),
array($survey_id)
);
$resultarray = array();
$counter = 1;
while ($row = $ilDB->fetchAssoc($result))
{
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::getQuestionblocksTable (   $arrFilter)

Calculates the data for the output of the questionblock browser.

public

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

References $data, $ilDB, $row, ilObject\_getObjectsDataForType(), and getQuestionblockQuestions().

{
global $ilUser;
global $ilDB;
$where = "";
if (is_array($arrFilter))
{
if (array_key_exists('title', $arrFilter) && strlen($arrFilter['title']))
{
$where .= " AND " . $ilDB->like('svy_qblk.title', 'text', "%%" . $arrFilter['title'] . "%%");
}
}
$query_result = $ilDB->query("SELECT svy_qblk.*, svy_svy.obj_fi FROM svy_qblk , svy_qblk_qst, svy_svy WHERE ".
"svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_svy.survey_id = svy_qblk_qst.survey_fi ".
"$where GROUP BY svy_qblk.questionblock_id, svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.owner_fi, svy_qblk.tstamp, svy_svy.obj_fi");
$rows = array();
if ($query_result->numRows())
{
$surveys = ilObject::_getObjectsDataForType('svy', true);
$surveytitles = array();
foreach ($surveys as $data)
{
$surveytitles[$data['id']] = $data['title'];
}
while ($row = $ilDB->fetchAssoc($query_result))
{
$questions_array =& $this->getQuestionblockQuestions($row["questionblock_id"]);
$counter = 1;
foreach ($questions_array as $key => $value)
{
$questions_array[$key] = "$counter. $value";
$counter++;
}
if (strlen($surveytitles[$row["obj_fi"]])) // only questionpools which are not in trash
{
$rows[$row["questionblock_id"]] = array(
"questionblock_id" => $row["questionblock_id"],
"title" => $row["title"],
"svy" => $surveytitles[$row["obj_fi"]],
"contains" => join($questions_array, ", "),
"owner" => $row["owner_fi"]
);
}
}
}
return $rows;
}

+ Here is the call graph for this function:

ilObjSurvey::getQuestionGUI (   $questiontype,
  $question_id 
)

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

Returns
object Resulting question gui object public

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

References SurveyQuestionGUI\_getQuestionGUI().

Referenced by duplicateQuestionForSurvey().

{
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
return SurveyQuestionGUI::_getQuestionGUI($questiontype, $question_id);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Get the titles of all available survey question pools.

Returns
array An array of survey question pool titles public

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

References ilObjSurveyQuestionPool\_getAvailableQuestionpools().

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

+ Here is the call graph for this function:

& ilObjSurvey::getQuestions (   $question_ids)

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

References $ilDB, and $row.

{
$result_array = array();
$result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype WHERE ".
"svy_question.questiontype_fi = svy_qtype.questiontype_id AND svy_question.tstamp > 0 AND ".
$ilDB->in('svy_question.question_id', $question_ids, false, 'integer'));
while ($row = $ilDB->fetchAssoc($result))
{
array_push($result_array, $row);
}
return $result_array;
}
ilObjSurvey::getQuestionsTable (   $arrFilter)

Calculates the data for the output of the question browser.

public

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

References $ilDB, $row, ilObjSurveyQuestionPool\_getQuestionTypeTranslations(), getAvailableQuestionpools(), getExistingQuestions(), and isPluginActive().

{
global $ilUser;
global $ilDB;
$where = "";
if (is_array($arrFilter))
{
if (array_key_exists('title', $arrFilter) && strlen($arrFilter['title']))
{
$where .= " AND " . $ilDB->like('svy_question.title', 'text', "%%" . $arrFilter['title'] . "%%");
}
if (array_key_exists('description', $arrFilter) && strlen($arrFilter['description']))
{
$where .= " AND " . $ilDB->like('svy_question.description', 'text', "%%" . $arrFilter['description'] . "%%");
}
if (array_key_exists('author', $arrFilter) && strlen($arrFilter['author']))
{
$where .= " AND " . $ilDB->like('svy_question.author', 'text', "%%" . $arrFilter['author'] . "%%");
}
if (array_key_exists('type', $arrFilter) && strlen($arrFilter['type']))
{
$where .= " AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter['type'], 'text');
}
if (array_key_exists('spl', $arrFilter) && strlen($arrFilter['spl']))
{
$where .= " AND svy_question.obj_fi = " . $ilDB->quote($arrFilter['spl'], 'integer');
}
}
$spls =& $this->getAvailableQuestionpools($use_obj_id = TRUE, $could_be_offline = FALSE, $showPath = FALSE);
$forbidden = "";
$forbidden = " AND " . $ilDB->in('svy_question.obj_fi', array_keys($spls), false, 'integer');
$forbidden .= " AND svy_question.complete = " . $ilDB->quote("1", 'text');
$existing = "";
$existing_questions =& $this->getExistingQuestions();
if (count($existing_questions))
{
$existing = " AND " . $ilDB->in('svy_question.question_id', $existing_questions, true, 'integer');
}
include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
$query_result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin, object_reference.ref_id FROM svy_question, svy_qtype, object_reference WHERE svy_question.original_id IS NULL$forbidden$existing AND svy_question.obj_fi = object_reference.obj_id AND svy_question.tstamp > 0 AND svy_question.questiontype_fi = svy_qtype.questiontype_id " . $where);
$rows = array();
if ($query_result->numRows())
{
while ($row = $ilDB->fetchAssoc($query_result))
{
$row['ttype'] = $trans[$row['type_tag']];
if ($row["plugin"])
{
if ($this->isPluginActive($row["type_tag"]))
{
array_push($rows, $row);
}
}
else
{
array_push($rows, $row);
}
}
}
return $rows;
}

+ Here is the call graph for this function:

ilObjSurvey::getQuestionType (   $question_id)

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

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

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

References $data, and $ilDB.

Referenced by duplicateQuestionForSurvey().

{
global $ilDB;
if ($question_id < 1) return -1;
$result = $ilDB->queryF("SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND " .
"svy_question.questiontype_fi = svy_qtype.questiontype_id",
array('integer'),
array($question_id)
);
if ($result->numRows() == 1)
{
$data = $ilDB->fetchAssoc($result);
return $data["type_tag"];
}
else
{
return "";
}
}

+ Here is the caller graph for this function:

ilObjSurvey::getRedirectAfterSurvey ( )

Gets redirect after survey.

Returns
string the redirection url after survey public
See Also
$_redirect_after_survey

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

References $_redirect_after_survey.

Referenced by saveToDb().

+ Here is the caller graph for this function:

ilObjSurvey::getRedirectOnlyKioskMode ( )

Gets the redirect only in kiosk mode.

Returns
integer redirect only in kiosk mode public
See Also
$_redirect_only_kiosk_mode

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

References $_redirect_only_kiosk_mode.

Referenced by saveToDb().

+ Here is the caller graph for this function:

& ilObjSurvey::getRoleData (   $ids)

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

References ilObject\_lookupDescription(), and ilObject\_lookupTitle().

{
if (!is_array($ids) || count($ids) ==0) return array();
$result = array();
foreach ($ids as $obj_id)
{
$result[$obj_id] = array("obj_id" => $obj_id, "title" => ilObject::_lookupTitle($obj_id), "description" => ilObject::_lookupDescription($obj_id));
}
return $result;
}

+ Here is the call graph for this function:

ilObjSurvey::getShowQuestionTitles ( )

Gets the status of the display_question_titles attribute.

Returns
integer The status of the display_question_titles attribute
See Also
$display_question_titles

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

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

{
return ($this->display_question_titles) ? 1 : 0;
}

+ Here is the caller graph for this function:

ilObjSurvey::getStartDate ( )

Gets the start date of the survey.

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

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

Referenced by canStartSurvey(), cloneObject(), getStartDay(), getStartHour(), getStartMinute(), getStartMonth(), getStartYear(), and saveToDb().

{
return (strlen($this->start_date)) ? $this->start_date : NULL;
}

+ Here is the caller graph for this function:

ilObjSurvey::getStartDateEnabled ( )

Gets the enabled state of the start date.

Returns
integer 1 for an enabled end date, 0 otherwise public
See Also
$start_date

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

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

{
return ($this->startdate_enabled) ? $this->startdate_enabled : 0;
}

+ Here is the caller graph for this function:

ilObjSurvey::getStartDay ( )

Gets the start day of the survey.

Returns
string Survey start day public
See Also
$start_date

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

References getStartDate(), IL_CAL_FKT_DATE, and IL_CAL_TIMESTAMP.

Referenced by toXML().

{
return $dt->get(IL_CAL_FKT_DATE, 'd');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getStartHour ( )

Gets the start hour of the survey.

Returns
string Survey start hour public
See Also
$start_date

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

References getStartDate(), IL_CAL_FKT_DATE, and IL_CAL_TIMESTAMP.

Referenced by toXML().

{
return $dt->get(IL_CAL_FKT_DATE, 'H');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getStartMinute ( )

Gets the start minute of the survey.

Returns
string Survey start minute public
See Also
$start_date

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

References getStartDate(), IL_CAL_FKT_DATE, and IL_CAL_TIMESTAMP.

Referenced by toXML().

{
return $dt->get(IL_CAL_FKT_DATE, 'i');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getStartMonth ( )

Gets the start month of the survey.

Returns
string Survey start month public
See Also
$start_date

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

References getStartDate(), IL_CAL_FKT_DATE, and IL_CAL_TIMESTAMP.

Referenced by toXML().

{
return $dt->get(IL_CAL_FKT_DATE, 'm');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getStartYear ( )

Gets the start year of the survey.

Returns
string Survey start year public
See Also
$start_date

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

References getStartDate(), IL_CAL_FKT_DATE, and IL_CAL_TIMESTAMP.

Referenced by toXML().

{
return $dt->get(IL_CAL_FKT_DATE, 'Y');
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getStatus ( )

Gets the survey status.

Returns
integer Survey status public
See Also
$status

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

References STATUS_OFFLINE.

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

{
return ($this->status) ? $this->status : STATUS_OFFLINE;
}

+ Here is the caller graph for this function:

ilObjSurvey::getSurveyCodesCount ( )

Returns the number of generated survey codes for the survey.

Returns
integer The number of generated survey codes public

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

References $ilDB, and getSurveyId().

{
global $ilDB;
$result = $ilDB->queryF("SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND user_key IS NULL",
array('integer'),
array($this->getSurveyId())
);
return $result->numRows();
}

+ Here is the call graph for this function:

ilObjSurvey::getSurveyCodesForExport (   $a_array)

Returns a list of survey codes for file export.

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

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

References $ilDB, $lang, $row, ilObject\getRefId(), getSurveyId(), IL_CAL_DATE, IL_CAL_UNIX, and isSurveyCodeUsed().

{
global $ilDB, $ilUser;
$result = $ilDB->queryF("SELECT svy_anonymous.*, svy_finished.state FROM svy_anonymous ".
"LEFT JOIN svy_finished ON svy_anonymous.survey_key = svy_finished.anonymous_id ".
"WHERE svy_anonymous.survey_fi = %s AND svy_anonymous.user_key IS NULL",
array('integer'),
array($this->getSurveyId())
);
$export = "";
$default_lang = $ilUser->getPref("survey_code_language");
$lang = (strlen($default_lang)) ? "&lang=" . $default_lang : "";
while ($row = $ilDB->fetchAssoc($result))
{
if (in_array($row["survey_key"], $a_array) || (count($a_array) == 0))
{
$export .= $row["survey_key"] . ",";
// No relative (today, tomorrow...) dates in export.
$date = new ilDate($row['tstamp'],IL_CAL_UNIX);
$created = $date->get(IL_CAL_DATE);
$export .= "$created,";
if ($this->isSurveyCodeUsed($row["survey_key"]))
{
$export .= "1,";
}
else
{
$export .= "0,";
}
$url = ILIAS_HTTP_PATH."/goto.php?cmd=infoScreen&target=svy_".$this->getRefId() . "&client_id=" . CLIENT_ID . "&accesscode=".$row["survey_key"].$lang;
$export .= $url . "\n";
}
}
return $export;
}

+ Here is the call graph for this function:

& ilObjSurvey::getSurveyCodesTableData (   $lang = "en")

Fetches the data for the survey codes table.

Parameters
string$langLanguage for the survey code URL
Returns
array The requested data public

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

References $ilDB, $lang, $row, ilDatePresentation\formatDate(), ilObject\getRefId(), getSurveyId(), IL_CAL_UNIX, and isSurveyCodeUsed().

{
global $ilDB;
include_once "./classes/class.ilFormat.php";
if (strlen($lang) == 0) $lang = "en";
$order = "ORDER BY tstamp, survey_key ASC";
$codes = array();
$result = $ilDB->queryF("SELECT svy_anonymous.anonymous_id, svy_anonymous.survey_key, svy_anonymous.survey_fi, ".
"svy_anonymous.tstamp, svy_finished.state FROM svy_anonymous LEFT JOIN svy_finished ".
"ON svy_anonymous.survey_key = svy_finished.anonymous_id WHERE svy_anonymous.survey_fi = %s ".
"AND svy_anonymous.user_key IS NULL $order",
array('integer'),
array($this->getSurveyId())
);
if ($result->numRows() > 0)
{
while ($row = $ilDB->fetchAssoc($result))
{
$url = "";
$state = 0;
if ($this->isSurveyCodeUsed($row["survey_key"]))
{
$state = 1;
}
else
{
$addlang = "";
if (strlen($lang))
{
$addlang = "&amp;lang=$lang";
}
$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");
}
array_push($codes, array('code' => $row["survey_key"], 'date' => $created, 'used' => $state, 'url' => $url, 'href' => $href));
}
}
return $codes;
}

+ Here is the call graph for this function:

& ilObjSurvey::getSurveyFinishedIds ( )

Get the finished id's of all survey participants.

Returns
array An array containing finished_id's of all survey participants public

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

References $ilDB, $ilLog, $row, and getSurveyId().

{
global $ilDB, $ilLog;
$users = array();
$result = $ilDB->queryF("SELECT * FROM svy_finished WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
if ($result->numRows())
{
while ($row = $ilDB->fetchAssoc($result))
{
array_push($users, $row["finished_id"]);
}
}
return $users;
}

+ Here is the call graph for this function:

& ilObjSurvey::getSurveyPages ( )

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

public

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

References $ilDB, $row, getConstraints(), getObligatoryStates(), and getSurveyId().

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

{
global $ilDB;
$obligatory_states =& $this->getObligatoryStates();
// get questionblocks
$all_questions = array();
$result = $ilDB->queryF("SELECT svy_question.*, svy_qtype.type_tag, svy_svy_qst.heading FROM " .
"svy_question, svy_qtype, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
"svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id ".
"ORDER BY svy_svy_qst.sequence",
array('integer'),
array($this->getSurveyId())
);
while ($row = $ilDB->fetchAssoc($result))
{
$all_questions[$row["question_id"]] = $row;
}
// get all questionblocks
$questionblocks = array();
if (count($all_questions))
{
$result = $ilDB->queryF("SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst ".
"WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s ".
"AND " . $ilDB->in('svy_qblk_qst.question_fi', array_keys($all_questions), false, 'integer'),
array('integer'),
array($this->getSurveyId())
);
while ($row = $ilDB->fetchAssoc($result))
{
$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]['page'] = $pageindex;
$all_questions[$question_id]["questionblock_title"] = $questionblocks[$question_id]['title'];
$all_questions[$question_id]["questionblock_id"] = $questionblocks[$question_id]['questionblock_id'];
$all_questions[$question_id]["questionblock_show_questiontext"] = $questionblocks[$question_id]['show_questiontext'];
$currentblock = $questionblocks[$question_id]['questionblock_id'];
$constraints = $this->getConstraints($question_id);
$all_questions[$question_id]["constraints"] = $constraints;
}
else
{
$pageindex++;
$all_questions[$question_id]['page'] = $pageindex;
$all_questions[$question_id]["questionblock_title"] = "";
$all_questions[$question_id]["questionblock_id"] = "";
$all_questions[$question_id]["questionblock_show_questiontext"] = 1;
$currentblock = "";
$constraints = $this->getConstraints($question_id);
$all_questions[$question_id]["constraints"] = $constraints;
}
if (!isset($all_pages[$pageindex]))
{
$all_pages[$pageindex] = array();
}
array_push($all_pages[$pageindex], $all_questions[$question_id]);
}
// calculate position percentage for every page
$max = count($all_pages);
$counter = 1;
foreach ($all_pages as $index => $block)
{
foreach ($block as $blockindex => $question)
{
$all_pages[$index][$blockindex]["position"] = $counter / $max;
}
$counter++;
}
return $all_pages;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& ilObjSurvey::getSurveyParticipants ( )

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

References $ilDB, $row, getSurveyId(), and getUserDataFromActiveId().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM svy_finished WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
$participants = array();
if ($result->numRows() > 0)
{
while ($row = $ilDB->fetchAssoc($result))
{
$userdata = $this->getUserDataFromActiveId($row["finished_id"]);
$participants[$userdata["sortname"] . $userdata["active_id"]] = $userdata;
}
}
return $participants;
}

+ Here is the call graph for this function:

& ilObjSurvey::getSurveyParticipantsState ( )

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

References $ilDB, $query, $row, DB_FETCHMODE_ASSOC, and getUserStateFromActiveId().

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

+ Here is the call graph for this function:

& ilObjSurvey::getSurveyQuestions (   $with_answers = false)

Returns the survey questions and questionblocks in an array.

public

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

References $data, $ilDB, $row, _instanciateQuestion(), getConstraints(), getObligatoryStates(), getSurveyId(), and isPluginActive().

Referenced by getDetailedParticipantResultsAsText(), getParticipantTextResults(), getUserSpecificResults(), moveDownQuestion(), moveUpQuestion(), and removeQuestions().

{
global $ilDB;
$obligatory_states =& $this->getObligatoryStates();
// get questionblocks
$all_questions = array();
$result = $ilDB->queryF("SELECT svy_qtype.type_tag, svy_qtype.plugin, svy_question.question_id, ".
"svy_svy_qst.heading FROM svy_qtype, svy_question, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
"svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
"ORDER BY svy_svy_qst.sequence",
array('integer'),
array($this->getSurveyId())
);
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
while ($row = $ilDB->fetchAssoc($result))
{
$add = true;
if ($row["plugin"])
{
if (!$this->isPluginActive($row["type_tag"]))
{
$add = false;
}
}
if ($add)
{
$question =& $this->_instanciateQuestion($row["question_id"]);
$questionrow = $question->_getQuestionDataArray($row["question_id"]);
foreach ($row as $key => $value)
{
$questionrow[$key] = $value;
}
$all_questions[$row["question_id"]] = $questionrow;
$all_questions[$row["question_id"]]["usableForPrecondition"] = $question->usableForPrecondition();
$all_questions[$row["question_id"]]["availableRelations"] = $question->getAvailableRelations();
if (array_key_exists($row["question_id"], $obligatory_states))
{
$all_questions[$row["question_id"]]["obligatory"] = $obligatory_states[$row["question_id"]];
}
}
}
// get all questionblocks
$questionblocks = array();
if (count($all_questions))
{
$result = $ilDB->queryF("SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst WHERE " .
"svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
"AND " . $ilDB->in('svy_qblk_qst.question_fi', array_keys($all_questions), false, 'integer'),
array('integer'),
array($this->getSurveyId())
);
while ($row = $ilDB->fetchAssoc($result))
{
$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();
$result = $ilDB->queryF("SELECT svy_variable.*, svy_category.title FROM svy_variable, svy_category " .
"WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id ".
"ORDER BY sequence ASC",
array('integer'),
array($question_id)
);
if ($result->numRows() > 0)
{
while ($data = $ilDB->fetchAssoc($result))
{
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::getSurveyTimes ( )

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

References $ilDB, $row, and ilObject\getId().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM svy_times, svy_finished WHERE svy_finished.survey_fi = %s",
array('integer'),
array($this->getId())
);
$times = array();;
while ($row = $ilDB->fetchAssoc($result))
{
if (strlen($row['left_page']) && strlen($row['entered_page']))
$times[$row['finished_fi']] += ($row['left_page']-$row['entered_page']);
}
return $times;
}

+ Here is the call graph for this function:

ilObjSurvey::getTextblock (   $question_id)

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

References $ilDB, and $row.

Referenced by cloneTextblocks().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM svy_svy_qst WHERE question_fi = %s",
array('integer'),
array($question_id)
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
return $row["heading"];
}
else
{
return "";
}
}

+ Here is the caller graph for this function:

ilObjSurvey::getUserAccessCode (   $user_id)

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

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

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

References $ilDB, $row, and getSurveyId().

{
global $ilDB;
$access_code = "";
$result = $ilDB->queryF("SELECT survey_key FROM svy_anonymous WHERE survey_fi = %s AND user_key = %s",
array('integer','text'),
array($this->getSurveyId(), md5($user_id))
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
$access_code = $row["survey_key"];
}
return $access_code;
}

+ Here is the call graph for this function:

& ilObjSurvey::getUserData (   $ids)

Returns a data of all users specified by id list.

Parameters
$idsarray of user id's
Returns
array The user data "usr_id, login, lastname, firstname, clientip" of the users with id as key

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

References $ilDB, and $row.

{
global $ilDB;
if (!is_array($ids) || count($ids) ==0) return array();
$result = $ilDB->query("SELECT usr_id, login, lastname, firstname FROM usr_data WHERE " . $ilDB->in('usr_id', $ids, false, 'integer') . " ORDER BY login");
$result_array = array();
while ($row = $ilDB->fetchAssoc($result))
{
$result_array[$row["usr_id"]]= $row;
}
return $result_array;
}
ilObjSurvey::getUserDataFromActiveId (   $active_id)

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

Parameters
integer$active_idThe active id of the user
Returns
array An array containing the user data public

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

References $_GET, $ilDB, $name, $row, ilObjUser\_lookupLogin(), and getAnonymize().

Referenced by getEvaluationByUser(), and getSurveyParticipants().

{
global $ilDB;
$surveySetting = new ilSetting("survey");
$use_anonymous_id = array_key_exists("use_anonymous_id", $_GET) ? $_GET["use_anonymous_id"] : $surveySetting->get("use_anonymous_id");
$result = $ilDB->queryF("SELECT * FROM svy_finished WHERE finished_id = %s",
array('integer'),
array($active_id)
);
$row = array();
$foundrows = $result->numRows();
if ($foundrows)
{
$row = $ilDB->fetchAssoc($result);
}
$name = ($use_anonymous_id) ? $row["anonymous_id"] : $this->lng->txt("anonymous");
$userdata = array(
"fullname" => $name,
"sortname" => $name,
"firstname" => "",
"lastname" => "",
"login" => "",
"gender" => "",
"active_id" => "$active_id"
);
if ($foundrows)
{
if (($row["user_fi"] > 0) && ($row["user_fi"] != ANONYMOUS_USER_ID) && ($this->getAnonymize() == 0))
{
include_once './Services/User/classes/class.ilObjUser.php';
if (strlen(ilObjUser::_lookupLogin($row["user_fi"])) == 0)
{
$userdata["fullname"] = $this->lng->txt("deleted_user");
}
else
{
$user = new ilObjUser($row["user_fi"]);
$userdata["fullname"] = $user->getFullname();
$gender = $user->getGender();
if (strlen($gender) == 1) $gender = $this->lng->txt("gender_$gender");
$userdata["gender"] = $gender;
$userdata["firstname"] = $user->getFirstname();
$userdata["lastname"] = $user->getLastname();
$userdata["sortname"] = $user->getLastname() . ", " . $user->getFirstname();
$userdata["login"] = $user->getLogin();
}
}
}
return $userdata;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getUserSettings (   $usr_id,
  $key 
)

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

References $ilDB, $row, and $usr_id.

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM svy_settings WHERE usr_id = %s AND keyword = %s",
array('integer', 'text'),
array($usr_id, $key)
);
$found = array();
if ($result->numRows())
{
while ($row = $ilDB->fetchAssoc($result))
{
$found[$row['settings_id']] = $row;
}
}
return $found;
}
& ilObjSurvey::getUserSpecificResults ( )

Calculates the evaluation data for the user specific results.

Returns
array An array containing the user specific results public

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

References $data, $ilDB, $questions, $row, SurveyQuestion\_getQuestionType(), SurveyQuestion\_includeClass(), getSurveyId(), and getSurveyQuestions().

Referenced by getParticipantTextResults().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getUserStateFromActiveId (   $active_id)

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

References $ilDB, $query, $row, ilObjUser\_lookupLogin(), and DB_FETCHMODE_ASSOC.

Referenced by getSurveyParticipantsState().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::getUserSurveyCode (   $user_id)

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

References $ilDB, $row, getSurveyId(), isAccessibleWithoutCode(), and isAllowedToTakeMultipleSurveys().

{
global $ilDB;
if (($user_id == ANONYMOUS_USER_ID) || (($this->isAccessibleWithoutCode() && $this->isAllowedToTakeMultipleSurveys()))) return "";
$result = $ilDB->queryF("SELECT anonymous_id FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
array('integer','integer'),
array($this->getSurveyId(), $user_id)
);
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
return $row["anonymous_id"];
}
else
{
return "";
}
}

+ Here is the call graph for this function:

& ilObjSurvey::getVariables (   $question_id)

Returns all variables of a question.

public

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

References $ilDB, and $row.

{
global $ilDB;
$result_array = array();
$result = $ilDB->queryF("SELECT svy_variable.*, svy_category.title FROM svy_variable LEFT JOIN ".
"svy_category ON svy_variable.category_fi = svy_category.category_id WHERE svy_variable.question_fi = %s ".
"ORDER BY svy_variable.sequence",
array('integer'),
array($question_id)
);
while ($row = $ilDB->fetchObject($result))
{
$result_array[$row->sequence] = $row;
}
return $result_array;
}
ilObjSurvey::getWorkingtimeForParticipant (   $finished_id)

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

References $ilDB, $row, and $total.

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM svy_times WHERE finished_fi = %s",
array('integer'),
array($finished_id)
);
$total = 0;
while ($row = $ilDB->fetchAssoc($result))
{
if ($row['left_page'] > 0 && $row['entered_page'] > 0)
$total += $row['left_page'] - $row['entered_page'];
}
return $total;
}
ilObjSurvey::hideQuestionTitles ( )

Sets the question titles hidden during the query.

public

See Also
$display_question_titles

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

{
$this->display_question_titles = 0;
}
ilObjSurvey::ilObjSurvey (   $a_id = 0,
  $a_call_by_reference = true 
)

Constructor public.

Parameters
integerreference_id or object_id
booleantreat the id as reference_id (true) or object_id (false)

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

References ANONYMIZE_OFF, EVALUATION_ACCESS_OFF, ilObject\ilObject(), INVITATION_OFF, MODE_PREDEFINED_USERS, QUESTIONTITLES_VISIBLE, and STATUS_OFFLINE.

Referenced by _getGlobalSurveyData(), and _isComplete().

{
global $ilUser;
$this->type = "svy";
$this->ilObject($a_id,$a_call_by_reference);
$this->survey_id = -1;
$this->introduction = "";
$this->outro = $this->lng->txt("survey_finished");
/* Change Sn */
$this->_redirect_only_kiosk_mode = TRUE;
$this->_mail_confirmation = TRUE;
$this->_mail_confirmation_subject = $this->lng->txt("mail_confirmation_subject");
$this->_mail_confirmation_body = $this->lng->txt("mail_confirmation_body");
/* Change Sn End */
$this->author = $ilUser->fullname;
$this->status = STATUS_OFFLINE;
$this->evaluation_access = EVALUATION_ACCESS_OFF;
$this->startdate_enabled = 0;
$this->enddate_enabled = 0;
$this->questions = array();
$this->invitation = INVITATION_OFF;
$this->invitation_mode = MODE_PREDEFINED_USERS;
$this->anonymize = ANONYMIZE_OFF;
$this->display_question_titles = QUESTIONTITLES_VISIBLE;
$this->surveyCodeSecurity = TRUE;
$this->mailnotification = false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::importObject (   $file_info,
  $svy_qpl_id 
)

Imports a survey from XML into the ILIAS database.

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

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

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

{
// check if file was uploaded
$source = $file_info["tmp_name"];
$error = "";
if (($source == 'none') || (!$source) || $file_info["error"] > UPLOAD_ERR_OK)
{
$error = $this->lng->txt("import_no_file_selected");
}
// check correct file type
$isXml = FALSE;
$isZip = FALSE;
if ((strcmp($file_info["type"], "text/xml") == 0) || (strcmp($file_info["type"], "application/xml") == 0))
{
$isXml = TRUE;
}
if (strpos($file_info["type"], "zip") !== FALSE)
{
$isZip = TRUE;
}
if (!$isXml && !$isZip)
{
$error = $this->lng->txt("import_wrong_file_type");
global $ilLog;
$ilLog->write("Survey: Import error. Filetype was \"" . $file_info["type"] ."\"");
}
if (strlen($error) == 0)
{
// import file as a survey
$import_dir = $this->getImportDirectory();
$import_subdir = "";
$importfile = "";
include_once "./Services/Utilities/classes/class.ilUtil.php";
if ($isZip)
{
$importfile = $import_dir."/".$file_info["name"];
ilUtil::moveUploadedFile($source, $file_info["name"], $importfile);
ilUtil::unzip($importfile);
$found = $this->locateImportFiles($import_dir);
if (!((strlen($found["dir"]) > 0) && (strlen($found["xml"]) > 0)))
{
$error = $this->lng->txt("wrong_import_file_structure");
return $error;
}
$importfile = $found["xml"];
$import_subdir = $found["dir"];
}
else
{
$importfile = tempnam($import_dir, "survey_import");
ilUtil::moveUploadedFile($source, $file_info["name"], $importfile);
}
$fh = fopen($importfile, "r");
if (!$fh)
{
$error = $this->lng->txt("import_error_opening_file");
return $error;
}
$xml = fread($fh, filesize($importfile));
$result = fclose($fh);
if (!$result)
{
$error = $this->lng->txt("import_error_closing_file");
return $error;
}
unset($_SESSION["import_mob_xhtml"]);
if (strpos($xml, "questestinterop"))
{
include_once "./Services/Survey/classes/class.SurveyImportParserPre38.php";
include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
$spl = new ilObjSurveyQuestionPool($svy_qpl_id, FALSE);
$import = new SurveyImportParserPre38($spl, "", TRUE);
$import->setSurveyObject($this);
$import->setXMLContent($xml);
$import->startParsing();
}
else
{
include_once "./Services/Survey/classes/class.SurveyImportParser.php";
include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
$spl = new ilObjSurveyQuestionPool($svy_qpl_id, FALSE);
$import = new SurveyImportParser($spl, "", TRUE);
$import->setSurveyObject($this);
$import->setXMLContent($xml);
$import->startParsing();
}
if (is_array($_SESSION["import_mob_xhtml"]))
{
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
include_once "./Services/RTE/classes/class.ilRTE.php";
include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
foreach ($_SESSION["import_mob_xhtml"] as $mob)
{
$importfile = $import_subdir . "/" . $mob["uri"];
if (file_exists($importfile))
{
$media_object =& ilObjMediaObject::_saveTempFileAsMediaObject(basename($importfile), $importfile, FALSE);
ilObjMediaObject::_saveUsage($media_object->getId(), "svy:html", $this->getId());
$this->setIntroduction(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $this->getIntroduction()));
$this->setOutro(str_replace("src=\"" . $mob["mob"] . "\"", "src=\"" . "il_" . IL_INST_ID . "_mob_" . $media_object->getId() . "\"", $this->getOutro()));
}
else
{
global $ilLog;
$ilLog->write("Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
}
}
$this->saveToDb();
}
// delete import directory
}
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.

public

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

References $ilDB, SurveyQuestion\_isComplete(), duplicateQuestionForSurvey(), getSurveyId(), and loadQuestionsFromDb().

{
global $ilDB;
include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
if (!SurveyQuestion::_isComplete($question_id))
{
return FALSE;
}
else
{
// get maximum sequence index in test
$result = $ilDB->queryF("SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
$sequence = $result->numRows();
$duplicate_id = $this->duplicateQuestionForSurvey($question_id);
$next_id = $ilDB->nextId('svy_svy_qst');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_svy_qst (survey_question_id, survey_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
array('integer', 'integer', 'integer', 'integer', 'integer'),
array($next_id, $this->getSurveyId(), $duplicate_id, $sequence, time())
);
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.

public

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

References $ilDB, $questions, $row, ilObject\$title, createQuestionblock(), and duplicateQuestionForSurvey().

{
global $ilDB;
$result = $ilDB->queryF("SELECT svy_qblk.title, svy_qblk.show_questiontext, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst, svy_svy_qst WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_svy_qst.question_fi = svy_qblk_qst.question_fi AND svy_qblk.questionblock_id = %s ORDER BY svy_svy_qst.sequence",
array('integer'),
array($questionblock_id)
);
$questions = array();
$show_questiontext = 0;
while ($row = $ilDB->fetchAssoc($result))
{
$duplicate_id = $this->duplicateQuestionForSurvey($row["question_fi"]);
array_push($questions, $duplicate_id);
$title = $row["title"];
$show_questiontext = $row["show_questiontext"];
}
$this->createQuestionblock($title, $show_questiontext, $questions);
}

+ Here is the call graph for this function:

ilObjSurvey::inviteGroup (   $group_id)

Invites a group to a survey.

Parameters
integer$group_idThe database id of the invited group public

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

References ilObjUser\_addDesktopItem(), ilObject\getId(), getInvitation(), ilObject\getRefId(), INVITATION_ON, and inviteUser().

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

+ Here is the call graph for this function:

ilObjSurvey::inviteRole (   $role_id)

Invites a role to a survey.

Parameters
integer$role_idThe database id of the invited role public

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

References ilObjUser\_addDesktopItem(), ilObject\getId(), getInvitation(), ilObject\getRefId(), INVITATION_ON, and inviteUser().

{
global $rbacreview;
global $ilAccess;
$invited = 0;
$members = $rbacreview->assignedUsers($role_id);
foreach ($members as $user_id)
{
if ($ilAccess->checkAccessOfUser($user_id, "read", "", $this->getRefId(), "svy", $this->getId()))
{
$this->inviteUser($user_id);
if ($this->getInvitation() == INVITATION_ON)
{
include_once './Services/User/classes/class.ilObjUser.php';
ilObjUser::_addDesktopItem($user_id, $this->getRefId(), "svy");
}
}
}
return $invited;
}

+ Here is the call graph for this function:

ilObjSurvey::inviteUser (   $user_id)

Invites a user to a survey.

Parameters
integer$user_idThe database id of the invited user public

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

References $ilDB, ilObjUser\_addDesktopItem(), getInvitation(), ilObject\getRefId(), getSurveyId(), and INVITATION_ON.

Referenced by inviteGroup(), inviteRole(), and setInvitation().

{
global $ilDB;
$result = $ilDB->queryF("SELECT user_fi FROM svy_inv_usr WHERE user_fi = %s AND survey_fi = %s",
array('integer','integer'),
array($user_id, $this->getSurveyId())
);
if ($result->numRows() < 1)
{
$next_id = $ilDB->nextId('svy_inv_usr');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_inv_usr (invited_user_id, survey_fi, user_fi, tstamp) " .
"VALUES (%s, %s, %s, %s)",
array('integer','integer','integer','integer'),
array($next_id, $this->getSurveyId(), $user_id, time())
);
}
if ($this->getInvitation() == INVITATION_ON)
{
include_once './Services/User/classes/class.ilObjUser.php';
ilObjUser::_addDesktopItem($user_id, $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 1029 of file class.ilObjSurvey.php.

References ANONYMIZE_FREEACCESS, and getAnonymize().

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

{
{
return true;
}
else
{
return false;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::isAllowedToTakeMultipleSurveys (   $userid = "")

Checks if a user is allowed to take multiple survey.

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

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

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

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::isAnonymizedParticipant (   $key)

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

References $ilDB, and getSurveyId().

{
global $ilDB;
$result = $ilDB->queryF("SELECT finished_id FROM svy_finished WHERE anonymous_id = %s AND survey_fi = %s",
array('text','integer'),
array($key, $this->getSurveyId())
);
return ($result->numRows() == 1) ? true : false;
}

+ Here is the call graph for this function:

ilObjSurvey::isAnonymousKey (   $key)

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

References $ilDB, and getSurveyId().

Referenced by checkSurveyCode().

{
global $ilDB;
$result = $ilDB->queryF("SELECT anonymous_id FROM svy_anonymous WHERE survey_key = %s AND survey_fi = %s",
array('text','integer'),
array($key, $this->getSurveyId())
);
return ($result->numRows() == 1) ? true : false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::isComplete ( )

Returns 1, if a survey is complete for use.

Returns
boolean 1, if the survey is complete for use, otherwise 0 public

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

References ilObject\getTitle().

Referenced by saveCompletionStatus(), and saveToDb().

{
if (($this->getTitle()) and (count($this->questions)))
{
return 1;
}
else
{
return 0;
}
}

+ 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_textText which should be checked
Returns
boolean public

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

Referenced by addMaterialTag().

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

+ Here is the caller graph for this function:

ilObjSurvey::isOffline ( )

Gets the survey status.

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

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

References STATUS_OFFLINE.

{
return ($this->status == STATUS_OFFLINE) ? true : false;
}
ilObjSurvey::isOnline ( )

Gets the survey status.

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

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

References STATUS_ONLINE.

{
return ($this->status == STATUS_ONLINE) ? true : false;
}
ilObjSurvey::isPluginActive (   $a_pname)

Checks whether or not a question plugin with a given name is active.

Parameters
string$a_pnameThe plugin name public

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

References IL_COMP_MODULE.

Referenced by getQuestionsTable(), and getSurveyQuestions().

{
global $ilPluginAdmin;
if ($ilPluginAdmin->isActive(IL_COMP_MODULE, "SurveyQuestionPool", "svyq", $a_pname))
{
return TRUE;
}
else
{
return FALSE;
}
}

+ Here is the caller graph for this function:

ilObjSurvey::isSurveyCodeUnique (   $code)

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

References $ilDB, and getSurveyId().

Referenced by createNewAccessCode().

{
global $ilDB;
$result = $ilDB->queryF("SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
array('integer','text'),
array($this->getSurveyId(), $code)
);
return ($result->numRows() > 0) ? false : true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::isSurveyCodeUsed (   $code)

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

References $ilDB, and getSurveyId().

Referenced by getSurveyCodesForExport(), and getSurveyCodesTableData().

{
global $ilDB;
$result = $ilDB->queryF("SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
array('integer','text'),
array($this->getSurveyId(), $code)
);
return ($result->numRows() > 0) ? true : false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::isSurveyStarted (   $user_id,
  $anonymize_id 
)

Checks if a user already started a survey.

Parameters
integer$user_idThe 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 3407 of file class.ilObjSurvey.php.

References $_SESSION, $ilDB, $row, getAnonymize(), ilObject\getId(), getSurveyId(), isAccessibleWithoutCode(), and isAllowedToTakeMultipleSurveys().

Referenced by canStartSurvey(), and checkSurveyCode().

{
global $ilDB;
if ($this->getAnonymize())
{
if ((($user_id != ANONYMOUS_USER_ID) && (strlen($anonymize_id) == 0)) && (!($this->isAccessibleWithoutCode() && $this->isAllowedToTakeMultipleSurveys())))
{
$result = $ilDB->queryF("SELECT * FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
array('integer','integer'),
array($this->getSurveyId(), $user_id)
);
}
else
{
$result = $ilDB->queryF("SELECT * FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
array('integer','text'),
array($this->getSurveyId(), $anonymize_id)
);
}
}
else
{
$result = $ilDB->queryF("SELECT * FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
array('integer','integer'),
array($this->getSurveyId(), $user_id)
);
}
if ($result->numRows() == 0)
{
return false;
}
else
{
$row = $ilDB->fetchAssoc($result);
$_SESSION["finished_id"][$this->getId()] = $row["finished_id"];
return (int)$row["state"];
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::loadFromDb ( )

Loads a survey object from a database.

public

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

References $data, $ilDB, ilRTE\_replaceMediaObjectImageSrc(), ilObject\getId(), loadQuestionsFromDb(), setAnonymize(), setAuthor(), setEndDate(), setEndDateEnabled(), setEvaluationAccess(), setIntroduction(), setInvitation(), setInvitationMode(), setMailAddresses(), setMailConfirmation(), setMailConfirmationBody(), setMailConfirmationSubject(), setMailNotification(), setMailParticipantData(), setOutro(), setRedirectAfterSurvey(), setRedirectOnlyKioskMode(), setShowQuestionTitles(), setStartDate(), setStartDateEnabled(), setStatus(), and setSurveyId().

Referenced by cloneObject(), and read().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM svy_svy WHERE obj_fi = %s",
array('integer'),
array($this->getId())
);
if ($result->numRows() == 1)
{
$data = $ilDB->fetchAssoc($result);
$this->setSurveyId($data["survey_id"]);
$this->setAuthor($data["author"]);
include_once("./Services/RTE/classes/class.ilRTE.php");
if (strcmp($data["outro"], "survey_finished") == 0)
{
$this->setOutro($this->lng->txt("survey_finished"));
}
else
{
}
$this->setRedirectAfterSurvey($data["redirect_after_survey"]);
$this->setRedirectOnlyKioskMode($data["redirect_only_kiosk_mode"]);
$this->setMailConfirmation($data["mail_confirmation"]);
$this->setMailConfirmationSubject($data["mail_confirmation_subject"]);
if (strcmp($data["mail_confirmation_body"], "mail_confirmation_body") == 0)
{
$this->setMailConfirmationBody($this->lng->txt("mail_confirmation_body"));
}
else
{
$this->setMailConfirmationBody(ilRTE::_replaceMediaObjectImageSrc($data["mail_confirmation_body"], 1));
}
$this->setInvitation($data["invitation"]);
$this->setInvitationMode($data["invitation_mode"]);
$this->setShowQuestionTitles($data["show_question_titles"]);
$this->setStartDate($data["startdate"]);
$this->setStartDateEnabled(strlen($data["startdate"]));
$this->setEndDate($data["enddate"]);
$this->setEndDateEnabled(strlen($data["enddate"]));
$this->setAnonymize($data["anonymize"]);
$this->setEvaluationAccess($data["evaluation_access"]);
$this->setStatus($data["status"]);
$this->setMailNotification($data['mailnotification']);
$this->setMailAddresses($data['mailaddresses']);
$this->setMailParticipantData($data['mailparticipantdata']);
}
}

+ 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.

public

See Also
$questions

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

References $data, $ilDB, and getSurveyId().

Referenced by insertQuestion(), and loadFromDb().

{
global $ilDB;
$this->questions = array();
$result = $ilDB->queryF("SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
array('integer'),
array($this->getSurveyId())
);
while ($data = $ilDB->fetchAssoc($result))
{
$this->questions[$data["sequence"]] = $data["question_fi"];
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::loadWorkingData (   $question_id,
  $active_id 
)

Gets the working data of question from the database.

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

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

References $ilDB, and $row.

{
global $ilDB;
$result_array = array();
$result = $ilDB->queryF("SELECT * FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
array('integer','integer'),
array($question_id, $active_id)
);
if ($result->numRows() >= 1)
{
while ($row = $ilDB->fetchAssoc($result))
{
array_push($result_array, $row);
}
return $result_array;
}
else
{
return $result_array;
}
}
ilObjSurvey::locateImportFiles (   $a_dir)

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

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

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

References $file, and $files.

Referenced by importObject().

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

+ Here is the caller graph for this function:

ilObjSurvey::modifyQuestionblock (   $questionblock_id,
  $title,
  $show_questiontext 
)

Modifies a question block.

Parameters
integer$questionblock_idThe database id of the question block
string$titleThe title of the question block public

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

References $ilDB, and ilObject\$title.

{
global $ilDB;
$affectedRows = $ilDB->manipulateF("UPDATE svy_qblk SET title = %s, show_questiontext = %s WHERE " .
"questionblock_id = %s",
array('text','text','integer'),
array($title, $show_questiontext, $questionblock_id)
);
}
ilObjSurvey::moveDownQuestion (   $question_id)

Moves a question down in the list of survey questions.

Parameters
integer$question_idThe question id of the question which has to be moved down

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

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

{
$move_questions = array($question_id);
$pages =& $this->getSurveyPages();
$pageindex = -1;
foreach ($pages as $idx => $page)
{
if (($page[0]["question_id"] == $question_id) && (strcmp($page[0]["questionblock_id"], "") == 0))
{
$pageindex = $idx;
}
}
if (($pageindex < count($pages)-1) && ($pageindex >= 0))
{
$this->moveQuestions($move_questions, $pages[$pageindex+1][count($pages[$pageindex+1])-1]["question_id"], 1);
}
else
{
// move down a question in a questionblock
$questions = 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.

Parameters
integer$questionblock_idThe questionblock id of the questionblock which has to be moved down public

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

References getSurveyPages(), and moveQuestions().

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

+ Here is the call graph for this function:

ilObjSurvey::moveQuestions (   $move_questions,
  $target_index,
  $insert_mode 
)

Move questions and/or questionblocks to another position.

Parameters
array$move_questionsAn array with the question id's of the questions to move
integer$target_indexThe question id of the target position
integer$insert_mode0, if insert before the target position, 1 if insert after the target position public

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

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

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

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

+ 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.

Parameters
integer$question_idThe question id of the question which has to be moved up public

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

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

{
$move_questions = array($question_id);
$pages =& $this->getSurveyPages();
$pageindex = -1;
foreach ($pages as $idx => $page)
{
if ($page[0]["question_id"] == $question_id)
{
$pageindex = $idx;
}
}
if ($pageindex > 0)
{
$this->moveQuestions($move_questions, $pages[$pageindex-1][0]["question_id"], 0);
}
else
{
// move up a question in a questionblock
$questions = 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.

Parameters
integer$questionblock_idThe questionblock id of the questionblock which has to be moved up public

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

References getSurveyPages(), and moveQuestions().

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

+ Here is the call graph for this function:

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

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

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

public

Parameters
stringevent
integerreference id of object where the event occured
arraypasses optional parameters if required
Returns
boolean

Reimplemented from ilObject.

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

References $_GET, and ilObject\getType().

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

+ Here is the call graph for this function:

ilObjSurvey::prepareTextareaOutput (   $txt_output)

Prepares a string for a text area output in surveys.

Parameters
string$txt_outputString which should be prepared for output public

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

{
include_once "./Services/Utilities/classes/class.ilUtil.php";
return ilUtil::prepareTextareaOutput($txt_output, $prepare_for_latex_output);
}
& ilObjSurvey::processCSVRow (   $row,
  $quoteAll = FALSE,
  $separator = ";" 
)

Processes an array as a CSV row and converts the array values to correct CSV values.

The "converted" array is returned

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

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

References $row, and $separator.

{
$resultarray = array();
foreach ($row as $rowindex => $entry)
{
if(is_array($entry))
{
$entry = implode("/", $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
booleanpublic

Reimplemented from ilObject.

Definition at line 285 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.

Parameters
integer$question_idThe database id of the question public

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

References $ilDB, $row, and getSurveyId().

Referenced by removeQuestion().

{
global $ilDB;
$result = $ilDB->queryF("SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
array('integer','integer'),
array($question_id, $this->getSurveyId())
);
if ($result->numRows() > 0)
{
$remove_constraints = array();
while ($row = $ilDB->fetchAssoc($result))
{
array_push($remove_constraints, $row["constraint_fi"]);
}
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
array('integer','integer'),
array($question_id, $this->getSurveyId())
);
foreach ($remove_constraints as $key => $constraint_id)
{
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_constraint WHERE constraint_id = %s",
array('integer'),
array($constraint_id)
);
}
}
}

+ 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.

Parameters
integer$question_idThe database id of the question public

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

References _instanciateQuestion(), and removeConstraintsConcerningQuestion().

Referenced by delete(), and removeQuestions().

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

+ 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.

Parameters
array$remove_questionsAn array with the question id's of the questions to remove
array$remove_questionblocksAn array with the questionblock id's of the questions blocks to remove public

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

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

{
global $ilDB;
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)
{
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_qblk WHERE questionblock_id = %s",
array('integer'),
array($questionblock_id)
);
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
array('integer','integer'),
array($questionblock_id, $this->getSurveyId())
);
}
$this->questions = array_values($this->questions);
}

+ Here is the call graph for this function:

ilObjSurvey::removeSelectedSurveyResults (   $finished_ids)

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

public

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

References $ilDB, and $row.

{
global $ilDB;
foreach ($finished_ids as $finished_id)
{
$result = $ilDB->queryF("SELECT finished_id FROM svy_finished WHERE finished_id = %s",
array('integer'),
array($finished_id)
);
$row = $ilDB->fetchAssoc($result);
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_answer WHERE active_fi = %s",
array('integer'),
array($row["finished_id"])
);
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_finished WHERE finished_id = %s",
array('integer'),
array($finished_id)
);
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_times WHERE finished_fi = %s",
array('integer'),
array($row["finished_id"])
);
}
}
ilObjSurvey::saveAuthorToMetadata (   $a_author = "")

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

Parameters
string$a_authorA string containing the name of the test author private
See Also
$author

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

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

Referenced by createMetaData().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::saveCompletionStatus ( )

Saves the completion status of the survey.

public

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

References $ilDB, getSurveyId(), and isComplete().

{
global $ilDB;
$complete = 0;
if ($this->isComplete())
{
$complete = 1;
}
if ($this->getSurveyId() > 0)
{
$affectedRows = $ilDB->manipulateF("UPDATE svy_svy SET complete = %s, tstamp = %s WHERE survey_id = %s",
array('text','integer','integer'),
array($this->isComplete(), time(), $this->getSurveyId())
);
}
}

+ Here is the call graph for this function:

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

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

References $ilDB, and getSurveyId().

Referenced by cloneTextblocks().

{
global $ilDB;
if ($heading)
{
$affectedRows = $ilDB->manipulateF("UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
array('text','integer','integer'),
array($heading, $this->getSurveyId(), $insertbefore)
);
}
else
{
$affectedRows = $ilDB->manipulateF("UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
array('text','integer','integer'),
array(NULL, $this->getSurveyId(), $insertbefore)
);
}
}

+ 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.

public

See Also
$questions

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

References $ilDB, $row, and getSurveyId().

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

{
global $ilDB;
// save old questions state
$old_questions = array();
$result = $ilDB->queryF("SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
if ($result->numRows())
{
while ($row = $ilDB->fetchAssoc($result))
{
$old_questions[$row["question_fi"]] = $row;
}
}
// delete existing question relations
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_svy_qst WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
// create new question relations
foreach ($this->questions as $key => $value)
{
$next_id = $ilDB->nextId('svy_svy_qst');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_svy_qst (survey_question_id, survey_fi, question_fi, heading, sequence, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
array('integer','integer','integer','text','integer','integer'),
array($next_id, $this->getSurveyId(), $value, (strlen($old_questions[$value]["heading"])) ? $old_questions[$value]["heading"] : NULL, $key, time())
);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::saveToDb ( )

Saves a survey object to a database.

public

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

References $ilDB, ilRTE\_replaceMediaObjectImageSrc(), getAnonymize(), getAuthor(), getEndDate(), getEvaluationAccess(), ilObject\getId(), getIntroduction(), getInvitation(), getInvitationMode(), getMailAddresses(), getMailConfirmation(), getMailConfirmationBody(), getMailConfirmationSubject(), getMailNotification(), getMailParticipantData(), getOutro(), getRedirectAfterSurvey(), getRedirectOnlyKioskMode(), getShowQuestionTitles(), getStartDate(), getStatus(), getSurveyId(), isComplete(), saveQuestionsToDb(), and setSurveyId().

Referenced by createReference(), and importObject().

{
global $ilDB;
include_once("./Services/RTE/classes/class.ilRTE.php");
if ($this->getSurveyId() < 1)
{
//mail_confirmation_subject, mail_confirmation_body
$next_id = $ilDB->nextId('svy_svy');
$affectedRows = $ilDB->insert("svy_svy", array(
"survey_id" => array("integer", $next_id),
"obj_fi" => array("integer", $this->getId()),
"author" => array("text", $this->getAuthor()),
"introduction" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 0)),
"outro" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getOutro(), 0)),
"redirect_after_survey" => array("text", $this->getRedirectAfterSurvey()),
"redirect_only_kiosk_mode" => array("integer", $this->getRedirectOnlyKioskMode()),
"mail_confirmation" => array("integer", $this->getMailConfirmation()),
"mail_confirmation_subject" => array("text", $this->getMailConfirmationSubject()),
"mail_confirmation_body" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getMailConfirmationBody(), 0)),
"status" => array("text", $this->getStatus()),
"startdate" => array("text", $this->getStartDate()),
"enddate" => array("text", $this->getEndDate()),
"evaluation_access" => array("text", $this->getEvaluationAccess()),
"invitation" => array("text", $this->getInvitation()),
"invitation_mode" => array("text", $this->getInvitationMode()),
"complete" => array("text", $this->isComplete()),
"created" => array("integer", time()),
"anonymize" => array("text", $this->getAnonymize()),
"show_question_titles" => array("text", $this->getShowQuestionTitles()),
"mailnotification" => array('integer', ($this->getMailNotification()) ? 1 : 0),
"mailaddresses" => array('text', strlen($this->getMailAddresses()) ? $this->getMailAddresses() : NULL),
"mailparticipantdata" => array('text', strlen($this->getMailParticipantData()) ? $this->getMailParticipantData() : NULL),
"tstamp" => array("integer", time())
));
$this->setSurveyId($next_id);
}
else
{
$affectedRows = $ilDB->update("svy_svy", array(
"author" => array("text", $this->getAuthor()),
"introduction" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 0)),
"outro" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getOutro(), 0)),
"redirect_after_survey" => array("text", $this->getRedirectAfterSurvey()),
"redirect_only_kiosk_mode" => array("integer", $this->getRedirectOnlyKioskMode()),
"mail_confirmation" => array("integer", $this->getMailConfirmation()),
"mail_confirmation_subject" => array("text", $this->getMailConfirmationSubject()),
"mail_confirmation_body" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getMailConfirmationBody(), 0)),
"status" => array("text", $this->getStatus()),
"startdate" => array("text", $this->getStartDate()),
"enddate" => array("text", $this->getEndDate()),
"evaluation_access" => array("text", $this->getEvaluationAccess()),
"invitation" => array("text", $this->getInvitation()),
"invitation_mode" => array("text", $this->getInvitationMode()),
"complete" => array("text", $this->isComplete()),
"anonymize" => array("text", $this->getAnonymize()),
"show_question_titles" => array("text", $this->getShowQuestionTitles()),
"mailnotification" => array('integer', ($this->getMailNotification()) ? 1 : 0),
"mailaddresses" => array('text', strlen($this->getMailAddresses()) ? $this->getMailAddresses() : NULL),
"mailparticipantdata" => array('text', strlen($this->getMailParticipantData()) ? $this->getMailParticipantData() : NULL),
"tstamp" => array("integer", time())
), array(
"survey_id" => array("integer", $this->getSurveyId())
));
}
if ($affectedRows)
{
// save questions to db
}
}

+ 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.

Parameters
int$user_idThe database id of the user
string$access_codeThe survey access code

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

References $ilDB, and getSurveyId().

Referenced by fillSurveyForUser().

{
global $ilDB;
$next_id = $ilDB->nextId('svy_anonymous');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, user_key, tstamp) ".
"VALUES (%s, %s, %s, %s, %s)",
array('integer','text', 'integer', 'text', 'integer'),
array($next_id, $access_code, $this->getSurveyId(), md5($user_id), time())
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::saveUserSettings (   $usr_id,
  $key,
  $title,
  $value 
)

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

References $ilDB, ilObject\$title, and $usr_id.

{
global $ilDB;
$next_id = $ilDB->nextId('svy_settings');
$affectedRows = $ilDB->insert("svy_settings", array(
"settings_id" => array("integer", $next_id),
"usr_id" => array("integer", $usr_id),
"keyword" => array("text", $key),
"title" => array("text", $title),
"value" => array("clob", $value)
));
}
ilObjSurvey::sendCodes (   $not_sent,
  $subject,
  $message 
)

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

References $data, $ilDB, $res, getExternalCodeRecipients(), ilObject\getOwner(), ilObject\getRefId(), and getSurveyId().

{
include_once "./Services/Mail/classes/class.ilMail.php";
$user_id = $this->getOwner();
$mail = new ilMail($user_id);
$recipients = $this->getExternalCodeRecipients();
foreach ($recipients as $data)
{
$messagetext = $message;
$url = ILIAS_HTTP_PATH."/goto.php?cmd=infoScreen&target=svy_".$this->getRefId() . "&amp;client_id=" . CLIENT_ID . "&amp;accesscode=".$data["code"];
$messagetext = str_replace('[url]', "<" . $url . ">", $messagetext);
foreach ($data as $key => $value)
{
$messagetext = str_replace('[' . $key . ']', $value, $messagetext);
}
if (($not_sent != 1) || $data['sent'] == 0)
{
$res = $mail->sendMail(
$data['email'], // to
"", // cc
"", // bcc
$subject, // subject
$messagetext, // message
array(), // attachments
array('normal') // type
);
}
}
global $ilDB;
$affectedRows = $ilDB->manipulateF("UPDATE svy_anonymous SET sent = %s WHERE survey_fi = %s AND externaldata IS NOT NULL",
array('integer','integer'),
array(1, $this->getSurveyId())
);
}

+ Here is the call graph for this function:

ilObjSurvey::sendNotificationMail (   $user_id,
  $anonymize_id 
)

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

References $data, $mailparticipantdata, $res, ilObjUser\_getUserData(), getActiveID(), getAnonymize(), getParticipantTextResults(), and ilObject\getTitle().

Referenced by finishSurvey().

{
include_once "./Services/User/classes/class.ilObjUser.php";
include_once "./Services/Mail/classes/class.ilMail.php";
$mail = new ilMail(ANONYMOUS_USER_ID);
$recipients = preg_split('/,/', $this->mailaddresses);
foreach ($recipients as $recipient)
{
$data = ilObjUser::_getUserData(array($user_id));
foreach ($data[0] as $key => $value)
{
if ($this->getAnonymize())
{
$messagetext = str_replace('[' . $key . ']', '', $messagetext);
}
else
{
$messagetext = str_replace('[' . $key . ']', $value, $messagetext);
}
}
$active_id = $this->getActiveID($user_id, $anonymize_id);
$messagetext .= ((strlen($messagetext)) ? "\n\n\n" : '') . $this->lng->txt('results') . "\n\n". $this->getParticipantTextResults($active_id);
if (($not_sent != 1) || $data['sent'] == 0)
{
$res = $mail->sendMail(
$recipient, // to
"", // cc
"", // bcc
$this->lng->txt('finished_mail_subject') . ': ' . $this->getTitle(), // subject
$messagetext, // message
array(), // attachments
array('normal') // type
);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::setAnonymize (   $a_anonymize)

set anonymize status

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

References ANONYMIZE_FREEACCESS, ANONYMIZE_OFF, and ANONYMIZE_ON.

Referenced by loadFromDb().

{
switch ($a_anonymize)
{
$this->anonymize = $a_anonymize;
break;
default:
$this->anonymize = ANONYMIZE_OFF;
break;
}
}

+ Here is the caller graph for this function:

ilObjSurvey::setAuthor (   $author = "")

Sets the authors name of the ilObjSurvey object.

Parameters
string$authorA string containing the name of the test author public
See Also
$author

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

References $author.

Referenced by loadFromDb().

{
$this->author = $author;
}

+ Here is the caller graph for this function:

ilObjSurvey::setEndDate (   $end_date = "")

Sets the end date of the survey.

Parameters
string$end_dateSurvey end date (YYYYMMDDHHMMSS) public
See Also
$end_date

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

References $end_date.

Referenced by loadFromDb().

{
$this->end_date = $end_date;
}

+ Here is the caller graph for this function:

ilObjSurvey::setEndDateAndTime (   $end_date = "",
  $end_time 
)

Sets the end date of the survey.

Parameters
string$end_dateSurvey end date (YYYY-MM-DD)
string$end_timeSurvey end time (HH:MM:SS) public
See Also
$start_date

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

References $d, $end_date, and $y.

{
$y = ''; $m = ''; $d = ''; $h = ''; $i = ''; $s = '';
if (preg_match("/(\d{4})-(\d{2})-(\d{2})/", $end_date, $matches))
{
$y = $matches[1];
$m = $matches[2];
$d = $matches[3];
}
if (preg_match("/(\d{2}):(\d{2}):(\d{2})/", $end_time, $matches))
{
$h = $matches[1];
$i = $matches[2];
$s = $matches[3];
}
$this->end_date = sprintf('%04d%02d%02d%02d%02d%02d', $y, $m, $d, $h, $i, $s);
}
ilObjSurvey::setEndDateEnabled (   $enabled = false)

Sets the enabled state of the end date.

Parameters
boolean$enabledTrue to enable the end date, false to disable the end date public
See Also
$end_date

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

Referenced by loadFromDb().

{
$this->enddate_enabled = ($enabled) ? $enabled : 0;
}

+ Here is the caller graph for this function:

ilObjSurvey::setEndTime (   $finished_id)

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

References $_SESSION, and $ilDB.

{
global $ilDB;
$time = time();
$affectedRows = $ilDB->manipulateF("UPDATE svy_times SET left_page = %s WHERE finished_fi = %s AND entered_page = %s",
array('integer', 'integer', 'integer'),
array($time, $finished_id, $_SESSION['svy_entered_page'])
);
unset($_SESSION['svy_entered_page']);
}
ilObjSurvey::setEvaluationAccess (   $evaluation_access = EVALUATION_ACCESS_OFF)

Sets the learners evaluation access.

Parameters
integer$evaluation_accessThe evaluation access public
See Also
$evaluation_access

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

References $evaluation_access, and EVALUATION_ACCESS_OFF.

Referenced by loadFromDb().

{
}

+ Here is the caller graph for this function:

ilObjSurvey::setIntroduction (   $introduction = "")

Sets the introduction text.

Parameters
string$introductionA string containing the introduction
See Also
$introduction

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

References $introduction.

Referenced by importObject(), and loadFromDb().

{
$this->introduction = $introduction;
}

+ Here is the caller graph for this function:

ilObjSurvey::setInvitation (   $invitation = 0)

Sets the invitation status.

Parameters
integer$invitationThe invitation status public
See Also
$invitation

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

References $ilDB, $invitation, $row, disinviteAllUsers(), ilObject\getId(), getInvitationMode(), INVITATION_OFF, INVITATION_ON, inviteUser(), and MODE_UNLIMITED.

Referenced by loadFromDb(), and setInvitationAndMode().

{
global $ilDB;
global $ilAccess;
$this->invitation = $invitation;
{
}
{
{
$result = $ilDB->query("SELECT usr_id FROM usr_data");
while ($row = $ilDB->fetchAssoc($result))
{
if ($ilAccess->checkAccessOfUser($row["usr_id"], "read", "", $this->getRefId(), "svy", $this->getId()))
{
$this->inviteUser($row['usr_id']);
}
}
}
}
}

+ 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)

Parameters
integer$invitationThe invitation status
integer$invitation_modeThe invitation mode public
See Also
$invitation_mode

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

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

{
$this->invitation_mode = $invitation_mode;
}

+ Here is the call graph for this function:

ilObjSurvey::setInvitationMode (   $invitation_mode = 0)

Sets the invitation mode.

Parameters
integer$invitation_modeThe invitation mode public
See Also
$invitation_mode

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

References $invitation_mode.

Referenced by loadFromDb().

{
$this->invitation_mode = $invitation_mode;
}

+ Here is the caller graph for this function:

ilObjSurvey::setMailAddresses (   $a_addresses)

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

Referenced by loadFromDb().

{
$this->mailaddresses = $a_addresses;
}

+ Here is the caller graph for this function:

ilObjSurvey::setMailConfirmation (   $a_int = 0)

Sets the mail confirmation.

Sets the mail confirmation of the ilObjSurvey object

Parameters
integer$a_intpublic
See Also
$_mail_confirmation

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

Referenced by loadFromDb().

{
$this->_mail_confirmation = $a_int;
}

+ Here is the caller graph for this function:

ilObjSurvey::setMailConfirmationBody (   $a_body = "")

Sets the mail confirmation body.

Sets the mail confirmation body of the ilObjSurvey object

Parameters
string$a_bodypublic
See Also
$_mail_confirmation_body

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

Referenced by loadFromDb().

{
$this->_mail_confirmation_body = $a_body;
}

+ Here is the caller graph for this function:

ilObjSurvey::setMailConfirmationSubject (   $a_subject = "")

Sets the mail confirmation subject.

Sets the mail confirmation subject of the ilObjSurvey object

Parameters
string$a_subjectpublic
See Also
$_mail_confirmation_subject

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

Referenced by loadFromDb().

{
$this->_mail_confirmation_subject = $a_subject;
}

+ Here is the caller graph for this function:

ilObjSurvey::setMailNotification (   $a_notification)

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

Referenced by loadFromDb().

{
$this->mailnotification = ($a_notification) ? true : false;
}

+ Here is the caller graph for this function:

ilObjSurvey::setMailParticipantData (   $a_data)

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

Referenced by loadFromDb().

{
$this->mailparticipantdata = $a_data;
}

+ Here is the caller graph for this function:

ilObjSurvey::setObligatoryStates (   $obligatory_questions)

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

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

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

References $ilDB, $row, and getSurveyId().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
if ($result->numRows())
{
while ($row = $ilDB->fetchAssoc($result))
{
if (!array_key_exists($row["question_fi"], $obligatory_questions))
{
$obligatory_questions[$row["question_fi"]] = 0;
}
}
}
// set the obligatory states in the database
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_qst_oblig WHERE survey_fi = %s",
array('integer'),
array($this->getSurveyId())
);
// set the obligatory states in the database
foreach ($obligatory_questions as $question_fi => $obligatory)
{
$next_id = $ilDB->nextId('svy_qst_oblig');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, " .
"obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)",
array('integer','integer','integer','text','integer'),
array($next_id, $this->getSurveyId(), $question_fi, (strlen($obligatory)) ? $obligatory : 0, time())
);
}
}

+ Here is the call graph for this function:

ilObjSurvey::setOutro (   $outro = "")

Sets the outro text.

Parameters
string$outroA string containing the outro
See Also
$outro

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

References $outro.

Referenced by importObject(), and loadFromDb().

{
$this->outro = $outro;
}

+ Here is the caller graph for this function:

ilObjSurvey::setPage (   $finished_id,
  $page_id 
)

Sets the number of the active survey page.

Parameters
integer$finished_idThe database id of the active user
integer$page_idThe index of the page public

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

References $ilDB.

{
global $ilDB;
$affectedRows = $ilDB->manipulateF("UPDATE svy_finished SET lastpage = %s WHERE finished_id = %s",
array('integer','integer'),
array(($page_id) ? $page_id : 0, $finished_id)
);
}
ilObjSurvey::setRedirectAfterSurvey (   $a_url = "")

Sets the redirect after survey.

Sets the redirect after survey

Parameters
string$a_urlpublic
See Also
$_redirect_after_survey

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

Referenced by loadFromDb().

{
$this->_redirect_after_survey = $a_url;
}

+ Here is the caller graph for this function:

ilObjSurvey::setRedirectOnlyKioskMode (   $a_int = 1)

Sets the redirection only in kiosk mode.

Sets the redirection only in kiosk mode of the ilObjSurvey object

Parameters
integer$a_intpublic
See Also
$_redirect_only_kiosk_mode

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

Referenced by loadFromDb().

{
$this->_redirect_only_kiosk_mode = $a_int;
}

+ Here is the caller graph for this function:

ilObjSurvey::setShowQuestionTitles (   $a_show)

Sets the status of the display_question_titles attribute.

Parameters
integer$a_showThe status of the display_question_titles attribute
See Also
$display_question_titles

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

Referenced by loadFromDb().

{
$this->display_question_titles = ($a_show) ? 1 : 0;
}

+ Here is the caller graph for this function:

ilObjSurvey::setStartDate (   $start_date = "")

Sets the start date of the survey.

Parameters
string$start_dataSurvey start date (YYYYMMDDHHMMSS) public
See Also
$start_date

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

References $start_date.

Referenced by loadFromDb().

{
$this->start_date = $start_date;
}

+ Here is the caller graph for this function:

ilObjSurvey::setStartDateAndTime (   $start_date = "",
  $start_time 
)

Sets the start date of the survey.

Parameters
string$start_dateSurvey start date (YYYY-MM-DD)
string$start_timeSurvey start time (HH:MM:SS) public
See Also
$start_date

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

References $d, $start_date, and $y.

{
$y = ''; $m = ''; $d = ''; $h = ''; $i = ''; $s = '';
if (preg_match("/(\d{4})-(\d{2})-(\d{2})/", $start_date, $matches))
{
$y = $matches[1];
$m = $matches[2];
$d = $matches[3];
}
if (preg_match("/(\d{2}):(\d{2}):(\d{2})/", $start_time, $matches))
{
$h = $matches[1];
$i = $matches[2];
$s = $matches[3];
}
$this->start_date = sprintf('%04d%02d%02d%02d%02d%02d', $y, $m, $d, $h, $i, $s);
}
ilObjSurvey::setStartDateEnabled (   $enabled = false)

Sets the enabled state of the start date.

Parameters
boolean$enabledTrue to enable the start date, false to disable the start date public
See Also
$start_date

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

Referenced by loadFromDb().

{
$this->startdate_enabled = ($enabled) ? $enabled : 0;
}

+ Here is the caller graph for this function:

ilObjSurvey::setStartTime (   $finished_id,
  $first_question 
)

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

References $_SESSION, and $ilDB.

{
global $ilDB;
$time = time();
$_SESSION['svy_entered_page'] = $time;
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_times (finished_fi, entered_page, left_page, first_question) VALUES (%s, %s, %s, %s)",
array('integer', 'integer', 'integer', 'integer'),
array($finished_id, $time, NULL, $first_question)
);
}
ilObjSurvey::setStatus (   $status = STATUS_OFFLINE)

Sets the survey status.

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

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

References $status, STATUS_OFFLINE, and STATUS_ONLINE.

Referenced by loadFromDb().

{
$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::setSurveyId (   $survey_id)

Sets the survey id.

Parameters
integer$survey_idThe survey id

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

References $survey_id.

Referenced by loadFromDb(), and saveToDb().

{
$this->survey_id = $survey_id;
}

+ Here is the caller graph for this function:

ilObjSurvey::showQuestionTitles ( )

Sets the question titles visible during the query.

public

See Also
$display_question_titles

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

{
$this->display_question_titles = 1;
}
ilObjSurvey::startSurvey (   $user_id,
  $anonymous_id 
)

Starts the survey creating an entry in the database.

Parameters
integer$user_idThe database id of the user who starts the survey public

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

References $ilDB, getAnonymize(), and getSurveyId().

{
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;
}
}
$next_id = $ilDB->nextId('svy_finished');
$affectedRows = $ilDB->manipulateF("INSERT INTO svy_finished (finished_id, survey_fi, user_fi, anonymous_id, state, tstamp) ".
"VALUES (%s, %s, %s, %s, %s, %s)",
array('integer','integer','integer','text','text','integer'),
array($next_id, $this->getSurveyId(), $user_id, $anonymous_id, 0, time())
);
return $next_id;
}

+ Here is the call graph for this function:

ilObjSurvey::toXML ( )

Returns a QTI xml representation of the survey.

Returns
string The QTI xml representation of the survey public

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

References _instanciateQuestion(), addMaterialTag(), getAnonymize(), getAuthor(), ilObject\getDescription(), getEndDateEnabled(), getEndDay(), getEndHour(), getEndMinute(), getEndMonth(), getEndYear(), getEvaluationAccess(), ilObject\getId(), getIntroduction(), getObligatoryStates(), getOutro(), getShowQuestionTitles(), getStartDateEnabled(), getStartDay(), getStartHour(), getStartMinute(), getStartMonth(), getStartYear(), getStatus(), getSurveyId(), getSurveyPages(), ilObject\getTitle(), ilObject\getType(), and ilXmlWriter\xmlHeader().

{
include_once("./Services/Xml/classes/class.ilXmlWriter.php");
$a_xml_writer = new ilXmlWriter;
// set xml header
$a_xml_writer->xmlHeader();
$attrs = array(
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
"xsi:noNamespaceSchemaLocation" => "http://www.ilias.de/download/xsd/ilias_survey_3_8.xsd"
);
$a_xml_writer->xmlStartTag("surveyobject", $attrs);
$attrs = array(
"id" => $this->getSurveyId(),
"title" => $this->getTitle()
);
$a_xml_writer->xmlStartTag("survey", $attrs);
$a_xml_writer->xmlElement("description", NULL, $this->getDescription());
$a_xml_writer->xmlElement("author", NULL, $this->getAuthor());
$a_xml_writer->xmlStartTag("objectives");
$attrs = array(
"label" => "introduction"
);
$this->addMaterialTag($a_xml_writer, $this->getIntroduction(), TRUE, TRUE, $attrs);
$attrs = array(
"label" => "outro"
);
$this->addMaterialTag($a_xml_writer, $this->getOutro(), TRUE, TRUE, $attrs);
$a_xml_writer->xmlEndTag("objectives");
if ($this->getAnonymize())
{
$attribs = array("enabled" => "1");
}
else
{
$attribs = array("enabled" => "0");
}
$a_xml_writer->xmlElement("anonymisation", $attribs);
$a_xml_writer->xmlStartTag("restrictions");
if ($this->getAnonymize() == 2)
{
$attribs = array("type" => "free");
}
else
{
$attribs = array("type" => "restricted");
}
$a_xml_writer->xmlElement("access", $attribs);
if ($this->getStartDateEnabled())
{
$attrs = array("type" => "date");
$a_xml_writer->xmlElement("startingtime", $attrs, sprintf("%04d-%02d-%02dT%02d:%02d:00", $this->getStartYear(), $this->getStartMonth(), $this->getStartDay(), $this->getStartHour(), $this->getStartMinute()));
}
if ($this->getEndDateEnabled())
{
$attrs = array("type" => "date");
$a_xml_writer->xmlElement("endingtime", $attrs, sprintf("%04d-%02d-%02dT%02d:%02d:00", $this->getEndYear(), $this->getEndMonth(), $this->getEndDay(), $this->getEndHour(), $this->getEndMinute()));
}
$a_xml_writer->xmlEndTag("restrictions");
// constraints
$pages =& $this->getSurveyPages();
$hasconstraints = FALSE;
foreach ($pages as $question_array)
{
foreach ($question_array as $question)
{
if (count($question["constraints"]))
{
$hasconstraints = TRUE;
}
}
}
if ($hasconstraints)
{
$a_xml_writer->xmlStartTag("constraints");
foreach ($pages as $question_array)
{
foreach ($question_array as $question)
{
if (count($question["constraints"]))
{
// found constraints
foreach ($question["constraints"] as $constraint)
{
$attribs = array(
"sourceref" => $question["question_id"],
"destref" => $constraint["question"],
"relation" => $constraint["short"],
"value" => $constraint["value"]
);
$a_xml_writer->xmlElement("constraint", $attribs);
}
}
}
}
$a_xml_writer->xmlEndTag("constraints");
}
// add the rest of the preferences in qtimetadata tags, because there is no correspondent definition in QTI
$a_xml_writer->xmlStartTag("metadata");
$a_xml_writer->xmlStartTag("metadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "evaluation_access");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getEvaluationAccess());
$a_xml_writer->xmlEndTag("metadatafield");
$a_xml_writer->xmlStartTag("metadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "status");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getStatus());
$a_xml_writer->xmlEndTag("metadatafield");
$a_xml_writer->xmlStartTag("metadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "display_question_titles");
$a_xml_writer->xmlElement("fieldentry", NULL, $this->getShowQuestionTitles());
$a_xml_writer->xmlEndTag("metadatafield");
$a_xml_writer->xmlStartTag("metadatafield");
$a_xml_writer->xmlElement("fieldlabel", NULL, "SCORM");
include_once "./Services/MetaData/classes/class.ilMD.php";
$md = new ilMD($this->getId(),0, $this->getType());
$writer = new ilXmlWriter();
$md->toXml($writer);
$metadata = $writer->xmlDumpMem();
$a_xml_writer->xmlElement("fieldentry", NULL, $metadata);
$a_xml_writer->xmlEndTag("metadatafield");
$a_xml_writer->xmlEndTag("metadata");
$a_xml_writer->xmlEndTag("survey");
$attribs = array("id" => $this->getId());
$a_xml_writer->xmlStartTag("surveyquestions", $attribs);
// add questionblock descriptions
$obligatory_states =& $this->getObligatoryStates();
foreach ($pages as $question_array)
{
if (count($question_array) > 1)
{
$attribs = array("id" => $question_array[0]["question_id"]);
$attribs = array("showQuestiontext" => $question_array[0]["questionblock_show_questiontext"]);
$a_xml_writer->xmlStartTag("questionblock", $attribs);
if (strlen($question_array[0]["questionblock_title"]))
{
$a_xml_writer->xmlElement("questionblocktitle", NULL, $question_array[0]["questionblock_title"]);
}
}
foreach ($question_array as $question)
{
if (strlen($question["heading"]))
{
$a_xml_writer->xmlElement("textblock", NULL, $question["heading"]);
}
$questionObject =& $this->_instanciateQuestion($question["question_id"]);
if ($questionObject !== FALSE) $questionObject->insertXML($a_xml_writer, FALSE, $obligatory_states[$question["question_id"]]);
}
if (count($question_array) > 1)
{
$a_xml_writer->xmlEndTag("questionblock");
}
}
$a_xml_writer->xmlEndTag("surveyquestions");
$a_xml_writer->xmlEndTag("surveyobject");
$xml = $a_xml_writer->xmlDumpMem(FALSE);
return $xml;
}

+ Here is the call graph for this function:

ilObjSurvey::unfoldQuestionblocks (   $questionblocks)

Unfolds question blocks of a question pool.

Parameters
array$questionblocksAn array of question block id's public

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

References $ilDB, and getSurveyId().

{
global $ilDB;
foreach ($questionblocks as $index)
{
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_qblk WHERE questionblock_id = %s",
array('integer'),
array($index)
);
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
array('integer','integer'),
array($index, $this->getSurveyId())
);
}
}

+ Here is the call graph for this function:

ilObjSurvey::update ( )

update object data

public

Returns
boolean

Reimplemented from ilObject.

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

References ilObject\updateMetaData().

{
$this->updateMetaData();
if (!parent::update())
{
return false;
}
// put here object specific stuff
return true;
}

+ Here is the call graph for this function:

ilObjSurvey::updateConjunctionForQuestions (   $questions,
  $conjunction 
)

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

References $ilDB, and $questions.

{
global $ilDB;
foreach ($questions as $question_id)
{
$affectedRows = $ilDB->manipulateF("UPDATE svy_constraint SET conjunction = %s ".
"WHERE constraint_id IN (SELECT constraint_fi FROM svy_qst_constraint WHERE svy_qst_constraint.question_fi = %s)",
array('integer','integer'),
array($conjunction, $question_id)
);
}
}
ilObjSurvey::updateConstraint (   $precondition_id,
  $if_question_id,
  $relation,
  $value,
  $conjunction 
)

Updates a precondition.

Parameters
integer$precondition_idThe id of the original precondition
integer$to_question_idThe question id of the question where to add the constraint
integer$if_question_idThe question id of the question which defines a precondition
integer$relationThe database id of the relation
mixed$valueThe value compared with the relation public

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

References $ilDB.

{
global $ilDB;
$affectedRows = $ilDB->manipulateF("UPDATE svy_constraint SET question_fi = %s, relation_fi = %s, value = %s, conjunction = %s ".
"WHERE constraint_id = %s",
array('integer','integer','float','integer','integer'),
array($if_question_id, $relation, $value, $conjunction, $precondition_id)
);
}

Field Documentation

ilObjSurvey::$_mail_confirmation
private

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

Referenced by getMailConfirmation().

ilObjSurvey::$_mail_confirmation_body
private

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

Referenced by getMailConfirmationBody().

ilObjSurvey::$_mail_confirmation_subject
private

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

Referenced by getMailConfirmationSubject().

ilObjSurvey::$_redirect_after_survey
private

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

Referenced by getRedirectAfterSurvey().

ilObjSurvey::$_redirect_only_kiosk_mode
private

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

Referenced by getRedirectOnlyKioskMode().

ilObjSurvey::$anonymize

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

ilObjSurvey::$author

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

Referenced by getAuthor(), and setAuthor().

ilObjSurvey::$display_question_titles

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

ilObjSurvey::$end_date

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

Referenced by setEndDate(), and setEndDateAndTime().

ilObjSurvey::$enddate_enabled

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

ilObjSurvey::$evaluation_access

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

Referenced by setEvaluationAccess().

ilObjSurvey::$introduction

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

Referenced by setIntroduction().

ilObjSurvey::$invitation

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

Referenced by setInvitation(), and setInvitationAndMode().

ilObjSurvey::$invitation_mode

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

Referenced by setInvitationAndMode(), and setInvitationMode().

ilObjSurvey::$mailaddresses

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

Referenced by getMailAddresses().

ilObjSurvey::$mailnotification

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

Referenced by getMailNotification().

ilObjSurvey::$mailparticipantdata

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

Referenced by getMailParticipantData(), and sendNotificationMail().

ilObjSurvey::$outro

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

Referenced by setOutro().

ilObjSurvey::$start_date

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

Referenced by setStartDate(), and setStartDateAndTime().

ilObjSurvey::$startdate_enabled

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

ilObjSurvey::$status

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

Referenced by setStatus().

ilObjSurvey::$surveyCodeSecurity

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


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