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();
   160         $lng = $DIC->language();
   163         $this->survey_id = -1;
   164         $this->introduction = 
"";
   165         $this->outro = 
$lng->
txt(
"survey_finished");
   166         $this->author = $ilUser->getFullname();
   167         $this->evaluation_access = self::EVALUATION_ACCESS_OFF;
   168         $this->questions = array();
   169         $this->anonymize = self::ANONYMIZE_OFF;
   170         $this->display_question_titles = self::QUESTIONTITLES_VISIBLE;
   171         $this->surveyCodeSecurity = 
true;
   172         $this->pool_usage = 
true;
   173         $this->mode = self::MODE_STANDARD;
   174         $this->mode_self_eval_results = self::RESULTS_SELF_EVAL_OWN;
   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);
   442             foreach ($user_ids as $user_id) {
   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" .
   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)) {
   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);
   519                 "UPDATE svy_svy SET complete = %s, tstamp = %s WHERE survey_id = %s",
   520                 array(
'text',
'integer',
'integer'),
   532         bool $a_force = 
false   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);
   558             $this->svy_log->debug(
"question is not complete");
   562             $result = 
$ilDB->queryF(
   563                 "SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
   567             $sequence = $result->numRows();
   569             $this->svy_log->debug(
"duplicate, id: " . $question_id . 
", duplicate id: " . $duplicate_id);
   576             $next_id = 
$ilDB->nextId(
'svy_svy_qst');
   577             $affectedRows = 
$ilDB->manipulateF(
   578                 "INSERT INTO svy_svy_qst (survey_question_id, survey_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
   579                 array(
'integer', 
'integer', 
'integer', 
'integer', 
'integer'),
   580                 array($next_id, $this->
getSurveyId(), $duplicate_id, $sequence, time())
   583             $this->svy_log->debug(
"added entry to svy_svy_qst, id: " . $next_id . 
", question id: " . $duplicate_id . 
", sequence: " . $sequence);
   597         $ilDB = $DIC->database();
   599         $set = 
$ilDB->query(
"SELECT * FROM svy_svy_qst " .
   600             " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
   601             " AND question_fi = " . 
$ilDB->quote($a_question_fi, 
"integer"));
   602         if ($rec = 
$ilDB->fetchAssoc($set)) {
   610         int $questionblock_id
   613         $sequence_manager = $this->survey_service->domain()->sequence(
   619         $result = 
$ilDB->queryF(
   620             "SELECT svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.show_blocktitle," .
   621             " svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst, svy_svy_qst" .
   622             " WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi" .
   623             " AND svy_svy_qst.question_fi = svy_qblk_qst.question_fi" .
   624             " AND svy_qblk.questionblock_id = %s" .
   625             " ORDER BY svy_svy_qst.sequence",
   627             array($questionblock_id)
   629         $questions = array();
   630         $show_questiontext = 
false;
   631         $show_blocktitle = 
false;
   633         while ($row = 
$ilDB->fetchAssoc($result)) {
   635             $duplicate_id = $sequence_manager->appendQuestion($row[
"question_fi"], 
true);
   636             $questions[] = $duplicate_id;
   637             $title = (string) $row[
"title"];
   638             $show_questiontext = (bool) $row[
"show_questiontext"];
   639             $show_blocktitle = (bool) $row[
"show_blocktitle"];
   653         $next_id = 
$ilDB->nextId(
'svy_settings');
   654         $affectedRows = 
$ilDB->insert(
"svy_settings", array(
   655             "settings_id" => array(
"integer", $next_id),
   656             "usr_id" => array(
"integer", $usr_id),
   657             "keyword" => array(
"text", $key),
   658             "title" => array(
"text", $title),
   659             "value" => array(
"clob", $value)
   669             "DELETE FROM svy_settings WHERE settings_id = %s",
   681         $result = 
$ilDB->queryF(
   682             "SELECT * FROM svy_settings WHERE usr_id = %s AND keyword = %s",
   683             array(
'integer', 
'text'),
   687         if ($result->numRows()) {
   688             while ($row = 
$ilDB->fetchAssoc($result)) {
   689                 $found[$row[
'settings_id']] = $row;
   702         if (is_object($rmd_start)) {
   706         if (is_object($rmd_end)) {
   710             $next_id = 
$ilDB->nextId(
'svy_svy');
   711             $affectedRows = 
$ilDB->insert(
"svy_svy", array(
   712                 "survey_id" => array(
"integer", $next_id),
   713                 "obj_fi" => array(
"integer", $this->
getId()),
   714                 "author" => array(
"text", $this->
getAuthor()),
   718                 "enddate" => array(
"text", $this->
getEndDate()),
   720                 "complete" => array(
"text", $this->
isComplete()),
   721                 "created" => array(
"integer", time()),
   727                 "tstamp" => array(
"integer", time()),
   728                 "pool_usage" => array(
"integer", $this->
getPoolUsage()),
   730                 "mode" => array(
"integer", $this->
getMode()),
   735                 "mode_360_results" => array(
"integer", $this->
get360Results()),
   737                 "mode_skill_service" => array(
"integer", (
int) $this->
getSkillService()),
   739                 "mode_self_eval_results" => array(
"integer", self::RESULTS_SELF_EVAL_OWN),
   742                 "reminder_start" => array(
"datetime", $rmd_start),
   743                 "reminder_end" => array(
"datetime", $rmd_end),
   761             $affectedRows = 
$ilDB->update(
"svy_svy", array(
   762                 "author" => array(
"text", $this->
getAuthor()),
   766                 "enddate" => array(
"text", $this->
getEndDate()),
   768                 "complete" => array(
"text", $this->
isComplete()),
   774                 "tstamp" => array(
"integer", time()),
   775                 "pool_usage" => array(
"integer", $this->
getPoolUsage()),
   777                 "mode" => array(
"integer", $this->
getMode()),
   782                 "mode_360_results" => array(
"integer", $this->
get360Results()),
   784                 "mode_skill_service" => array(
"integer", (
int) $this->
getSkillService()),
   789                 "reminder_start" => array(
"datetime", $rmd_start),
   790                 "reminder_end" => array(
"datetime", $rmd_end),
   806             "survey_id" => array(
"integer", $this->
getSurveyId())
   828             $item->update($this->ref_id);
   837         $this->svy_log->debug(
"save questions");
   840         $old_questions = array();
   841         $result = 
$ilDB->queryF(
   842             "SELECT survey_question_id,question_fi,sequence" .
   843             " FROM svy_svy_qst WHERE survey_fi = %s",
   847         while ($row = 
$ilDB->fetchAssoc($result)) {
   848             $old_questions[$row[
"question_fi"]] = $row;         
   852         $insert = $update = $delete = array();
   853         foreach ($this->questions as $seq => $fi) {
   854             if (!array_key_exists($fi, $old_questions)) {               
   856             } elseif ($old_questions[$fi][
"sequence"] != $seq) {                                
   857                 $update[$fi] = $old_questions[$fi][
"survey_question_id"];
   860             unset($old_questions[$fi]);                                         
   864         if (count($old_questions)) {
   866             foreach ($old_questions as $fi => $old) {
   867                 $del_ids[] = $old[
"survey_question_id"];
   869             $ilDB->manipulate(
$q = 
"DELETE FROM svy_svy_qst" .
   870                 " WHERE " . 
$ilDB->in(
"survey_question_id", $del_ids, 
"", 
"integer"));
   871             $this->svy_log->debug(
"delete: " . 
$q);
   873         unset($old_questions);
   876         foreach ($this->questions as $seq => $fi) {
   877             if (in_array($fi, $insert)) {
   880                     $next_id = 
$ilDB->nextId(
'svy_svy_qst');
   882                         "INSERT INTO svy_svy_qst" .
   883                         " (survey_question_id, survey_fi, question_fi, heading, sequence, tstamp)" .
   884                         " VALUES (%s, %s, %s, %s, %s, %s)",
   885                         array(
'integer', 
'integer', 
'integer', 
'text', 
'integer', 
'integer'),
   886                         array($next_id, $this->
getSurveyId(), $fi, null, $seq, time())
   888                     $this->svy_log->debug(
"insert svy_svy_qst, id:" . $next_id . 
", fi: " . $fi . 
", seq:" . $seq);
   890             } elseif (array_key_exists($fi, $update)) {
   891                 $ilDB->manipulate(
"UPDATE svy_svy_qst" .
   892                     " SET sequence = " . 
$ilDB->quote($seq, 
"integer") .
   893                     ", tstamp = " . 
$ilDB->quote(time(), 
"integer") .
   894                     " WHERE survey_question_id = " . 
$ilDB->quote($update[$fi], 
"integer"));
   895                 $this->svy_log->debug(
"update svy_svy_qst, id:" . $update[$fi] . 
", fi: " . $fi . 
", seq:" . $seq);
   902         string $questiontype,
   913         if ($question_id < 1) {
   916         $result = 
$ilDB->queryF(
   917             "SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND " .
   918             "svy_question.questiontype_fi = svy_qtype.questiontype_id",
   922         if ($result->numRows() === 1) {
   924             return $data[
"type_tag"];
   940         switch ($a_anonymize) {
   941             case self::ANONYMIZE_OFF:
   942             case self::ANONYMIZE_ON:
   943             case self::ANONYMIZE_FREEACCESS:
   944             case self::ANONYMIZE_CODE_ALL:
   945                 $this->anonymize = $a_anonymize;
   948                 $this->anonymize = self::ANONYMIZE_OFF;
   961         $this->calculate_sum_score = $a_val;
   972         return ($this->
getAnonymize() === self::ANONYMIZE_OFF ||
   986         $result = 
$ilDB->queryF(
   987             "SELECT * FROM svy_svy WHERE obj_fi = %s",
   989             array($this->
getId())
   991         if ($result->numRows() === 1) {
   996             if ($data[
"outro"] === 
"survey_finished") {
   997                 $this->
setOutro($this->
lng->txt(
"survey_finished"));
  1002             $this->
setStartDate((
string) ($data[
"startdate"] ?? 
""));
  1003             $this->
setEndDate((
string) ($data[
"enddate"] ?? 
""));
  1012             $this->
setMode($data[
'mode']);
  1045         if (isset($this->ref_id) && $this->ref_id !== 0) {
  1047             switch ($activation[
"timing_type"]) {
  1065         $this->questions = array();
  1066         $result = 
$ilDB->queryF(
  1067             "SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
  1072             $this->questions[
$data[
"sequence"]] = $data[
"question_fi"];
  1081         $ilDB = $DIC->database();
  1084         $result = 
$ilDB->queryF(
  1085             "SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
  1092         $to_delete_ids = array();
  1094             if (in_array(
$data[
"question_fi"], $fis)) {         
  1095                 $to_delete_ids[] = 
$data[
"survey_question_id"];
  1097                 $fis[] = 
$data[
"question_fi"];
  1102         if (count($to_delete_ids) > 0) {
  1103             $ilDB->manipulate(
$q = 
"DELETE FROM svy_svy_qst" .
  1104                 " WHERE " . 
$ilDB->in(
"survey_question_id", $to_delete_ids, 
false, 
"integer") .
  1106             $this->svy_log->debug(
"delete: " . 
$q);
  1108             $ilDB->manipulate(
$q = 
"DELETE FROM svy_qblk_qst " .
  1109                 " WHERE " . 
$ilDB->in(
"question_fi", $fis, 
true, 
"integer") .
  1111             $this->svy_log->debug(
"delete: " . 
$q);
  1115         $set = 
$ilDB->query(
"SELECT * FROM svy_svy_qst " .
  1116             " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") . 
" ORDER BY sequence");
  1118         while ($rec = 
$ilDB->fetchAssoc($set)) {
  1120                 $q = 
"UPDATE svy_svy_qst SET " .
  1121                 " sequence = " . 
$ilDB->quote($seq++, 
"integer") .
  1122                 " WHERE survey_question_id = " . 
$ilDB->quote($rec[
"survey_question_id"], 
"integer")
  1124             $this->svy_log->debug(
"update: " . 
$q);
  1140         string $a_author = 
""  1143         $md_life = $md->getLifecycle();
  1145             if ($a_author === 
'') {
  1150             $md_life = $md->addLifecycle();
  1152             $con = $md_life->addContribute();
  1153             $con->setRole(
"Author");
  1155             $ent = $con->addEntity();
  1156             $ent->setEntity($a_author);
  1166         $md_life = $md->getLifecycle();
  1168             $ids = $md_life->getContributeIds();
  1169             foreach ($ids as 
$id) {
  1170                 $md_cont = $md_life->getContribute($id);
  1171                 if (strcmp($md_cont->getRole(), 
"Author") === 0) {
  1172                     $entids = $md_cont->getEntityIds();
  1173                     foreach ($entids as $entid) {
  1174                         $md_ent = $md_cont->getEntity($entid);
  1175                         $author[] = $md_ent->getEntity();
  1180         return implode(
",", $author);
  1190         $this->display_question_titles = $a_show;
  1194         string $introduction = 
""  1214         string $start_date = 
""  1233         if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/", $start_date, $matches)) {
  1238         if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $start_time, $matches)) {
  1243         $this->start_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m, 
$d, $h, $i, $s);
  1255         string $end_date = 
""  1294         if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/", $end_date, $matches)) {
  1299         if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $end_time, $matches)) {
  1304         $this->end_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m, 
$d, $h, $i, $s);
  1314         string $evaluation_access = self::EVALUATION_ACCESS_OFF
  1322         $this->activation_visibility = $a_value;
  1337         $this->activation_limited = $a_value;
  1357         $existing_questions = array();
  1358         $result = 
$ilDB->queryF(
  1359             "SELECT svy_question.original_id FROM svy_question, svy_svy_qst WHERE " .
  1360             "svy_svy_qst.survey_fi = %s AND svy_svy_qst.question_fi = svy_question.question_id",
  1365             if (
$data[
"original_id"]) {
  1366                 $existing_questions[] = (
int) 
$data[
"original_id"];
  1369         return $existing_questions;
  1377         bool $could_be_offline = 
false,
  1378         bool $showPath = 
false  1391         array $move_questions,
  1395         $array_pos = array_search($target_index, $this->questions);
  1396         $part1 = $part2 = [];
  1397         if ($insert_mode === 0) {
  1398             $part1 = array_slice($this->questions, 0, $array_pos);
  1399             $part2 = array_slice($this->questions, $array_pos);
  1400         } elseif ($insert_mode === 1) {
  1401             $part1 = array_slice($this->questions, 0, $array_pos + 1);
  1402             $part2 = array_slice($this->questions, $array_pos + 1);
  1405         foreach ($move_questions as $question_id) {
  1406             if (!(!in_array($question_id, $part1))) {
  1407                 unset($part1[array_search($question_id, $part1)]);
  1410             if (!(!in_array($question_id, $part2))) {
  1411                 unset($part2[array_search($question_id, $part2)]);
  1416         if ($found !== count($move_questions)) {
  1419         $part1 = array_values($part1);
  1420         $part2 = array_values($part2);
  1421         $this->questions = array_values(array_merge($part1, $move_questions, $part2));
  1422         foreach ($move_questions as $question_id) {
  1424             foreach ($constraints as $idx => $constraint) {
  1425                 foreach ($part2 as $next_question_id) {
  1426                     if ($constraint[
"question"] == $next_question_id) {
  1442         $question = self::_instanciateQuestion($question_id);
  1443         #20610 if no question found, do nothing.  1445             $question->delete($question_id);
  1458         $result = 
$ilDB->queryF(
  1459             "SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
  1460             array(
'integer',
'integer'),
  1463         if ($result->numRows() > 0) {
  1464             $remove_constraints = array();
  1465             while ($row = 
$ilDB->fetchAssoc($result)) {
  1466                 $remove_constraints[] = $row[
"constraint_fi"];
  1468             $affectedRows = 
$ilDB->manipulateF(
  1469                 "DELETE FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
  1470                 array(
'integer',
'integer'),
  1473             foreach ($remove_constraints as 
$key => $constraint_id) {
  1474                 $affectedRows = 
$ilDB->manipulateF(
  1475                     "DELETE FROM svy_constraint WHERE constraint_id = %s",
  1477                     array($constraint_id)
  1489         array $remove_questions,
  1490         array $remove_questionblocks
  1494         $block_sizes = array();
  1496             if (in_array($question_id, $remove_questions) or in_array(
$data[
"questionblock_id"], $remove_questionblocks)) {
  1497                 unset($this->questions[array_search($question_id, $this->questions)]);
  1499             } elseif (
$data[
"questionblock_id"]) {
  1500                 $block_sizes[
$data[
"questionblock_id"]] = ($block_sizes[$data[
"questionblock_id"]] ?? 0) + 1;
  1505         foreach ($block_sizes as $block_id => $size) {
  1507                 $remove_questionblocks[] = $block_id;
  1511         foreach (array_unique($remove_questionblocks) as $questionblock_id) {
  1512             $affectedRows = 
$ilDB->manipulateF(
  1513                 "DELETE FROM svy_qblk WHERE questionblock_id = %s",
  1515                 array($questionblock_id)
  1517             $affectedRows = 
$ilDB->manipulateF(
  1518                 "DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
  1519                 array(
'integer',
'integer'),
  1524         $this->questions = array_values($this->questions);
  1533         array $questionblocks
  1536         foreach ($questionblocks as $index) {
  1537             $affectedRows = 
$ilDB->manipulateF(
  1538                 "DELETE FROM svy_qblk WHERE questionblock_id = %s",
  1542             $affectedRows = 
$ilDB->manipulateF(
  1543                 "DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
  1544                 array(
'integer',
'integer'),
  1555         int $questionblock_id
  1560             "DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s AND question_fi = %s",
  1561             array(
'integer',
'integer',
'integer'),
  1562             array($questionblock_id, $this->
getSurveyId(), $question_id)
  1571         int $questionblock_id
  1577             $next_id = 
$ilDB->nextId(
'svy_qblk_qst');
  1578             $affectedRows = 
$ilDB->manipulateF(
  1579                 "INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
  1580                 "question_fi) VALUES (%s, %s, %s, %s)",
  1581                 array(
'integer', 
'integer', 
'integer', 
'integer'),
  1582                 array($next_id, $this->
getSurveyId(), $questionblock_id, $question_id)
  1597         $ilDB = $DIC->database();
  1599         $set = 
$ilDB->query(
"SELECT * FROM svy_qblk_qst " .
  1600             " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
  1601             " AND question_fi = " . 
$ilDB->quote($a_question_fi, 
"integer"));
  1602         if ($rec = 
$ilDB->fetchAssoc($set)) {
  1615         int $questionblock_id
  1619         $result = 
$ilDB->queryF(
  1620             "SELECT svy_question.title, svy_qblk_qst.question_fi, svy_qblk_qst.survey_fi FROM " .
  1621             "svy_qblk, svy_qblk_qst, svy_question WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND " .
  1622             "svy_question.question_id = svy_qblk_qst.question_fi AND svy_qblk.questionblock_id = %s",
  1624             array($questionblock_id)
  1627         while ($row = 
$ilDB->fetchAssoc($result)) {
  1628             $titles[$row[
"question_fi"]] = $row[
"title"];
  1629             $survey_id = $row[
"survey_fi"];
  1631         $result = 
$ilDB->queryF(
  1632             "SELECT question_fi, sequence FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
  1636         $resultarray = array();
  1638         while ($row = 
$ilDB->fetchAssoc($result)) {
  1639             if (array_key_exists($row[
"question_fi"], $titles)) {
  1640                 $resultarray[$counter++] = $titles[$row[
"question_fi"]];
  1643         return $resultarray;
  1652         int $questionblock_id
  1657         $result = 
$ilDB->queryF(
  1658             "SELECT a.question_fi FROM svy_qblk_qst a JOIN svy_svy_qst b ON (a.question_fi = b.question_fi) " .
  1659             " WHERE a.questionblock_fi = %s ORDER BY b.sequence",
  1661             array($questionblock_id)
  1664         if ($result->numRows()) {
  1666                 if (!in_array(
$data[
'question_fi'], $ids)) {            
  1667                     $ids[] = (
int) 
$data[
'question_fi'];
  1679         int $questionblock_id
  1683         $ilDB = $DIC->database();
  1684         $result = 
$ilDB->queryF(
  1685             "SELECT * FROM svy_qblk WHERE questionblock_id = %s",
  1687             array($questionblock_id)
  1689         $row = 
$ilDB->fetchAssoc($result);
  1699         bool $show_questiontext = 
true,
  1700         bool $show_blocktitle = 
false,
  1701         bool $compress_view = 
false  1705         $ilDB = $DIC->database();
  1706         $next_id = 
$ilDB->nextId(
'svy_qblk');
  1708             "INSERT INTO svy_qblk (questionblock_id, title, show_questiontext," .
  1709             " show_blocktitle, owner_fi, tstamp, compress_view) " .
  1710             "VALUES (%s, %s, %s, %s, %s, %s, %s)",
  1711             array(
'integer',
'text',
'integer',
'integer',
'integer',
'integer',
'integer'),
  1712             array($next_id, 
$title, $show_questiontext, $show_blocktitle, 
$owner, time(),$compress_view)
  1722         bool $show_questiontext,
  1723         bool $show_blocktitle,
  1725         bool $compress_view = 
false  1735         $next_id = 
$ilDB->nextId(
'svy_qblk');
  1736         $affectedRows = 
$ilDB->manipulateF(
  1737             "INSERT INTO svy_qblk (questionblock_id, title, show_questiontext," .
  1738             " show_blocktitle, owner_fi, tstamp, compress_view) VALUES (%s, %s, %s, %s, %s, %s, %s)",
  1739             array(
'integer',
'text',
'text',
'text',
'integer',
'integer',
'integer'),
  1740             array($next_id, $title, $show_questiontext, $show_blocktitle, $ilUser->getId(), time(), $compress_view)
  1742         if ($affectedRows) {
  1743             $questionblock_id = $next_id;
  1744             foreach ($questions as $index) {
  1746                     $next_id = 
$ilDB->nextId(
'svy_qblk_qst');   
  1747                     $affectedRows = 
$ilDB->manipulateF(
  1748                         "INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
  1749                         "question_fi) VALUES (%s, %s, %s, %s)",
  1750                         array(
'integer', 
'integer', 
'integer', 
'integer'),
  1751                         array($next_id, $this->
getSurveyId(), $questionblock_id, $index)
  1763         int $questionblock_id,
  1765         bool $show_questiontext,
  1766         bool $show_blocktitle,
  1767         bool $compress_view = 
false  1771             "UPDATE svy_qblk SET title = %s, show_questiontext = %s," .
  1772             " show_blocktitle = %s, compress_view = %s WHERE questionblock_id = %s",
  1773             array(
'text',
'text',
'text',
'integer', 
'integer'),
  1774             array($title, $show_questiontext, $show_blocktitle, $compress_view, $questionblock_id)
  1786         $result = 
$ilDB->queryF(
  1787             "SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
  1788             array(
'integer',
'integer'),
  1791         $constraints = array();
  1792         while ($row = 
$ilDB->fetchAssoc($result)) {
  1793             $constraints[] = $row[
"constraint_fi"];
  1795         foreach ($constraints as $constraint_id) {
  1808         $affectedRows = 
$ilDB->manipulateF(
  1809             "DELETE FROM svy_constraint WHERE constraint_id = %s",
  1811             array($constraint_id)
  1813         $affectedRows = 
$ilDB->manipulateF(
  1814             "DELETE FROM svy_qst_constraint WHERE constraint_fi = %s",
  1816             array($constraint_id)
  1825         bool $with_answers = 
false  1829         $all_questions = array();
  1830         $result = 
$ilDB->queryF(
  1831             "SELECT svy_qtype.type_tag, svy_qtype.plugin, svy_question.question_id, " .
  1832             "svy_svy_qst.heading FROM svy_qtype, svy_question, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
  1833             "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
  1834             "ORDER BY svy_svy_qst.sequence",
  1838         while ($row = 
$ilDB->fetchAssoc($result)) {
  1840             if ($row[
"plugin"]) {
  1844                 $question = self::_instanciateQuestion($row[
"question_id"]);
  1845                 $questionrow = $question->getQuestionDataArray($row[
"question_id"]);
  1846                 foreach ($row as 
$key => $value) {
  1847                     $questionrow[
$key] = $value;
  1849                 $all_questions[$row[
"question_id"]] = $questionrow;
  1850                 $all_questions[$row[
"question_id"]][
"usableForPrecondition"] = $question->usableForPrecondition();
  1851                 $all_questions[$row[
"question_id"]][
"availableRelations"] = $question->getAvailableRelations();
  1855         $questionblocks = array();
  1856         if (count($all_questions)) {
  1857             $result = 
$ilDB->queryF(
  1858                 "SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst WHERE " .
  1859                 "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
  1860                 "AND " . 
$ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions), 
false, 
'integer'),
  1864             while ($row = 
$ilDB->fetchAssoc($result)) {
  1865                 $questionblocks[$row[
'question_fi']] = $row;
  1869         foreach ($all_questions as $question_id => $row) {
  1871             if (isset($questionblocks[$question_id])) {
  1872                 $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
  1873                 $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
  1875                 $all_questions[$question_id][
"questionblock_title"] = 
"";
  1876                 $all_questions[$question_id][
"questionblock_id"] = 
"";
  1878             $all_questions[$question_id][
"constraints"] = $constraints;
  1879             if ($with_answers) {
  1881                 $result = 
$ilDB->queryF(
  1882                     "SELECT svy_variable.*, svy_category.title FROM svy_variable, svy_category " .
  1883                     "WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id " .
  1884                     "ORDER BY sequence ASC",
  1888                 if ($result->numRows() > 0) {
  1890                         $answers[] = 
$data[
"title"];
  1893                 $all_questions[$question_id][
"answers"] = $answers;
  1896         return $all_questions;
  1905         array $obligatory_questions
  1908         $result = 
$ilDB->queryF(
  1909             "SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
  1913         if ($result->numRows()) {
  1914             while ($row = 
$ilDB->fetchAssoc($result)) {
  1915                 if (!array_key_exists($row[
"question_fi"], $obligatory_questions)) {
  1916                     $obligatory_questions[$row[
"question_fi"]] = 0;
  1921         foreach ($obligatory_questions as $question_fi => $obligatory) {
  1923             $ilDB->manipulate(
"UPDATE svy_question" .
  1924                 " SET obligatory = " . 
$ilDB->quote($obligatory, 
"integer") .
  1925                 " WHERE question_id = " . 
$ilDB->quote($question_fi, 
"integer"));
  1937         $all_questions = array();
  1938         $result = 
$ilDB->queryF(
  1939             "SELECT svy_question.*, svy_qtype.type_tag, svy_svy_qst.heading FROM " .
  1940             "svy_question, svy_qtype, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
  1941             "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
  1942             "ORDER BY svy_svy_qst.sequence",
  1946         while ($row = 
$ilDB->fetchAssoc($result)) {
  1947             $all_questions[$row[
"question_id"]] = $row;
  1950         $questionblocks = array();
  1951         if (count($all_questions)) {
  1952             $result = 
$ilDB->queryF(
  1953                 "SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst " .
  1954                 "WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
  1955                 "AND " . 
$ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions), 
false, 
'integer'),
  1959             while ($row = 
$ilDB->fetchAssoc($result)) {
  1960                 $questionblocks[$row[
'question_fi']] = $row;
  1964         $all_pages = array();
  1967         foreach ($all_questions as $question_id => $row) {
  1968             $constraints = array();
  1969             if (isset($questionblocks[$question_id])) {
  1970                 if (!$currentblock or ($currentblock != $questionblocks[$question_id][
'questionblock_id'])) {
  1973                 $all_questions[$question_id][
'page'] = $pageindex;
  1974                 $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
  1975                 $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
  1976                 $all_questions[$question_id][
"questionblock_show_questiontext"] = $questionblocks[$question_id][
'show_questiontext'];
  1977                 $all_questions[$question_id][
"questionblock_show_blocktitle"] = $questionblocks[$question_id][
'show_blocktitle'];
  1978                 $all_questions[$question_id][
"questionblock_compress_view"] = $questionblocks[$question_id][
'compress_view'];
  1979                 $currentblock = $questionblocks[$question_id][
'questionblock_id'];
  1982                 $all_questions[$question_id][
'page'] = $pageindex;
  1983                 $all_questions[$question_id][
"questionblock_title"] = 
"";
  1984                 $all_questions[$question_id][
"questionblock_id"] = 
"";
  1985                 $all_questions[$question_id][
"questionblock_show_questiontext"] = 1;
  1986                 $all_questions[$question_id][
"questionblock_show_blocktitle"] = 1;
  1987                 $all_questions[$question_id][
"questionblock_compress_view"] = 
false;
  1991             $all_questions[$question_id][
"constraints"] = $constraints;
  1992             if (!isset($all_pages[$pageindex])) {
  1993                 $all_pages[$pageindex] = array();
  1995             $all_pages[$pageindex][] = $all_questions[$question_id];
  1998         $max = count($all_pages);
  2000         foreach ($all_pages as $index => $block) {
  2001             foreach ($block as $blockindex => $question) {
  2002                 $all_pages[$index][$blockindex][
"position"] = $counter / $max;
  2019         int $active_page_question_id,
  2024         if ($active_page_question_id === 0) {
  2027         foreach ($pages as 
$key => $question_array) {
  2028             foreach ($question_array as $question) {
  2029                 if ($active_page_question_id == $question[
"question_id"]) {
  2034         if ($foundpage === -1) {
  2037             $foundpage += $direction;
  2038             if ($foundpage < 0) {
  2041             if ($foundpage >= count($pages)) {
  2044             return $pages[$foundpage];
  2052         bool $use_obj_id = 
false,
  2053         bool $could_be_offline = 
false,
  2054         bool $showPath = 
false,
  2055         string $permission = 
"read"  2069         $result = 
$ilDB->queryF(
  2070             "SELECT svy_constraint.*, svy_relation.*, svy_qst_constraint.question_fi ref_question_fi FROM svy_qst_constraint, svy_constraint, " .
  2071             "svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id AND " .
  2072             "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_constraint.constraint_id = %s",
  2074             array($constraint_id)
  2077         if ($result->numRows()) {
  2078             $pc = 
$ilDB->fetchAssoc($result);
  2092         $result_array = array();
  2093         $result = 
$ilDB->queryF(
  2094             "SELECT svy_constraint.*, svy_relation.* FROM svy_qst_constraint, svy_constraint, svy_relation " .
  2095             "WHERE svy_constraint.relation_fi = svy_relation.relation_id AND " .
  2096             "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.question_fi = %s " .
  2097             "AND svy_qst_constraint.survey_fi = %s",
  2098             array(
'integer',
'integer'),
  2101         while ($row = 
$ilDB->fetchAssoc($result)) {
  2104             $question = 
new $question_type();
  2105             $question->loadFromDb($row[
"question_fi"]);
  2106             $valueoutput = $question->getPreconditionValueOutput($row[
"value"]);
  2107             $result_array[] = array(
"id" => $row[
"constraint_id"],
  2108                                     "question" => $row[
"question_fi"],
  2109                                     "short" => $row[
"shortname"],
  2110                                     "long" => $row[
"longname"],
  2111                                     "value" => $row[
"value"],
  2112                                     "conjunction" => $row[
"conjunction"],
  2113                                     "valueoutput" => $valueoutput
  2116         return $result_array;
  2127         $ilDB = $DIC->database();
  2128         $result_array = array();
  2129         $result = 
$ilDB->queryF(
  2130             "SELECT svy_qst_constraint.question_fi as for_question, svy_constraint.*, svy_relation.* " .
  2131             "FROM svy_qst_constraint, svy_constraint, svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id " .
  2132             "AND svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.survey_fi = %s",
  2136         while ($row = 
$ilDB->fetchAssoc($result)) {
  2137             $result_array[] = array(
"id" => $row[
"constraint_id"],
  2138                                     "for_question" => $row[
"for_question"],
  2139                                     "question" => $row[
"question_fi"],
  2140                                     "short" => $row[
"shortname"],
  2141                                     "long" => $row[
"longname"],
  2142                                     "relation_id" => $row[
"relation_id"],
  2143                                     "value" => $row[
"value"],
  2144                                     'conjunction' => $row[
'conjunction']
  2147         return $result_array;
  2160         $result_array = array();
  2161         $result = 
$ilDB->queryF(
  2162             "SELECT svy_variable.*, svy_category.title FROM svy_variable LEFT JOIN " .
  2163             "svy_category ON svy_variable.category_fi = svy_category.category_id WHERE svy_variable.question_fi = %s " .
  2164             "ORDER BY svy_variable.sequence",
  2168         while ($row = 
$ilDB->fetchObject($result)) {
  2169             $result_array[$row->sequence] = $row;
  2171         return $result_array;
  2184         int $if_question_id,
  2191         $next_id = 
$ilDB->nextId(
'svy_constraint');
  2192         $affectedRows = 
$ilDB->manipulateF(
  2193             "INSERT INTO svy_constraint (constraint_id, question_fi, relation_fi, value, conjunction) VALUES " .
  2194             "(%s, %s, %s, %s, %s)",
  2195             array(
'integer',
'integer',
'integer',
'float', 
'integer'),
  2196             array($next_id, $if_question_id, $relation, $value, $conjunction)
  2198         if ($affectedRows) {
  2210         int $to_question_id,
  2215         $next_id = 
$ilDB->nextId(
'svy_qst_constraint');
  2217             "INSERT INTO svy_qst_constraint (question_constraint_id, survey_fi, question_fi, " .
  2218             "constraint_fi) VALUES (%s, %s, %s, %s)",
  2219             array(
'integer',
'integer',
'integer',
'integer'),
  2220             array($next_id, $this->
getSurveyId(), $to_question_id, $constraint_id)
  2228         int $precondition_id,
  2229         int $if_question_id,
  2236             "UPDATE svy_constraint SET question_fi = %s, relation_fi = %s, value = %s, conjunction = %s " .
  2237             "WHERE constraint_id = %s",
  2238             array(
'integer',
'integer',
'float',
'integer',
'integer'),
  2239             array($if_question_id, $relation, $value, $conjunction, $precondition_id)
  2251         foreach ($questions as $question_id) {
  2253                 "UPDATE svy_constraint SET conjunction = %s " .
  2254                 "WHERE constraint_id IN (SELECT constraint_fi FROM svy_qst_constraint WHERE svy_qst_constraint.question_fi = %s)",
  2255                 array(
'integer',
'integer'),
  2256                 array($conjunction, $question_id)
  2265         bool $short_as_key = 
false  2270         $custom_order = array(
"equal", 
"not_equal", 
"less", 
"less_or_equal", 
"more", 
"more_or_equal");
  2271         $custom_order = array_flip($custom_order);
  2273         $result_array = array();
  2274         $result = 
$ilDB->query(
"SELECT * FROM svy_relation");
  2275         while ($row = 
$ilDB->fetchAssoc($result)) {
  2276             if ($short_as_key) {
  2277                 $result_array[$row[
"shortname"]] = array(
"short" => $row[
"shortname"], 
"long" => $row[
"longname"], 
"id" => $row[
"relation_id"], 
"order" => $custom_order[$row[
"longname"]]);
  2279                 $result_array[$row[
"relation_id"]] = array(
"short" => $row[
"shortname"], 
"long" => $row[
"longname"], 
"order" => $custom_order[$row[
"longname"]]);
  2284         foreach ($result_array as $idx => $item) {
  2285             unset($result_array[$idx][
"order"]);
  2288         return $result_array;
  2304         $affectedRows = 
$ilDB->manipulateF(
  2305             "DELETE FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
  2306             array(
'integer',
'integer'),
  2307             array($question_id, $active_id)
  2320         $result_array = array();
  2321         $result = 
$ilDB->queryF(
  2322             "SELECT * FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
  2323             array(
'integer',
'integer'),
  2324             array($question_id, $active_id)
  2326         if ($result->numRows() >= 1) {
  2327             while ($row = 
$ilDB->fetchAssoc($result)) {
  2328                 $result_array[] = $row;
  2331         return $result_array;
  2345             "UPDATE svy_finished SET state = %s, tstamp = %s" .
  2346             " WHERE survey_fi = %s AND finished_id = %s",
  2347             array(
'text',
'integer',
'integer',
'integer'),
  2348             array(1, time(), $this->
getSurveyId(), $finished_id)
  2352         if ($this->
getMode() === self::MODE_SELF_EVAL) {
  2355             $sskill->writeAndAddSelfEvalSkills($user[
'usr_id']);
  2359         if ($this->
getMode() === self::MODE_IND_FEEDB) {
  2364             $run_manager = $this->survey_service
  2367                 ->run($this, $this->
user->getId(), $appr_id);
  2368             $run = $run_manager->getById($finished_id);
  2371                 $rater_id = $run->getUserId();
  2373                 foreach ($raters as 
$id => $rater) {
  2374                     if (($rater[
"code"] ?? 
"") === $run->getCode()) {
  2381             $sskill->writeAndAddIndFeedbackSkills($finished_id, $appr_id, $rater_id);
  2400             "UPDATE svy_finished SET lastpage = %s WHERE finished_id = %s",
  2401             array(
'integer',
'integer'),
  2402             array(($page_id) ?: 0, $finished_id)
  2414         string $a_anonymize_id,
  2418         $placeholders = array(
  2419             "FIRST_NAME" => 
"firstname",
  2420             "LAST_NAME" => 
"lastname",
  2423             "firstname" => 
"firstname"  2428         $recipients = explode(
",", $this->mailaddresses ?? 
"");
  2429         foreach ($recipients as $recipient) {
  2432             $ntf->setLangModules(array(
"survey"));
  2434             $ntf->setSubjectLangId(
'finished_mail_subject');
  2438             if (trim($messagetext ?? 
"")) {
  2443                 foreach ($placeholders as 
$key => $mapping) {
  2445                         $messagetext = str_replace(
'[' . 
$key . 
']', 
'', $messagetext);
  2447                         $messagetext = str_replace(
'[' . 
$key . 
']', trim(
$data[$mapping] ?? 
""), $messagetext);
  2450                 $ntf->setIntroductionDirect($messagetext);
  2452                 $ntf->setIntroductionLangId(
'survey_notification_finished_introduction');
  2457                 $ntf->addAdditionalInfo(
  2458                     'survey_360_appraisee',
  2463             $active_id = $this->
getActiveID($a_user_id, $a_anonymize_id, $a_appr_id);
  2465                 $ntf->addAdditionalInfo(
  2472             $ntf->setGotoLangId(
'survey_notification_tutor_link');
  2473             $ntf->setReasonLangId(
'survey_notification_finished_reason');
  2475             $recipient = trim($recipient ?? 
"");
  2478                 $ntf->sendMailAndReturnRecipients([$user_id]);
  2481                 if (count($user_ids) > 0) {
  2482                     $ntf->sendMailAndReturnRecipients([current($user_ids)]);
  2513         $questioncounter = 1;
  2514         foreach ($questions as $question_id => $question_data) {
  2515             $textresult .= $questioncounter++ . 
". " . $question_data[
"title"] . 
"\n";
  2516             $found = $userResults[$question_id][$active_id];
  2518             if (is_array($found)) {
  2519                 $text = implode(
"\n", $found);
  2524                 $text = self::getSurveySkippedValue();
  2526             $text = str_replace(
"<br />", 
"\n", $text);
  2527             $textresult .= $text . 
"\n\n";
  2538         string $anonymize_id,
  2544         if ($anonymize_id) {
  2545             $result = 
$ilDB->queryF(
  2546                 "SELECT finished_id FROM svy_finished" .
  2547                 " WHERE survey_fi = %s AND anonymous_id = %s AND appr_id = %s",
  2548                 array(
'integer',
'text',
'integer'),
  2549                 array($this->
getSurveyId(), $anonymize_id, $appr_id)
  2552             $result = 
$ilDB->queryF(
  2553                 "SELECT finished_id FROM svy_finished" .
  2554                 " WHERE survey_fi = %s AND user_fi = %s AND appr_id = %s",
  2555                 array(
'integer',
'integer',
'integer'),
  2559         if ($result->numRows() === 0) {
  2562             $row = 
$ilDB->fetchAssoc($result);
  2563             return (
int) $row[
"finished_id"];
  2575         $result = 
$ilDB->queryF(
  2576             "SELECT lastpage FROM svy_finished WHERE finished_id = %s",
  2580         if ($row = 
$ilDB->fetchAssoc($result)) {
  2581             return (
int) $row[
"lastpage"];
  2595         array $constraint_data,
  2596         ?array $working_data
  2598         if (!is_array($working_data) || count($working_data) === 0) {
  2602         if ((count($working_data) === 1) and (strcmp($working_data[0][
"value"], 
"") === 0)) {
  2607         foreach ($working_data as 
$data) {
  2608             switch ($constraint_data[
"short"]) {
  2610                     if ($data[
"value"] < $constraint_data[
"value"]) {
  2616                     if ($data[
"value"] <= $constraint_data[
"value"]) {
  2622                     if ($data[
"value"] == $constraint_data[
"value"]) {
  2628                     if ($data[
"value"] <> $constraint_data[
"value"]) {
  2634                     if ($data[
"value"] >= $constraint_data[
"value"]) {
  2640                     if ($data[
"value"] > $constraint_data[
"value"]) {
  2650         return (
int) $found;
  2661         $ilDB = $DIC->database();
  2663         $result = 
$ilDB->queryF(
  2664             "SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
  2668         return (
bool) $result->numRows();
  2681         $result = 
$ilDB->queryF(
  2682             "SELECT * FROM svy_finished WHERE survey_fi = %s",
  2686         if ($result->numRows()) {
  2687             while ($row = 
$ilDB->fetchAssoc($result)) {
  2688                 $users[] = (
int) $row[
"finished_id"];
  2702         $evaluation = array();
  2708             $question = 
new $question_type();
  2709             $question->loadFromDb($question_id);
  2712             $q_res = $q_eval->getResults();
  2715             foreach ($finished_ids as $user_id) {
  2716                 $data[$user_id] = $q_eval->parseUserSpecificResults($q_res, $user_id);
  2719             $evaluation[$question_id] = 
$data;
  2731         bool $force_non_anonymous = 
false  2735         $surveySetting = 
new ilSetting(
"survey");
  2736         $use_anonymous_id = $surveySetting->get(
"use_anonymous_id");
  2737         $result = 
$ilDB->queryF(
  2738             "SELECT * FROM svy_finished WHERE finished_id = %s",
  2743         $foundrows = $result->numRows();
  2745             $row = 
$ilDB->fetchAssoc($result);
  2747         $name = ($use_anonymous_id) ? $row[
"anonymous_id"] : $this->
lng->txt(
"anonymous");
  2749             "fullname" => $name,
  2750             "sortname" => $name,
  2755             "active_id" => (
string) $active_id
  2758             if (($row[
"user_fi"] > 0) &&
  2762                         $force_non_anonymous)) {
  2764                     $userdata[
"fullname"] = $userdata[
"sortname"] = $this->
lng->txt(
"deleted_user");
  2767                     $userdata[
'usr_id'] = $row[
'user_fi'];
  2770                     if (strlen($gender) === 1) {
  2771                         $gender = $this->
lng->txt(
"gender_$gender");
  2773                     $userdata[
"gender"] = $gender;
  2777                     $userdata[
"login"] = $user->
getLogin();
  2781                 $code = $this->code_manager->getByUserKey((
string) $row[
"anonymous_id"]);
  2782                 if (!is_null($code) && $this->feature_config->usesAppraisees()) {
  2783                     $userdata[
"firstname"] = $code->getFirstName();
  2784                     $userdata[
"lastname"] = $code->getLastName();
  2785                     $userdata[
"sortname"] = $code->getLastName() . 
", " . $code->getFirstName();
  2804         $result = 
$ilDB->queryF(
  2805             "SELECT * FROM svy_answer WHERE active_fi = %s",
  2809         while ($row = 
$ilDB->fetchAssoc($result)) {
  2810             if (!is_array($answers[$row[
"question_fi"]])) {
  2811                 $answers[$row[
"question_fi"]] = array();
  2813             $answers[$row[
"question_fi"]][] = $row;
  2817             "name" => $userdata[
"fullname"],
  2818             "firstname" => $userdata[
"firstname"],
  2819             "lastname" => $userdata[
"lastname"],
  2820             "login" => $userdata[
"login"],
  2821             "gender" => $userdata[
"gender"],
  2822             "answers" => array()
  2824         foreach ($questions as 
$key => $question) {
  2825             if (array_key_exists(
$key, $answers)) {
  2826                 $resultset[
"answers"][
$key] = $answers[
$key];
  2828                 $resultset[
"answers"][
$key] = array();
  2830             sort($resultset[
"answers"][
$key]);
  2844         if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title'])) {
  2845             $where .= 
" AND " . 
$ilDB->like(
'svy_question.title', 
'text', 
"%%" . $arrFilter[
'title'] . 
"%%");
  2847         if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description'])) {
  2848             $where .= 
" AND " . 
$ilDB->like(
'svy_question.description', 
'text', 
"%%" . $arrFilter[
'description'] . 
"%%");
  2850         if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author'])) {
  2851             $where .= 
" AND " . 
$ilDB->like(
'svy_question.author', 
'text', 
"%%" . $arrFilter[
'author'] . 
"%%");
  2853         if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type'])) {
  2854             $where .= 
" AND svy_qtype.type_tag = " . 
$ilDB->quote($arrFilter[
'type'], 
'text');
  2856         if (array_key_exists(
'spl', $arrFilter) && strlen($arrFilter[
'spl'])) {
  2857             $where .= 
" AND svy_question.obj_fi = " . 
$ilDB->quote($arrFilter[
'spl'], 
'integer');
  2861         $forbidden = 
" AND " . 
$ilDB->in(
'svy_question.obj_fi', array_keys($spls), 
false, 
'integer');
  2862         $forbidden .= 
" AND svy_question.complete = " . 
$ilDB->quote(
"1", 
'text');
  2865         if (count($existing_questions)) {
  2866             $existing = 
" AND " . 
$ilDB->in(
'svy_question.question_id', $existing_questions, 
true, 
'integer');
  2871         $query_result = 
$ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin, object_reference.ref_id" .
  2872             " FROM svy_question, svy_qtype, object_reference" .
  2873             " WHERE svy_question.original_id IS NULL" . $forbidden . $existing .
  2874             " AND svy_question.obj_fi = object_reference.obj_id AND svy_question.tstamp > 0" .
  2875             " AND svy_question.questiontype_fi = svy_qtype.questiontype_id " . $where);
  2878         if ($query_result->numRows()) {
  2879             while ($row = 
$ilDB->fetchAssoc($query_result)) {
  2880                 if (array_key_exists(
'spl_txt', $arrFilter) && strlen($arrFilter[
'spl_txt'])) {
  2881                     if (stripos($spls[$row[
"obj_fi"]], $arrFilter[
'spl_txt']) === 
false) {
  2886                 $row[
'ttype'] = $trans[$row[
'type_tag']];
  2887                 if ($row[
"plugin"]) {
  2907         if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title'])) {
  2908             $where .= 
" AND " . 
$ilDB->like(
'svy_qblk.title', 
'text', 
"%%" . $arrFilter[
'title'] . 
"%%");
  2911         $query_result = 
$ilDB->query(
"SELECT svy_qblk.*, svy_svy.obj_fi FROM svy_qblk , svy_qblk_qst, svy_svy WHERE " .
  2912             "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_svy.survey_id = svy_qblk_qst.survey_fi " .
  2913             "$where GROUP BY svy_qblk.questionblock_id, svy_qblk.title, svy_qblk.show_questiontext,  svy_qblk.show_blocktitle, " .
  2914             "svy_qblk.owner_fi, svy_qblk.tstamp, svy_svy.obj_fi");
  2916         if ($query_result->numRows()) {
  2918             $surveytitles = array();
  2919             foreach ($survey_ref_ids as $survey_ref_id) {
  2923             while ($row = 
$ilDB->fetchAssoc($query_result)) {
  2926                 foreach ($questions_array as 
$key => $value) {
  2927                     $questions_array[
$key] = 
"$counter. $value";
  2930                 if (strlen($surveytitles[$row[
"obj_fi"]] ?? 
"")) { 
  2931                     $rows[$row[
"questionblock_id"]] = array(
  2932                         "questionblock_id" => $row[
"questionblock_id"],
  2933                         "title" => $row[
"title"],
  2934                         "svy" => $surveytitles[$row[
"obj_fi"]],
  2935                         "contains" => implode(
", ", $questions_array),
  2936                         "owner" => $row[
"owner_fi"]
  2952         $a_xml_writer->xmlHeader();
  2954             "xmlns:xsi" => 
"http://www.w3.org/2001/XMLSchema-instance",
  2955             "xsi:noNamespaceSchemaLocation" => 
"https://www.ilias.de/download/xsd/ilias_survey_4_2.xsd"  2957         $a_xml_writer->xmlStartTag(
"surveyobject", $attrs);
  2962         $a_xml_writer->xmlStartTag(
"survey", $attrs);
  2964         $a_xml_writer->xmlElement(
"description", null, $this->
getDescription());
  2965         $a_xml_writer->xmlElement(
"author", null, $this->
getAuthor());
  2966         $a_xml_writer->xmlStartTag(
"objectives");
  2968             "label" => 
"introduction"  2975         $a_xml_writer->xmlEndTag(
"objectives");
  2978             $attribs = array(
"enabled" => 
"1");
  2980             $attribs = array(
"enabled" => 
"0");
  2982         $a_xml_writer->xmlElement(
"anonymisation", $attribs);
  2983         $a_xml_writer->xmlStartTag(
"restrictions");
  2985             $attribs = array(
"type" => 
"free");
  2987             $attribs = array(
"type" => 
"restricted");
  2989         $a_xml_writer->xmlElement(
"access", $attribs);
  2991             $attrs = array(
"type" => 
"date");
  2992             preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartDate(), $matches);
  2993             $a_xml_writer->xmlElement(
"startingtime", $attrs, sprintf(
"%04d-%02d-%02dT%02d:%02d:00", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5]));
  2996             $attrs = array(
"type" => 
"date");
  2997             preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndDate(), $matches);
  2998             $a_xml_writer->xmlElement(
"endingtime", $attrs, sprintf(
"%04d-%02d-%02dT%02d:%02d:00", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5]));
  3000         $a_xml_writer->xmlEndTag(
"restrictions");
  3004         $hasconstraints = 
false;
  3005         foreach ($pages as $question_array) {
  3006             foreach ($question_array as $question) {
  3007                 if (count($question[
"constraints"])) {
  3008                     $hasconstraints = 
true;
  3013         if ($hasconstraints) {
  3014             $a_xml_writer->xmlStartTag(
"constraints");
  3015             foreach ($pages as $question_array) {
  3016                 foreach ($question_array as $question) {
  3017                     if (count($question[
"constraints"])) {
  3019                         foreach ($question[
"constraints"] as $constraint) {
  3021                                 "sourceref" => $question[
"question_id"],
  3022                                 "destref" => $constraint[
"question"],
  3023                                 "relation" => $constraint[
"short"],
  3024                                 "value" => $constraint[
"value"],
  3025                                 "conjunction" => $constraint[
"conjunction"]
  3027                             $a_xml_writer->xmlElement(
"constraint", $attribs);
  3032             $a_xml_writer->xmlEndTag(
"constraints");
  3036         $a_xml_writer->xmlStartTag(
"metadata");
  3038         $custom_properties = array();
  3049         $custom_properties[
"mode"] = $this->
getMode();
  3053         $custom_properties[
"mode_360_results"] = $this->
get360Results();
  3062         foreach ($custom_properties as $label => $value) {
  3063             $a_xml_writer->xmlStartTag(
"metadatafield");
  3064             $a_xml_writer->xmlElement(
"fieldlabel", null, $label);
  3065             $a_xml_writer->xmlElement(
"fieldentry", null, $value);
  3066             $a_xml_writer->xmlEndTag(
"metadatafield");
  3069         $a_xml_writer->xmlStartTag(
"metadatafield");
  3070         $a_xml_writer->xmlElement(
"fieldlabel", null, 
"SCORM");
  3073         $md->toXML($writer);
  3074         $metadata = $writer->xmlDumpMem();
  3075         $a_xml_writer->xmlElement(
"fieldentry", null, $metadata);
  3076         $a_xml_writer->xmlEndTag(
"metadatafield");
  3078         $a_xml_writer->xmlEndTag(
"metadata");
  3079         $a_xml_writer->xmlEndTag(
"survey");
  3081         $attribs = array(
"id" => $this->
getId());
  3082         $a_xml_writer->xmlStartTag(
"surveyquestions", $attribs);
  3084         foreach ($pages as $question_array) {
  3085             if (count($question_array) > 1) {
  3086                 $attribs = array(
"id" => $question_array[0][
"question_id"]);
  3088                     "showQuestiontext" => $question_array[0][
"questionblock_show_questiontext"],
  3089                     "showBlocktitle" => $question_array[0][
"questionblock_show_blocktitle"],
  3090                     "compressView" => $question_array[0][
"questionblock_compress_view"]
  3092                 $a_xml_writer->xmlStartTag(
"questionblock", $attribs);
  3093                 if (strlen($question_array[0][
"questionblock_title"])) {
  3094                     $a_xml_writer->xmlElement(
"questionblocktitle", null, $question_array[0][
"questionblock_title"]);
  3097             foreach ($question_array as $question) {
  3098                 if (strlen($question[
"heading"] ?? 
"")) {
  3099                     $a_xml_writer->xmlElement(
"textblock", null, $question[
"heading"]);
  3101                 $questionObject = self::_instanciateQuestion($question[
"question_id"]);
  3105                 if ($questionObject !== 
false) {
  3106                     $questionObject->insertXML($a_xml_writer, 
false);
  3109             if (count($question_array) > 1) {
  3110                 $a_xml_writer->xmlEndTag(
"questionblock");
  3114         $a_xml_writer->xmlEndTag(
"surveyquestions");
  3115         $a_xml_writer->xmlEndTag(
"surveyobject");
  3116         $xml = $a_xml_writer->xmlDumpMem(
false);
  3127         if ($question_id < 1) {
  3131         if ($question_type === 
'') {
  3135         $question = 
new $question_type();
  3136         $question->loadFromDb($question_id);
  3148         if (!is_dir($a_dir) || is_int(strpos($a_dir, 
".."))) {
  3151         $importDirectory = 
"";
  3154         $current_dir = opendir($a_dir);
  3156         while ($entryname = readdir($current_dir)) {
  3157             $files[] = $entryname;
  3160         foreach ($files as $file) {
  3161             if (is_dir($a_dir . 
"/" . $file) and ($file !== 
"." and $file !== 
"..")) {
  3163                 $importDirectory = $a_dir . 
"/" . $file;
  3166         closedir($current_dir);
  3167         if ($importDirectory !== 
'') {
  3169             $current_dir = opendir($importDirectory);
  3171             while ($entryname = readdir($current_dir)) {
  3172                 $files[] = $entryname;
  3174             foreach ($files as $file) {
  3175                 if (is_file($importDirectory . 
"/" . $file) &&
  3176                     ($file !== 
"." && $file !== 
"..") &&
  3177                     (preg_match(
"/^[0-9]{10}__[0-9]+__(svy_)*[0-9]+\.[A-Za-z]{1,3}$/", $file) ||
  3178                         preg_match(
"/^[0-9]{10}__[0-9]+__(survey__)*[0-9]+\.[A-Za-z]{1,3}$/", $file))) {
  3180                     $xmlFile = $importDirectory . 
"/" . $file;
  3184         return array(
"dir" => $importDirectory, 
"xml" => $xmlFile);
  3198         if ($svy_qpl_id < 1) {
  3202         $source = $file_info[
"tmp_name"];
  3204         if (($source === 
'none') || (!$source) || $file_info[
"error"] > UPLOAD_ERR_OK) {
  3205             $error = $this->
lng->txt(
"import_no_file_selected");
  3210         if ((strcmp($file_info[
"type"], 
"text/xml") === 0) || (strcmp($file_info[
"type"], 
"application/xml") === 0)) {
  3211             $this->svy_log->debug(
"isXML");
  3215         $suffix = pathinfo($file_info[
"name"]);
  3216         if (strcmp(strtolower($suffix[
"extension"]), 
"zip") === 0) {
  3217             $this->svy_log->debug(
"isZip");
  3220         if (!$isXml && !$isZip) {
  3221             $error = $this->
lng->txt(
"import_wrong_file_type");
  3222             $this->svy_log->debug(
"Survey: Import error. Filetype was \"" . $file_info[
"type"] . 
"\"");
  3227             $import_subdir = 
"";
  3230                 $importfile = $import_dir . 
"/" . $file_info[
"name"];
  3232                 $this->domain->resources()->zip()->unzipFile($importfile);
  3234                 if (!((strlen($found[
"dir"]) > 0) && (strlen($found[
"xml"]) > 0))) {
  3235                     $error = $this->
lng->txt(
"wrong_import_file_structure");
  3238                 $importfile = $found[
"xml"];
  3239                 $import_subdir = $found[
"dir"];
  3241                 $importfile = tempnam($import_dir, 
"survey_import");
  3245             $this->svy_log->debug(
"Import file = $importfile");
  3246             $this->svy_log->debug(
"Import subdir = $import_subdir");
  3248             $fh = fopen($importfile, 
'rb');
  3250                 $error = $this->
lng->txt(
"import_error_opening_file");
  3253             $xml = fread($fh, filesize($importfile));
  3254             $result = fclose($fh);
  3256                 $error = $this->
lng->txt(
"import_error_closing_file");
  3260             $this->import_manager->clearMobs();
  3261             if (strpos($xml, 
"questestinterop")) {
  3264                 $this->svy_log->debug(
"survey id = " . $this->
getId());
  3265                 $this->svy_log->debug(
"question pool id = " . $svy_qpl_id);
  3268                 $config = $imp->getConfig(
"Modules/Survey");
  3269                 $config->setQuestionPoolID($svy_qpl_id);
  3270                 $imp->getMapping()->addMapping(
"Modules/Survey", 
"svy", 0, $this->
getId());
  3271                 $imp->importFromDirectory($import_subdir, 
"svy", 
"Modules/Survey");
  3272                 $this->svy_log->debug(
"config(Modules/survey)->getQuestionPoolId =" . $config->getQuestionPoolID());
  3278     public function cloneObject(
int $target_id, 
int $copy_id = 0, 
bool $omit_tree = 
false): ?
ilObject  3288         $newObj = parent::cloneObject($target_id, $copy_id, $omit_tree);
  3290         $newObj->updateMetaData();
  3294         $newObj->setOutro($this->
getOutro());
  3306         $newObj->setMode($this->
getMode());
  3331         $question_pointer = array();
  3335         foreach ($this->questions as 
$key => $question_id) {
  3337             $question = self::_instanciateQuestion($question_id);
  3341                 $question->setObjId($newObj->getId());
  3342                 $question->saveToDb($original_id);
  3343                 $newObj->questions[
$key] = $question->getId();
  3344                 $question_pointer[$question_id] = $question->getId();
  3345                 $mapping[$question_id] = $question->getId();
  3352         if (!$cp_options->isRootNode($this->getRefId())) {
  3356         $newObj->saveToDb();
  3357         $newObj->cloneTextblocks($mapping);
  3360         if (($svy_type === self::MODE_360 || $svy_type === self::MODE_SELF_EVAL) &&
  3365             foreach ($mapping as $src_qst_id => $tgt_qst_id) {
  3366                 $qst_skill = $src_skills->getSkillForQuestion($src_qst_id);
  3368                     $tgt_skills->addQuestionSkillAssignment($tgt_qst_id, $qst_skill[
"base_skill_id"], $qst_skill[
"tref_id"]);
  3373             $thresholds->cloneTo($newObj, $mapping);
  3377         $questionblocks = array();
  3378         $questionblock_questions = array();
  3379         $result = 
$ilDB->queryF(
  3380             "SELECT * FROM svy_qblk_qst WHERE survey_fi = %s",
  3384         if ($result->numRows() > 0) {
  3385             while ($row = 
$ilDB->fetchAssoc($result)) {
  3386                 $questionblock_questions[] = $row;
  3387                 $questionblocks[$row[
"questionblock_fi"]] = $row[
"questionblock_fi"];
  3391         foreach ($questionblocks as 
$key => $value) {
  3392             $questionblock = self::_getQuestionblock(
$key);
  3393             $questionblock_id = self::_addQuestionblock(
  3394                 (
string) $questionblock[
"title"],
  3395                 (
int) $questionblock[
"owner_fi"],
  3396                 (
bool) $questionblock[
"show_questiontext"],
  3397                 (
bool) $questionblock[
"show_blocktitle"],
  3398                 (
bool) $questionblock[
"compress_view"]
  3400             $questionblocks[
$key] = $questionblock_id;
  3403         foreach ($questionblock_questions as 
$key => $value) {
  3404             if ($questionblocks[$value[
"questionblock_fi"]] &&
  3405                 $question_pointer[$value[
"question_fi"]]) {
  3406                 $next_id = 
$ilDB->nextId(
'svy_qblk_qst');
  3407                 $affectedRows = 
$ilDB->manipulateF(
  3408                     "INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, question_fi) " .
  3409                     "VALUES (%s, %s, %s, %s)",
  3410                     array(
'integer',
'integer',
'integer',
'integer'),
  3411                     array($next_id, $newObj->getSurveyId(), $questionblocks[$value[
"questionblock_fi"]], $question_pointer[$value[
"question_fi"]])
  3417         $constraints = self::_getConstraints($this->
getSurveyId());
  3418         $newConstraints = array();
  3419         foreach ($constraints as 
$key => $constraint) {
  3420             if ($question_pointer[$constraint[
"for_question"]] &&
  3421                 $question_pointer[$constraint[
"question"]]) {
  3422                 if (!array_key_exists($constraint[
'id'], $newConstraints)) {
  3423                     $constraint_id = $newObj->addConstraint($question_pointer[$constraint[
"question"]], $constraint[
"relation_id"], $constraint[
"value"], $constraint[
'conjunction']);
  3424                     $newConstraints[$constraint[
'id']] = $constraint_id;
  3426                 $newObj->addConstraintToQuestion($question_pointer[$constraint[
"for_question"]], $newConstraints[$constraint[
'id']]);
  3432         $obj_settings->cloneSettings($newObj->getId());
  3433         unset($obj_settings);
  3445         $result = 
$ilDB->queryF(
  3446             "SELECT * FROM svy_svy_qst WHERE question_fi = %s",
  3450         if ($row = 
$ilDB->fetchAssoc($result)) {
  3451             return $row[
"heading"] ?? 
"";
  3465         foreach ($mapping as $original_id => $new_id) {
  3481         if (!is_writable($svy_data_dir)) {
  3482             throw new ilSurveyException(
"Survey Data Directory (" . $svy_data_dir . 
") not writeable.");
  3486         $svy_dir = $svy_data_dir . 
"/svy_" . $this->
getId();
  3488         if (!is_dir($svy_dir)) {
  3492         $export_dir = $svy_dir . 
"/export";
  3494         if (!is_dir($export_dir)) {
  3520         if (!is_writable($svy_data_dir)) {
  3521             throw new ilSurveyException(
"Survey Data Directory (" . $svy_data_dir . 
") not writeable.");
  3525         $svy_dir = $svy_data_dir . 
"/svy_" . $this->
getId();
  3527         if (!is_dir($svy_dir)) {
  3532         $import_dir = $svy_dir . 
"/import";
  3534         if (!is_dir($import_dir)) {
  3546             "/svy_" . $this->
getId() . 
"/import";
  3547         if (!is_dir($import_dir)) {
  3550         if (is_dir($import_dir)) {
  3569                 "UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
  3570                 array(
'text',
'integer',
'integer'),
  3571                 array($heading, $this->
getSurveyId(), $insertbefore)
  3575                 "UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
  3576                 array(
'text',
'integer',
'integer'),
  3590         $result = 
$ilDB->queryF(
  3591             "SELECT finished_id FROM svy_finished WHERE anonymous_id = %s AND survey_fi = %s",
  3592             array(
'text',
'integer'),
  3595         return $result->numRows() === 1;
  3608         array $a_codes = null,
  3615         $sql = 
"SELECT svy_anonymous.*, svy_finished.state" .
  3616             " FROM svy_anonymous" .
  3617             " LEFT JOIN svy_finished ON (svy_anonymous.survey_key = svy_finished.anonymous_id)" .
  3618             " WHERE svy_anonymous.survey_fi = " . 
$ilDB->quote($this->
getSurveyId(), 
"integer") .
  3619             " AND svy_anonymous.user_key IS NULL";
  3622             $sql .= 
" AND " . 
$ilDB->in(
"svy_anonymous.survey_key", $a_codes, 
"", 
"text");
  3624             $sql .= 
" AND " . 
$ilDB->in(
"svy_anonymous.anonymous_id", $a_ids, 
"", 
"text");
  3631         $titles[] = 
'"' . 
$lng->
txt(
"survey_code") . 
'"';
  3632         $titles[] = 
'"' . 
$lng->
txt(
"email") . 
'"';
  3633         $titles[] = 
'"' . 
$lng->
txt(
"lastname") . 
'"';
  3634         $titles[] = 
'"' . 
$lng->
txt(
"firstname") . 
'"';
  3635         $titles[] = 
'"' . 
$lng->
txt(
"create_date") . 
'"';
  3636         $titles[] = 
'"' . 
$lng->
txt(
"used") . 
'"';
  3637         $titles[] = 
'"' . 
$lng->
txt(
"mail_sent_short") . 
'"';
  3638         $titles[] = 
'"' . 
$lng->
txt(
"survey_code_url") . 
'"';
  3639         $export[] = implode(
";", $titles);
  3641         $result = 
$ilDB->query($sql);
  3642         $default_lang = $ilUser->getPref(
"survey_code_language");
  3643         while ($row = 
$ilDB->fetchAssoc($result)) {
  3645             $item[] = $row[
"survey_key"];
  3647             if ($row[
"externaldata"]) {
  3648                 $ext = unserialize((
string) $row[
"externaldata"], [
'allowed_classes' => 
false]);
  3649                 $item[] = $ext[
"email"];
  3650                 $item[] = $ext[
"lastname"];
  3651                 $item[] = $ext[
"firstname"];
  3663             $item[] = ($row[
"sent"]) ? 1 : 0;
  3665             $params = array(
"accesscode" => $row[
"survey_key"]);
  3666             if ($default_lang) {
  3667                 $params[
"lang"] = $default_lang;
  3671             $export[] = 
'"' . implode(
'";"', $item) . 
'"';
  3673         return implode(
"\n", $export);
  3689         $sql = 
"SELECT svy_anonymous.*, svy_finished.state" .
  3690             " FROM svy_anonymous" .
  3691             " LEFT JOIN svy_finished ON (svy_anonymous.survey_key = svy_finished.anonymous_id)" .
  3692             " WHERE svy_anonymous.survey_fi = " . 
$ilDB->quote($this->
getSurveyId(), 
"integer") 
  3696             $sql .= 
" AND " . 
$ilDB->in(
"svy_anonymous.anonymous_id", $ids, 
"", 
"integer");
  3699         $sql .= 
" ORDER BY tstamp, survey_key ASC";
  3700         $result = 
$ilDB->query($sql);
  3701         if ($result->numRows() > 0) {
  3702             while ($row = 
$ilDB->fetchAssoc($result)) {
  3708                     $params = array(
"accesscode" => $row[
"survey_key"]);
  3717                     'id' => $row[
"anonymous_id"],
  3718                     'code' => $row[
"survey_key"],
  3719                     'date' => $row[
"tstamp"],
  3721                     'sent' => $row[
'sent'],
  3728                 if ($row[
"externaldata"]) {
  3729                     $ext = unserialize((
string) $row[
"externaldata"], [
'allowed_classes' => 
false]);
  3730                     $item[
'email'] = $ext[
'email'] ?? 
"";
  3731                     $item[
'last_name'] = $ext[
'lastname'] ?? 
"";
  3732                     $item[
'first_name'] = $ext[
'firstname'] ?? 
"";
  3748         $result = 
$ilDB->queryF(
  3749             "SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
  3750             array(
'integer',
'text'),
  3753         return $result->numRows() > 0;
  3763         $result = 
$ilDB->queryF(
  3764             "SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
  3765             array(
'integer',
'text'),
  3768         return !(($result->numRows() > 0));
  3775         string $a_anonymize_key,
  3781         $next_id = 
$ilDB->nextId(
'svy_anonymous');
  3783             "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) " .
  3784             "VALUES (%s, %s, %s, %s, %s)",
  3785             array(
'integer',
'text',
'integer',
'text',
'integer'),
  3786             array($next_id, $a_anonymize_key, $this->
getSurveyId(), serialize($a_data), $a_created)
  3805         $check_finished = ($not_sent > 1);
  3810         foreach ($recipients as 
$data) {
  3811             if ($data[
'email'] && $data[
'code']) {
  3813                 switch ($not_sent) {
  3815                         $do_send = !(bool) $data[
'sent'];
  3819                         $do_send = $data[
'finished'];
  3823                         $do_send = !$data[
'finished'];
  3833                     $url = ilLink::_getLink(
  3837                             "accesscode" => $data[
"code"],
  3841                     $messagetext = str_replace(
'[url]', 
$url, $messagetext);
  3842                     foreach ($data as 
$key => $value) {
  3843                         $messagetext = str_replace(
'[' . 
$key . 
']', $value, $messagetext);
  3861             "UPDATE svy_anonymous SET sent = %s WHERE survey_fi = %s AND externaldata IS NOT NULL",
  3862             array(
'integer',
'integer'),
  3871         bool $a_check_finished = 
false  3874         $result = 
$ilDB->queryF(
  3875             "SELECT survey_key code, externaldata, sent FROM svy_anonymous WHERE survey_fi = %s",
  3880         while ($row = 
$ilDB->fetchAssoc($result)) {
  3881             if (!$row[
'externaldata']) {
  3885             $externaldata = unserialize((
string) $row[
'externaldata'], [
'allowed_classes' => 
false]);
  3886             if (!$externaldata[
'email']) {
  3890             $externaldata[
'code'] = $row[
'code'];
  3891             $externaldata[
'sent'] = $row[
'sent'];
  3893             if ($a_check_finished) {
  3899             $res[] = $externaldata;
  3912         $result = $this->db->queryF(
  3913             "SELECT state FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
  3914             array(
'integer',
'text'),
  3918         $row = $this->db->fetchAssoc($result);
  3920         return $row[
'state'] ?? 
false;
  3931         if ($survey_code !== 
'') {
  3932             $affectedRows = 
$ilDB->manipulateF(
  3933                 "DELETE FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
  3934                 array(
'integer', 
'text'),
  3950         $result = 
$ilDB->queryF(
  3951             "SELECT survey_key FROM svy_anonymous WHERE survey_fi = %s AND user_key = %s",
  3952             array(
'integer',
'text'),
  3955         if ($result->numRows()) {
  3956             $row = 
$ilDB->fetchAssoc($result);
  3957             $access_code = $row[
"survey_key"];
  3959         return $access_code;
  3976         $next_id = 
$ilDB->nextId(
'svy_anonymous');
  3977         $affectedRows = 
$ilDB->manipulateF(
  3978             "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, user_key, tstamp) " .
  3979             "VALUES (%s, %s, %s, %s, %s)",
  3980             array(
'integer',
'text', 
'integer', 
'text', 
'integer'),
  3981             array($next_id, $access_code, $this->
getSurveyId(), md5($user_id), time())
  3994         $result = 
$ilDB->queryF(
  3995             "SELECT tstamp FROM svy_answer WHERE active_fi = %s ORDER BY tstamp DESC",
  3999         if ($result->numRows()) {
  4000             $row = 
$ilDB->fetchAssoc($result);
  4001             return (
int) $row[
"tstamp"];
  4003             $result = 
$ilDB->queryF(
  4004                 "SELECT tstamp FROM svy_finished WHERE finished_id = %s",
  4008             if ($result->numRows()) {
  4009                 $row = 
$ilDB->fetchAssoc($result);
  4010                 return (
int) $row[
"tstamp"];
  4032         if (preg_match(
"/<[^>]*?>/", $a_text)) {
  4046         bool $close_material_tag = 
true,
  4047         bool $add_mobs = 
true,
  4048         array $attribs = null
  4052             "type" => 
"text/plain"  4054         if ($this->
isHTML($a_material)) {
  4055             $attrs[
"type"] = 
"text/xhtml";
  4058         $a_xml_writer->
xmlElement(
"mattext", $attrs, $mattext);
  4062             foreach ($mobs as $mob) {
  4063                 $mob_id = 
"il_" . 
IL_INST_ID . 
"_mob_" . $mob;
  4064                 if (strpos($mattext, $mob_id) !== 
false) {
  4068                         "uri" => 
"objects/" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $mob . 
"/" . $mob_obj->getTitle(),
  4069                         "type" => 
"svy:html",
  4070                         "id" => $this->
getId()
  4072                     $a_xml_writer->
xmlElement(
"matimage", $imgattrs, null);
  4076         if ($close_material_tag) {
  4091             if ($this->surveyCodeSecurity === 
false) {
  4115         if (count($ids) === 0) {
  4119         $result = 
$ilDB->query(
"SELECT usr_id, login, lastname, firstname FROM usr_data WHERE " . 
$ilDB->in(
'usr_id', $ids, 
false, 
'integer') . 
" ORDER BY login");
  4120         $result_array = array();
  4121         while ($row = 
$ilDB->fetchAssoc($result)) {
  4122             $result_array[$row[
"usr_id"]] = $row;
  4124         return $result_array;
  4140         $this->mailnotification = $a_notification;
  4156         $this->mailaddresses = $a_addresses;
  4172         $this->mailparticipantdata = $a_data;
  4183         $result = 
$ilDB->queryF(
  4184             "SELECT * FROM svy_times WHERE finished_fi = %s",
  4189         while ($row = 
$ilDB->fetchAssoc($result)) {
  4190             if ($row[
'left_page'] > 0 && $row[
'entered_page'] > 0) {
  4191                 $total += $row[
'left_page'] - $row[
'entered_page'];
  4200         if (count($this->questions) === count($a_order)) {
  4201             $this->questions = array_flip($a_order);
  4213         $this->pool_usage = $a_value;
  4222         string $a_last_name,
  4223         string $a_first_name,
  4228         $a_email = trim($a_email);
  4235         $data = array(
"email" => $a_email,
  4236             "lastname" => trim($a_last_name),
  4237             "firstname" => trim($a_first_name));
  4240             "externaldata" => array(
"text", serialize(
$data)),
  4241             "sent" => array(
"integer", $a_sent)
  4247             array(
"anonymous_id" => array(
"integer", $a_id))
  4260         if ($this->
getMode() === self::MODE_360) {
  4268         $this->mode_360_self_eval = $a_value;
  4278         $this->mode_360_self_appr = $a_value;
  4288         $this->mode_360_self_rate = $a_value;
  4298         $this->mode_360_results = $a_value;
  4314         $ilDB = $DIC->database();
  4315         $access = $DIC->access();
  4320                 "obj_id" => array(
"integer", $this->
getSurveyId()),
  4321                 "user_id" => array(
"integer", $a_user_id)
  4323             $ilDB->insert(
"svy_360_appr", $fields);
  4339         $ntf->setLangModules(array(
"svy", 
"survey"));
  4341         $ntf->setGotoLangId(
'url');
  4346         $ntf->setIntroductionLangId(
"svy_user_added_appraisee_mail");
  4347         $subject = str_replace(
"%1", $this->
getTitle(), 
$lng->
txt(
"svy_user_added_appraisee"));
  4356             $ntf->composeAndGetMessage($a_user_id, null, 
"read", 
true),
  4368         $ntf->setLangModules(array(
"svy", 
"survey"));
  4370         $ntf->setGotoLangId(
'url');
  4375         $ntf->setIntroductionLangId(
"svy_user_added_appraisee_close_mail");
  4376         $subject = str_replace(
"%1", $this->
getTitle(), 
$lng->
txt(
"svy_user_added_appraisee"));
  4385             $ntf->composeAndGetMessage($a_user_id, null, 
"read", 
true),
  4398         $ntf->setLangModules(array(
"svy", 
"survey"));
  4400         $ntf->setGotoLangId(
'url');
  4405         $ntf->setIntroductionLangId(
"svy_user_added_rater_mail");
  4406         $subject = str_replace(
"%1", $this->
getTitle(), 
$lng->
txt(
"svy_user_added_rater"));
  4416             $ntf->composeAndGetMessage($a_user_id, null, 
"read", 
true),
  4428         $set = 
$ilDB->query(
"SELECT user_id" .
  4429             " FROM svy_360_appr" .
  4430             " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
  4431             " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer"));
  4432         return (
bool) 
$ilDB->numRows($set);
  4443         $set = 
$ilDB->query(
"SELECT has_closed" .
  4444             " FROM svy_360_appr" .
  4445             " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
  4446             " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer"));
  4447         $row = 
$ilDB->fetchAssoc($set);
  4448         return (
bool) ($row[
"has_closed"] ?? 
false);
  4459         $ilDB->manipulate(
"DELETE FROM svy_360_appr" .
  4460             " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
  4461             " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer"));
  4463         $set = 
$ilDB->query(
"SELECT user_id" .
  4464             " FROM svy_360_rater" .
  4465             " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
  4466             " AND appr_id = " . 
$ilDB->quote($a_user_id, 
"integer"));
  4467         while ($row = 
$ilDB->fetchAssoc($set)) {
  4485         $set = 
$ilDB->query(
"SELECT * FROM svy_360_appr" .
  4486             " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer"));
  4487         while ($row = 
$ilDB->fetchAssoc($set)) {
  4490             $name[
"name"] = $name[
"lastname"] . 
", " . $name[
"firstname"];
  4491             $res[$row[
"user_id"]] = $name;
  4495             foreach ($raters as $rater) {
  4496                 if ($rater[
"finished"]) {
  4500             $res[$row[
"user_id"]][
"finished"] = $finished . 
"/" . count($raters);
  4501             $res[$row[
"user_id"]][
"closed"] = $row[
"has_closed"];
  4511         int $a_appraisee_id,
  4513         int $a_anonymous_id = 0
  4517         $ilDB = $DIC->database();
  4518         $access = $DIC->access();
  4521             !$this->
isRater($a_appraisee_id, $a_user_id, $a_anonymous_id)) {
  4523                 "obj_id" => array(
"integer", $this->
getSurveyId()),
  4524                 "appr_id" => array(
"integer", $a_appraisee_id),
  4525                 "user_id" => array(
"integer", $a_user_id),
  4526                 "anonymous_id" => array(
"integer", $a_anonymous_id)
  4528             $ilDB->insert(
"svy_360_rater", $fields);
  4544         int $a_appraisee_id,
  4546         int $a_anonymous_id = 0
  4553             (!$a_appraisee_id || $a_appraisee_id === $a_user_id)) {
  4559         $sql = 
"SELECT user_id" .
  4560             " FROM svy_360_rater" .
  4562             " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
  4563             " AND anonymous_id = " . 
$ilDB->quote($a_anonymous_id, 
"integer");
  4564         if ($a_appraisee_id) {
  4565             $sql .= 
" AND appr_id = " . 
$ilDB->quote($a_appraisee_id, 
"integer");
  4567         $set = 
$ilDB->query($sql);
  4568         return (
bool) 
$ilDB->numRows($set);
  4575         int $a_appraisee_id,
  4577         int $a_anonymous_id = 0
  4586         $ilDB->manipulate(
"DELETE FROM svy_360_rater" .
  4587             " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
  4588             " AND appr_id = " . 
$ilDB->quote($a_appraisee_id, 
"integer") .
  4589             " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
  4590             " AND anonymous_id = " . 
$ilDB->quote($a_anonymous_id, 
"integer"));
  4601         $res = $anonymous_ids = array();
  4603         $set = 
$ilDB->query(
"SELECT * FROM svy_360_rater" .
  4604             " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
  4605             " AND appr_id = " . 
$ilDB->quote($a_appraisee_id, 
"integer"));
  4606         while ($row = 
$ilDB->fetchAssoc($set)) {
  4607             if ($row[
"anonymous_id"]) {
  4608                 $res[
"a" . $row[
"anonymous_id"]] = array(
  4609                     "lastname" => 
"unknown code " . $row[
"anonymous_id"],
  4610                     "sent" => $row[
"mail_sent"],
  4613                 $anonymous_ids[] = $row[
"anonymous_id"];
  4616                 $name[
"name"] = $name[
"lastname"] . 
", " . $name[
"firstname"];
  4617                 $name[
"user_id"] = 
"u" . $name[
"user_id"];
  4619                 $name[
"sent"] = $row[
"mail_sent"];
  4620                 $name[
"finished"] = (bool) $this->
is360SurveyStarted($a_appraisee_id, (
int) $row[
"user_id"]);
  4621                 $res[
"u" . $row[
"user_id"]] = $name;
  4625         if (count($anonymous_ids)) {
  4627             foreach (
$data as $item) {
  4628                 if (isset(
$res[
"a" . $item[
"id"]])) {
  4629                     $res[
"a" . $item[
"id"]] = array(
  4630                         "user_id" => 
"a" . $item[
"id"],
  4631                         "lastname" => $item[
"last_name"],
  4632                         "firstname" => $item[
"first_name"],
  4633                         "name" => $item[
"last_name"] . 
", " . $item[
"first_name"],
  4635                         "email" => $item[
"email"],
  4636                         "code" => $item[
"code"],
  4637                         "href" => $item[
"href"],
  4638                         "sent" => 
$res[
"a" . $item[
"id"]][
"sent"],
  4654         int $a_anonymous_id = null
  4660         $sql = 
"SELECT appr_id FROM svy_360_rater" .
  4664             $sql .= 
" AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer");
  4666             $sql .= 
" AND anonymous_id = " . 
$ilDB->quote($a_anonymous_id, 
"integer");
  4669         $set = 
$ilDB->query($sql);
  4670         while ($row = 
$ilDB->fetchAssoc($set)) {
  4671             $res[] = (
int) $row[
"appr_id"];
  4677             !in_array($a_user_id, 
$res)) {
  4678             $res[] = $a_user_id;
  4691         $set = 
$ilDB->query(
"SELECT anonymous_id FROM svy_anonymous" .
  4692                 " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
  4693                 " AND survey_key = " . 
$ilDB->quote($a_code, 
"text"));
  4695         return $res[
"anonymous_id"] ?? null;
  4704         string $anonymous_code = null
  4708         $sql = 
"SELECT * FROM svy_finished" .
  4710             " AND appr_id = " . 
$ilDB->quote($appr_id, 
"integer");
  4712             $sql .= 
" AND user_fi = " . 
$ilDB->quote($user_id, 
"integer");
  4714             $sql .= 
" AND anonymous_id = " . 
$ilDB->quote($anonymous_code, 
"text");
  4716         $result = 
$ilDB->query($sql);
  4717         if ($result->numRows() === 0) {
  4720             $row = 
$ilDB->fetchAssoc($result);
  4721             return (
int) $row[
"state"];
  4734         string $a_code = null
  4738         $user_id = $ilUser->getId();
  4743                 if ($this->feature_config->usesAppraisees() &&
  4745                     $this->
isRater(0, $user_id)) {
  4747                     $code = $this->data_manager->code(
"")
  4748                         ->withUserId($user_id);
  4749                     $this->code_manager->add($code);
  4750                     $a_code = $this->code_manager->getByUserId($user_id);
  4756             $this->
getAnonymize() === self::ANONYMIZE_FREEACCESS) {
  4761                 $code = $this->data_manager->code(
"")
  4762                     ->withUserId($user_id);
  4763                 $code_id = $this->code_manager->add($code);
  4764                 $a_code = $this->code_manager->getByCodeId($code_id);
  4773         $sql = 
"SELECT * FROM svy_finished" .
  4777             $sql .= 
" AND (user_fi = " . 
$ilDB->quote($user_id, 
"integer") .
  4778                 " OR anonymous_id = " . 
$ilDB->quote($a_code, 
"text") . 
")";
  4782             $sql .= 
" AND anonymous_id = " . 
$ilDB->quote($a_code, 
"text");
  4784         $set = 
$ilDB->query($sql);
  4785         while ($row = 
$ilDB->fetchAssoc($set)) {
  4786             $res[$row[
"finished_id"]] = array(
"appr_id" => $row[
"appr_id"],
  4787                 "user_id" => $row[
"user_fi"],
  4788                 "code" => $row[
"anonymous_id"],
  4789                 "finished" => (
bool) $row[
"state"]);
  4791         return array(
"code" => $a_code, 
"runs" => 
$res);
  4803             $set = 
$ilDB->query(
"SELECT sf.anonymous_id FROM svy_finished sf" .
  4804                 " WHERE sf.survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
  4805                 " AND sf.user_fi = " . 
$ilDB->quote($a_user_id, 
"integer"));
  4806             $a_code = 
$ilDB->fetchAssoc($set);
  4807             return (
string) ($a_code[
"anonymous_id"] ?? 
"");
  4821         $set = 
$ilDB->query(
"SELECT user_fi FROM svy_finished" .
  4822             " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
  4823             " AND anonymous_id = " . 
$ilDB->quote($a_code, 
"text"));
  4824         $user_id = 
$ilDB->fetchAssoc($set);
  4825         $user_id = (
int) $user_id[
"user_fi"];
  4839         bool $a_exclude_appraisee = 
false  4845         $set = 
$ilDB->query(
"SELECT finished_id, user_fi FROM svy_finished" .
  4846             " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
  4847             " AND appr_id = " . 
$ilDB->quote($a_appr_id, 
"integer"));
  4848         while ($row = 
$ilDB->fetchAssoc($set)) {
  4849             if ($a_exclude_appraisee && $row[
"user_fi"] == $a_appr_id) {
  4852             $res[] = (
int) $row[
"finished_id"];
  4868         $set = 
$ilDB->query(
"SELECT finished_id, user_fi FROM svy_finished" .
  4869             " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
  4870             " AND appr_id = " . 
$ilDB->quote($a_appr_id, 
"integer") .
  4871             " AND user_fi = " . 
$ilDB->quote($a_rat_id, 
"integer"));
  4872         if ($row = 
$ilDB->fetchAssoc($set)) {
  4873             return (
int) $row[
"finished_id"];
  4883         $this->mode_skill_service = $a_val;
  4895         int $a_appraisee_id,
  4897         int $a_anonymous_id,
  4898         int $a_tstamp = null
  4906         $ilDB->manipulate(
"UPDATE svy_360_rater" .
  4907             " SET mail_sent = " . 
$ilDB->quote($a_tstamp, 
"integer") .
  4909             " AND appr_id = " . 
$ilDB->quote($a_appraisee_id, 
"integer") .
  4910             " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
  4911             " AND anonymous_id = " . 
$ilDB->quote($a_anonymous_id, 
"integer"));
  4922         $ilDB = $DIC->database();
  4923         $user = $DIC->user();
  4926         $ilDB->manipulate(
"UPDATE svy_360_appr" .
  4927             " SET has_closed = " . 
$ilDB->quote(time(), 
"integer") .
  4929             " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer"));
  4935             $sskill->writeAndAddAppraiseeSkills($a_user_id);
  4939         if ($user->
getId() !== $a_user_id) {
  4951         $ilDB->manipulate(
"UPDATE svy_360_appr" .
  4952             " SET has_closed = " . 
$ilDB->quote(null, 
"integer") .
  4959     public static function validateExternalRaterCode(
  4966         $anonym_repo = $DIC->survey()
  4972         if (!$anonym_repo->isExternalRaterValidated($a_ref_id)) {
  4973             $svy = 
new self($a_ref_id);
  4976             $domain_service = $DIC->survey()->internal()->domain();
  4977             $code_manager = $domain_service->code($svy, 0);
  4978             $feature_config = $domain_service->modeFeatureConfig($svy->getMode());
  4979             $access_manager = $domain_service->access($a_ref_id, 0);
  4981             if ($access_manager->canStartSurvey() &&
  4982                 $feature_config->usesAppraisees() &&
  4983                 $code_manager->exists($a_code)) {
  4984                 $anonymous_id = $svy->getAnonymousIdByCode($a_code);
  4985                 if ($anonymous_id) {
  4986                     if (count($svy->getAppraiseesToRate(null, $anonymous_id))) {
  4987                         $anonym_repo->setExternalRaterValidation($a_ref_id, 
true);
  4992             $anonym_repo->setExternalRaterValidation($a_ref_id, 
false);
  4996         return $anonym_repo->isExternalRaterValidated($a_ref_id);
  5011         $this->reminder_status = $a_value;
  5021         $this->reminder_start = $a_value;
  5031         $this->reminder_end = $a_value;
  5041         $this->reminder_frequency = $a_value;
  5051         $this->reminder_target = $a_value;
  5061         if ($a_value == 
"") {
  5064         $this->reminder_last_sent = $a_value;
  5068         bool $selectDefault = 
false  5070         if ($selectDefault) {
  5071             $defaultTemplateId = 0;
  5074             if ($defaultTemplateId > 0) {
  5075                 return $defaultTemplateId;
  5084         $this->reminder_tmpl = $a_value;
  5097         $this->tutor_ntf_status = $a_value;
  5113         $this->tutor_ntf_recipients = $a_value;
  5129         $this->tutor_ntf_target = $a_value;
  5139         $this->tutor_res_status = $a_value;
  5149         $this->tutor_res_recipients = $a_value;
  5165                 $set = 
$ilDB->query(
"SELECT COUNT(*) numall FROM svy_finished" .
  5166                     " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
  5167                     " AND state = " . 
$ilDB->quote(1, 
"integer") .
  5168                     " AND " . 
$ilDB->in(
"user_fi", $user_ids, 
"", 
"integer"));
  5169                 $row = 
$ilDB->fetchAssoc($set);
  5172                 if ((
int) $row[
"numall"] === count($user_ids)) {
  5186         $access = $DIC->access();
  5188         $rater_ids = array();
  5190             $this->svy_log->debug(
"Handle appraisee " . $app[
'user_id']);
  5197                     in_array($this->
getReminderTarget(), array(self::NOTIFICATION_APPRAISEES, self::NOTIFICATION_APPRAISEES_AND_RATERS))) {
  5198                     $this->svy_log->debug(
"...1");
  5201                         $this->svy_log->debug(
"...2");
  5202                         if (!isset($rater_ids[$app[
'user_id']])) {
  5203                             $rater_ids[$app[
'user_id']] = array();
  5205                         if (!isset($app[
"user_id"], $rater_ids[$app[
'user_id']])) {
  5206                             $rater_ids[$app[
'user_id']][] = $app[
"user_id"];
  5211                 $this->svy_log->debug(
"Check raters.");
  5217                         array(self::NOTIFICATION_RATERS, self::NOTIFICATION_APPRAISEES_AND_RATERS),
  5223                         if ($rater[
"login"] !== 
"") {
  5226                         if ($rater_id > 0) {
  5228                             if (!($rater[
"anonymous_id"] ?? 
false) && !($rater[
"finished"] ?? 
false)) {
  5229                                 if (!isset($rater_ids[$rater_id])) {
  5230                                     $rater_ids[$rater_id] = array();
  5232                                 if (!in_array($app[
"user_id"], $rater_ids[$rater_id])) {
  5233                                     $rater_ids[$rater_id][] = $app[
"user_id"];
  5242         $this->svy_log->debug(
"Found raters:" . count($rater_ids));
  5244         foreach ($rater_ids as 
$id => $app) {
  5253         array $a_appraisee_ids
  5255         $this->svy_log->debug(
"Send mail to:" . $a_user_id);
  5258         $ntf->setLangModules(array(
"svy", 
"survey"));
  5260         $ntf->setGotoLangId(
'url');
  5265         $ntf->setIntroductionLangId(
"svy_user_added_rater_reminder_mail");
  5266         $subject = str_replace(
"%1", $this->
getTitle(), 
$lng->
txt(
"svy_user_added_rater"));
  5268         foreach ($a_appraisee_ids as $appraisee_id) {
  5279             $ntf->composeAndGetMessage($a_user_id, null, 
"read", 
true),
  5297         if ($a_use_invited) {
  5298             $user_ids = $this->invitation_manager->getAllForSurvey($this->
getSurveyId());
  5301             if ($parent_grp_ref_id) {
  5303                 $user_ids = $part->getMembers();
  5306                 if ($parent_crs_ref_id) {
  5308                     $user_ids = $part->getMembers();
  5326             $ulng->loadLanguageModule(
'survey');
  5328             $subject = sprintf($ulng->txt(
'survey_notification_tutor_subject'), $this->
getTitle());
  5331             $message .= $ulng->txt(
'survey_notification_tutor_body') . 
":\n\n";
  5332             $message .= $ulng->txt(
'obj_svy') . 
": " . $this->
getTitle() . 
"\n";
  5333             $message .= 
"\n" . $ulng->txt(
'survey_notification_tutor_link') . 
": " . $link;
  5336             $mail_obj->appendInstallationSignature(
true);
  5354         $now_with_format = date(
"YmdHis", $now);
  5355         $today = date(
"Y-m-d");
  5357         $this->svy_log->debug(
"Check status and dates.");
  5377         if ($today < $start ||
  5378             ($end && $today > $end)) {
  5382         $this->svy_log->debug(
"Check access period.");
  5387             ($now < $item_data[
"timing_start"] ||
  5388             $now > $item_data[
"timing_end"])) {
  5392         $this->svy_log->debug(
"Check frequency.");
  5399             $missing_ids = array();
  5400             if (!$this->feature_config->usesAppraisees()) {
  5401                 $this->svy_log->debug(
"Entering survey mode.");
  5407                     $finished_ids = array();
  5408                     $set = 
$ilDB->query(
"SELECT user_fi FROM svy_finished" .
  5409                         " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
  5410                         " AND state = " . 
$ilDB->quote(1, 
"text") .
  5411                         " AND " . 
$ilDB->in(
"user_fi", $user_ids, 
"", 
"integer"));
  5412                     while ($row = 
$ilDB->fetchAssoc($set)) {
  5413                         $finished_ids[] = $row[
"user_fi"];
  5417                     $missing_ids = array_diff($user_ids, $finished_ids);
  5419                         foreach ($missing_ids as $idx => $user_id) {
  5421                             if (!$ilAccess->checkAccessOfUser($user_id, 
"read", 
"", $this->getRefId(), 
"svy", $this->
getId())) {
  5422                                 unset($missing_ids[$idx]);
  5427                         $this->sentReminder($missing_ids);
  5431                 $this->svy_log->debug(
"Entering 360 mode.");
  5440             return count($missing_ids);
  5446     protected function sentReminder(
  5447         array $a_recipient_ids
  5457             $templateService = $DIC->mail()->textTemplates();
  5460             $tmpl_params = array(
  5466             $tmpl_params = null;
  5470         foreach ($a_recipient_ids as $user_id) {
  5472                 $subject = $tmpl->getSubject();
  5479                 $ulng->loadLanguageModule(
'survey');
  5481                 $subject = sprintf($ulng->txt(
'survey_reminder_subject'), $this->
getTitle());
  5484                 $message .= $ulng->txt(
'survey_reminder_body') . 
":\n\n";
  5485                 $message .= $ulng->txt(
'obj_svy') . 
": " . $this->
getTitle() . 
"\n";
  5486                 $message .= 
"\n" . $ulng->txt(
'survey_reminder_link') . 
": " . $link;
  5490             $mail_obj->appendInstallationSignature(
true);
  5503         int $starting_time = null
  5505         $this->activation_starting_time = $starting_time;
  5509         int $ending_time = null
  5511         $this->activation_ending_time = $ending_time;
  5526         $this->view_own_results = $a_value;
  5536         $this->mail_own_results = $a_value;
  5546         $this->mail_confirmation = $a_value;
  5556         $this->anon_user_list = $a_value;
  5568         $lng = $DIC->language();
  5572         $surveySetting = 
new ilSetting(
"survey");
  5573         if (!$surveySetting->get(
"skipped_is_custom", 
false)) {
  5576             return $surveySetting->get(
"skipped_custom_value", 
"");
  5581         int &$defaultTemplateId = null
  5587         $templateService = $DIC->mail()->textTemplates();
  5589             $res[$tmpl->getTplId()] = $tmpl->getTitle();
  5590             if (null !== $defaultTemplateId && $tmpl->isDefault()) {
  5591                 $defaultTemplateId = $tmpl->getTplId();
  5601         array $a_context_params
  5607             $user = new \ilObjUser($a_user_id);
  5609             $a_message = $this->placeholder_resolver->resolve(
$context, $a_message, $user, $a_context_params);
  5619         $this->mode = $a_value;
  5629         $this->mode_self_eval_results = $a_value;
  5649         $q = 
"SELECT obj_fi FROM svy_svy" .
  5650             " WHERE tutor_res_cron IS NULL" .
  5651             " AND tutor_res_status = " . $ilDB->quote(1, 
"integer") .
  5652             " AND enddate < " . $ilDB->quote(date(
"Ymd000000"), 
"text");
  5655             $q = 
"SELECT obj_fi FROM svy_svy" .
  5656                 " WHERE tutor_res_status = " . $ilDB->quote(1, 
"integer") .
  5657                 " AND enddate < " . $ilDB->quote(date(
"Ymd000000"), 
"text");
  5660         $set = $ilDB->query(
$q);
  5664         while ($row = $ilDB->fetchAssoc($set)) {
  5665             $res[] = (
int) $row[
"obj_fi"];
  5675             $sum_score += call_user_func([$c, 
"getMaxSumScore"], $this->
getSurveyId());
 deleteUserSettings(int $id)
 
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...
 
setTutorResultsRecipients(array $a_value)
 
getTutorNotificationTarget()
Group that is checked for the "all participants have finished" mail Either a) all members of a parent...
 
removeQuestions(array $remove_questions, array $remove_questionblocks)
 
setIntroduction(string $introduction="")
 
importSurveyCode(string $a_anonymize_key, int $a_created, array $a_data)
 
setReminderEnd(?ilDate $a_value=null)
 
updateConjunctionForQuestions(array $questions, int $conjunction)
 
getSurveyCodesTableData(array $ids=null, string $lang=null)
Fetches the data for the survey codes table. 
 
getSurveyQuestions(bool $with_answers=false)
Returns the survey questions and questionblocks in an array. 
 
isAnonymizedParticipant(string $key)
 
setReminderFrequency(int $a_value)
 
getLastAccess(int $finished_id)
 
ILIAS Survey Code CodeManager $code_manager
 
checkConstraint(array $constraint_data, ?array $working_data)
Checks if a constraint is valid. 
 
isSurveyFinishedByCode(string $a_code)
Get if survey is finished for a specific anonymous user code. 
 
setMailParticipantData(string $a_data)
Set preceding text (incl. 
 
ILIAS SurveyQuestionPool Export ImportManager $import_manager
 
string $reminder_last_sent
 
setEndDate(string $end_date="")
 
isAppraisee(int $a_user_id)
 
getMailParticipantData()
Preceding text (incl. 
 
string $mailparticipantdata
 
manipulateF(string $query, array $types, array $values)
 
setSurveyId(int $survey_id)
 
addAppraisee(int $a_user_id)
 
saveUserAccessCode(int $user_id, string $access_code)
Saves a survey access code for a registered user to the database. 
 
static getLogger(string $a_component_id)
Get component logger. 
 
setShowQuestionTitles(bool $a_show)
 
static _hasDatasets(int $survey_id)
 
setObligatoryStates(array $obligatory_questions)
Sets the obligatory states for questions in a survey from the questions form. 
 
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. 
 
Mode FeatureConfig $feature_config
 
const EVALUATION_ACCESS_OFF
 
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 is_email(string $a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid. 
 
setAnonymize(int $a_anonymize)
set anonymize status 
 
getSurveyPages()
Returns the survey pages in an array (a page contains one or more questions) 
 
getUserLanguage()
Return language of user. 
 
int $display_question_titles
 
getTextblock(int $question_id)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
const EVALUATION_ACCESS_PARTICIPANTS
 
static _lookupFullname(int $a_user_id)
 
getVariables(int $question_id)
Returns all variables (answer options/scale values) of a question. 
 
setReminderTemplate(?int $a_value)
 
getExistingQuestions()
Gets the question id's of the questions which are already in the survey. 
 
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
 
static getSurveySkippedValue()
 
string $author
A text representation of the authors name. 
 
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...
 
bool $activation_visibility
 
isComplete()
Check if survey is complete for use. 
 
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
 
addConstraint(int $if_question_id, int $relation, float $value, int $conjunction)
Adds a constraint. 
 
setEndDateAndTime(string $end_date, string $end_time)
 
setMailNotification(bool $a_notification)
Activate mail to tutors each time a participant finishes the survey. 
 
int $activation_ending_time
 
duplicateQuestionForSurvey(int $question_id, bool $a_force=false)
Takes a question and creates a copy of the question for use in the survey. 
 
isAccessibleWithoutCode()
 
setSelfEvaluationResults(int $a_value)
 
static _getQuestionblock(int $questionblock_id)
get question block properties 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
const NOTIFICATION_APPRAISEES
 
getQuestionblocksTable(array $arrFilter)
Retrieve data for question block browser. 
 
const TIMINGS_DEACTIVATED
 
getUserAccessCode(int $user_id)
Returns a survey access code that was saved for a registered user. 
 
static _lookupName(int $a_user_id)
lookup user name 
 
getFinishedIdsForAppraiseeId(int $a_appr_id, bool $a_exclude_appraisee=false)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
findCodeForUser(int $a_user_id)
 
static _getAvailableQuestionpools(bool $use_object_id=false, bool $could_be_offline=false, bool $showPath=false, string $permission="read")
Returns the available question pools for the active user. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
moveQuestions(array $move_questions, int $target_index, int $insert_mode)
Move questions and/or questionblocks to another position. 
 
static _lookupId($a_user_str)
 
loadWorkingData(int $question_id, int $active_id)
Gets the given answer data of a question in a run. 
 
getFullname(int $a_max_strlen=0)
 
addConstraintToQuestion(int $to_question_id, int $constraint_id)
 
static getUserIdsByEmail(string $a_email)
 
static _getQuestionType(int $question_id)
Returns the question type of a question with a given id. 
 
setMailConfirmation(bool $a_value)
 
getSurveyParticipants(?array $finished_ids=null, bool $force_non_anonymous=false, bool $include_invites=false)
 
set360Results(int $a_value)
 
deleteAppraisee(int $a_user_id)
 
setMailAddresses(string $a_addresses)
Set (Tutor) Recipients of "single participant has finished" mails. 
 
static _addQuestionblock(string $title="", int $owner=0, bool $show_questiontext=true, bool $show_blocktitle=false, bool $compress_view=false)
 
deleteAllUserData(bool $reset_LP=true)
Deletes all user data of a survey. 
 
getQuestionpoolTitles(bool $could_be_offline=false, bool $showPath=false)
Returns the available question pools for the active user. 
 
setAuthor(string $author="")
 
int $survey_id
A unique positive numerical ID which identifies the survey. 
 
isUnusedCode(string $a_code, int $a_user_id)
 
static _getQuestionTypeTranslations()
 
static makeDirParents(string $a_dir)
Create a new directory and all parent directories. 
 
checkTutorNotification()
Check, if mail to tutors after all participants have finished the survey should be sent...
 
removeSelectedSurveyResults(array $finished_ids)
Deletes the user data of a given array of survey participants. 
 
getReminderTemplate(bool $selectDefault=false)
 
setActivationVisibility(bool $a_value)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
canExportSurveyCode()
Checks if the survey code can be exported with the survey evaluation. 
 
insertQuestionblock(int $questionblock_id)
 
setActivationEndDate(int $ending_time=null)
 
sendTutorNotification()
Send mail to tutors after all participants have finished the survey. 
 
sentReminderPlaceholders(string $a_message, int $a_user_id, array $a_context_params)
 
setTutorNotificationStatus(bool $a_value)
Activates mail being sent to tutors after all participants have finished the survey. 
 
static _lookupObjId(int $ref_id)
 
static _instanciateQuestionEvaluation(int $question_id, array $a_finished_ids=null)
 
prepareTextareaOutput(string $txt_output)
Prepares a string for a text area output in surveys. 
 
importObject(array $file_info, int $svy_qpl_id)
 
unfoldQuestionblocks(array $questionblocks)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static getTemplateContextById(string $a_id)
 
xmlEndTag(string $tag)
Writes an endtag. 
 
setViewOwnResults(bool $a_value)
 
setOutro(string $outro="")
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getQuestionblockQuestions(int $questionblock_id)
 
setPage(int $finished_id, int $page_id)
Sets the number of the active survey page. 
 
setReminderTarget(int $a_value)
 
getNextPage(int $active_page_question_id, int $direction)
Get current, previous or next page. 
 
getTutorNotificationRecipients()
Mail being sent to tutors after all participants have finished the survey? 
 
getParticipantTextResults(int $active_id)
 
InternalDomainService $domain
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getQuestionsTable(array $arrFilter)
Retrieve data for question browser. 
 
cloneTextblocks(array $mapping)
Clones the text blocks of survey questions. 
 
static _getQuestionGUI(?string $questiontype, int $question_id=-1)
Creates a question gui representation. 
 
addQuestion(int $question_id)
Adds a question to the survey (used in importer!) 
 
deleteSurveyRecord()
Deletes the survey from the database. 
 
getWorkingtimeForParticipant(int $finished_id)
 
setPoolUsage(bool $a_value)
 
getEvaluationByUser(array $questions, int $active_id)
Calculates the evaluation data for a given run. 
 
ILIAS Survey InternalService $survey_service
 
checkForParentType(int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentTyp...
 
static _isComplete(int $question_id)
Checks whether the question is complete or not. 
 
setMailOwnResults(bool $a_value)
 
getMailNotification()
Send mail to tutors each time a participant finishes the survey? 
 
cloneMetaData(ilObject $target_obj)
Copy meta data. 
 
isSurveyCodeUsed(string $code)
 
sendAppraiseeCloseNotification(int $a_user_id)
 
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='ilpublicuserprofilegui')
Default behaviour is: 
 
static _lookupTitle(int $obj_id)
 
bool $calculate_sum_score
 
getPrecondition(int $constraint_id)
Returns a precondition with a given id. 
 
updateCode(int $a_id, string $a_email, string $a_last_name, string $a_first_name, int $a_sent)
 
getAppraiseesToRate(?int $a_user_id, int $a_anonymous_id=null)
 
isQuestionInSurvey(int $a_question_fi)
 
string $evaluation_access
 
sendAppraiseeNotification(int $a_user_id)
 
const ANONYMIZE_FREEACCESS
 
static _getLanguageOfUser(int $a_usr_id)
Get language object of user. 
 
static _getConstraints(int $survey_id)
 
const NOTIFICATION_PARENT_COURSE
 
setCalculateSumScore(bool $a_val)
 
static _instanciateQuestion(int $question_id)
Creates an instance of a question with a given question id. 
 
getConstraints(int $question_id)
Returns the constraints to a given question or questionblock. 
 
const RESULTS_SELF_EVAL_OWN
 
setStartDateAndTime(string $start_date, string $start_time)
 
const NOTIFICATION_APPRAISEES_AND_RATERS
 
updateOrder(array $a_order)
 
getQuestionblockQuestionIds(int $questionblock_id)
 
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively 
 
static _getStaticLink(?int $a_ref_id, string $a_type='', bool $a_fallback_goto=true, string $append="")
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
const QUESTIONTITLES_VISIBLE
 
getActivationVisibility()
 
getImportDirectory()
get import directory of survey 
 
const QUESTIONTITLES_HIDDEN
 
modifyQuestionblock(int $questionblock_id, string $title, bool $show_questiontext, bool $show_blocktitle, bool $compress_view=false)
 
set360SelfRaters(bool $a_value)
 
setStartDate(string $start_date="")
 
setTutorNotificationRecipients(array $a_value)
Set tutor recipients for "all participants have finished" mail. 
 
static _getUserData(array $a_internalids)
return user data for given user ids 
 
getSelfEvaluationResults()
 
static _includeClass(string $question_type, int $gui=0)
Include the php class file for a given question type. 
 
updateConstraint(int $precondition_id, int $if_question_id, int $relation, float $value, int $conjunction)
 
deleteSurveyCode(string $survey_code)
 
getUserSettings(int $usr_id, string $key)
 
toXML()
Returns a QTI xml representation of the survey. 
 
saveAuthorToMetadata(string $a_author="")
Saves an authors name into the lifecycle metadata if no lifecycle metadata exists This will only be c...
 
static _getOriginalId(int $question_id, bool $a_return_question_id_if_no_original=true)
Returns the original id of a question. 
 
getAnonymousIdByCode(string $a_code)
 
static _getUsedHTMLTagsAsString(string $a_module="")
Returns a string of all allowed HTML tags for text editing. 
 
isHTML(string $a_text)
Checks if a given string contains HTML or not. 
 
Participants InvitationsManager $invitation_manager
 
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file 
 
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, instead it parses the serialized rbac_pa entries. 
 
getNotificationTargetUserIds(bool $a_use_invited)
These users must finish the survey to trigger the tutor notification "all users finished the survey" ...
 
set360RaterSent(int $a_appraisee_id, int $a_user_id, int $a_anonymous_id, int $a_tstamp=null)
 
setOfflineStatus(bool $status)
 
setTutorResultsStatus(bool $a_value)
 
static getDataDir()
get data directory (outside webspace) 
 
const NOTIFICATION_INVITED_USERS
 
set360SelfEvaluation(bool $a_value)
 
getActiveID(int $user_id, string $anonymize_id, int $appr_id)
Get run id. 
 
Class ilMailTemplatePlaceholderResolver. 
 
getQuestionGUI(string $questiontype, int $question_id)
 
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. 
 
deleteConstraints(int $question_id)
Deletes the constraints for a question. 
 
is360SurveyStarted(int $appr_id, int $user_id, string $anonymous_code=null)
 
createImportDirectory()
creates data directory for import files (data_dir/svy_data/svy_<id>/import) 
 
setReminderLastSent(?string $a_value)
 
createExportDirectory()
creates data directory for export files (data_dir/svy_data/svy_<id>/export) 
 
isRater(int $a_appraisee_id, int $a_user_id, int $a_anonymous_id=0)
 
set360SelfAppraisee(bool $a_value)
 
ilMailTemplatePlaceholderResolver $placeholder_resolver
 
const EVALUATION_ACCESS_ALL
 
getUserData(array $ids)
Returns a data of all users specified by id list. 
 
isSurveyCodeUnique(string $code)
 
saveCompletionStatus()
Saves the completion status of the survey. 
 
removeQuestionFromBlock(int $question_id, int $questionblock_id)
 
getSurveyFinishedIds()
Get run ids. 
 
static getSurveysWithTutorResults()
 
getExternalCodeRecipients(bool $a_check_finished=false)
 
getAllRelations(bool $short_as_key=false)
 
removeConstraintsConcerningQuestion(int $question_id)
Remove constraints concerning a question with a given question_id. 
 
deleteRater(int $a_appraisee_id, int $a_user_id, int $a_anonymous_id=0)
 
static getItem(int $ref_id)
 
getQuestionType(int $question_id)
 
setTutorNotificationTarget(int $a_value)
 
int $activation_starting_time
 
isQuestionInAnyBlock(int $a_question_fi)
 
setActivationStartDate(int $starting_time=null)
 
isAppraiseeClosed(int $a_user_id)
 
getTutorResultsRecipients()
 
setActivationLimited(bool $a_value)
 
addRater(int $a_appraisee_id, int $a_user_id, int $a_anonymous_id=0)
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins 
 
array $tutor_ntf_recipients
 
const RESULTS_SELF_EVAL_NONE
 
setEvaluationAccess(string $evaluation_access=self::EVALUATION_ACCESS_OFF)
 
int $mode_self_eval_results
 
addQuestionToBlock(int $question_id, int $questionblock_id)
 
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag. 
 
getUserSpecificResults(array $finished_ids)
Calculates the evaluation data for the user specific results. 
 
deleteWorkingData(int $question_id, int $active_id)
Deletes the working data of a question in the database. 
 
setAnonymousUserList(bool $a_value)
 
static _getQuestionClasses()
 
sendRaterNotification(int $a_user_id, int $a_appraisee_id)
 
send360ReminderToUser(int $a_user_id, array $a_appraisee_ids)
 
static _getInstance(int $a_copy_id)
 
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content) 
 
insertQuestion(int $question_id)
Inserts a question in the survey and saves the relation to the database. 
 
getUserDataFromActiveId(int $active_id, bool $force_non_anonymous=false)
Returns run information. 
 
closeAppraisee(int $a_user_id)
 
ilPluginAdmin $plugin_admin
 
ILIAS Survey InternalDataService $data_manager
 
setSkillService(bool $a_val)
 
debug(string $message, array $context=[])
 
getTutorNotificationStatus()
 
__construct(int $a_id=0, bool $a_call_by_reference=true)
 
const NOTIFICATION_RATERS
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getRatersData(int $a_appraisee_id)
 
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. 
 
Basic class for all survey question types The SurveyQuestionGUI class defines and encapsulates basic ...
 
sendCodes(int $not_sent, string $subject, string $message, string $lang)
 
setReminderStatus(bool $a_value)
 
static getInstance(int $obj_id)
 
static _lookupEmail(int $a_user_id)
 
saveHeading(string $heading, int $insertbefore)
 
Class ilObjectActivation. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getReminderMailTemplates(int &$defaultTemplateId=null)
 
getFinishedIdForAppraiseeIdAndRaterId(int $a_appr_id, int $a_rat_id)
Get finished id for an appraisee and a rater. 
 
deleteConstraint(int $constraint_id)
Deletes a single constraint. 
 
getUserSurveyExecutionStatus(string $a_code=null)
Get current user execution status. 
 
createQuestionblock(string $title, bool $show_questiontext, bool $show_blocktitle, array $questions, bool $compress_view=false)
 
const RESULTS_SELF_EVAL_ALL
 
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) ...
 
saveUserSettings(int $usr_id, string $key, string $title, string $value)
 
removeQuestion(int $question_id)
 
finishSurvey(int $finished_id, int $appr_id=0)
Finishes the survey creating an entry in the database. 
 
sent360Reminders()
Send 360 reminders. 
 
getMailAddresses()
(Tutor) Recipients of "single participant has finished" mails 
 
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
 
array $tutor_res_recipients
 
setReminderStart(?ilDate $a_value=null)
 
getLastActivePage(int $active_id)
Returns the question id of the last active page a user visited in a survey. 
 
locateImportFiles(string $a_dir)
Locates the import directory and the xml file in a directory with an unzipped import file...
 
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
 
static _lookupLogin(int $a_user_id)