147 bool $a_call_by_reference =
true
151 $this->survey_service =
$DIC->survey()->internal();
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();
163 $this->survey_id = -1;
164 $this->introduction =
"";
165 $this->outro =
$lng->
txt(
"survey_finished");
166 $this->author = $ilUser->getFullname();
168 $this->questions = array();
171 $this->surveyCodeSecurity =
true;
172 $this->pool_usage =
true;
176 $this->invitation_manager = $this
182 $this->import_manager =
$DIC->surveyQuestionPool()
186 $this->placeholder_resolver =
$DIC->mail()->placeholderResolver();
191 $this->domain =
$DIC->survey()->internal()->domain();
197 $this->code_manager = $this
200 ->code($this, $this->
user->getId());
202 $this->feature_config = $this
205 ->modeFeatureConfig($this->
getMode());
207 $this->data_manager = $this
214 $id = parent::create();
228 public function update($a_upload =
false): bool
234 if (!parent::update()) {
245 $result = parent::createReference();
262 $this->questions[] = $question_id;
265 public function delete():
bool
267 $this->svy_log->debug(
"Deleting Survey, ref id: " . $this->
getRefId() .
", obj id: " .
274 foreach ($this->questions as $question_id) {
275 $this->svy_log->debug(
"Remove question " . $question_id);
283 $this->svy_log->debug(
"Call parent delete.");
284 $remove = parent::delete();
302 "DELETE FROM svy_svy WHERE survey_id = %s",
307 $result =
$ilDB->queryF(
308 "SELECT questionblock_fi FROM svy_qblk_qst WHERE survey_fi = %s",
312 $questionblocks = array();
313 while ($row =
$ilDB->fetchAssoc($result)) {
314 $questionblocks[] = $row[
"questionblock_fi"];
316 if (count($questionblocks)) {
317 $affectedRows =
$ilDB->manipulate(
"DELETE FROM svy_qblk WHERE " .
$ilDB->in(
'questionblock_id', $questionblocks,
false,
'integer'));
320 "DELETE FROM svy_qblk_qst WHERE survey_fi = %s",
326 if (isset($this->code_manager)) {
327 $this->code_manager->deleteAll(
true);
332 $directory = $svy_data_dir .
"/svy_" . $this->
getId();
333 if (is_dir($directory)) {
342 foreach ($mobs as $mob) {
355 bool $reset_LP =
true
359 $result =
$ilDB->queryF(
360 "SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
364 $active_array = array();
365 while ($row =
$ilDB->fetchAssoc($result)) {
366 $active_array[] = $row[
"finished_id"];
369 $affectedRows =
$ilDB->manipulateF(
370 "DELETE FROM svy_finished WHERE survey_fi = %s",
375 foreach ($active_array as $active_fi) {
376 $affectedRows =
$ilDB->manipulateF(
377 "DELETE FROM svy_answer WHERE active_fi = %s",
381 $affectedRows =
$ilDB->manipulateF(
382 "DELETE FROM svy_times WHERE finished_fi = %s",
390 $lp_obj->resetLPDataForCompleteObject();
393 $this->invitation_manager->removeAll($this->
getSurveyId());
407 foreach ($finished_ids as $finished_id) {
408 $result =
$ilDB->queryF(
409 "SELECT finished_id, user_fi FROM svy_finished WHERE finished_id = %s",
413 $row =
$ilDB->fetchAssoc($result);
414 if ($row[
"user_fi"]) {
415 $user_ids[] = (
int) $row[
"user_fi"];
418 $affectedRows =
$ilDB->manipulateF(
419 "DELETE FROM svy_answer WHERE active_fi = %s",
421 array($row[
"finished_id"])
424 $affectedRows =
$ilDB->manipulateF(
425 "DELETE FROM svy_finished WHERE finished_id = %s",
430 $affectedRows =
$ilDB->manipulateF(
431 "DELETE FROM svy_times WHERE finished_fi = %s",
433 array($row[
"finished_id"])
437 if (count($user_ids)) {
439 $lp_obj->resetLPDataForUserIds($user_ids);
443 $this->invitation_manager->remove($this->getSurveyId(),
$user_id);
452 ?array $finished_ids =
null,
453 bool $force_non_anonymous =
false,
454 bool $include_invites =
false
457 $sql =
"SELECT * FROM svy_finished" .
458 " WHERE survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer");
460 $sql .=
" AND " .
$ilDB->in(
"finished_id", $finished_ids,
"",
"integer");
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;
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)) {
478 $participants[$name[
"lastname"] .
"," . $name[
"firstname"] . $usr_id] = [
480 "sortname" => $name[
"lastname"] .
"," . $name[
"firstname"],
481 "fistname" => $name[
"firstname"],
482 "lastname" => $name[
"lastname"],
483 "login" => $name[
"login"],
487 "finished_tstamp" => 0,
493 return $participants;
502 return ($this->
getTitle() && count($this->questions));
507 return count($this->questions);
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())
532 bool $a_force =
false
534 $questiontype = $this->getQuestionType($question_id);
535 $question_gui = $this->getQuestionGUI($questiontype, $question_id);
538 if ($this->
getId() === $question_gui->object->getObjId() && !$a_force) {
542 $duplicate_id = $question_gui->object->duplicate(
true,
"",
"", 0, $this->
getId());
543 return $duplicate_id;
555 $this->svy_log->debug(
"insert question, id:" . $question_id);
557 $this->svy_log->debug(
"question is not complete");
561 $result =
$ilDB->queryF(
562 "SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
564 array($this->getSurveyId())
566 $sequence = $result->numRows();
567 $duplicate_id = $this->duplicateQuestionForSurvey($question_id);
568 $this->svy_log->debug(
"duplicate, id: " . $question_id .
", duplicate id: " . $duplicate_id);
571 if ($this->isQuestionInSurvey($duplicate_id)) {
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())
582 $this->svy_log->debug(
"added entry to svy_svy_qst, id: " . $next_id .
", question id: " . $duplicate_id .
", sequence: " . $sequence);
584 $this->loadQuestionsFromDb();
585 $this->saveCompletionStatus();
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)) {
609 int $questionblock_id
612 $sequence_manager = $this->survey_service->domain()->sequence(
613 $this->getSurveyId(),
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",
626 array($questionblock_id)
628 $questions = array();
629 $show_questiontext =
false;
630 $show_blocktitle =
false;
632 while ($row =
$ilDB->fetchAssoc($result)) {
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"];
640 $this->createQuestionblock($title, $show_questiontext, $show_blocktitle, $questions);
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)
668 "DELETE FROM svy_settings WHERE settings_id = %s",
680 $result =
$ilDB->queryF(
681 "SELECT * FROM svy_settings WHERE usr_id = %s AND keyword = %s",
682 array(
'integer',
'text'),
686 if ($result->numRows()) {
687 while ($row =
$ilDB->fetchAssoc($result)) {
688 $found[$row[
'settings_id']] = $row;
700 $rmd_start = $this->getReminderStart();
701 if (is_object($rmd_start)) {
704 $rmd_end = $this->getReminderEnd();
705 if (is_object($rmd_end)) {
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()),
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()),
728 "mode" => array(
"integer", $this->getMode()),
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()),
735 "mode_skill_service" => array(
"integer", (
int) $this->getSkillService()),
737 "mode_self_eval_results" => array(
"integer", self::RESULTS_SELF_EVAL_OWN),
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())
757 $this->setSurveyId($next_id);
759 $affectedRows =
$ilDB->update(
"svy_svy", array(
760 "author" => array(
"text",
ilStr::subStr($this->getAuthor(), 0, 50)),
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()),
774 "mode" => array(
"integer", $this->getMode()),
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()),
781 "mode_skill_service" => array(
"integer", (
int) $this->getSkillService()),
783 "mode_self_eval_results" => array(
"integer", $this->getSelfEvaluationResults()),
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())
803 "survey_id" => array(
"integer", $this->getSurveyId())
808 $this->saveQuestionsToDb();
816 if (!$this->isActivationLimited()) {
820 $item->setTimingStart($this->getActivationStartDate());
821 $item->setTimingEnd($this->getActivationEndDate());
822 $item->toggleVisible($this->getActivationVisibility());
825 $item->update($this->ref_id);
834 $this->svy_log->debug(
"save questions");
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",
842 array($this->getSurveyId())
844 while ($row =
$ilDB->fetchAssoc($result)) {
845 $old_questions[$row[
"question_fi"]] = $row;
849 $insert = $update = $delete = array();
850 foreach ($this->questions as $seq => $fi) {
851 if (!array_key_exists($fi, $old_questions)) {
853 } elseif ($old_questions[$fi][
"sequence"] != $seq) {
854 $update[$fi] = $old_questions[$fi][
"survey_question_id"];
857 unset($old_questions[$fi]);
861 if (count($old_questions)) {
863 foreach ($old_questions as $fi => $old) {
864 $del_ids[] = $old[
"survey_question_id"];
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);
870 unset($old_questions);
873 foreach ($this->questions as $seq => $fi) {
874 if (in_array($fi, $insert)) {
876 if (!$this->isQuestionInSurvey($fi)) {
877 $next_id =
$ilDB->nextId(
'svy_svy_qst');
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())
885 $this->svy_log->debug(
"insert svy_svy_qst, id:" . $next_id .
", fi: " . $fi .
", seq:" . $seq);
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);
899 string $questiontype,
910 if ($question_id < 1) {
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",
919 if ($result->numRows() === 1) {
921 return $data[
"type_tag"];
929 return $this->survey_id;
937 switch ($a_anonymize) {
938 case self::ANONYMIZE_OFF:
939 case self::ANONYMIZE_ON:
940 case self::ANONYMIZE_FREEACCESS:
941 case self::ANONYMIZE_CODE_ALL:
942 $this->anonymize = $a_anonymize;
945 $this->anonymize = self::ANONYMIZE_OFF;
952 return $this->anonymize;
958 $this->calculate_sum_score = $a_val;
963 return $this->calculate_sum_score;
969 return ($this->getAnonymize() === self::ANONYMIZE_OFF ||
970 $this->getAnonymize() === self::ANONYMIZE_FREEACCESS);
976 return ($this->getAnonymize() === self::ANONYMIZE_ON ||
977 $this->getAnonymize() === self::ANONYMIZE_FREEACCESS);
983 $result =
$ilDB->queryF(
984 "SELECT * FROM svy_svy WHERE obj_fi = %s",
986 array($this->
getId())
988 if ($result->numRows() === 1) {
990 $this->setSurveyId(
$data[
"survey_id"]);
991 $this->setAuthor(
$data[
"author"] ??
"");
993 if (
$data[
"outro"] ===
"survey_finished") {
994 $this->setOutro($this->
lng->txt(
"survey_finished"));
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']);
1009 $this->setMode(
$data[
'mode']);
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']);
1016 $this->setSelfEvaluationResults((
int)
$data[
'mode_self_eval_results']);
1018 $this->setSkillService((
bool)
$data[
'mode_skill_service']);
1020 $this->setReminderStatus((
bool)
$data[
"reminder_status"]);
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"] ??
""));
1033 $this->setMailOwnResults((
bool)
$data[
"own_results_mail"]);
1034 $this->setMailConfirmation((
bool)
$data[
"confirmation_mail"]);
1035 $this->setCalculateSumScore((
bool)
$data[
"calculate_sum_score"]);
1037 $this->setAnonymousUserList((
bool)
$data[
"anon_user_list"]);
1041 if (isset($this->ref_id) && $this->ref_id !== 0) {
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"]);
1052 $this->setActivationLimited(
false);
1061 $this->questions = array();
1062 $result =
$ilDB->queryF(
1063 "SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
1065 array($this->getSurveyId())
1068 $this->questions[
$data[
"sequence"]] =
$data[
"question_fi"];
1080 $result =
$ilDB->queryF(
1081 "SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
1083 array($this->getSurveyId())
1088 $to_delete_ids = array();
1090 if (in_array(
$data[
"question_fi"], $fis)) {
1091 $to_delete_ids[] =
$data[
"survey_question_id"];
1093 $fis[] =
$data[
"question_fi"];
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);
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);
1111 $set =
$ilDB->query(
"SELECT * FROM svy_svy_qst " .
1112 " WHERE survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
" ORDER BY sequence");
1114 while ($rec =
$ilDB->fetchAssoc($set)) {
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")
1120 $this->svy_log->debug(
"update: " .
$q);
1127 $this->author = $author;
1136 string $a_author =
""
1138 if ($a_author ===
'') {
1139 $ilUser = $this->user;
1140 $a_author = $ilUser->getFullname();
1142 $this->domain->metadata()->saveAuthorsInLOMIfNoLifecycleSet(
1153 return $this->domain->metadata()->getAuthorsFromLOM(
1162 return (
bool) $this->display_question_titles;
1167 $this->display_question_titles = $a_show;
1171 string $introduction =
""
1173 $this->introduction = $introduction;
1179 $this->outro = $outro;
1184 return $this->start_date;
1191 string $start_date =
""
1193 $this->start_date = $start_date;
1210 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/", $start_date, $matches)) {
1215 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $start_time, $matches)) {
1220 $this->start_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m,
$d, $h, $i, $s);
1225 return $this->end_date;
1232 string $end_date =
""
1234 $this->end_date = $end_date;
1239 $start = $this->getStartDate();
1249 $end = $this->getEndDate();
1271 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/", $end_date, $matches)) {
1276 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $end_time, $matches)) {
1281 $this->end_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m,
$d, $h, $i, $s);
1287 return $this->evaluation_access;
1291 string $evaluation_access = self::EVALUATION_ACCESS_OFF
1293 $this->evaluation_access = $evaluation_access;
1299 $this->activation_visibility = $a_value;
1304 return $this->activation_visibility;
1309 return $this->activation_limited;
1314 $this->activation_limited = $a_value;
1319 return $this->introduction;
1324 return $this->outro;
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",
1339 array($this->getSurveyId())
1342 if (
$data[
"original_id"]) {
1343 $existing_questions[] = (
int)
$data[
"original_id"];
1346 return $existing_questions;
1354 bool $could_be_offline =
false,
1355 bool $showPath =
false
1368 array $move_questions,
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);
1382 foreach ($move_questions as $question_id) {
1383 if (!(!in_array($question_id, $part1))) {
1384 unset($part1[array_search($question_id, $part1)]);
1387 if (!(!in_array($question_id, $part2))) {
1388 unset($part2[array_search($question_id, $part2)]);
1393 if ($found !== count($move_questions)) {
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) {
1405 $this->deleteConstraint($constraint[
"id"]);
1410 $this->saveQuestionsToDb();
1419 $question = self::_instanciateQuestion($question_id);
1420 #20610 if no question found, do nothing.
1422 $question->delete($question_id);
1423 $this->removeConstraintsConcerningQuestion($question_id);
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())
1440 if ($result->numRows() > 0) {
1441 $remove_constraints = array();
1442 while ($row =
$ilDB->fetchAssoc($result)) {
1443 $remove_constraints[] = $row[
"constraint_fi"];
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())
1450 foreach ($remove_constraints as $key => $constraint_id) {
1451 $affectedRows =
$ilDB->manipulateF(
1452 "DELETE FROM svy_constraint WHERE constraint_id = %s",
1454 array($constraint_id)
1466 array $remove_questions,
1467 array $remove_questionblocks
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;
1482 foreach ($block_sizes as $block_id => $size) {
1484 $remove_questionblocks[] = $block_id;
1488 foreach (array_unique($remove_questionblocks) as $questionblock_id) {
1489 $affectedRows =
$ilDB->manipulateF(
1490 "DELETE FROM svy_qblk WHERE questionblock_id = %s",
1492 array($questionblock_id)
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())
1501 $this->questions = array_values($this->questions);
1502 $this->saveQuestionsToDb();
1510 array $questionblocks
1513 foreach ($questionblocks as $index) {
1514 $affectedRows =
$ilDB->manipulateF(
1515 "DELETE FROM svy_qblk WHERE questionblock_id = %s",
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())
1532 int $questionblock_id
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)
1548 int $questionblock_id
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)
1562 $this->deleteConstraints($question_id);
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)) {
1592 int $questionblock_id
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",
1601 array($questionblock_id)
1604 while ($row =
$ilDB->fetchAssoc($result)) {
1605 $titles[$row[
"question_fi"]] = $row[
"title"];
1606 $survey_id = $row[
"survey_fi"];
1608 $result =
$ilDB->queryF(
1609 "SELECT question_fi, sequence FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
1613 $resultarray = array();
1615 while ($row =
$ilDB->fetchAssoc($result)) {
1616 if (array_key_exists($row[
"question_fi"], $titles)) {
1617 $resultarray[
$counter++] = $titles[$row[
"question_fi"]];
1620 return $resultarray;
1629 int $questionblock_id
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",
1638 array($questionblock_id)
1641 if ($result->numRows()) {
1643 if (!in_array(
$data[
'question_fi'], $ids)) {
1644 $ids[] = (
int)
$data[
'question_fi'];
1656 int $questionblock_id
1661 $result =
$ilDB->queryF(
1662 "SELECT * FROM svy_qblk WHERE questionblock_id = %s",
1664 array($questionblock_id)
1666 $row =
$ilDB->fetchAssoc($result);
1676 bool $show_questiontext =
true,
1677 bool $show_blocktitle =
false,
1678 bool $compress_view =
false
1683 $next_id =
$ilDB->nextId(
'svy_qblk');
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)
1699 bool $show_questiontext,
1700 bool $show_blocktitle,
1702 bool $compress_view =
false
1708 $this->moveQuestions($questions, $questions[0], 0);
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)
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');
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)
1730 $this->deleteConstraints($index);
1740 int $questionblock_id,
1742 bool $show_questiontext,
1743 bool $show_blocktitle,
1744 bool $compress_view =
false
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)
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())
1768 $constraints = array();
1769 while ($row =
$ilDB->fetchAssoc($result)) {
1770 $constraints[] = $row[
"constraint_fi"];
1772 foreach ($constraints as $constraint_id) {
1773 $this->deleteConstraint($constraint_id);
1785 $affectedRows =
$ilDB->manipulateF(
1786 "DELETE FROM svy_constraint WHERE constraint_id = %s",
1788 array($constraint_id)
1790 $affectedRows =
$ilDB->manipulateF(
1791 "DELETE FROM svy_qst_constraint WHERE constraint_fi = %s",
1793 array($constraint_id)
1802 bool $with_answers =
false
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",
1813 array($this->getSurveyId())
1815 while ($row =
$ilDB->fetchAssoc($result)) {
1817 if ($row[
"plugin"]) {
1821 $question = self::_instanciateQuestion($row[
"question_id"]);
1822 $questionrow = $question->getQuestionDataArray($row[
"question_id"]);
1823 foreach ($row as $key => $value) {
1824 $questionrow[$key] = $value;
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();
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'),
1839 array($this->getSurveyId())
1841 while ($row =
$ilDB->fetchAssoc($result)) {
1842 $questionblocks[$row[
'question_fi']] = $row;
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'];
1852 $all_questions[$question_id][
"questionblock_title"] =
"";
1853 $all_questions[$question_id][
"questionblock_id"] =
"";
1855 $all_questions[$question_id][
"constraints"] = $constraints;
1856 if ($with_answers) {
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",
1865 if ($result->numRows() > 0) {
1867 $answers[] =
$data[
"title"];
1870 $all_questions[$question_id][
"answers"] = $answers;
1873 return $all_questions;
1882 array $obligatory_questions
1885 $result =
$ilDB->queryF(
1886 "SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
1888 array($this->getSurveyId())
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;
1898 foreach ($obligatory_questions as $question_fi => $obligatory) {
1900 $ilDB->manipulate(
"UPDATE svy_question" .
1901 " SET obligatory = " .
$ilDB->quote($obligatory,
"integer") .
1902 " WHERE question_id = " .
$ilDB->quote($question_fi,
"integer"));
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",
1921 array($this->getSurveyId())
1923 while ($row =
$ilDB->fetchAssoc($result)) {
1924 $all_questions[$row[
"question_id"]] = $row;
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'),
1934 array($this->getSurveyId())
1936 while ($row =
$ilDB->fetchAssoc($result)) {
1937 $questionblocks[$row[
'question_fi']] = $row;
1941 $all_pages = array();
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'])) {
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'];
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;
1967 $constraints = $this->getConstraints($question_id);
1968 $all_questions[$question_id][
"constraints"] = $constraints;
1969 if (!isset($all_pages[$pageindex])) {
1970 $all_pages[$pageindex] = array();
1972 $all_pages[$pageindex][] = $all_questions[$question_id];
1975 $max = count($all_pages);
1977 foreach ($all_pages as $index => $block) {
1978 foreach ($block as $blockindex => $question) {
1979 $all_pages[$index][$blockindex][
"position"] =
$counter / $max;
1996 int $active_page_question_id,
2000 $pages = $this->getSurveyPages();
2001 if ($active_page_question_id === 0) {
2004 foreach ($pages as $key => $question_array) {
2005 foreach ($question_array as $question) {
2006 if ($active_page_question_id == $question[
"question_id"]) {
2011 if ($foundpage === -1) {
2014 $foundpage += $direction;
2015 if ($foundpage < 0) {
2018 if ($foundpage >= count($pages)) {
2021 return $pages[$foundpage];
2029 bool $use_obj_id =
false,
2030 bool $could_be_offline =
false,
2031 bool $showPath =
false,
2032 string $permission =
"read"
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",
2051 array($constraint_id)
2054 if ($result->numRows()) {
2055 $pc =
$ilDB->fetchAssoc($result);
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())
2078 while ($row =
$ilDB->fetchAssoc($result)) {
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
2093 return $result_array;
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",
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']
2124 return $result_array;
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",
2145 while ($row =
$ilDB->fetchObject($result)) {
2146 $result_array[$row->sequence] = $row;
2148 return $result_array;
2161 int $if_question_id,
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)
2175 if ($affectedRows) {
2187 int $to_question_id,
2192 $next_id =
$ilDB->nextId(
'svy_qst_constraint');
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)
2205 int $precondition_id,
2206 int $if_question_id,
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)
2228 foreach ($questions as $question_id) {
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)
2242 bool $short_as_key =
false
2247 $custom_order = array(
"equal",
"not_equal",
"less",
"less_or_equal",
"more",
"more_or_equal");
2248 $custom_order = array_flip($custom_order);
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"]]);
2256 $result_array[$row[
"relation_id"]] = array(
"short" => $row[
"shortname"],
"long" => $row[
"longname"],
"order" => $custom_order[$row[
"longname"]]);
2261 foreach ($result_array as $idx => $item) {
2262 unset($result_array[$idx][
"order"]);
2265 return $result_array;
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)
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)
2303 if ($result->numRows() >= 1) {
2304 while ($row =
$ilDB->fetchAssoc($result)) {
2305 $result_array[] = $row;
2308 return $result_array;
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)
2329 if ($this->getMode() === self::MODE_SELF_EVAL) {
2330 $user = $this->getUserDataFromActiveId($finished_id);
2332 $sskill->writeAndAddSelfEvalSkills($user[
'usr_id']);
2336 if ($this->getMode() === self::MODE_IND_FEEDB) {
2340 $raters = $this->getRatersData($appr_id);
2341 $run_manager = $this->survey_service
2344 ->run($this, $this->
user->getId(), $appr_id);
2345 $run = $run_manager->getById($finished_id);
2348 $rater_id = $run->getUserId();
2350 foreach ($raters as
$id => $rater) {
2351 if (($rater[
"code"] ??
"") === $run->getCode()) {
2358 $sskill->writeAndAddIndFeedbackSkills($finished_id, $appr_id, $rater_id);
2361 $this->checkTutorNotification();
2377 "UPDATE svy_finished SET lastpage = %s WHERE finished_id = %s",
2378 array(
'integer',
'integer'),
2379 array(($page_id) ?: 0, $finished_id)
2391 string $a_anonymize_id,
2395 $placeholders = array(
2396 "FIRST_NAME" =>
"firstname",
2397 "LAST_NAME" =>
"lastname",
2400 "firstname" =>
"firstname"
2405 $recipients = explode(
",", $this->mailaddresses ??
"");
2406 foreach ($recipients as $recipient) {
2409 $ntf->setLangModules(array(
"survey"));
2410 $ntf->setRefId($this->getRefId());
2411 $ntf->setSubjectLangId(
'finished_mail_subject');
2413 $messagetext = $this->mailparticipantdata;
2415 if (trim($messagetext ??
"")) {
2416 if (!$this->hasAnonymizedResults()) {
2420 foreach ($placeholders as $key => $mapping) {
2421 if ($this->hasAnonymizedResults()) {
2422 $messagetext = str_replace(
'[' . $key .
']',
'', $messagetext);
2424 $messagetext = str_replace(
'[' . $key .
']', trim(
$data[$mapping] ??
""), $messagetext);
2427 $ntf->setIntroductionDirect($messagetext);
2429 $ntf->setIntroductionLangId(
'survey_notification_finished_introduction');
2434 $ntf->addAdditionalInfo(
2435 'survey_360_appraisee',
2440 $active_id = $this->getActiveID($a_user_id, $a_anonymize_id, $a_appr_id);
2442 $ntf->addAdditionalInfo(
2444 $this->getParticipantTextResults($active_id),
2449 $ntf->setGotoLangId(
'survey_notification_tutor_link');
2450 $ntf->setReasonLangId(
'survey_notification_finished_reason');
2452 $recipient = trim($recipient ??
"");
2455 $ntf->sendMailAndReturnRecipients([
$user_id]);
2458 if (count($user_ids) > 0) {
2459 $ntf->sendMailAndReturnRecipients([current($user_ids)]);
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];
2495 if (is_array($found)) {
2496 $text = implode(
"\n", $found);
2501 $text = self::getSurveySkippedValue();
2504 $textresult .=
$text .
"\n\n";
2515 string $anonymize_id,
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)
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)
2538 if ($result->numRows() === 0) {
2541 $row =
$ilDB->fetchAssoc($result);
2542 return (
int) $row[
"finished_id"];
2554 $result =
$ilDB->queryF(
2555 "SELECT lastpage FROM svy_finished WHERE finished_id = %s",
2559 if ($row =
$ilDB->fetchAssoc($result)) {
2560 return (
int) $row[
"lastpage"];
2574 array $constraint_data,
2575 ?array $working_data
2577 if (!is_array($working_data) || count($working_data) === 0) {
2581 if ((count($working_data) === 1) and (strcmp($working_data[0][
"value"],
"") === 0)) {
2586 foreach ($working_data as
$data) {
2587 switch ($constraint_data[
"short"]) {
2589 if (
$data[
"value"] < $constraint_data[
"value"]) {
2595 if (
$data[
"value"] <= $constraint_data[
"value"]) {
2601 if (
$data[
"value"] == $constraint_data[
"value"]) {
2607 if (
$data[
"value"] <> $constraint_data[
"value"]) {
2613 if (
$data[
"value"] >= $constraint_data[
"value"]) {
2619 if (
$data[
"value"] > $constraint_data[
"value"]) {
2629 return (
int) $found;
2642 $result =
$ilDB->queryF(
2643 "SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
2647 return (
bool) $result->numRows();
2660 $result =
$ilDB->queryF(
2661 "SELECT * FROM svy_finished WHERE survey_fi = %s",
2663 array($this->getSurveyId())
2665 if ($result->numRows()) {
2666 while ($row =
$ilDB->fetchAssoc($result)) {
2667 $users[] = (
int) $row[
"finished_id"];
2681 $evaluation = array();
2683 foreach (array_keys($this->getSurveyQuestions()) as $question_id) {
2687 $question =
new $question_type();
2688 $question->loadFromDb($question_id);
2691 $q_res = $q_eval->getResults();
2694 foreach ($finished_ids as
$user_id) {
2698 $evaluation[$question_id] =
$data;
2710 bool $force_non_anonymous =
false
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",
2722 $foundrows = $result->numRows();
2724 $row =
$ilDB->fetchAssoc($result);
2726 $name = ($use_anonymous_id) ? $row[
"anonymous_id"] : $this->
lng->txt(
"anonymous");
2728 "fullname" => $name,
2729 "sortname" => $name,
2734 "active_id" => (
string) $active_id
2737 if (($row[
"user_fi"] > 0) &&
2739 !$this->hasAnonymizedResults() &&
2740 !$this->get360Mode()) ||
2741 $force_non_anonymous)) {
2743 $userdata[
"fullname"] = $userdata[
"sortname"] = $this->
lng->txt(
"deleted_user");
2746 $userdata[
'usr_id'] = $row[
'user_fi'];
2749 if (strlen($gender) === 1) {
2750 $gender = $this->
lng->txt(
"gender_$gender");
2752 $userdata[
"gender"] = $gender;
2756 $userdata[
"login"] = $user->
getLogin();
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();
2783 $result =
$ilDB->queryF(
2784 "SELECT * FROM svy_answer WHERE active_fi = %s",
2788 while ($row =
$ilDB->fetchAssoc($result)) {
2789 if (!is_array($answers[$row[
"question_fi"]])) {
2790 $answers[$row[
"question_fi"]] = array();
2792 $answers[$row[
"question_fi"]][] = $row;
2794 $userdata = $this->getUserDataFromActiveId($active_id);
2796 "name" => $userdata[
"fullname"],
2797 "firstname" => $userdata[
"firstname"],
2798 "lastname" => $userdata[
"lastname"],
2799 "login" => $userdata[
"login"],
2800 "gender" => $userdata[
"gender"],
2801 "answers" => array()
2803 foreach ($questions as $key => $question) {
2804 if (array_key_exists($key, $answers)) {
2805 $resultset[
"answers"][$key] = $answers[$key];
2807 $resultset[
"answers"][$key] = array();
2809 sort($resultset[
"answers"][$key]);
2823 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title'])) {
2824 $where .=
" AND " .
$ilDB->like(
'svy_question.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
2826 if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description'])) {
2827 $where .=
" AND " .
$ilDB->like(
'svy_question.description',
'text',
"%%" . $arrFilter[
'description'] .
"%%");
2829 if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author'])) {
2830 $where .=
" AND " .
$ilDB->like(
'svy_question.author',
'text',
"%%" . $arrFilter[
'author'] .
"%%");
2832 if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type'])) {
2833 $where .=
" AND svy_qtype.type_tag = " .
$ilDB->quote($arrFilter[
'type'],
'text');
2835 if (array_key_exists(
'spl', $arrFilter) && strlen($arrFilter[
'spl'])) {
2836 $where .=
" AND svy_question.obj_fi = " .
$ilDB->quote($arrFilter[
'spl'],
'integer');
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');
2843 $existing_questions = $this->getExistingQuestions();
2844 if (count($existing_questions)) {
2845 $existing =
" AND " .
$ilDB->in(
'svy_question.question_id', $existing_questions,
true,
'integer');
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);
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) {
2865 $row[
'ttype'] = $trans[$row[
'type_tag']];
2866 if ($row[
"plugin"]) {
2886 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title'])) {
2887 $where .=
" AND " .
$ilDB->like(
'svy_qblk.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
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");
2895 if ($query_result->numRows()) {
2897 $surveytitles = array();
2898 foreach ($survey_ref_ids as $survey_ref_id) {
2902 while ($row =
$ilDB->fetchAssoc($query_result)) {
2903 $questions_array = $this->getQuestionblockQuestions($row[
"questionblock_id"]);
2905 foreach ($questions_array as $key => $value) {
2906 $questions_array[$key] =
"$counter. $value";
2909 if (strlen($surveytitles[$row[
"obj_fi"]] ??
"")) {
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"]
2931 $a_xml_writer->xmlHeader();
2933 "xmlns:xsi" =>
"http://www.w3.org/2001/XMLSchema-instance",
2934 "xsi:noNamespaceSchemaLocation" =>
"https://www.ilias.de/download/xsd/ilias_survey_4_2.xsd"
2936 $a_xml_writer->xmlStartTag(
"surveyobject", $attrs);
2938 "id" => $this->getSurveyId(),
2941 $a_xml_writer->xmlStartTag(
"survey", $attrs);
2943 $a_xml_writer->xmlElement(
"description",
null, $this->getDescription());
2944 $a_xml_writer->xmlElement(
"author",
null, $this->getAuthor());
2945 $a_xml_writer->xmlStartTag(
"objectives");
2947 "label" =>
"introduction"
2949 $this->addMaterialTag($a_xml_writer, $this->getIntroduction(),
true,
true, $attrs);
2953 $this->addMaterialTag($a_xml_writer, $this->getOutro(),
true,
true, $attrs);
2954 $a_xml_writer->xmlEndTag(
"objectives");
2956 if ($this->getAnonymize()) {
2957 $attribs = array(
"enabled" =>
"1");
2959 $attribs = array(
"enabled" =>
"0");
2961 $a_xml_writer->xmlElement(
"anonymisation", $attribs);
2962 $a_xml_writer->xmlStartTag(
"restrictions");
2963 if ($this->getAnonymize() === 2) {
2964 $attribs = array(
"type" =>
"free");
2966 $attribs = array(
"type" =>
"restricted");
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]));
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]));
2979 $a_xml_writer->xmlEndTag(
"restrictions");
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;
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"])) {
2998 foreach ($question[
"constraints"] as $constraint) {
3000 "sourceref" => $question[
"question_id"],
3001 "destref" => $constraint[
"question"],
3002 "relation" => $constraint[
"short"],
3003 "value" => $constraint[
"value"],
3004 "conjunction" => $constraint[
"conjunction"]
3006 $a_xml_writer->xmlElement(
"constraint", $attribs);
3011 $a_xml_writer->xmlEndTag(
"constraints");
3015 $a_xml_writer->xmlStartTag(
"metadata");
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();
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();
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();
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");
3047 $a_xml_writer->xmlEndTag(
"metadata");
3048 $a_xml_writer->xmlEndTag(
"survey");
3050 $attribs = array(
"id" => $this->
getId());
3051 $a_xml_writer->xmlStartTag(
"surveyquestions", $attribs);
3053 foreach ($pages as $question_array) {
3054 if (count($question_array) > 1) {
3055 $attribs = array(
"id" => $question_array[0][
"question_id"]);
3057 "showQuestiontext" => $question_array[0][
"questionblock_show_questiontext"],
3058 "showBlocktitle" => $question_array[0][
"questionblock_show_blocktitle"],
3059 "compressView" => $question_array[0][
"questionblock_compress_view"]
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"]);
3066 foreach ($question_array as $question) {
3067 if (strlen($question[
"heading"] ??
"")) {
3068 $a_xml_writer->xmlElement(
"textblock",
null, $question[
"heading"]);
3070 $questionObject = self::_instanciateQuestion($question[
"question_id"]);
3074 if ($questionObject !==
false) {
3075 $questionObject->insertXML($a_xml_writer,
false);
3078 if (count($question_array) > 1) {
3079 $a_xml_writer->xmlEndTag(
"questionblock");
3083 $a_xml_writer->xmlEndTag(
"surveyquestions");
3084 $a_xml_writer->xmlEndTag(
"surveyobject");
3085 $xml = $a_xml_writer->xmlDumpMem(
false);
3096 if ($question_id < 1) {
3100 if ($question_type ===
'') {
3104 $question =
new $question_type();
3105 $question->loadFromDb($question_id);
3117 if (!is_dir($a_dir) || is_int(strpos($a_dir,
".."))) {
3120 $importDirectory =
"";
3123 $current_dir = opendir($a_dir);
3125 while ($entryname = readdir($current_dir)) {
3126 $files[] = $entryname;
3129 foreach ($files as $file) {
3130 if (is_dir($a_dir .
"/" . $file) and ($file !==
"." and $file !==
"..")) {
3132 $importDirectory = $a_dir .
"/" . $file;
3135 closedir($current_dir);
3136 if ($importDirectory !==
'') {
3138 $current_dir = opendir($importDirectory);
3140 while ($entryname = readdir($current_dir)) {
3141 $files[] = $entryname;
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))) {
3149 $xmlFile = $importDirectory .
"/" . $file;
3153 return array(
"dir" => $importDirectory,
"xml" => $xmlFile);
3167 if ($svy_qpl_id < 1) {
3171 $source = $file_info[
"tmp_name"];
3173 if (($source ===
'none') || (!$source) || $file_info[
"error"] > UPLOAD_ERR_OK) {
3174 $error = $this->
lng->txt(
"import_no_file_selected");
3179 if ((strcmp($file_info[
"type"],
"text/xml") === 0) || (strcmp($file_info[
"type"],
"application/xml") === 0)) {
3180 $this->svy_log->debug(
"isXML");
3184 $suffix = pathinfo($file_info[
"name"]);
3185 if (strcmp(strtolower($suffix[
"extension"]),
"zip") === 0) {
3186 $this->svy_log->debug(
"isZip");
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"] .
"\"");
3193 if ($error ===
'') {
3195 $import_dir = $this->getImportDirectory();
3196 $import_subdir =
"";
3199 $importfile = $import_dir .
"/" . $file_info[
"name"];
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");
3207 $importfile = $found[
"xml"];
3208 $import_subdir = $found[
"dir"];
3210 $importfile = tempnam($import_dir,
"survey_import");
3214 $this->svy_log->debug(
"Import file = $importfile");
3215 $this->svy_log->debug(
"Import subdir = $import_subdir");
3217 $fh = fopen($importfile,
'rb');
3219 $error = $this->
lng->txt(
"import_error_opening_file");
3222 $xml = fread($fh, filesize($importfile));
3223 $result = fclose($fh);
3225 $error = $this->
lng->txt(
"import_error_closing_file");
3229 $this->import_manager->clearMobs();
3230 if (strpos($xml,
"questestinterop")) {
3233 $this->svy_log->debug(
"survey id = " . $this->
getId());
3234 $this->svy_log->debug(
"question pool id = " . $svy_qpl_id);
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());
3247 public function cloneObject(
int $target_id,
int $copy_id = 0,
bool $omit_tree =
false): ?
ilObject
3251 $this->loadFromDb();
3254 $svy_type = $this->getMode();
3257 $newObj = parent::cloneObject($target_id, $copy_id, $omit_tree);
3258 $this->cloneMetaData($newObj);
3259 $newObj->updateMetaData();
3261 $newObj->setAuthor($this->getAuthor());
3262 $newObj->setIntroduction($this->getIntroduction());
3263 $newObj->setOutro($this->getOutro());
3264 $newObj->setEvaluationAccess($this->getEvaluationAccess());
3265 $newObj->setStartDate($this->getStartDate());
3266 $newObj->setEndDate($this->getEndDate());
3267 $newObj->setAnonymize($this->getAnonymize());
3268 $newObj->setShowQuestionTitles($this->getShowQuestionTitles());
3269 $newObj->setMailOwnResults($this->hasMailOwnResults());
3270 $newObj->setMailConfirmation($this->hasMailConfirmation());
3271 $newObj->setAnonymousUserList($this->hasAnonymousUserList());
3273 $newObj->setMode($this->getMode());
3274 $newObj->set360SelfEvaluation($this->get360SelfEvaluation());
3275 $newObj->set360SelfAppraisee($this->get360SelfAppraisee());
3276 $newObj->set360SelfRaters($this->get360SelfRaters());
3277 $newObj->set360Results($this->get360Results());
3278 $newObj->setSkillService($this->getSkillService());
3281 $newObj->setReminderStatus($this->getReminderStatus());
3282 $newObj->setReminderStart($this->getReminderStart());
3283 $newObj->setReminderEnd($this->getReminderEnd());
3284 $newObj->setReminderFrequency($this->getReminderFrequency());
3285 $newObj->setReminderTarget($this->getReminderTarget());
3286 $newObj->setReminderTemplate($this->getReminderTemplate());
3288 $newObj->setTutorNotificationStatus($this->getTutorNotificationStatus());
3289 $newObj->setTutorNotificationRecipients($this->getTutorNotificationRecipients());
3290 $newObj->setTutorNotificationTarget($this->getTutorNotificationTarget());
3291 $newObj->setTutorResultsStatus($this->getTutorResultsStatus());
3292 $newObj->setTutorResultsRecipients($this->getTutorResultsRecipients());
3294 $newObj->setMailNotification($this->getMailNotification());
3295 $newObj->setMailAddresses($this->getMailAddresses());
3296 $newObj->setMailParticipantData($this->getMailParticipantData());
3298 $question_pointer = array();
3302 foreach ($this->questions as $key => $question_id) {
3304 $question = self::_instanciateQuestion($question_id);
3308 $question->setObjId($newObj->getId());
3309 $question->saveToDb($original_id);
3310 $newObj->questions[$key] = $question->getId();
3311 $question_pointer[$question_id] = $question->getId();
3312 $mapping[$question_id] = $question->getId();
3319 if (!$cp_options->isRootNode($this->getRefId())) {
3320 $newObj->setOfflineStatus($this->getOfflineStatus());
3323 $newObj->saveToDb();
3324 $newObj->cloneTextblocks($mapping);
3327 if (($svy_type === self::MODE_360 || $svy_type === self::MODE_SELF_EVAL) &&
3328 $this->getSkillService()) {
3332 foreach ($mapping as $src_qst_id => $tgt_qst_id) {
3333 $qst_skill = $src_skills->getSkillForQuestion($src_qst_id);
3335 $tgt_skills->addQuestionSkillAssignment($tgt_qst_id, $qst_skill[
"base_skill_id"], $qst_skill[
"tref_id"]);
3340 $thresholds->cloneTo($newObj, $mapping);
3344 $questionblocks = array();
3345 $questionblock_questions = array();
3346 $result =
$ilDB->queryF(
3347 "SELECT * FROM svy_qblk_qst WHERE survey_fi = %s",
3349 array($this->getSurveyId())
3351 if ($result->numRows() > 0) {
3352 while ($row =
$ilDB->fetchAssoc($result)) {
3353 $questionblock_questions[] = $row;
3354 $questionblocks[$row[
"questionblock_fi"]] = $row[
"questionblock_fi"];
3358 foreach ($questionblocks as $key => $value) {
3359 $questionblock = self::_getQuestionblock($key);
3360 $questionblock_id = self::_addQuestionblock(
3361 (
string) $questionblock[
"title"],
3362 (
int) $questionblock[
"owner_fi"],
3363 (
bool) $questionblock[
"show_questiontext"],
3364 (
bool) $questionblock[
"show_blocktitle"],
3365 (
bool) $questionblock[
"compress_view"]
3367 $questionblocks[$key] = $questionblock_id;
3370 foreach ($questionblock_questions as $key => $value) {
3371 if ($questionblocks[$value[
"questionblock_fi"]] &&
3372 $question_pointer[$value[
"question_fi"]]) {
3373 $next_id =
$ilDB->nextId(
'svy_qblk_qst');
3374 $affectedRows =
$ilDB->manipulateF(
3375 "INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, question_fi) " .
3376 "VALUES (%s, %s, %s, %s)",
3377 array(
'integer',
'integer',
'integer',
'integer'),
3378 array($next_id, $newObj->getSurveyId(), $questionblocks[$value[
"questionblock_fi"]], $question_pointer[$value[
"question_fi"]])
3384 $constraints = self::_getConstraints($this->getSurveyId());
3385 $newConstraints = array();
3386 foreach ($constraints as $key => $constraint) {
3387 if ($question_pointer[$constraint[
"for_question"]] &&
3388 $question_pointer[$constraint[
"question"]]) {
3389 if (!array_key_exists($constraint[
'id'], $newConstraints)) {
3390 $constraint_id = $newObj->addConstraint($question_pointer[$constraint[
"question"]], $constraint[
"relation_id"], $constraint[
"value"], $constraint[
'conjunction']);
3391 $newConstraints[$constraint[
'id']] = $constraint_id;
3393 $newObj->addConstraintToQuestion($question_pointer[$constraint[
"for_question"]], $newConstraints[$constraint[
'id']]);
3399 $obj_settings->cloneSettings($newObj->getId());
3400 unset($obj_settings);
3412 $result =
$ilDB->queryF(
3413 "SELECT * FROM svy_svy_qst WHERE question_fi = %s",
3417 if ($row =
$ilDB->fetchAssoc($result)) {
3418 return $row[
"heading"] ??
"";
3432 foreach ($mapping as $original_id => $new_id) {
3433 $textblock = $this->getTextblock($original_id);
3448 if (!is_writable($svy_data_dir)) {
3449 throw new ilSurveyException(
"Survey Data Directory (" . $svy_data_dir .
") not writeable.");
3453 $svy_dir = $svy_data_dir .
"/svy_" . $this->
getId();
3455 if (!is_dir($svy_dir)) {
3459 $export_dir = $svy_dir .
"/export";
3461 if (!is_dir($export_dir)) {
3487 if (!is_writable($svy_data_dir)) {
3488 throw new ilSurveyException(
"Survey Data Directory (" . $svy_data_dir .
") not writeable.");
3492 $svy_dir = $svy_data_dir .
"/svy_" . $this->
getId();
3494 if (!is_dir($svy_dir)) {
3499 $import_dir = $svy_dir .
"/import";
3501 if (!is_dir($import_dir)) {
3513 "/svy_" . $this->
getId() .
"/import";
3514 if (!is_dir($import_dir)) {
3517 if (is_dir($import_dir)) {
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)
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)
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())
3562 return $result->numRows() === 1;
3575 ?array $a_codes =
null,
3576 ?array $a_ids =
null
3579 $ilUser = $this->user;
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";
3589 $sql .=
" AND " .
$ilDB->in(
"svy_anonymous.survey_key", $a_codes,
"",
"text");
3591 $sql .=
" AND " .
$ilDB->in(
"svy_anonymous.anonymous_id", $a_ids,
"",
"text");
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);
3608 $result =
$ilDB->query($sql);
3609 $default_lang = $ilUser->getPref(
"survey_code_language");
3610 while ($row =
$ilDB->fetchAssoc($result)) {
3612 $item[] = $row[
"survey_key"];
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"];
3629 $item[] = ($this->isSurveyCodeUsed($row[
"survey_key"])) ? 1 : 0;
3630 $item[] = ($row[
"sent"]) ? 1 : 0;
3632 $params = array(
"accesscode" => $row[
"survey_key"]);
3633 if ($default_lang) {
3634 $params[
"lang"] = $default_lang;
3636 $item[] = ilLink::_getLink($this->getRefId(),
"svy",
$params);
3638 $export[] =
'"' . implode(
'";"', $item) .
'"';
3640 return implode(
"\n", $export);
3650 ?
string $lang =
null
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")
3663 $sql .=
" AND " .
$ilDB->in(
"svy_anonymous.anonymous_id", $ids,
"",
"integer");
3666 $sql .=
" ORDER BY tstamp, survey_key ASC";
3667 $result =
$ilDB->query($sql);
3668 if ($result->numRows() > 0) {
3669 while ($row =
$ilDB->fetchAssoc($result)) {
3672 if ($this->isSurveyCodeUsed($row[
"survey_key"])) {
3675 $params = array(
"accesscode" => $row[
"survey_key"]);
3679 $href = ilLink::_getLink($this->getRefId(),
"svy",
$params);
3684 'id' => $row[
"anonymous_id"],
3685 'code' => $row[
"survey_key"],
3686 'date' => $row[
"tstamp"],
3688 'sent' => $row[
'sent'],
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'] ??
"";
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)
3720 return $result->numRows() > 0;
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)
3735 return !(($result->numRows() > 0));
3742 string $a_anonymize_key,
3748 $next_id =
$ilDB->nextId(
'svy_anonymous');
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)
3772 $check_finished = ($not_sent > 1);
3776 $recipients = $this->getExternalCodeRecipients($check_finished);
3777 foreach ($recipients as
$data) {
3780 switch ($not_sent) {
3782 $do_send = !(bool)
$data[
'sent'];
3786 $do_send =
$data[
'finished'];
3790 $do_send = !
$data[
'finished'];
3799 $messagetext = $message;
3800 $url = ilLink::_getLink(
3804 "accesscode" =>
$data[
"code"],
3808 $messagetext = str_replace(
'[url]',
$url, $messagetext);
3809 foreach (
$data as $key => $value) {
3810 $messagetext = str_replace(
'[' . $key .
']', $value, $messagetext);
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())
3838 bool $a_check_finished =
false
3841 $result =
$ilDB->queryF(
3842 "SELECT survey_key code, externaldata, sent FROM svy_anonymous WHERE survey_fi = %s",
3844 array($this->getSurveyId())
3847 while ($row =
$ilDB->fetchAssoc($result)) {
3848 if (!$row[
'externaldata']) {
3852 $externaldata = unserialize((
string) $row[
'externaldata'], [
'allowed_classes' =>
false]);
3853 if (!$externaldata[
'email']) {
3857 $externaldata[
'code'] = $row[
'code'];
3858 $externaldata[
'sent'] = $row[
'sent'];
3860 if ($a_check_finished) {
3863 $externaldata[
'finished'] = $this->isSurveyFinishedByCode($row[
'code']);
3866 $res[] = $externaldata;
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)
3885 $row = $this->db->fetchAssoc($result);
3887 return $row[
'state'] ??
false;
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)
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))
3922 if ($result->numRows()) {
3923 $row =
$ilDB->fetchAssoc($result);
3924 $access_code = $row[
"survey_key"];
3926 return $access_code;
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())
3961 $result =
$ilDB->queryF(
3962 "SELECT tstamp FROM svy_answer WHERE active_fi = %s ORDER BY tstamp DESC",
3966 if ($result->numRows()) {
3967 $row =
$ilDB->fetchAssoc($result);
3968 return (
int) $row[
"tstamp"];
3970 $result =
$ilDB->queryF(
3971 "SELECT tstamp FROM svy_finished WHERE finished_id = %s",
3975 if ($result->numRows()) {
3976 $row =
$ilDB->fetchAssoc($result);
3977 return (
int) $row[
"tstamp"];
3999 if (preg_match(
"/<[^>]*?>/", $a_text)) {
4013 bool $close_material_tag =
true,
4014 bool $add_mobs =
true,
4015 ?array $attribs =
null
4017 $a_xml_writer->xmlStartTag(
"material", $attribs);
4019 "type" =>
"text/plain"
4021 if ($this->isHTML($a_material)) {
4022 $attrs[
"type"] =
"text/xhtml";
4025 $a_xml_writer->
xmlElement(
"mattext", $attrs, $mattext);
4029 foreach ($mobs as $mob) {
4030 $mob_id =
"il_" .
IL_INST_ID .
"_mob_" . $mob;
4031 if (strpos($mattext, $mob_id) !==
false) {
4035 "uri" =>
"objects/" .
"il_" .
IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle(),
4036 "type" =>
"svy:html",
4037 "id" => $this->getId()
4039 $a_xml_writer->
xmlElement(
"matimage", $imgattrs,
null);
4043 if ($close_material_tag) {
4057 if ($this->getAnonymize() !== self::ANONYMIZE_OFF) {
4058 if ($this->surveyCodeSecurity ===
false) {
4067 $this->survey_id = $survey_id;
4082 if (count($ids) === 0) {
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;
4091 return $result_array;
4099 return $this->mailnotification;
4107 $this->mailnotification = $a_notification;
4115 return $this->mailaddresses;
4123 $this->mailaddresses = $a_addresses;
4131 return $this->mailparticipantdata;
4139 $this->mailparticipantdata = $a_data;
4150 $result =
$ilDB->queryF(
4151 "SELECT * FROM svy_times WHERE finished_fi = %s",
4156 while ($row =
$ilDB->fetchAssoc($result)) {
4157 if ($row[
'left_page'] > 0 && $row[
'entered_page'] > 0) {
4158 $total += $row[
'left_page'] - $row[
'entered_page'];
4167 if (count($this->questions) === count($a_order)) {
4168 $this->questions = array_flip($a_order);
4169 $this->saveQuestionsToDb();
4175 return $this->pool_usage;
4180 $this->pool_usage = $a_value;
4189 string $a_last_name,
4190 string $a_first_name,
4195 $a_email = trim($a_email);
4202 $data = array(
"email" => $a_email,
4203 "lastname" => trim($a_last_name),
4204 "firstname" => trim($a_first_name));
4207 "externaldata" => array(
"text", serialize(
$data)),
4208 "sent" => array(
"integer", $a_sent)
4214 array(
"anonymous_id" => array(
"integer", $a_id))
4227 if ($this->getMode() === self::MODE_360) {
4235 $this->mode_360_self_eval = $a_value;
4240 return $this->mode_360_self_eval;
4245 $this->mode_360_self_appr = $a_value;
4250 return $this->mode_360_self_appr;
4255 $this->mode_360_self_rate = $a_value;
4260 return $this->mode_360_self_rate;
4265 $this->mode_360_results = $a_value;
4270 return $this->mode_360_results;
4282 $access =
$DIC->access();
4284 if (!$this->isAppraisee($a_user_id) &&
4287 "obj_id" => array(
"integer", $this->getSurveyId()),
4288 "user_id" => array(
"integer", $a_user_id)
4290 $ilDB->insert(
"svy_360_appr", $fields);
4294 $this->sendAppraiseeNotification($a_user_id);
4307 $ntf->setRefId($this->getRefId());
4308 $ntf->setGotoLangId(
'url');
4311 $lng = $ntf->getUserLanguage($a_user_id);
4313 $ntf->setIntroductionLangId(
"svy_user_added_appraisee_mail");
4314 $subject = str_replace(
"%1", $this->
getTitle(),
$lng->txt(
"svy_user_added_appraisee"));
4323 $ntf->composeAndGetMessage($a_user_id,
null,
"read",
true),
4336 $ntf->setRefId($this->getRefId());
4337 $ntf->setGotoLangId(
'url');
4340 $lng = $ntf->getUserLanguage($a_user_id);
4342 $ntf->setIntroductionLangId(
"svy_user_added_appraisee_close_mail");
4343 $subject = str_replace(
"%1", $this->
getTitle(),
$lng->txt(
"svy_user_added_appraisee"));
4352 $ntf->composeAndGetMessage($a_user_id,
null,
"read",
true),
4366 $ntf->setRefId($this->getRefId());
4367 $ntf->setGotoLangId(
'url');
4370 $lng = $ntf->getUserLanguage($a_user_id);
4372 $ntf->setIntroductionLangId(
"svy_user_added_rater_mail");
4373 $subject = str_replace(
"%1", $this->
getTitle(),
$lng->txt(
"svy_user_added_rater"));
4383 $ntf->composeAndGetMessage($a_user_id,
null,
"read",
true),
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);
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);
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"));
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"]);
4438 if ($this->get360SelfEvaluation()) {
4439 $this->deleteRater($a_user_id, $a_user_id);
4452 $set =
$ilDB->query(
"SELECT * FROM svy_360_appr" .
4453 " WHERE obj_id = " .
$ilDB->quote($this->getSurveyId(),
"integer"));
4454 while ($row =
$ilDB->fetchAssoc($set)) {
4457 $name[
"name"] = $name[
"lastname"] .
", " . $name[
"firstname"];
4458 $res[$row[
"user_id"]] = $name;
4461 $raters = $this->getRatersData($row[
"user_id"]);
4462 foreach ($raters as $rater) {
4463 if ($rater[
"finished"]) {
4467 $res[$row[
"user_id"]][
"finished"] = $finished .
"/" . count($raters);
4468 $res[$row[
"user_id"]][
"closed"] = $row[
"has_closed"];
4478 int $a_appraisee_id,
4480 int $a_anonymous_id = 0
4485 $access =
$DIC->access();
4487 if ($this->isAppraisee($a_appraisee_id) &&
4488 !$this->isRater($a_appraisee_id, $a_user_id, $a_anonymous_id)) {
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)
4495 $ilDB->insert(
"svy_360_rater", $fields);
4511 int $a_appraisee_id,
4513 int $a_anonymous_id = 0
4518 if ($this->isAppraisee($a_user_id) &&
4519 $this->get360SelfEvaluation() &&
4520 (!$a_appraisee_id || $a_appraisee_id === $a_user_id)) {
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");
4534 $set =
$ilDB->query($sql);
4535 return (
bool)
$ilDB->numRows($set);
4542 int $a_appraisee_id,
4544 int $a_anonymous_id = 0
4548 $finished_id = $this->getFinishedIdForAppraiseeIdAndRaterId($a_appraisee_id, $a_user_id);
4550 $this->removeSelectedSurveyResults(array($finished_id));
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"));
4568 $res = $anonymous_ids = array();
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"],
4580 $anonymous_ids[] = $row[
"anonymous_id"];
4583 $name[
"name"] = $name[
"lastname"] .
", " . $name[
"firstname"];
4584 $name[
"user_id"] =
"u" . $name[
"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;
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"],
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"])
4621 ?
int $a_anonymous_id =
null
4627 $sql =
"SELECT appr_id FROM svy_360_rater" .
4628 " WHERE obj_id = " .
$ilDB->quote($this->getSurveyId(),
"integer");
4631 $sql .=
" AND user_id = " .
$ilDB->quote($a_user_id,
"integer");
4633 $sql .=
" AND anonymous_id = " .
$ilDB->quote($a_anonymous_id,
"integer");
4636 $set =
$ilDB->query($sql);
4637 while ($row =
$ilDB->fetchAssoc($set)) {
4638 $res[] = (
int) $row[
"appr_id"];
4642 if ($this->get360SelfEvaluation() &&
4643 $this->isAppraisee((
int) $a_user_id) &&
4644 !in_array($a_user_id,
$res)) {
4645 $res[] = $a_user_id;
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"));
4662 return $res[
"anonymous_id"] ??
null;
4671 ?
string $anonymous_code =
null
4675 $sql =
"SELECT * FROM svy_finished" .
4676 " WHERE survey_fi =" .
$ilDB->quote($this->getSurveyId(),
"integer") .
4677 " AND appr_id = " .
$ilDB->quote($appr_id,
"integer");
4679 $sql .=
" AND user_fi = " .
$ilDB->quote(
$user_id,
"integer");
4681 $sql .=
" AND anonymous_id = " .
$ilDB->quote($anonymous_code,
"text");
4683 $result =
$ilDB->query($sql);
4684 if ($result->numRows() === 0) {
4687 $row =
$ilDB->fetchAssoc($result);
4688 return (
int) $row[
"state"];
4701 ?
string $a_code =
null
4703 $ilUser = $this->
user;
4707 if (!$this->isAccessibleWithoutCode()) {
4710 if ($this->feature_config->usesAppraisees() &&
4714 $code = $this->data_manager->code(
"")
4716 $this->code_manager->add($code);
4717 $a_code = $this->code_manager->getByUserId(
$user_id);
4723 $this->getAnonymize() === self::ANONYMIZE_FREEACCESS) {
4728 $code = $this->data_manager->code(
"")
4730 $code_id = $this->code_manager->add($code);
4731 $a_code = $this->code_manager->getByCodeId($code_id);
4740 $sql =
"SELECT * FROM svy_finished" .
4741 " WHERE survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer");
4744 $sql .=
" AND (user_fi = " .
$ilDB->quote(
$user_id,
"integer") .
4745 " OR anonymous_id = " .
$ilDB->quote($a_code,
"text") .
")";
4749 $sql .=
" AND anonymous_id = " .
$ilDB->quote($a_code,
"text");
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"]);
4758 return array(
"code" => $a_code,
"runs" =>
$res);
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"] ??
"");
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"));
4806 bool $a_exclude_appraisee =
false
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) {
4819 $res[] = (
int) $row[
"finished_id"];
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"];
4850 $this->mode_skill_service = $a_val;
4855 return $this->mode_skill_service;
4862 int $a_appraisee_id,
4864 int $a_anonymous_id,
4865 ?
int $a_tstamp =
null
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"));
4890 $user =
$DIC->user();
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"));
4900 if ($this->getSkillService() && $skmg_set->isActivated()) {
4902 $sskill->writeAndAddAppraiseeSkills($a_user_id);
4906 if ($user->
getId() !== $a_user_id) {
4907 $this->sendAppraiseeCloseNotification($a_user_id);
4918 $ilDB->manipulate(
"UPDATE svy_360_appr" .
4919 " SET has_closed = " .
$ilDB->quote(
null,
"integer") .
4920 " WHERE obj_id = " .
$ilDB->quote($this->getSurveyId(),
"integer"));
4926 public static function validateExternalRaterCode(
4933 $anonym_repo =
$DIC->survey()
4939 if (!$anonym_repo->isExternalRaterValidated($a_ref_id)) {
4940 $svy =
new self($a_ref_id);
4943 $domain_service =
$DIC->survey()->internal()->domain();
4944 $code_manager = $domain_service->code($svy, 0);
4945 $feature_config = $domain_service->modeFeatureConfig($svy->getMode());
4946 $access_manager = $domain_service->access($a_ref_id, 0);
4948 if ($access_manager->canStartSurvey() &&
4950 $code_manager->exists($a_code)) {
4951 $anonymous_id = $svy->getAnonymousIdByCode($a_code);
4952 if ($anonymous_id) {
4953 if (count($svy->getAppraiseesToRate(
null, $anonymous_id))) {
4954 $anonym_repo->setExternalRaterValidation($a_ref_id,
true);
4959 $anonym_repo->setExternalRaterValidation($a_ref_id,
false);
4963 return $anonym_repo->isExternalRaterValidated($a_ref_id);
4973 return $this->reminder_status;
4978 $this->reminder_status = $a_value;
4983 return $this->reminder_start;
4988 $this->reminder_start = $a_value;
4993 return $this->reminder_end;
4998 $this->reminder_end = $a_value;
5003 return $this->reminder_frequency;
5008 $this->reminder_frequency = $a_value;
5013 return $this->reminder_target;
5018 $this->reminder_target = $a_value;
5023 return $this->reminder_last_sent;
5028 if ($a_value ==
"") {
5031 $this->reminder_last_sent = $a_value;
5035 bool $selectDefault =
false
5037 if ($selectDefault) {
5038 $defaultTemplateId = 0;
5039 $this->getReminderMailTemplates($defaultTemplateId);
5041 if ($defaultTemplateId > 0) {
5042 return $defaultTemplateId;
5046 return $this->reminder_tmpl;
5051 $this->reminder_tmpl = $a_value;
5056 return $this->tutor_ntf_status;
5064 $this->tutor_ntf_status = $a_value;
5072 return $this->tutor_ntf_recipients;
5080 $this->tutor_ntf_recipients = $a_value;
5091 return $this->tutor_ntf_target;
5096 $this->tutor_ntf_target = $a_value;
5101 return $this->tutor_res_status;
5106 $this->tutor_res_status = $a_value;
5111 return $this->tutor_res_recipients;
5116 $this->tutor_res_recipients = $a_value;
5127 if ($this->getTutorNotificationStatus()) {
5130 $user_ids = $this->getNotificationTargetUserIds(($this->getTutorNotificationTarget() === self::NOTIFICATION_INVITED_USERS));
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);
5139 if ((
int) $row[
"numall"] === count($user_ids)) {
5140 $this->sendTutorNotification();
5153 $access =
$DIC->access();
5155 $rater_ids = array();
5156 foreach ($this->getAppraiseesData() as $app) {
5157 $this->svy_log->debug(
"Handle appraisee " . $app[
'user_id']);
5159 if (!$this->isAppraiseeClosed($app[
'user_id'])) {
5160 $this->svy_log->debug(
"Check self evaluation, self: " . $this->get360SelfAppraisee() .
", target: " . $this->getReminderTarget());
5163 if ($this->get360SelfEvaluation() &&
5164 in_array($this->getReminderTarget(), array(self::NOTIFICATION_APPRAISEES, self::NOTIFICATION_APPRAISEES_AND_RATERS))) {
5165 $this->svy_log->debug(
"...1");
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();
5172 if (!isset($app[
"user_id"], $rater_ids[$app[
'user_id']])) {
5173 $rater_ids[$app[
'user_id']][] = $app[
"user_id"];
5178 $this->svy_log->debug(
"Check raters.");
5183 $this->getReminderTarget(),
5184 array(self::NOTIFICATION_RATERS, self::NOTIFICATION_APPRAISEES_AND_RATERS),
5188 foreach ($this->getRatersData($app[
'user_id']) as $rater) {
5190 if ($rater[
"login"] !==
"") {
5193 if ($rater_id > 0) {
5195 if (!($rater[
"anonymous_id"] ??
false) && !($rater[
"finished"] ??
false)) {
5196 if (!isset($rater_ids[$rater_id])) {
5197 $rater_ids[$rater_id] = array();
5199 if (!in_array($app[
"user_id"], $rater_ids[$rater_id])) {
5200 $rater_ids[$rater_id][] = $app[
"user_id"];
5209 $this->svy_log->debug(
"Found raters:" . count($rater_ids));
5211 foreach ($rater_ids as
$id => $app) {
5213 $this->send360ReminderToUser((
int)
$id, $app);
5220 array $a_appraisee_ids
5222 $this->svy_log->debug(
"Send mail to:" . $a_user_id);
5225 $ntf->setLangModules(array(
"svy",
"survey"));
5226 $ntf->setRefId($this->getRefId());
5227 $ntf->setGotoLangId(
'url');
5230 $lng = $ntf->getUserLanguage($a_user_id);
5232 $ntf->setIntroductionLangId(
"svy_user_added_rater_reminder_mail");
5233 $subject = str_replace(
"%1", $this->
getTitle(),
$lng->txt(
"svy_user_added_rater"));
5235 foreach ($a_appraisee_ids as $appraisee_id) {
5246 $ntf->composeAndGetMessage($a_user_id,
null,
"read",
true),
5261 $tree = $this->tree;
5264 if ($a_use_invited) {
5265 $user_ids = $this->invitation_manager->getAllForSurvey($this->getSurveyId());
5267 $parent_grp_ref_id = $tree->checkForParentType($this->getRefId(),
"grp");
5268 if ($parent_grp_ref_id) {
5270 $user_ids = $part->getMembers();
5272 $parent_crs_ref_id = $tree->checkForParentType($this->getRefId(),
"crs");
5273 if ($parent_crs_ref_id) {
5275 $user_ids = $part->getMembers();
5290 foreach ($this->getTutorNotificationRecipients() as
$user_id) {
5293 $ulng->loadLanguageModule(
'survey');
5295 $subject = sprintf($ulng->txt(
'survey_notification_tutor_subject'), $this->getTitle());
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;
5303 $mail_obj->appendInstallationSignature(
true);
5318 $ilAccess = $this->access;
5321 $now_with_format = date(
"YmdHis", $now);
5322 $today = date(
"Y-m-d");
5324 $this->svy_log->debug(
"Check status and dates.");
5328 $this->getOfflineStatus() ||
5329 !$this->getReminderStatus() ||
5330 ($this->getStartDate() && $now_with_format < $this->getStartDate()) ||
5331 ($this->getEndDate() && $now_with_format > $this->getEndDate())) {
5336 $start = $this->getReminderStart();
5340 $end = $this->getReminderEnd();
5344 if ($today < $start ||
5345 ($end && $today > $end)) {
5349 $this->svy_log->debug(
"Check access period.");
5354 ($now < $item_data[
"timing_start"] ||
5355 $now > $item_data[
"timing_end"])) {
5359 $this->svy_log->debug(
"Check frequency.");
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.");
5371 $user_ids = $this->getNotificationTargetUserIds(($this->getReminderTarget() === self::NOTIFICATION_INVITED_USERS));
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"];
5384 $missing_ids = array_diff($user_ids, $finished_ids);
5386 foreach ($missing_ids as $idx =>
$user_id) {
5388 if (!$ilAccess->checkAccessOfUser(
$user_id,
"read",
"", $this->getRefId(),
"svy", $this->getId())) {
5389 unset($missing_ids[$idx]);
5394 $this->sentReminder($missing_ids);
5398 $this->svy_log->debug(
"Entering 360 mode.");
5400 $this->sent360Reminders();
5404 $this->setReminderLastSent($today);
5407 return count($missing_ids);
5413 protected function sentReminder(
5414 array $a_recipient_ids
5421 if ($this->getReminderTemplate() &&
5422 array_key_exists($this->getReminderTemplate(), $this->getReminderMailTemplates())) {
5424 $templateService =
$DIC->mail()->textTemplates();
5425 $tmpl = $templateService->loadTemplateForId($this->getReminderTemplate());
5427 $tmpl_params = array(
5428 "ref_id" => $this->getRefId(),
5433 $tmpl_params =
null;
5437 foreach ($a_recipient_ids as
$user_id) {
5439 $subject = $tmpl->getSubject();
5440 $message = $this->sentReminderPlaceholders($tmpl->getMessage(),
$user_id, $tmpl_params);
5446 $ulng->loadLanguageModule(
'survey');
5448 $subject = sprintf($ulng->txt(
'survey_reminder_subject'), $this->getTitle());
5451 $message .= $ulng->txt(
'survey_reminder_body') .
":\n\n";
5452 $message .= $ulng->txt(
'obj_svy') .
": " . $this->
getTitle() .
"\n";
5453 $message .=
"\n" . $ulng->txt(
'survey_reminder_link') .
": " . $link;
5457 $mail_obj->appendInstallationSignature(
true);
5470 ?
int $starting_time =
null
5472 $this->activation_starting_time = $starting_time;
5476 ?
int $ending_time =
null
5478 $this->activation_ending_time = $ending_time;
5483 return $this->activation_starting_time;
5488 return $this->activation_ending_time;
5493 $this->view_own_results = $a_value;
5498 return $this->view_own_results;
5503 $this->mail_own_results = $a_value;
5508 return $this->mail_own_results;
5513 $this->mail_confirmation = $a_value;
5518 return $this->mail_confirmation;
5523 $this->anon_user_list = $a_value;
5528 return $this->anon_user_list;
5539 $surveySetting =
new ilSetting(
"survey");
5540 if (!$surveySetting->get(
"skipped_is_custom",
false)) {
5541 return $lng->txt(
"skipped");
5543 return $surveySetting->get(
"skipped_custom_value",
"");
5548 ?
int &$defaultTemplateId =
null
5554 $templateService =
$DIC->mail()->textTemplates();
5556 $res[$tmpl->getTplId()] = $tmpl->getTitle();
5557 if (
null !== $defaultTemplateId && $tmpl->isDefault()) {
5558 $defaultTemplateId = $tmpl->getTplId();
5568 array $a_context_params
5574 $user = new \ilObjUser($a_user_id);
5576 $a_message = $this->placeholder_resolver->resolve($context, $a_message, $user, $a_context_params);
5577 }
catch (\Exception
$e) {
5586 $this->mode = $a_value;
5596 $this->mode_self_eval_results = $a_value;
5601 return $this->mode_self_eval_results;
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");
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");
5631 while ($row =
$ilDB->fetchAssoc($set)) {
5632 $res[] = (
int) $row[
"obj_fi"];
5642 $sum_score += call_user_func([
$c,
"getMaxSumScore"], $this->getSurveyId());
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Basic class for all survey question types The SurveyQuestionGUI class defines and encapsulates basic ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getOriginalId(int $question_id, bool $a_return_question_id_if_no_original=true)
Returns the original id of a question.
static _instanciateQuestionEvaluation(int $question_id, ?array $a_finished_ids=null)
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.
static _isComplete(int $question_id)
Checks whether the question is complete or not.
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static _getInstance(int $a_copy_id)
@classDescription Date and time handling
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getDataDir()
get data directory (outside webspace)
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getLanguageOfUser(int $a_usr_id)
Get language object of user.
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 _getStaticLink(?int $a_ref_id, string $a_type='', bool $a_fallback_goto=true, string $append="")
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
setLangModules(array $a_modules)
Class ilObjSurveyQuestionPool.
static _getQuestionClasses()
static _getQuestionTypeTranslations()
set360SelfAppraisee(bool $a_value)
sendRaterNotification(int $a_user_id, int $a_appraisee_id)
string $author
A text representation of the authors name.
isAccessibleWithoutCode()
isUnusedCode(string $a_code, int $a_user_id)
Participants InvitationsManager $invitation_manager
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.
getSurveyPages()
Returns the survey pages in an array (a page contains one or more questions)
getNextPage(int $active_page_question_id, int $direction)
Get current, previous or next page.
removeQuestionFromBlock(int $question_id, int $questionblock_id)
addRater(int $a_appraisee_id, int $a_user_id, int $a_anonymous_id=0)
isSurveyCodeUsed(string $code)
setEndDateAndTime(string $end_date, string $end_time)
importSurveyCode(string $a_anonymize_key, int $a_created, array $a_data)
const EVALUATION_ACCESS_PARTICIPANTS
isSurveyFinishedByCode(string $a_code)
Get if survey is finished for a specific anonymous user code.
const RESULTS_SELF_EVAL_NONE
setStartDateAndTime(string $start_date, string $start_time)
getExternalCodeRecipients(bool $a_check_finished=false)
Mode FeatureConfig $feature_config
removeQuestion(int $question_id)
setAnonymousUserList(bool $a_value)
closeAppraisee(int $a_user_id)
bool $calculate_sum_score
moveQuestions(array $move_questions, int $target_index, int $insert_mode)
Move questions and/or questionblocks to another position.
getFinishedIdForAppraiseeIdAndRaterId(int $a_appr_id, int $a_rat_id)
Get finished id for an appraisee and a rater.
addAppraisee(int $a_user_id)
getUserSpecificResults(array $finished_ids)
Calculates the evaluation data for the user specific results.
getQuestionblockQuestions(int $questionblock_id)
getSurveyFinishedIds()
Get run ids.
setReminderStatus(bool $a_value)
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.
string $mailparticipantdata
getActivationVisibility()
getTextblock(int $question_id)
int $activation_ending_time
setSelfEvaluationResults(int $a_value)
setTutorNotificationStatus(bool $a_value)
Activates mail being sent to tutors after all participants have finished the survey.
prepareTextareaOutput(string $txt_output)
Prepares a string for a text area output in surveys.
createImportDirectory()
creates data directory for import files (data_dir/svy_data/svy_<id>/import)
static _addQuestionblock(string $title="", int $owner=0, bool $show_questiontext=true, bool $show_blocktitle=false, bool $compress_view=false)
is360SurveyStarted(int $appr_id, int $user_id, ?string $anonymous_code=null)
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.
__construct(int $a_id=0, bool $a_call_by_reference=true)
getUserSettings(int $usr_id, string $key)
setReminderLastSent(?string $a_value)
getSurveyCodesTableData(?array $ids=null, ?string $lang=null)
Fetches the data for the survey codes table.
array $tutor_res_recipients
isQuestionInSurvey(int $a_question_fi)
set360Results(int $a_value)
getEvaluationByUser(array $questions, int $active_id)
Calculates the evaluation data for a given run.
set360RaterSent(int $a_appraisee_id, int $a_user_id, int $a_anonymous_id, ?int $a_tstamp=null)
setSurveyId(int $survey_id)
isQuestionInAnyBlock(int $a_question_fi)
sendAppraiseeNotification(int $a_user_id)
static _getQuestionblock(int $questionblock_id)
get question block properties
locateImportFiles(string $a_dir)
Locates the import directory and the xml file in a directory with an unzipped import file.
getTutorNotificationRecipients()
Mail being sent to tutors after all participants have finished the survey?
getSurveyQuestions(bool $with_answers=false)
Returns the survey questions and questionblocks in an array.
setOutro(string $outro="")
getSelfEvaluationResults()
int $activation_starting_time
addQuestion(int $question_id)
Adds a question to the survey (used in importer!)
setTutorResultsRecipients(array $a_value)
const NOTIFICATION_INVITED_USERS
const RESULTS_SELF_EVAL_ALL
updateConstraint(int $precondition_id, int $if_question_id, int $relation, float $value, int $conjunction)
getExistingQuestions()
Gets the question id's of the questions which are already in the survey.
deleteConstraint(int $constraint_id)
Deletes a single constraint.
setReminderTemplate(?int $a_value)
setSkillService(bool $a_val)
removeSelectedSurveyResults(array $finished_ids)
Deletes the user data of a given array of survey participants.
saveUserAccessCode(int $user_id, string $access_code)
Saves a survey access code for a registered user to the database.
setObligatoryStates(array $obligatory_questions)
Sets the obligatory states for questions in a survey from the questions form.
setActivationEndDate(?int $ending_time=null)
setIntroduction(string $introduction="")
setEndDate(string $end_date="")
ilPluginAdmin $plugin_admin
sendCodes(int $not_sent, string $subject, string $message, string $lang)
setStartDate(string $start_date="")
getQuestionblocksTable(array $arrFilter)
Retrieve data for question block browser.
getUserAccessCode(int $user_id)
Returns a survey access code that was saved for a registered user.
const NOTIFICATION_PARENT_COURSE
const EVALUATION_ACCESS_ALL
isRater(int $a_appraisee_id, int $a_user_id, int $a_anonymous_id=0)
InternalDomainService $domain
bool $activation_visibility
deleteWorkingData(int $question_id, int $active_id)
Deletes the working data of a question in the database.
int $mode_self_eval_results
getQuestionsTable(array $arrFilter)
Retrieve data for question browser.
insertQuestionblock(int $questionblock_id)
getUserDataFromActiveId(int $active_id, bool $force_non_anonymous=false)
Returns run information.
getUserData(array $ids)
Returns a data of all users specified by id list.
getTutorNotificationTarget()
Group that is checked for the "all participants have finished" mail Either a) all members of a parent...
getNotificationTargetUserIds(bool $a_use_invited)
These users must finish the survey to trigger the tutor notification "all users finished the survey" ...
ILIAS SurveyQuestionPool Export ImportManager $import_manager
getFinishedIdsForAppraiseeId(int $a_appr_id, bool $a_exclude_appraisee=false)
const QUESTIONTITLES_VISIBLE
getLastActivePage(int $active_id)
Returns the question id of the last active page a user visited in a survey.
deleteSurveyCode(string $survey_code)
setReminderFrequency(int $a_value)
setShowQuestionTitles(bool $a_show)
toXML()
Returns a QTI xml representation of the survey.
setActivationStartDate(?int $starting_time=null)
getAnonymousIdByCode(string $a_code)
getLastAccess(int $finished_id)
sendTutorNotification()
Send mail to tutors after all participants have finished the survey.
getReminderTemplate(bool $selectDefault=false)
loadWorkingData(int $question_id, int $active_id)
Gets the given answer data of a question in a run.
deleteConstraints(int $question_id)
Deletes the constraints for a question.
getQuestionpoolTitles(bool $could_be_offline=false, bool $showPath=false)
Returns the available question pools for the active user.
const NOTIFICATION_APPRAISEES_AND_RATERS
setPage(int $finished_id, int $page_id)
Sets the number of the active survey page.
static getSurveysWithTutorResults()
static _getConstraints(int $survey_id)
saveUserSettings(int $usr_id, string $key, string $title, string $value)
const ANONYMIZE_FREEACCESS
int $survey_id
A unique positive numerical ID which identifies the survey.
saveHeading(string $heading, int $insertbefore)
updateOrder(array $a_order)
getQuestionType(int $question_id)
deleteUserSettings(int $id)
addConstraintToQuestion(int $to_question_id, int $constraint_id)
setTutorResultsStatus(bool $a_value)
getTutorResultsRecipients()
updateConjunctionForQuestions(array $questions, int $conjunction)
setActivationVisibility(bool $a_value)
static _hasDatasets(int $survey_id)
deleteAllUserData(bool $reset_LP=true)
Deletes all user data of a survey.
getMailParticipantData()
Preceding text (incl.
setMailNotification(bool $a_notification)
Activate mail to tutors each time a participant finishes the survey.
getAllRelations(bool $short_as_key=false)
sendAppraiseeCloseNotification(int $a_user_id)
int $display_question_titles
deleteAppraisee(int $a_user_id)
getMailAddresses()
(Tutor) Recipients of "single participant has finished" mails
setTutorNotificationRecipients(array $a_value)
Set tutor recipients for "all participants have finished" mail.
isComplete()
Check if survey is complete for use.
getSurveyParticipants(?array $finished_ids=null, bool $force_non_anonymous=false, bool $include_invites=false)
setReminderTarget(int $a_value)
getQuestionblockQuestionIds(int $questionblock_id)
ilMailTemplatePlaceholderResolver $placeholder_resolver
addConstraint(int $if_question_id, int $relation, float $value, int $conjunction)
Adds a constraint.
getQuestionGUI(string $questiontype, int $question_id)
getActiveID(int $user_id, string $anonymize_id, int $appr_id)
Get run id.
getConstraints(int $question_id)
Returns the constraints to a given question or questionblock.
saveAuthorToMetadata(string $a_author="")
Saves an authors name into the lifecycle metadata if no lifecycle metadata exists This will only be c...
checkTutorNotification()
Check, if mail to tutors after all participants have finished the survey should be sent.
getWorkingtimeForParticipant(int $finished_id)
findCodeForUser(int $a_user_id)
deleteRater(int $a_appraisee_id, int $a_user_id, int $a_anonymous_id=0)
saveCompletionStatus()
Saves the completion status of the survey.
static getSurveySkippedValue()
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.
const EVALUATION_ACCESS_OFF
static _instanciateQuestion(int $question_id)
Creates an instance of a question with a given question id.
createReference()
creates reference for object
updateCode(int $a_id, string $a_email, string $a_last_name, string $a_first_name, int $a_sent)
setMailParticipantData(string $a_data)
Set preceding text (incl.
duplicateQuestionForSurvey(int $question_id, bool $a_force=false)
Takes a question and creates a copy of the question for use in the survey.
isHTML(string $a_text)
Checks if a given string contains HTML or not.
setCalculateSumScore(bool $a_val)
string $reminder_last_sent
modifyQuestionblock(int $questionblock_id, string $title, bool $show_questiontext, bool $show_blocktitle, bool $compress_view=false)
setTutorNotificationTarget(int $a_value)
setEvaluationAccess(string $evaluation_access=self::EVALUATION_ACCESS_OFF)
getImportDirectory()
get import directory of survey
deleteSurveyRecord()
Deletes the survey from the database.
createQuestionblock(string $title, bool $show_questiontext, bool $show_blocktitle, array $questions, bool $compress_view=false)
cloneTextblocks(array $mapping)
Clones the text blocks of survey questions.
isAppraiseeClosed(int $a_user_id)
const RESULTS_SELF_EVAL_OWN
sent360Reminders()
Send 360 reminders.
getTutorNotificationStatus()
finishSurvey(int $finished_id, int $appr_id=0)
Finishes the survey creating an entry in the database.
isAppraisee(int $a_user_id)
const NOTIFICATION_APPRAISEES
unfoldQuestionblocks(array $questionblocks)
setMailConfirmation(bool $a_value)
getParticipantTextResults(int $active_id)
isSurveyCodeUnique(string $code)
string $evaluation_access
setReminderStart(?ilDate $a_value=null)
getReminderMailTemplates(?int &$defaultTemplateId=null)
setReminderEnd(?ilDate $a_value=null)
setAnonymize(int $a_anonymize)
set anonymize status
removeConstraintsConcerningQuestion(int $question_id)
Remove constraints concerning a question with a given question_id.
importObject(array $file_info, int $svy_qpl_id)
addQuestionToBlock(int $question_id, int $questionblock_id)
removeQuestions(array $remove_questions, array $remove_questionblocks)
getAppraiseesToRate(?int $a_user_id, ?int $a_anonymous_id=null)
getUserSurveyExecutionStatus(?string $a_code=null)
Get current user execution status.
set360SelfRaters(bool $a_value)
getRatersData(int $a_appraisee_id)
getMailNotification()
Send mail to tutors each time a participant finishes the survey?
setMailAddresses(string $a_addresses)
Set (Tutor) Recipients of "single participant has finished" mails.
getPrecondition(int $constraint_id)
Returns a precondition with a given id.
checkConstraint(array $constraint_data, ?array $working_data)
Checks if a constraint is valid.
setActivationLimited(bool $a_value)
setPoolUsage(bool $a_value)
insertQuestion(int $question_id)
Inserts a question in the survey and saves the relation to the database.
setMailOwnResults(bool $a_value)
send360ReminderToUser(int $a_user_id, array $a_appraisee_ids)
array $tutor_ntf_recipients
set360SelfEvaluation(bool $a_value)
setViewOwnResults(bool $a_value)
createExportDirectory()
creates data directory for export files (data_dir/svy_data/svy_<id>/export)
const NOTIFICATION_RATERS
setAuthor(string $author="")
canExportSurveyCode()
Checks if the survey code can be exported with the survey evaluation.
ILIAS Survey InternalDataService $data_manager
getVariables(int $question_id)
Returns all variables (answer options/scale values) of a question.
isAnonymizedParticipant(string $key)
sentReminderPlaceholders(string $a_message, int $a_user_id, array $a_context_params)
ILIAS Survey Code CodeManager $code_manager
ILIAS Survey InternalService $survey_service
const QUESTIONTITLES_HIDDEN
static _lookupFullname(int $a_user_id)
getFullname(int $max_strlen=0)
static _getUserData(array $a_internalids)
static getUserIdsByEmail(string $a_email)
static _lookupName(int $a_user_id)
static _lookupId(string|array $a_user_str)
static _lookupLogin(int $a_user_id)
static _lookupEmail(int $a_user_id)
Class ilObjectActivation.
const TIMINGS_DEACTIVATED
static getItem(int $ref_id)
static getInstance(int $obj_id)
Class ilObject Basic functions for all objects.
setOfflineStatus(bool $status)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getUsedHTMLTagsAsString(string $module='')
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...
Skill management settings.
static subStr(string $a_str, int $a_start, ?int $a_length=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Handles survey reminder mail placeholders.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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:
static is_email(string $a_email, ?ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
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,...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
usesAppraisees()
If raters rate single persons (appraisees) this mode is activated.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
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)
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
FeatureConfig $feature_config
if(!file_exists('../ilias.ini.php'))