ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilObjSurvey Class Reference
+ Inheritance diagram for ilObjSurvey:
+ Collaboration diagram for ilObjSurvey:

Public Member Functions

 __construct (int $a_id=0, bool $a_call_by_reference=true)
 
 create ($a_upload=false)
 
 update ($a_upload=false)
 
 createReference ()
 creates reference for object More...
 
 read ()
 
 addQuestion (int $question_id)
 Adds a question to the survey (used in importer!) More...
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 deleteSurveyRecord ()
 Deletes the survey from the database. More...
 
 deleteAllUserData (bool $reset_LP=true)
 Deletes all user data of a survey. More...
 
 removeSelectedSurveyResults (array $finished_ids)
 Deletes the user data of a given array of survey participants. More...
 
 getSurveyParticipants (?array $finished_ids=null, bool $force_non_anonymous=false, bool $include_invites=false)
 
 isComplete ()
 Check if survey is complete for use. More...
 
 hasQuestions ()
 
 saveCompletionStatus ()
 Saves the completion status of the survey. More...
 
 duplicateQuestionForSurvey (int $question_id, bool $a_force=false)
 Takes a question and creates a copy of the question for use in the survey. More...
 
 insertQuestion (int $question_id)
 Inserts a question in the survey and saves the relation to the database. More...
 
 isQuestionInSurvey (int $a_question_fi)
 
 insertQuestionblock (int $questionblock_id)
 
 saveUserSettings (int $usr_id, string $key, string $title, string $value)
 
 deleteUserSettings (int $id)
 
 getUserSettings (int $usr_id, string $key)
 
 saveToDb ()
 
 saveQuestionsToDb ()
 
 getQuestionGUI (string $questiontype, int $question_id)
 
 getQuestionType (int $question_id)
 
 getSurveyId ()
 
 setAnonymize (int $a_anonymize)
 set anonymize status More...
 
 getAnonymize ()
 
 setCalculateSumScore (bool $a_val)
 
 getCalculateSumScore ()
 
 isAccessibleWithoutCode ()
 
 hasAnonymizedResults ()
 
 loadFromDb ()
 
 loadQuestionsFromDb ()
 
 fixSequenceStructure ()
 
 setAuthor (string $author="")
 
 saveAuthorToMetadata (string $a_author="")
 Saves an authors name into the lifecycle metadata if no lifecycle metadata exists This will only be called for conversion of "old" surveys where the author hasn't been stored in the lifecycle metadata. More...
 
 getAuthor ()
 
 getShowQuestionTitles ()
 
 setShowQuestionTitles (bool $a_show)
 
 setIntroduction (string $introduction="")
 
 setOutro (string $outro="")
 
 getStartDate ()
 
 setStartDate (string $start_date="")
 
 setStartDateAndTime (string $start_date, string $start_time)
 
 getEndDate ()
 
 setEndDate (string $end_date="")
 
 hasStarted ()
 
 hasEnded ()
 
 setEndDateAndTime (string $end_date, string $end_time)
 
 getEvaluationAccess ()
 
 setEvaluationAccess (string $evaluation_access=self::EVALUATION_ACCESS_OFF)
 
 setActivationVisibility (bool $a_value)
 
 getActivationVisibility ()
 
 isActivationLimited ()
 
 setActivationLimited (bool $a_value)
 
 getIntroduction ()
 
 getOutro ()
 
 getExistingQuestions ()
 Gets the question id's of the questions which are already in the survey. More...
 
 getQuestionpoolTitles (bool $could_be_offline=false, bool $showPath=false)
 Returns the available question pools for the active user. More...
 
 moveQuestions (array $move_questions, int $target_index, int $insert_mode)
 Move questions and/or questionblocks to another position. More...
 
 removeQuestion (int $question_id)
 
 removeConstraintsConcerningQuestion (int $question_id)
 Remove constraints concerning a question with a given question_id. More...
 
 removeQuestions (array $remove_questions, array $remove_questionblocks)
 
 unfoldQuestionblocks (array $questionblocks)
 
 removeQuestionFromBlock (int $question_id, int $questionblock_id)
 
 addQuestionToBlock (int $question_id, int $questionblock_id)
 
 isQuestionInAnyBlock (int $a_question_fi)
 
 getQuestionblockQuestions (int $questionblock_id)
 
 getQuestionblockQuestionIds (int $questionblock_id)
 
 createQuestionblock (string $title, bool $show_questiontext, bool $show_blocktitle, array $questions, bool $compress_view=false)
 
 modifyQuestionblock (int $questionblock_id, string $title, bool $show_questiontext, bool $show_blocktitle, bool $compress_view=false)
 
 deleteConstraints (int $question_id)
 Deletes the constraints for a question. More...
 
 deleteConstraint (int $constraint_id)
 Deletes a single constraint. More...
 
 getSurveyQuestions (bool $with_answers=false)
 Returns the survey questions and questionblocks in an array. More...
 
 setObligatoryStates (array $obligatory_questions)
 Sets the obligatory states for questions in a survey from the questions form. More...
 
 getSurveyPages ()
 Returns the survey pages in an array (a page contains one or more questions) More...
 
 getNextPage (int $active_page_question_id, int $direction)
 Get current, previous or next page. More...
 
 getAvailableQuestionpools (bool $use_obj_id=false, bool $could_be_offline=false, bool $showPath=false, string $permission="read")
 Returns the available question pools for the active user. More...
 
 getPrecondition (int $constraint_id)
 Returns a precondition with a given id. More...
 
 getConstraints (int $question_id)
 Returns the constraints to a given question or questionblock. More...
 
 getVariables (int $question_id)
 Returns all variables (answer options/scale values) of a question. More...
 
 addConstraint (int $if_question_id, int $relation, float $value, int $conjunction)
 Adds a constraint. More...
 
 addConstraintToQuestion (int $to_question_id, int $constraint_id)
 
 updateConstraint (int $precondition_id, int $if_question_id, int $relation, float $value, int $conjunction)
 
 updateConjunctionForQuestions (array $questions, int $conjunction)
 
 getAllRelations (bool $short_as_key=false)
 
 deleteWorkingData (int $question_id, int $active_id)
 Deletes the working data of a question in the database. More...
 
 loadWorkingData (int $question_id, int $active_id)
 Gets the given answer data of a question in a run. More...
 
 finishSurvey (int $finished_id, int $appr_id=0)
 Finishes the survey creating an entry in the database. More...
 
 setPage (int $finished_id, int $page_id)
 Sets the number of the active survey page. More...
 
 sendNotificationMail (int $a_user_id, string $a_anonymize_id, int $a_appr_id=0)
 These mails are sent to tutors for each single participant that finishes a survey. More...
 
 getActiveID (int $user_id, string $anonymize_id, int $appr_id)
 Get run id. More...
 
 getLastActivePage (int $active_id)
 Returns the question id of the last active page a user visited in a survey. More...
 
 checkConstraint (array $constraint_data, ?array $working_data)
 Checks if a constraint is valid. More...
 
 getSurveyFinishedIds ()
 Get run ids. More...
 
 getUserSpecificResults (array $finished_ids)
 Calculates the evaluation data for the user specific results. More...
 
 getUserDataFromActiveId (int $active_id, bool $force_non_anonymous=false)
 Returns run information. More...
 
 getEvaluationByUser (array $questions, int $active_id)
 Calculates the evaluation data for a given run. More...
 
 getQuestionsTable (array $arrFilter)
 Retrieve data for question browser. More...
 
 getQuestionblocksTable (array $arrFilter)
 Retrieve data for question block browser. More...
 
 toXML ()
 Returns a QTI xml representation of the survey. More...
 
 locateImportFiles (string $a_dir)
 Locates the import directory and the xml file in a directory with an unzipped import file. More...
 
 importObject (array $file_info, int $svy_qpl_id)
 
 getTextblock (int $question_id)
 
 cloneTextblocks (array $mapping)
 Clones the text blocks of survey questions. More...
 
 createExportDirectory ()
 creates data directory for export files (data_dir/svy_data/svy_<id>/export) More...
 
 getExportDirectory ()
 
 createImportDirectory ()
 creates data directory for import files (data_dir/svy_data/svy_<id>/import) More...
 
 getImportDirectory ()
 get import directory of survey More...
 
 saveHeading (string $heading, int $insertbefore)
 
 isAnonymizedParticipant (string $key)
 
 getSurveyCodesForExport (?array $a_codes=null, ?array $a_ids=null)
 Return a list of survey codes for file export, note: user_key needs to be null to export a record. More...
 
 getSurveyCodesTableData (?array $ids=null, ?string $lang=null)
 Fetches the data for the survey codes table. More...
 
 isSurveyCodeUsed (string $code)
 
 isSurveyCodeUnique (string $code)
 
 importSurveyCode (string $a_anonymize_key, int $a_created, array $a_data)
 
 sendCodes (int $not_sent, string $subject, string $message, string $lang)
 
 getExternalCodeRecipients (bool $a_check_finished=false)
 
 isSurveyFinishedByCode (string $a_code)
 Get if survey is finished for a specific anonymous user code. More...
 
 deleteSurveyCode (string $survey_code)
 
 getUserAccessCode (int $user_id)
 Returns a survey access code that was saved for a registered user. More...
 
 saveUserAccessCode (int $user_id, string $access_code)
 Saves a survey access code for a registered user to the database. More...
 
 getLastAccess (int $finished_id)
 
 prepareTextareaOutput (string $txt_output)
 Prepares a string for a text area output in surveys. More...
 
 isHTML (string $a_text)
 Checks if a given string contains HTML or not. More...
 
 addMaterialTag (ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true, ?array $attribs=null)
 Creates an XML material tag from a plain text or xhtml text. More...
 
 canExportSurveyCode ()
 Checks if the survey code can be exported with the survey evaluation. More...
 
 setSurveyId (int $survey_id)
 
 getUserData (array $ids)
 Returns a data of all users specified by id list. More...
 
 getMailNotification ()
 Send mail to tutors each time a participant finishes the survey? More...
 
 setMailNotification (bool $a_notification)
 Activate mail to tutors each time a participant finishes the survey. More...
 
 getMailAddresses ()
 (Tutor) Recipients of "single participant has finished" mails More...
 
 setMailAddresses (string $a_addresses)
 Set (Tutor) Recipients of "single participant has finished" mails. More...
 
 getMailParticipantData ()
 Preceding text (incl. More...
 
 setMailParticipantData (string $a_data)
 Set preceding text (incl. More...
 
 getWorkingtimeForParticipant (int $finished_id)
 
 updateOrder (array $a_order)
 
 getPoolUsage ()
 
 setPoolUsage (bool $a_value)
 
 updateCode (int $a_id, string $a_email, string $a_last_name, string $a_first_name, int $a_sent)
 
 get360Mode ()
 
 set360SelfEvaluation (bool $a_value)
 
 get360SelfEvaluation ()
 
 set360SelfAppraisee (bool $a_value)
 
 get360SelfAppraisee ()
 
 set360SelfRaters (bool $a_value)
 
 get360SelfRaters ()
 
 set360Results (int $a_value)
 
 get360Results ()
 
 addAppraisee (int $a_user_id)
 
 sendAppraiseeNotification (int $a_user_id)
 
 sendAppraiseeCloseNotification (int $a_user_id)
 
 sendRaterNotification (int $a_user_id, int $a_appraisee_id)
 
 isAppraisee (int $a_user_id)
 
 isAppraiseeClosed (int $a_user_id)
 
 deleteAppraisee (int $a_user_id)
 
 getAppraiseesData ()
 
 addRater (int $a_appraisee_id, int $a_user_id, int $a_anonymous_id=0)
 
 isRater (int $a_appraisee_id, int $a_user_id, int $a_anonymous_id=0)
 
 deleteRater (int $a_appraisee_id, int $a_user_id, int $a_anonymous_id=0)
 
 getRatersData (int $a_appraisee_id)
 
 getAppraiseesToRate (?int $a_user_id, ?int $a_anonymous_id=null)
 
 getAnonymousIdByCode (string $a_code)
 
 is360SurveyStarted (int $appr_id, int $user_id, ?string $anonymous_code=null)
 
 getUserSurveyExecutionStatus (?string $a_code=null)
 Get current user execution status. More...
 
 findCodeForUser (int $a_user_id)
 
 isUnusedCode (string $a_code, int $a_user_id)
 
 getFinishedIdsForAppraiseeId (int $a_appr_id, bool $a_exclude_appraisee=false)
 
 getFinishedIdForAppraiseeIdAndRaterId (int $a_appr_id, int $a_rat_id)
 Get finished id for an appraisee and a rater. More...
 
 setSkillService (bool $a_val)
 
 getSkillService ()
 
 set360RaterSent (int $a_appraisee_id, int $a_user_id, int $a_anonymous_id, ?int $a_tstamp=null)
 
 closeAppraisee (int $a_user_id)
 
 openAllAppraisees ()
 
 getReminderStatus ()
 
 setReminderStatus (bool $a_value)
 
 getReminderStart ()
 
 setReminderStart (?ilDate $a_value=null)
 
 getReminderEnd ()
 
 setReminderEnd (?ilDate $a_value=null)
 
 getReminderFrequency ()
 
 setReminderFrequency (int $a_value)
 
 getReminderTarget ()
 
 setReminderTarget (int $a_value)
 
 getReminderLastSent ()
 
 setReminderLastSent (?string $a_value)
 
 getReminderTemplate (bool $selectDefault=false)
 
 setReminderTemplate (?int $a_value)
 
 getTutorNotificationStatus ()
 
 setTutorNotificationStatus (bool $a_value)
 Activates mail being sent to tutors after all participants have finished the survey. More...
 
 getTutorNotificationRecipients ()
 Mail being sent to tutors after all participants have finished the survey? More...
 
 setTutorNotificationRecipients (array $a_value)
 Set tutor recipients for "all participants have finished" mail. More...
 
 getTutorNotificationTarget ()
 Group that is checked for the "all participants have finished" mail Either a) all members of a parent group/course or b) all users which have been invited (svy_invitation) (= task on dashboard) More...
 
 setTutorNotificationTarget (int $a_value)
 
 getTutorResultsStatus ()
 
 setTutorResultsStatus (bool $a_value)
 
 getTutorResultsRecipients ()
 
 setTutorResultsRecipients (array $a_value)
 
 sent360Reminders ()
 Send 360 reminders. More...
 
 send360ReminderToUser (int $a_user_id, array $a_appraisee_ids)
 
 getNotificationTargetUserIds (bool $a_use_invited)
 These users must finish the survey to trigger the tutor notification "all users finished the survey" a) members of a parent group/course or b) all members that have been invited (svy_invitation) invitations are presented as tasks on the dashboard. More...
 
 checkReminder ()
 
 setActivationStartDate (?int $starting_time=null)
 
 setActivationEndDate (?int $ending_time=null)
 
 getActivationStartDate ()
 
 getActivationEndDate ()
 
 setViewOwnResults (bool $a_value)
 
 hasViewOwnResults ()
 
 setMailOwnResults (bool $a_value)
 
 hasMailOwnResults ()
 
 setMailConfirmation (bool $a_value)
 
 hasMailConfirmation ()
 
 setAnonymousUserList (bool $a_value)
 
 hasAnonymousUserList ()
 
 getReminderMailTemplates (?int &$defaultTemplateId=null)
 
 setMode (int $a_value)
 
 getMode ()
 
 setSelfEvaluationResults (int $a_value)
 
 getSelfEvaluationResults ()
 
 getMaxSumScore ()
 
- Public Member Functions inherited from ilObject
 getObjectProperties ()
 
 flushObjectProperties ()
 
 withReferences ()
 determines whether objects are referenced or not (got ref ids or not) More...
 
 processAutoRating ()
 
 read ()
 
 getId ()
 
 setId (int $id)
 
 setRefId (int $ref_id)
 
 getRefId ()
 
 getType ()
 
 setType (string $type)
 
 getPresentationTitle ()
 get presentation title Normally same as title Overwritten for sessions More...
 
 getTitle ()
 
 getUntranslatedTitle ()
 Get untranslated object title WebDAV needs to access the untranslated title of an object. More...
 
 setTitle (string $title)
 
 getDescription ()
 
 setDescription (string $description)
 
 getLongDescription ()
 get object long description (stored in object_description) More...
 
 getImportId ()
 
 setImportId (string $import_id)
 
 setOfflineStatus (bool $status)
 
 getOfflineStatus ()
 
 supportsOfflineHandling ()
 
 getOwner ()
 
 getOwnerName ()
 get full name of object owner More...
 
 setOwner (int $usr_id)
 
 getCreateDate ()
 Get create date in YYYY-MM-DD HH-MM-SS format. More...
 
 getLastUpdateDate ()
 Get last update date in YYYY-MM-DD HH-MM-SS format. More...
 
 create ()
 note: title, description and type should be set when this function is called More...
 
 update ()
 
 MDUpdateListener (string $element)
 Metadata update listener. More...
 
 createMetaData ()
 
 updateMetaData ()
 
 deleteMetaData ()
 
 updateOwner ()
 update owner of object in db More...
 
 putInTree (int $parent_ref_id)
 maybe this method should be in tree object!? More...
 
 setPermissions (int $parent_ref_id)
 
 setParentRolePermissions (int $parent_ref_id)
 Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g. More...
 
 createReference ()
 creates reference for object More...
 
 countReferences ()
 
 delete ()
 delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!! More...
 
 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. More...
 
 applyDidacticTemplate (int $tpl_id)
 
 getXMLZip ()
 
 getHTMLDirectory ()
 
 appendCopyInfo (int $target_id, int $copy_id, int $new_obj_id)
 Prepend Copy info if object with same name exists in that container. More...
 
 cloneDependencies (int $target_id, int $copy_id)
 Clone object dependencies. More...
 
 cloneMetaData (ilObject $target_obj)
 Copy meta data. More...
 
 selfOrParentWithRatingEnabled ()
 
 getPossibleSubObjects (bool $filter=true)
 get all possible sub objects of this type the object can decide which types of sub objects are possible jut in time overwrite if the decision distinguish from standard model More...
 

Static Public Member Functions

static _getQuestionblock (int $questionblock_id)
 get question block properties More...
 
static _addQuestionblock (string $title="", int $owner=0, bool $show_questiontext=true, bool $show_blocktitle=false, bool $compress_view=false)
 
static _getConstraints (int $survey_id)
 
static _hasDatasets (int $survey_id)
 
static _instanciateQuestion (int $question_id)
 Creates an instance of a question with a given question id. More...
 
static getSurveySkippedValue ()
 
static getSurveysWithTutorResults ()
 
- Static Public Member Functions inherited from ilObject
static _lookupObjIdByImportId (string $import_id)
 Get (latest) object id for an import id. More...
 
static _lookupImportId (int $obj_id)
 
static _lookupOwnerName (int $owner_id)
 Lookup owner name for owner id. More...
 
static _getIdForImportId (string $import_id)
 
static _getAllReferences (int $id)
 get all reference ids for object ID More...
 
static _lookupTitle (int $obj_id)
 
static lookupOfflineStatus (int $obj_id)
 Lookup offline status using objectDataCache. More...
 
static _lookupOwner (int $obj_id)
 Lookup owner user ID for object ID. More...
 
static _getIdsForTitle (string $title, string $type='', bool $partial_match=false)
 
static _lookupDescription (int $obj_id)
 
static _lookupLastUpdate (int $obj_id, bool $formatted=false)
 
static _getLastUpdateOfObjects (array $obj_ids)
 
static _lookupObjId (int $ref_id)
 
static _setDeletedDate (int $ref_id, int $deleted_by)
 
static setDeletedDates (array $ref_ids, int $user_id)
 
static _resetDeletedDate (int $ref_id)
 
static _lookupDeletedDate (int $ref_id)
 
static _writeTitle (int $obj_id, string $title)
 write title to db (static) More...
 
static _writeDescription (int $obj_id, string $desc)
 write description to db (static) More...
 
static _writeImportId (int $obj_id, string $import_id)
 write import id to db (static) More...
 
static _lookupType (int $id, bool $reference=false)
 
static _isInTrash (int $ref_id)
 
static _hasUntrashedReference (int $obj_id)
 checks whether an object has at least one reference that is not in trash More...
 
static _lookupObjectId (int $ref_id)
 
static _getObjectsDataForType (string $type, bool $omit_trash=false)
 get all objects of a certain type More...
 
static _exists (int $id, bool $reference=false, ?string $type=null)
 checks if an object exists in object_data More...
 
static _getObjectsByType (string $obj_type="", ?int $owner=null)
 
static _prepareCloneSelection (array $ref_ids, string $new_type, bool $show_path=true)
 Prepare copy wizard object selection. More...
 
static getIconForType (string $type)
 
static _getIcon (int $obj_id=0, string $size="big", string $type="", bool $offline=false)
 Get icon for repository item. More...
 
static collectDeletionDependencies (array &$deps, int $ref_id, int $obj_id, string $type, int $depth=0)
 Collect deletion dependencies. More...
 
static getDeletionDependencies (int $obj_id)
 Get deletion dependencies. More...
 
static getLongDescriptions (array $obj_ids)
 
static getAllOwnedRepositoryObjects (int $user_id)
 
static fixMissingTitles ($type, array &$obj_title_map)
 Try to fix missing object titles. More...
 
static _lookupCreationDate (int $obj_id)
 
static _getObjectTypeIdByTitle (string $type, ?\ilDBInterface $ilDB=null)
 

Data Fields

const EVALUATION_ACCESS_OFF = "0"
 
const EVALUATION_ACCESS_ALL = "1"
 
const EVALUATION_ACCESS_PARTICIPANTS = "2"
 
const ANONYMIZE_OFF = 0
 
const ANONYMIZE_ON = 1
 
const ANONYMIZE_FREEACCESS = 2
 
const ANONYMIZE_CODE_ALL = 3
 
const QUESTIONTITLES_HIDDEN = 0
 
const QUESTIONTITLES_VISIBLE = 1
 
const PRINT_HIDE_LABELS = 1
 
const PRINT_SHOW_LABELS = 3
 
const MODE_STANDARD = 0
 
const MODE_360 = 1
 
const MODE_SELF_EVAL = 2
 
const MODE_IND_FEEDB = 3
 
const RESULTS_SELF_EVAL_NONE = 0
 
const RESULTS_SELF_EVAL_OWN = 1
 
const RESULTS_SELF_EVAL_ALL = 2
 
const RESULTS_360_NONE = 0
 
const RESULTS_360_OWN = 1
 
const RESULTS_360_ALL = 2
 
const NOTIFICATION_PARENT_COURSE = 1
 
const NOTIFICATION_INVITED_USERS = 2
 
const NOTIFICATION_APPRAISEES = 3
 
const NOTIFICATION_RATERS = 4
 
const NOTIFICATION_APPRAISEES_AND_RATERS = 5
 
int $survey_id = 0
 A unique positive numerical ID which identifies the survey. More...
 
string $author = ""
 A text representation of the authors name. More...
 
string $introduction = ""
 
string $outro = ""
 
string $evaluation_access = self::EVALUATION_ACCESS_OFF
 
string $start_date = ""
 
string $end_date = ""
 
array $questions = []
 
int $anonymize = 0
 
int $display_question_titles = 0
 
bool $surveyCodeSecurity = false
 
bool $mailnotification = false
 
string $mailaddresses = ""
 
string $mailparticipantdata = ""
 
bool $pool_usage = false
 
- Data Fields inherited from ilObject
const TITLE_LENGTH = 255
 
const DESC_LENGTH = 128
 
const LONG_DESC_LENGTH = 4000
 
const TABLE_OBJECT_DATA = "object_data"
 
array $objectList
 
string $untranslatedTitle
 

Protected Member Functions

 initServices ()
 
 doCreateMetaData ()
 
 getParticipantTextResults (int $active_id)
 
 checkTutorNotification ()
 Check, if mail to tutors after all participants have finished the survey should be sent. More...
 
 sendTutorNotification ()
 Send mail to tutors after all participants have finished the survey. More...
 
 sentReminderPlaceholders (string $a_message, int $a_user_id, array $a_context_params)
 
- Protected Member Functions inherited from ilObject
 doMDUpdateListener (string $a_element)
 
 beforeMDUpdateListener (string $a_element)
 
 doCreateMetaData ()
 
 beforeCreateMetaData ()
 
 doUpdateMetaData ()
 
 beforeUpdateMetaData ()
 
 doDeleteMetaData ()
 
 beforeDeleteMetaData ()
 
 handleAutoRating ()
 
 hasAutoRating ()
 

Protected Attributes

InternalDomainService $domain
 
ilLogger $svy_log
 
bool $activation_limited = false
 
ilObjUser $user
 
ilAccessHandler $access
 
ilPluginAdmin $plugin_admin
 
bool $calculate_sum_score = false
 
bool $activation_visibility = false
 
int $activation_starting_time = null
 
int $activation_ending_time = null
 
bool $mode_360_self_eval = false
 
bool $mode_360_self_appr = false
 
bool $mode_360_self_rate = false
 
int $mode_360_results = 0
 
bool $mode_skill_service = false
 
bool $reminder_status = false
 
ilDate $reminder_start = null
 
ilDate $reminder_end = null
 
int $reminder_frequency = 0
 
int $reminder_target = 0
 
string $reminder_last_sent = null
 
int $reminder_tmpl = null
 
bool $tutor_ntf_status = false
 
array $tutor_ntf_recipients = []
 
int $tutor_ntf_target = 0
 
bool $tutor_res_status = false
 
array $tutor_res_recipients = []
 
bool $view_own_results = false
 
bool $mail_own_results = false
 
bool $mail_confirmation = false
 
bool $anon_user_list = false
 
int $mode = 0
 
int $mode_self_eval_results = 0
 
Participants InvitationsManager $invitation_manager
 
ILIAS Survey InternalService $survey_service
 
ILIAS Survey Code CodeManager $code_manager
 
ILIAS Survey InternalDataService $data_manager
 
Mode FeatureConfig $feature_config
 
ILIAS SurveyQuestionPool Export ImportManager $import_manager
 
ilMailTemplatePlaceholderResolver $placeholder_resolver
 
- Protected Attributes inherited from ilObject
ilLogger $obj_log
 
ILIAS $ilias
 
ilObjectDefinition $obj_definition
 
ilDBInterface $db
 
ilLogger $log
 
ilErrorHandling $error
 
ilTree $tree
 
ilAppEventHandler $app_event_handler
 
ilRbacAdmin $rbac_admin
 
ilRbacReview $rbac_review
 
ilObjUser $user
 
ilLanguage $lng
 
LOMServices $lom_services
 
bool $call_by_reference
 
int $max_title = self::TITLE_LENGTH
 
int $max_desc = self::DESC_LENGTH
 
bool $add_dots = true
 
int $ref_id = null
 
string $type = ""
 
string $title = ""
 
string $desc = ""
 
string $long_desc = ""
 
int $owner = 0
 
string $create_date = ""
 
string $last_update = ""
 
string $import_id = ""
 
bool $register = false
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjSurvey::__construct ( int  $a_id = 0,
bool  $a_call_by_reference = true 
)

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

148 {
149 global $DIC;
150
151 $this->survey_service = $DIC->survey()->internal();
152
153 $this->user = $DIC->user();
154 $this->lng = $DIC->language();
155 $this->db = $DIC->database();
156 $this->access = $DIC->access();
157 $this->plugin_admin = $DIC["ilPluginAdmin"];
158 $this->tree = $DIC->repositoryTree();
159 $ilUser = $DIC->user();
160 $lng = $DIC->language();
161
162 $this->type = "svy";
163 $this->survey_id = -1;
164 $this->introduction = "";
165 $this->outro = $lng->txt("survey_finished");
166 $this->author = $ilUser->getFullname();
167 $this->evaluation_access = self::EVALUATION_ACCESS_OFF;
168 $this->questions = array();
169 $this->anonymize = self::ANONYMIZE_OFF;
170 $this->display_question_titles = self::QUESTIONTITLES_VISIBLE;
171 $this->surveyCodeSecurity = true;
172 $this->pool_usage = true;
173 $this->mode = self::MODE_STANDARD;
174 $this->mode_self_eval_results = self::RESULTS_SELF_EVAL_OWN;
175
176 $this->invitation_manager = $this
177 ->survey_service
178 ->domain()
179 ->participants()
180 ->invitations();
181
182 $this->import_manager = $DIC->surveyQuestionPool()
183 ->internal()
184 ->domain()
185 ->import();
186 $this->placeholder_resolver = $DIC->mail()->placeholderResolver();
187
188 parent::__construct($a_id, $a_call_by_reference);
189 $this->svy_log = ilLoggerFactory::getLogger("svy");
190 $this->initServices();
191 $this->domain = $DIC->survey()->internal()->domain();
192 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getLogger(string $a_component_id)
Get component logger.
const QUESTIONTITLES_VISIBLE
const EVALUATION_ACCESS_OFF
const RESULTS_SELF_EVAL_OWN
ilLanguage $lng
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ilObject\$lng, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\access(), ANONYMIZE_OFF, EVALUATION_ACCESS_OFF, ilLoggerFactory\getLogger(), initServices(), ILIAS\Repository\lng(), MODE_STANDARD, QUESTIONTITLES_VISIBLE, RESULTS_SELF_EVAL_OWN, ilLanguage\txt(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ _addQuestionblock()

static ilObjSurvey::_addQuestionblock ( string  $title = "",
int  $owner = 0,
bool  $show_questiontext = true,
bool  $show_blocktitle = false,
bool  $compress_view = false 
)
static
Todo:
move to survey question manager/repo

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

1679 : int {
1680 global $DIC;
1681
1682 $ilDB = $DIC->database();
1683 $next_id = $ilDB->nextId('svy_qblk');
1684 $ilDB->manipulateF(
1685 "INSERT INTO svy_qblk (questionblock_id, title, show_questiontext," .
1686 " show_blocktitle, owner_fi, tstamp, compress_view) " .
1687 "VALUES (%s, %s, %s, %s, %s, %s, %s)",
1688 array('integer','text','integer','integer','integer','integer','integer'),
1689 array($next_id, $title, $show_questiontext, $show_blocktitle, $owner, time(),$compress_view)
1690 );
1691 return $next_id;
1692 }
string $title

◆ _getConstraints()

static ilObjSurvey::_getConstraints ( int  $survey_id)
static
Todo:
move to constraint manager/repo, use dto

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

2101 : array {
2102 global $DIC;
2103
2104 $ilDB = $DIC->database();
2105 $result_array = array();
2106 $result = $ilDB->queryF(
2107 "SELECT svy_qst_constraint.question_fi as for_question, svy_constraint.*, svy_relation.* " .
2108 "FROM svy_qst_constraint, svy_constraint, svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id " .
2109 "AND svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.survey_fi = %s",
2110 array('integer'),
2111 array($survey_id)
2112 );
2113 while ($row = $ilDB->fetchAssoc($result)) {
2114 $result_array[] = array("id" => $row["constraint_id"],
2115 "for_question" => $row["for_question"],
2116 "question" => $row["question_fi"],
2117 "short" => $row["shortname"],
2118 "long" => $row["longname"],
2119 "relation_id" => $row["relation_id"],
2120 "value" => $row["value"],
2121 'conjunction' => $row['conjunction']
2122 );
2123 }
2124 return $result_array;
2125 }
int $survey_id
A unique positive numerical ID which identifies the survey.

◆ _getQuestionblock()

static ilObjSurvey::_getQuestionblock ( int  $questionblock_id)
static

get question block properties

Todo:
move to survey question manager/repo

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

1657 : array {
1658 global $DIC;
1659
1660 $ilDB = $DIC->database();
1661 $result = $ilDB->queryF(
1662 "SELECT * FROM svy_qblk WHERE questionblock_id = %s",
1663 array('integer'),
1664 array($questionblock_id)
1665 );
1666 $row = $ilDB->fetchAssoc($result);
1667 return $row;
1668 }

◆ _hasDatasets()

static ilObjSurvey::_hasDatasets ( int  $survey_id)
static
Todo:
move to run manager

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

2637 : bool {
2638 global $DIC;
2639
2640 $ilDB = $DIC->database();
2641
2642 $result = $ilDB->queryF(
2643 "SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
2644 array('integer'),
2645 array($survey_id)
2646 );
2647 return (bool) $result->numRows();
2648 }

Referenced by ilSurveyConstraintsGUI\constraintsObject(), ilSurveySyncTableGUI\importData(), and ilSurveyEditorGUI\questionsObject().

+ Here is the caller graph for this function:

◆ _instanciateQuestion()

static ilObjSurvey::_instanciateQuestion ( int  $question_id)
static

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

Todo:
move to factory in pool module

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

3095 : ?SurveyQuestion {
3096 if ($question_id < 1) {
3097 return null;
3098 }
3099 $question_type = SurveyQuestion::_getQuestionType($question_id);
3100 if ($question_type === '') {
3101 return null;
3102 }
3103 SurveyQuestion::_includeClass($question_type);
3104 $question = new $question_type();
3105 $question->loadFromDb($question_id);
3106 return $question;
3107 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _includeClass(string $question_type, int $gui=0)
Include the php class file for a given question type.
static _getQuestionType(int $question_id)
Returns the question type of a question with a given id.

Referenced by ilSurveyEditorGUI\copyPasteObject(), ilSurveyEditorGUI\copyQuestionsToPoolObject(), and ilSurveyEditorGUI\executeCopyQuestionsToPoolObject().

+ Here is the caller graph for this function:

◆ addAppraisee()

ilObjSurvey::addAppraisee ( int  $a_user_id)
Todo:
move to appraisal manager

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

4278 : void {
4279 global $DIC;
4280
4281 $ilDB = $DIC->database();
4282 $access = $DIC->access();
4283
4284 if (!$this->isAppraisee($a_user_id) &&
4285 $a_user_id !== ANONYMOUS_USER_ID) {
4286 $fields = array(
4287 "obj_id" => array("integer", $this->getSurveyId()),
4288 "user_id" => array("integer", $a_user_id)
4289 );
4290 $ilDB->insert("svy_360_appr", $fields);
4291
4292 // send notification and add to desktop
4293 if ($access->checkAccessOfUser($a_user_id, "read", "", $this->getRefId())) {
4294 $this->sendAppraiseeNotification($a_user_id);
4295 }
4296 }
4297 }
ilAccessHandler $access
sendAppraiseeNotification(int $a_user_id)
isAppraisee(int $a_user_id)
const ANONYMOUS_USER_ID
Definition: constants.php:27
checkAccessOfUser(int $a_user_id, string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)

References $ilDB, and ilRBACAccessHandler\checkAccessOfUser().

+ Here is the call graph for this function:

◆ addConstraint()

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

Adds a constraint.

Parameters
int$if_question_idquestion id of the question which defines a precondition
int$relationrelation id
float$valuevalue compared with the relation
int$conjunction
Returns
?int
Todo:
move to constraint manager/repo

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

2165 : ?int {
2166 $ilDB = $this->db;
2167
2168 $next_id = $ilDB->nextId('svy_constraint');
2169 $affectedRows = $ilDB->manipulateF(
2170 "INSERT INTO svy_constraint (constraint_id, question_fi, relation_fi, value, conjunction) VALUES " .
2171 "(%s, %s, %s, %s, %s)",
2172 array('integer','integer','integer','float', 'integer'),
2173 array($next_id, $if_question_id, $relation, $value, $conjunction)
2174 );
2175 if ($affectedRows) {
2176 return $next_id;
2177 } else {
2178 return null;
2179 }
2180 }
$relation
ilDBInterface $db

◆ addConstraintToQuestion()

ilObjSurvey::addConstraintToQuestion ( int  $to_question_id,
int  $constraint_id 
)
Todo:
move to constraint manager/repo

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

2189 : void {
2190 $ilDB = $this->db;
2191
2192 $next_id = $ilDB->nextId('svy_qst_constraint');
2193 $ilDB->manipulateF(
2194 "INSERT INTO svy_qst_constraint (question_constraint_id, survey_fi, question_fi, " .
2195 "constraint_fi) VALUES (%s, %s, %s, %s)",
2196 array('integer','integer','integer','integer'),
2197 array($next_id, $this->getSurveyId(), $to_question_id, $constraint_id)
2198 );
2199 }

◆ addMaterialTag()

ilObjSurvey::addMaterialTag ( ilXmlWriter  $a_xml_writer,
string  $a_material,
bool  $close_material_tag = true,
bool  $add_mobs = true,
?array  $attribs = null 
)

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

Todo:
move to export sub-service

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

4016 : void {
4017 $a_xml_writer->xmlStartTag("material", $attribs);
4018 $attrs = array(
4019 "type" => "text/plain"
4020 );
4021 if ($this->isHTML($a_material)) {
4022 $attrs["type"] = "text/xhtml";
4023 }
4024 $mattext = ilRTE::_replaceMediaObjectImageSrc($a_material, 0);
4025 $a_xml_writer->xmlElement("mattext", $attrs, $mattext);
4026
4027 if ($add_mobs) {
4028 $mobs = ilObjMediaObject::_getMobsOfObject("svy:html", $this->getId());
4029 foreach ($mobs as $mob) {
4030 $mob_id = "il_" . IL_INST_ID . "_mob_" . $mob;
4031 if (strpos($mattext, $mob_id) !== false) {
4032 $mob_obj = new ilObjMediaObject($mob);
4033 $imgattrs = array(
4034 "label" => $mob_id,
4035 "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle(),
4036 "type" => "svy:html",
4037 "id" => $this->getId()
4038 );
4039 $a_xml_writer->xmlElement("matimage", $imgattrs, null);
4040 }
4041 }
4042 }
4043 if ($close_material_tag) {
4044 $a_xml_writer->xmlEndTag("material");
4045 }
4046 }
static _getMobsOfObject(string $a_type, int $a_id, int|false $a_usage_hist_nr=0, string $a_lang="-")
isHTML(string $a_text)
Checks if a given string contains HTML or not.
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
const IL_INST_ID
Definition: constants.php:40

◆ addQuestion()

ilObjSurvey::addQuestion ( int  $question_id)

Adds a question to the survey (used in importer!)

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

260 : void
261 {
262 $this->questions[] = $question_id;
263 }

◆ addQuestionToBlock()

ilObjSurvey::addQuestionToBlock ( int  $question_id,
int  $questionblock_id 
)
Todo:
move to survey question manager/repo

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

1549 : void {
1550 $ilDB = $this->db;
1551
1552 // see #22018
1553 if (!$this->isQuestionInAnyBlock($question_id)) {
1554 $next_id = $ilDB->nextId('svy_qblk_qst');
1555 $affectedRows = $ilDB->manipulateF(
1556 "INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
1557 "question_fi) VALUES (%s, %s, %s, %s)",
1558 array('integer', 'integer', 'integer', 'integer'),
1559 array($next_id, $this->getSurveyId(), $questionblock_id, $question_id)
1560 );
1561
1562 $this->deleteConstraints($question_id); // #13713
1563 }
1564 }
isQuestionInAnyBlock(int $a_question_fi)
deleteConstraints(int $question_id)
Deletes the constraints for a question.

References $ilDB.

◆ addRater()

ilObjSurvey::addRater ( int  $a_appraisee_id,
int  $a_user_id,
int  $a_anonymous_id = 0 
)
Todo:
move to appraisal manager

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

4481 : void {
4482 global $DIC;
4483
4484 $ilDB = $DIC->database();
4485 $access = $DIC->access();
4486
4487 if ($this->isAppraisee($a_appraisee_id) &&
4488 !$this->isRater($a_appraisee_id, $a_user_id, $a_anonymous_id)) {
4489 $fields = array(
4490 "obj_id" => array("integer", $this->getSurveyId()),
4491 "appr_id" => array("integer", $a_appraisee_id),
4492 "user_id" => array("integer", $a_user_id),
4493 "anonymous_id" => array("integer", $a_anonymous_id)
4494 );
4495 $ilDB->insert("svy_360_rater", $fields);
4496
4497 // send notification and add to desktop
4498 if ($access->checkAccessOfUser($a_user_id, "read", "", $this->getRefId())) {
4499 // out-commented, since adding raters will end in a mail
4500 // form to send the mail "manually"
4501 // otherwise two mails would be sent (tested in individual feedback)
4502 //$this->sendRaterNotification($a_user_id, $a_appraisee_id);
4503 }
4504 }
4505 }
isRater(int $a_appraisee_id, int $a_user_id, int $a_anonymous_id=0)

References $ilDB, and ilRBACAccessHandler\checkAccessOfUser().

+ Here is the call graph for this function:

◆ canExportSurveyCode()

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
bool true if the survey is anonymized and the survey code may be shown in the export file
Todo:
move to code manager

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

4055 : bool
4056 {
4057 if ($this->getAnonymize() !== self::ANONYMIZE_OFF) {
4058 if ($this->surveyCodeSecurity === false) {
4059 return true;
4060 }
4061 }
4062 return false;
4063 }

◆ checkConstraint()

ilObjSurvey::checkConstraint ( array  $constraint_data,
?array  $working_data 
)

Checks if a constraint is valid.

Parameters
array$constraint_dataconstraint data
?array$working_data user input of the related question
Returns
bool true if the constraint is valid, otherwise false
Todo:
move to run/constraint manager

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

2576 : bool {
2577 if (!is_array($working_data) || count($working_data) === 0) {
2578 return 0;
2579 }
2580
2581 if ((count($working_data) === 1) and (strcmp($working_data[0]["value"], "") === 0)) {
2582 return 0;
2583 }
2584
2585 $found = false;
2586 foreach ($working_data as $data) {
2587 switch ($constraint_data["short"]) {
2588 case "<":
2589 if ($data["value"] < $constraint_data["value"]) {
2590 $found = true;
2591 }
2592 break;
2593
2594 case "<=":
2595 if ($data["value"] <= $constraint_data["value"]) {
2596 $found = true;
2597 }
2598 break;
2599
2600 case "=":
2601 if ($data["value"] == $constraint_data["value"]) {
2602 $found = true;
2603 }
2604 break;
2605
2606 case "<>":
2607 if ($data["value"] <> $constraint_data["value"]) {
2608 $found = true;
2609 }
2610 break;
2611
2612 case ">=":
2613 if ($data["value"] >= $constraint_data["value"]) {
2614 $found = true;
2615 }
2616 break;
2617
2618 case ">":
2619 if ($data["value"] > $constraint_data["value"]) {
2620 $found = true;
2621 }
2622 break;
2623 }
2624 if ($found) {
2625 break;
2626 }
2627 }
2628
2629 return (int) $found;
2630 }

◆ checkReminder()

ilObjSurvey::checkReminder ( )

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

5315 : ?int
5316 {
5317 $ilDB = $this->db;
5318 $ilAccess = $this->access;
5319
5320 $now = time();
5321 $now_with_format = date("YmdHis", $now);
5322 $today = date("Y-m-d");
5323
5324 $this->svy_log->debug("Check status and dates.");
5325
5326 // object settings / participation period
5327 if (
5328 $this->getOfflineStatus() ||
5329 !$this->getReminderStatus() ||
5330 ($this->getStartDate() && $now_with_format < $this->getStartDate()) ||
5331 ($this->getEndDate() && $now_with_format > $this->getEndDate())) {
5332 return null;
5333 }
5334
5335 // reminder period
5336 $start = $this->getReminderStart();
5337 if ($start) {
5338 $start = $start->get(IL_CAL_DATE);
5339 }
5340 $end = $this->getReminderEnd();
5341 if ($end) {
5342 $end = $end->get(IL_CAL_DATE);
5343 }
5344 if ($today < $start ||
5345 ($end && $today > $end)) {
5346 return null;
5347 }
5348
5349 $this->svy_log->debug("Check access period.");
5350
5351 // object access period
5352 $item_data = ilObjectActivation::getItem($this->getRefId());
5353 if ((int) $item_data["timing_type"] === ilObjectActivation::TIMINGS_ACTIVATION &&
5354 ($now < $item_data["timing_start"] ||
5355 $now > $item_data["timing_end"])) {
5356 return null;
5357 }
5358
5359 $this->svy_log->debug("Check frequency.");
5360
5361 // check frequency
5362 $cut = new ilDate($today, IL_CAL_DATE);
5363 $cut->increment(IL_CAL_DAY, $this->getReminderFrequency() * -1);
5364 if (!$this->getReminderLastSent() ||
5365 $cut->get(IL_CAL_DATE) >= substr($this->getReminderLastSent(), 0, 10)) {
5366 $missing_ids = array();
5367 if (!$this->feature_config->usesAppraisees()) {
5368 $this->svy_log->debug("Entering survey mode.");
5369
5370 // #16871
5371 $user_ids = $this->getNotificationTargetUserIds(($this->getReminderTarget() === self::NOTIFICATION_INVITED_USERS));
5372 if ($user_ids) {
5373 // gather participants who already finished
5374 $finished_ids = array();
5375 $set = $ilDB->query("SELECT user_fi FROM svy_finished" .
5376 " WHERE survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer") .
5377 " AND state = " . $ilDB->quote(1, "text") .
5378 " AND " . $ilDB->in("user_fi", $user_ids, "", "integer"));
5379 while ($row = $ilDB->fetchAssoc($set)) {
5380 $finished_ids[] = $row["user_fi"];
5381 }
5382
5383 // some users missing out?
5384 $missing_ids = array_diff($user_ids, $finished_ids);
5385 if ($missing_ids) {
5386 foreach ($missing_ids as $idx => $user_id) {
5387 // should be able to participate
5388 if (!$ilAccess->checkAccessOfUser($user_id, "read", "", $this->getRefId(), "svy", $this->getId())) {
5389 unset($missing_ids[$idx]);
5390 }
5391 }
5392 }
5393 if ($missing_ids) {
5394 $this->sentReminder($missing_ids);
5395 }
5396 }
5397 } else {
5398 $this->svy_log->debug("Entering 360 mode.");
5399
5400 $this->sent360Reminders();
5401 }
5402
5403
5404 $this->setReminderLastSent($today);
5405 $this->saveToDb();
5406
5407 return count($missing_ids);
5408 }
5409
5410 return null;
5411 }
const IL_CAL_DATE
const IL_CAL_DAY
Class for single dates.
setReminderLastSent(?string $a_value)
getNotificationTargetUserIds(bool $a_use_invited)
These users must finish the survey to trigger the tutor notification "all users finished the survey" ...
sent360Reminders()
Send 360 reminders.
static getItem(int $ref_id)

References $ilDB, $user_id, ilObjectActivation\getItem(), IL_CAL_DATE, IL_CAL_DAY, and ilObjectActivation\TIMINGS_ACTIVATION.

+ Here is the call graph for this function:

◆ checkTutorNotification()

ilObjSurvey::checkTutorNotification ( )
protected

Check, if mail to tutors after all participants have finished the survey should be sent.

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

5123 : void
5124 {
5125 $ilDB = $this->db;
5126
5127 if ($this->getTutorNotificationStatus()) {
5128 // get target users, either parent course/group members or
5129 // user with the survey on the dashboard
5130 $user_ids = $this->getNotificationTargetUserIds(($this->getTutorNotificationTarget() === self::NOTIFICATION_INVITED_USERS));
5131 if ($user_ids) {
5132 $set = $ilDB->query("SELECT COUNT(*) numall FROM svy_finished" .
5133 " WHERE survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer") .
5134 " AND state = " . $ilDB->quote(1, "integer") .
5135 " AND " . $ilDB->in("user_fi", $user_ids, "", "integer"));
5136 $row = $ilDB->fetchAssoc($set);
5137
5138 // all users finished the survey -> send notifications
5139 if ((int) $row["numall"] === count($user_ids)) {
5140 $this->sendTutorNotification();
5141 }
5142 }
5143 }
5144 }
getTutorNotificationTarget()
Group that is checked for the "all participants have finished" mail Either a) all members of a parent...
sendTutorNotification()
Send mail to tutors after all participants have finished the survey.

References $ilDB.

◆ cloneTextblocks()

ilObjSurvey::cloneTextblocks ( array  $mapping)

Clones the text blocks of survey questions.

Todo:
move to survey question manager
Parameters
array<int,int>$mapping (key is original, value is new id)

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

3431 : void {
3432 foreach ($mapping as $original_id => $new_id) {
3433 $textblock = $this->getTextblock($original_id);
3434 $this->saveHeading(ilUtil::stripSlashes($textblock, true, ilRTESettings::_getUsedHTMLTagsAsString("survey")), $new_id);
3435 }
3436 }
getTextblock(int $question_id)
saveHeading(string $heading, int $insertbefore)
static _getUsedHTMLTagsAsString(string $module='')
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")

References ilRTESettings\_getUsedHTMLTagsAsString(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ closeAppraisee()

ilObjSurvey::closeAppraisee ( int  $a_user_id)
Todo:
move to appraisal/run manager/mode

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

4886 : void {
4887 global $DIC;
4888
4889 $ilDB = $DIC->database();
4890 $user = $DIC->user();
4891
4892 // close the appraisee
4893 $ilDB->manipulate("UPDATE svy_360_appr" .
4894 " SET has_closed = " . $ilDB->quote(time(), "integer") .
4895 " WHERE obj_id = " . $ilDB->quote($this->getSurveyId(), "integer") .
4896 " AND user_id = " . $ilDB->quote($a_user_id, "integer"));
4897
4898 // write competences
4899 $skmg_set = new ilSkillManagementSettings();
4900 if ($this->getSkillService() && $skmg_set->isActivated()) {
4901 $sskill = new ilSurveySkill($this);
4902 $sskill->writeAndAddAppraiseeSkills($a_user_id);
4903 }
4904
4905 // send notification
4906 if ($user->getId() !== $a_user_id) {
4907 $this->sendAppraiseeCloseNotification($a_user_id);
4908 }
4909 }
sendAppraiseeCloseNotification(int $a_user_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ create()

ilObjSurvey::create (   $a_upload = false)

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

212 : int
213 {
214 $id = parent::create();
215 if (!$a_upload) {
216 $this->createMetaData();
217 }
218 $this->setOfflineStatus(true);
219 $this->update($a_upload);
220 return $id;
221 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
setOfflineStatus(bool $status)

References $id, ilObject\createMetaData(), ilObject\setOfflineStatus(), and ilObject\update().

+ Here is the call graph for this function:

◆ createExportDirectory()

ilObjSurvey::createExportDirectory ( )

creates data directory for export files (data_dir/svy_data/svy_<id>/export)

Todo:
move to export sub-service
Exceptions
ilSurveyException

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

3444 : void
3445 {
3446 $svy_data_dir = ilFileUtils::getDataDir() . "/svy_data";
3447 ilFileUtils::makeDir($svy_data_dir);
3448 if (!is_writable($svy_data_dir)) {
3449 throw new ilSurveyException("Survey Data Directory (" . $svy_data_dir . ") not writeable.");
3450 }
3451
3452 // create learning module directory (data_dir/lm_data/lm_<id>)
3453 $svy_dir = $svy_data_dir . "/svy_" . $this->getId();
3454 ilFileUtils::makeDir($svy_dir);
3455 if (!is_dir($svy_dir)) {
3456 throw new ilSurveyException("Creation of Survey Directory failed.");
3457 }
3458 // create Export subdirectory (data_dir/lm_data/lm_<id>/Export)
3459 $export_dir = $svy_dir . "/export";
3460 ilFileUtils::makeDir($export_dir);
3461 if (!is_dir($export_dir)) {
3462 throw new ilSurveyException("Creation of Export Directory failed.");
3463 }
3464 }
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getDataDir()
get data directory (outside webspace)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ilFileUtils\getDataDir(), ILIAS\Survey\Mode\getId(), and ilFileUtils\makeDir().

+ Here is the call graph for this function:

◆ createImportDirectory()

ilObjSurvey::createImportDirectory ( )

creates data directory for import files (data_dir/svy_data/svy_<id>/import)

Todo:
move to export sub-service
Exceptions
ilSurveyException

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

3482 : void
3483 {
3484 $svy_data_dir = ilFileUtils::getDataDir() . "/svy_data";
3485 ilFileUtils::makeDir($svy_data_dir);
3486
3487 if (!is_writable($svy_data_dir)) {
3488 throw new ilSurveyException("Survey Data Directory (" . $svy_data_dir . ") not writeable.");
3489 }
3490
3491 // create test directory (data_dir/svy_data/svy_<id>)
3492 $svy_dir = $svy_data_dir . "/svy_" . $this->getId();
3493 ilFileUtils::makeDir($svy_dir);
3494 if (!is_dir($svy_dir)) {
3495 throw new ilSurveyException("Creation of Survey Directory failed.");
3496 }
3497
3498 // create import subdirectory (data_dir/svy_data/svy_<id>/import)
3499 $import_dir = $svy_dir . "/import";
3500 ilFileUtils::makeDir($import_dir);
3501 if (!is_dir($import_dir)) {
3502 throw new ilSurveyException("Creation of Import Directory failed.");
3503 }
3504 }

References ilFileUtils\getDataDir(), ILIAS\Survey\Mode\getId(), and ilFileUtils\makeDir().

+ Here is the call graph for this function:

◆ createQuestionblock()

ilObjSurvey::createQuestionblock ( string  $title,
bool  $show_questiontext,
bool  $show_blocktitle,
array  $questions,
bool  $compress_view = false 
)
Parameters
int[]$questionsarray with question ids

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

1703 : void {
1704 $ilDB = $this->db;
1705
1706 // if the selected questions are not in a continous selection, move all questions of the
1707 // questionblock at the position of the first selected question
1708 $this->moveQuestions($questions, $questions[0], 0);
1709
1710 // now save the question block
1711 $ilUser = $this->user;
1712 $next_id = $ilDB->nextId('svy_qblk');
1713 $affectedRows = $ilDB->manipulateF(
1714 "INSERT INTO svy_qblk (questionblock_id, title, show_questiontext," .
1715 " show_blocktitle, owner_fi, tstamp, compress_view) VALUES (%s, %s, %s, %s, %s, %s, %s)",
1716 array('integer','text','text','text','integer','integer','integer'),
1717 array($next_id, $title, $show_questiontext, $show_blocktitle, $ilUser->getId(), time(), $compress_view)
1718 );
1719 if ($affectedRows) {
1720 $questionblock_id = $next_id;
1721 foreach ($questions as $index) {
1722 if (!$this->isQuestionInAnyBlock($index)) {
1723 $next_id = $ilDB->nextId('svy_qblk_qst'); // #22018
1724 $affectedRows = $ilDB->manipulateF(
1725 "INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
1726 "question_fi) VALUES (%s, %s, %s, %s)",
1727 array('integer', 'integer', 'integer', 'integer'),
1728 array($next_id, $this->getSurveyId(), $questionblock_id, $index)
1729 );
1730 $this->deleteConstraints($index);
1731 }
1732 }
1733 }
1734 }
moveQuestions(array $move_questions, int $target_index, int $insert_mode)
Move questions and/or questionblocks to another position.

◆ createReference()

ilObjSurvey::createReference ( )

creates reference for object

Reimplemented from ilObject.

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

243 : int
244 {
245 $result = parent::createReference();
246 $this->saveToDb();
247 return $result;
248 }

References saveToDb().

+ Here is the call graph for this function:

◆ delete()

ilObjSurvey::delete ( )

delete object or referenced object (in the case of a referenced object, object data is only deleted if last reference is deleted) This function removes an object entirely from system!!

Returns
bool true if object was removed completely; false if only a references was removed

Reimplemented from ilObject.

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

265 : bool
266 {
267 $this->svy_log->debug("Deleting Survey, ref id: " . $this->getRefId() . ", obj id: " .
268 $this->getId() . ", title: " . $this->getTitle());
269 $this->svy_log->debug("References: " . $this->countReferences());
270 if ($this->countReferences() === 1) {
271 $this->deleteMetaData();
272
273 // Delete all survey questions, constraints and materials
274 foreach ($this->questions as $question_id) {
275 $this->svy_log->debug("Remove question " . $question_id);
276 $this->removeQuestion($question_id);
277 }
278 $this->deleteSurveyRecord();
279
281 }
282
283 $this->svy_log->debug("Call parent delete.");
284 $remove = parent::delete();
285
286 // always call parent delete function first!!
287 if (!$remove) {
288 return false;
289 }
290 return true;
291 }
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
removeQuestion(int $question_id)
getImportDirectory()
get import directory of survey
deleteSurveyRecord()
Deletes the survey from the database.

References ilObject\countReferences(), ilFileUtils\delDir(), ilObject\deleteMetaData(), deleteSurveyRecord(), ilObject\getId(), getImportDirectory(), ilObject\getRefId(), ilObject\getTitle(), and removeQuestion().

+ Here is the call graph for this function:

◆ deleteAllUserData()

ilObjSurvey::deleteAllUserData ( bool  $reset_LP = true)

Deletes all user data of a survey.

Parameters
bool$reset_LPnotice that the LP can only be reset it the determining components still exist
Todo:
move to run manager/repo

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

356 : void {
358
359 $result = $ilDB->queryF(
360 "SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
361 array('integer'),
362 array($this->getSurveyId())
363 );
364 $active_array = array();
365 while ($row = $ilDB->fetchAssoc($result)) {
366 $active_array[] = $row["finished_id"];
367 }
368
369 $affectedRows = $ilDB->manipulateF(
370 "DELETE FROM svy_finished WHERE survey_fi = %s",
371 array('integer'),
372 array($this->getSurveyId())
373 );
374
375 foreach ($active_array as $active_fi) {
376 $affectedRows = $ilDB->manipulateF(
377 "DELETE FROM svy_answer WHERE active_fi = %s",
378 array('integer'),
379 array($active_fi)
380 );
381 $affectedRows = $ilDB->manipulateF(
382 "DELETE FROM svy_times WHERE finished_fi = %s",
383 array('integer'),
384 array($active_fi)
385 );
386 }
387
388 if ($reset_LP) {
389 $lp_obj = ilObjectLP::getInstance($this->getId());
390 $lp_obj->resetLPDataForCompleteObject();
391 }
392
393 $this->invitation_manager->removeAll($this->getSurveyId());
394 }
static getInstance(int $obj_id)

Referenced by deleteSurveyRecord().

+ Here is the caller graph for this function:

◆ deleteAppraisee()

ilObjSurvey::deleteAppraisee ( int  $a_user_id)
Todo:
move to appraisal manager

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

4423 : void {
4424 $ilDB = $this->db;
4425
4426 $ilDB->manipulate("DELETE FROM svy_360_appr" .
4427 " WHERE obj_id = " . $ilDB->quote($this->getSurveyId(), "integer") .
4428 " AND user_id = " . $ilDB->quote($a_user_id, "integer"));
4429
4430 $set = $ilDB->query("SELECT user_id" .
4431 " FROM svy_360_rater" .
4432 " WHERE obj_id = " . $ilDB->quote($this->getSurveyId(), "integer") .
4433 " AND appr_id = " . $ilDB->quote($a_user_id, "integer"));
4434 while ($row = $ilDB->fetchAssoc($set)) {
4435 $this->deleteRater($a_user_id, $row["user_id"]);
4436 }
4437 // appraisee will not be part of raters table
4438 if ($this->get360SelfEvaluation()) {
4439 $this->deleteRater($a_user_id, $a_user_id);
4440 }
4441 }
deleteRater(int $a_appraisee_id, int $a_user_id, int $a_anonymous_id=0)

◆ deleteConstraint()

ilObjSurvey::deleteConstraint ( int  $constraint_id)

Deletes a single constraint.

Todo:
move to constraint manager/repo

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

1783 : void {
1784 $ilDB = $this->db;
1785 $affectedRows = $ilDB->manipulateF(
1786 "DELETE FROM svy_constraint WHERE constraint_id = %s",
1787 array('integer'),
1788 array($constraint_id)
1789 );
1790 $affectedRows = $ilDB->manipulateF(
1791 "DELETE FROM svy_qst_constraint WHERE constraint_fi = %s",
1792 array('integer'),
1793 array($constraint_id)
1794 );
1795 }

◆ deleteConstraints()

ilObjSurvey::deleteConstraints ( int  $question_id)

Deletes the constraints for a question.

Todo:
move to constraint manager/repo

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

1761 : void {
1762 $ilDB = $this->db;
1763 $result = $ilDB->queryF(
1764 "SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
1765 array('integer','integer'),
1766 array($question_id, $this->getSurveyId())
1767 );
1768 $constraints = array();
1769 while ($row = $ilDB->fetchAssoc($result)) {
1770 $constraints[] = $row["constraint_fi"];
1771 }
1772 foreach ($constraints as $constraint_id) {
1773 $this->deleteConstraint($constraint_id);
1774 }
1775 }
deleteConstraint(int $constraint_id)
Deletes a single constraint.

◆ deleteRater()

ilObjSurvey::deleteRater ( int  $a_appraisee_id,
int  $a_user_id,
int  $a_anonymous_id = 0 
)
Todo:
move to appraisal manager

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

4545 : void {
4546 $ilDB = $this->db;
4547
4548 $finished_id = $this->getFinishedIdForAppraiseeIdAndRaterId($a_appraisee_id, $a_user_id);
4549 if ($finished_id) {
4550 $this->removeSelectedSurveyResults(array($finished_id));
4551 }
4552
4553 $ilDB->manipulate("DELETE FROM svy_360_rater" .
4554 " WHERE obj_id = " . $ilDB->quote($this->getSurveyId(), "integer") .
4555 " AND appr_id = " . $ilDB->quote($a_appraisee_id, "integer") .
4556 " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
4557 " AND anonymous_id = " . $ilDB->quote($a_anonymous_id, "integer"));
4558 }
getFinishedIdForAppraiseeIdAndRaterId(int $a_appr_id, int $a_rat_id)
Get finished id for an appraisee and a rater.
removeSelectedSurveyResults(array $finished_ids)
Deletes the user data of a given array of survey participants.

◆ deleteSurveyCode()

ilObjSurvey::deleteSurveyCode ( string  $survey_code)
Todo:
move to code manager

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

3895 : void {
3896 $ilDB = $this->db;
3897
3898 if ($survey_code !== '') {
3899 $affectedRows = $ilDB->manipulateF(
3900 "DELETE FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
3901 array('integer', 'text'),
3902 array($this->getSurveyId(), $survey_code)
3903 );
3904 }
3905 }

References $ilDB.

◆ deleteSurveyRecord()

ilObjSurvey::deleteSurveyRecord ( )

Deletes the survey from the database.

Todo:
move to survey manager/repo

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

297 : void
298 {
300
301 $ilDB->manipulateF(
302 "DELETE FROM svy_svy WHERE survey_id = %s",
303 array('integer'),
304 array($this->getSurveyId())
305 );
306
307 $result = $ilDB->queryF(
308 "SELECT questionblock_fi FROM svy_qblk_qst WHERE survey_fi = %s",
309 array('integer'),
310 array($this->getSurveyId())
311 );
312 $questionblocks = array();
313 while ($row = $ilDB->fetchAssoc($result)) {
314 $questionblocks[] = $row["questionblock_fi"];
315 }
316 if (count($questionblocks)) {
317 $affectedRows = $ilDB->manipulate("DELETE FROM svy_qblk WHERE " . $ilDB->in('questionblock_id', $questionblocks, false, 'integer'));
318 }
319 $ilDB->manipulateF(
320 "DELETE FROM svy_qblk_qst WHERE survey_fi = %s",
321 array('integer'),
322 array($this->getSurveyId())
323 );
324 $this->deleteAllUserData(false);
325
326 if (isset($this->code_manager)) {
327 $this->code_manager->deleteAll(true);
328 }
329
330 // delete export files
331 $svy_data_dir = ilFileUtils::getDataDir() . "/svy_data";
332 $directory = $svy_data_dir . "/svy_" . $this->getId();
333 if (is_dir($directory)) {
334 ilFileUtils::delDir($directory);
335 }
336
337 $mobs = ilObjMediaObject::_getMobsOfObject("svy:html", $this->getId());
338 // remaining usages are not in text anymore -> delete them
339 // and media objects (note: delete method of ilObjMediaObject
340 // checks whether object is used in another context; if yes,
341 // the object is not deleted!)
342 foreach ($mobs as $mob) {
343 ilObjMediaObject::_removeUsage($mob, "svy:html", $this->getId());
344 $mob_obj = new ilObjMediaObject($mob);
345 $mob_obj->delete();
346 }
347 }
static _removeUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Remove usage of mob in another container.
deleteAllUserData(bool $reset_LP=true)
Deletes all user data of a survey.

References ilObject\$db, $ilDB, ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), ilFileUtils\delDir(), deleteAllUserData(), ilFileUtils\getDataDir(), ilObject\getId(), and getSurveyId().

Referenced by delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteUserSettings()

ilObjSurvey::deleteUserSettings ( int  $id)

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

664 : void {
666
667 $ilDB->manipulateF(
668 "DELETE FROM svy_settings WHERE settings_id = %s",
669 array('integer'),
670 array($id)
671 );
672 }

◆ deleteWorkingData()

ilObjSurvey::deleteWorkingData ( int  $question_id,
int  $active_id 
)

Deletes the working data of a question in the database.

Todo:
move to run(?) manager/repo

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

2278 : void {
2279 $ilDB = $this->db;
2280
2281 $affectedRows = $ilDB->manipulateF(
2282 "DELETE FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
2283 array('integer','integer'),
2284 array($question_id, $active_id)
2285 );
2286 }

◆ doCreateMetaData()

ilObjSurvey::doCreateMetaData ( )
protected

Reimplemented from ilObject.

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

223 : void
224 {
225 $this->saveAuthorToMetadata();
226 }
saveAuthorToMetadata(string $a_author="")
Saves an authors name into the lifecycle metadata if no lifecycle metadata exists This will only be c...

References saveAuthorToMetadata().

+ Here is the call graph for this function:

◆ duplicateQuestionForSurvey()

ilObjSurvey::duplicateQuestionForSurvey ( int  $question_id,
bool  $a_force = false 
)

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

Todo:
move to survey question manager/repo

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

533 : int {
534 $questiontype = $this->getQuestionType($question_id);
535 $question_gui = $this->getQuestionGUI($questiontype, $question_id);
536
537 // check if question is a pool question at all, if not do nothing
538 if ($this->getId() === $question_gui->object->getObjId() && !$a_force) {
539 return $question_id;
540 }
541
542 $duplicate_id = $question_gui->object->duplicate(true, "", "", 0, $this->getId());
543 return $duplicate_id;
544 }
getQuestionType(int $question_id)
getQuestionGUI(string $questiontype, int $question_id)

◆ findCodeForUser()

ilObjSurvey::findCodeForUser ( int  $a_user_id)
Todo:
move to code manager

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

4766 : string {
4767 $ilDB = $this->db;
4768
4769 if ($a_user_id !== ANONYMOUS_USER_ID) {
4770 $set = $ilDB->query("SELECT sf.anonymous_id FROM svy_finished sf" .
4771 " WHERE sf.survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer") .
4772 " AND sf.user_fi = " . $ilDB->quote($a_user_id, "integer"));
4773 $a_code = $ilDB->fetchAssoc($set);
4774 return (string) ($a_code["anonymous_id"] ?? "");
4775 }
4776 return "";
4777 }

References $ilDB.

◆ finishSurvey()

ilObjSurvey::finishSurvey ( int  $finished_id,
int  $appr_id = 0 
)

Finishes the survey creating an entry in the database.

Todo:
move to run manager

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

2318 : void {
2319 $ilDB = $this->db;
2320
2321 $ilDB->manipulateF(
2322 "UPDATE svy_finished SET state = %s, tstamp = %s" .
2323 " WHERE survey_fi = %s AND finished_id = %s",
2324 array('text','integer','integer','integer'),
2325 array(1, time(), $this->getSurveyId(), $finished_id)
2326 );
2327
2328 // self eval writes skills on finishing
2329 if ($this->getMode() === self::MODE_SELF_EVAL) {
2330 $user = $this->getUserDataFromActiveId($finished_id);
2331 $sskill = new ilSurveySkill($this);
2332 $sskill->writeAndAddSelfEvalSkills($user['usr_id']);
2333 }
2334
2335 // self eval writes skills on finishing
2336 if ($this->getMode() === self::MODE_IND_FEEDB) {
2337 // we use a rater id like "a27" for anonymous or
2338 // "123" for non anonymous user
2339 // @todo: move this e.g. to participant manager
2340 $raters = $this->getRatersData($appr_id);
2341 $run_manager = $this->survey_service
2342 ->domain()
2343 ->execution()
2344 ->run($this, $this->user->getId(), $appr_id);
2345 $run = $run_manager->getById($finished_id);
2346 $rater_id = "";
2347 if ($run->getUserId() !== 0 && $run->getUserId() !== ANONYMOUS_USER_ID) {
2348 $rater_id = $run->getUserId();
2349 } else {
2350 foreach ($raters as $id => $rater) {
2351 if (($rater["code"] ?? "") === $run->getCode()) {
2352 $rater_id = $id;
2353 }
2354 }
2355 }
2356 $sskill = new ilSurveySkill($this);
2357 //$sskill->writeAndAddSelfEvalSkills($user['usr_id']);
2358 $sskill->writeAndAddIndFeedbackSkills($finished_id, $appr_id, $rater_id);
2359 }
2360
2361 $this->checkTutorNotification();
2362 }
getUserDataFromActiveId(int $active_id, bool $force_non_anonymous=false)
Returns run information.
checkTutorNotification()
Check, if mail to tutors after all participants have finished the survey should be sent.
getRatersData(int $a_appraisee_id)

◆ fixSequenceStructure()

ilObjSurvey::fixSequenceStructure ( )

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

1073 : void
1074 {
1075 global $DIC;
1076
1077 $ilDB = $DIC->database();
1078 //return;
1079 // we keep all survey question ids with their lowest sequence
1080 $result = $ilDB->queryF(
1081 "SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
1082 array('integer'),
1083 array($this->getSurveyId())
1084 );
1085
1086 // step 1: find duplicates -> $to_delete_ids
1087 $fis = array();
1088 $to_delete_ids = array();
1089 while ($data = $ilDB->fetchAssoc($result)) {
1090 if (in_array($data["question_fi"], $fis)) { // found a duplicate
1091 $to_delete_ids[] = $data["survey_question_id"];
1092 } else {
1093 $fis[] = $data["question_fi"];
1094 }
1095 }
1096
1097 // step 2: we delete the duplicates
1098 if (count($to_delete_ids) > 0) {
1099 $ilDB->manipulate($q = "DELETE FROM svy_svy_qst" .
1100 " WHERE " . $ilDB->in("survey_question_id", $to_delete_ids, false, "integer") .
1101 " AND survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer"));
1102 $this->svy_log->debug("delete: " . $q);
1103
1104 $ilDB->manipulate($q = "DELETE FROM svy_qblk_qst " .
1105 " WHERE " . $ilDB->in("question_fi", $fis, true, "integer") .
1106 " AND survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer"));
1107 $this->svy_log->debug("delete: " . $q);
1108 }
1109
1110 // step 3: we fix the sequence
1111 $set = $ilDB->query("SELECT * FROM svy_svy_qst " .
1112 " WHERE survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer") . " ORDER BY sequence");
1113 $seq = 0;
1114 while ($rec = $ilDB->fetchAssoc($set)) {
1115 $ilDB->manipulate(
1116 $q = "UPDATE svy_svy_qst SET " .
1117 " sequence = " . $ilDB->quote($seq++, "integer") .
1118 " WHERE survey_question_id = " . $ilDB->quote($rec["survey_question_id"], "integer")
1119 );
1120 $this->svy_log->debug("update: " . $q);
1121 }
1122 }
$q
Definition: shib_logout.php:25

References $data, $DIC, $ilDB, and $q.

◆ get360Mode()

ilObjSurvey::get360Mode ( )

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

4225 : bool
4226 {
4227 if ($this->getMode() === self::MODE_360) {
4228 return true;
4229 }
4230 return false;
4231 }

Referenced by ILIAS\Survey\Evaluation\EvaluationManager\getSelectableAppraisees().

+ Here is the caller graph for this function:

◆ get360Results()

ilObjSurvey::get360Results ( )

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

4268 : int
4269 {
4271 }

Referenced by ILIAS\Survey\Evaluation\EvaluationManager\isMultiParticipantsView().

+ Here is the caller graph for this function:

◆ get360SelfAppraisee()

ilObjSurvey::get360SelfAppraisee ( )

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

4248 : bool
4249 {
4251 }

Referenced by ILIAS\Survey\Participants\StatusManager\canAddItselfAsAppraisee().

+ Here is the caller graph for this function:

◆ get360SelfEvaluation()

ilObjSurvey::get360SelfEvaluation ( )

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

4238 : bool
4239 {
4241 }

◆ get360SelfRaters()

ilObjSurvey::get360SelfRaters ( )

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

4258 : bool
4259 {
4261 }

◆ getActivationEndDate()

ilObjSurvey::getActivationEndDate ( )

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

5486 : ?int
5487 {
5489 }

◆ getActivationStartDate()

ilObjSurvey::getActivationStartDate ( )

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

5481 : ?int
5482 {
5484 }

◆ getActivationVisibility()

ilObjSurvey::getActivationVisibility ( )

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

1302 : bool
1303 {
1305 }

◆ getActiveID()

ilObjSurvey::getActiveID ( int  $user_id,
string  $anonymize_id,
int  $appr_id 
)

Get run id.

Todo:
move to run manager/repo

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

2517 : ?int {
2518 $ilDB = $this->db;
2519 // #15031 - should not matter if code was used by registered or anonymous (each code must be unique)
2520 if ($anonymize_id) {
2521 $result = $ilDB->queryF(
2522 "SELECT finished_id FROM svy_finished" .
2523 " WHERE survey_fi = %s AND anonymous_id = %s AND appr_id = %s",
2524 array('integer','text','integer'),
2525 array($this->getSurveyId(), $anonymize_id, $appr_id)
2526 );
2527 } else {
2528 if ($user_id == ANONYMOUS_USER_ID) {
2529 return null;
2530 }
2531 $result = $ilDB->queryF(
2532 "SELECT finished_id FROM svy_finished" .
2533 " WHERE survey_fi = %s AND user_fi = %s AND appr_id = %s",
2534 array('integer','integer','integer'),
2535 array($this->getSurveyId(), $user_id, $appr_id)
2536 );
2537 }
2538 if ($result->numRows() === 0) {
2539 return null;
2540 } else {
2541 $row = $ilDB->fetchAssoc($result);
2542 return (int) $row["finished_id"];
2543 }
2544 }

References $ilDB.

◆ getAllRelations()

ilObjSurvey::getAllRelations ( bool  $short_as_key = false)
Todo:
move to constraint manager/repo

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

2243 : array {
2244 $ilDB = $this->db;
2245
2246 // #7987
2247 $custom_order = array("equal", "not_equal", "less", "less_or_equal", "more", "more_or_equal");
2248 $custom_order = array_flip($custom_order);
2249
2250 $result_array = array();
2251 $result = $ilDB->query("SELECT * FROM svy_relation");
2252 while ($row = $ilDB->fetchAssoc($result)) {
2253 if ($short_as_key) {
2254 $result_array[$row["shortname"]] = array("short" => $row["shortname"], "long" => $row["longname"], "id" => $row["relation_id"], "order" => $custom_order[$row["longname"]]);
2255 } else {
2256 $result_array[$row["relation_id"]] = array("short" => $row["shortname"], "long" => $row["longname"], "order" => $custom_order[$row["longname"]]);
2257 }
2258 }
2259
2260 $result_array = ilArrayUtil::sortArray($result_array, "order", "ASC", true, true);
2261 foreach ($result_array as $idx => $item) {
2262 unset($result_array[$idx]["order"]);
2263 }
2264
2265 return $result_array;
2266 }
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)

◆ getAnonymize()

ilObjSurvey::getAnonymize ( )

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

950 : int
951 {
952 return $this->anonymize;
953 }

◆ getAnonymousIdByCode()

ilObjSurvey::getAnonymousIdByCode ( string  $a_code)
Todo:
move to code manager

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

4656 : ?int {
4657 $ilDB = $this->db;
4658 $set = $ilDB->query("SELECT anonymous_id FROM svy_anonymous" .
4659 " WHERE survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer") .
4660 " AND survey_key = " . $ilDB->quote($a_code, "text"));
4661 $res = $ilDB->fetchAssoc($set);
4662 return $res["anonymous_id"] ?? null;
4663 }
$res
Definition: ltiservices.php:69

Referenced by ILIAS\Survey\Participants\StatusManager\isExternalRater().

+ Here is the caller graph for this function:

◆ getAppraiseesData()

ilObjSurvey::getAppraiseesData ( )
Todo:
move to appraisal manager, use dto

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

4446 : array
4447 {
4448 $ilDB = $this->db;
4449
4450 $res = array();
4451
4452 $set = $ilDB->query("SELECT * FROM svy_360_appr" .
4453 " WHERE obj_id = " . $ilDB->quote($this->getSurveyId(), "integer"));
4454 while ($row = $ilDB->fetchAssoc($set)) {
4455 $name = ilObjUser::_lookupName($row["user_id"]);
4456 $name["email"] = ilObjUser::_lookupEmail($row["user_id"]);
4457 $name["name"] = $name["lastname"] . ", " . $name["firstname"];
4458 $res[$row["user_id"]] = $name;
4459
4460 $finished = 0;
4461 $raters = $this->getRatersData($row["user_id"]);
4462 foreach ($raters as $rater) {
4463 if ($rater["finished"]) {
4464 $finished++;
4465 }
4466 }
4467 $res[$row["user_id"]]["finished"] = $finished . "/" . count($raters);
4468 $res[$row["user_id"]]["closed"] = $row["has_closed"];
4469 }
4470
4471 return $res;
4472 }
static _lookupName(int $a_user_id)
static _lookupEmail(int $a_user_id)

References $ilDB, $res, ilObjUser\_lookupEmail(), and ilObjUser\_lookupName().

Referenced by ILIAS\Survey\Evaluation\EvaluationManager\getSelectableAppraisees().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAppraiseesToRate()

ilObjSurvey::getAppraiseesToRate ( ?int  $a_user_id,
?int  $a_anonymous_id = null 
)
Todo:
move to appraisal manager
Returns
int[]

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

4622 : array {
4623 $ilDB = $this->db;
4624
4625 $res = array();
4626
4627 $sql = "SELECT appr_id FROM svy_360_rater" .
4628 " WHERE obj_id = " . $ilDB->quote($this->getSurveyId(), "integer");
4629
4630 if ($a_user_id) {
4631 $sql .= " AND user_id = " . $ilDB->quote($a_user_id, "integer");
4632 } else {
4633 $sql .= " AND anonymous_id = " . $ilDB->quote($a_anonymous_id, "integer");
4634 }
4635
4636 $set = $ilDB->query($sql);
4637 while ($row = $ilDB->fetchAssoc($set)) {
4638 $res[] = (int) $row["appr_id"];
4639 }
4640
4641 // user may evaluate himself if already appraisee
4642 if ($this->get360SelfEvaluation() &&
4643 $this->isAppraisee((int) $a_user_id) &&
4644 !in_array($a_user_id, $res)) {
4645 $res[] = $a_user_id;
4646 }
4647
4648 return $res;
4649 }

Referenced by ILIAS\Survey\Participants\StatusManager\isExternalRater().

+ Here is the caller graph for this function:

◆ getAuthor()

ilObjSurvey::getAuthor ( )

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

1151 : string
1152 {
1153 return $this->domain->metadata()->getAuthorsFromLOM(
1154 $this->getId(),
1155 0,
1156 $this->getType()
1157 );
1158 }

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ getAvailableQuestionpools()

ilObjSurvey::getAvailableQuestionpools ( bool  $use_obj_id = false,
bool  $could_be_offline = false,
bool  $showPath = false,
string  $permission = "read" 
)

Returns the available question pools for the active user.

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

2033 : array {
2034 return ilObjSurveyQuestionPool::_getAvailableQuestionpools($use_obj_id, $could_be_offline, $showPath, $permission);
2035 }
static _getAvailableQuestionpools(bool $use_object_id=false, bool $could_be_offline=false, bool $showPath=false, string $permission="read")
Returns the available question pools for the active user.

◆ getCalculateSumScore()

ilObjSurvey::getCalculateSumScore ( )

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

961 : bool
962 {
964 }

◆ getConstraints()

ilObjSurvey::getConstraints ( int  $question_id)

Returns the constraints to a given question or questionblock.

Todo:
move to constraint manager, introduce dto

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

2066 : array {
2067 $ilDB = $this->db;
2068
2069 $result_array = array();
2070 $result = $ilDB->queryF(
2071 "SELECT svy_constraint.*, svy_relation.* FROM svy_qst_constraint, svy_constraint, svy_relation " .
2072 "WHERE svy_constraint.relation_fi = svy_relation.relation_id AND " .
2073 "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.question_fi = %s " .
2074 "AND svy_qst_constraint.survey_fi = %s",
2075 array('integer','integer'),
2076 array($question_id, $this->getSurveyId())
2077 );
2078 while ($row = $ilDB->fetchAssoc($result)) {
2079 $question_type = SurveyQuestion::_getQuestionType($row["question_fi"]);
2080 SurveyQuestion::_includeClass($question_type);
2081 $question = new $question_type();
2082 $question->loadFromDb($row["question_fi"]);
2083 $valueoutput = $question->getPreconditionValueOutput($row["value"]);
2084 $result_array[] = array("id" => $row["constraint_id"],
2085 "question" => $row["question_fi"],
2086 "short" => $row["shortname"],
2087 "long" => $row["longname"],
2088 "value" => $row["value"],
2089 "conjunction" => $row["conjunction"],
2090 "valueoutput" => $valueoutput
2091 );
2092 }
2093 return $result_array;
2094 }

Referenced by SurveyConstraintsTableGUI\initItems().

+ Here is the caller graph for this function:

◆ getEndDate()

ilObjSurvey::getEndDate ( )

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

1223 : string
1224 {
1225 return $this->end_date;
1226 }

◆ getEvaluationAccess()

ilObjSurvey::getEvaluationAccess ( )

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

1285 : string
1286 {
1288 }
string $evaluation_access

◆ getEvaluationByUser()

ilObjSurvey::getEvaluationByUser ( array  $questions,
int  $active_id 
)

Calculates the evaluation data for a given run.

Todo:
move to evaluation manager

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

2778 : array {
2779 $ilDB = $this->db;
2780
2781 // collect all answers
2782 $answers = array();
2783 $result = $ilDB->queryF(
2784 "SELECT * FROM svy_answer WHERE active_fi = %s",
2785 array('integer'),
2786 array($active_id)
2787 );
2788 while ($row = $ilDB->fetchAssoc($result)) {
2789 if (!is_array($answers[$row["question_fi"]])) {
2790 $answers[$row["question_fi"]] = array();
2791 }
2792 $answers[$row["question_fi"]][] = $row;
2793 }
2794 $userdata = $this->getUserDataFromActiveId($active_id);
2795 $resultset = array(
2796 "name" => $userdata["fullname"],
2797 "firstname" => $userdata["firstname"],
2798 "lastname" => $userdata["lastname"],
2799 "login" => $userdata["login"],
2800 "gender" => $userdata["gender"],
2801 "answers" => array()
2802 );
2803 foreach ($questions as $key => $question) {
2804 if (array_key_exists($key, $answers)) {
2805 $resultset["answers"][$key] = $answers[$key];
2806 } else {
2807 $resultset["answers"][$key] = array();
2808 }
2809 sort($resultset["answers"][$key]);
2810 }
2811 return $resultset;
2812 }

◆ getExistingQuestions()

ilObjSurvey::getExistingQuestions ( )

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

Returns
int[]

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

1331 : array
1332 {
1333 $ilDB = $this->db;
1334 $existing_questions = array();
1335 $result = $ilDB->queryF(
1336 "SELECT svy_question.original_id FROM svy_question, svy_svy_qst WHERE " .
1337 "svy_svy_qst.survey_fi = %s AND svy_svy_qst.question_fi = svy_question.question_id",
1338 array('integer'),
1339 array($this->getSurveyId())
1340 );
1341 while ($data = $ilDB->fetchAssoc($result)) {
1342 if ($data["original_id"]) {
1343 $existing_questions[] = (int) $data["original_id"];
1344 }
1345 }
1346 return $existing_questions;
1347 }

References $data, $ilDB, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getExportDirectory()

ilObjSurvey::getExportDirectory ( )
Todo:
move to export sub-service

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

3469 : string
3470 {
3471 $export_dir = ilFileUtils::getDataDir() . "/svy_data" . "/svy_" . $this->getId() . "/export";
3472
3473 return $export_dir;
3474 }

References ilFileUtils\getDataDir(), and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ getExternalCodeRecipients()

ilObjSurvey::getExternalCodeRecipients ( bool  $a_check_finished = false)
Todo:
move to code manager

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

3839 : array {
3840 $ilDB = $this->db;
3841 $result = $ilDB->queryF(
3842 "SELECT survey_key code, externaldata, sent FROM svy_anonymous WHERE survey_fi = %s",
3843 array('integer'),
3844 array($this->getSurveyId())
3845 );
3846 $res = array();
3847 while ($row = $ilDB->fetchAssoc($result)) {
3848 if (!$row['externaldata']) {
3849 continue;
3850 }
3851
3852 $externaldata = unserialize((string) $row['externaldata'], ['allowed_classes' => false]);
3853 if (!$externaldata['email']) {
3854 continue;
3855 }
3856
3857 $externaldata['code'] = $row['code'];
3858 $externaldata['sent'] = $row['sent'];
3859
3860 if ($a_check_finished) {
3861 #23294
3862 //$externaldata['finished'] = $this->isSurveyCodeUsed($row['code']);
3863 $externaldata['finished'] = $this->isSurveyFinishedByCode($row['code']);
3864 }
3865
3866 $res[] = $externaldata;
3867 }
3868 return $res;
3869 }
isSurveyFinishedByCode(string $a_code)
Get if survey is finished for a specific anonymous user code.

◆ getFinishedIdForAppraiseeIdAndRaterId()

ilObjSurvey::getFinishedIdForAppraiseeIdAndRaterId ( int  $a_appr_id,
int  $a_rat_id 
)

Get finished id for an appraisee and a rater.

Todo:
move to run manager

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

4832 : ?int {
4833 $ilDB = $this->db;
4834
4835 $set = $ilDB->query("SELECT finished_id, user_fi FROM svy_finished" .
4836 " WHERE survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer") .
4837 " AND appr_id = " . $ilDB->quote($a_appr_id, "integer") .
4838 " AND user_fi = " . $ilDB->quote($a_rat_id, "integer"));
4839 if ($row = $ilDB->fetchAssoc($set)) {
4840 return (int) $row["finished_id"];
4841 }
4842 return null;
4843 }

◆ getFinishedIdsForAppraiseeId()

ilObjSurvey::getFinishedIdsForAppraiseeId ( int  $a_appr_id,
bool  $a_exclude_appraisee = false 
)
Returns
int[]
Todo:
move to run manager

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

4807 : array {
4808 $ilDB = $this->db;
4809
4810 $res = array();
4811
4812 $set = $ilDB->query("SELECT finished_id, user_fi FROM svy_finished" .
4813 " WHERE survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer") .
4814 " AND appr_id = " . $ilDB->quote($a_appr_id, "integer"));
4815 while ($row = $ilDB->fetchAssoc($set)) {
4816 if ($a_exclude_appraisee && $row["user_fi"] == $a_appr_id) {
4817 continue;
4818 }
4819 $res[] = (int) $row["finished_id"];
4820 }
4821
4822 return $res;
4823 }

◆ getImportDirectory()

ilObjSurvey::getImportDirectory ( )

get import directory of survey

Todo:
move to export sub-service

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

3510 : string
3511 {
3512 $import_dir = ilFileUtils::getDataDir() . "/svy_data" .
3513 "/svy_" . $this->getId() . "/import";
3514 if (!is_dir($import_dir)) {
3515 ilFileUtils::makeDirParents($import_dir);
3516 }
3517 if (is_dir($import_dir)) {
3518 return $import_dir;
3519 } else {
3520 return "";
3521 }
3522 }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.

References ilFileUtils\getDataDir(), ILIAS\Survey\Mode\getId(), and ilFileUtils\makeDirParents().

Referenced by delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIntroduction()

ilObjSurvey::getIntroduction ( )

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

1317 : string
1318 {
1319 return $this->introduction;
1320 }

◆ getLastAccess()

ilObjSurvey::getLastAccess ( int  $finished_id)
Todo:
move to run manager

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

3958 : ?int {
3959 $ilDB = $this->db;
3960
3961 $result = $ilDB->queryF(
3962 "SELECT tstamp FROM svy_answer WHERE active_fi = %s ORDER BY tstamp DESC",
3963 array('integer'),
3964 array($finished_id)
3965 );
3966 if ($result->numRows()) {
3967 $row = $ilDB->fetchAssoc($result);
3968 return (int) $row["tstamp"];
3969 } else {
3970 $result = $ilDB->queryF(
3971 "SELECT tstamp FROM svy_finished WHERE finished_id = %s",
3972 array('integer'),
3973 array($finished_id)
3974 );
3975 if ($result->numRows()) {
3976 $row = $ilDB->fetchAssoc($result);
3977 return (int) $row["tstamp"];
3978 }
3979 }
3980 return null;
3981 }

References $ilDB.

◆ getLastActivePage()

ilObjSurvey::getLastActivePage ( int  $active_id)

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

Todo:
move to run manager/repo

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

2552 : ?int {
2553 $ilDB = $this->db;
2554 $result = $ilDB->queryF(
2555 "SELECT lastpage FROM svy_finished WHERE finished_id = %s",
2556 array('integer'),
2557 array($active_id)
2558 );
2559 if ($row = $ilDB->fetchAssoc($result)) {
2560 return (int) $row["lastpage"];
2561 }
2562 return null;
2563 }

◆ getMailAddresses()

ilObjSurvey::getMailAddresses ( )

(Tutor) Recipients of "single participant has finished" mails

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

4113 : string
4114 {
4115 return $this->mailaddresses;
4116 }

◆ getMailNotification()

ilObjSurvey::getMailNotification ( )

Send mail to tutors each time a participant finishes the survey?

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

4097 : bool
4098 {
4100 }

◆ getMailParticipantData()

ilObjSurvey::getMailParticipantData ( )

Preceding text (incl.

placeholders) for "single participant has finished" mails

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

4129 : string
4130 {
4132 }
string $mailparticipantdata

◆ getMaxSumScore()

ilObjSurvey::getMaxSumScore ( )

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

5638 : int
5639 {
5640 $sum_score = 0;
5642 $sum_score += call_user_func([$c, "getMaxSumScore"], $this->getSurveyId());
5643 }
5644 return $sum_score;
5645 }
$c
Definition: deliver.php:25

References $c, and ilObjSurveyQuestionPool\_getQuestionClasses().

+ Here is the call graph for this function:

◆ getMode()

◆ getNextPage()

ilObjSurvey::getNextPage ( int  $active_page_question_id,
int  $direction 
)

Get current, previous or next page.

Parameters
int$active_page_question_idThe database id of one of the questions on that page
int$directionThe direction of the next page (-1 = previous page, 1 = next page)
Returns
?array question data or null, if there is no previous/next page
Exceptions
ilSurveyException
Todo:
move to execution manager

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

1998 : ?array {
1999 $foundpage = -1;
2000 $pages = $this->getSurveyPages();
2001 if ($active_page_question_id === 0) {
2002 return $pages[0];
2003 }
2004 foreach ($pages as $key => $question_array) {
2005 foreach ($question_array as $question) {
2006 if ($active_page_question_id == $question["question_id"]) {
2007 $foundpage = $key;
2008 }
2009 }
2010 }
2011 if ($foundpage === -1) {
2012 throw new ilSurveyException("nextPage: Current page not found.");
2013 } else {
2014 $foundpage += $direction;
2015 if ($foundpage < 0) {
2016 return null;
2017 }
2018 if ($foundpage >= count($pages)) {
2019 return null;
2020 }
2021 return $pages[$foundpage];
2022 }
2023 }
getSurveyPages()
Returns the survey pages in an array (a page contains one or more questions)

◆ getNotificationTargetUserIds()

ilObjSurvey::getNotificationTargetUserIds ( bool  $a_use_invited)

These users must finish the survey to trigger the tutor notification "all users finished the survey" a) members of a parent group/course or b) all members that have been invited (svy_invitation) invitations are presented as tasks on the dashboard.

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

5260 : array {
5262
5263 $user_ids = [];
5264 if ($a_use_invited) {
5265 $user_ids = $this->invitation_manager->getAllForSurvey($this->getSurveyId());
5266 } else {
5267 $parent_grp_ref_id = $tree->checkForParentType($this->getRefId(), "grp");
5268 if ($parent_grp_ref_id) {
5269 $part = new ilGroupParticipants(ilObject::_lookupObjId($parent_grp_ref_id));
5270 $user_ids = $part->getMembers();
5271 } else {
5272 $parent_crs_ref_id = $tree->checkForParentType($this->getRefId(), "crs");
5273 if ($parent_crs_ref_id) {
5274 $part = new ilCourseParticipants(ilObject::_lookupObjId($parent_crs_ref_id));
5275 $user_ids = $part->getMembers();
5276 }
5277 }
5278 }
5279 return $user_ids;
5280 }
ilTree $tree
static _lookupObjId(int $ref_id)
checkForParentType(int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentTyp...

◆ getOutro()

ilObjSurvey::getOutro ( )

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

1322 : string
1323 {
1324 return $this->outro;
1325 }

◆ getParticipantTextResults()

ilObjSurvey::getParticipantTextResults ( int  $active_id)
protected

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

2486 : string {
2487 $textresult = "";
2488 $userResults = $this->getUserSpecificResults(array($active_id));
2489 $questions = $this->getSurveyQuestions(true);
2490 $questioncounter = 1;
2491 foreach ($questions as $question_id => $question_data) {
2492 $textresult .= $questioncounter++ . ". " . $question_data["title"] . "\n";
2493 $found = $userResults[$question_id][$active_id];
2494 $text = "";
2495 if (is_array($found)) {
2496 $text = implode("\n", $found);
2497 } else {
2498 $text = $found;
2499 }
2500 if ($text === '') {
2502 }
2503 $text = str_replace("<br />", "\n", $text);
2504 $textresult .= $text . "\n\n";
2505 }
2506 return $textresult;
2507 }
getUserSpecificResults(array $finished_ids)
Calculates the evaluation data for the user specific results.
getSurveyQuestions(bool $with_answers=false)
Returns the survey questions and questionblocks in an array.
static getSurveySkippedValue()
$text
Definition: xapiexit.php:21

◆ getPoolUsage()

ilObjSurvey::getPoolUsage ( )

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

4173 : bool
4174 {
4175 return $this->pool_usage;
4176 }

◆ getPrecondition()

ilObjSurvey::getPrecondition ( int  $constraint_id)

Returns a precondition with a given id.

Todo:
move to constraint manager, introduce dto

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

2043 : array {
2044 $ilDB = $this->db;
2045
2046 $result = $ilDB->queryF(
2047 "SELECT svy_constraint.*, svy_relation.*, svy_qst_constraint.question_fi ref_question_fi FROM svy_qst_constraint, svy_constraint, " .
2048 "svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id AND " .
2049 "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_constraint.constraint_id = %s",
2050 array('integer'),
2051 array($constraint_id)
2052 );
2053 $pc = array();
2054 if ($result->numRows()) {
2055 $pc = $ilDB->fetchAssoc($result);
2056 }
2057 return $pc;
2058 }

◆ getQuestionblockQuestionIds()

ilObjSurvey::getQuestionblockQuestionIds ( int  $questionblock_id)
Parameters
int$questionblock_id
Returns
int[]
Todo:
move to survey question manager/repo

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

1630 : array {
1631 $ilDB = $this->db;
1632
1633 // we need a correct order here, see #22011
1634 $result = $ilDB->queryF(
1635 "SELECT a.question_fi FROM svy_qblk_qst a JOIN svy_svy_qst b ON (a.question_fi = b.question_fi) " .
1636 " WHERE a.questionblock_fi = %s ORDER BY b.sequence",
1637 array("integer"),
1638 array($questionblock_id)
1639 );
1640 $ids = array();
1641 if ($result->numRows()) {
1642 while ($data = $ilDB->fetchAssoc($result)) {
1643 if (!in_array($data['question_fi'], $ids)) { // no duplicates, see #22018
1644 $ids[] = (int) $data['question_fi'];
1645 }
1646 }
1647 }
1648 return $ids;
1649 }

◆ getQuestionblockQuestions()

ilObjSurvey::getQuestionblockQuestions ( int  $questionblock_id)
Parameters
int$questionblock_id
Returns
string[] question titles
Todo:
move to survey question manager/repo

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

1593 : array {
1594 $ilDB = $this->db;
1595 $titles = array();
1596 $result = $ilDB->queryF(
1597 "SELECT svy_question.title, svy_qblk_qst.question_fi, svy_qblk_qst.survey_fi FROM " .
1598 "svy_qblk, svy_qblk_qst, svy_question WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND " .
1599 "svy_question.question_id = svy_qblk_qst.question_fi AND svy_qblk.questionblock_id = %s",
1600 array('integer'),
1601 array($questionblock_id)
1602 );
1603 $survey_id = "";
1604 while ($row = $ilDB->fetchAssoc($result)) {
1605 $titles[$row["question_fi"]] = $row["title"];
1606 $survey_id = $row["survey_fi"];
1607 }
1608 $result = $ilDB->queryF(
1609 "SELECT question_fi, sequence FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
1610 array('integer'),
1611 array($survey_id)
1612 );
1613 $resultarray = array();
1614 $counter = 1;
1615 while ($row = $ilDB->fetchAssoc($result)) {
1616 if (array_key_exists($row["question_fi"], $titles)) {
1617 $resultarray[$counter++] = $titles[$row["question_fi"]];
1618 }
1619 }
1620 return $resultarray;
1621 }
$counter

◆ getQuestionblocksTable()

ilObjSurvey::getQuestionblocksTable ( array  $arrFilter)

Retrieve data for question block browser.

Todo:
move to survey question manager, use dto

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

2882 : array {
2883 $ilDB = $this->db;
2884
2885 $where = "";
2886 if (array_key_exists('title', $arrFilter) && strlen($arrFilter['title'])) {
2887 $where .= " AND " . $ilDB->like('svy_qblk.title', 'text', "%%" . $arrFilter['title'] . "%%");
2888 }
2889
2890 $query_result = $ilDB->query("SELECT svy_qblk.*, svy_svy.obj_fi FROM svy_qblk , svy_qblk_qst, svy_svy WHERE " .
2891 "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_svy.survey_id = svy_qblk_qst.survey_fi " .
2892 "$where GROUP BY svy_qblk.questionblock_id, svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.show_blocktitle, " .
2893 "svy_qblk.owner_fi, svy_qblk.tstamp, svy_svy.obj_fi");
2894 $rows = array();
2895 if ($query_result->numRows()) {
2896 $survey_ref_ids = ilUtil::_getObjectsByOperations("svy", "write");
2897 $surveytitles = array();
2898 foreach ($survey_ref_ids as $survey_ref_id) {
2899 $survey_id = ilObject::_lookupObjId($survey_ref_id);
2901 }
2902 while ($row = $ilDB->fetchAssoc($query_result)) {
2903 $questions_array = $this->getQuestionblockQuestions($row["questionblock_id"]);
2904 $counter = 1;
2905 foreach ($questions_array as $key => $value) {
2906 $questions_array[$key] = "$counter. $value";
2907 $counter++;
2908 }
2909 if (strlen($surveytitles[$row["obj_fi"]] ?? "")) { // only questionpools which are not in trash
2910 $rows[$row["questionblock_id"]] = array(
2911 "questionblock_id" => $row["questionblock_id"],
2912 "title" => $row["title"],
2913 "svy" => $surveytitles[$row["obj_fi"]],
2914 "contains" => implode(", ", $questions_array),
2915 "owner" => $row["owner_fi"]
2916 );
2917 }
2918 }
2919 }
2920 return $rows;
2921 }
getQuestionblockQuestions(int $questionblock_id)
static _lookupTitle(int $obj_id)
static _getObjectsByOperations( $a_obj_type, string $a_operation, int $a_usr_id=0, int $limit=0)
Get all objects of a specific type and check access This function is not recursive,...

References $ilDB.

Referenced by ilSurveyQuestionblockbrowserTableGUI\initData().

+ Here is the caller graph for this function:

◆ getQuestionGUI()

ilObjSurvey::getQuestionGUI ( string  $questiontype,
int  $question_id 
)

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

902 return SurveyQuestionGUI::_getQuestionGUI($questiontype, $question_id);
903 }
Basic class for all survey question types The SurveyQuestionGUI class defines and encapsulates basic ...
static _getQuestionGUI(?string $questiontype, int $question_id=-1)
Creates a question gui representation.

◆ getQuestionpoolTitles()

ilObjSurvey::getQuestionpoolTitles ( bool  $could_be_offline = false,
bool  $showPath = false 
)

Returns the available question pools for the active user.

Returns
array<int, string> keys are obj IDs, values are titles

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

1356 : array {
1357 return ilObjSurveyQuestionPool::_getAvailableQuestionpools(true, $could_be_offline, $showPath);
1358 }

◆ getQuestionsTable()

ilObjSurvey::getQuestionsTable ( array  $arrFilter)

Retrieve data for question browser.

Todo:
move to survey question manager, use dto

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

2820 : array {
2821 $ilDB = $this->db;
2822 $where = "";
2823 if (array_key_exists('title', $arrFilter) && strlen($arrFilter['title'])) {
2824 $where .= " AND " . $ilDB->like('svy_question.title', 'text', "%%" . $arrFilter['title'] . "%%");
2825 }
2826 if (array_key_exists('description', $arrFilter) && strlen($arrFilter['description'])) {
2827 $where .= " AND " . $ilDB->like('svy_question.description', 'text', "%%" . $arrFilter['description'] . "%%");
2828 }
2829 if (array_key_exists('author', $arrFilter) && strlen($arrFilter['author'])) {
2830 $where .= " AND " . $ilDB->like('svy_question.author', 'text', "%%" . $arrFilter['author'] . "%%");
2831 }
2832 if (array_key_exists('type', $arrFilter) && strlen($arrFilter['type'])) {
2833 $where .= " AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter['type'], 'text');
2834 }
2835 if (array_key_exists('spl', $arrFilter) && strlen($arrFilter['spl'])) {
2836 $where .= " AND svy_question.obj_fi = " . $ilDB->quote($arrFilter['spl'], 'integer');
2837 }
2838
2839 $spls = $this->getAvailableQuestionpools(true, false, false);
2840 $forbidden = " AND " . $ilDB->in('svy_question.obj_fi', array_keys($spls), false, 'integer');
2841 $forbidden .= " AND svy_question.complete = " . $ilDB->quote("1", 'text');
2842 $existing = "";
2843 $existing_questions = $this->getExistingQuestions();
2844 if (count($existing_questions)) {
2845 $existing = " AND " . $ilDB->in('svy_question.question_id', $existing_questions, true, 'integer');
2846 }
2847
2849
2850 $query_result = $ilDB->query("SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin, object_reference.ref_id" .
2851 " FROM svy_question, svy_qtype, object_reference" .
2852 " WHERE svy_question.original_id IS NULL" . $forbidden . $existing .
2853 " AND svy_question.obj_fi = object_reference.obj_id AND svy_question.tstamp > 0" .
2854 " AND svy_question.questiontype_fi = svy_qtype.questiontype_id " . $where);
2855
2856 $rows = array();
2857 if ($query_result->numRows()) {
2858 while ($row = $ilDB->fetchAssoc($query_result)) {
2859 if (array_key_exists('spl_txt', $arrFilter) && strlen($arrFilter['spl_txt'])) {
2860 if (stripos($spls[$row["obj_fi"]], $arrFilter['spl_txt']) === false) {
2861 continue;
2862 }
2863 }
2864
2865 $row['ttype'] = $trans[$row['type_tag']];
2866 if ($row["plugin"]) {
2867 continue;
2868 } else {
2869 $rows[] = $row;
2870 }
2871 }
2872 }
2873 return $rows;
2874 }
getAvailableQuestionpools(bool $use_obj_id=false, bool $could_be_offline=false, bool $showPath=false, string $permission="read")
Returns the available question pools for the active user.
getExistingQuestions()
Gets the question id's of the questions which are already in the survey.

References $ilDB.

Referenced by ilSurveyQuestionbrowserTableGUI\initData().

+ Here is the caller graph for this function:

◆ getQuestionType()

ilObjSurvey::getQuestionType ( int  $question_id)

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

908 : string {
910 if ($question_id < 1) {
911 return -1;
912 }
913 $result = $ilDB->queryF(
914 "SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND " .
915 "svy_question.questiontype_fi = svy_qtype.questiontype_id",
916 array('integer'),
917 array($question_id)
918 );
919 if ($result->numRows() === 1) {
920 $data = $ilDB->fetchAssoc($result);
921 return $data["type_tag"];
922 } else {
923 return "";
924 }
925 }

◆ getRatersData()

ilObjSurvey::getRatersData ( int  $a_appraisee_id)
Todo:
move to appraisal manager

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

4565 : array {
4566 $ilDB = $this->db;
4567
4568 $res = $anonymous_ids = array();
4569
4570 $set = $ilDB->query("SELECT * FROM svy_360_rater" .
4571 " WHERE obj_id = " . $ilDB->quote($this->getSurveyId(), "integer") .
4572 " AND appr_id = " . $ilDB->quote($a_appraisee_id, "integer"));
4573 while ($row = $ilDB->fetchAssoc($set)) {
4574 if ($row["anonymous_id"]) {
4575 $res["a" . $row["anonymous_id"]] = array(
4576 "lastname" => "unknown code " . $row["anonymous_id"],
4577 "sent" => $row["mail_sent"],
4578 "finished" => null
4579 );
4580 $anonymous_ids[] = $row["anonymous_id"];
4581 } else {
4582 $name = ilObjUser::_lookupName($row["user_id"]);
4583 $name["name"] = $name["lastname"] . ", " . $name["firstname"];
4584 $name["user_id"] = "u" . $name["user_id"];
4585 $name["email"] = ilObjUser::_lookupEmail($row["user_id"]);
4586 $name["sent"] = $row["mail_sent"];
4587 $name["finished"] = (bool) $this->is360SurveyStarted($a_appraisee_id, (int) $row["user_id"]);
4588 $res["u" . $row["user_id"]] = $name;
4589 }
4590 }
4591
4592 if (count($anonymous_ids)) {
4593 $data = $this->getSurveyCodesTableData($anonymous_ids);
4594 foreach ($data as $item) {
4595 if (isset($res["a" . $item["id"]])) {
4596 $res["a" . $item["id"]] = array(
4597 "user_id" => "a" . $item["id"],
4598 "lastname" => $item["last_name"],
4599 "firstname" => $item["first_name"],
4600 "name" => $item["last_name"] . ", " . $item["first_name"],
4601 "login" => "",
4602 "email" => $item["email"],
4603 "code" => $item["code"],
4604 "href" => $item["href"],
4605 "sent" => $res["a" . $item["id"]]["sent"],
4606 "finished" => (bool) $this->is360SurveyStarted($a_appraisee_id, 0, $item["code"])
4607 );
4608 }
4609 }
4610 }
4611
4612 return $res;
4613 }
is360SurveyStarted(int $appr_id, int $user_id, ?string $anonymous_code=null)
getSurveyCodesTableData(?array $ids=null, ?string $lang=null)
Fetches the data for the survey codes table.

Referenced by ILIAS\Survey\Evaluation\EvaluationManager\getSelectableRaters().

+ Here is the caller graph for this function:

◆ getReminderEnd()

ilObjSurvey::getReminderEnd ( )

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

4991 : ?ilDate
4992 {
4993 return $this->reminder_end;
4994 }

◆ getReminderFrequency()

ilObjSurvey::getReminderFrequency ( )

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

5001 : int
5002 {
5004 }

◆ getReminderLastSent()

ilObjSurvey::getReminderLastSent ( )

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

5021 : ?string
5022 {
5024 }
string $reminder_last_sent

◆ getReminderMailTemplates()

ilObjSurvey::getReminderMailTemplates ( ?int &  $defaultTemplateId = null)

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

5549 : array {
5550 global $DIC;
5551
5552 $res = array();
5553
5554 $templateService = $DIC->mail()->textTemplates();
5555 foreach ($templateService->loadTemplatesForContextId(ilSurveyMailTemplateReminderContext::ID) as $tmpl) {
5556 $res[$tmpl->getTplId()] = $tmpl->getTitle();
5557 if (null !== $defaultTemplateId && $tmpl->isDefault()) {
5558 $defaultTemplateId = $tmpl->getTplId();
5559 }
5560 }
5561
5562 return $res;
5563 }

◆ getReminderStart()

ilObjSurvey::getReminderStart ( )

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

4981 : ?ilDate
4982 {
4983 return $this->reminder_start;
4984 }

◆ getReminderStatus()

ilObjSurvey::getReminderStatus ( )

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

4971 : bool
4972 {
4974 }

◆ getReminderTarget()

ilObjSurvey::getReminderTarget ( )

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

5011 : int
5012 {
5014 }

◆ getReminderTemplate()

ilObjSurvey::getReminderTemplate ( bool  $selectDefault = false)

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

5036 : ?int {
5037 if ($selectDefault) {
5038 $defaultTemplateId = 0;
5039 $this->getReminderMailTemplates($defaultTemplateId);
5040
5041 if ($defaultTemplateId > 0) {
5042 return $defaultTemplateId;
5043 }
5044 }
5045
5046 return $this->reminder_tmpl;
5047 }
getReminderMailTemplates(?int &$defaultTemplateId=null)

◆ getSelfEvaluationResults()

ilObjSurvey::getSelfEvaluationResults ( )

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

5599 : int
5600 {
5602 }

Referenced by ILIAS\Survey\Evaluation\EvaluationManager\isMultiParticipantsView().

+ Here is the caller graph for this function:

◆ getShowQuestionTitles()

ilObjSurvey::getShowQuestionTitles ( )

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

1160 : bool
1161 {
1162 return (bool) $this->display_question_titles;
1163 }
int $display_question_titles

◆ getSkillService()

ilObjSurvey::getSkillService ( )

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

4853 : bool
4854 {
4856 }

◆ getStartDate()

ilObjSurvey::getStartDate ( )

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

1182 : string
1183 {
1184 return $this->start_date;
1185 }

◆ getSurveyCodesForExport()

ilObjSurvey::getSurveyCodesForExport ( ?array  $a_codes = null,
?array  $a_ids = null 
)

Return a list of survey codes for file export, note: user_key needs to be null to export a record.

Parameters
?string[]$a_codes array of all survey codes that should be exported, if null...
?int[]$a_ids array of anonymous ids that should be exported
Returns
string comma separated list of survey codes an URLs for file export
Todo:
move to code manager
Exceptions
ilDateTimeException

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

3577 : string {
3578 $ilDB = $this->db;
3579 $ilUser = $this->user;
3580 $lng = $this->lng;
3581
3582 $sql = "SELECT svy_anonymous.*, svy_finished.state" .
3583 " FROM svy_anonymous" .
3584 " LEFT JOIN svy_finished ON (svy_anonymous.survey_key = svy_finished.anonymous_id)" .
3585 " WHERE svy_anonymous.survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer") .
3586 " AND svy_anonymous.user_key IS NULL";
3587
3588 if ($a_codes) {
3589 $sql .= " AND " . $ilDB->in("svy_anonymous.survey_key", $a_codes, "", "text");
3590 } elseif ($a_ids) {
3591 $sql .= " AND " . $ilDB->in("svy_anonymous.anonymous_id", $a_ids, "", "text");
3592 }
3593
3594 $export = array();
3595
3596 // #14905
3597 $titles = array();
3598 $titles[] = '"' . $lng->txt("survey_code") . '"';
3599 $titles[] = '"' . $lng->txt("email") . '"';
3600 $titles[] = '"' . $lng->txt("lastname") . '"';
3601 $titles[] = '"' . $lng->txt("firstname") . '"';
3602 $titles[] = '"' . $lng->txt("create_date") . '"';
3603 $titles[] = '"' . $lng->txt("used") . '"';
3604 $titles[] = '"' . $lng->txt("mail_sent_short") . '"';
3605 $titles[] = '"' . $lng->txt("survey_code_url") . '"';
3606 $export[] = implode(";", $titles);
3607
3608 $result = $ilDB->query($sql);
3609 $default_lang = $ilUser->getPref("survey_code_language");
3610 while ($row = $ilDB->fetchAssoc($result)) {
3611 $item = array();
3612 $item[] = $row["survey_key"];
3613
3614 if ($row["externaldata"]) {
3615 $ext = unserialize((string) $row["externaldata"], ['allowed_classes' => false]);
3616 $item[] = $ext["email"];
3617 $item[] = $ext["lastname"];
3618 $item[] = $ext["firstname"];
3619 } else {
3620 $item[] = "";
3621 $item[] = "";
3622 $item[] = "";
3623 }
3624
3625 // No relative (today, tomorrow...) dates in export.
3626 $date = new ilDateTime($row['tstamp'], IL_CAL_UNIX);
3627 $item[] = $date->get(IL_CAL_DATETIME);
3628
3629 $item[] = ($this->isSurveyCodeUsed($row["survey_key"])) ? 1 : 0;
3630 $item[] = ($row["sent"]) ? 1 : 0;
3631
3632 $params = array("accesscode" => $row["survey_key"]);
3633 if ($default_lang) {
3634 $params["lang"] = $default_lang;
3635 }
3636 $item[] = ilLink::_getLink($this->getRefId(), "svy", $params);
3637
3638 $export[] = '"' . implode('";"', $item) . '"';
3639 }
3640 return implode("\n", $export);
3641 }
const IL_CAL_UNIX
const IL_CAL_DATETIME
@classDescription Date and time handling
isSurveyCodeUsed(string $code)
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31

References $ilDB.

◆ getSurveyCodesTableData()

ilObjSurvey::getSurveyCodesTableData ( ?array  $ids = null,
?string  $lang = null 
)

Fetches the data for the survey codes table.

Parameters
?string$lang Language for the survey code URL
Todo:
move to code manager

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

3651 : array {
3652 $ilDB = $this->db;
3653
3654 $codes = array();
3655
3656 $sql = "SELECT svy_anonymous.*, svy_finished.state" .
3657 " FROM svy_anonymous" .
3658 " LEFT JOIN svy_finished ON (svy_anonymous.survey_key = svy_finished.anonymous_id)" .
3659 " WHERE svy_anonymous.survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer") /*.
3660 " AND svy_anonymous.user_key IS NULL" */; // #15860
3661
3662 if ($ids) {
3663 $sql .= " AND " . $ilDB->in("svy_anonymous.anonymous_id", $ids, "", "integer");
3664 }
3665
3666 $sql .= " ORDER BY tstamp, survey_key ASC";
3667 $result = $ilDB->query($sql);
3668 if ($result->numRows() > 0) {
3669 while ($row = $ilDB->fetchAssoc($result)) {
3670 $href = "";
3671 $used = false;
3672 if ($this->isSurveyCodeUsed($row["survey_key"])) {
3673 $used = true;
3674 } else {
3675 $params = array("accesscode" => $row["survey_key"]);
3676 if ($lang) {
3677 $params["lang"] = $lang;
3678 }
3679 $href = ilLink::_getLink($this->getRefId(), "svy", $params);
3680 }
3681
3682
3683 $item = array(
3684 'id' => $row["anonymous_id"],
3685 'code' => $row["survey_key"],
3686 'date' => $row["tstamp"],
3687 'used' => $used,
3688 'sent' => $row['sent'],
3689 'href' => $href,
3690 'email' => '',
3691 'last_name' => '',
3692 'first_name' => ''
3693 );
3694
3695 if ($row["externaldata"]) {
3696 $ext = unserialize((string) $row["externaldata"], ['allowed_classes' => false]);
3697 $item['email'] = $ext['email'] ?? "";
3698 $item['last_name'] = $ext['lastname'] ?? "";
3699 $item['first_name'] = $ext['firstname'] ?? "";
3700 }
3701
3702 $codes[] = $item;
3703 }
3704 }
3705 return $codes;
3706 }

◆ getSurveyFinishedIds()

ilObjSurvey::getSurveyFinishedIds ( )

Get run ids.

Todo:
move to run manager
Returns
int[]

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

2655 : array
2656 {
2657 $ilDB = $this->db;
2658
2659 $users = array();
2660 $result = $ilDB->queryF(
2661 "SELECT * FROM svy_finished WHERE survey_fi = %s",
2662 array('integer'),
2663 array($this->getSurveyId())
2664 );
2665 if ($result->numRows()) {
2666 while ($row = $ilDB->fetchAssoc($result)) {
2667 $users[] = (int) $row["finished_id"];
2668 }
2669 }
2670 return $users;
2671 }

References $ilDB, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getSurveyId()

ilObjSurvey::getSurveyId ( )

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

927 : int
928 {
929 return $this->survey_id;
930 }

Referenced by ILIAS\Survey\Code\CodeManager\__construct(), ILIAS\Survey\Execution\RunManager\__construct(), deleteSurveyRecord(), and ilSurveyParticipantsTableGUI\getItems().

+ Here is the caller graph for this function:

◆ getSurveyPages()

ilObjSurvey::getSurveyPages ( )

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

Todo:
move to survey question manager/repo, use dto

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

1910 : array
1911 {
1912 $ilDB = $this->db;
1913 // get questionblocks
1914 $all_questions = array();
1915 $result = $ilDB->queryF(
1916 "SELECT svy_question.*, svy_qtype.type_tag, svy_svy_qst.heading FROM " .
1917 "svy_question, svy_qtype, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
1918 "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
1919 "ORDER BY svy_svy_qst.sequence",
1920 array('integer'),
1921 array($this->getSurveyId())
1922 );
1923 while ($row = $ilDB->fetchAssoc($result)) {
1924 $all_questions[$row["question_id"]] = $row;
1925 }
1926 // get all questionblocks
1927 $questionblocks = array();
1928 if (count($all_questions)) {
1929 $result = $ilDB->queryF(
1930 "SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst " .
1931 "WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
1932 "AND " . $ilDB->in('svy_qblk_qst.question_fi', array_keys($all_questions), false, 'integer'),
1933 array('integer'),
1934 array($this->getSurveyId())
1935 );
1936 while ($row = $ilDB->fetchAssoc($result)) {
1937 $questionblocks[$row['question_fi']] = $row;
1938 }
1939 }
1940
1941 $all_pages = array();
1942 $pageindex = -1;
1943 $currentblock = "";
1944 foreach ($all_questions as $question_id => $row) {
1945 $constraints = array();
1946 if (isset($questionblocks[$question_id])) {
1947 if (!$currentblock or ($currentblock != $questionblocks[$question_id]['questionblock_id'])) {
1948 $pageindex++;
1949 }
1950 $all_questions[$question_id]['page'] = $pageindex;
1951 $all_questions[$question_id]["questionblock_title"] = $questionblocks[$question_id]['title'];
1952 $all_questions[$question_id]["questionblock_id"] = $questionblocks[$question_id]['questionblock_id'];
1953 $all_questions[$question_id]["questionblock_show_questiontext"] = $questionblocks[$question_id]['show_questiontext'];
1954 $all_questions[$question_id]["questionblock_show_blocktitle"] = $questionblocks[$question_id]['show_blocktitle'];
1955 $all_questions[$question_id]["questionblock_compress_view"] = $questionblocks[$question_id]['compress_view'];
1956 $currentblock = $questionblocks[$question_id]['questionblock_id'];
1957 } else {
1958 $pageindex++;
1959 $all_questions[$question_id]['page'] = $pageindex;
1960 $all_questions[$question_id]["questionblock_title"] = "";
1961 $all_questions[$question_id]["questionblock_id"] = "";
1962 $all_questions[$question_id]["questionblock_show_questiontext"] = 1;
1963 $all_questions[$question_id]["questionblock_show_blocktitle"] = 1;
1964 $all_questions[$question_id]["questionblock_compress_view"] = false;
1965 $currentblock = "";
1966 }
1967 $constraints = $this->getConstraints($question_id);
1968 $all_questions[$question_id]["constraints"] = $constraints;
1969 if (!isset($all_pages[$pageindex])) {
1970 $all_pages[$pageindex] = array();
1971 }
1972 $all_pages[$pageindex][] = $all_questions[$question_id];
1973 }
1974 // calculate position percentage for every page
1975 $max = count($all_pages);
1976 $counter = 1;
1977 foreach ($all_pages as $index => $block) {
1978 foreach ($block as $blockindex => $question) {
1979 $all_pages[$index][$blockindex]["position"] = $counter / $max;
1980 }
1981 $counter++;
1982 }
1983
1984 return $all_pages;
1985 }
getConstraints(int $question_id)
Returns the constraints to a given question or questionblock.

References $counter, and $ilDB.

◆ getSurveyParticipants()

ilObjSurvey::getSurveyParticipants ( ?array  $finished_ids = null,
bool  $force_non_anonymous = false,
bool  $include_invites = false 
)
Todo:
move to run/participant manager/repo

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

455 : array {
457 $sql = "SELECT * FROM svy_finished" .
458 " WHERE survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer");
459 if ($finished_ids) {
460 $sql .= " AND " . $ilDB->in("finished_id", $finished_ids, "", "integer");
461 }
462
463 $result = $ilDB->query($sql);
464 $participants = array();
465 if ($result->numRows() > 0) {
466 while ($row = $ilDB->fetchAssoc($result)) {
467 $userdata = $this->getUserDataFromActiveId($row["finished_id"], $force_non_anonymous);
468 $userdata["finished"] = (bool) $row["state"];
469 $userdata["finished_tstamp"] = $row["tstamp"];
470 $participants[$userdata["sortname"] . $userdata["active_id"]] = $userdata;
471 }
472 }
473 $participant_ids = array_column($participants, "usr_id");
474 if ($include_invites) {
475 foreach ($this->invitation_manager->getAllForSurvey($this->getSurveyId()) as $usr_id) {
476 if (!in_array($usr_id, $participant_ids)) {
477 $name = ilObjUser::_lookupName($usr_id);
478 $participants[$name["lastname"] . "," . $name["firstname"] . $usr_id] = [
479 "fullname" => ilObjUser::_lookupFullname($usr_id),
480 "sortname" => $name["lastname"] . "," . $name["firstname"],
481 "fistname" => $name["firstname"],
482 "lastname" => $name["lastname"],
483 "login" => $name["login"],
484 "gender" => "",
485 "usr_id" => $usr_id,
486 "finished" => false,
487 "finished_tstamp" => 0,
488 "invited" => true
489 ];
490 }
491 }
492 }
493 return $participants;
494 }
return true
static _lookupFullname(int $a_user_id)

References $ilDB.

Referenced by ilSurveyParticipantsTableGUI\getItems(), and ILIAS\Survey\Evaluation\EvaluationManager\getSelectableAppraisees().

+ Here is the caller graph for this function:

◆ getSurveyQuestions()

ilObjSurvey::getSurveyQuestions ( bool  $with_answers = false)

Returns the survey questions and questionblocks in an array.

Todo:
move to survey question manager/repo, use dto

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

1803 : array {
1804 $ilDB = $this->db;
1805 // get questionblocks
1806 $all_questions = array();
1807 $result = $ilDB->queryF(
1808 "SELECT svy_qtype.type_tag, svy_qtype.plugin, svy_question.question_id, " .
1809 "svy_svy_qst.heading FROM svy_qtype, svy_question, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
1810 "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
1811 "ORDER BY svy_svy_qst.sequence",
1812 array('integer'),
1813 array($this->getSurveyId())
1814 );
1815 while ($row = $ilDB->fetchAssoc($result)) {
1816 $add = true;
1817 if ($row["plugin"]) {
1818 $add = false;
1819 }
1820 if ($add) {
1821 $question = self::_instanciateQuestion($row["question_id"]);
1822 $questionrow = $question->getQuestionDataArray($row["question_id"]);
1823 foreach ($row as $key => $value) {
1824 $questionrow[$key] = $value;
1825 }
1826 $all_questions[$row["question_id"]] = $questionrow;
1827 $all_questions[$row["question_id"]]["usableForPrecondition"] = $question->usableForPrecondition();
1828 $all_questions[$row["question_id"]]["availableRelations"] = $question->getAvailableRelations();
1829 }
1830 }
1831 // get all questionblocks
1832 $questionblocks = array();
1833 if (count($all_questions)) {
1834 $result = $ilDB->queryF(
1835 "SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst WHERE " .
1836 "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
1837 "AND " . $ilDB->in('svy_qblk_qst.question_fi', array_keys($all_questions), false, 'integer'),
1838 array('integer'),
1839 array($this->getSurveyId())
1840 );
1841 while ($row = $ilDB->fetchAssoc($result)) {
1842 $questionblocks[$row['question_fi']] = $row;
1843 }
1844 }
1845
1846 foreach ($all_questions as $question_id => $row) {
1847 $constraints = $this->getConstraints($question_id);
1848 if (isset($questionblocks[$question_id])) {
1849 $all_questions[$question_id]["questionblock_title"] = $questionblocks[$question_id]['title'];
1850 $all_questions[$question_id]["questionblock_id"] = $questionblocks[$question_id]['questionblock_id'];
1851 } else {
1852 $all_questions[$question_id]["questionblock_title"] = "";
1853 $all_questions[$question_id]["questionblock_id"] = "";
1854 }
1855 $all_questions[$question_id]["constraints"] = $constraints;
1856 if ($with_answers) {
1857 $answers = array();
1858 $result = $ilDB->queryF(
1859 "SELECT svy_variable.*, svy_category.title FROM svy_variable, svy_category " .
1860 "WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id " .
1861 "ORDER BY sequence ASC",
1862 array('integer'),
1863 array($question_id)
1864 );
1865 if ($result->numRows() > 0) {
1866 while ($data = $ilDB->fetchAssoc($result)) {
1867 $answers[] = $data["title"];
1868 }
1869 }
1870 $all_questions[$question_id]["answers"] = $answers;
1871 }
1872 }
1873 return $all_questions;
1874 }
static _instanciateQuestion(int $question_id)
Creates an instance of a question with a given question id.

Referenced by SurveyConstraintsTableGUI\initItems().

+ Here is the caller graph for this function:

◆ getSurveySkippedValue()

static ilObjSurvey::getSurveySkippedValue ( )
static

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

5531 : string
5532 {
5533 global $DIC;
5534
5535 $lng = $DIC->language();
5536
5537 // #13541
5538
5539 $surveySetting = new ilSetting("survey");
5540 if (!$surveySetting->get("skipped_is_custom", false)) {
5541 return $lng->txt("skipped");
5542 } else {
5543 return $surveySetting->get("skipped_custom_value", "");
5544 }
5545 }
ILIAS Setting Class.

References $DIC, and $lng.

Referenced by ilSurveyResultsUserTableGUI\fillRow(), and SurveyQuestionEvaluation\getSkippedValue().

+ Here is the caller graph for this function:

◆ getSurveysWithTutorResults()

static ilObjSurvey::getSurveysWithTutorResults ( )
static
Returns
int[]

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

5607 : array
5608 {
5609 global $ilDB;
5610
5611 $res = array();
5612
5614
5615
5616 $q = "SELECT obj_fi FROM svy_svy" .
5617 " WHERE tutor_res_cron IS NULL" .
5618 " AND tutor_res_status = " . $ilDB->quote(1, "integer") .
5619 " AND enddate < " . $ilDB->quote(date("Ymd000000"), "text");
5620
5621 if (DEVMODE) {
5622 $q = "SELECT obj_fi FROM svy_svy" .
5623 " WHERE tutor_res_status = " . $ilDB->quote(1, "integer") .
5624 " AND enddate < " . $ilDB->quote(date("Ymd000000"), "text");
5625 }
5626
5627 $set = $ilDB->query($q);
5628
5629 $log->debug($q);
5630
5631 while ($row = $ilDB->fetchAssoc($set)) {
5632 $res[] = (int) $row["obj_fi"];
5633 }
5634
5635 return $res;
5636 }
debug(string $message, array $context=[])
ilLogger $log

References $ilDB, $log, $q, $res, ilLoggerFactory\getLogger(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getTextblock()

ilObjSurvey::getTextblock ( int  $question_id)
Todo:
move to survey question manager

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

3410 : string {
3411 $ilDB = $this->db;
3412 $result = $ilDB->queryF(
3413 "SELECT * FROM svy_svy_qst WHERE question_fi = %s",
3414 array('integer'),
3415 array($question_id)
3416 );
3417 if ($row = $ilDB->fetchAssoc($result)) {
3418 return $row["heading"] ?? "";
3419 } else {
3420 return "";
3421 }
3422 }

◆ getTutorNotificationRecipients()

ilObjSurvey::getTutorNotificationRecipients ( )

Mail being sent to tutors after all participants have finished the survey?

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

5070 : array
5071 {
5073 }
array $tutor_ntf_recipients

◆ getTutorNotificationStatus()

ilObjSurvey::getTutorNotificationStatus ( )

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

5054 : bool
5055 {
5057 }

◆ getTutorNotificationTarget()

ilObjSurvey::getTutorNotificationTarget ( )

Group that is checked for the "all participants have finished" mail Either a) all members of a parent group/course or b) all users which have been invited (svy_invitation) (= task on dashboard)

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

5089 : int
5090 {
5092 }

◆ getTutorResultsRecipients()

ilObjSurvey::getTutorResultsRecipients ( )

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

5109 : array
5110 {
5112 }
array $tutor_res_recipients

◆ getTutorResultsStatus()

ilObjSurvey::getTutorResultsStatus ( )

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

5099 : bool
5100 {
5102 }

◆ getUserAccessCode()

ilObjSurvey::getUserAccessCode ( int  $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
Todo:
move to code manager

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

3913 : string
3914 {
3915 $ilDB = $this->db;
3916 $access_code = "";
3917 $result = $ilDB->queryF(
3918 "SELECT survey_key FROM svy_anonymous WHERE survey_fi = %s AND user_key = %s",
3919 array('integer','text'),
3920 array($this->getSurveyId(), md5($user_id))
3921 );
3922 if ($result->numRows()) {
3923 $row = $ilDB->fetchAssoc($result);
3924 $access_code = $row["survey_key"];
3925 }
3926 return $access_code;
3927 }

References $ilDB, and $user_id.

◆ getUserData()

ilObjSurvey::getUserData ( array  $ids)

Returns a data of all users specified by id list.

Parameters
int[]$idsarray of user id's
Returns
array The user data "usr_id, login, lastname, firstname, clientip" of the users with id as key
Todo:
use user service, remove direct access to usr_data table

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

4079 : array {
4080 $ilDB = $this->db;
4081
4082 if (count($ids) === 0) {
4083 return array();
4084 }
4085
4086 $result = $ilDB->query("SELECT usr_id, login, lastname, firstname FROM usr_data WHERE " . $ilDB->in('usr_id', $ids, false, 'integer') . " ORDER BY login");
4087 $result_array = array();
4088 while ($row = $ilDB->fetchAssoc($result)) {
4089 $result_array[$row["usr_id"]] = $row;
4090 }
4091 return $result_array;
4092 }

◆ getUserDataFromActiveId()

ilObjSurvey::getUserDataFromActiveId ( int  $active_id,
bool  $force_non_anonymous = false 
)

Returns run information.

Todo:
move to run manager/repo

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

2711 : array {
2712 $ilDB = $this->db;
2713
2714 $surveySetting = new ilSetting("survey");
2715 $use_anonymous_id = $surveySetting->get("use_anonymous_id");
2716 $result = $ilDB->queryF(
2717 "SELECT * FROM svy_finished WHERE finished_id = %s",
2718 array('integer'),
2719 array($active_id)
2720 );
2721 $row = array();
2722 $foundrows = $result->numRows();
2723 if ($foundrows) {
2724 $row = $ilDB->fetchAssoc($result);
2725 }
2726 $name = ($use_anonymous_id) ? $row["anonymous_id"] : $this->lng->txt("anonymous");
2727 $userdata = array(
2728 "fullname" => $name,
2729 "sortname" => $name,
2730 "firstname" => "",
2731 "lastname" => "",
2732 "login" => "",
2733 "gender" => "",
2734 "active_id" => (string) $active_id
2735 );
2736 if ($foundrows) {
2737 if (($row["user_fi"] > 0) &&
2738 (($row["user_fi"] != ANONYMOUS_USER_ID &&
2739 !$this->hasAnonymizedResults() &&
2740 !$this->get360Mode()) || // 360° uses ANONYMIZE_CODE_ALL which is wrong - see ilObjSurveyGUI::afterSave()
2741 $force_non_anonymous)) {
2742 if (ilObjUser::_lookupLogin($row["user_fi"]) === '') {
2743 $userdata["fullname"] = $userdata["sortname"] = $this->lng->txt("deleted_user");
2744 } else {
2745 $user = new ilObjUser($row["user_fi"]);
2746 $userdata['usr_id'] = $row['user_fi'];
2747 $userdata["fullname"] = $user->getFullname();
2748 $gender = $user->getGender();
2749 if (strlen($gender) === 1) {
2750 $gender = $this->lng->txt("gender_$gender");
2751 }
2752 $userdata["gender"] = $gender;
2753 $userdata["firstname"] = $user->getFirstname();
2754 $userdata["lastname"] = $user->getLastname();
2755 $userdata["sortname"] = $user->getLastname() . ", " . $user->getFirstname();
2756 $userdata["login"] = $user->getLogin();
2757 }
2758 }
2759 if ($row["user_fi"] == 0 || $row["user_fi"] == ANONYMOUS_USER_ID) {
2760 $code = $this->code_manager->getByUserKey((string) $row["anonymous_id"]);
2761 if (!is_null($code) && $this->feature_config->usesAppraisees()) {
2762 $userdata["firstname"] = $code->getFirstName();
2763 $userdata["lastname"] = $code->getLastName();
2764 $userdata["sortname"] = $code->getLastName() . ", " . $code->getFirstName();
2765 }
2766 }
2767 }
2768 return $userdata;
2769 }
User class.
getFullname(int $max_strlen=0)
static _lookupLogin(int $a_user_id)

◆ getUserSettings()

ilObjSurvey::getUserSettings ( int  $usr_id,
string  $key 
)

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

677 : array {
679
680 $result = $ilDB->queryF(
681 "SELECT * FROM svy_settings WHERE usr_id = %s AND keyword = %s",
682 array('integer', 'text'),
683 array($usr_id, $key)
684 );
685 $found = array();
686 if ($result->numRows()) {
687 while ($row = $ilDB->fetchAssoc($result)) {
688 $found[$row['settings_id']] = $row;
689 }
690 }
691 return $found;
692 }

◆ getUserSpecificResults()

ilObjSurvey::getUserSpecificResults ( array  $finished_ids)

Calculates the evaluation data for the user specific results.

Parameters
int[]$finished_ids
Todo:
move to evaluation manager

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

2680 : array {
2681 $evaluation = array();
2682
2683 foreach (array_keys($this->getSurveyQuestions()) as $question_id) {
2684 // get question instance
2685 $question_type = SurveyQuestion::_getQuestionType($question_id);
2686 SurveyQuestion::_includeClass($question_type);
2687 $question = new $question_type();
2688 $question->loadFromDb($question_id);
2689
2690 $q_eval = SurveyQuestion::_instanciateQuestionEvaluation($question_id, $finished_ids);
2691 $q_res = $q_eval->getResults();
2692
2693 $data = array();
2694 foreach ($finished_ids as $user_id) {
2695 $data[$user_id] = $q_eval->parseUserSpecificResults($q_res, $user_id);
2696 }
2697
2698 $evaluation[$question_id] = $data;
2699 }
2700
2701 return $evaluation;
2702 }
static _instanciateQuestionEvaluation(int $question_id, ?array $a_finished_ids=null)

References $data, $user_id, SurveyQuestion\_getQuestionType(), SurveyQuestion\_includeClass(), and SurveyQuestion\_instanciateQuestionEvaluation().

+ Here is the call graph for this function:

◆ getUserSurveyExecutionStatus()

ilObjSurvey::getUserSurveyExecutionStatus ( ?string  $a_code = null)

Get current user execution status.

Generates a code in svy_anonymous for logged in raters, if codes are used Generates a code for the anonymous user, if the survey is set to anonymous and no codes are used

Parameters
?string$a_code
Returns
array|null
Todo:
move to run manager

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

4702 : ?array {
4703 $ilUser = $this->user;
4704 $ilDB = $this->db;
4705 $user_id = $ilUser->getId();
4706 // code is obligatory?
4707 if (!$this->isAccessibleWithoutCode()) {
4708 if (!$a_code) {
4709 // registered raters do not need code
4710 if ($this->feature_config->usesAppraisees() &&
4712 $this->isRater(0, $user_id)) {
4713 // auto-generate code
4714 $code = $this->data_manager->code("")
4715 ->withUserId($user_id);
4716 $this->code_manager->add($code);
4717 $a_code = $this->code_manager->getByUserId($user_id);
4718 } else {
4719 return null;
4720 }
4721 }
4722 } elseif ($user_id === ANONYMOUS_USER_ID ||
4723 $this->getAnonymize() === self::ANONYMIZE_FREEACCESS) {
4724 // self::ANONYMIZE_FREEACCESS: anonymized, no codes
4725 // or anonymous user when no codes are used
4726 if (!$a_code) {
4727 // auto-generate code
4728 $code = $this->data_manager->code("")
4729 ->withUserId($user_id);
4730 $code_id = $this->code_manager->add($code);
4731 $a_code = $this->code_manager->getByCodeId($code_id);
4732 }
4733 } else {
4734 $a_code = null;
4735 }
4736
4737 $res = array();
4738
4739 // get runs for user id / code
4740 $sql = "SELECT * FROM svy_finished" .
4741 " WHERE survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer");
4742 // if proper user id is given, use it or current code
4743 if ($user_id !== ANONYMOUS_USER_ID) {
4744 $sql .= " AND (user_fi = " . $ilDB->quote($user_id, "integer") .
4745 " OR anonymous_id = " . $ilDB->quote($a_code, "text") . ")";
4746 }
4747 // use anonymous code to find finished id(s)
4748 else {
4749 $sql .= " AND anonymous_id = " . $ilDB->quote($a_code, "text");
4750 }
4751 $set = $ilDB->query($sql);
4752 while ($row = $ilDB->fetchAssoc($set)) {
4753 $res[$row["finished_id"]] = array("appr_id" => $row["appr_id"],
4754 "user_id" => $row["user_fi"],
4755 "code" => $row["anonymous_id"],
4756 "finished" => (bool) $row["state"]);
4757 }
4758 return array("code" => $a_code, "runs" => $res);
4759 }

References $user_id, and ANONYMOUS_USER_ID.

◆ getVariables()

ilObjSurvey::getVariables ( int  $question_id)

Returns all variables (answer options/scale values) of a question.

Todo:
move to (pool?) question manager/repo

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

2134 : array {
2135 $ilDB = $this->db;
2136
2137 $result_array = array();
2138 $result = $ilDB->queryF(
2139 "SELECT svy_variable.*, svy_category.title FROM svy_variable LEFT JOIN " .
2140 "svy_category ON svy_variable.category_fi = svy_category.category_id WHERE svy_variable.question_fi = %s " .
2141 "ORDER BY svy_variable.sequence",
2142 array('integer'),
2143 array($question_id)
2144 );
2145 while ($row = $ilDB->fetchObject($result)) {
2146 $result_array[$row->sequence] = $row;
2147 }
2148 return $result_array;
2149 }

◆ getWorkingtimeForParticipant()

ilObjSurvey::getWorkingtimeForParticipant ( int  $finished_id)
Todo:
move to run manager?

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

4147 : int {
4148 $ilDB = $this->db;
4149
4150 $result = $ilDB->queryF(
4151 "SELECT * FROM svy_times WHERE finished_fi = %s",
4152 array('integer'),
4153 array($finished_id)
4154 );
4155 $total = 0;
4156 while ($row = $ilDB->fetchAssoc($result)) {
4157 if ($row['left_page'] > 0 && $row['entered_page'] > 0) {
4158 $total += $row['left_page'] - $row['entered_page'];
4159 }
4160 }
4161 return $total;
4162 }

◆ hasAnonymizedResults()

ilObjSurvey::hasAnonymizedResults ( )

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

974 : bool
975 {
976 return ($this->getAnonymize() === self::ANONYMIZE_ON ||
977 $this->getAnonymize() === self::ANONYMIZE_FREEACCESS);
978 }

◆ hasAnonymousUserList()

ilObjSurvey::hasAnonymousUserList ( )

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

5526 : bool
5527 {
5528 return $this->anon_user_list;
5529 }

◆ hasEnded()

ilObjSurvey::hasEnded ( )

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

1247 : bool
1248 {
1249 $end = $this->getEndDate();
1250 if ($end) {
1252 return ($end_date->get(IL_CAL_UNIX) < time());
1253 }
1254 return false;
1255 }
const IL_CAL_TIMESTAMP

References IL_CAL_TIMESTAMP, and IL_CAL_UNIX.

◆ hasMailConfirmation()

ilObjSurvey::hasMailConfirmation ( )

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

5516 : bool
5517 {
5519 }

◆ hasMailOwnResults()

ilObjSurvey::hasMailOwnResults ( )

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

5506 : bool
5507 {
5509 }

◆ hasQuestions()

ilObjSurvey::hasQuestions ( )

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

505 : bool
506 {
507 return count($this->questions);
508 }

◆ hasStarted()

ilObjSurvey::hasStarted ( )

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

1237 : bool
1238 {
1239 $start = $this->getStartDate();
1240 if ($start) {
1242 return ($start_date->get(IL_CAL_UNIX) < time());
1243 }
1244 return true;
1245 }

References IL_CAL_TIMESTAMP, and IL_CAL_UNIX.

◆ hasViewOwnResults()

ilObjSurvey::hasViewOwnResults ( )

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

5496 : bool
5497 {
5499 }

◆ importObject()

ilObjSurvey::importObject ( array  $file_info,
int  $svy_qpl_id 
)
Exceptions
ilException
ilImportException
ilInvalidSurveyImportFileException
Returns
string error
Todo:
move to export sub-service

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

3166 : string {
3167 if ($svy_qpl_id < 1) {
3168 $svy_qpl_id = -1;
3169 }
3170 // check if file was uploaded
3171 $source = $file_info["tmp_name"];
3172 $error = "";
3173 if (($source === 'none') || (!$source) || $file_info["error"] > UPLOAD_ERR_OK) {
3174 $error = $this->lng->txt("import_no_file_selected");
3175 }
3176 // check correct file type
3177 $isXml = false;
3178 $isZip = false;
3179 if ((strcmp($file_info["type"], "text/xml") === 0) || (strcmp($file_info["type"], "application/xml") === 0)) {
3180 $this->svy_log->debug("isXML");
3181 $isXml = true;
3182 }
3183 // too many different mime-types, so we use the suffix
3184 $suffix = pathinfo($file_info["name"]);
3185 if (strcmp(strtolower($suffix["extension"]), "zip") === 0) {
3186 $this->svy_log->debug("isZip");
3187 $isZip = true;
3188 }
3189 if (!$isXml && !$isZip) {
3190 $error = $this->lng->txt("import_wrong_file_type");
3191 $this->svy_log->debug("Survey: Import error. Filetype was \"" . $file_info["type"] . "\"");
3192 }
3193 if ($error === '') {
3194 // import file as a survey
3195 $import_dir = $this->getImportDirectory();
3196 $import_subdir = "";
3197 $importfile = "";
3198 if ($isZip) {
3199 $importfile = $import_dir . "/" . $file_info["name"];
3200 ilFileUtils::moveUploadedFile($source, $file_info["name"], $importfile);
3201 $this->domain->resources()->zip()->unzipFile($importfile);
3202 $found = $this->locateImportFiles($import_dir);
3203 if (!((strlen($found["dir"]) > 0) && (strlen($found["xml"]) > 0))) {
3204 $error = $this->lng->txt("wrong_import_file_structure");
3205 return $error;
3206 }
3207 $importfile = $found["xml"];
3208 $import_subdir = $found["dir"];
3209 } else {
3210 $importfile = tempnam($import_dir, "survey_import");
3211 ilFileUtils::moveUploadedFile($source, $file_info["name"], $importfile);
3212 }
3213
3214 $this->svy_log->debug("Import file = $importfile");
3215 $this->svy_log->debug("Import subdir = $import_subdir");
3216
3217 $fh = fopen($importfile, 'rb');
3218 if (!$fh) {
3219 $error = $this->lng->txt("import_error_opening_file");
3220 return $error;
3221 }
3222 $xml = fread($fh, filesize($importfile));
3223 $result = fclose($fh);
3224 if (!$result) {
3225 $error = $this->lng->txt("import_error_closing_file");
3226 return $error;
3227 }
3228
3229 $this->import_manager->clearMobs();
3230 if (strpos($xml, "questestinterop")) {
3231 throw new ilInvalidSurveyImportFileException("Unsupported survey version (< 3.8) found.");
3232 } else {
3233 $this->svy_log->debug("survey id = " . $this->getId());
3234 $this->svy_log->debug("question pool id = " . $svy_qpl_id);
3235
3236 $imp = new ilImport();
3237 $config = $imp->getConfig("components/ILIAS/Survey");
3238 $config->setQuestionPoolID($svy_qpl_id);
3239 $imp->getMapping()->addMapping("components/ILIAS/Survey", "svy", 0, $this->getId());
3240 $imp->importFromDirectory($import_subdir, "svy", "components/ILIAS/Survey");
3241 $this->svy_log->debug("config(Modules/survey)->getQuestionPoolId =" . $config->getQuestionPoolID());
3242 }
3243 }
3244 return $error;
3245 }
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
Import class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
locateImportFiles(string $a_dir)
Locates the import directory and the xml file in a directory with an unzipped import file.
ilErrorHandling $error

◆ importSurveyCode()

ilObjSurvey::importSurveyCode ( string  $a_anonymize_key,
int  $a_created,
array  $a_data 
)
Todo:
move to code manager

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

3745 : void {
3746 $ilDB = $this->db;
3747
3748 $next_id = $ilDB->nextId('svy_anonymous');
3749 $ilDB->manipulateF(
3750 "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) " .
3751 "VALUES (%s, %s, %s, %s, %s)",
3752 array('integer','text','integer','text','integer'),
3753 array($next_id, $a_anonymize_key, $this->getSurveyId(), serialize($a_data), $a_created)
3754 );
3755 }

◆ initServices()

ilObjSurvey::initServices ( )
protected

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

194 : void
195 {
196 if ($this->getRefId() > 0) {
197 $this->code_manager = $this
198 ->survey_service
199 ->domain()
200 ->code($this, $this->user->getId());
201 }
202 $this->feature_config = $this
203 ->survey_service
204 ->domain()
205 ->modeFeatureConfig($this->getMode());
206
207 $this->data_manager = $this
208 ->survey_service
209 ->data();
210 }

References getMode(), ilObject\getRefId(), and ILIAS\Repository\user().

Referenced by __construct(), and read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertQuestion()

ilObjSurvey::insertQuestion ( int  $question_id)

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

Todo:
move to survey question manager/repo

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

552 : bool {
554
555 $this->svy_log->debug("insert question, id:" . $question_id);
556 if (!SurveyQuestion::_isComplete($question_id)) {
557 $this->svy_log->debug("question is not complete");
558 return false;
559 } else {
560 // get maximum sequence index in test
561 $result = $ilDB->queryF(
562 "SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
563 array('integer'),
564 array($this->getSurveyId())
565 );
566 $sequence = $result->numRows();
567 $duplicate_id = $this->duplicateQuestionForSurvey($question_id);
568 $this->svy_log->debug("duplicate, id: " . $question_id . ", duplicate id: " . $duplicate_id);
569
570 // check if question is not already in the survey, see #22018
571 if ($this->isQuestionInSurvey($duplicate_id)) {
572 return false;
573 }
574
575 $next_id = $ilDB->nextId('svy_svy_qst');
576 $affectedRows = $ilDB->manipulateF(
577 "INSERT INTO svy_svy_qst (survey_question_id, survey_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
578 array('integer', 'integer', 'integer', 'integer', 'integer'),
579 array($next_id, $this->getSurveyId(), $duplicate_id, $sequence, time())
580 );
581
582 $this->svy_log->debug("added entry to svy_svy_qst, id: " . $next_id . ", question id: " . $duplicate_id . ", sequence: " . $sequence);
583
584 $this->loadQuestionsFromDb();
585 $this->saveCompletionStatus();
586 return true;
587 }
588 }
static _isComplete(int $question_id)
Checks whether the question is complete or not.
isQuestionInSurvey(int $a_question_fi)
saveCompletionStatus()
Saves the completion status of the survey.
duplicateQuestionForSurvey(int $question_id, bool $a_force=false)
Takes a question and creates a copy of the question for use in the survey.

◆ insertQuestionblock()

ilObjSurvey::insertQuestionblock ( int  $questionblock_id)

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

610 : void {
611
612 $sequence_manager = $this->survey_service->domain()->sequence(
613 $this->getSurveyId(),
614 $this
615 );
616
618 $result = $ilDB->queryF(
619 "SELECT svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.show_blocktitle," .
620 " svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst, svy_svy_qst" .
621 " WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi" .
622 " AND svy_svy_qst.question_fi = svy_qblk_qst.question_fi" .
623 " AND svy_qblk.questionblock_id = %s" .
624 " ORDER BY svy_svy_qst.sequence",
625 array('integer'),
626 array($questionblock_id)
627 );
628 $questions = array();
629 $show_questiontext = false;
630 $show_blocktitle = false;
631 $title = "";
632 while ($row = $ilDB->fetchAssoc($result)) {
633 //$duplicate_id = $this->duplicateQuestionForSurvey($row["question_fi"]);
634 $duplicate_id = $sequence_manager->appendQuestion($row["question_fi"], true);
635 $questions[] = $duplicate_id;
636 $title = (string) $row["title"];
637 $show_questiontext = (bool) $row["show_questiontext"];
638 $show_blocktitle = (bool) $row["show_blocktitle"];
639 }
640 $this->createQuestionblock($title, $show_questiontext, $show_blocktitle, $questions);
641 }
createQuestionblock(string $title, bool $show_questiontext, bool $show_blocktitle, array $questions, bool $compress_view=false)

◆ is360SurveyStarted()

ilObjSurvey::is360SurveyStarted ( int  $appr_id,
int  $user_id,
?string  $anonymous_code = null 
)
Todo:
move to appraisal manager

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

4672 : ?int {
4673 $ilDB = $this->db;
4674
4675 $sql = "SELECT * FROM svy_finished" .
4676 " WHERE survey_fi =" . $ilDB->quote($this->getSurveyId(), "integer") .
4677 " AND appr_id = " . $ilDB->quote($appr_id, "integer");
4678 if ($user_id) {
4679 $sql .= " AND user_fi = " . $ilDB->quote($user_id, "integer");
4680 } else {
4681 $sql .= " AND anonymous_id = " . $ilDB->quote($anonymous_code, "text");
4682 }
4683 $result = $ilDB->query($sql);
4684 if ($result->numRows() === 0) {
4685 return null;
4686 } else {
4687 $row = $ilDB->fetchAssoc($result);
4688 return (int) $row["state"];
4689 }
4690 }

References $ilDB, and $user_id.

◆ isAccessibleWithoutCode()

ilObjSurvey::isAccessibleWithoutCode ( )

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

967 : bool
968 {
969 return ($this->getAnonymize() === self::ANONYMIZE_OFF ||
970 $this->getAnonymize() === self::ANONYMIZE_FREEACCESS);
971 }

◆ isActivationLimited()

ilObjSurvey::isActivationLimited ( )

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

1307 : bool
1308 {
1310 }

◆ isAnonymizedParticipant()

ilObjSurvey::isAnonymizedParticipant ( string  $key)
Parameters
string$key(access code)
Todo:
move to participant manager

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

3553 : bool
3554 {
3555 $ilDB = $this->db;
3556
3557 $result = $ilDB->queryF(
3558 "SELECT finished_id FROM svy_finished WHERE anonymous_id = %s AND survey_fi = %s",
3559 array('text','integer'),
3560 array($key, $this->getSurveyId())
3561 );
3562 return $result->numRows() === 1;
3563 }

References $ilDB.

◆ isAppraisee()

ilObjSurvey::isAppraisee ( int  $a_user_id)
Todo:
move to appraisal manager

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

4393 : bool {
4394 $ilDB = $this->db;
4395 $set = $ilDB->query("SELECT user_id" .
4396 " FROM svy_360_appr" .
4397 " WHERE obj_id = " . $ilDB->quote($this->getSurveyId(), "integer") .
4398 " AND user_id = " . $ilDB->quote($a_user_id, "integer"));
4399 return (bool) $ilDB->numRows($set);
4400 }

Referenced by ILIAS\Survey\Participants\StatusManager\canAddItselfAsAppraisee(), and ILIAS\Survey\Participants\StatusManager\isAppraisee().

+ Here is the caller graph for this function:

◆ isAppraiseeClosed()

ilObjSurvey::isAppraiseeClosed ( int  $a_user_id)
Todo:
move to appraisal manager

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

4407 : bool {
4408 $ilDB = $this->db;
4409
4410 $set = $ilDB->query("SELECT has_closed" .
4411 " FROM svy_360_appr" .
4412 " WHERE obj_id = " . $ilDB->quote($this->getSurveyId(), "integer") .
4413 " AND user_id = " . $ilDB->quote($a_user_id, "integer"));
4414 $row = $ilDB->fetchAssoc($set);
4415 return (bool) ($row["has_closed"] ?? false);
4416 }

◆ isComplete()

ilObjSurvey::isComplete ( )

Check if survey is complete for use.

Todo:
move to survey manager

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

500 : bool
501 {
502 return ($this->getTitle() && count($this->questions));
503 }

References ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle().

+ Here is the call graph for this function:

◆ isHTML()

ilObjSurvey::isHTML ( string  $a_text)

Checks if a given string contains HTML or not.

Todo:
move to export sub-service

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

3998 : bool {
3999 if (preg_match("/<[^>]*?>/", $a_text)) {
4000 return true;
4001 } else {
4002 return false;
4003 }
4004 }

◆ isQuestionInAnyBlock()

ilObjSurvey::isQuestionInAnyBlock ( int  $a_question_fi)
Todo:
move to survey question manager/repo

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

1571 : bool {
1572 global $DIC;
1573
1574 $ilDB = $DIC->database();
1575
1576 $set = $ilDB->query("SELECT * FROM svy_qblk_qst " .
1577 " WHERE survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer") .
1578 " AND question_fi = " . $ilDB->quote($a_question_fi, "integer"));
1579 if ($rec = $ilDB->fetchAssoc($set)) {
1580 return true;
1581 }
1582 return false;
1583 }

◆ isQuestionInSurvey()

ilObjSurvey::isQuestionInSurvey ( int  $a_question_fi)

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

593 : bool {
594 global $DIC;
595 //return false;
596 $ilDB = $DIC->database();
597
598 $set = $ilDB->query("SELECT * FROM svy_svy_qst " .
599 " WHERE survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer") .
600 " AND question_fi = " . $ilDB->quote($a_question_fi, "integer"));
601 if ($rec = $ilDB->fetchAssoc($set)) {
602 return true;
603 }
604 return false;
605 }

◆ isRater()

ilObjSurvey::isRater ( int  $a_appraisee_id,
int  $a_user_id,
int  $a_anonymous_id = 0 
)
Todo:
move to appraisal manager

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

4514 : bool {
4515 $ilDB = $this->db;
4516
4517 // user is rater if already appraisee and active self-evaluation
4518 if ($this->isAppraisee($a_user_id) &&
4519 $this->get360SelfEvaluation() &&
4520 (!$a_appraisee_id || $a_appraisee_id === $a_user_id)) {
4521 return true;
4522 }
4523
4524 // :TODO: should we get rid of code as well?
4525
4526 $sql = "SELECT user_id" .
4527 " FROM svy_360_rater" .
4528 " WHERE obj_id = " . $ilDB->quote($this->getSurveyId(), "integer") .
4529 " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
4530 " AND anonymous_id = " . $ilDB->quote($a_anonymous_id, "integer");
4531 if ($a_appraisee_id) {
4532 $sql .= " AND appr_id = " . $ilDB->quote($a_appraisee_id, "integer");
4533 }
4534 $set = $ilDB->query($sql);
4535 return (bool) $ilDB->numRows($set);
4536 }

◆ isSurveyCodeUnique()

ilObjSurvey::isSurveyCodeUnique ( string  $code)
Todo:
move to code manager

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

3728 : bool {
3729 $ilDB = $this->db;
3730 $result = $ilDB->queryF(
3731 "SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
3732 array('integer','text'),
3733 array($this->getSurveyId(), $code)
3734 );
3735 return !(($result->numRows() > 0));
3736 }

◆ isSurveyCodeUsed()

ilObjSurvey::isSurveyCodeUsed ( string  $code)
Todo:
move to code manager

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

3713 : bool {
3714 $ilDB = $this->db;
3715 $result = $ilDB->queryF(
3716 "SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
3717 array('integer','text'),
3718 array($this->getSurveyId(), $code)
3719 );
3720 return $result->numRows() > 0;
3721 }

◆ isSurveyFinishedByCode()

ilObjSurvey::isSurveyFinishedByCode ( string  $a_code)

Get if survey is finished for a specific anonymous user code.

Parameters
string$a_codeanonymous user code
Returns
bool
Todo:
move to run manager

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

3877 : bool
3878 {
3879 $result = $this->db->queryF(
3880 "SELECT state FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
3881 array('integer','text'),
3882 array($this->getSurveyId(), $a_code)
3883 );
3884
3885 $row = $this->db->fetchAssoc($result);
3886
3887 return $row['state'] ?? false;
3888 }

◆ isUnusedCode()

ilObjSurvey::isUnusedCode ( string  $a_code,
int  $a_user_id 
)
Todo:
move to code manager

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

4785 : bool {
4786 $ilDB = $this->db;
4787
4788 $set = $ilDB->query("SELECT user_fi FROM svy_finished" .
4789 " WHERE survey_fi = " . $ilDB->quote($this->getSurveyId(), "integer") .
4790 " AND anonymous_id = " . $ilDB->quote($a_code, "text"));
4791 $user_id = $ilDB->fetchAssoc($set);
4792 $user_id = (int) $user_id["user_fi"];
4793
4794 if ($user_id && ($user_id !== $a_user_id || $user_id === ANONYMOUS_USER_ID)) {
4795 return false;
4796 }
4797 return true;
4798 }

◆ loadFromDb()

ilObjSurvey::loadFromDb ( )

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

980 : void
981 {
983 $result = $ilDB->queryF(
984 "SELECT * FROM svy_svy WHERE obj_fi = %s",
985 array('integer'),
986 array($this->getId())
987 );
988 if ($result->numRows() === 1) {
989 $data = $ilDB->fetchAssoc($result);
990 $this->setSurveyId($data["survey_id"]);
991 $this->setAuthor($data["author"] ?? "");
992 $this->setIntroduction(ilRTE::_replaceMediaObjectImageSrc((string) $data["introduction"], 1));
993 if ($data["outro"] === "survey_finished") {
994 $this->setOutro($this->lng->txt("survey_finished"));
995 } else {
996 $this->setOutro(ilRTE::_replaceMediaObjectImageSrc((string) $data["outro"], 1));
997 }
998 $this->setShowQuestionTitles((bool) $data["show_question_titles"]);
999 $this->setStartDate((string) ($data["startdate"] ?? ""));
1000 $this->setEndDate((string) ($data["enddate"] ?? ""));
1001 $this->setAnonymize((int) $data["anonymize"]);
1002 $this->setEvaluationAccess($data["evaluation_access"] ?? "");
1003 $this->loadQuestionsFromDb();
1004 $this->setMailNotification((bool) $data['mailnotification']);
1005 $this->setMailAddresses((string) $data['mailaddresses']);
1006 $this->setMailParticipantData((string) $data['mailparticipantdata']);
1007 $this->setPoolUsage((bool) $data['pool_usage']);
1008 // Mode
1009 $this->setMode($data['mode']);
1010 // 360°
1011 $this->set360SelfEvaluation((bool) $data['mode_360_self_eval']);
1012 $this->set360SelfRaters((bool) $data['mode_360_self_rate']);
1013 $this->set360SelfAppraisee((bool) $data['mode_360_self_appr']);
1014 $this->set360Results((int) $data['mode_360_results']);
1015 // Mode self evaluated
1016 $this->setSelfEvaluationResults((int) $data['mode_self_eval_results']);
1017 // Competences
1018 $this->setSkillService((bool) $data['mode_skill_service']);
1019 // reminder/notification
1020 $this->setReminderStatus((bool) $data["reminder_status"]);
1021 $this->setReminderStart($data["reminder_start"] ? new ilDate($data["reminder_start"], IL_CAL_DATE) : null);
1022 $this->setReminderEnd($data["reminder_end"] ? new ilDate($data["reminder_end"], IL_CAL_DATE) : null);
1023 $this->setReminderFrequency((int) $data["reminder_frequency"]);
1024 $this->setReminderTarget((int) $data["reminder_target"]);
1025 $this->setReminderLastSent((string) $data["reminder_last_sent"]);
1026 $this->setReminderTemplate((int) $data["reminder_tmpl"]);
1027 $this->setTutorNotificationStatus($data["tutor_ntf_status"]);
1028 $this->setTutorNotificationRecipients(explode(";", $data["tutor_ntf_reci"] ?? ""));
1029 $this->setTutorNotificationTarget($data["tutor_ntf_target"]);
1030 $this->setTutorResultsStatus((bool) $data["tutor_res_status"]);
1031 $this->setTutorResultsRecipients(explode(";", $data["tutor_res_reci"] ?? ""));
1032
1033 $this->setMailOwnResults((bool) $data["own_results_mail"]);
1034 $this->setMailConfirmation((bool) $data["confirmation_mail"]);
1035 $this->setCalculateSumScore((bool) $data["calculate_sum_score"]);
1036
1037 $this->setAnonymousUserList((bool) $data["anon_user_list"]);
1038 }
1039
1040 // moved activation to ilObjectActivation
1041 if (isset($this->ref_id) && $this->ref_id !== 0) {
1042 $activation = ilObjectActivation::getItem($this->ref_id);
1043 switch ($activation["timing_type"]) {
1045 $this->setActivationLimited(true);
1046 $this->setActivationStartDate($activation["timing_start"]);
1047 $this->setActivationEndDate($activation["timing_end"]);
1048 $this->setActivationVisibility($activation["visible"]);
1049 break;
1050
1051 default:
1052 $this->setActivationLimited(false);
1053 break;
1054 }
1055 }
1056 }
set360SelfAppraisee(bool $a_value)
setMode(int $a_value)
setAnonymousUserList(bool $a_value)
setReminderStatus(bool $a_value)
setSelfEvaluationResults(int $a_value)
setTutorNotificationStatus(bool $a_value)
Activates mail being sent to tutors after all participants have finished the survey.
set360Results(int $a_value)
setSurveyId(int $survey_id)
setOutro(string $outro="")
setTutorResultsRecipients(array $a_value)
setReminderTemplate(?int $a_value)
setSkillService(bool $a_val)
setActivationEndDate(?int $ending_time=null)
setIntroduction(string $introduction="")
setEndDate(string $end_date="")
setStartDate(string $start_date="")
setReminderFrequency(int $a_value)
setShowQuestionTitles(bool $a_show)
setActivationStartDate(?int $starting_time=null)
setTutorResultsStatus(bool $a_value)
setActivationVisibility(bool $a_value)
setMailNotification(bool $a_notification)
Activate mail to tutors each time a participant finishes the survey.
setTutorNotificationRecipients(array $a_value)
Set tutor recipients for "all participants have finished" mail.
setReminderTarget(int $a_value)
setMailParticipantData(string $a_data)
Set preceding text (incl.
setCalculateSumScore(bool $a_val)
setTutorNotificationTarget(int $a_value)
setEvaluationAccess(string $evaluation_access=self::EVALUATION_ACCESS_OFF)
setMailConfirmation(bool $a_value)
setReminderStart(?ilDate $a_value=null)
setReminderEnd(?ilDate $a_value=null)
setAnonymize(int $a_anonymize)
set anonymize status
set360SelfRaters(bool $a_value)
setMailAddresses(string $a_addresses)
Set (Tutor) Recipients of "single participant has finished" mails.
setActivationLimited(bool $a_value)
setPoolUsage(bool $a_value)
setMailOwnResults(bool $a_value)
set360SelfEvaluation(bool $a_value)
setAuthor(string $author="")

References $data, $ilDB, ilRTE\_replaceMediaObjectImageSrc(), ILIAS\Survey\Mode\getId(), ilObjectActivation\getItem(), IL_CAL_DATE, ILIAS\Repository\lng(), and ilObjectActivation\TIMINGS_ACTIVATION.

Referenced by read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadQuestionsFromDb()

ilObjSurvey::loadQuestionsFromDb ( )

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

1058 : void
1059 {
1060 $ilDB = $this->db;
1061 $this->questions = array();
1062 $result = $ilDB->queryF(
1063 "SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
1064 array('integer'),
1065 array($this->getSurveyId())
1066 );
1067 while ($data = $ilDB->fetchAssoc($result)) {
1068 $this->questions[$data["sequence"]] = $data["question_fi"];
1069 }
1070 }

References $data, and $ilDB.

◆ loadWorkingData()

ilObjSurvey::loadWorkingData ( int  $question_id,
int  $active_id 
)

Gets the given answer data of a question in a run.

Todo:
move to run(?) manager/repo

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

2295 : array {
2296 $ilDB = $this->db;
2297 $result_array = array();
2298 $result = $ilDB->queryF(
2299 "SELECT * FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
2300 array('integer','integer'),
2301 array($question_id, $active_id)
2302 );
2303 if ($result->numRows() >= 1) {
2304 while ($row = $ilDB->fetchAssoc($result)) {
2305 $result_array[] = $row;
2306 }
2307 }
2308 return $result_array;
2309 }

◆ locateImportFiles()

ilObjSurvey::locateImportFiles ( string  $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)
Todo:
move to export sub-service

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

3116 : ?array {
3117 if (!is_dir($a_dir) || is_int(strpos($a_dir, ".."))) {
3118 return null;
3119 }
3120 $importDirectory = "";
3121 $xmlFile = "";
3122
3123 $current_dir = opendir($a_dir);
3124 $files = array();
3125 while ($entryname = readdir($current_dir)) {
3126 $files[] = $entryname;
3127 }
3128
3129 foreach ($files as $file) {
3130 if (is_dir($a_dir . "/" . $file) and ($file !== "." and $file !== "..")) {
3131 // found directory created by zip
3132 $importDirectory = $a_dir . "/" . $file;
3133 }
3134 }
3135 closedir($current_dir);
3136 if ($importDirectory !== '') {
3137 // find the xml file
3138 $current_dir = opendir($importDirectory);
3139 $files = array();
3140 while ($entryname = readdir($current_dir)) {
3141 $files[] = $entryname;
3142 }
3143 foreach ($files as $file) {
3144 if (is_file($importDirectory . "/" . $file) &&
3145 ($file !== "." && $file !== "..") &&
3146 (preg_match("/^[0-9]{10}__[0-9]+__(svy_)*[0-9]+\.[A-Za-z]{1,3}$/", $file) ||
3147 preg_match("/^[0-9]{10}__[0-9]+__(survey__)*[0-9]+\.[A-Za-z]{1,3}$/", $file))) {
3148 // found xml file
3149 $xmlFile = $importDirectory . "/" . $file;
3150 }
3151 }
3152 }
3153 return array("dir" => $importDirectory, "xml" => $xmlFile);
3154 }

◆ modifyQuestionblock()

ilObjSurvey::modifyQuestionblock ( int  $questionblock_id,
string  $title,
bool  $show_questiontext,
bool  $show_blocktitle,
bool  $compress_view = false 
)
Todo:
move to survey question manager/repo

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

1745 : void {
1746 $ilDB = $this->db;
1747 $ilDB->manipulateF(
1748 "UPDATE svy_qblk SET title = %s, show_questiontext = %s," .
1749 " show_blocktitle = %s, compress_view = %s WHERE questionblock_id = %s",
1750 array('text','text','text','integer', 'integer'),
1751 array($title, $show_questiontext, $show_blocktitle, $compress_view, $questionblock_id)
1752 );
1753 }

◆ moveQuestions()

ilObjSurvey::moveQuestions ( array  $move_questions,
int  $target_index,
int  $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
int$target_indexThe question id of the target position
int$insert_mode0, if insert before the target position, 1 if insert after the target position
Todo:
move to survey question manager/repo

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

1371 : void {
1372 $array_pos = array_search($target_index, $this->questions);
1373 $part1 = $part2 = [];
1374 if ($insert_mode === 0) {
1375 $part1 = array_slice($this->questions, 0, $array_pos);
1376 $part2 = array_slice($this->questions, $array_pos);
1377 } elseif ($insert_mode === 1) {
1378 $part1 = array_slice($this->questions, 0, $array_pos + 1);
1379 $part2 = array_slice($this->questions, $array_pos + 1);
1380 }
1381 $found = 0;
1382 foreach ($move_questions as $question_id) {
1383 if (!(!in_array($question_id, $part1))) {
1384 unset($part1[array_search($question_id, $part1)]);
1385 $found++;
1386 }
1387 if (!(!in_array($question_id, $part2))) {
1388 unset($part2[array_search($question_id, $part2)]);
1389 $found++;
1390 }
1391 }
1392 // sanity check: do not move questions if they have not be found in the array
1393 if ($found !== count($move_questions)) {
1394 return;
1395 }
1396 $part1 = array_values($part1);
1397 $part2 = array_values($part2);
1398 $this->questions = array_values(array_merge($part1, $move_questions, $part2));
1399 foreach ($move_questions as $question_id) {
1400 $constraints = $this->getConstraints($question_id);
1401 foreach ($constraints as $idx => $constraint) {
1402 foreach ($part2 as $next_question_id) {
1403 if ($constraint["question"] == $next_question_id) {
1404 // constraint concerning a question that follows -> delete constraint
1405 $this->deleteConstraint($constraint["id"]);
1406 }
1407 }
1408 }
1409 }
1410 $this->saveQuestionsToDb();
1411 }

◆ openAllAppraisees()

ilObjSurvey::openAllAppraisees ( )
Todo:
move to appraisal manager

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

4914 : void
4915 {
4916 $ilDB = $this->db;
4917
4918 $ilDB->manipulate("UPDATE svy_360_appr" .
4919 " SET has_closed = " . $ilDB->quote(null, "integer") .
4920 " WHERE obj_id = " . $ilDB->quote($this->getSurveyId(), "integer"));
4921 }

References $ilDB.

◆ prepareTextareaOutput()

ilObjSurvey::prepareTextareaOutput ( string  $txt_output)

Prepares a string for a text area output in surveys.

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

3988 : string {
3990 }
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free,...

◆ read()

ilObjSurvey::read ( )

Reimplemented from ilObject.

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

250 : void
251 {
252 parent::read();
253 $this->loadFromDb();
254 $this->initServices();
255 }

References initServices(), and loadFromDb().

+ Here is the call graph for this function:

◆ removeConstraintsConcerningQuestion()

ilObjSurvey::removeConstraintsConcerningQuestion ( int  $question_id)

Remove constraints concerning a question with a given question_id.

Todo:
move to constraint manager/repo

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

1433 : void {
1434 $ilDB = $this->db;
1435 $result = $ilDB->queryF(
1436 "SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
1437 array('integer','integer'),
1438 array($question_id, $this->getSurveyId())
1439 );
1440 if ($result->numRows() > 0) {
1441 $remove_constraints = array();
1442 while ($row = $ilDB->fetchAssoc($result)) {
1443 $remove_constraints[] = $row["constraint_fi"];
1444 }
1445 $affectedRows = $ilDB->manipulateF(
1446 "DELETE FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
1447 array('integer','integer'),
1448 array($question_id, $this->getSurveyId())
1449 );
1450 foreach ($remove_constraints as $key => $constraint_id) {
1451 $affectedRows = $ilDB->manipulateF(
1452 "DELETE FROM svy_constraint WHERE constraint_id = %s",
1453 array('integer'),
1454 array($constraint_id)
1455 );
1456 }
1457 }
1458 }

References $ilDB.

◆ removeQuestion()

ilObjSurvey::removeQuestion ( int  $question_id)
Todo:
move to survey question manager/repo

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

1418 : void {
1419 $question = self::_instanciateQuestion($question_id);
1420 #20610 if no question found, do nothing.
1421 if ($question) {
1422 $question->delete($question_id);
1423 $this->removeConstraintsConcerningQuestion($question_id);
1424 }
1425 }
removeConstraintsConcerningQuestion(int $question_id)
Remove constraints concerning a question with a given question_id.

Referenced by delete().

+ Here is the caller graph for this function:

◆ removeQuestionFromBlock()

ilObjSurvey::removeQuestionFromBlock ( int  $question_id,
int  $questionblock_id 
)
Todo:
move to survey question manager/repo

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

1533 : void {
1534 $ilDB = $this->db;
1535
1536 $ilDB->manipulateF(
1537 "DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s AND question_fi = %s",
1538 array('integer','integer','integer'),
1539 array($questionblock_id, $this->getSurveyId(), $question_id)
1540 );
1541 }

◆ removeQuestions()

ilObjSurvey::removeQuestions ( array  $remove_questions,
array  $remove_questionblocks 
)
Parameters
int[]$remove_questionsquestion ids of the questions to remove
int[]$remove_questionblocksquestionblock ids of the questions blocks to remove
Todo:
move to survey question manager/repo

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

1468 : void {
1469 $ilDB = $this->db;
1470
1471 $block_sizes = array();
1472 foreach ($this->getSurveyQuestions() as $question_id => $data) {
1473 if (in_array($question_id, $remove_questions) or in_array($data["questionblock_id"], $remove_questionblocks)) {
1474 unset($this->questions[array_search($question_id, $this->questions)]);
1475 $this->removeQuestion($question_id);
1476 } elseif ($data["questionblock_id"]) {
1477 $block_sizes[$data["questionblock_id"]] = ($block_sizes[$data["questionblock_id"]] ?? 0) + 1;
1478 }
1479 }
1480
1481 // blocks with just 1 question need to be deleted
1482 foreach ($block_sizes as $block_id => $size) {
1483 if ($size < 2) {
1484 $remove_questionblocks[] = $block_id;
1485 }
1486 }
1487
1488 foreach (array_unique($remove_questionblocks) as $questionblock_id) {
1489 $affectedRows = $ilDB->manipulateF(
1490 "DELETE FROM svy_qblk WHERE questionblock_id = %s",
1491 array('integer'),
1492 array($questionblock_id)
1493 );
1494 $affectedRows = $ilDB->manipulateF(
1495 "DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
1496 array('integer','integer'),
1497 array($questionblock_id, $this->getSurveyId())
1498 );
1499 }
1500
1501 $this->questions = array_values($this->questions);
1502 $this->saveQuestionsToDb();
1503 }

◆ removeSelectedSurveyResults()

ilObjSurvey::removeSelectedSurveyResults ( array  $finished_ids)

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

Todo:
move to run manager/repo

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

402 : void {
404
405 $user_ids = [];
406
407 foreach ($finished_ids as $finished_id) {
408 $result = $ilDB->queryF(
409 "SELECT finished_id, user_fi FROM svy_finished WHERE finished_id = %s",
410 array('integer'),
411 array($finished_id)
412 );
413 $row = $ilDB->fetchAssoc($result);
414 if ($row["user_fi"]) {
415 $user_ids[] = (int) $row["user_fi"];
416 }
417
418 $affectedRows = $ilDB->manipulateF(
419 "DELETE FROM svy_answer WHERE active_fi = %s",
420 array('integer'),
421 array($row["finished_id"])
422 );
423
424 $affectedRows = $ilDB->manipulateF(
425 "DELETE FROM svy_finished WHERE finished_id = %s",
426 array('integer'),
427 array($finished_id)
428 );
429
430 $affectedRows = $ilDB->manipulateF(
431 "DELETE FROM svy_times WHERE finished_fi = %s",
432 array('integer'),
433 array($row["finished_id"])
434 );
435 }
436
437 if (count($user_ids)) {
438 $lp_obj = ilObjectLP::getInstance($this->getId());
439 $lp_obj->resetLPDataForUserIds($user_ids);
440
441 // remove invitations, if exist
442 foreach ($user_ids as $user_id) {
443 $this->invitation_manager->remove($this->getSurveyId(), $user_id);
444 }
445 }
446 }

References $ilDB, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ saveAuthorToMetadata()

ilObjSurvey::saveAuthorToMetadata ( string  $a_author = "")

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

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

1137 : void {
1138 if ($a_author === '') {
1139 $ilUser = $this->user;
1140 $a_author = $ilUser->getFullname();
1141 }
1142 $this->domain->metadata()->saveAuthorsInLOMIfNoLifecycleSet(
1143 $this->getId(),
1144 0,
1145 $this->getType(),
1146 $a_author,
1147 );
1148 }

Referenced by doCreateMetaData().

+ Here is the caller graph for this function:

◆ saveCompletionStatus()

ilObjSurvey::saveCompletionStatus ( )

Saves the completion status of the survey.

Todo:
move to survey manager/repo

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

514 : void
515 {
516 $db = $this->db;
517 if ($this->getSurveyId() > 0) {
519 "UPDATE svy_svy SET complete = %s, tstamp = %s WHERE survey_id = %s",
520 array('text','integer','integer'),
521 array($this->isComplete(), time(), $this->getSurveyId())
522 );
523 }
524 }
isComplete()
Check if survey is complete for use.
manipulateF(string $query, array $types, array $values)

◆ saveHeading()

ilObjSurvey::saveHeading ( string  $heading,
int  $insertbefore 
)
Todo:
move to survey question manager
Parameters
string$heading
int$insertbeforequestion id which gets the heading (before)

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

3532 : void {
3533 $ilDB = $this->db;
3534 if ($heading) {
3535 $ilDB->manipulateF(
3536 "UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
3537 array('text','integer','integer'),
3538 array($heading, $this->getSurveyId(), $insertbefore)
3539 );
3540 } else {
3541 $ilDB->manipulateF(
3542 "UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
3543 array('text','integer','integer'),
3544 array(null, $this->getSurveyId(), $insertbefore)
3545 );
3546 }
3547 }

References $ilDB.

◆ saveQuestionsToDb()

ilObjSurvey::saveQuestionsToDb ( )

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

830 : void
831 {
833
834 $this->svy_log->debug("save questions");
835
836 // gather old questions state
837 $old_questions = array();
838 $result = $ilDB->queryF(
839 "SELECT survey_question_id,question_fi,sequence" .
840 " FROM svy_svy_qst WHERE survey_fi = %s",
841 array('integer'),
842 array($this->getSurveyId())
843 );
844 while ($row = $ilDB->fetchAssoc($result)) {
845 $old_questions[$row["question_fi"]] = $row; // problem, as soon as duplicates exist, they will be hidden here
846 }
847
848 // #15231 - diff with current questions state
849 $insert = $update = $delete = array();
850 foreach ($this->questions as $seq => $fi) {
851 if (!array_key_exists($fi, $old_questions)) { // really new fi IDs
852 $insert[] = $fi; // this should be ok, should not create duplicates here
853 } elseif ($old_questions[$fi]["sequence"] != $seq) { // we are updating one of the duplicates (if any)
854 $update[$fi] = $old_questions[$fi]["survey_question_id"];
855 }
856 // keep track of still relevant questions
857 unset($old_questions[$fi]); // deleting old question, if they are not in current array
858 }
859
860 // delete obsolete question relations
861 if (count($old_questions)) {
862 $del_ids = array();
863 foreach ($old_questions as $fi => $old) {
864 $del_ids[] = $old["survey_question_id"];
865 }
866 $ilDB->manipulate($q = "DELETE FROM svy_svy_qst" .
867 " WHERE " . $ilDB->in("survey_question_id", $del_ids, "", "integer"));
868 $this->svy_log->debug("delete: " . $q);
869 }
870 unset($old_questions);
871
872 // create/update question relations
873 foreach ($this->questions as $seq => $fi) {
874 if (in_array($fi, $insert)) {
875 // check if question is not already in the survey, see #22018
876 if (!$this->isQuestionInSurvey($fi)) {
877 $next_id = $ilDB->nextId('svy_svy_qst');
878 $ilDB->manipulateF(
879 "INSERT INTO svy_svy_qst" .
880 " (survey_question_id, survey_fi, question_fi, heading, sequence, tstamp)" .
881 " VALUES (%s, %s, %s, %s, %s, %s)",
882 array('integer', 'integer', 'integer', 'text', 'integer', 'integer'),
883 array($next_id, $this->getSurveyId(), $fi, null, $seq, time())
884 );
885 $this->svy_log->debug("insert svy_svy_qst, id:" . $next_id . ", fi: " . $fi . ", seq:" . $seq);
886 }
887 } elseif (array_key_exists($fi, $update)) {
888 $ilDB->manipulate("UPDATE svy_svy_qst" .
889 " SET sequence = " . $ilDB->quote($seq, "integer") .
890 ", tstamp = " . $ilDB->quote(time(), "integer") .
891 " WHERE survey_question_id = " . $ilDB->quote($update[$fi], "integer"));
892 $this->svy_log->debug("update svy_svy_qst, id:" . $update[$fi] . ", fi: " . $fi . ", seq:" . $seq);
893 }
894 }
895 }

References $ilDB, and $q.

◆ saveToDb()

ilObjSurvey::saveToDb ( )

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

695 : void
696 {
698
699 // date handling
700 $rmd_start = $this->getReminderStart();
701 if (is_object($rmd_start)) {
702 $rmd_start = $rmd_start->get(IL_CAL_DATE);
703 }
704 $rmd_end = $this->getReminderEnd();
705 if (is_object($rmd_end)) {
706 $rmd_end = $rmd_end->get(IL_CAL_DATE);
707 }
708 if ($this->getSurveyId() < 1) {
709 $next_id = $ilDB->nextId('svy_svy');
710 $affectedRows = $ilDB->insert("svy_svy", array(
711 "survey_id" => array("integer", $next_id),
712 "obj_fi" => array("integer", $this->getId()),
713 "author" => array("text", $this->getAuthor()),
714 "introduction" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 0)),
715 "outro" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getOutro(), 0)),
716 "startdate" => array("text", $this->getStartDate()),
717 "enddate" => array("text", $this->getEndDate()),
718 "evaluation_access" => array("text", $this->getEvaluationAccess()),
719 "complete" => array("text", $this->isComplete()),
720 "created" => array("integer", time()),
721 "anonymize" => array("text", $this->getAnonymize()),
722 "show_question_titles" => array("text", $this->getShowQuestionTitles()),
723 "mailnotification" => array('integer', ($this->getMailNotification()) ? 1 : 0),
724 "mailaddresses" => array('text', $this->getMailAddresses()),
725 "mailparticipantdata" => array('text', $this->getMailParticipantData()),
726 "tstamp" => array("integer", time()),
727 // Mode type
728 "mode" => array("integer", $this->getMode()),
729 // 360°
730 "mode_360_self_eval" => array("integer", $this->get360SelfEvaluation()),
731 "mode_360_self_rate" => array("integer", $this->get360SelfRaters()),
732 "mode_360_self_appr" => array("integer", $this->get360SelfAppraisee()),
733 "mode_360_results" => array("integer", $this->get360Results()),
734 // competences
735 "mode_skill_service" => array("integer", (int) $this->getSkillService()),
736 // Self Evaluation Only
737 "mode_self_eval_results" => array("integer", self::RESULTS_SELF_EVAL_OWN),
738 // reminder/notification
739 "reminder_status" => array("integer", (int) $this->getReminderStatus()),
740 "reminder_start" => array("datetime", $rmd_start),
741 "reminder_end" => array("datetime", $rmd_end),
742 "reminder_frequency" => array("integer", $this->getReminderFrequency()),
743 "reminder_target" => array("integer", $this->getReminderTarget()),
744 "reminder_last_sent" => array("datetime", $this->getReminderLastSent()),
745 "reminder_tmpl" => array("text", $this->getReminderTemplate(true)),
746 "tutor_ntf_status" => array("integer", (int) $this->getTutorNotificationStatus()),
747 "tutor_ntf_reci" => array("text", implode(";", $this->getTutorNotificationRecipients())),
748 "tutor_ntf_target" => array("integer", $this->getTutorNotificationTarget()),
749 "own_results_view" => array("integer", $this->hasViewOwnResults()),
750 "own_results_mail" => array("integer", $this->hasMailOwnResults()),
751 "tutor_res_status" => array("integer", (int) $this->getTutorResultsStatus()),
752 "tutor_res_reci" => array("text", implode(";", $this->getTutorResultsRecipients())),
753 "confirmation_mail" => array("integer", $this->hasMailConfirmation()),
754 "anon_user_list" => array("integer", $this->hasAnonymousUserList()),
755 "calculate_sum_score" => array("integer", $this->getCalculateSumScore())
756 ));
757 $this->setSurveyId($next_id);
758 } else {
759 $affectedRows = $ilDB->update("svy_svy", array(
760 "author" => array("text", ilStr::subStr($this->getAuthor(), 0, 50)),
761 "introduction" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getIntroduction(), 0)),
762 "outro" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getOutro(), 0)),
763 "startdate" => array("text", $this->getStartDate()),
764 "enddate" => array("text", $this->getEndDate()),
765 "evaluation_access" => array("text", $this->getEvaluationAccess()),
766 "complete" => array("text", $this->isComplete()),
767 "anonymize" => array("text", $this->getAnonymize()),
768 "show_question_titles" => array("text", $this->getShowQuestionTitles()),
769 "mailnotification" => array('integer', ($this->getMailNotification()) ? 1 : 0),
770 "mailaddresses" => array('text', $this->getMailAddresses()),
771 "mailparticipantdata" => array('text', $this->getMailParticipantData()),
772 "tstamp" => array("integer", time()),
773 //MODE TYPE
774 "mode" => array("integer", $this->getMode()),
775 // 360°
776 "mode_360_self_eval" => array("integer", $this->get360SelfEvaluation()),
777 "mode_360_self_rate" => array("integer", $this->get360SelfRaters()),
778 "mode_360_self_appr" => array("integer", $this->get360SelfAppraisee()),
779 "mode_360_results" => array("integer", $this->get360Results()),
780 // Competences
781 "mode_skill_service" => array("integer", (int) $this->getSkillService()),
782 // Self Evaluation Only
783 "mode_self_eval_results" => array("integer", $this->getSelfEvaluationResults()),
784 // reminder/notification
785 "reminder_status" => array("integer", $this->getReminderStatus()),
786 "reminder_start" => array("datetime", $rmd_start),
787 "reminder_end" => array("datetime", $rmd_end),
788 "reminder_frequency" => array("integer", $this->getReminderFrequency()),
789 "reminder_target" => array("integer", $this->getReminderTarget()),
790 "reminder_last_sent" => array("datetime", $this->getReminderLastSent()),
791 "reminder_tmpl" => array("text", $this->getReminderTemplate()),
792 "tutor_ntf_status" => array("integer", $this->getTutorNotificationStatus()),
793 "tutor_ntf_reci" => array("text", implode(";", $this->getTutorNotificationRecipients())),
794 "tutor_ntf_target" => array("integer", $this->getTutorNotificationTarget()),
795 "own_results_view" => array("integer", $this->hasViewOwnResults()),
796 "own_results_mail" => array("integer", $this->hasMailOwnResults()),
797 "tutor_res_status" => array("integer", (int) $this->getTutorResultsStatus()),
798 "tutor_res_reci" => array("text", implode(";", $this->getTutorResultsRecipients())),
799 "confirmation_mail" => array("integer", $this->hasMailConfirmation()),
800 "anon_user_list" => array("integer", $this->hasAnonymousUserList()),
801 "calculate_sum_score" => array("integer", $this->getCalculateSumScore())
802 ), array(
803 "survey_id" => array("integer", $this->getSurveyId())
804 ));
805 }
806 if ($affectedRows) {
807 // save questions to db
808 $this->saveQuestionsToDb();
809 }
810
811 // moved activation to ilObjectActivation
812 if ($this->ref_id) {
813 ilObjectActivation::getItem($this->ref_id);
814
815 $item = new ilObjectActivation();
816 if (!$this->isActivationLimited()) {
817 $item->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
818 } else {
819 $item->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
820 $item->setTimingStart($this->getActivationStartDate());
821 $item->setTimingEnd($this->getActivationEndDate());
822 $item->toggleVisible($this->getActivationVisibility());
823 }
824
825 $item->update($this->ref_id);
826 }
827 }
getTutorNotificationRecipients()
Mail being sent to tutors after all participants have finished the survey?
getReminderTemplate(bool $selectDefault=false)
getMailParticipantData()
Preceding text (incl.
getMailAddresses()
(Tutor) Recipients of "single participant has finished" mails
getMailNotification()
Send mail to tutors each time a participant finishes the survey?
Class ilObjectActivation.
static subStr(string $a_str, int $a_start, ?int $a_length=null)
Definition: class.ilStr.php:21

References $ilDB, ilRTE\_replaceMediaObjectImageSrc(), ILIAS\Survey\Mode\getId(), ilObjectActivation\getItem(), IL_CAL_DATE, ilStr\subStr(), ilObjectActivation\TIMINGS_ACTIVATION, and ilObjectActivation\TIMINGS_DEACTIVATED.

Referenced by createReference().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveUserAccessCode()

ilObjSurvey::saveUserAccessCode ( int  $user_id,
string  $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
Todo:
move to code manager

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

3938 : void {
3939 $ilDB = $this->db;
3940
3941 // not really sure what to do about ANONYMOUS_USER_ID
3942
3943 $next_id = $ilDB->nextId('svy_anonymous');
3944 $affectedRows = $ilDB->manipulateF(
3945 "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, user_key, tstamp) " .
3946 "VALUES (%s, %s, %s, %s, %s)",
3947 array('integer','text', 'integer', 'text', 'integer'),
3948 array($next_id, $access_code, $this->getSurveyId(), md5($user_id), time())
3949 );
3950 }

◆ saveUserSettings()

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

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

649 : void {
651
652 $next_id = $ilDB->nextId('svy_settings');
653 $affectedRows = $ilDB->insert("svy_settings", array(
654 "settings_id" => array("integer", $next_id),
655 "usr_id" => array("integer", $usr_id),
656 "keyword" => array("text", $key),
657 "title" => array("text", $title),
658 "value" => array("clob", $value)
659 ));
660 }

◆ send360ReminderToUser()

ilObjSurvey::send360ReminderToUser ( int  $a_user_id,
array  $a_appraisee_ids 
)

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

5221 : void {
5222 $this->svy_log->debug("Send mail to:" . $a_user_id);
5223
5224 $ntf = new ilSystemNotification();
5225 $ntf->setLangModules(array("svy", "survey"));
5226 $ntf->setRefId($this->getRefId());
5227 $ntf->setGotoLangId('url');
5228
5229 // user specific language
5230 $lng = $ntf->getUserLanguage($a_user_id);
5231
5232 $ntf->setIntroductionLangId("svy_user_added_rater_reminder_mail");
5233 $subject = str_replace("%1", $this->getTitle(), $lng->txt("svy_user_added_rater"));
5234
5235 foreach ($a_appraisee_ids as $appraisee_id) {
5236 $ntf->addAdditionalInfo("survey_360_appraisee", ilUserUtil::getNamePresentation($appraisee_id, false, false, "", true));
5237 }
5238
5239 // #10044
5240 $mail = new ilMail(ANONYMOUS_USER_ID);
5241 $mail->enqueue(
5242 ilObjUser::_lookupLogin($a_user_id),
5243 "",
5244 "",
5245 $subject,
5246 $ntf->composeAndGetMessage($a_user_id, null, "read", true),
5247 []
5248 );
5249 }
getUserLanguage()
Return language of user.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:

◆ sendAppraiseeCloseNotification()

ilObjSurvey::sendAppraiseeCloseNotification ( int  $a_user_id)
Todo:
move to appraisal manager

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

4333 : void {
4334 $ntf = new ilSystemNotification();
4335 $ntf->setLangModules(array("svy", "survey"));
4336 $ntf->setRefId($this->getRefId());
4337 $ntf->setGotoLangId('url');
4338
4339 // user specific language
4340 $lng = $ntf->getUserLanguage($a_user_id);
4341
4342 $ntf->setIntroductionLangId("svy_user_added_appraisee_close_mail");
4343 $subject = str_replace("%1", $this->getTitle(), $lng->txt("svy_user_added_appraisee"));
4344
4345 // #10044
4346 $mail = new ilMail(ANONYMOUS_USER_ID);
4347 $mail->enqueue(
4348 ilObjUser::_lookupLogin($a_user_id),
4349 "",
4350 "",
4351 $subject,
4352 $ntf->composeAndGetMessage($a_user_id, null, "read", true),
4353 []
4354 );
4355 }

◆ sendAppraiseeNotification()

ilObjSurvey::sendAppraiseeNotification ( int  $a_user_id)
Todo:
move to appraisal manager

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

4304 : void {
4305 $ntf = new ilSystemNotification();
4306 $ntf->setLangModules(array("svy", "survey"));
4307 $ntf->setRefId($this->getRefId());
4308 $ntf->setGotoLangId('url');
4309
4310 // user specific language
4311 $lng = $ntf->getUserLanguage($a_user_id);
4312
4313 $ntf->setIntroductionLangId("svy_user_added_appraisee_mail");
4314 $subject = str_replace("%1", $this->getTitle(), $lng->txt("svy_user_added_appraisee"));
4315
4316 // #10044
4317 $mail = new ilMail(ANONYMOUS_USER_ID);
4318 $mail->enqueue(
4319 ilObjUser::_lookupLogin($a_user_id),
4320 "",
4321 "",
4322 $subject,
4323 $ntf->composeAndGetMessage($a_user_id, null, "read", true),
4324 []
4325 );
4326 }

◆ sendCodes()

ilObjSurvey::sendCodes ( int  $not_sent,
string  $subject,
string  $message,
string  $lang 
)
Todo:
move to code manager

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

3765 : void {
3766 /*
3767 * 0 = all
3768 * 1 = not sent
3769 * 2 = finished
3770 * 3 = not finished
3771 */
3772 $check_finished = ($not_sent > 1);
3773
3774
3775 $mail = new ilMail(ANONYMOUS_USER_ID);
3776 $recipients = $this->getExternalCodeRecipients($check_finished);
3777 foreach ($recipients as $data) {
3778 if ($data['email'] && $data['code']) {
3779 $do_send = false;
3780 switch ($not_sent) {
3781 case 1:
3782 $do_send = !(bool) $data['sent'];
3783 break;
3784
3785 case 2:
3786 $do_send = $data['finished'];
3787 break;
3788
3789 case 3:
3790 $do_send = !$data['finished'];
3791 break;
3792
3793 default:
3794 $do_send = true;
3795 break;
3796 }
3797 if ($do_send) {
3798 // build text
3799 $messagetext = $message;
3800 $url = ilLink::_getLink(
3801 $this->getRefId(),
3802 "svy",
3803 array(
3804 "accesscode" => $data["code"],
3805 "lang" => $lang
3806 )
3807 );
3808 $messagetext = str_replace('[url]', $url, $messagetext);
3809 foreach ($data as $key => $value) {
3810 $messagetext = str_replace('[' . $key . ']', $value, $messagetext);
3811 }
3812
3813 // send mail
3814 $mail->enqueue(
3815 $data['email'], // to
3816 "", // cc
3817 "", // bcc
3818 $subject, // subject
3819 $messagetext, // message
3820 array() // attachments
3821 );
3822 }
3823 }
3824 }
3825
3826 $ilDB = $this->db;
3827 $ilDB->manipulateF(
3828 "UPDATE svy_anonymous SET sent = %s WHERE survey_fi = %s AND externaldata IS NOT NULL",
3829 array('integer','integer'),
3830 array(1, $this->getSurveyId())
3831 );
3832 }
getExternalCodeRecipients(bool $a_check_finished=false)
$url
Definition: shib_logout.php:70

◆ sendNotificationMail()

ilObjSurvey::sendNotificationMail ( int  $a_user_id,
string  $a_anonymize_id,
int  $a_appr_id = 0 
)

These mails are sent to tutors for each single participant that finishes a survey.

It includes the "additional participant data" text that can be set in the settings screen.

Exceptions
ilWACException

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

2393 : void {
2394 // #12755
2395 $placeholders = array(
2396 "FIRST_NAME" => "firstname",
2397 "LAST_NAME" => "lastname",
2398 "LOGIN" => "login",
2399 // old style
2400 "firstname" => "firstname"
2401 );
2402
2403 //mailaddresses is just text split by commas.
2404 //sendMail can send emails if it gets an user id or an email as first parameter.
2405 $recipients = explode(",", $this->mailaddresses ?? "");
2406 foreach ($recipients as $recipient) {
2407 // #11298
2408 $ntf = new ilSystemNotification();
2409 $ntf->setLangModules(array("survey"));
2410 $ntf->setRefId($this->getRefId());
2411 $ntf->setSubjectLangId('finished_mail_subject');
2412
2413 $messagetext = $this->mailparticipantdata;
2414 $data = [];
2415 if (trim($messagetext ?? "")) {
2416 if (!$this->hasAnonymizedResults()) {
2417 $data = ilObjUser::_getUserData(array($a_user_id));
2418 $data = $data[0];
2419 }
2420 foreach ($placeholders as $key => $mapping) {
2421 if ($this->hasAnonymizedResults()) { // #16480
2422 $messagetext = str_replace('[' . $key . ']', '', $messagetext);
2423 } else {
2424 $messagetext = str_replace('[' . $key . ']', trim($data[$mapping] ?? ""), $messagetext);
2425 }
2426 }
2427 $ntf->setIntroductionDirect($messagetext);
2428 } else {
2429 $ntf->setIntroductionLangId('survey_notification_finished_introduction');
2430 }
2431
2432 // 360°? add appraisee data
2433 if ($a_appr_id) {
2434 $ntf->addAdditionalInfo(
2435 'survey_360_appraisee',
2437 );
2438 }
2439
2440 $active_id = $this->getActiveID($a_user_id, $a_anonymize_id, $a_appr_id);
2441 if ($active_id) { // 43908
2442 $ntf->addAdditionalInfo(
2443 'results',
2444 $this->getParticipantTextResults($active_id),
2445 true
2446 );
2447 }
2448
2449 $ntf->setGotoLangId('survey_notification_tutor_link');
2450 $ntf->setReasonLangId('survey_notification_finished_reason');
2451
2452 $recipient = trim($recipient ?? "");
2453 $user_id = (int) ilObjUser::_lookupId($recipient);
2454 if ($user_id > 0) {
2455 $ntf->sendMailAndReturnRecipients([$user_id]);
2456 } else {
2457 $user_ids = ilObjUser::getUserIdsByEmail($recipient);
2458 if (count($user_ids) > 0) {
2459 $ntf->sendMailAndReturnRecipients([current($user_ids)]);
2460 }
2461 }
2462 /* note: this block is replace by the single line above
2463 since the UI asks for account names and the "e-mail" fallback leads
2464 to strange issues like multiple mails. Also the test case has been
2465 adopted, see https://mantis.ilias.de/view.php?id=36327
2466 if (is_numeric($recipient)) {
2467 $lng = $ntf->getUserLanguage((int) $recipient);
2468 $ntf->sendMailAndReturnRecipients([(int) $recipient]);
2469 } else {
2470 $recipient = trim($recipient);
2471 $user_ids = ilObjUser::getUserIdsByEmail($recipient);
2472 if (empty($user_ids)) {
2473 $ntf->sendMailAndReturnRecipients([ilObjUser::_lookupId($recipient)]);
2474 } else {
2475 foreach ($user_ids as $user_id) {
2476 $lng = $ntf->getUserLanguage($user_id);
2477 $ntf->sendMailAndReturnRecipients(array($user_id));
2478 }
2479 }
2480 }*/
2481 }
2482 }
getActiveID(int $user_id, string $anonymize_id, int $appr_id)
Get run id.
getParticipantTextResults(int $active_id)
static _getUserData(array $a_internalids)
static getUserIdsByEmail(string $a_email)
static _lookupId(string|array $a_user_str)

◆ sendRaterNotification()

ilObjSurvey::sendRaterNotification ( int  $a_user_id,
int  $a_appraisee_id 
)
Todo:
move to appraisal manager

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

4363 : void {
4364 $ntf = new ilSystemNotification();
4365 $ntf->setLangModules(array("svy", "survey"));
4366 $ntf->setRefId($this->getRefId());
4367 $ntf->setGotoLangId('url');
4368
4369 // user specific language
4370 $lng = $ntf->getUserLanguage($a_user_id);
4371
4372 $ntf->setIntroductionLangId("svy_user_added_rater_mail");
4373 $subject = str_replace("%1", $this->getTitle(), $lng->txt("svy_user_added_rater"));
4374 $ntf->addAdditionalInfo("survey_360_appraisee", ilUserUtil::getNamePresentation($a_appraisee_id, false, false, "", true));
4375
4376 // #10044
4377 $mail = new ilMail(ANONYMOUS_USER_ID);
4378 $mail->enqueue(
4379 ilObjUser::_lookupLogin($a_user_id),
4380 "",
4381 "",
4382 $subject,
4383 $ntf->composeAndGetMessage($a_user_id, null, "read", true),
4384 []
4385 );
4386 }

◆ sendTutorNotification()

ilObjSurvey::sendTutorNotification ( )
protected

Send mail to tutors after all participants have finished the survey.

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

5285 : void
5286 {
5287 $link = ilLink::_getStaticLink($this->getRefId(), "svy");
5288
5289 // get tutors being set in the setting
5290 foreach ($this->getTutorNotificationRecipients() as $user_id) {
5291 // use language of recipient to compose message
5293 $ulng->loadLanguageModule('survey');
5294
5295 $subject = sprintf($ulng->txt('survey_notification_tutor_subject'), $this->getTitle());
5296 $message = sprintf($ulng->txt('survey_notification_tutor_salutation'), ilObjUser::_lookupFullname($user_id)) . "\n\n";
5297
5298 $message .= $ulng->txt('survey_notification_tutor_body') . ":\n\n";
5299 $message .= $ulng->txt('obj_svy') . ": " . $this->getTitle() . "\n";
5300 $message .= "\n" . $ulng->txt('survey_notification_tutor_link') . ": " . $link;
5301
5302 $mail_obj = new ilMail(ANONYMOUS_USER_ID);
5303 $mail_obj->appendInstallationSignature(true);
5304 $mail_obj->enqueue(
5306 "",
5307 "",
5308 $subject,
5309 $message,
5310 array()
5311 );
5312 }
5313 }
static _getLanguageOfUser(int $a_usr_id)
Get language object of user.

References $user_id, ilLanguageFactory\_getLanguageOfUser(), ilLink\_getStaticLink(), ilObjUser\_lookupFullname(), ilObjUser\_lookupLogin(), ANONYMOUS_USER_ID, and ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle().

+ Here is the call graph for this function:

◆ sent360Reminders()

ilObjSurvey::sent360Reminders ( )

Send 360 reminders.

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

5149 : void
5150 {
5151 global $DIC;
5152
5153 $access = $DIC->access();
5154 // collect all open ratings
5155 $rater_ids = array();
5156 foreach ($this->getAppraiseesData() as $app) {
5157 $this->svy_log->debug("Handle appraisee " . $app['user_id']);
5158
5159 if (!$this->isAppraiseeClosed($app['user_id'])) {
5160 $this->svy_log->debug("Check self evaluation, self: " . $this->get360SelfAppraisee() . ", target: " . $this->getReminderTarget());
5161
5162 // self evaluation?
5163 if ($this->get360SelfEvaluation() &&
5164 in_array($this->getReminderTarget(), array(self::NOTIFICATION_APPRAISEES, self::NOTIFICATION_APPRAISEES_AND_RATERS))) {
5165 $this->svy_log->debug("...1");
5166 // did user already finished self evaluation?
5167 if (!$this->is360SurveyStarted((int) $app['user_id'], (int) $app['user_id'])) {
5168 $this->svy_log->debug("...2");
5169 if (!isset($rater_ids[$app['user_id']])) {
5170 $rater_ids[$app['user_id']] = array();
5171 }
5172 if (!isset($app["user_id"], $rater_ids[$app['user_id']])) {
5173 $rater_ids[$app['user_id']][] = $app["user_id"];
5174 }
5175 }
5176 }
5177
5178 $this->svy_log->debug("Check raters.");
5179
5180 // should raters be notified?
5181 if (
5182 in_array(
5183 $this->getReminderTarget(),
5184 array(self::NOTIFICATION_RATERS, self::NOTIFICATION_APPRAISEES_AND_RATERS),
5185 true
5186 )
5187 ) {
5188 foreach ($this->getRatersData($app['user_id']) as $rater) {
5189 $rater_id = 0;
5190 if ($rater["login"] !== "") {
5191 $rater_id = ilObjUser::_lookupId($rater["login"]);
5192 }
5193 if ($rater_id > 0) {
5194 // is rater not anonymous and did not rate yet?
5195 if (!($rater["anonymous_id"] ?? false) && !($rater["finished"] ?? false)) {
5196 if (!isset($rater_ids[$rater_id])) {
5197 $rater_ids[$rater_id] = array();
5198 }
5199 if (!in_array($app["user_id"], $rater_ids[$rater_id])) {
5200 $rater_ids[$rater_id][] = $app["user_id"];
5201 }
5202 }
5203 }
5204 }
5205 }
5206 }
5207 }
5208
5209 $this->svy_log->debug("Found raters:" . count($rater_ids));
5210
5211 foreach ($rater_ids as $id => $app) {
5212 if ($access->checkAccessOfUser((int) $id, "read", "", $this->getRefId())) {
5213 $this->send360ReminderToUser((int) $id, $app);
5214 }
5215 }
5216 }
isAppraiseeClosed(int $a_user_id)
send360ReminderToUser(int $a_user_id, array $a_appraisee_ids)

References $DIC, $id, ilObjUser\_lookupId(), and ilRBACAccessHandler\checkAccessOfUser().

+ Here is the call graph for this function:

◆ sentReminderPlaceholders()

ilObjSurvey::sentReminderPlaceholders ( string  $a_message,
int  $a_user_id,
array  $a_context_params 
)
protected

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

5569 : string {
5570 // see ilMail::replacePlaceholders()
5571 try {
5573
5574 $user = new \ilObjUser($a_user_id);
5575
5576 $a_message = $this->placeholder_resolver->resolve($context, $a_message, $user, $a_context_params);
5577 } catch (\Exception $e) {
5578 ilLoggerFactory::getLogger('mail')->error(__METHOD__ . ' has been called with invalid context.');
5579 }
5580
5581 return $a_message;
5582 }

◆ set360RaterSent()

ilObjSurvey::set360RaterSent ( int  $a_appraisee_id,
int  $a_user_id,
int  $a_anonymous_id,
?int  $a_tstamp = null 
)
Todo:
move to appraisal manager

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

4866 : void {
4867 $ilDB = $this->db;
4868
4869 if (!$a_tstamp) {
4870 $a_tstamp = time();
4871 }
4872
4873 $ilDB->manipulate("UPDATE svy_360_rater" .
4874 " SET mail_sent = " . $ilDB->quote($a_tstamp, "integer") .
4875 " WHERE obj_id = " . $ilDB->quote($this->getSurveyId(), "integer") .
4876 " AND appr_id = " . $ilDB->quote($a_appraisee_id, "integer") .
4877 " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
4878 " AND anonymous_id = " . $ilDB->quote($a_anonymous_id, "integer"));
4879 }

◆ set360Results()

ilObjSurvey::set360Results ( int  $a_value)

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

4263 : void
4264 {
4265 $this->mode_360_results = $a_value;
4266 }

◆ set360SelfAppraisee()

ilObjSurvey::set360SelfAppraisee ( bool  $a_value)

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

4243 : void
4244 {
4245 $this->mode_360_self_appr = $a_value;
4246 }

◆ set360SelfEvaluation()

ilObjSurvey::set360SelfEvaluation ( bool  $a_value)

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

4233 : void
4234 {
4235 $this->mode_360_self_eval = $a_value;
4236 }

◆ set360SelfRaters()

ilObjSurvey::set360SelfRaters ( bool  $a_value)

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

4253 : void
4254 {
4255 $this->mode_360_self_rate = $a_value;
4256 }

◆ setActivationEndDate()

ilObjSurvey::setActivationEndDate ( ?int  $ending_time = null)

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

5477 : void {
5478 $this->activation_ending_time = $ending_time;
5479 }

◆ setActivationLimited()

ilObjSurvey::setActivationLimited ( bool  $a_value)

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

1312 : void
1313 {
1314 $this->activation_limited = $a_value;
1315 }

◆ setActivationStartDate()

ilObjSurvey::setActivationStartDate ( ?int  $starting_time = null)

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

5471 : void {
5472 $this->activation_starting_time = $starting_time;
5473 }

◆ setActivationVisibility()

ilObjSurvey::setActivationVisibility ( bool  $a_value)

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

1298 : void {
1299 $this->activation_visibility = $a_value;
1300 }

◆ setAnonymize()

ilObjSurvey::setAnonymize ( int  $a_anonymize)

set anonymize status

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

935 : void
936 {
937 switch ($a_anonymize) {
942 $this->anonymize = $a_anonymize;
943 break;
944 default:
945 $this->anonymize = self::ANONYMIZE_OFF;
946 break;
947 }
948 }
const ANONYMIZE_FREEACCESS
const ANONYMIZE_CODE_ALL

◆ setAnonymousUserList()

ilObjSurvey::setAnonymousUserList ( bool  $a_value)

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

5521 : void
5522 {
5523 $this->anon_user_list = $a_value;
5524 }

◆ setAuthor()

ilObjSurvey::setAuthor ( string  $author = "")

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

1126 : void {
1127 $this->author = $author;
1128 }
string $author
A text representation of the authors name.

◆ setCalculateSumScore()

ilObjSurvey::setCalculateSumScore ( bool  $a_val)

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

957 : void {
958 $this->calculate_sum_score = $a_val;
959 }

◆ setEndDate()

ilObjSurvey::setEndDate ( string  $end_date = "")
Parameters
string$end_date(YYYYMMDDHHMMSS)

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

1233 : void {
1234 $this->end_date = $end_date;
1235 }

◆ setEndDateAndTime()

ilObjSurvey::setEndDateAndTime ( string  $end_date,
string  $end_time 
)
Parameters
string$end_date(YYYY-MM-DD)
string$end_time(HH:MM:SS)

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

1264 : void {
1265 $y = '';
1266 $m = '';
1267 $d = '';
1268 $h = '';
1269 $i = '';
1270 $s = '';
1271 if (preg_match("/(\d{4})-(\d{2})-(\d{2})/", $end_date, $matches)) {
1272 $y = $matches[1];
1273 $m = $matches[2];
1274 $d = $matches[3];
1275 }
1276 if (preg_match("/(\d{2}):(\d{2}):(\d{2})/", $end_time, $matches)) {
1277 $h = $matches[1];
1278 $i = $matches[2];
1279 $s = $matches[3];
1280 }
1281 $this->end_date = sprintf('%04d%02d%02d%02d%02d%02d', $y, $m, $d, $h, $i, $s);
1282 }

References Vendor\Package\$d.

◆ setEvaluationAccess()

ilObjSurvey::setEvaluationAccess ( string  $evaluation_access = self::EVALUATION_ACCESS_OFF)

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

1292 : void {
1293 $this->evaluation_access = $evaluation_access;
1294 }

◆ setIntroduction()

ilObjSurvey::setIntroduction ( string  $introduction = "")

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

1172 : void {
1173 $this->introduction = $introduction;
1174 }

◆ setMailAddresses()

ilObjSurvey::setMailAddresses ( string  $a_addresses)

Set (Tutor) Recipients of "single participant has finished" mails.

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

4121 : void
4122 {
4123 $this->mailaddresses = $a_addresses;
4124 }

◆ setMailConfirmation()

ilObjSurvey::setMailConfirmation ( bool  $a_value)

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

5511 : void
5512 {
5513 $this->mail_confirmation = $a_value;
5514 }

◆ setMailNotification()

ilObjSurvey::setMailNotification ( bool  $a_notification)

Activate mail to tutors each time a participant finishes the survey.

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

4105 : void
4106 {
4107 $this->mailnotification = $a_notification;
4108 }

◆ setMailOwnResults()

ilObjSurvey::setMailOwnResults ( bool  $a_value)

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

5501 : void
5502 {
5503 $this->mail_own_results = $a_value;
5504 }

◆ setMailParticipantData()

ilObjSurvey::setMailParticipantData ( string  $a_data)

Set preceding text (incl.

placeholders) for "single participant has finished" mails

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

4137 : void
4138 {
4139 $this->mailparticipantdata = $a_data;
4140 }

◆ setMode()

ilObjSurvey::setMode ( int  $a_value)

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

5584 : void
5585 {
5586 $this->mode = $a_value;
5587 }

◆ setObligatoryStates()

ilObjSurvey::setObligatoryStates ( array  $obligatory_questions)

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

Parameters
array$obligatory_questionskey is question id, value should be bool value
Todo:
move to survey question manager/repo

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

1883 : void {
1884 $ilDB = $this->db;
1885 $result = $ilDB->queryF(
1886 "SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
1887 array('integer'),
1888 array($this->getSurveyId())
1889 );
1890 if ($result->numRows()) {
1891 while ($row = $ilDB->fetchAssoc($result)) {
1892 if (!array_key_exists($row["question_fi"], $obligatory_questions)) {
1893 $obligatory_questions[$row["question_fi"]] = 0;
1894 }
1895 }
1896 }
1897 // set the obligatory states in the database
1898 foreach ($obligatory_questions as $question_fi => $obligatory) {
1899 // #12420
1900 $ilDB->manipulate("UPDATE svy_question" .
1901 " SET obligatory = " . $ilDB->quote($obligatory, "integer") .
1902 " WHERE question_id = " . $ilDB->quote($question_fi, "integer"));
1903 }
1904 }

References $ilDB.

◆ setOutro()

ilObjSurvey::setOutro ( string  $outro = "")

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

1178 : void {
1179 $this->outro = $outro;
1180 }

◆ setPage()

ilObjSurvey::setPage ( int  $finished_id,
int  $page_id 
)

Sets the number of the active survey page.

Parameters
int$finished_idid of the active user
int$page_idindex of the page
Todo:
move to run manager/repo

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

2373 : void {
2374 $ilDB = $this->db;
2375
2376 $ilDB->manipulateF(
2377 "UPDATE svy_finished SET lastpage = %s WHERE finished_id = %s",
2378 array('integer','integer'),
2379 array(($page_id) ?: 0, $finished_id)
2380 );
2381 }

◆ setPoolUsage()

ilObjSurvey::setPoolUsage ( bool  $a_value)

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

4178 : void
4179 {
4180 $this->pool_usage = $a_value;
4181 }

◆ setReminderEnd()

ilObjSurvey::setReminderEnd ( ?ilDate  $a_value = null)

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

4996 : void
4997 {
4998 $this->reminder_end = $a_value;
4999 }

◆ setReminderFrequency()

ilObjSurvey::setReminderFrequency ( int  $a_value)

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

5006 : void
5007 {
5008 $this->reminder_frequency = $a_value;
5009 }

◆ setReminderLastSent()

ilObjSurvey::setReminderLastSent ( ?string  $a_value)

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

5026 : void
5027 {
5028 if ($a_value == "") {
5029 $a_value = null;
5030 }
5031 $this->reminder_last_sent = $a_value;
5032 }

◆ setReminderStart()

ilObjSurvey::setReminderStart ( ?ilDate  $a_value = null)

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

4986 : void
4987 {
4988 $this->reminder_start = $a_value;
4989 }

◆ setReminderStatus()

ilObjSurvey::setReminderStatus ( bool  $a_value)

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

4976 : void
4977 {
4978 $this->reminder_status = $a_value;
4979 }

◆ setReminderTarget()

ilObjSurvey::setReminderTarget ( int  $a_value)

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

5016 : void
5017 {
5018 $this->reminder_target = $a_value;
5019 }

Referenced by ILIAS\Survey\Mode\Feedback360\UIModifier\setValuesFromForm(), and ILIAS\Survey\Mode\IndividualFeedback\UIModifier\setValuesFromForm().

+ Here is the caller graph for this function:

◆ setReminderTemplate()

ilObjSurvey::setReminderTemplate ( ?int  $a_value)

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

5049 : void
5050 {
5051 $this->reminder_tmpl = $a_value;
5052 }

◆ setSelfEvaluationResults()

ilObjSurvey::setSelfEvaluationResults ( int  $a_value)

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

5594 : void
5595 {
5596 $this->mode_self_eval_results = $a_value;
5597 }

◆ setShowQuestionTitles()

ilObjSurvey::setShowQuestionTitles ( bool  $a_show)

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

1165 : void
1166 {
1167 $this->display_question_titles = $a_show;
1168 }

◆ setSkillService()

ilObjSurvey::setSkillService ( bool  $a_val)

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

4848 : void
4849 {
4850 $this->mode_skill_service = $a_val;
4851 }

◆ setStartDate()

ilObjSurvey::setStartDate ( string  $start_date = "")
Parameters
string$start_date(YYYYMMDDHHMMSS)

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

1192 : void {
1193 $this->start_date = $start_date;
1194 }

◆ setStartDateAndTime()

ilObjSurvey::setStartDateAndTime ( string  $start_date,
string  $start_time 
)
Parameters
string$start_date(YYYY-MM-DD)
string$start_time(HH:MM:SS)

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

1203 : void {
1204 $y = '';
1205 $m = '';
1206 $d = '';
1207 $h = '';
1208 $i = '';
1209 $s = '';
1210 if (preg_match("/(\d{4})-(\d{2})-(\d{2})/", $start_date, $matches)) {
1211 $y = $matches[1];
1212 $m = $matches[2];
1213 $d = $matches[3];
1214 }
1215 if (preg_match("/(\d{2}):(\d{2}):(\d{2})/", $start_time, $matches)) {
1216 $h = $matches[1];
1217 $i = $matches[2];
1218 $s = $matches[3];
1219 }
1220 $this->start_date = sprintf('%04d%02d%02d%02d%02d%02d', $y, $m, $d, $h, $i, $s);
1221 }

References Vendor\Package\$d.

◆ setSurveyId()

ilObjSurvey::setSurveyId ( int  $survey_id)

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

4065 : void
4066 {
4067 $this->survey_id = $survey_id;
4068 }

◆ setTutorNotificationRecipients()

ilObjSurvey::setTutorNotificationRecipients ( array  $a_value)

Set tutor recipients for "all participants have finished" mail.

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

5078 : void
5079 {
5080 $this->tutor_ntf_recipients = $a_value;
5081 }

◆ setTutorNotificationStatus()

ilObjSurvey::setTutorNotificationStatus ( bool  $a_value)

Activates mail being sent to tutors after all participants have finished the survey.

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

5062 : void
5063 {
5064 $this->tutor_ntf_status = $a_value;
5065 }

◆ setTutorNotificationTarget()

ilObjSurvey::setTutorNotificationTarget ( int  $a_value)

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

5094 : void
5095 {
5096 $this->tutor_ntf_target = $a_value;
5097 }

◆ setTutorResultsRecipients()

ilObjSurvey::setTutorResultsRecipients ( array  $a_value)

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

5114 : void
5115 {
5116 $this->tutor_res_recipients = $a_value;
5117 }

◆ setTutorResultsStatus()

ilObjSurvey::setTutorResultsStatus ( bool  $a_value)

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

5104 : void
5105 {
5106 $this->tutor_res_status = $a_value;
5107 }

◆ setViewOwnResults()

ilObjSurvey::setViewOwnResults ( bool  $a_value)

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

5491 : void
5492 {
5493 $this->view_own_results = $a_value;
5494 }

◆ toXML()

ilObjSurvey::toXML ( )

Returns a QTI xml representation of the survey.

Todo:
move to export sub-service

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

2927 : string
2928 {
2929 $a_xml_writer = new ilXmlWriter();
2930 // set xml header
2931 $a_xml_writer->xmlHeader();
2932 $attrs = array(
2933 "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
2934 "xsi:noNamespaceSchemaLocation" => "https://www.ilias.de/download/xsd/ilias_survey_4_2.xsd"
2935 );
2936 $a_xml_writer->xmlStartTag("surveyobject", $attrs);
2937 $attrs = array(
2938 "id" => $this->getSurveyId(),
2939 "title" => $this->getTitle()
2940 );
2941 $a_xml_writer->xmlStartTag("survey", $attrs);
2942
2943 $a_xml_writer->xmlElement("description", null, $this->getDescription());
2944 $a_xml_writer->xmlElement("author", null, $this->getAuthor());
2945 $a_xml_writer->xmlStartTag("objectives");
2946 $attrs = array(
2947 "label" => "introduction"
2948 );
2949 $this->addMaterialTag($a_xml_writer, $this->getIntroduction(), true, true, $attrs);
2950 $attrs = array(
2951 "label" => "outro"
2952 );
2953 $this->addMaterialTag($a_xml_writer, $this->getOutro(), true, true, $attrs);
2954 $a_xml_writer->xmlEndTag("objectives");
2955
2956 if ($this->getAnonymize()) {
2957 $attribs = array("enabled" => "1");
2958 } else {
2959 $attribs = array("enabled" => "0");
2960 }
2961 $a_xml_writer->xmlElement("anonymisation", $attribs);
2962 $a_xml_writer->xmlStartTag("restrictions");
2963 if ($this->getAnonymize() === 2) {
2964 $attribs = array("type" => "free");
2965 } else {
2966 $attribs = array("type" => "restricted");
2967 }
2968 $a_xml_writer->xmlElement("access", $attribs);
2969 if ($this->getStartDate()) {
2970 $attrs = array("type" => "date");
2971 preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->getStartDate(), $matches);
2972 $a_xml_writer->xmlElement("startingtime", $attrs, sprintf("%04d-%02d-%02dT%02d:%02d:00", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5]));
2973 }
2974 if ($this->getEndDate()) {
2975 $attrs = array("type" => "date");
2976 preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->getEndDate(), $matches);
2977 $a_xml_writer->xmlElement("endingtime", $attrs, sprintf("%04d-%02d-%02dT%02d:%02d:00", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5]));
2978 }
2979 $a_xml_writer->xmlEndTag("restrictions");
2980
2981 // constraints
2982 $pages = $this->getSurveyPages();
2983 $hasconstraints = false;
2984 foreach ($pages as $question_array) {
2985 foreach ($question_array as $question) {
2986 if (count($question["constraints"])) {
2987 $hasconstraints = true;
2988 }
2989 }
2990 }
2991
2992 if ($hasconstraints) {
2993 $a_xml_writer->xmlStartTag("constraints");
2994 foreach ($pages as $question_array) {
2995 foreach ($question_array as $question) {
2996 if (count($question["constraints"])) {
2997 // found constraints
2998 foreach ($question["constraints"] as $constraint) {
2999 $attribs = array(
3000 "sourceref" => $question["question_id"],
3001 "destref" => $constraint["question"],
3002 "relation" => $constraint["short"],
3003 "value" => $constraint["value"],
3004 "conjunction" => $constraint["conjunction"]
3005 );
3006 $a_xml_writer->xmlElement("constraint", $attribs);
3007 }
3008 }
3009 }
3010 }
3011 $a_xml_writer->xmlEndTag("constraints");
3012 }
3013
3014 // add the rest of the preferences in qtimetadata tags, because there is no correspondent definition in QTI
3015 $a_xml_writer->xmlStartTag("metadata");
3016
3017 $custom_properties = array();
3018 $custom_properties["evaluation_access"] = $this->getEvaluationAccess();
3019 $custom_properties["status"] = !$this->getOfflineStatus();
3020 $custom_properties["display_question_titles"] = $this->getShowQuestionTitles();
3021
3022 $custom_properties["own_results_view"] = (int) $this->hasViewOwnResults();
3023 $custom_properties["own_results_mail"] = (int) $this->hasMailOwnResults();
3024 $custom_properties["confirmation_mail"] = (int) $this->hasMailConfirmation();
3025
3026 $custom_properties["anon_user_list"] = (int) $this->hasAnonymousUserList();
3027 $custom_properties["mode"] = $this->getMode();
3028 $custom_properties["mode_360_self_eval"] = (int) $this->get360SelfEvaluation();
3029 $custom_properties["mode_360_self_rate"] = (int) $this->get360SelfRaters();
3030 $custom_properties["mode_360_self_appr"] = (int) $this->get360SelfAppraisee();
3031 $custom_properties["mode_360_results"] = $this->get360Results();
3032 $custom_properties["mode_skill_service"] = (int) $this->getSkillService();
3033 $custom_properties["mode_self_eval_results"] = $this->getSelfEvaluationResults();
3034
3035
3036 // :TODO: skills?
3037
3038 // reminder/tutor notification are (currently?) not exportable
3039
3040 foreach ($custom_properties as $label => $value) {
3041 $a_xml_writer->xmlStartTag("metadatafield");
3042 $a_xml_writer->xmlElement("fieldlabel", null, $label);
3043 $a_xml_writer->xmlElement("fieldentry", null, $value);
3044 $a_xml_writer->xmlEndTag("metadatafield");
3045 }
3046
3047 $a_xml_writer->xmlEndTag("metadata");
3048 $a_xml_writer->xmlEndTag("survey");
3049
3050 $attribs = array("id" => $this->getId());
3051 $a_xml_writer->xmlStartTag("surveyquestions", $attribs);
3052 // add questionblock descriptions
3053 foreach ($pages as $question_array) {
3054 if (count($question_array) > 1) {
3055 $attribs = array("id" => $question_array[0]["question_id"]);
3056 $attribs = array(
3057 "showQuestiontext" => $question_array[0]["questionblock_show_questiontext"],
3058 "showBlocktitle" => $question_array[0]["questionblock_show_blocktitle"],
3059 "compressView" => $question_array[0]["questionblock_compress_view"]
3060 );
3061 $a_xml_writer->xmlStartTag("questionblock", $attribs);
3062 if (strlen($question_array[0]["questionblock_title"])) {
3063 $a_xml_writer->xmlElement("questionblocktitle", null, $question_array[0]["questionblock_title"]);
3064 }
3065 }
3066 foreach ($question_array as $question) {
3067 if (strlen($question["heading"] ?? "")) {
3068 $a_xml_writer->xmlElement("textblock", null, $question["heading"]);
3069 }
3070 $questionObject = self::_instanciateQuestion($question["question_id"]);
3071 //questionObject contains all the fields from the database. (loadFromDb)
3072 //we don't need the value from svy_qst_oblig table, we already have the values from svy_question table.
3073 //if ($questionObject !== FALSE) $questionObject->insertXML($a_xml_writer, FALSE, $obligatory_states[$question["question_id"]]);
3074 if ($questionObject !== false) {
3075 $questionObject->insertXML($a_xml_writer, false);
3076 }
3077 }
3078 if (count($question_array) > 1) {
3079 $a_xml_writer->xmlEndTag("questionblock");
3080 }
3081 }
3082
3083 $a_xml_writer->xmlEndTag("surveyquestions");
3084 $a_xml_writer->xmlEndTag("surveyobject");
3085 $xml = $a_xml_writer->xmlDumpMem(false);
3086 return $xml;
3087 }
addMaterialTag(ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true, ?array $attribs=null)
Creates an XML material tag from a plain text or xhtml text.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\Survey\Mode\getId(), ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ unfoldQuestionblocks()

ilObjSurvey::unfoldQuestionblocks ( array  $questionblocks)
Parameters
int[]$questionblocksquestion block ids
Todo:
move to survey question manager/repo

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

1511 : void {
1512 $ilDB = $this->db;
1513 foreach ($questionblocks as $index) {
1514 $affectedRows = $ilDB->manipulateF(
1515 "DELETE FROM svy_qblk WHERE questionblock_id = %s",
1516 array('integer'),
1517 array($index)
1518 );
1519 $affectedRows = $ilDB->manipulateF(
1520 "DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
1521 array('integer','integer'),
1522 array($index, $this->getSurveyId())
1523 );
1524 }
1525 }

References $ilDB.

◆ update()

ilObjSurvey::update (   $a_upload = false)

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

228 : bool
229 {
230 if (!$a_upload) {
231 $this->updateMetaData();
232 }
233
234 if (!parent::update()) {
235 return false;
236 }
237
238 // put here object specific stuff
239
240 return true;
241 }

References ilObject\updateMetaData().

+ Here is the call graph for this function:

◆ updateCode()

ilObjSurvey::updateCode ( int  $a_id,
string  $a_email,
string  $a_last_name,
string  $a_first_name,
int  $a_sent 
)
Todo:
move to code manager

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

4192 : bool {
4193 $ilDB = $this->db;
4194
4195 $a_email = trim($a_email);
4196
4197 // :TODO:
4198 if (($a_email && !ilUtil::is_email($a_email)) || $a_email === "") {
4199 return false;
4200 }
4201
4202 $data = array("email" => $a_email,
4203 "lastname" => trim($a_last_name),
4204 "firstname" => trim($a_first_name));
4205
4206 $fields = array(
4207 "externaldata" => array("text", serialize($data)),
4208 "sent" => array("integer", $a_sent)
4209 );
4210
4211 $ilDB->update(
4212 "svy_anonymous",
4213 $fields,
4214 array("anonymous_id" => array("integer", $a_id))
4215 );
4216
4217 return true;
4218 }
static is_email(string $a_email, ?ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.

◆ updateConjunctionForQuestions()

ilObjSurvey::updateConjunctionForQuestions ( array  $questions,
int  $conjunction 
)
Todo:
move to constraint manager/repo

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

2226 : void {
2227 $ilDB = $this->db;
2228 foreach ($questions as $question_id) {
2229 $ilDB->manipulateF(
2230 "UPDATE svy_constraint SET conjunction = %s " .
2231 "WHERE constraint_id IN (SELECT constraint_fi FROM svy_qst_constraint WHERE svy_qst_constraint.question_fi = %s)",
2232 array('integer','integer'),
2233 array($conjunction, $question_id)
2234 );
2235 }
2236 }

References $ilDB.

◆ updateConstraint()

ilObjSurvey::updateConstraint ( int  $precondition_id,
int  $if_question_id,
int  $relation,
float  $value,
int  $conjunction 
)
Todo:
move to constraint manager/repo

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

2210 : void {
2211 $ilDB = $this->db;
2212 $ilDB->manipulateF(
2213 "UPDATE svy_constraint SET question_fi = %s, relation_fi = %s, value = %s, conjunction = %s " .
2214 "WHERE constraint_id = %s",
2215 array('integer','integer','float','integer','integer'),
2216 array($if_question_id, $relation, $value, $conjunction, $precondition_id)
2217 );
2218 }

◆ updateOrder()

ilObjSurvey::updateOrder ( array  $a_order)

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

4166 : void {
4167 if (count($this->questions) === count($a_order)) {
4168 $this->questions = array_flip($a_order);
4169 $this->saveQuestionsToDb();
4170 }
4171 }

Field Documentation

◆ $access

ilAccessHandler ilObjSurvey::$access
protected

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

◆ $activation_ending_time

int ilObjSurvey::$activation_ending_time = null
protected

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

◆ $activation_limited

bool ilObjSurvey::$activation_limited = false
protected

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

◆ $activation_starting_time

int ilObjSurvey::$activation_starting_time = null
protected

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

◆ $activation_visibility

bool ilObjSurvey::$activation_visibility = false
protected

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

◆ $anon_user_list

bool ilObjSurvey::$anon_user_list = false
protected

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

◆ $anonymize

int ilObjSurvey::$anonymize = 0

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

◆ $author

string ilObjSurvey::$author = ""

A text representation of the authors name.

The name of the author must not necessary be the name of the owner.

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

◆ $calculate_sum_score

bool ilObjSurvey::$calculate_sum_score = false
protected

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

◆ $code_manager

ILIAS Survey Code CodeManager ilObjSurvey::$code_manager
protected

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

◆ $data_manager

ILIAS Survey InternalDataService ilObjSurvey::$data_manager
protected

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

◆ $display_question_titles

int ilObjSurvey::$display_question_titles = 0

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

◆ $domain

InternalDomainService ilObjSurvey::$domain
protected

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

◆ $end_date

string ilObjSurvey::$end_date = ""

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

◆ $evaluation_access

string ilObjSurvey::$evaluation_access = self::EVALUATION_ACCESS_OFF

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

◆ $feature_config

Mode FeatureConfig ilObjSurvey::$feature_config
protected

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

◆ $import_manager

ILIAS SurveyQuestionPool Export ImportManager ilObjSurvey::$import_manager
protected

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

◆ $introduction

string ilObjSurvey::$introduction = ""

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

◆ $invitation_manager

Participants InvitationsManager ilObjSurvey::$invitation_manager
protected

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

◆ $mail_confirmation

bool ilObjSurvey::$mail_confirmation = false
protected

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

◆ $mail_own_results

bool ilObjSurvey::$mail_own_results = false
protected

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

◆ $mailaddresses

string ilObjSurvey::$mailaddresses = ""

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

◆ $mailnotification

bool ilObjSurvey::$mailnotification = false

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

◆ $mailparticipantdata

string ilObjSurvey::$mailparticipantdata = ""

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

◆ $mode

int ilObjSurvey::$mode = 0
protected

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

◆ $mode_360_results

int ilObjSurvey::$mode_360_results = 0
protected

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

◆ $mode_360_self_appr

bool ilObjSurvey::$mode_360_self_appr = false
protected

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

◆ $mode_360_self_eval

bool ilObjSurvey::$mode_360_self_eval = false
protected

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

◆ $mode_360_self_rate

bool ilObjSurvey::$mode_360_self_rate = false
protected

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

◆ $mode_self_eval_results

int ilObjSurvey::$mode_self_eval_results = 0
protected

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

◆ $mode_skill_service

bool ilObjSurvey::$mode_skill_service = false
protected

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

◆ $outro

string ilObjSurvey::$outro = ""

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

◆ $placeholder_resolver

ilMailTemplatePlaceholderResolver ilObjSurvey::$placeholder_resolver
protected

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

◆ $plugin_admin

ilPluginAdmin ilObjSurvey::$plugin_admin
protected

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

◆ $pool_usage

bool ilObjSurvey::$pool_usage = false

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

◆ $questions

array ilObjSurvey::$questions = []

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

◆ $reminder_end

ilDate ilObjSurvey::$reminder_end = null
protected

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

◆ $reminder_frequency

int ilObjSurvey::$reminder_frequency = 0
protected

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

◆ $reminder_last_sent

string ilObjSurvey::$reminder_last_sent = null
protected

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

◆ $reminder_start

ilDate ilObjSurvey::$reminder_start = null
protected

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

◆ $reminder_status

bool ilObjSurvey::$reminder_status = false
protected

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

◆ $reminder_target

int ilObjSurvey::$reminder_target = 0
protected

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

◆ $reminder_tmpl

int ilObjSurvey::$reminder_tmpl = null
protected

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

◆ $start_date

string ilObjSurvey::$start_date = ""

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

◆ $survey_id

int ilObjSurvey::$survey_id = 0

A unique positive numerical ID which identifies the survey.

This is the primary key from a database table.

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

◆ $survey_service

ILIAS Survey InternalService ilObjSurvey::$survey_service
protected

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

◆ $surveyCodeSecurity

bool ilObjSurvey::$surveyCodeSecurity = false

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

◆ $svy_log

ilLogger ilObjSurvey::$svy_log
protected

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

◆ $tutor_ntf_recipients

array ilObjSurvey::$tutor_ntf_recipients = []
protected

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

◆ $tutor_ntf_status

bool ilObjSurvey::$tutor_ntf_status = false
protected

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

◆ $tutor_ntf_target

int ilObjSurvey::$tutor_ntf_target = 0
protected

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

◆ $tutor_res_recipients

array ilObjSurvey::$tutor_res_recipients = []
protected

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

◆ $tutor_res_status

bool ilObjSurvey::$tutor_res_status = false
protected

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

◆ $user

ilObjUser ilObjSurvey::$user
protected

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

◆ $view_own_results

bool ilObjSurvey::$view_own_results = false
protected

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

◆ ANONYMIZE_CODE_ALL

const ilObjSurvey::ANONYMIZE_CODE_ALL = 3

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

Referenced by ilObjSurveyGUI\afterSave().

◆ ANONYMIZE_FREEACCESS

const ilObjSurvey::ANONYMIZE_FREEACCESS = 2

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

◆ ANONYMIZE_OFF

const ilObjSurvey::ANONYMIZE_OFF = 0

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

Referenced by __construct().

◆ ANONYMIZE_ON

const ilObjSurvey::ANONYMIZE_ON = 1

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

◆ EVALUATION_ACCESS_ALL

const ilObjSurvey::EVALUATION_ACCESS_ALL = "1"

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

◆ EVALUATION_ACCESS_OFF

const ilObjSurvey::EVALUATION_ACCESS_OFF = "0"

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

Referenced by __construct().

◆ EVALUATION_ACCESS_PARTICIPANTS

const ilObjSurvey::EVALUATION_ACCESS_PARTICIPANTS = "2"

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

Referenced by ilObjSurveyGUI\afterSave().

◆ MODE_360

◆ MODE_IND_FEEDB

◆ MODE_SELF_EVAL

◆ MODE_STANDARD

const ilObjSurvey::MODE_STANDARD = 0

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

Referenced by __construct(), and ilObjSurveyGUI\getTabs().

◆ NOTIFICATION_APPRAISEES

const ilObjSurvey::NOTIFICATION_APPRAISEES = 3

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

◆ NOTIFICATION_APPRAISEES_AND_RATERS

const ilObjSurvey::NOTIFICATION_APPRAISEES_AND_RATERS = 5

◆ NOTIFICATION_INVITED_USERS

const ilObjSurvey::NOTIFICATION_INVITED_USERS = 2

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

◆ NOTIFICATION_PARENT_COURSE

const ilObjSurvey::NOTIFICATION_PARENT_COURSE = 1

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

◆ NOTIFICATION_RATERS

const ilObjSurvey::NOTIFICATION_RATERS = 4

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

◆ PRINT_HIDE_LABELS

const ilObjSurvey::PRINT_HIDE_LABELS = 1

◆ PRINT_SHOW_LABELS

const ilObjSurvey::PRINT_SHOW_LABELS = 3

◆ QUESTIONTITLES_HIDDEN

const ilObjSurvey::QUESTIONTITLES_HIDDEN = 0

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

◆ QUESTIONTITLES_VISIBLE

const ilObjSurvey::QUESTIONTITLES_VISIBLE = 1

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

Referenced by __construct().

◆ RESULTS_360_ALL

const ilObjSurvey::RESULTS_360_ALL = 2

◆ RESULTS_360_NONE

const ilObjSurvey::RESULTS_360_NONE = 0

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

◆ RESULTS_360_OWN

const ilObjSurvey::RESULTS_360_OWN = 1

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

◆ RESULTS_SELF_EVAL_ALL

◆ RESULTS_SELF_EVAL_NONE

const ilObjSurvey::RESULTS_SELF_EVAL_NONE = 0

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

◆ RESULTS_SELF_EVAL_OWN

const ilObjSurvey::RESULTS_SELF_EVAL_OWN = 1

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

Referenced by __construct().


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