4 include_once
"./Services/Object/classes/class.ilObject.php";
216 public function __construct($a_id = 0, $a_call_by_reference =
true)
220 $this->
user = $DIC->user();
221 $this->lng = $DIC->language();
222 $this->db = $DIC->database();
223 $this->access = $DIC->access();
224 $this->log = $DIC[
"ilLog"];
225 $this->plugin_admin = $DIC[
"ilPluginAdmin"];
226 $this->tree = $DIC->repositoryTree();
228 $lng = $DIC->language();
231 $this->survey_id = -1;
232 $this->introduction =
"";
233 $this->outro =
$lng->txt(
"survey_finished");
234 $this->author =
$ilUser->getFullname();
235 $this->evaluation_access = self::EVALUATION_ACCESS_OFF;
236 $this->questions = array();
238 $this->invitation_mode = self::MODE_PREDEFINED_USERS;
239 $this->anonymize = self::ANONYMIZE_OFF;
240 $this->display_question_titles = self::QUESTIONTITLES_VISIBLE;
241 $this->surveyCodeSecurity =
true;
242 $this->template_id = null;
243 $this->pool_usage =
true;
245 $this->mode = self::MODE_STANDARD;
246 $this->mode_self_eval_results = self::RESULTS_SELF_EVAL_OWN;
248 parent::__construct($a_id, $a_call_by_reference);
254 public function create($a_upload =
false)
271 parent::createMetaData();
281 public function update($a_upload =
false)
298 $result = parent::createReference();
321 array_push($this->questions, $question_id);
330 public function delete()
336 foreach ($this->questions as $question_id) {
344 $remove = parent::delete();
362 $affectedRows =
$ilDB->manipulateF(
363 "DELETE FROM svy_svy WHERE survey_id = %s",
369 "SELECT questionblock_fi FROM svy_qblk_qst WHERE survey_fi = %s",
373 $questionblocks = array();
375 array_push($questionblocks,
$row[
"questionblock_fi"]);
377 if (count($questionblocks)) {
378 $affectedRows =
$ilDB->manipulate(
"DELETE FROM svy_qblk WHERE " .
$ilDB->in(
'questionblock_id', $questionblocks,
false,
'integer'));
380 $affectedRows =
$ilDB->manipulateF(
381 "DELETE FROM svy_qblk_qst WHERE survey_fi = %s",
387 $affectedRows =
$ilDB->manipulateF(
388 "DELETE FROM svy_anonymous WHERE survey_fi = %s",
395 $directory = $svy_data_dir .
"/svy_" . $this->
getId();
396 if (is_dir($directory)) {
400 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
406 foreach (
$mobs as $mob) {
424 "SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
428 $active_array = array();
430 array_push($active_array,
$row[
"finished_id"]);
433 $affectedRows =
$ilDB->manipulateF(
434 "DELETE FROM svy_finished WHERE survey_fi = %s",
439 foreach ($active_array as $active_fi) {
440 $affectedRows =
$ilDB->manipulateF(
441 "DELETE FROM svy_answer WHERE active_fi = %s",
445 $affectedRows =
$ilDB->manipulateF(
446 "DELETE FROM svy_times WHERE finished_fi = %s",
453 include_once
"Services/Object/classes/class.ilObjectLP.php";
455 $lp_obj->resetLPDataForCompleteObject();
468 $user_ids[] = array();
470 foreach ($finished_ids as $finished_id) {
472 "SELECT finished_id FROM svy_finished WHERE finished_id = %s",
478 if (
$row[
"user_fi"]) {
479 $user_ids[] =
$row[
"user_fi"];
482 $affectedRows =
$ilDB->manipulateF(
483 "DELETE FROM svy_answer WHERE active_fi = %s",
485 array(
$row[
"finished_id"])
488 $affectedRows =
$ilDB->manipulateF(
489 "DELETE FROM svy_finished WHERE finished_id = %s",
494 $affectedRows =
$ilDB->manipulateF(
495 "DELETE FROM svy_times WHERE finished_fi = %s",
497 array(
$row[
"finished_id"])
501 if (
sizeof($user_ids)) {
502 include_once
"Services/Object/classes/class.ilObjectLP.php";
504 $lp_obj->resetLPDataForUserIds($user_ids);
512 $sql =
"SELECT * FROM svy_finished" .
515 $sql .=
" AND " .
$ilDB->in(
"finished_id", $finished_ids,
"",
"integer");
519 $participants = array();
523 $userdata[
"finished"] = (bool)
$row[
"state"];
524 $userdata[
"finished_tstamp"] =
$row[
"tstamp"];
525 $participants[$userdata[
"sortname"] . $userdata[
"active_id"]] = $userdata;
528 return $participants;
539 if (($this->
getTitle())
and (count($this->questions))) {
560 $affectedRows =
$ilDB->manipulateF(
561 "UPDATE svy_svy SET complete = %s, tstamp = %s WHERE survey_id = %s",
562 array(
'text',
'integer',
'integer'),
580 $question_gui = $this->
getQuestionGUI($questiontype, $question_id);
583 if ($this->
getId() == $question_gui->object->getObjId() && !$a_force) {
587 $duplicate_id = $question_gui->object->duplicate(
true,
"",
"",
"", $this->
getId());
588 return $duplicate_id;
600 $this->log->debug(
"insert question, id:" . $question_id);
602 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
604 $this->log->debug(
"question is not complete");
610 "SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
614 $sequence =
$result->numRows();
616 $this->log->debug(
"duplicate, id: " . $question_id .
", duplicate id: " . $duplicate_id);
623 $next_id =
$ilDB->nextId(
'svy_svy_qst');
624 $affectedRows =
$ilDB->manipulateF(
625 "INSERT INTO svy_svy_qst (survey_question_id, survey_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
626 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
627 array($next_id, $this->
getSurveyId(), $duplicate_id, $sequence, time())
630 $this->log->debug(
"added entry to svy_svy_qst, id: " . $next_id .
", question id: " . $duplicate_id .
", sequence: " . $sequence);
647 $ilDB = $DIC->database();
649 $set =
$ilDB->query(
"SELECT * FROM svy_svy_qst " .
650 " WHERE survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
651 " AND question_fi = " .
$ilDB->quote($a_question_fi,
"integer"));
652 if ($rec =
$ilDB->fetchAssoc($set)) {
669 "SELECT svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.show_blocktitle," .
670 " svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst, svy_svy_qst" .
671 " WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi" .
672 " AND svy_svy_qst.question_fi = svy_qblk_qst.question_fi" .
673 " AND svy_qblk.questionblock_id = %s" .
674 " ORDER BY svy_svy_qst.sequence",
676 array($questionblock_id)
679 $show_questiontext = 0;
680 $show_blocktitle = 0;
685 $show_questiontext =
$row[
"show_questiontext"];
686 $show_blocktitle =
$row[
"show_blocktitle"];
695 $next_id =
$ilDB->nextId(
'svy_settings');
696 $affectedRows =
$ilDB->insert(
"svy_settings", array(
697 "settings_id" => array(
"integer", $next_id),
698 "usr_id" => array(
"integer", $usr_id),
699 "keyword" => array(
"text",
$key),
700 "title" => array(
"text",
$title),
701 "value" => array(
"clob", $value)
709 $affectedRows =
$ilDB->manipulateF(
710 "DELETE FROM svy_settings WHERE settings_id = %s",
714 return $affectedRows;
722 "SELECT * FROM svy_settings WHERE usr_id = %s AND keyword = %s",
723 array(
'integer',
'text'),
746 if (is_object($rmd_start)) {
750 if (is_object($rmd_end)) {
754 include_once(
"./Services/RTE/classes/class.ilRTE.php");
756 $next_id =
$ilDB->nextId(
'svy_svy');
757 $affectedRows =
$ilDB->insert(
"svy_svy", array(
758 "survey_id" => array(
"integer", $next_id),
759 "obj_fi" => array(
"integer", $this->
getId()),
760 "author" => array(
"text", $this->
getAuthor()),
764 "enddate" => array(
"text", $this->
getEndDate()),
768 "complete" => array(
"text", $this->
isComplete()),
769 "created" => array(
"integer", time()),
775 "tstamp" => array(
"integer", time()),
776 "template_id" => array(
"integer", $this->
getTemplate()),
777 "pool_usage" => array(
"integer", $this->
getPoolUsage()),
779 "mode" => array(
"integer", $this->
getMode()),
784 "mode_360_results" => array(
"integer", $this->
get360Results()),
786 "mode_skill_service" => array(
"integer", (
int) $this->
getSkillService()),
791 "reminder_start" => array(
"datetime", $rmd_start),
792 "reminder_end" => array(
"datetime", $rmd_end),
807 $affectedRows =
$ilDB->update(
"svy_svy", array(
808 "author" => array(
"text", $this->
getAuthor()),
812 "enddate" => array(
"text", $this->
getEndDate()),
816 "complete" => array(
"text", $this->
isComplete()),
822 "tstamp" => array(
"integer", time()),
823 "template_id" => array(
"integer", $this->
getTemplate()),
824 "pool_usage" => array(
"integer", $this->
getPoolUsage()),
826 "mode" => array(
"integer", $this->
getMode()),
831 "mode_360_results" => array(
"integer", $this->
get360Results()),
833 "mode_skill_service" => array(
"integer", (
int) $this->
getSkillService()),
838 "reminder_start" => array(
"datetime", $rmd_start),
839 "reminder_end" => array(
"datetime", $rmd_end),
852 "survey_id" => array(
"integer", $this->
getSurveyId())
862 include_once
"./Services/Object/classes/class.ilObjectActivation.php";
875 $item->update($this->ref_id);
889 $this->log->debug(
"save questions");
892 $old_questions = array();
894 "SELECT survey_question_id,question_fi,sequence" .
895 " FROM svy_svy_qst WHERE survey_fi = %s",
900 $old_questions[
$row[
"question_fi"]] =
$row;
904 $insert = $update = $delete = array();
905 foreach ($this->questions as $seq => $fi) {
906 if (!array_key_exists($fi, $old_questions)) {
908 } elseif ($old_questions[$fi][
"sequence"] != $seq) {
909 $update[$fi] = $old_questions[$fi][
"survey_question_id"];
912 unset($old_questions[$fi]);
916 if (
sizeof($old_questions)) {
918 foreach ($old_questions as $fi => $old) {
919 $del_ids[] = $old[
"survey_question_id"];
921 $ilDB->manipulate($q =
"DELETE FROM svy_svy_qst" .
922 " WHERE " .
$ilDB->in(
"survey_question_id", $del_ids,
"",
"integer"));
923 $this->log->debug(
"delete: " . $q);
925 unset($old_questions);
928 foreach ($this->questions as $seq => $fi) {
929 if (in_array($fi, $insert)) {
932 $next_id =
$ilDB->nextId(
'svy_svy_qst');
934 "INSERT INTO svy_svy_qst" .
935 " (survey_question_id, survey_fi, question_fi, heading, sequence, tstamp)" .
936 " VALUES (%s, %s, %s, %s, %s, %s)",
937 array(
'integer',
'integer',
'integer',
'text',
'integer',
'integer'),
938 array($next_id, $this->
getSurveyId(), $fi, null, $seq, time())
940 $this->log->debug(
"insert svy_svy_qst, id:" . $next_id .
", fi: " . $fi .
", seq:" . $seq);
942 } elseif (array_key_exists($fi, $update)) {
943 $ilDB->manipulate(
"UPDATE svy_svy_qst" .
944 " SET sequence = " .
$ilDB->quote($seq,
"integer") .
945 ", tstamp = " .
$ilDB->quote(time(),
"integer") .
946 " WHERE survey_question_id = " .
$ilDB->quote($update[$fi],
"integer"));
947 $this->log->debug(
"update svy_svy_qst, id:" . $update[$fi] .
", fi: " . $fi .
", seq:" . $seq);
963 "SELECT anonymous_id FROM svy_finished WHERE anonymous_id = %s",
969 return $row[
"anonymous_id"];
983 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
997 if ($question_id < 1) {
1001 "SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND " .
1002 "svy_question.questiontype_fi = svy_qtype.questiontype_id",
1006 if (
$result->numRows() == 1) {
1008 return $data[
"type_tag"];
1030 switch ($a_anonymize) {
1031 case self::ANONYMIZE_OFF:
1032 case self::ANONYMIZE_ON:
1033 case self::ANONYMIZE_FREEACCESS:
1034 case self::ANONYMIZE_CODE_ALL:
1035 $this->anonymize = $a_anonymize;
1038 $this->anonymize = self::ANONYMIZE_OFF;
1050 return ($this->anonymize) ? $this->anonymize : 0;
1060 return ($this->
getAnonymize() == self::ANONYMIZE_OFF ||
1084 "SELECT * FROM svy_svy WHERE obj_fi = %s",
1086 array($this->
getId())
1088 if (
$result->numRows() == 1) {
1092 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1094 if (strcmp(
$data[
"outro"],
"survey_finished") == 0) {
1095 $this->
setOutro($this->lng->txt(
"survey_finished"));
1143 if ($this->ref_id) {
1144 include_once
"./Services/Object/classes/class.ilObjectActivation.php";
1146 switch ($activation[
"timing_type"]) {
1170 $this->questions = array();
1172 "SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
1177 $this->questions[
$data[
"sequence"]] = $data[
"question_fi"];
1188 $ilDB = $DIC->database();
1192 "SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
1199 $to_delete_ids = array();
1201 if (in_array(
$data[
"question_fi"], $fis)) {
1202 $to_delete_ids[] =
$data[
"survey_question_id"];
1204 $fis[] =
$data[
"question_fi"];
1209 if (count($to_delete_ids) > 0) {
1210 $ilDB->manipulate($q =
"DELETE FROM svy_svy_qst" .
1211 " WHERE " .
$ilDB->in(
"survey_question_id", $to_delete_ids,
false,
"integer") .
1213 $this->log->debug(
"delete: " . $q);
1215 $ilDB->manipulate($q =
"DELETE FROM svy_qblk_qst " .
1216 " WHERE " .
$ilDB->in(
"question_fi", $fis,
true,
"integer") .
1218 $this->log->debug(
"delete: " . $q);
1222 $set =
$ilDB->query(
"SELECT * FROM svy_svy_qst " .
1223 " WHERE survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
" ORDER BY sequence");
1225 while ($rec =
$ilDB->fetchAssoc($set)) {
1227 $q =
"UPDATE svy_svy_qst SET " .
1228 " sequence = " .
$ilDB->quote($seq++,
"integer") .
1229 " WHERE survey_question_id = " .
$ilDB->quote($rec[
"survey_question_id"],
"integer")
1231 $this->log->debug(
"update: " . $q);
1260 $md_life = &$md->getLifecycle();
1262 if (strlen($a_author) == 0) {
1264 $a_author =
$ilUser->getFullname();
1267 $md_life = &$md->addLifecycle();
1269 $con = &$md_life->addContribute();
1270 $con->setRole(
"Author");
1272 $ent = &$con->addEntity();
1273 $ent->setEntity($a_author);
1288 include_once
"./Services/MetaData/classes/class.ilMD.php";
1290 $md_life = &$md->getLifecycle();
1292 $ids = &$md_life->getContributeIds();
1293 foreach ($ids as
$id) {
1294 $md_cont = &$md_life->getContribute($id);
1295 if (strcmp($md_cont->getRole(),
"Author") == 0) {
1296 $entids = &$md_cont->getEntityIds();
1297 foreach ($entids as $entid) {
1298 $md_ent = &$md_cont->getEntity($entid);
1299 array_push(
$author, $md_ent->getEntity());
1315 return ($this->display_question_titles) ? 1 : 0;
1326 $this->display_question_titles = ($a_show) ? 1 : 0;
1337 $this->display_question_titles = 1;
1348 $this->display_question_titles = 0;
1370 if ($ilAccess->checkAccessOfUser(
$row[
"usr_id"],
"read",
"", $this->getRefId(),
"svy", $this->
getId())) {
1447 include_once
"./Services/Administration/classes/class.ilSetting.php";
1448 $surveySetting =
new ilSetting(
"survey");
1449 $unlimited_invitation = $surveySetting->get(
"unlimited_invitation");
1450 if (!$unlimited_invitation && $this->invitation_mode == self::MODE_UNLIMITED) {
1451 return self::MODE_PREDEFINED_USERS;
1453 return ($this->invitation_mode) ? $this->invitation_mode : self::MODE_UNLIMITED;
1466 return (strlen($this->start_date)) ? $this->start_date : null;
1481 $edit_settings =
false;
1483 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartDate(), $matches)) {
1484 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
1486 if ($now < $epoch_time) {
1487 array_push(
$messages, $this->lng->txt(
'start_date_not_reached') .
' (' .
1490 $edit_settings =
true;
1494 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndDate(), $matches)) {
1495 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
1497 if ($now > $epoch_time) {
1498 array_push(
$messages, $this->lng->txt(
'end_date_reached') .
' (' .
1501 $edit_settings =
true;
1507 array_push(
$messages, $this->lng->txt(
"survey_is_offline"));
1509 $edit_settings =
true;
1512 if (!$a_no_rbac && !$ilAccess->checkAccess(
"read",
"", $this->ref_id)) {
1513 array_push(
$messages, $this->lng->txt(
"cannot_participate_survey"));
1532 "edit_settings" => $edit_settings
1564 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/",
$start_date, $matches)) {
1569 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $start_time, $matches)) {
1574 $this->start_date = sprintf(
'%04d%02d%02d%02d%02d%02d',
$y,
$m,
$d,
$h,
$i,
$s);
1586 return (strlen($this->end_date)) ? $this->end_date : null;
1617 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/",
$end_date, $matches)) {
1622 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $end_time, $matches)) {
1627 $this->end_date = sprintf(
'%04d%02d%02d%02d%02d%02d',
$y,
$m,
$d,
$h,
$i,
$s);
1639 return ($this->evaluation_access) ? $this->evaluation_access : self::EVALUATION_ACCESS_OFF;
1656 $this->activation_visibility = (bool) $a_value;
1666 return (
bool) $this->activation_limited;
1671 $this->activation_limited = (bool) $a_value;
1683 return (strlen($this->introduction)) ? $this->introduction : null;
1695 return (strlen($this->outro)) ? $this->outro : null;
1707 $existing_questions = array();
1709 "SELECT svy_question.original_id FROM svy_question, svy_svy_qst WHERE " .
1710 "svy_svy_qst.survey_fi = %s AND svy_svy_qst.question_fi = svy_question.question_id",
1715 if (
$data[
"original_id"]) {
1716 array_push($existing_questions,
$data[
"original_id"]);
1719 return $existing_questions;
1730 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1744 $array_pos = array_search($target_index, $this->questions);
1745 if ($insert_mode == 0) {
1746 $part1 = array_slice($this->questions, 0, $array_pos);
1747 $part2 = array_slice($this->questions, $array_pos);
1748 } elseif ($insert_mode == 1) {
1749 $part1 = array_slice($this->questions, 0, $array_pos + 1);
1750 $part2 = array_slice($this->questions, $array_pos + 1);
1753 foreach ($move_questions as $question_id) {
1754 if (!(array_search($question_id, $part1) ===
false)) {
1755 unset($part1[array_search($question_id, $part1)]);
1758 if (!(array_search($question_id, $part2) ===
false)) {
1759 unset($part2[array_search($question_id, $part2)]);
1764 if ($found != count($move_questions)) {
1767 $part1 = array_values($part1);
1768 $part2 = array_values($part2);
1769 $this->questions = array_values(array_merge($part1, $move_questions, $part2));
1770 foreach ($move_questions as $question_id) {
1772 foreach ($constraints as $idx => $constraint) {
1773 foreach ($part2 as $next_question_id) {
1774 if ($constraint[
"question"] == $next_question_id) {
1792 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1793 $question = self::_instanciateQuestion($question_id);
1794 #20610 if no question found, do nothing. 1796 $question->delete($question_id);
1811 "SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
1812 array(
'integer',
'integer'),
1816 $remove_constraints = array();
1818 array_push($remove_constraints,
$row[
"constraint_fi"]);
1820 $affectedRows =
$ilDB->manipulateF(
1821 "DELETE FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
1822 array(
'integer',
'integer'),
1825 foreach ($remove_constraints as
$key => $constraint_id) {
1826 $affectedRows =
$ilDB->manipulateF(
1827 "DELETE FROM svy_constraint WHERE constraint_id = %s",
1829 array($constraint_id)
1846 $block_sizes = array();
1848 if (in_array($question_id, $remove_questions)
or in_array(
$data[
"questionblock_id"], $remove_questionblocks)) {
1849 unset($this->questions[array_search($question_id, $this->questions)]);
1851 } elseif (
$data[
"questionblock_id"]) {
1852 $block_sizes[
$data[
"questionblock_id"]]++;
1857 foreach ($block_sizes as $block_id =>
$size) {
1859 $remove_questionblocks[] = $block_id;
1863 foreach (array_unique($remove_questionblocks) as $questionblock_id) {
1864 $affectedRows =
$ilDB->manipulateF(
1865 "DELETE FROM svy_qblk WHERE questionblock_id = %s",
1867 array($questionblock_id)
1869 $affectedRows =
$ilDB->manipulateF(
1870 "DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
1871 array(
'integer',
'integer'),
1876 $this->questions = array_values($this->questions);
1889 foreach ($questionblocks as
$index) {
1890 $affectedRows =
$ilDB->manipulateF(
1891 "DELETE FROM svy_qblk WHERE questionblock_id = %s",
1895 $affectedRows =
$ilDB->manipulateF(
1896 "DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
1897 array(
'integer',
'integer'),
1907 $affectedRows =
$ilDB->manipulateF(
1908 "DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s AND question_fi = %s",
1909 array(
'integer',
'integer',
'integer'),
1910 array($questionblock_id, $this->
getSurveyId(), $question_id)
1920 $next_id =
$ilDB->nextId(
'svy_qblk_qst');
1921 $affectedRows =
$ilDB->manipulateF(
1922 "INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
1923 "question_fi) VALUES (%s, %s, %s, %s)",
1924 array(
'integer',
'integer',
'integer',
'integer'),
1925 array($next_id, $this->
getSurveyId(), $questionblock_id, $question_id)
1942 $ilDB = $DIC->database();
1944 $set =
$ilDB->query(
"SELECT * FROM svy_qblk_qst " .
1945 " WHERE survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
1946 " AND question_fi = " .
$ilDB->quote($a_question_fi,
"integer"));
1947 if ($rec =
$ilDB->fetchAssoc($set)) {
1965 "SELECT svy_question.title, svy_qblk_qst.question_fi, svy_qblk_qst.survey_fi FROM " .
1966 "svy_qblk, svy_qblk_qst, svy_question WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND " .
1967 "svy_question.question_id = svy_qblk_qst.question_fi AND svy_qblk.questionblock_id = %s",
1969 array($questionblock_id)
1973 $titles[
$row[
"question_fi"]] = $row[
"title"];
1977 "SELECT question_fi, sequence FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
1981 $resultarray = array();
1984 if (array_key_exists(
$row[
"question_fi"], $titles)) {
1985 $resultarray[$counter++] = $titles[
$row[
"question_fi"]];
1988 return $resultarray;
2003 "SELECT a.question_fi FROM svy_qblk_qst a JOIN svy_svy_qst b ON (a.question_fi = b.question_fi) " .
2004 " WHERE a.questionblock_fi = %s ORDER BY b.sequence",
2006 array($questionblock_id)
2011 if (!in_array(
$data[
'question_fi'], $ids)) {
2012 array_push($ids,
$data[
'question_fi']);
2031 $ilDB = $DIC->database();
2033 "SELECT * FROM svy_qblk WHERE questionblock_id = %s",
2035 array($questionblock_id)
2053 $ilDB = $DIC->database();
2054 $next_id =
$ilDB->nextId(
'svy_qblk');
2056 "INSERT INTO svy_qblk (questionblock_id, title, show_questiontext," .
2057 " show_blocktitle, owner_fi, tstamp) " .
2058 "VALUES (%s, %s, %s, %s, %s, %s)",
2059 array(
'integer',
'text',
'integer',
'integer',
'integer',
'integer'),
2060 array($next_id,
$title, $show_questiontext, $show_blocktitle,
$owner, time())
2082 $next_id =
$ilDB->nextId(
'svy_qblk');
2083 $affectedRows =
$ilDB->manipulateF(
2084 "INSERT INTO svy_qblk (questionblock_id, title, show_questiontext," .
2085 " show_blocktitle, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
2086 array(
'integer',
'text',
'text',
'text',
'integer',
'integer'),
2087 array($next_id,
$title, $show_questiontext, $show_blocktitle,
$ilUser->getId(), time())
2089 if ($affectedRows) {
2090 $questionblock_id = $next_id;
2093 $next_id =
$ilDB->nextId(
'svy_qblk_qst');
2094 $affectedRows =
$ilDB->manipulateF(
2095 "INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
2096 "question_fi) VALUES (%s, %s, %s, %s)",
2097 array(
'integer',
'integer',
'integer',
'integer'),
2098 array($next_id, $this->
getSurveyId(), $questionblock_id, $index)
2116 $affectedRows =
$ilDB->manipulateF(
2117 "UPDATE svy_qblk SET title = %s, show_questiontext = %s," .
2118 " show_blocktitle = %s WHERE questionblock_id = %s",
2119 array(
'text',
'text',
'text',
'integer'),
2120 array(
$title, $show_questiontext, $show_blocktitle, $questionblock_id)
2134 "SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
2135 array(
'integer',
'integer'),
2138 $constraints = array();
2140 array_push($constraints,
$row[
"constraint_fi"]);
2142 foreach ($constraints as $constraint_id) {
2157 $affectedRows =
$ilDB->manipulateF(
2158 "DELETE FROM svy_constraint WHERE constraint_id = %s",
2160 array($constraint_id)
2162 $affectedRows =
$ilDB->manipulateF(
2163 "DELETE FROM svy_qst_constraint WHERE constraint_fi = %s",
2165 array($constraint_id)
2178 $all_questions = array();
2180 "SELECT svy_qtype.type_tag, svy_qtype.plugin, svy_question.question_id, " .
2181 "svy_svy_qst.heading FROM svy_qtype, svy_question, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
2182 "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
2183 "ORDER BY svy_svy_qst.sequence",
2187 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
2190 if (
$row[
"plugin"]) {
2196 $question = self::_instanciateQuestion(
$row[
"question_id"]);
2197 $questionrow = $question->getQuestionDataArray(
$row[
"question_id"]);
2199 $questionrow[
$key] = $value;
2201 $all_questions[
$row[
"question_id"]] = $questionrow;
2202 $all_questions[$row[
"question_id"]][
"usableForPrecondition"] = $question->usableForPrecondition();
2203 $all_questions[$row[
"question_id"]][
"availableRelations"] = $question->getAvailableRelations();
2207 $questionblocks = array();
2208 if (count($all_questions)) {
2210 "SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst WHERE " .
2211 "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
2212 "AND " .
$ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions),
false,
'integer'),
2217 $questionblocks[
$row[
'question_fi']] =
$row;
2221 foreach ($all_questions as $question_id =>
$row) {
2223 if (isset($questionblocks[$question_id])) {
2224 $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
2225 $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
2226 $all_questions[$question_id][
"constraints"] = $constraints;
2228 $all_questions[$question_id][
"questionblock_title"] =
"";
2229 $all_questions[$question_id][
"questionblock_id"] =
"";
2230 $all_questions[$question_id][
"constraints"] = $constraints;
2232 if ($with_answers) {
2235 "SELECT svy_variable.*, svy_category.title FROM svy_variable, svy_category " .
2236 "WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id " .
2237 "ORDER BY sequence ASC",
2243 array_push($answers,
$data[
"title"]);
2246 $all_questions[$question_id][
"answers"] = $answers;
2249 return $all_questions;
2262 "SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
2268 if (!array_key_exists(
$row[
"question_fi"], $obligatory_questions)) {
2269 $obligatory_questions[
$row[
"question_fi"]] = 0;
2275 foreach ($obligatory_questions as $question_fi => $obligatory) {
2277 $ilDB->manipulate(
"UPDATE svy_question" .
2278 " SET obligatory = " .
$ilDB->quote($obligatory,
"integer") .
2279 " WHERE question_id = " .
$ilDB->quote($question_fi,
"integer"));
2292 $all_questions = array();
2294 "SELECT svy_question.*, svy_qtype.type_tag, svy_svy_qst.heading FROM " .
2295 "svy_question, svy_qtype, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
2296 "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
2297 "ORDER BY svy_svy_qst.sequence",
2302 $all_questions[
$row[
"question_id"]] =
$row;
2305 $questionblocks = array();
2306 if (count($all_questions)) {
2308 "SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst " .
2309 "WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
2310 "AND " .
$ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions),
false,
'integer'),
2315 $questionblocks[
$row[
'question_fi']] =
$row;
2319 $all_pages = array();
2322 foreach ($all_questions as $question_id =>
$row) {
2323 $constraints = array();
2324 if (isset($questionblocks[$question_id])) {
2325 if (!$currentblock
or ($currentblock != $questionblocks[$question_id][
'questionblock_id'])) {
2328 $all_questions[$question_id][
'page'] = $pageindex;
2329 $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
2330 $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
2331 $all_questions[$question_id][
"questionblock_show_questiontext"] = $questionblocks[$question_id][
'show_questiontext'];
2332 $all_questions[$question_id][
"questionblock_show_blocktitle"] = $questionblocks[$question_id][
'show_blocktitle'];
2333 $currentblock = $questionblocks[$question_id][
'questionblock_id'];
2335 $all_questions[$question_id][
"constraints"] = $constraints;
2338 $all_questions[$question_id][
'page'] = $pageindex;
2339 $all_questions[$question_id][
"questionblock_title"] =
"";
2340 $all_questions[$question_id][
"questionblock_id"] =
"";
2341 $all_questions[$question_id][
"questionblock_show_questiontext"] = 1;
2342 $all_questions[$question_id][
"questionblock_show_blocktitle"] = 1;
2345 $all_questions[$question_id][
"constraints"] = $constraints;
2347 if (!isset($all_pages[$pageindex])) {
2348 $all_pages[$pageindex] = array();
2350 array_push($all_pages[$pageindex], $all_questions[$question_id]);
2353 $max = count($all_pages);
2355 foreach ($all_pages as
$index => $block) {
2356 foreach ($block as $blockindex => $question) {
2357 $all_pages[
$index][$blockindex][
"position"] = $counter / $max;
2377 if (strcmp($active_page_question_id,
"") == 0) {
2380 foreach ($pages as
$key => $question_array) {
2381 foreach ($question_array as $question) {
2382 if ($active_page_question_id == $question[
"question_id"]) {
2387 if ($foundpage == -1) {
2390 $foundpage += $direction;
2391 if ($foundpage < 0) {
2394 if ($foundpage >= count($pages)) {
2397 return $pages[$foundpage];
2409 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
2422 $result_array = array();
2424 "SELECT svy_constraint.*, svy_relation.*, svy_qst_constraint.question_fi ref_question_fi FROM svy_qst_constraint, svy_constraint, " .
2425 "svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id AND " .
2426 "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_constraint.constraint_id = %s",
2446 $result_array = array();
2448 "SELECT svy_constraint.*, svy_relation.* FROM svy_qst_constraint, svy_constraint, svy_relation " .
2449 "WHERE svy_constraint.relation_fi = svy_relation.relation_id AND " .
2450 "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.question_fi = %s " .
2451 "AND svy_qst_constraint.survey_fi = %s",
2452 array(
'integer',
'integer'),
2456 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
2459 $question =
new $question_type();
2460 $question->loadFromDb(
$row[
"question_fi"]);
2461 $valueoutput = $question->getPreconditionValueOutput(
$row[
"value"]);
2462 array_push($result_array, array(
"id" =>
$row[
"constraint_id"],
"question" =>
$row[
"question_fi"],
"short" =>
$row[
"shortname"],
"long" =>
$row[
"longname"],
"value" =>
$row[
"value"],
"conjunction" =>
$row[
"conjunction"],
"valueoutput" => $valueoutput));
2464 return $result_array;
2476 $ilDB = $DIC->database();
2477 $result_array = array();
2479 "SELECT svy_qst_constraint.question_fi as for_question, svy_constraint.*, svy_relation.* " .
2480 "FROM svy_qst_constraint, svy_constraint, svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id " .
2481 "AND svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.survey_fi = %s",
2486 array_push($result_array, array(
"id" =>
$row[
"constraint_id"],
"for_question" =>
$row[
"for_question"],
"question" =>
$row[
"question_fi"],
"short" =>
$row[
"shortname"],
"long" =>
$row[
"longname"],
"relation_id" =>
$row[
"relation_id"],
"value" =>
$row[
"value"],
'conjunction' =>
$row[
'conjunction']));
2488 return $result_array;
2501 $result_array = array();
2503 "SELECT svy_variable.*, svy_category.title FROM svy_variable LEFT JOIN " .
2504 "svy_category ON svy_variable.category_fi = svy_category.category_id WHERE svy_variable.question_fi = %s " .
2505 "ORDER BY svy_variable.sequence",
2510 $result_array[
$row->sequence] =
$row;
2512 return $result_array;
2527 $next_id =
$ilDB->nextId(
'svy_constraint');
2528 $affectedRows =
$ilDB->manipulateF(
2529 "INSERT INTO svy_constraint (constraint_id, question_fi, relation_fi, value, conjunction) VALUES " .
2530 "(%s, %s, %s, %s, %s)",
2531 array(
'integer',
'integer',
'integer',
'float',
'integer'),
2532 array($next_id, $if_question_id, $relation, $value, $conjunction)
2534 if ($affectedRows) {
2552 $next_id =
$ilDB->nextId(
'svy_qst_constraint');
2553 $affectedRows =
$ilDB->manipulateF(
2554 "INSERT INTO svy_qst_constraint (question_constraint_id, survey_fi, question_fi, " .
2555 "constraint_fi) VALUES (%s, %s, %s, %s)",
2556 array(
'integer',
'integer',
'integer',
'integer'),
2557 array($next_id, $this->
getSurveyId(), $to_question_id, $constraint_id)
2571 public function updateConstraint($precondition_id, $if_question_id, $relation, $value, $conjunction)
2574 $affectedRows =
$ilDB->manipulateF(
2575 "UPDATE svy_constraint SET question_fi = %s, relation_fi = %s, value = %s, conjunction = %s " .
2576 "WHERE constraint_id = %s",
2577 array(
'integer',
'integer',
'float',
'integer',
'integer'),
2578 array($if_question_id, $relation, $value, $conjunction, $precondition_id)
2586 $affectedRows =
$ilDB->manipulateF(
2587 "UPDATE svy_constraint SET conjunction = %s " .
2588 "WHERE constraint_id IN (SELECT constraint_fi FROM svy_qst_constraint WHERE svy_qst_constraint.question_fi = %s)",
2589 array(
'integer',
'integer'),
2590 array($conjunction, $question_id)
2605 $custom_order = array(
"equal",
"not_equal",
"less",
"less_or_equal",
"more",
"more_or_equal");
2606 $custom_order = array_flip($custom_order);
2608 $result_array = array();
2611 if ($short_as_key) {
2612 $result_array[
$row[
"shortname"]] = array(
"short" => $row[
"shortname"],
"long" => $row[
"longname"],
"id" => $row[
"relation_id"],
"order" => $custom_order[$row[
"longname"]]);
2614 $result_array[
$row[
"relation_id"]] = array(
"short" => $row[
"shortname"],
"long" => $row[
"longname"],
"order" => $custom_order[$row[
"longname"]]);
2619 foreach ($result_array as $idx => $item) {
2620 unset($result_array[$idx][
"order"]);
2623 return $result_array;
2633 "SELECT user_fi FROM svy_inv_usr WHERE survey_fi = %s",
2651 $affectedRows =
$ilDB->manipulateF(
2652 "DELETE FROM svy_inv_usr WHERE survey_fi = %s AND user_fi = %s",
2653 array(
'integer',
'integer'),
2656 include_once
'./Services/User/classes/class.ilObjUser.php';
2671 "SELECT user_fi FROM svy_inv_usr WHERE user_fi = %s AND survey_fi = %s",
2672 array(
'integer',
'integer'),
2676 $next_id =
$ilDB->nextId(
'svy_inv_usr');
2677 $affectedRows =
$ilDB->manipulateF(
2678 "INSERT INTO svy_inv_usr (invited_user_id, survey_fi, user_fi, tstamp) " .
2679 "VALUES (%s, %s, %s, %s)",
2680 array(
'integer',
'integer',
'integer',
'integer'),
2681 array($next_id, $this->
getSurveyId(), $user_id, time())
2685 include_once
'./Services/User/classes/class.ilObjUser.php';
2700 $result_array = array();
2702 "SELECT user_fi FROM svy_inv_usr WHERE survey_fi = %s",
2707 array_push($result_array,
$row[
"user_fi"]);
2709 return $result_array;
2723 $affectedRows =
$ilDB->manipulateF(
2724 "DELETE FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
2725 array(
'integer',
'integer'),
2726 array($question_id, $active_id)
2741 $result_array = array();
2743 "SELECT * FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
2744 array(
'integer',
'integer'),
2745 array($question_id, $active_id)
2747 if (
$result->numRows() >= 1) {
2749 array_push($result_array,
$row);
2751 return $result_array;
2753 return $result_array;
2767 if ($this->
getAnonymize() && (strlen($anonymous_id) == 0)) {
2771 if (strcmp($user_id,
"") == 0) {
2772 if ($user_id == ANONYMOUS_USER_ID) {
2776 $next_id =
$ilDB->nextId(
'svy_finished');
2777 $affectedRows =
$ilDB->manipulateF(
2778 "INSERT INTO svy_finished (finished_id, survey_fi, user_fi, anonymous_id, state, tstamp, appr_id) " .
2779 "VALUES (%s, %s, %s, %s, %s, %s, %s)",
2780 array(
'integer',
'integer',
'integer',
'text',
'text',
'integer',
'integer'),
2781 array($next_id, $this->
getSurveyId(), $user_id, $anonymous_id, 0, time(), $appraisee_id)
2797 "UPDATE svy_finished SET state = %s, tstamp = %s" .
2798 " WHERE survey_fi = %s AND finished_id = %s",
2799 array(
'text',
'integer',
'integer',
'integer'),
2800 array(1, time(), $this->
getSurveyId(), $finished_id)
2807 $sskill->writeSelfEvalSkills(
$user[
'usr_id']);
2824 $affectedRows =
$ilDB->manipulateF(
2825 "UPDATE svy_finished SET lastpage = %s WHERE finished_id = %s",
2826 array(
'integer',
'integer'),
2827 array(($page_id) ? $page_id : 0, $finished_id)
2839 $placeholders = array(
2840 "FIRST_NAME" =>
"firstname",
2841 "LAST_NAME" =>
"lastname",
2844 "firstname" =>
"firstname" 2849 $recipients = preg_split(
'/,/', $this->mailaddresses);
2850 foreach ($recipients as $recipient) {
2853 $ntf->setLangModules(array(
"survey"));
2855 $ntf->setSubjectLangId(
'finished_mail_subject');
2858 if (trim($messagetext)) {
2863 foreach ($placeholders as
$key => $mapping) {
2865 $messagetext = str_replace(
'[' .
$key .
']',
'', $messagetext);
2867 $messagetext = str_replace(
'[' .
$key .
']', trim(
$data[$mapping]), $messagetext);
2870 $ntf->setIntroductionDirect($messagetext);
2872 $ntf->setIntroductionLangId(
'survey_notification_finished_introduction');
2877 $ntf->addAdditionalInfo(
2878 'survey_360_appraisee',
2883 $active_id = $this->
getActiveID($a_user_id, $a_anonymize_id, $a_appr_id);
2884 $ntf->addAdditionalInfo(
2890 $ntf->setGotoLangId(
'survey_notification_tutor_link');
2891 $ntf->setReasonLangId(
'survey_notification_finished_reason');
2893 if (is_numeric($recipient)) {
2894 $lng = $ntf->getUserLanguage($recipient);
2895 $ntf->sendMail(array($recipient), null, null);
2897 $recipient = trim($recipient);
2899 if (empty($user_ids)) {
2900 $ntf->sendMail(array($recipient), null, null);
2902 foreach ($user_ids as $user_id) {
2903 $lng = $ntf->getUserLanguage($user_id);
2904 $ntf->sendMail(array($user_id), null, null);
2916 $questioncounter = 1;
2917 foreach (
$questions as $question_id => $question_data) {
2918 $textresult .= $questioncounter++ .
". " . $question_data[
"title"] .
"\n";
2919 $found = $userResults[$question_id][$active_id];
2921 if (is_array($found)) {
2922 $text = implode(
"\n", $found);
2926 if (strlen(
$text) == 0) {
2927 $text = self::getSurveySkippedValue();
2930 $textresult .=
$text .
"\n\n";
2947 if ($anonymize_id) {
2949 "SELECT * FROM svy_finished" .
2950 " WHERE survey_fi = %s AND anonymous_id = %s AND appr_id = %s",
2951 array(
'integer',
'text',
'integer'),
2952 array($this->
getSurveyId(), $anonymize_id, $appr_id)
2956 "SELECT * FROM svy_finished" .
2957 " WHERE survey_fi = %s AND user_fi = %s AND appr_id = %s",
2958 array(
'integer',
'integer',
'integer'),
2962 if (
$result->numRows() == 0) {
2969 return (
int)
$row[
"state"];
2987 if ($anonymize_id) {
2989 "SELECT finished_id FROM svy_finished" .
2990 " WHERE survey_fi = %s AND anonymous_id = %s AND appr_id = %s",
2991 array(
'integer',
'text',
'integer'),
2992 array($this->
getSurveyId(), $anonymize_id, $appr_id)
2996 "SELECT finished_id FROM svy_finished" .
2997 " WHERE survey_fi = %s AND user_fi = %s AND appr_id = %s",
2998 array(
'integer',
'integer',
'integer'),
3002 if (
$result->numRows() == 0) {
3006 return $row[
"finished_id"];
3021 "SELECT lastpage FROM svy_finished WHERE finished_id = %s",
3025 if (
$result->numRows() == 0) {
3029 return (
$row[
"lastpage"]) ?
$row[
"lastpage"] :
'';
3043 if (!is_array($working_data) || count($working_data) == 0) {
3047 if ((count($working_data) == 1)
and (strcmp($working_data[0][
"value"],
"") == 0)) {
3052 foreach ($working_data as
$data) {
3053 switch ($constraint_data[
"short"]) {
3055 if ($data[
"value"] < $constraint_data[
"value"]) {
3061 if ($data[
"value"] <= $constraint_data[
"value"]) {
3067 if ($data[
"value"] == $constraint_data[
"value"]) {
3073 if ($data[
"value"] <> $constraint_data[
"value"]) {
3079 if ($data[
"value"] >= $constraint_data[
"value"]) {
3085 if ($data[
"value"] > $constraint_data[
"value"]) {
3095 return (
int) $found;
3102 $ilDB = $DIC->database();
3105 "SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
3109 return (
$result->numRows()) ?
true :
false;
3125 "SELECT * FROM svy_finished WHERE survey_fi = %s",
3145 $evaluation = array();
3147 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3152 $question =
new $question_type();
3153 $question->loadFromDb($question_id);
3156 $q_res = $q_eval->getResults();
3159 foreach ($finished_ids as $user_id) {
3160 $data[$user_id] = $q_eval->parseUserSpecificResults($q_res, $user_id);
3163 $evaluation[$question_id] =
$data;
3180 $surveySetting =
new ilSetting(
"survey");
3181 $use_anonymous_id = array_key_exists(
"use_anonymous_id",
$_GET) ?
$_GET[
"use_anonymous_id"] : $surveySetting->get(
"use_anonymous_id");
3183 "SELECT * FROM svy_finished WHERE finished_id = %s",
3188 $foundrows =
$result->numRows();
3192 $name = ($use_anonymous_id) ?
$row[
"anonymous_id"] : $this->lng->txt(
"anonymous");
3194 "fullname" =>
$name,
3195 "sortname" =>
$name,
3200 "active_id" =>
"$active_id" 3203 if ((
$row[
"user_fi"] > 0) &&
3204 ((
$row[
"user_fi"] != ANONYMOUS_USER_ID &&
3207 (
bool) $force_non_anonymous)) {
3208 include_once
'./Services/User/classes/class.ilObjUser.php';
3210 $userdata[
"fullname"] = $userdata[
"sortname"] = $this->lng->txt(
"deleted_user");
3213 $userdata[
'usr_id'] =
$row[
'user_fi'];
3214 $userdata[
"fullname"] =
$user->getFullname();
3215 $gender =
$user->getGender();
3216 if (strlen($gender) == 1) {
3217 $gender = $this->lng->txt(
"gender_$gender");
3219 $userdata[
"gender"] = $gender;
3220 $userdata[
"firstname"] =
$user->getFirstname();
3221 $userdata[
"lastname"] =
$user->getLastname();
3222 $userdata[
"sortname"] =
$user->getLastname() .
", " .
$user->getFirstname();
3223 $userdata[
"login"] =
$user->getLogin();
3246 "SELECT * FROM svy_answer WHERE active_fi = %s",
3251 if (!is_array($answers[
$row[
"question_fi"]])) {
3252 $answers[$row[
"question_fi"]] = array();
3254 array_push($answers[$row[
"question_fi"]], $row);
3258 "name" => $userdata[
"fullname"],
3259 "firstname" => $userdata[
"firstname"],
3260 "lastname" => $userdata[
"lastname"],
3261 "login" => $userdata[
"login"],
3262 "gender" => $userdata[
"gender"],
3263 "answers" => array()
3266 if (array_key_exists(
$key, $answers)) {
3267 $resultset[
"answers"][
$key] = $answers[
$key];
3269 $resultset[
"answers"][
$key] = array();
3271 sort($resultset[
"answers"][
$key]);
3286 if (is_array($arrFilter)) {
3287 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title'])) {
3288 $where .=
" AND " .
$ilDB->like(
'svy_question.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
3290 if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description'])) {
3291 $where .=
" AND " .
$ilDB->like(
'svy_question.description',
'text',
"%%" . $arrFilter[
'description'] .
"%%");
3293 if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author'])) {
3294 $where .=
" AND " .
$ilDB->like(
'svy_question.author',
'text',
"%%" . $arrFilter[
'author'] .
"%%");
3296 if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type'])) {
3297 $where .=
" AND svy_qtype.type_tag = " .
$ilDB->quote($arrFilter[
'type'],
'text');
3299 if (array_key_exists(
'spl', $arrFilter) && strlen($arrFilter[
'spl'])) {
3300 $where .=
" AND svy_question.obj_fi = " .
$ilDB->quote($arrFilter[
'spl'],
'integer');
3306 $forbidden =
" AND " .
$ilDB->in(
'svy_question.obj_fi', array_keys($spls),
false,
'integer');
3307 $forbidden .=
" AND svy_question.complete = " .
$ilDB->quote(
"1",
'text');
3310 if (count($existing_questions)) {
3311 $existing =
" AND " .
$ilDB->in(
'svy_question.question_id', $existing_questions,
true,
'integer');
3314 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
3317 $query_result =
$ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin, object_reference.ref_id" .
3318 " FROM svy_question, svy_qtype, object_reference" .
3319 " WHERE svy_question.original_id IS NULL" . $forbidden . $existing .
3320 " AND svy_question.obj_fi = object_reference.obj_id AND svy_question.tstamp > 0" .
3321 " AND svy_question.questiontype_fi = svy_qtype.questiontype_id " . $where);
3324 if ($query_result->numRows()) {
3325 while (
$row =
$ilDB->fetchAssoc($query_result)) {
3326 if (array_key_exists(
'spl_txt', $arrFilter) && strlen($arrFilter[
'spl_txt'])) {
3327 if (!stristr($spls[
$row[
"obj_fi"]], $arrFilter[
'spl_txt'])) {
3332 $row[
'ttype'] = $trans[
$row[
'type_tag']];
3333 if ($row[
"plugin"]) {
3335 array_push(
$rows, $row);
3338 array_push(
$rows, $row);
3356 if (is_array($arrFilter)) {
3357 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title'])) {
3358 $where .=
" AND " .
$ilDB->like(
'svy_qblk.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
3362 $query_result =
$ilDB->query(
"SELECT svy_qblk.*, svy_svy.obj_fi FROM svy_qblk , svy_qblk_qst, svy_svy WHERE " .
3363 "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_svy.survey_id = svy_qblk_qst.survey_fi " .
3364 "$where GROUP BY svy_qblk.questionblock_id, svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.show_blocktitle, " .
3365 "svy_qblk.owner_fi, svy_qblk.tstamp, svy_svy.obj_fi");
3367 if ($query_result->numRows()) {
3369 $surveytitles = array();
3370 foreach ($survey_ref_ids as $survey_ref_id) {
3374 while (
$row =
$ilDB->fetchAssoc($query_result)) {
3377 foreach ($questions_array as
$key => $value) {
3378 $questions_array[
$key] =
"$counter. $value";
3381 if (strlen($surveytitles[
$row[
"obj_fi"]])) {
3382 $rows[$row[
"questionblock_id"]] = array(
3383 "questionblock_id" => $row[
"questionblock_id"],
3384 "title" => $row[
"title"],
3385 "svy" => $surveytitles[$row[
"obj_fi"]],
3386 "contains" => join(
", ", $questions_array),
3387 "owner" => $row[
"owner_fi"]
3403 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
3408 "xmlns:xsi" =>
"http://www.w3.org/2001/XMLSchema-instance",
3409 "xsi:noNamespaceSchemaLocation" =>
"http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd" 3411 $a_xml_writer->xmlStartTag(
"surveyobject", $attrs);
3416 $a_xml_writer->xmlStartTag(
"survey", $attrs);
3418 $a_xml_writer->xmlElement(
"description", null, $this->
getDescription());
3419 $a_xml_writer->xmlElement(
"author", null, $this->
getAuthor());
3420 $a_xml_writer->xmlStartTag(
"objectives");
3422 "label" =>
"introduction" 3429 $a_xml_writer->xmlEndTag(
"objectives");
3432 $attribs = array(
"enabled" =>
"1");
3434 $attribs = array(
"enabled" =>
"0");
3436 $a_xml_writer->xmlElement(
"anonymisation", $attribs);
3437 $a_xml_writer->xmlStartTag(
"restrictions");
3439 $attribs = array(
"type" =>
"free");
3441 $attribs = array(
"type" =>
"restricted");
3443 $a_xml_writer->xmlElement(
"access", $attribs);
3445 $attrs = array(
"type" =>
"date");
3446 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartDate(), $matches);
3447 $a_xml_writer->xmlElement(
"startingtime", $attrs, sprintf(
"%04d-%02d-%02dT%02d:%02d:00", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
3450 $attrs = array(
"type" =>
"date");
3451 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndDate(), $matches);
3452 $a_xml_writer->xmlElement(
"endingtime", $attrs, sprintf(
"%04d-%02d-%02dT%02d:%02d:00", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
3454 $a_xml_writer->xmlEndTag(
"restrictions");
3458 $hasconstraints =
false;
3459 foreach ($pages as $question_array) {
3460 foreach ($question_array as $question) {
3461 if (count($question[
"constraints"])) {
3462 $hasconstraints =
true;
3467 if ($hasconstraints) {
3468 $a_xml_writer->xmlStartTag(
"constraints");
3469 foreach ($pages as $question_array) {
3470 foreach ($question_array as $question) {
3471 if (count($question[
"constraints"])) {
3473 foreach ($question[
"constraints"] as $constraint) {
3475 "sourceref" => $question[
"question_id"],
3476 "destref" => $constraint[
"question"],
3477 "relation" => $constraint[
"short"],
3478 "value" => $constraint[
"value"],
3479 "conjunction" => $constraint[
"conjunction"]
3481 $a_xml_writer->xmlElement(
"constraint", $attribs);
3486 $a_xml_writer->xmlEndTag(
"constraints");
3490 $a_xml_writer->xmlStartTag(
"metadata");
3492 $custom_properties = array();
3496 $custom_properties[
"pool_usage"] = (int) $this->
getPoolUsage();
3503 $custom_properties[
"mode"] = (int) $this->
getMode();
3505 $custom_properties[
"mode_360_self_rate"] = (int) $this->
get360SelfRaters();
3507 $custom_properties[
"mode_360_results"] = $this->
get360Results();
3508 $custom_properties[
"mode_skill_service"] = (int) $this->
getSkillService();
3516 foreach ($custom_properties as $label => $value) {
3517 $a_xml_writer->xmlStartTag(
"metadatafield");
3518 $a_xml_writer->xmlElement(
"fieldlabel", null, $label);
3519 $a_xml_writer->xmlElement(
"fieldentry", null, $value);
3520 $a_xml_writer->xmlEndTag(
"metadatafield");
3523 $a_xml_writer->xmlStartTag(
"metadatafield");
3524 $a_xml_writer->xmlElement(
"fieldlabel", null,
"SCORM");
3525 include_once
"./Services/MetaData/classes/class.ilMD.php";
3528 $md->toXml($writer);
3530 $a_xml_writer->xmlElement(
"fieldentry", null,
$metadata);
3531 $a_xml_writer->xmlEndTag(
"metadatafield");
3533 $a_xml_writer->xmlEndTag(
"metadata");
3534 $a_xml_writer->xmlEndTag(
"survey");
3536 $attribs = array(
"id" => $this->
getId());
3537 $a_xml_writer->xmlStartTag(
"surveyquestions", $attribs);
3539 foreach ($pages as $question_array) {
3540 if (count($question_array) > 1) {
3541 $attribs = array(
"id" => $question_array[0][
"question_id"]);
3542 $attribs = array(
"showQuestiontext" => $question_array[0][
"questionblock_show_questiontext"],
3543 "showBlocktitle" => $question_array[0][
"questionblock_show_blocktitle"]);
3544 $a_xml_writer->xmlStartTag(
"questionblock", $attribs);
3545 if (strlen($question_array[0][
"questionblock_title"])) {
3546 $a_xml_writer->xmlElement(
"questionblocktitle", null, $question_array[0][
"questionblock_title"]);
3549 foreach ($question_array as $question) {
3550 if (strlen($question[
"heading"])) {
3551 $a_xml_writer->xmlElement(
"textblock", null, $question[
"heading"]);
3553 $questionObject = self::_instanciateQuestion($question[
"question_id"]);
3557 if ($questionObject !==
false) {
3558 $questionObject->insertXML($a_xml_writer,
false);
3561 if (count($question_array) > 1) {
3562 $a_xml_writer->xmlEndTag(
"questionblock");
3566 $a_xml_writer->xmlEndTag(
"surveyquestions");
3567 $a_xml_writer->xmlEndTag(
"surveyobject");
3568 $xml = $a_xml_writer->xmlDumpMem(
false);
3581 if ($question_id < 1) {
3584 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3586 if (strlen($question_type) == 0) {
3590 $question =
new $question_type();
3591 $question->loadFromDb($question_id);
3603 if (!is_dir($a_dir) || is_int(strpos($a_dir,
".."))) {
3606 $importDirectory =
"";
3609 $current_dir = opendir($a_dir);
3611 while ($entryname = readdir($current_dir)) {
3615 foreach (
$files as $file) {
3616 if (is_dir($a_dir .
"/" . $file)
and ($file !=
"." and $file !=
"..")) {
3618 $importDirectory = $a_dir .
"/" . $file;
3621 closedir($current_dir);
3622 if (strlen($importDirectory)) {
3624 $current_dir = opendir($importDirectory);
3626 while ($entryname = readdir($current_dir)) {
3629 foreach (
$files as $file) {
3630 if (@is_file($importDirectory .
"/" . $file) &&
3631 ($file !=
"." && $file !=
"..") &&
3632 (preg_match(
"/^[0-9]{10}__[0-9]+__(svy_)*[0-9]+\.[A-Za-z]{1,3}$/", $file) ||
3633 preg_match(
"/^[0-9]{10}__[0-9]+__(survey__)*[0-9]+\.[A-Za-z]{1,3}$/", $file))) {
3635 $xmlFile = $importDirectory .
"/" . $file;
3639 return array(
"dir" => $importDirectory,
"xml" => $xmlFile);
3652 if ($svy_qpl_id < 1) {
3656 $source = $file_info[
"tmp_name"];
3658 if ((
$source ==
'none') || (!
$source) || $file_info[
"error"] > UPLOAD_ERR_OK) {
3659 $error = $this->lng->txt(
"import_no_file_selected");
3664 if ((strcmp($file_info[
"type"],
"text/xml") == 0) || (strcmp($file_info[
"type"],
"application/xml") == 0)) {
3665 $this->log->debug(
"isXML");
3669 $suffix = pathinfo($file_info[
"name"]);
3670 if (strcmp(strtolower($suffix[
"extension"]),
"zip") == 0) {
3671 $this->log->debug(
"isZip");
3674 if (!$isXml && !$isZip) {
3675 $error = $this->lng->txt(
"import_wrong_file_type");
3676 $this->log->debug(
"Survey: Import error. Filetype was \"" . $file_info[
"type"] .
"\"");
3678 if (strlen(
$error) == 0) {
3681 $import_subdir =
"";
3684 $importfile = $import_dir .
"/" . $file_info[
"name"];
3685 ilUtil::moveUploadedFile(
$source, $file_info[
"name"], $importfile);
3688 if (!((strlen($found[
"dir"]) > 0) && (strlen($found[
"xml"]) > 0))) {
3689 $error = $this->lng->txt(
"wrong_import_file_structure");
3692 $importfile = $found[
"xml"];
3693 $import_subdir = $found[
"dir"];
3695 $importfile = tempnam($import_dir,
"survey_import");
3696 ilUtil::moveUploadedFile(
$source, $file_info[
"name"], $importfile);
3699 $this->log->debug(
"Import file = $importfile");
3700 $this->log->debug(
"Import subdir = $import_subdir");
3702 $fh =
fopen($importfile,
"r");
3704 $error = $this->lng->txt(
"import_error_opening_file");
3707 $xml = fread($fh, filesize($importfile));
3710 $error = $this->lng->txt(
"import_error_closing_file");
3715 if (strpos(
$xml,
"questestinterop")) {
3716 include_once(
"./Modules/Survey/exceptions/class.ilInvalidSurveyImportFileException.php");
3719 $this->log->debug(
"survey id = " . $this->
getId());
3720 $this->log->debug(
"question pool id = " . $svy_qpl_id);
3722 include_once(
"./Services/Export/classes/class.ilImport.php");
3724 $config = $imp->getConfig(
"Modules/Survey");
3725 $config->setQuestionPoolID($svy_qpl_id);
3726 $imp->getMapping()->addMapping(
"Modules/Survey",
"svy", 0, $this->
getId());
3727 $imp->importFromDirectory($import_subdir,
"svy",
"Modules/Survey");
3728 $this->log->debug(
"config(Modules/survey)->getQuestionPoolId =" .
$config->getQuestionPoolID());
3732 include_once
"./Services/Survey/classes/class.SurveyImportParser.php";
3734 $import->setSurveyObject($this);
3735 $import->setXMLContent(
$xml);
3736 $import->startParsing();
3739 if (is_array(
$_SESSION[
"import_mob_xhtml"])) {
3740 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
3741 include_once
"./Services/RTE/classes/class.ilRTE.php";
3742 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
3743 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob) {
3744 $importfile = $import_subdir .
"/" . $mob[
"uri"];
3745 if (file_exists($importfile)) {
3746 if (!$mob[
"type"]) {
3747 $mob[
"type"] =
"svy:html";
3753 if ($mob[
"type"] ==
"svy:html") {
3755 $this->
setIntroduction(str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $this->
getIntroduction()));
3756 $this->
setOutro(str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $this->
getOutro()));
3759 elseif ($import->questions[$mob[
"id"]]) {
3760 $new_qid = $import->questions[$mob[
"id"]];
3763 $qtext = $new_question->getQuestiontext();
3765 $qtext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $qtext);
3767 $new_question->setQuestiontext($qtext);
3768 $new_question->saveToDb();
3771 if ($new_question->getOriginalId()) {
3773 $pool_question->setQuestiontext($qtext);
3774 $pool_question->saveToDb();
3779 $ilLog->write(
"Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
3801 public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree =
false)
3811 $newObj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
3813 $newObj->updateMetaData();
3817 $newObj->setOutro($this->
getOutro());
3864 $question_pointer = array();
3867 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3869 foreach ($this->questions as
$key => $question_id) {
3871 $question = self::_instanciateQuestion($question_id);
3875 $question->setObjId($newObj->getId());
3876 $question->saveToDb($original_id);
3877 $newObj->questions[
$key] = $question->getId();
3878 $question_pointer[$question_id] = $question->getId();
3879 $mapping[$question_id] = $question->getId();
3886 if (!$cp_options->isRootNode($this->getRefId())) {
3890 $newObj->saveToDb();
3891 $newObj->cloneTextblocks($mapping);
3896 include_once
"./Modules/Survey/classes/class.ilSurveySkill.php";
3900 foreach ($mapping as $src_qst_id => $tgt_qst_id) {
3901 $qst_skill = $src_skills->getSkillForQuestion($src_qst_id);
3903 $tgt_skills->addQuestionSkillAssignment($tgt_qst_id, $qst_skill[
"base_skill_id"], $qst_skill[
"tref_id"]);
3909 $questionblocks = array();
3910 $questionblock_questions = array();
3912 "SELECT * FROM svy_qblk_qst WHERE survey_fi = %s",
3918 array_push($questionblock_questions,
$row);
3919 $questionblocks[
$row[
"questionblock_fi"]] = $row[
"questionblock_fi"];
3923 foreach ($questionblocks as
$key => $value) {
3924 $questionblock = self::_getQuestionblock(
$key);
3925 $questionblock_id = self::_addQuestionblock($questionblock[
"title"], $questionblock[
"owner_fi"], $questionblock[
"show_questiontext"], $questionblock[
"show_blocktitle"]);
3926 $questionblocks[
$key] = $questionblock_id;
3929 foreach ($questionblock_questions as
$key => $value) {
3930 if ($questionblocks[$value[
"questionblock_fi"]] &&
3931 $question_pointer[$value[
"question_fi"]]) {
3932 $next_id =
$ilDB->nextId(
'svy_qblk_qst');
3933 $affectedRows =
$ilDB->manipulateF(
3934 "INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, question_fi) " .
3935 "VALUES (%s, %s, %s, %s)",
3936 array(
'integer',
'integer',
'integer',
'integer'),
3937 array($next_id, $newObj->getSurveyId(), $questionblocks[$value[
"questionblock_fi"]], $question_pointer[$value[
"question_fi"]])
3943 $constraints = self::_getConstraints($this->
getSurveyId());
3944 $newConstraints = array();
3945 foreach ($constraints as
$key => $constraint) {
3946 if ($question_pointer[$constraint[
"for_question"]] &&
3947 $question_pointer[$constraint[
"question"]]) {
3948 if (!array_key_exists($constraint[
'id'], $newConstraints)) {
3949 $constraint_id = $newObj->addConstraint($question_pointer[$constraint[
"question"]], $constraint[
"relation_id"], $constraint[
"value"], $constraint[
'conjunction']);
3950 $newConstraints[$constraint[
'id']] = $constraint_id;
3952 $newObj->addConstraintToQuestion($question_pointer[$constraint[
"for_question"]], $newConstraints[$constraint[
'id']]);
3957 include_once(
'./Services/Tracking/classes/class.ilLPObjSettings.php');
3959 $obj_settings->cloneSettings($newObj->getId());
3960 unset($obj_settings);
3969 "SELECT * FROM svy_svy_qst WHERE question_fi = %s",
3975 return $row[
"heading"];
3988 foreach ($mapping as $original_id => $new_id) {
3990 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
4006 if (!is_writable($svy_data_dir)) {
4007 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
4008 throw new ilSurveyException(
"Survey Data Directory (" . $svy_data_dir .
") not writeable.");
4012 $svy_dir = $svy_data_dir .
"/svy_" . $this->
getId();
4014 if (!@is_dir($svy_dir)) {
4015 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
4019 $export_dir = $svy_dir .
"/export";
4021 if (!@is_dir($export_dir)) {
4022 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
4049 if (!is_writable($svy_data_dir)) {
4050 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
4051 throw new ilSurveyException(
"Survey Data Directory (" . $svy_data_dir .
") not writeable.");
4055 $svy_dir = $svy_data_dir .
"/svy_" . $this->
getId();
4057 if (!@is_dir($svy_dir)) {
4058 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
4063 $import_dir = $svy_dir .
"/import";
4065 if (!@is_dir($import_dir)) {
4066 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
4077 "/svy_" . $this->
getId() .
"/import";
4078 if (!is_dir($import_dir)) {
4081 if (@is_dir($import_dir)) {
4092 $affectedRows =
$ilDB->manipulateF(
4093 "UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
4094 array(
'text',
'integer',
'integer'),
4095 array($heading, $this->
getSurveyId(), $insertbefore)
4098 $affectedRows =
$ilDB->manipulateF(
4099 "UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
4100 array(
'text',
'integer',
'integer'),
4111 "SELECT anonymous_id FROM svy_anonymous WHERE survey_key = %s AND survey_fi = %s",
4112 array(
'text',
'integer'),
4115 return (
$result->numRows() == 1) ?
true :
false;
4122 if ($user_id == ANONYMOUS_USER_ID) {
4127 $ilDB->manipulate(
"UPDATE svy_anonymous" .
4128 " SET user_key = " .
$ilDB->quote(md5($user_id),
"text") .
4129 " WHERE survey_key = " .
$ilDB->quote(
$code,
"text"));
4138 "SELECT finished_id FROM svy_finished WHERE anonymous_id = %s AND survey_fi = %s",
4139 array(
'text',
'integer'),
4142 return (
$result->numRows() == 1) ?
true :
false;
4171 include_once
"./Services/Link/classes/class.ilLink.php";
4173 $sql =
"SELECT svy_anonymous.*, svy_finished.state" .
4174 " FROM svy_anonymous" .
4175 " LEFT JOIN svy_finished ON (svy_anonymous.survey_key = svy_finished.anonymous_id)" .
4176 " WHERE svy_anonymous.survey_fi = " .
$ilDB->quote($this->
getSurveyId(),
"integer") .
4177 " AND svy_anonymous.user_key IS NULL";
4180 $sql .=
" AND " .
$ilDB->in(
"svy_anonymous.survey_key", $a_codes,
"",
"text");
4182 $sql .=
" AND " .
$ilDB->in(
"svy_anonymous.anonymous_id", $a_ids,
"",
"text");
4189 $titles[] =
'"' .
$lng->txt(
"survey_code") .
'"';
4190 $titles[] =
'"' .
$lng->txt(
"email") .
'"';
4191 $titles[] =
'"' .
$lng->txt(
"lastname") .
'"';
4192 $titles[] =
'"' .
$lng->txt(
"firstname") .
'"';
4193 $titles[] =
'"' .
$lng->txt(
"create_date") .
'"';
4194 $titles[] =
'"' .
$lng->txt(
"used") .
'"';
4195 $titles[] =
'"' .
$lng->txt(
"mail_sent_short") .
'"';
4196 $titles[] =
'"' .
$lng->txt(
"survey_code_url") .
'"';
4197 $export[] = implode(
";", $titles);
4200 $default_lang =
$ilUser->getPref(
"survey_code_language");
4203 $item[] =
$row[
"survey_key"];
4205 if (
$row[
"externaldata"]) {
4206 $ext = unserialize(
$row[
"externaldata"]);
4207 $item[] = $ext[
"email"];
4208 $item[] = $ext[
"lastname"];
4209 $item[] = $ext[
"firstname"];
4221 $item[] = (
$row[
"sent"]) ? 1 : 0;
4223 $params = array(
"accesscode" =>
$row[
"survey_key"]);
4224 if ($default_lang) {
4225 $params[
"lang"] = $default_lang;
4229 $export[] =
'"' . implode(
'";"', $item) .
'"';
4231 return implode(
"\n", $export);
4245 include_once
"./Services/Link/classes/class.ilLink.php";
4249 $sql =
"SELECT svy_anonymous.*, svy_finished.state" .
4250 " FROM svy_anonymous" .
4251 " LEFT JOIN svy_finished ON (svy_anonymous.survey_key = svy_finished.anonymous_id)" .
4252 " WHERE svy_anonymous.survey_fi = " .
$ilDB->quote($this->
getSurveyId(),
"integer")
4256 $sql .=
" AND " .
$ilDB->in(
"svy_anonymous.anonymous_id", $ids,
"",
"integer");
4259 $sql .=
" ORDER BY tstamp, survey_key ASC";
4268 $params = array(
"accesscode" =>
$row[
"survey_key"]);
4277 'id' =>
$row[
"anonymous_id"],
4278 'code' =>
$row[
"survey_key"],
4279 'date' =>
$row[
"tstamp"],
4281 'sent' =>
$row[
'sent'],
4288 if (
$row[
"externaldata"]) {
4289 $ext = unserialize(
$row[
"externaldata"]);
4290 $item[
'email'] = $ext[
'email'];
4291 $item[
'last_name'] = $ext[
'lastname'];
4292 $item[
'first_name'] = $ext[
'firstname'];
4295 array_push($codes, $item);
4305 "SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
4306 array(
'integer',
'text'),
4309 return (
$result->numRows() > 0) ?
true :
false;
4316 "SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
4317 array(
'integer',
'text'),
4320 return (
$result->numRows() > 0) ?
false :
true;
4329 for (
$i = 0;
$i < $nrOfCodes;
$i++) {
4330 $next_id =
$ilDB->nextId(
'svy_anonymous');
4332 "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, tstamp) " .
4333 "VALUES (%s, %s, %s, %s)",
4334 array(
'integer',
'text',
'integer',
'integer'),
4347 $next_id =
$ilDB->nextId(
'svy_anonymous');
4349 "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) " .
4350 "VALUES (%s, %s, %s, %s, %s)",
4351 array(
'integer',
'text',
'integer',
'text',
'integer'),
4352 array($next_id, $a_anonymize_key, $this->
getSurveyId(), serialize($a_data), $a_created)
4361 foreach (
$data as $dataset) {
4363 $next_id =
$ilDB->nextId(
'svy_anonymous');
4364 $affectedRows =
$ilDB->manipulateF(
4365 "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) " .
4366 "VALUES (%s, %s, %s, %s, %s)",
4367 array(
'integer',
'text',
'integer',
'text',
'integer'),
4368 array($next_id, $anonymize_key, $this->
getSurveyId(), serialize($dataset), time())
4384 $check_finished = ($not_sent > 1);
4386 include_once
"./Services/Mail/classes/class.ilMail.php";
4387 include_once
"./Services/Link/classes/class.ilLink.php";
4389 $mail =
new ilMail(ANONYMOUS_USER_ID);
4391 foreach ($recipients as
$data) {
4392 if ($data[
'email'] && $data[
'code']) {
4394 switch ((
int) $not_sent) {
4396 $do_send = !(bool) $data[
'sent'];
4400 $do_send = $data[
'finished'];
4404 $do_send = !$data[
'finished'];
4418 "accesscode" => $data[
"code"],
4422 $messagetext = str_replace(
'[url]',
$url, $messagetext);
4423 foreach ($data as
$key => $value) {
4424 $messagetext = str_replace(
'[' .
$key .
']', $value, $messagetext);
4443 "UPDATE svy_anonymous SET sent = %s WHERE survey_fi = %s AND externaldata IS NOT NULL",
4444 array(
'integer',
'integer'),
4453 "SELECT survey_key code, externaldata, sent FROM svy_anonymous WHERE survey_fi = %s",
4459 if (!
$row[
'externaldata']) {
4463 $externaldata = unserialize(
$row[
'externaldata']);
4464 if (!$externaldata[
'email']) {
4468 $externaldata[
'code'] =
$row[
'code'];
4469 $externaldata[
'sent'] =
$row[
'sent'];
4471 if ($a_check_finished) {
4477 array_push(
$res, $externaldata);
4490 "SELECT state FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
4491 array(
'integer',
'text'),
4497 return $row[
'state'];
4509 if (strlen($survey_code) > 0) {
4510 $affectedRows =
$ilDB->manipulateF(
4511 "DELETE FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
4512 array(
'integer',
'text'),
4529 "SELECT survey_key FROM svy_anonymous WHERE survey_fi = %s AND user_key = %s",
4530 array(
'integer',
'text'),
4535 $access_code =
$row[
"survey_key"];
4537 return $access_code;
4552 $next_id =
$ilDB->nextId(
'svy_anonymous');
4553 $affectedRows =
$ilDB->manipulateF(
4554 "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, user_key, tstamp) " .
4555 "VALUES (%s, %s, %s, %s, %s)",
4556 array(
'integer',
'text',
'integer',
'text',
'integer'),
4557 array($next_id, $access_code, $this->
getSurveyId(), md5($user_id), time())
4569 $codestring =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
4572 for (
$i = 1;
$i <= 5;
$i++) {
4573 $index = mt_rand(0, strlen($codestring) - 1);
4588 "SELECT tstamp FROM svy_answer WHERE active_fi = %s ORDER BY tstamp DESC",
4594 return $row[
"tstamp"];
4597 "SELECT tstamp FROM svy_finished WHERE finished_id = %s",
4603 return $row[
"tstamp"];
4629 if (preg_match(
"/<[^>]*?>/", $a_text)) {
4644 public function addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag =
true, $add_mobs =
true, $attribs = null)
4646 include_once
"./Services/RTE/classes/class.ilRTE.php";
4647 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
4649 $a_xml_writer->xmlStartTag(
"material", $attribs);
4651 "type" =>
"text/plain" 4653 if ($this->
isHTML($a_material)) {
4654 $attrs[
"type"] =
"text/xhtml";
4657 $a_xml_writer->xmlElement(
"mattext", $attrs, $mattext);
4661 foreach (
$mobs as $mob) {
4662 $mob_id =
"il_" . IL_INST_ID .
"_mob_" . $mob;
4663 if (strpos($mattext, $mob_id) !==
false) {
4667 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle(),
4668 "type" =>
"svy:html",
4669 "id" => $this->
getId()
4671 $a_xml_writer->xmlElement(
"matimage", $imgattrs, null);
4675 if ($close_material_tag) {
4676 $a_xml_writer->xmlEndTag(
"material");
4691 if ($this->surveyCodeSecurity ==
false) {
4707 if (extension_loaded(
"tidy")) {
4710 "output-xml" =>
true,
4711 "numeric-entities" =>
true 4714 $tidy->parseString($print_output,
$config,
'utf8');
4715 $tidy->cleanRepair();
4716 $print_output = tidy_get_output($tidy);
4717 $print_output = preg_replace(
"/^.*?(<html)/",
"\\1", $print_output);
4719 $print_output = str_replace(
" ",
" ", $print_output);
4720 $print_output = str_replace(
"⊗",
"X", $print_output);
4723 $print_output = str_replace(
">",
"~|gt|~", $print_output);
4724 $print_output = str_replace(
"<",
"~|lt|~", $print_output);
4725 $print_output = str_replace(
" ",
"~|nbsp|~", $print_output);
4726 $print_output = preg_replace(
'/&(?!amp)/',
'&', $print_output);
4727 $print_output = str_replace(
"~|nbsp|~",
" ", $print_output);
4728 $print_output = str_replace(
"~|gt|~",
">", $print_output);
4729 $print_output = str_replace(
"~|lt|~",
"<", $print_output);
4731 $xsl = file_get_contents(
"./Modules/Survey/xml/question2fo.xsl");
4735 'font-family="Helvetica, unifont"',
4736 'font-family="' .
$GLOBALS[
'ilSetting']->
get(
'rpc_pdf_font',
'Helvetica, unifont') .
'"',
4739 $args = array(
'/_xml' => $print_output,
'/_xsl' => $xsl );
4743 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", null, $args,
$params);
4745 $this->log->error(
"Print XSLT failed:");
4746 $this->log->error(
"Content: " . $print_output);
4747 $this->log->error(
"Xsl: " . $xsl);
4767 $fp =
fopen($fo_file,
"w");
4771 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
4777 $ilLog->write(__METHOD__ .
': ' . $e->getMessage());
4791 if ($ilPluginAdmin->isActive(
IL_COMP_MODULE,
"SurveyQuestionPool",
"svyq", $a_pname)) {
4818 if (!is_array($ids) || count($ids) == 0) {
4822 $result =
$ilDB->query(
"SELECT usr_id, login, lastname, firstname FROM usr_data WHERE " .
$ilDB->in(
'usr_id', $ids,
false,
'integer') .
" ORDER BY login");
4823 $result_array = array();
4825 $result_array[
$row[
"usr_id"]] =
$row;
4827 return $result_array;
4837 $this->mailnotification = ($a_notification) ?
true :
false;
4847 $this->mailaddresses = $a_addresses;
4857 $this->mailparticipantdata = $a_data;
4867 $affectedRows =
$ilDB->manipulateF(
4868 "INSERT INTO svy_times (id, finished_fi, entered_page, left_page, first_question) VALUES (%s, %s, %s, %s,%s)",
4869 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
4870 array(
$id, $finished_id,
$time, null, $first_question)
4878 $affectedRows =
$ilDB->manipulateF(
4879 "UPDATE svy_times SET left_page = %s WHERE finished_fi = %s AND entered_page = %s",
4880 array(
'integer',
'integer',
'integer'),
4891 "SELECT * FROM svy_times WHERE finished_fi = %s",
4897 if (
$row[
'left_page'] > 0 &&
$row[
'entered_page'] > 0) {
4916 if (
sizeof($this->questions) ==
sizeof($a_order)) {
4917 $this->questions = array_flip($a_order);
4918 $this->saveQuestionsToDB();
4929 $this->pool_usage = (bool) $a_value;
4941 if ($template_settings) {
4942 include_once
"Services/Administration/classes/class.ilSettingsTemplate.php";
4944 $template_settings = $template_settings->getSettings();
4945 $template_settings = $template_settings[
"use_pool"];
4946 if ($template_settings && $template_settings[
"hide"]) {
4947 $use_pool = (bool) $template_settings[
"value"];
4964 include_once
"Services/Administration/classes/class.ilSettingsTemplate.php";
4966 $template_settings =
$template->getSettings();
4968 if ($template_settings) {
4969 if ($template_settings[
"show_question_titles"] !== null) {
4970 if ($template_settings[
"show_question_titles"][
"value"]) {
4977 if ($template_settings[
"use_pool"] !== null) {
4978 if ($template_settings[
"use_pool"][
"value"]) {
4997 $codes = (bool) $template_settings[
"acc_codes"][
"value"];
4998 $anon = (bool) $template_settings[
"anonymization_options"][
"value"];
5028 public function updateCode($a_id, $a_email, $a_last_name, $a_first_name, $a_sent)
5032 $a_email = trim($a_email);
5039 $data = array(
"email" => $a_email,
5040 "lastname" => trim($a_last_name),
5041 "firstname" => trim($a_first_name));
5044 "externaldata" => array(
"text", serialize(
$data)),
5045 "sent" => array(
"integer", $a_sent)
5051 array(
"anonymous_id" => array(
"integer", $a_id))
5072 $this->mode_360_self_eval = (bool) $a_value;
5082 $this->mode_360_self_appr = (bool) $a_value;
5092 $this->mode_360_self_rate = (bool) $a_value;
5102 $this->mode_360_results = (int) $a_value;
5114 $ilDB = $DIC->database();
5118 $a_user_id != ANONYMOUS_USER_ID) {
5120 "obj_id" => array(
"integer", $this->
getSurveyId()),
5121 "user_id" => array(
"integer", $a_user_id)
5123 $ilDB->insert(
"svy_360_appr", $fields);
5126 if (
$access->checkAccessOfUser($a_user_id,
"read",
"", $this->getRefId())) {
5141 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
5143 $ntf->setLangModules(array(
"svy",
"survey"));
5145 $ntf->setGotoLangId(
'url');
5148 $lng = $ntf->getUserLanguage($a_user_id);
5150 $ntf->setIntroductionLangId(
"svy_user_added_360_appraisee_mail");
5151 $subject = str_replace(
"%1", $this->
getTitle(),
$lng->txt(
"svy_user_added_360_appraisee"));
5154 $mail =
new ilMail(ANONYMOUS_USER_ID);
5161 $ntf->composeAndGetMessage($a_user_id, null,
"read",
true),
5174 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
5176 $ntf->setLangModules(array(
"svy",
"survey"));
5178 $ntf->setGotoLangId(
'url');
5181 $lng = $ntf->getUserLanguage($a_user_id);
5183 $ntf->setIntroductionLangId(
"svy_user_added_360_appraisee_close_mail");
5184 $subject = str_replace(
"%1", $this->
getTitle(),
$lng->txt(
"svy_user_added_360_appraisee"));
5187 $mail =
new ilMail(ANONYMOUS_USER_ID);
5194 $ntf->composeAndGetMessage($a_user_id, null,
"read",
true),
5207 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
5209 $ntf->setLangModules(array(
"svy",
"survey"));
5211 $ntf->setGotoLangId(
'url');
5214 $lng = $ntf->getUserLanguage($a_user_id);
5216 $ntf->setIntroductionLangId(
"svy_user_added_360_rater_mail");
5217 $subject = str_replace(
"%1", $this->
getTitle(),
$lng->txt(
"svy_user_added_360_rater"));
5221 $mail =
new ilMail(ANONYMOUS_USER_ID);
5228 $ntf->composeAndGetMessage($a_user_id, null,
"read",
true),
5238 $set =
$ilDB->query(
"SELECT user_id" .
5239 " FROM svy_360_appr" .
5240 " WHERE obj_id = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
5241 " AND user_id = " .
$ilDB->quote($a_user_id,
"integer"));
5242 return (
bool)
$ilDB->numRows($set);
5249 $set =
$ilDB->query(
"SELECT has_closed" .
5250 " FROM svy_360_appr" .
5251 " WHERE obj_id = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
5252 " AND user_id = " .
$ilDB->quote($a_user_id,
"integer"));
5254 return $row[
"has_closed"];
5261 $ilDB->manipulate(
"DELETE FROM svy_360_appr" .
5262 " WHERE obj_id = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
5263 " AND user_id = " .
$ilDB->quote($a_user_id,
"integer"));
5265 $set =
$ilDB->query(
"SELECT user_id" .
5266 " FROM svy_360_rater" .
5267 " WHERE obj_id = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
5268 " AND appr_id = " .
$ilDB->quote($a_user_id,
"integer"));
5269 while (
$row =
$ilDB->fetchAssoc($set)) {
5284 $set =
$ilDB->query(
"SELECT * FROM svy_360_appr" .
5285 " WHERE obj_id = " .
$ilDB->quote($this->getSurveyId(),
"integer"));
5286 while (
$row =
$ilDB->fetchAssoc($set)) {
5294 foreach ($raters as $rater) {
5295 if ($rater[
"finished"]) {
5299 $res[$row[
"user_id"]][
"finished"] = $finished .
"/" .
sizeof($raters);
5300 $res[$row[
"user_id"]][
"closed"] = $row[
"has_closed"];
5306 public function addRater($a_appraisee_id, $a_user_id, $a_anonymous_id = 0)
5310 $ilDB = $DIC->database();
5314 !$this->
isRater($a_appraisee_id, $a_user_id, $a_anonymous_id)) {
5316 "obj_id" => array(
"integer", $this->
getSurveyId()),
5317 "appr_id" => array(
"integer", $a_appraisee_id),
5318 "user_id" => array(
"integer", $a_user_id),
5319 "anonymous_id" => array(
"integer", $a_anonymous_id)
5321 $ilDB->insert(
"svy_360_rater", $fields);
5324 if (
$access->checkAccessOfUser($a_user_id,
"read",
"", $this->getRefId())) {
5332 public function isRater($a_appraisee_id, $a_user_id, $a_anonymous_id = 0)
5339 (!$a_appraisee_id || $a_appraisee_id == $a_user_id)) {
5345 $sql =
"SELECT user_id" .
5346 " FROM svy_360_rater" .
5348 " AND user_id = " .
$ilDB->quote($a_user_id,
"integer") .
5349 " AND anonymous_id = " .
$ilDB->quote($a_anonymous_id,
"integer");
5350 if ($a_appraisee_id) {
5351 $sql .=
" AND appr_id = " .
$ilDB->quote($a_appraisee_id,
"integer");
5353 $set =
$ilDB->query($sql);
5354 return (
bool)
$ilDB->numRows($set);
5357 public function deleteRater($a_appraisee_id, $a_user_id, $a_anonymous_id = 0)
5366 $ilDB->manipulate(
"DELETE FROM svy_360_rater" .
5367 " WHERE obj_id = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
5368 " AND appr_id = " .
$ilDB->quote($a_appraisee_id,
"integer") .
5369 " AND user_id = " .
$ilDB->quote($a_user_id,
"integer") .
5370 " AND anonymous_id = " .
$ilDB->quote($a_anonymous_id,
"integer"));
5377 $res = $anonymous_ids = array();
5379 $set =
$ilDB->query(
"SELECT * FROM svy_360_rater" .
5380 " WHERE obj_id = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
5381 " AND appr_id = " .
$ilDB->quote($a_appraisee_id,
"integer"));
5382 while (
$row =
$ilDB->fetchAssoc($set)) {
5383 if (
$row[
"anonymous_id"]) {
5384 $res[
"a" .
$row[
"anonymous_id"]] = array(
5385 "lastname" =>
"unknown code " .
$row[
"anonymous_id"],
5386 "sent" =>
$row[
"mail_sent"],
5389 $anonymous_ids[] =
$row[
"anonymous_id"];
5401 if (
sizeof($anonymous_ids)) {
5403 foreach (
$data as $item) {
5404 if (isset(
$res[
"a" . $item[
"id"]])) {
5405 $res[
"a" . $item[
"id"]] = array(
5406 "user_id" =>
"a" . $item[
"id"],
5407 "lastname" => $item[
"last_name"],
5408 "firstname" => $item[
"first_name"],
5409 "name" => $item[
"last_name"] .
", " . $item[
"first_name"],
5411 "email" => $item[
"email"],
5412 "code" => $item[
"code"],
5413 "href" => $item[
"href"],
5414 "sent" =>
$res[
"a" . $item[
"id"]][
"sent"],
5430 $sql =
"SELECT appr_id FROM svy_360_rater" .
5434 $sql .=
" AND user_id = " .
$ilDB->quote($a_user_id,
"integer");
5436 $sql .=
" AND anonymous_id = " .
$ilDB->quote($a_anonymous_id,
"integer");
5439 $set =
$ilDB->query($sql);
5440 while (
$row =
$ilDB->fetchAssoc($set)) {
5447 !in_array($a_user_id,
$res)) {
5448 $res[] = $a_user_id;
5458 $set =
$ilDB->query(
"SELECT anonymous_id FROM svy_anonymous" .
5459 " WHERE survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
5460 " AND survey_key = " .
$ilDB->quote($a_code,
"text"));
5462 return $res[
"anonymous_id"];
5469 $sql =
"SELECT * FROM svy_finished" .
5471 " AND appr_id = " .
$ilDB->quote($appr_id,
"integer");
5473 $sql .=
" AND user_fi = " .
$ilDB->quote($user_id,
"integer");
5475 $sql .=
" AND anonymous_id = " .
$ilDB->quote($anonymous_code,
"text");
5478 if (
$result->numRows() == 0) {
5482 return (
int)
$row[
"state"];
5498 $user_id != ANONYMOUS_USER_ID &&
5499 $this->
isRater(0, $user_id)) {
5507 } elseif ($user_id == ANONYMOUS_USER_ID ||
5520 $sql =
"SELECT * FROM svy_finished" .
5523 if ($user_id != ANONYMOUS_USER_ID) {
5524 $sql .=
" AND (user_fi = " .
$ilDB->quote($user_id,
"integer") .
5525 " OR anonymous_id = " .
$ilDB->quote($a_code,
"text") .
")";
5529 $sql .=
" AND anonymous_id = " .
$ilDB->quote($a_code,
"text");
5531 $set =
$ilDB->query($sql);
5532 while (
$row =
$ilDB->fetchAssoc($set)) {
5533 $res[
$row[
"finished_id"]] = array(
"appr_id" => $row[
"appr_id"],
5534 "user_id" => $row[
"user_fi"],
5535 "code" => $row[
"anonymous_id"],
5536 "finished" => (
bool) $row[
"state"]);
5539 return array(
"code" => $a_code,
"runs" =>
$res);
5546 if ($a_user_id != ANONYMOUS_USER_ID) {
5547 $set =
$ilDB->query(
"SELECT sf.anonymous_id FROM svy_finished sf" .
5548 " WHERE sf.survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
5549 " AND sf.user_fi = " .
$ilDB->quote($a_user_id,
"integer"));
5550 $a_code =
$ilDB->fetchAssoc($set);
5551 return $a_code[
"anonymous_id"];
5559 $set =
$ilDB->query(
"SELECT user_fi FROM svy_finished" .
5560 " WHERE survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
5561 " AND anonymous_id = " .
$ilDB->quote($a_code,
"text"));
5562 $user_id =
$ilDB->fetchAssoc($set);
5563 $user_id = $user_id[
"user_fi"];
5565 if ($user_id && ($user_id != $a_user_id || $user_id == ANONYMOUS_USER_ID)) {
5577 $set =
$ilDB->query(
"SELECT finished_id, user_fi FROM svy_finished" .
5578 " WHERE survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
5579 " AND appr_id = " .
$ilDB->quote($a_appr_id,
"integer"));
5580 while (
$row =
$ilDB->fetchAssoc($set)) {
5581 if ($a_exclude_appraisee &&
$row[
"user_fi"] == $a_appr_id) {
5601 $set =
$ilDB->query(
"SELECT finished_id, user_fi FROM svy_finished" .
5602 " WHERE survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
5603 " AND appr_id = " .
$ilDB->quote($a_appr_id,
"integer") .
5604 " AND user_fi = " .
$ilDB->quote($a_rat_id,
"integer"));
5606 return $row[
"finished_id"];
5619 $this->mode_skill_service = $a_val;
5632 public function set360RaterSent($a_appraisee_id, $a_user_id, $a_anonymous_id, $a_tstamp = null)
5640 $ilDB->manipulate(
"UPDATE svy_360_rater" .
5641 " SET mail_sent = " .
$ilDB->quote($a_tstamp,
"integer") .
5643 " AND appr_id = " .
$ilDB->quote($a_appraisee_id,
"integer") .
5644 " AND user_id = " .
$ilDB->quote($a_user_id,
"integer") .
5645 " AND anonymous_id = " .
$ilDB->quote($a_anonymous_id,
"integer"));
5652 $ilDB = $DIC->database();
5653 $user = $DIC->user();
5656 $ilDB->manipulate(
"UPDATE svy_360_appr" .
5657 " SET has_closed = " .
$ilDB->quote(time(),
"integer") .
5659 " AND user_id = " .
$ilDB->quote($a_user_id,
"integer"));
5662 include_once(
"./Services/Skill/classes/class.ilSkillManagementSettings.php");
5665 include_once(
"./Modules/Survey/classes/class.ilSurveySkill.php");
5667 $sskill->writeAppraiseeSkills($a_user_id);
5671 if (
$user->getId() != $a_user_id) {
5680 $ilDB->manipulate(
"UPDATE svy_360_appr" .
5681 " SET has_closed = " .
$ilDB->quote(null,
"integer") .
5687 if (!isset(
$_SESSION[
"360_extrtr"][$a_ref_id])) {
5688 $svy =
new self($a_ref_id);
5691 if ($svy->canStartSurvey(null,
true) &&
5692 $svy->get360Mode() &&
5693 $svy->isAnonymousKey($a_code)) {
5694 $anonymous_id = $svy->getAnonymousIdByCode($a_code);
5695 if ($anonymous_id) {
5696 if (
sizeof($svy->getAppraiseesToRate(null, $anonymous_id))) {
5697 $_SESSION[
"360_extrtr"][$a_ref_id] =
true;
5703 $_SESSION[
"360_extrtr"][$a_ref_id] =
false;
5707 return $_SESSION[
"360_extrtr"][$a_ref_id];
5722 $this->reminder_status = (bool) $a_value;
5732 $this->reminder_start = $a_value;
5742 $this->reminder_end = $a_value;
5752 $this->reminder_frequency = (int) $a_value;
5762 $this->reminder_target = (int) $a_value;
5772 $this->reminder_last_sent = $a_value;
5781 if ($selectDefault) {
5782 $defaultTemplateId = 0;
5783 $this->getReminderMailTemplates($defaultTemplateId);
5785 if ($defaultTemplateId > 0) {
5786 return $defaultTemplateId;
5795 $this->reminder_tmpl = $a_value;
5805 $this->tutor_ntf_status = (bool) $a_value;
5815 $this->tutor_ntf_recipients = $a_value;
5825 $this->tutor_ntf_target = (int) $a_value;
5835 $set =
$ilDB->query(
"SELECT COUNT(*) numall FROM svy_finished" .
5836 " WHERE survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
5837 " AND state = " .
$ilDB->quote(1,
"integer") .
5838 " AND " .
$ilDB->in(
"user_fi", $user_ids,
"",
"integer"));
5840 if (
$row[
"numall"] ==
sizeof($user_ids)) {
5860 $rater_ids = array();
5862 $this->log->debug(
"Handle appraisee " . $app[
'user_id']);
5870 $this->log->debug(
"...1");
5873 $this->log->debug(
"...2");
5874 if (!is_array($rater_ids[$app[
'user_id']])) {
5875 $rater_ids[$app[
'user_id']] = array();
5877 if (!in_array($app[
"user_id"], $rater_ids[$app[
'user_id']])) {
5878 $rater_ids[$app[
'user_id']][] = $app[
"user_id"];
5883 $this->log->debug(
"Check raters.");
5889 if (!$rater[
"anonymous_id"] && !$rater[
"finished"]) {
5890 if (!is_array($rater_ids[$rater[
"user_id"]])) {
5891 $rater_ids[$rater[
"user_id"]] = array();
5893 if (!in_array($app[
"user_id"], $rater_ids[$rater[
"user_id"]])) {
5894 $rater_ids[$rater[
"user_id"]][] = $app[
"user_id"];
5902 $this->log->debug(
"Found raters:" . count($rater_ids));
5904 foreach ($rater_ids as
$id => $app) {
5905 if (
$access->checkAccessOfUser(
$id,
"read",
"", $this->getRefId())) {
5918 $this->log->debug(
"Send mail to:" . $a_user_id);
5920 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
5922 $ntf->setLangModules(array(
"svy",
"survey"));
5924 $ntf->setGotoLangId(
'url');
5927 $lng = $ntf->getUserLanguage($a_user_id);
5929 $ntf->setIntroductionLangId(
"svy_user_added_360_rater_reminder_mail");
5930 $subject = str_replace(
"%1", $this->
getTitle(),
$lng->txt(
"svy_user_added_360_rater"));
5932 foreach ($a_appraisee_ids as $appraisee_id) {
5937 $mail =
new ilMail(ANONYMOUS_USER_ID);
5938 $mail->enableSOAP(
false);
5944 $ntf->composeAndGetMessage($a_user_id, null,
"read",
true),
5955 if ((
bool) $a_use_invited) {
5958 $parent_grp_ref_id =
$tree->checkForParentType($this->
getRefId(),
"grp");
5959 if ($parent_grp_ref_id) {
5960 include_once
"Modules/Group/classes/class.ilGroupParticipants.php";
5962 $user_ids = $part->getMembers();
5964 $parent_crs_ref_id =
$tree->checkForParentType($this->
getRefId(),
"crs");
5965 if ($parent_crs_ref_id) {
5966 include_once
"Modules/Course/classes/class.ilCourseParticipants.php";
5968 $user_ids = $part->getMembers();
5977 include_once
"./Services/Mail/classes/class.ilMail.php";
5978 include_once
"./Services/User/classes/class.ilObjUser.php";
5979 include_once
"./Services/Language/classes/class.ilLanguageFactory.php";
5980 include_once
"./Services/User/classes/class.ilUserUtil.php";
5981 include_once
"./Services/Link/classes/class.ilLink.php";
5987 $ulng->loadLanguageModule(
'survey');
5989 $subject = sprintf($ulng->txt(
'survey_notification_tutor_subject'), $this->
getTitle());
5992 $message .= $ulng->txt(
'survey_notification_tutor_body') .
":\n\n";
5993 $message .= $ulng->txt(
'obj_svy') .
": " . $this->
getTitle() .
"\n";
5994 $message .=
"\n" . $ulng->txt(
'survey_notification_tutor_link') .
": " . $link;
5996 $mail_obj =
new ilMail(ANONYMOUS_USER_ID);
5997 $mail_obj->appendInstallationSignature(
true);
5998 $mail_obj->sendMail(
6016 $now_with_format = date(
"YmdHis", $now);
6017 $today = date(
"Y-m-d");
6019 $this->log->debug(
"Check status and dates.");
6044 $this->log->debug(
"Check access period.");
6047 include_once
"Services/Object/classes/class.ilObjectActivation.php";
6050 ($now < $item_data[
"timing_start"] ||
6051 $now > $item_data[
"timing_end"])) {
6055 $this->log->debug(
"Check frequency.");
6062 $missing_ids = array();
6065 $this->log->debug(
"Entering survey mode.");
6071 $finished_ids = array();
6072 $set =
$ilDB->query(
"SELECT user_fi FROM svy_finished" .
6073 " WHERE survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer") .
6074 " AND state = " .
$ilDB->quote(1,
"text") .
6075 " AND " .
$ilDB->in(
"user_fi", $user_ids,
"",
"integer"));
6076 while (
$row =
$ilDB->fetchAssoc($set)) {
6077 $finished_ids[] =
$row[
"user_fi"];
6081 $missing_ids = array_diff($user_ids, $finished_ids);
6083 foreach ($missing_ids as $idx => $user_id) {
6085 if (!$ilAccess->checkAccessOfUser($user_id,
"read",
"", $this->getRefId(),
"svy", $this->
getId())) {
6086 unset($missing_ids[$idx]);
6091 $this->sentReminder($missing_ids);
6095 $this->log->debug(
"Entering 360 mode.");
6104 return sizeof($missing_ids);
6110 protected function sentReminder(array $a_recipient_ids)
6118 $templateService = $DIC[
'mail.texttemplates.service'];
6121 $tmpl_params = array(
6128 include_once
"./Services/Link/classes/class.ilLink.php";
6131 include_once
"./Services/Language/classes/class.ilLanguageFactory.php";
6134 foreach ($a_recipient_ids as $user_id) {
6136 $subject = $tmpl->getSubject();
6143 $ulng->loadLanguageModule(
'survey');
6145 $subject = sprintf($ulng->txt(
'survey_reminder_subject'), $this->
getTitle());
6148 $message .= $ulng->txt(
'survey_reminder_body') .
":\n\n";
6149 $message .= $ulng->txt(
'obj_svy') .
": " . $this->
getTitle() .
"\n";
6150 $message .=
"\n" . $ulng->txt(
'survey_reminder_link') .
": " . $link;
6153 $mail_obj =
new ilMail(ANONYMOUS_USER_ID);
6154 $mail_obj->appendInstallationSignature(
true);
6155 $mail_obj->sendMail(
6169 $this->activation_starting_time = $starting_time;
6174 $this->activation_ending_time = $ending_time;
6179 return (strlen($this->activation_starting_time)) ? $this->activation_starting_time : null;
6184 return (strlen($this->activation_ending_time)) ? $this->activation_ending_time : null;
6189 $this->view_own_results = (bool) $a_value;
6199 $this->mail_own_results = (bool) $a_value;
6209 $this->mail_confirmation = (bool) $a_value;
6219 $this->anon_user_list = (bool) $a_value;
6231 $lng = $DIC->language();
6235 include_once
"./Services/Administration/classes/class.ilSetting.php";
6236 $surveySetting =
new ilSetting(
"survey");
6237 if (!$surveySetting->get(
"skipped_is_custom",
false)) {
6238 return $lng->txt(
"skipped");
6240 return $surveySetting->get(
"skipped_custom_value",
"");
6248 public function getReminderMailTemplates(&$defaultTemplateId = null)
6255 $templateService = $DIC[
'mail.texttemplates.service'];
6257 $res[$tmpl->getTplId()] = $tmpl->getTitle();
6258 if (null !== $defaultTemplateId && $tmpl->isDefault()) {
6259 $defaultTemplateId = $tmpl->getTplId();
6272 $user = new \ilObjUser($a_user_id);
6274 $processor = new \ilMailTemplatePlaceholderResolver(
$context, $a_message);
6275 $a_message = $processor->resolve(
$user, $a_context_params);
6285 $this->mode = $a_value;
6295 $this->mode_self_eval_results = $a_value;
createSurveyCodes($nrOfCodes)
showQuestionTitles()
Sets the question titles visible during the query.
static _lookupLogin($a_user_id)
lookup login
getTutorNotificationTarget()
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _lookupName($a_user_id)
lookup user name
static getUserIdsByEmail($a_email)
STATIC METHOD get all user_ids of an email address.
set360RaterSent($a_appraisee_id, $a_user_id, $a_anonymous_id, $a_tstamp=null)
static makeDirParents($a_dir)
Create a new directory and all parent directories.
deliverPDFfromFO($fo)
Delivers a PDF file from a XSL-FO string.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
setInvitationAndMode($invitation=0, $invitation_mode=0)
Sets the invitation status and mode (a more performant solution if you change both) ...
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
getAppraiseesToRate($a_user_id, $a_anonymous_id=null)
getUserSurveyExecutionStatus($a_code=null)
createNewAccessCode()
Returns a new, unused survey access code.
updateConjunctionForQuestions($questions, $conjunction)
is360SurveyStarted($appr_id, $user_id, $anonymous_code=null)
& getQuestionpoolTitles($could_be_offline=false, $showPath=false)
Get the titles of all available survey question pools.
setEndDateAndTime($end_date="", $end_time)
Sets the end date of the survey.
isAnonymizedParticipant($key)
sentReminderPlaceholders($a_message, $a_user_id, array $a_context_params)
__construct($a_id=0, $a_call_by_reference=true)
Constructor public.
& getSurveyPages()
Returns the survey pages in an array (a page contains one or more questions)
deleteRater($a_appraisee_id, $a_user_id, $a_anonymous_id=0)
getReminderTemplate($selectDefault=false)
& getEvaluationByUser($questions, $active_id)
Calculates the evaluation data for a given user or anonymous id.
processPrintoutput2FO($print_output)
Convert a print output to XSL-FO.
setReminderLastSent($a_value)
static _getUsedHTMLTagsAsString($a_module="")
Returns a string of all allowed HTML tags for text editing.
const EVALUATION_ACCESS_OFF
getParticipantTextResults($active_id)
applySettingsTemplate($template_id)
Apply settings template.
$activation_starting_time
& getSurveyFinishedIds()
Get the finished id's of all survey participants.
getQuestionGUI($questiontype, $question_id)
Returns a question gui object to a given questiontype and question id.
static validateExternalRaterCode($a_ref_id, $a_code)
static is_email($a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
setMailNotification($a_notification)
disinviteAllUsers()
Disinvite all users.
Skill management settings.
& getSurveyParticipants($finished_ids=null, $force_non_anonymous=false)
saveUserSettings($usr_id, $key, $title, $value)
getConstraints($question_id)
Returns the constraints to a given question or questionblock.
const EVALUATION_ACCESS_PARTICIPANTS
setTutorNotificationTarget($a_value)
static getSurveySkippedValue()
static _lookupFullname($a_user_id)
Lookup Full Name.
deleteSurveyCode($survey_code)
Deletes a given survey access code.
getWorkingtimeForParticipant($finished_id)
static getTemplateContextById($a_id)
deleteAllUserData($reset_LP=true)
Deletes all user data of a survey.
getSurveyId()
Returns the survey database id.
updateMetaData()
update meta data entry
getSurveyCodesForExport(array $a_codes=null, array $a_ids=null)
Returns a list of survey codes for file export.
static prepareTextareaOutput($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
isComplete()
Returns 1, if a survey is complete for use.
removeQuestions($remove_questions, $remove_questionblocks)
Remove questions from the survey.
static _hasDatasets($survey_id)
static _getStaticLink( $a_ref_id, $a_type='', $a_fallback_goto=true, $append="")
Get static link.
getAnonymousIdByCode($a_code)
isAccessibleWithoutCode()
Checks if the survey is accessable without a survey code.
read()
read object data from db into object public
static factory($a_package, $a_timeout=0)
Creates an ilRpcClient instance to our ilServer.
canStartSurvey($anonymous_id=null, $a_no_rbac=false)
Checks if the survey can be started.
setReminderFrequency($a_value)
removeQuestion($question_id)
Remove a question from the survey.
static getItem($a_ref_id)
Get item data.
static _getObjectsByOperations($a_obj_type, $a_operation, $a_usr_id=0, $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.
deleteConstraint($constraint_id)
Deletes a constraint of a question.
getOfflineStatus()
Get offline status.
setAuthor($author="")
Sets the authors name of the ilObjSurvey object.
const NOTIFICATION_APPRAISEES
sendAppraiseeCloseNotification($a_user_id)
Send appraisee notification.
const TIMINGS_DEACTIVATED
static _isComplete($question_id)
Checks whether the question is complete or not.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
static _getQuestionType($question_id)
Returns the question type of a question with a given id.
getUserDataFromActiveId($active_id, $force_non_anonymous=false)
Returns the user information from an active_id (survey_finished.finished_id)
sendAppraiseeNotification($a_user_id)
Send appraisee notification.
prepareTextareaOutput($txt_output)
Prepares a string for a text area output in surveys.
setSkillService($a_val)
Set skill service.
& getVariables($question_id)
Returns all variables of a question.
locateImportFiles($a_dir)
Locates the import directory and the xml file in a directory with an unzipped import file...
getIntroduction()
Gets the introduction text.
unfoldQuestionblocks($questionblocks)
Unfolds question blocks of a question pool.
static _lookupTitle($a_id)
lookup object title
create($a_upload=false)
create survey object
getAnonymize()
get anonymize status
setViewOwnResults($a_value)
sendNotificationMail($a_user_id, $a_anonymize_id, $a_appr_id)
getUserAccessCode($user_id)
Returns a survey access code that was saved for a registered user.
static _getConstraints($survey_id)
Returns the constraints to a given question or questionblock.
closeAppraisee($a_user_id)
bindSurveyCodeToUser($user_id, $code)
setTutorNotificationStatus($a_value)
Survey Question Import Parser.
setObligatoryStates($obligatory_questions)
Sets the obligatory states for questions in a survey from the questions form.
static _getQuestionTypeTranslations()
getLastAccess($finished_id)
$metadata['__DYNAMIC:1__']
static _getQuestionGUI($questiontype, $question_id=-1)
Creates a question gui representation.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
canExportSurveyCode()
Checks if the survey code can be exported with the survey evaluation.
getAllRelations($short_as_key=false)
Returns all available relations.
& getQuestionblockQuestions($questionblock_id)
Returns the question titles of all questions of a question block.
addRater($a_appraisee_id, $a_user_id, $a_anonymous_id=0)
setMailAddresses($a_addresses)
removeQuestionFromBlock($question_id, $questionblock_id)
getSurveyCodesTableData(array $ids=null, $lang=null)
Fetches the data for the survey codes table.
isSurveyCodeUnique($code)
Skill/Competence handling in surveys.
removeConstraintsConcerningQuestion($question_id)
Remove constraints concerning a question with a given question_id.
insertQuestion($question_id)
Inserts a question in the survey and saves the relation to the database.
getUserSpecificResults($finished_ids)
Calculates the evaluation data for the user specific results.
getInvitationMode()
Gets the invitation mode.
removeSelectedSurveyResults($finished_ids)
Deletes the user data of a given array of survey participants.
getEndDate()
Gets the end date of the survey.
getTutorNotificationRecipients()
insertQuestionblock($questionblock_id)
Inserts a questionblock in the survey and saves the relation to the database.
setStartTime($finished_id, $first_question)
setReminderEnd(ilDate $a_value=null)
getAuthor()
Gets the authors name of the ilObjSurvey object.
isHTML($a_text)
Checks if a given string contains HTML or not.
hideQuestionTitles()
Sets the question titles hidden during the query.
saveQuestionsToDb()
Saves the survey questions to the database.
duplicateQuestionForSurvey($question_id, $a_force=false)
Takes a question and creates a copy of the question for use in the survey.
deleteSurveyRecord()
Deletes the survey from the database.
updateConstraint($precondition_id, $if_question_id, $relation, $value, $conjunction)
Updates a precondition.
isPluginActive($a_pname)
Checks whether or not a question plugin with a given name is active.
catch(Exception $e) $message
setAnonymousUserList($a_value)
disinviteUser($user_id)
Disinvites a user from a survey.
update($a_upload=false)
update object data
static _getInstance($a_copy_id)
Get instance of copy wizard options.
hasAnonymizedResults()
Checks if the survey results are to be anonymized.
static _getOriginalId($question_id, $a_return_question_id_if_no_original=true)
Returns the original id of a question.
setInvitationMode($invitation_mode=0)
Sets the invitation mode.
inviteUser($user_id)
Invites a user to a survey.
getNextPage($active_page_question_id, $direction)
Returns the next "page" of a running test.
setReminderTemplate($a_value)
foreach($_POST as $key=> $value) $res
setReminderTarget($a_value)
getLastActivePage($active_id)
Returns the question id of the last active page a user visited in a survey.
& getSurveyQuestions($with_answers=false)
Returns the survey questions and questionblocks in an array.
getId()
get object id public
static _instanciateQuestionEvaluation($question_id, array $a_finished_ids=null)
Creates an instance of a question evaluation with a given question id.
const ANONYMIZE_FREEACCESS
set360SelfEvaluation($a_value)
isUnusedCode($a_code, $a_user_id)
setShowQuestionTitles($a_show)
Sets the status of the display_question_titles attribute.
loadFromDb()
Loads a survey object from a database.
setActivationLimited($a_value)
setInvitation($invitation=0)
Sets the invitation status.
const NOTIFICATION_PARENT_COURSE
setMailParticipantData($a_data)
const RESULTS_SELF_EVAL_OWN
const NOTIFICATION_APPRAISEES_AND_RATERS
getFinishedIdsForAppraiseeId($a_appr_id, $a_exclude_appraisee=false)
updateCode($a_id, $a_email, $a_last_name, $a_first_name, $a_sent)
updateOrder(array $a_order)
setActivationStartDate($starting_time=null)
getEvaluationAccess()
Gets the learners evaluation access.
static _lookupObjId($a_id)
setActivationVisibility($a_value)
addQuestion($question_id)
Adds a question to the survey (used in importer!)
const QUESTIONTITLES_VISIBLE
getActivationVisibility()
getImportDirectory()
get import directory of survey
getQuestionblocksTable($arrFilter)
Calculates the data for the output of the questionblock browser.
const QUESTIONTITLES_HIDDEN
getQuestionType($question_id)
Returns the question type of a question with a given id.
setMailOwnResults($a_value)
setReminderStart(ilDate $a_value=null)
setTutorNotificationRecipients(array $a_value)
setIntroduction($introduction="")
Sets the introduction text.
getTitle()
get object title public
static _dropDesktopItem($a_usr_id, $a_item_id, $a_type)
drop an item from user's personal desktop
getDescription()
get object description
getSelfEvaluationResults()
set360SelfRaters($a_value)
getShowQuestionTitles()
Gets the status of the display_question_titles attribute.
cloneMetaData($target_obj)
Copy meta data.
toXML()
Returns a QTI xml representation of the survey.
xmlHeader()
Writes xml header public.
setSelfEvaluationResults($a_value)
static _addQuestionblock($title="", $owner=0, $show_questiontext=true, $show_blocktitle=false)
Adds a questionblock to the database.
& getInvitedUsers()
Returns a list of all invited users in a survey.
addConstraintToQuestion($to_question_id, $constraint_id)
Adds a constraint to a question.
importSurveyCode($a_anonymize_key, $a_created, $a_data)
const MODE_PREDEFINED_USERS
setSurveyId($survey_id)
Sets the survey id.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
isQuestionInAnyBlock($a_question_fi)
Is question already in a block?
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
createQuestionblock($title, $show_questiontext, $show_blocktitle, $questions)
Creates a question block for the survey.
const NOTIFICATION_INVITED_USERS
getInvitation()
Gets the invitation status.
getExportDirectory()
get export directory of survey
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _getQuestionblock($questionblock_id)
Returns the database row for a given question block.
setMailConfirmation($a_value)
setReminderStatus($a_value)
setPage($finished_id, $page_id)
Sets the number of the active survey page.
getType()
get object type public
getNotificationTargetUserIds($a_use_invited)
setEvaluationAccess($evaluation_access=self::EVALUATION_ACCESS_OFF)
Sets the learners evaluation access.
static _lookupType($a_id, $a_reference=false)
lookup object type
createImportDirectory()
creates data directory for import files (data_dir/svy_data/svy_<id>/import, depending on data directo...
createExportDirectory()
creates data directory for export files (data_dir/svy_data/svy_<id>/export, depending on data directo...
setTimingType($a_type)
Set timing type.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
setEndDate($end_date="")
Sets the end date of the survey.
static _getLanguageOfUser($a_usr_id)
Get language object of user.
send360ReminderToUser($a_user_id, $a_appraisee_ids)
Send rater notification.
& getUserData($ids)
Returns a data of all users specified by id list.
finishSurvey($finished_id)
Finishes the survey creating an entry in the database.
const EVALUATION_ACCESS_ALL
update($pash, $contents, Config $config)
getFinishedIdForAppraiseeIdAndRaterId($a_appr_id, $a_rat_id)
Get finished id for an appraisee and a rater.
deleteWorkingData($question_id, $active_id)
Deletes the working data of a question in the database.
saveCompletionStatus()
Saves the completion status of the survey.
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
getExternalCodeRecipients($a_check_finished=false)
getStartDate()
Gets the start date of the survey.
checkConstraint($constraint_data, $working_data)
Checks if a constraint is valid.
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
& getAvailableQuestionpools($use_obj_id=false, $could_be_offline=false, $showPath=false, $permission="read")
Returns the available question pools for the active user.
createSurveyCodesForExternalData($data)
saveUserAccessCode($user_id, $access_code)
Saves a survey access code for a registered user to the database.
cloneTextblocks($mapping)
Clones the textblocks of survey questions.
saveToDb()
Saves a survey object to a database.
static getDataDir()
get data directory (outside webspace)
createMetaData()
Create meta data entry.
& getExistingQuestions()
Gets the question id's of the questions which are already in the survey.
getQuestionsTable($arrFilter)
Calculates the data for the output of the question browser.
saveHeading($heading="", $insertbefore)
setOfflineStatus($a_status)
Set offline status.
getRatersData($a_appraisee_id)
static _lookupEmail($a_user_id)
Lookup email.
isRater($a_appraisee_id, $a_user_id, $a_anonymous_id=0)
isSurveyFinishedByCode($a_code)
Get if survey is finished for an specific anonymous user code.
setStartDateAndTime($start_date="", $start_time)
Sets the start date of the survey.
addConstraint($if_question_id, $relation, $value, $conjunction)
Adds a constraint.
isQuestionInSurvey($a_question_fi)
Check if a question is already in the survey.
getSkillService()
Get skill service.
saveAuthorToMetadata($a_author="")
Saves an authors name into the lifecycle metadata if no lifecycle metadata exists This will only be c...
const RESULTS_SELF_EVAL_NONE
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
getRefId()
get reference id public
getAnonymousId($id)
Checks for an anomyous survey id in the database an returns the id.
countReferences()
count references of object
deleteMetaData()
delete meta data entry
getTextblock($question_id)
findCodeForUser($a_user_id)
getActiveID($user_id, $anonymize_id, $appr_id)
Checks if a user already started a survey.
setTemplate($template_id)
static getLogger($a_component_id)
Get component logger.
getOutro()
Gets the outro text.
getUserSettings($usr_id, $key)
update()
update object in db
getTutorNotificationStatus()
set360SelfAppraisee($a_value)
const NOTIFICATION_RATERS
sendCodes($not_sent, $subject, $message, $lang)
modifyQuestionblock($questionblock_id, $title, $show_questiontext, $show_blocktitle)
Modifies a question block.
Class ilInvalidSurveyImportFileException.
moveQuestions($move_questions, $target_index, $insert_mode)
Move questions and/or questionblocks to another position.
isPoolActive()
Get current pool status.
addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag=true, $add_mobs=true, $attribs=null)
Creates an XML material tag from a plain text or xhtml text.
loadWorkingData($question_id, $active_id)
Gets the working data of question from the database.
setStartDate($start_date="")
Sets the start date of the survey.
static getInstance($a_obj_id)
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static _getAvailableQuestionpools($use_object_id=false, $could_be_offline=false, $showPath=false, $permission="read")
Returns the available question pools for the active user.
deleteConstraints($question_id)
Deletes the constraints for a question.
importObject($file_info, $svy_qpl_id)
Imports a survey from XML into the ILIAS database.
Class ilObjectActivation.
static _getUserData($a_internalids)
return user data for given user ids
Wrapper classes for system notifications.
isAppraiseeClosed($a_user_id)
const RESULTS_SELF_EVAL_ALL
startSurvey($user_id, $anonymous_id, $appraisee_id)
Starts the survey creating an entry in the database.
setAnonymize($a_anonymize)
set anonymize status
setActivationEndDate($ending_time=null)
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
Settings template application class.
& getQuestionblockQuestionIds($questionblock_id)
Returns the question id's of all questions of a question block.
sendRaterNotification($a_user_id, $a_appraisee_id)
Send rater notification.
isSurveyStarted($user_id, $anonymize_id, $appr_id=0)
Checks if a user already started a survey.
loadQuestionsFromDb()
Loads the survey questions from the database.
sent360Reminders()
Send 360 reminders.
deleteAppraisee($a_user_id)
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
setOutro($outro="")
Sets the outro text.
fixSequenceStructure()
Remove duplicate sequence entries, see #22018.
getPrecondition($id)
Returns a precondition with a given id.
addQuestionToBlock($question_id, $questionblock_id)