ILIAS  release_4-3 Revision
 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 ()
 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, $a_force=false)
 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
 isAccessibleWithCodeForAll ()
 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.
 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.
 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.
 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.
 getEvaluationAccess ()
 Gets the learners evaluation access.
 setEvaluationAccess ($evaluation_access=EVALUATION_ACCESS_OFF)
 Sets the learners evaluation access.
 setActivationVisibility ($a_value)
 getActivationVisibility ()
 isActivationLimited ()
 setActivationLimited ($a_value)
 getIntroduction ()
 Gets the introduction text.
 getOutro ()
 Gets the outro text.
getExistingQuestions ()
 Gets the question id's of the questions which are already in the survey.
getQuestionpoolTitles ($could_be_offline=FALSE, $showPath=FALSE)
 Get the titles of all available survey question pools.
 moveUpQuestion ($question_id)
 Moves a question up in the list of survey questions.
 moveDownQuestion ($question_id)
 Moves a question down in the list of survey questions.
 moveUpQuestionblock ($questionblock_id)
 Moves a questionblock up in the list of survey questions.
 moveDownQuestionblock ($questionblock_id)
 Moves a questionblock down in the list of survey questions.
 moveQuestions ($move_questions, $target_index, $insert_mode)
 Move questions and/or questionblocks to another position.
 removeQuestion ($question_id)
 Remove a question from the survey.
 removeConstraintsConcerningQuestion ($question_id)
 Remove constraints concerning a question with a given question_id.
 removeQuestions ($remove_questions, $remove_questionblocks)
 Remove questions from the survey.
 unfoldQuestionblocks ($questionblocks)
 Unfolds question blocks of a question pool.
 removeQuestionFromBlock ($question_id, $questionblock_id)
 addQuestionToBlock ($question_id, $questionblock_id)
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, $show_questiontext=true, $show_blocktitle=false)
 Adds a questionblock to the database.
 createQuestionblock ($title, $show_questiontext, $show_blocktitle, $questions)
 Creates a question block for the survey.
 modifyQuestionblock ($questionblock_id, $title, $show_questiontext, $show_blocktitle)
 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)
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, $lang="en")
 getExternalCodeRecipients ($a_check_finished=false)
 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.
 processPrintoutput2FO ($print_output)
 Convert a print output to XSL-FO.
 deliverPDFfromFO ($fo)
 Delivers a PDF file from a XSL-FO string.
 _checkCondition ($a_svy_id, $a_operator, $a_value, $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)
 setTemplate ($template_id)
 getTemplate ()
 updateOrder (array $a_order)
 getPoolUsage ()
 setPoolUsage ($a_value)
 isPoolActive ()
 Get current pool status.
 applySettingsTemplate ($template_id)
 Apply settings template.
 setActivationStartDate ($starting_time=NULL)
 setActivationEndDate ($ending_time=NULL)
 getActivationStartDate ()
 getActivationEndDate ()
- 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
 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
 _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
 _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
 applyDidacticTemplate ($a_tpl_id)
 Apply template.
 setRegisterMode ($a_bool)
 isUserRegistered ($a_user_id=0)
 requireRegistration ()
 getXMLZip ()
 getHTMLDirectory ()
 cloneObject ($a_target_id, $a_copy_id=0, $a_omit_tree=false)
 Clone object permissions, put in tree ...
 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.
 _lookupCreationDate ($a_id)
 Lookup creation date.

Data Fields

 $survey_id
 $author
 $introduction
 $outro
 $status
 $evaluation_access
 $start_date
 $end_date
 $questions
 $invitation
 $invitation_mode
 $anonymize
 $display_question_titles
 $surveyCodeSecurity
 $mailnotification
 $mailaddresses
 $mailparticipantdata
 $template_id
 $pool_usage
- 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)

Protected Attributes

 $activation_visibility
 $activation_starting_time
 $activation_ending_time

Additional Inherited Members

- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId ($a_import_id)
static _getAllReferences ($a_id)
 get all reference ids of object
static _lookupTitle ($a_id)
 lookup object title
static _getIdsForTitle ($title, $type= '', $partialmatch=false)
static _lookupDescription ($a_id)
 lookup object description
static _lookupObjId ($a_id)
static _lookupType ($a_id, $a_reference=false)
 lookup object type
static _lookupObjectId ($a_ref_id)
 lookup object id
 _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, $show_path=true)
 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.
static getLongDescriptions (array $a_obj_ids)
 Get long description data.
static getAllOwnedRepositoryObjects ($a_user_id)
 Get all ids of objects user owns.

Detailed Description

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

Member Function Documentation

ilObjSurvey::_addQuestionblock (   $title = "",
  $owner = 0,
  $show_questiontext = true,
  $show_blocktitle = false 
)

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

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

Referenced by cloneObject().

{
global $ilDB;
$next_id = $ilDB->nextId('svy_qblk');
$ilDB->manipulateF("INSERT INTO svy_qblk (questionblock_id, title, show_questiontext,".
" show_blocktitle, owner_fi, tstamp) " .
"VALUES (%s, %s, %s, %s, %s, %s)",
array('integer','text','integer','integer','integer','integer'),
array($next_id, $title, $show_questiontext, $show_blocktitle, $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 5089 of file class.ilObjSurvey.php.

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

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

References $result, and ilObjSurvey().

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

+ Here is the call graph for this function:

ilObjSurvey::_getLastAccess (   $finished_id)

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

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

References $result, and $survey_id.

Referenced by SurveyQuestion\calculateCumulatedResults(), SurveyTextQuestionGUI\getCumulatedResultsDetails(), SurveyMetricQuestionGUI\getCumulatedResultsDetails(), SurveyMultipleChoiceQuestionGUI\getCumulatedResultsDetails(), SurveySingleChoiceQuestionGUI\getCumulatedResultsDetails(), and SurveyMatrixQuestionGUI\getCumulatedResultsDetails().

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

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

References $result, and $survey_id.

Referenced by ilSurveySyncTableGUI\importData().

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

+ Here is the caller graph for this function:

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

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

Referenced by cloneObject(), ilObjSurveyGUI\copyQuestionsToPoolObject(), ilObjSurveyGUI\executeCopyQuestionsToPoolObject(), fillSurveyForUser(), getDetailedParticipantResultsAsText(), getSurveyQuestions(), ilSurveyPageGUI\paste(), 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 519 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 2631 of file class.ilObjSurvey.php.

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

References 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 4944 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 242 of file class.ilObjSurvey.php.

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

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

References deleteConstraints(), and getSurveyId().

{
global $ilDB;
$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, $question_id)
);
$this->deleteConstraints($question_id); // #13713
}

+ Here is the call graph for this function:

ilObjSurvey::applySettingsTemplate (   $template_id)

Apply settings template.

Parameters
int$template_id

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

References $template_id, ANONYMIZE_FREEACCESS, ANONYMIZE_OFF, ANONYMIZE_ON, saveToDb(), setAnonymize(), setPoolUsage(), setShowQuestionTitles(), and setTemplate().

{
{
return;
}
include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
$template = new ilSettingsTemplate($template_id);
$template_settings = $template->getSettings();
if($template_settings)
{
if($template_settings["show_question_titles"] !== NULL)
{
if($template_settings["show_question_titles"]["value"])
{
$this->setShowQuestionTitles(true);
}
else
{
$this->setShowQuestionTitles(false);
}
}
if($template_settings["use_pool"] !== NULL)
{
if($template_settings["use_pool"]["value"])
{
$this->setPoolUsage(true);
}
else
{
$this->setPoolUsage(false);
}
}
if($template_settings["anonymization_options"]["value"])
{
$anon_map = array('personalized' => ANONYMIZE_OFF,
'anonymize_with_code' => ANONYMIZE_ON,
'anonymize_without_code' => ANONYMIZE_FREEACCESS);
$this->setAnonymize($anon_map[$template_settings["anonymization_options"]["value"]]);
}
/* other settings: not needed here
* - enabled_end_date
* - enabled_start_date
* - rte_switch
*/
}
$this->saveToDb();
}

+ Here is the call graph for this function:

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

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

{
global $ilAccess;
$result = TRUE;
$messages = array();
$edit_settings = false;
// check start date
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;
$edit_settings = true;
}
}
// check end date
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;
$edit_settings = true;
}
}
// check online status
if ($this->getStatus() == STATUS_OFFLINE)
{
array_push($messages, $this->lng->txt("survey_is_offline"));
$result = FALSE;
$edit_settings = true;
}
// 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,
"edit_settings" => $edit_settings
);
}

+ 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 3292 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;
}
$found = false;
foreach ($working_data as $data)
{
switch ($constraint_data["short"])
{
case "<":
if ($data["value"] < $constraint_data["value"])
{
$found = true;
}
break;
case "<=":
if ($data["value"] <= $constraint_data["value"])
{
$found = true;
}
break;
case "=":
if ($data["value"] == $constraint_data["value"])
{
$found = true;
}
break;
case "<>":
if ($data["value"] <> $constraint_data["value"])
{
$found = true;
}
break;
case ">=":
if ($data["value"] >= $constraint_data["value"])
{
$found = true;
}
break;
case ">":
if ($data["value"] > $constraint_data["value"])
{
$found = true;
}
break;
}
if ($found)
{
break;
}
}
return (int)$found;
}
ilObjSurvey::checkSurveyCode (   $code)

Definition at line 4474 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 686 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

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

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

{
global $ilDB;
$this->loadFromDb();
// Copy settings
$newObj = parent::cloneObject($a_target_id,$a_copy_id);
$this->cloneMetaData($newObj);
$newObj->updateMetaData();
$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->setEndDate($this->getEndDate());
$newObj->setInvitation($this->getInvitation());
$newObj->setInvitationMode($this->getInvitationMode());
$newObj->setAnonymize($this->getAnonymize());
$newObj->setShowQuestionTitles($this->getShowQuestionTitles());
$newObj->setTemplate($this->getTemplate());
$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);
if($question) // #10824
{
$question->id = -1;
$original_id = SurveyQuestion::_getOriginalId($question_id, false);
$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"], $questionblock["show_questiontext"], $questionblock["show_blocktitle"]);
$questionblocks[$key] = $questionblock_id;
}
// create new questionblock questions
foreach ($questionblock_questions as $key => $value)
{
if($questionblocks[$value["questionblock_fi"]] &&
$question_pointer[$value["question_fi"]])
{
$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 ($question_pointer[$constraint["for_question"]] &&
$question_pointer[$constraint["question"]])
{
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))
{
if($question_pointer[$row["question_fi"]])
{
$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 4268 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 178 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 4283 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 4362 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 192 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 4810 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,
  $show_blocktitle,
  $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 2108 of file class.ilObjSurvey.php.

References $ilUser, $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,".
" show_blocktitle, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
array('integer','text','text','text','integer','integer'),
array($next_id, $title, $show_questiontext, $show_blocktitle, $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 218 of file class.ilObjSurvey.php.

References $result, and saveToDb().

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

+ Here is the call graph for this function:

ilObjSurvey::createSurveyCodes (   $nrOfCodes)

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

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

References $data, 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 254 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 343 of file class.ilObjSurvey.php.

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

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

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

Referenced by addQuestionToBlock(), and 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 4753 of file class.ilObjSurvey.php.

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

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

References ilObject\$id.

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

{
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::deliverPDFfromFO (   $fo)

Delivers a PDF file from a XSL-FO string.

Parameters
string$foThe XSL-FO string public

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

References $ilLog, ilUtil\deliverData(), ilRpcClientFactory\factory(), ilUtil\getASCIIFilename(), and ilUtil\ilTempnam().

{
global $ilLog;
include_once "./Services/Utilities/classes/class.ilUtil.php";
$fo_file = ilUtil::ilTempnam() . ".fo";
$fp = fopen($fo_file, "w"); fwrite($fp, $fo); fclose($fp);
include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
try
{
$pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF($fo);
ilUtil::deliverData($pdf_base64->scalar, ilUtil::getASCIIFilename($this->getTitle()) . ".pdf", "application/pdf");
return true;
}
{
$ilLog->write(__METHOD__.': '.$e->getMessage());
return false;
}
catch(Exception $e)
{
$ilLog->write(__METHOD__.': '.$e->getMessage());
return false;
}
/*
include_once "./Services/Transformation/classes/class.ilFO2PDF.php";
$fo2pdf = new ilFO2PDF();
$fo2pdf->setFOString($fo);
$result = $fo2pdf->send();
ilUtil::deliverData($result, ilUtil::getASCIIFilename($this->getTitle()) . ".pdf", "application/pdf");
*/
}

+ Here is the call graph for this function:

ilObjSurvey::disinviteAllUsers ( )

Disinvite all users.

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

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

References 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,
  $a_force = false 
)

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

References $ilUser, ilObject\getId(), getQuestionGUI(), and getQuestionType().

Referenced by insertQuestion(), and insertQuestionblock().

{
global $ilUser;
$questiontype = $this->getQuestionType($question_id);
$question_gui = $this->getQuestionGUI($questiontype, $question_id);
// check if question is a pool question at all, if not do nothing
if($this->getId() == $question_gui->object->getObjId() && !$a_force)
{
return $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 2932 of file class.ilObjSurvey.php.

References _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 2994 of file class.ilObjSurvey.php.

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

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

Referenced by saveToDb().

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

+ Here is the caller graph for this function:

ilObjSurvey::getActivationStartDate ( )

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

Referenced by saveToDb().

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

+ Here is the caller graph for this function:

ilObjSurvey::getActivationVisibility ( )

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

References $activation_visibility.

Referenced by saveToDb().

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

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

References $result, $row, and ilUtil\sortArray().

{
global $ilDB;
// #7987
$custom_order = array("equal", "not_equal", "less", "less_or_equal", "more", "more_or_equal");
$custom_order = array_flip($custom_order);
$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"], "order" => $custom_order[$row["longname"]]);
}
else
{
$result_array[$row["relation_id"]] = array("short" => $row["shortname"], "long" => $row["longname"], "order" => $custom_order[$row["longname"]]);
}
}
$result_array = ilUtil::sortArray($result_array, "order", "ASC", true, true);
foreach($result_array as $idx => $item)
{
unset($result_array[$idx]["order"]);
}
return $result_array;
}

+ Here is the call graph for this function:

ilObjSurvey::getAllRTEContent ( )

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

private

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

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

Referenced by canExportSurveyCode(), cloneObject(), finishSurvey(), getActiveID(), getUserDataFromActiveId(), isAccessibleWithCodeForAll(), isAccessibleWithoutCode(), 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 880 of file class.ilObjSurvey.php.

References ilObject\$id, $result, 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 1141 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 2517 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 2552 of file class.ilObjSurvey.php.

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

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

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

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

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

References $questions, $result, $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"],
"firstname" => $userdata["firstname"],
"lastname" => $userdata["lastname"],
"login" => $userdata["login"],
"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 1629 of file class.ilObjSurvey.php.

References $data, $result, 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))
{
if($data["original_id"])
{
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 4313 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 4324 of file class.ilObjSurvey.php.

References $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 != "." && $entry != ".." && ereg("^[0-9]{10}_{2}[0-9]+_{2}(svy_)*[0-9]+\.[a-z]{1,3}\$", $entry))
{
$file[] = $entry;
}
}
// close import directory
$dir->close();
// sort files
sort ($file);
reset ($file);
return $file;
}
ilObjSurvey::getExternalCodeRecipients (   $a_check_finished = false)

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

References $res, $result, $row, getSurveyId(), and isSurveyCodeUsed().

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'];
if($a_check_finished)
{
$externaldata['finished'] = $this->isSurveyCodeUsed($row['code']);
}
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 5166 of file class.ilObjSurvey.php.

References ilObject\$ref_id, $result, 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 4394 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 1606 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 1298 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 1310 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 2863 of file class.ilObjSurvey.php.

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

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

References $mailaddresses.

Referenced by saveToDb().

{
}

+ Here is the caller graph for this function:

ilObjSurvey::getMailNotification ( )

Definition at line 5189 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 5209 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 2474 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 2353 of file class.ilObjSurvey.php.

References $result, $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 1618 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 3090 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::getPoolUsage ( )

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

References $pool_usage.

Referenced by isPoolActive(), and saveToDb().

{
}

+ Here is the caller graph for this function:

ilObjSurvey::getPrecondition (   $id)

Returns a precondition with a given id.

public

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

References ilObject\$id, and $result.

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

References $result.

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

References $data, and $result.

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

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

References $ilUser, $row, $survey_id, ilUtil\_getObjectsByOperations(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), and getQuestionblockQuestions().

{
global $ilUser, $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.show_blocktitle, ".
"svy_qblk.owner_fi, svy_qblk.tstamp, svy_svy.obj_fi");
$rows = array();
if ($query_result->numRows())
{
$survey_ref_ids = ilUtil::_getObjectsByOperations("svy", "write");
$surveytitles = array();
foreach ($survey_ref_ids as $survey_ref_id)
{
}
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 904 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 1654 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 3583 of file class.ilObjSurvey.php.

References $result, and $row.

{
global $ilDB;
$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 3603 of file class.ilObjSurvey.php.

References $ilUser, $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))
{
if (array_key_exists('spl_txt', $arrFilter) && strlen($arrFilter['spl_txt']))
{
if(!stristr($spls[$row["obj_fi"]], $arrFilter['spl_txt']))
{
continue;
}
}
$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 917 of file class.ilObjSurvey.php.

References $data, and $result.

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::getRoleData (   $ids)

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

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

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

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

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

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

References $ilUser, $lang, $result, $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 4562 of file class.ilObjSurvey.php.

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

{
global $ilDB;
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 3377 of file class.ilObjSurvey.php.

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

References $result, $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'];
$all_questions[$question_id]["questionblock_show_blocktitle"] = $questionblocks[$question_id]['show_blocktitle'];
$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;
$all_questions[$question_id]["questionblock_show_blocktitle"] = 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 409 of file class.ilObjSurvey.php.

References $result, $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::getSurveyQuestions (   $with_answers = false)

Returns the survey questions and questionblocks in an array.

public

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

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

References $result, $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::getTemplate ( )

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

References $template_id.

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

{
}

+ Here is the caller graph for this function:

ilObjSurvey::getTextblock (   $question_id)

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

References $result, and $row.

Referenced by cloneTextblocks(), and ilSurveyPageGUI\editJS().

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

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

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

References $_GET, $result, $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"] = $userdata["sortname"] = $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 723 of file class.ilObjSurvey.php.

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

References $data, $questions, $result, $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::getUserSurveyCode (   $user_id)

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

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

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

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

References $ilUser, 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");
$this->author = $ilUser->fullname;
$this->status = STATUS_OFFLINE;
$this->evaluation_access = EVALUATION_ACCESS_OFF;
$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->template_id = NULL;
$this->pool_usage = true;
}

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

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

{
if ($svy_qpl_id < 1) $svy_qpl_id = -1;
// 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;
}
// too many different mime-types, so we use the suffix
$suffix = pathinfo($file_info["name"]);
if (strcmp(strtolower($suffix["extension"]), "zip") == 0)
{
$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";
$import = new SurveyImportParserPre38($svy_qpl_id, "", TRUE);
$import->setSurveyObject($this);
$import->setXMLContent($xml);
$import->startParsing();
}
else
{
include_once "./Services/Survey/classes/class.SurveyImportParser.php";
$import = new SurveyImportParser($svy_qpl_id, "", 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 608 of file class.ilObjSurvey.php.

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

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

{
global $ilDB;
$result = $ilDB->queryF("SELECT svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.show_blocktitle,".
" 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;
$show_blocktitle = 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"];
$show_blocktitle = $row["show_blocktitle"];
}
$this->createQuestionblock($title, $show_questiontext, $show_blocktitle, $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 2808 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 2836 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 2778 of file class.ilObjSurvey.php.

References $result, 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::isAccessibleWithCodeForAll ( )

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

References ANONYMIZE_CODE_ALL, and getAnonymize().

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

+ Here is the call graph for this function:

ilObjSurvey::isAccessibleWithoutCode ( )

Checks if the survey is accessable without a survey code.

Returns
boolean status

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

References ANONYMIZE_FREEACCESS, and getAnonymize().

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

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSurvey::isActivationLimited ( )

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

Referenced by saveToDb().

{
return (bool)$this->activation_limited;
}

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

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

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

+ Here is the caller graph for this function:

ilObjSurvey::isAnonymizedParticipant (   $key)

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

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

References $result, 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 501 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 4924 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 1356 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 1344 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 5122 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::isPoolActive ( )

Get current pool status.

Returns
bool

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

References getPoolUsage(), and getTemplate().

{
$use_pool = (bool)$this->getPoolUsage();
$template_settings = $this->getTemplate();
if($template_settings)
{
include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
$template_settings = new ilSettingsTemplate($template_settings);
$template_settings = $template_settings->getSettings();
$template_settings = $template_settings["use_pool"];
if($template_settings && $template_settings["hide"])
{
$use_pool = (bool)$template_settings["value"];
}
}
return $use_pool;
}

+ Here is the call graph for this function:

ilObjSurvey::isSurveyCodeUnique (   $code)

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

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

References $result, and getSurveyId().

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

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

Referenced by canStartSurvey(), and checkSurveyCode().

{
global $ilDB;
if ($this->getAnonymize())
{
if ((($user_id != ANONYMOUS_USER_ID) && sizeof($anonymize_id)) && (!($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 1011 of file class.ilObjSurvey.php.

References $data, $result, ilRTE\_replaceMediaObjectImageSrc(), ilObject\getId(), ilObjectActivation\getItem(), loadQuestionsFromDb(), setActivationEndDate(), setActivationLimited(), setActivationStartDate(), setActivationVisibility(), setAnonymize(), setAuthor(), setEndDate(), setEvaluationAccess(), setIntroduction(), setInvitation(), setInvitationMode(), setMailAddresses(), setMailNotification(), setMailParticipantData(), setOutro(), setPoolUsage(), setShowQuestionTitles(), setStartDate(), setStatus(), setSurveyId(), setTemplate(), and ilObjectActivation\TIMINGS_ACTIVATION.

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->setInvitation($data["invitation"]);
$this->setInvitationMode($data["invitation_mode"]);
$this->setShowQuestionTitles($data["show_question_titles"]);
$this->setStartDate($data["startdate"]);
$this->setEndDate($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']);
$this->setTemplate($data['template_id']);
$this->setPoolUsage($data['pool_usage']);
}
// moved activation to ilObjectActivation
if($this->ref_id)
{
include_once "./Services/Object/classes/class.ilObjectActivation.php";
$activation = ilObjectActivation::getItem($this->ref_id);
switch($activation["timing_type"])
{
$this->setActivationLimited(true);
$this->setActivationStartDate($activation["timing_start"]);
$this->setActivationEndDate($activation["timing_end"]);
$this->setActivationVisibility($activation["visible"]);
break;
default:
$this->setActivationLimited(false);
break;
}
}
}

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

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

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

References $file.

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!="..") && (ereg("^[0-9]{10}_{2}[0-9]+_{2}(svy_)*[0-9]+\.[a-z]{1,3}\$", $file) || ereg("^[0-9]{10}_{2}[0-9]+_{2}(survey__)*[0-9]+\.[a-z]{1,3}\$", $file)))
{
// 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,
  $show_blocktitle 
)

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

References ilObject\$title.

{
global $ilDB;
$affectedRows = $ilDB->manipulateF("UPDATE svy_qblk SET title = %s, show_questiontext = %s,".
" show_blocktitle = %s WHERE questionblock_id = %s",
array('text','text','text','integer'),
array($title, $show_questiontext, $show_blocktitle, $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 1700 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 1763 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 1793 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 1666 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 1735 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 442 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 4911 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 4840 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::processPrintoutput2FO (   $print_output)

Convert a print output to XSL-FO.

Parameters
string$print_outputThe print output
Returns
string XSL-FO code public

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

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

{
global $ilLog;
if (extension_loaded("tidy"))
{
$config = array(
"indent" => false,
"output-xml" => true,
"numeric-entities" => true
);
$tidy = new tidy();
$tidy->parseString($print_output, $config, 'utf8');
$tidy->cleanRepair();
$print_output = tidy_get_output($tidy);
$print_output = preg_replace("/^.*?(<html)/", "\\1", $print_output);
}
else
{
$print_output = str_replace("&nbsp;", "&#160;", $print_output);
$print_output = str_replace("&otimes;", "X", $print_output);
}
$xsl = file_get_contents("./Modules/Survey/xml/question2fo.xsl");
// additional font support
$xsl = str_replace(
'font-family="Helvetica, unifont"',
'font-family="'.$GLOBALS['ilSetting']->get('rpc_pdf_font','Helvetica, unifont').'"',
$xsl
);
$args = array( '/_xml' => $print_output, '/_xsl' => $xsl );
$xh = xslt_create();
$params = array();
$output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
xslt_error($xh);
xslt_free($xh);
$ilLog->write($output);
return $output;
}

+ Here is the call graph for this function:

ilObjSurvey::read (   $a_force_db = false)

read object data from db into object

Parameters
booleanpublic

Reimplemented from ilObject.

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

References $result, $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 1844 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::removeQuestionFromBlock (   $question_id,
  $questionblock_id 
)

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

References getSurveyId().

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

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

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

{
global $ilDB;
$block_sizes = array();
foreach ($this->getSurveyQuestions() 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);
}
else if($data["questionblock_id"])
{
$block_sizes[$data["questionblock_id"]]++;
}
}
// blocks with just 1 question need to be deleted
foreach($block_sizes as $block_id => $size)
{
if($size < 2)
{
$remove_questionblocks[] = $block_id;
}
}
foreach (array_unique($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 380 of file class.ilObjSurvey.php.

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

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

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

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

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

References ilRTE\_replaceMediaObjectImageSrc(), getActivationEndDate(), getActivationStartDate(), getActivationVisibility(), getAnonymize(), getAuthor(), getEndDate(), getEvaluationAccess(), ilObject\getId(), getIntroduction(), getInvitation(), getInvitationMode(), ilObjectActivation\getItem(), getMailAddresses(), getMailNotification(), getMailParticipantData(), getOutro(), getPoolUsage(), getShowQuestionTitles(), getStartDate(), getStatus(), getSurveyId(), getTemplate(), isActivationLimited(), isComplete(), saveQuestionsToDb(), setSurveyId(), ilObjectActivation\setTimingType(), ilObjectActivation\TIMINGS_ACTIVATION, and ilObjectActivation\TIMINGS_DEACTIVATED.

Referenced by applySettingsTemplate(), createReference(), and importObject().

{
global $ilDB;
include_once("./Services/RTE/classes/class.ilRTE.php");
if ($this->getSurveyId() < 1)
{
$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)),
"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()),
"template_id" => array("integer", $this->getTemplate()),
"pool_usage" => array("integer", $this->getPoolUsage())
));
$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)),
"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()),
"template_id" => array("integer", $this->getTemplate()),
"pool_usage" => array("integer", $this->getPoolUsage())
), array(
"survey_id" => array("integer", $this->getSurveyId())
));
}
if ($affectedRows)
{
// save questions to db
}
// moved activation to ilObjectActivation
if($this->ref_id)
{
include_once "./Services/Object/classes/class.ilObjectActivation.php";
$item = new ilObjectActivation;
if(!$this->isActivationLimited())
{
}
else
{
$item->setTimingStart($this->getActivationStartDate());
$item->setTimingEnd($this->getActivationEndDate());
$item->toggleVisible($this->getActivationVisibility());
}
$item->update($this->ref_id);
}
}

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

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

References 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,
  $lang = "en" 
)

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

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

{
/*
* 0 = all
* 1 = not sent
* 2 = finished
* 3 = not finished
*/
$check_finished = ($not_sent > 1);
include_once "./Services/Mail/classes/class.ilMail.php";
$user_id = $this->getOwner();
$mail = new ilMail($user_id);
$recipients = $this->getExternalCodeRecipients($check_finished);
foreach ($recipients as $data)
{
if($data['email'] && $data['code'])
{
$do_send = false;
switch ((int)$not_sent)
{
case 1:
$do_send = !(bool)$data['sent'];
break;
case 2:
$do_send = $data['finished'];
break;
case 3:
$do_send = !$data['finished'];
break;
default:
$do_send = true;
break;
}
if ($do_send)
{
// build text
$messagetext = $message;
$url = ILIAS_HTTP_PATH."/goto.php?cmd=infoScreen&target=svy_".$this->getRefId() . "&client_id=" . CLIENT_ID . "&accesscode=".$data["code"]."&lang=".$lang;
$messagetext = str_replace('[url]', "<" . $url . ">", $messagetext);
foreach ($data as $key => $value)
{
$messagetext = str_replace('[' . $key . ']', $value, $messagetext);
}
// send mail
$mail->sendMail(
$data['email'], // to
"", // cc
"", // bcc
$subject, // subject
$messagetext, // message
array(), // attachments
array('normal') // type
);
}
}
}
global $ilDB;
$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 3036 of file class.ilObjSurvey.php.

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

Referenced by finishSurvey().

{
include_once "./Services/User/classes/class.ilObjUser.php";
include_once "./Services/Mail/classes/class.ilMail.php";
// #12755
$placeholders = array(
"FIRST_NAME" => "firstname",
"LAST_NAME" => "lastname",
"LOGIN" => "login",
// old style
"firstname" => "firstname"
);
$mail = new ilMail(ANONYMOUS_USER_ID);
$recipients = preg_split('/,/', $this->mailaddresses);
foreach ($recipients as $recipient)
{
$data = ilObjUser::_getUserData(array($user_id));
$data = $data[0];
foreach ($placeholders as $key => $mapping)
{
if ($this->getAnonymize())
{
$messagetext = str_replace('[' . $key . ']', '', $messagetext);
}
else
{
$messagetext = str_replace('[' . $key . ']', trim($data[$mapping]), $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);
// #11298
include_once "./Services/Link/classes/class.ilLink.php";
$link = ilLink::_getStaticLink($this->getRefId(), "svy");
$messagetext .= "\n\n".$this->lng->txt('obj_svy').": ". $this->getTitle()."\n";
$messagetext .= "\n".$this->lng->txt('survey_notification_tutor_link').": ".$link;
$mail->appendInstallationSignature(true);
$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::setActivationEndDate (   $ending_time = NULL)

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

Referenced by loadFromDb().

{
$this->activation_ending_time = $ending_time;
}

+ Here is the caller graph for this function:

ilObjSurvey::setActivationLimited (   $a_value)

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

Referenced by loadFromDb().

{
$this->activation_limited = (bool)$a_value;
}

+ Here is the caller graph for this function:

ilObjSurvey::setActivationStartDate (   $starting_time = NULL)

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

Referenced by loadFromDb().

{
$this->activation_starting_time = $starting_time;
}

+ Here is the caller graph for this function:

ilObjSurvey::setActivationVisibility (   $a_value)

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

Referenced by loadFromDb().

{
$this->activation_visibility = (bool) $a_value;
}

+ Here is the caller graph for this function:

ilObjSurvey::setAnonymize (   $a_anonymize)

set anonymize status

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

References ANONYMIZE_CODE_ALL, ANONYMIZE_FREEACCESS, ANONYMIZE_OFF, and ANONYMIZE_ON.

Referenced by applySettingsTemplate(), and 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 1097 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 1524 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 1537 of file class.ilObjSurvey.php.

References $d, and $end_date.

{
$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::setEndTime (   $finished_id)

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

References $_SESSION.

{
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 1574 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 1275 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 1218 of file class.ilObjSurvey.php.

References $invitation, $result, $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 1263 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 1250 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 5204 of file class.ilObjSurvey.php.

Referenced by loadFromDb().

{
$this->mailaddresses = $a_addresses;
}

+ Here is the caller graph for this function:

ilObjSurvey::setMailNotification (   $a_notification)

Definition at line 5194 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 5214 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 2306 of file class.ilObjSurvey.php.

References $result, $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())
);
// #12420
$ilDB->manipulate("UPDATE svy_question".
" SET obligatory = ".$ilDB->quote($obligatory, "integer").
" WHERE question_id = ".$ilDB->quote($question_fi, "integer"));
}
}

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

{
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::setPoolUsage (   $a_value)

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

Referenced by applySettingsTemplate(), and loadFromDb().

{
$this->pool_usage = (bool)$a_value;
}

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

Referenced by applySettingsTemplate(), and 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 1474 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 1487 of file class.ilObjSurvey.php.

References $d, and $start_date.

{
$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::setStartTime (   $finished_id,
  $first_question 
)

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

References $_SESSION.

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

References $result, $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 5140 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::setTemplate (   $template_id)

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

References $template_id.

Referenced by applySettingsTemplate(), and loadFromDb().

{
$this->template_id = (int)$template_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 1195 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 2965 of file class.ilObjSurvey.php.

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

References _instanciateQuestion(), addMaterialTag(), getAnonymize(), getAuthor(), ilObject\getDescription(), getEndDate(), getEvaluationAccess(), ilObject\getId(), getIntroduction(), getObligatoryStates(), getOutro(), getShowQuestionTitles(), getStartDate(), 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_4_2.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->getStartDate())
{
$attrs = array("type" => "date");
preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->getStartDate(), $matches);
$a_xml_writer->xmlElement("startingtime", $attrs, sprintf("%04d-%02d-%02dT%02d:%02d:00", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
}
if ($this->getEndDate())
{
$attrs = array("type" => "date");
preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->getEndDate(), $matches);
$a_xml_writer->xmlElement("endingtime", $attrs, sprintf("%04d-%02d-%02dT%02d:%02d:00", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
}
$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"],
"conjunction" => $constraint["conjunction"]
);
$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"],
"showBlocktitle" => $question_array[0]["questionblock_show_blocktitle"]);
$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 1942 of file class.ilObjSurvey.php.

References 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 204 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 2690 of file class.ilObjSurvey.php.

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

{
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)
);
}
ilObjSurvey::updateOrder ( array  $a_order)

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

{
if(sizeof($this->questions) == sizeof($a_order))
{
$this->questions = array_flip($a_order);
$this->saveQuestionsToDB();
}
}

Field Documentation

ilObjSurvey::$activation_ending_time
protected

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

ilObjSurvey::$activation_starting_time
protected

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

ilObjSurvey::$activation_visibility
protected

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

Referenced by getActivationVisibility().

ilObjSurvey::$anonymize

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

ilObjSurvey::$end_date

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

Referenced by setEndDate(), and setEndDateAndTime().

ilObjSurvey::$evaluation_access

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

Referenced by setInvitation(), and setInvitationAndMode().

ilObjSurvey::$invitation_mode

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

Referenced by setInvitationAndMode(), and setInvitationMode().

ilObjSurvey::$mailaddresses

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

Referenced by getMailAddresses().

ilObjSurvey::$mailnotification

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

Referenced by getMailNotification().

ilObjSurvey::$mailparticipantdata

Definition at line 139 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::$pool_usage

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

Referenced by getPoolUsage().

ilObjSurvey::$start_date

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

Referenced by setStartDate(), and setStartDateAndTime().

ilObjSurvey::$status

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

Referenced by setStatus().

ilObjSurvey::$surveyCodeSecurity

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

ilObjSurvey::$template_id

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

Referenced by applySettingsTemplate(), getTemplate(), and setTemplate().


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