4 include_once
"./Services/Object/classes/class.ilObject.php";
187 $this->survey_id = -1;
188 $this->introduction =
"";
189 $this->outro = $lng->txt(
"survey_finished");
190 $this->author = $ilUser->getFullname();
191 $this->status = self::STATUS_OFFLINE;
192 $this->evaluation_access = self::EVALUATION_ACCESS_OFF;
193 $this->questions = array();
195 $this->invitation_mode = self::MODE_PREDEFINED_USERS;
196 $this->anonymize = self::ANONYMIZE_OFF;
197 $this->display_question_titles = self::QUESTIONTITLES_VISIBLE;
198 $this->surveyCodeSecurity = TRUE;
199 $this->template_id = NULL;
200 $this->pool_usage =
true;
202 parent::__construct($a_id,$a_call_by_reference);
224 parent::createMetaData();
238 if (!parent::update())
250 $result = parent::createReference();
260 function read($a_force_db =
false)
262 parent::read($a_force_db);
274 array_push($this->questions, $question_id);
291 foreach ($this->questions as $question_id)
300 $remove = parent::delete();
319 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_svy WHERE survey_id = %s",
324 $result = $ilDB->queryF(
"SELECT questionblock_fi FROM svy_qblk_qst WHERE survey_fi = %s",
328 $questionblocks = array();
331 array_push($questionblocks,
$row[
"questionblock_fi"]);
333 if (count($questionblocks))
335 $affectedRows = $ilDB->manipulate(
"DELETE FROM svy_qblk WHERE " . $ilDB->in(
'questionblock_id', $questionblocks,
false,
'integer'));
337 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE survey_fi = %s",
343 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_anonymous WHERE survey_fi = %s",
349 include_once
"./Services/Utilities/classes/class.ilUtil.php";
351 $directory = $svy_data_dir.
"/svy_".$this->
getId();
352 if (is_dir($directory))
354 include_once
"./Services/Utilities/classes/class.ilUtil.php";
358 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
364 foreach(
$mobs as $mob)
381 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
385 $active_array = array();
388 array_push($active_array,
$row[
"finished_id"]);
391 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_finished WHERE survey_fi = %s",
396 foreach ($active_array as $active_fi)
398 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_answer WHERE active_fi = %s",
402 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_times WHERE finished_fi = %s",
408 include_once
"Services/Object/classes/class.ilObjectLP.php";
410 $lp_obj->resetLPDataForCompleteObject();
422 $user_ids[] = array();
424 foreach ($finished_ids as $finished_id)
426 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE finished_id = %s",
434 $user_ids[] =
$row[
"user_fi"];
437 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_answer WHERE active_fi = %s",
439 array(
$row[
"finished_id"])
442 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_finished WHERE finished_id = %s",
447 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_times WHERE finished_fi = %s",
449 array(
$row[
"finished_id"])
453 if(
sizeof($user_ids))
455 include_once
"Services/Object/classes/class.ilObjectLP.php";
457 $lp_obj->resetLPDataForUserIds($user_ids);
465 $sql =
"SELECT * FROM svy_finished".
466 " WHERE survey_fi = ".$ilDB->quote($this->
getSurveyId(),
"integer");
469 $sql .=
" AND ".$ilDB->in(
"finished_id", $finished_ids,
"",
"integer");
473 $participants = array();
479 $userdata[
"finished"] = (bool)
$row[
"state"];
480 $userdata[
"finished_tstamp"] =
$row[
"tstamp"];
481 $participants[$userdata[
"sortname"] . $userdata[
"active_id"]] = $userdata;
484 return $participants;
500 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
540 if ($a_node_id==
$_GET[
"ref_id"])
542 $parent_obj =& $this->
ilias->obj_factory->getInstanceByRefId($a_node_id);
543 $parent_type = $parent_obj->getType();
544 if($parent_type == $this->
getType())
546 $a_node_id = (int) $tree->getParentId($a_node_id);
550 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
561 if (($this->
getTitle()) and (count($this->questions)))
580 $survey->loadFromDb();
581 if (($survey->getTitle()) and (count($survey->questions)))
600 $survey->loadFromDb();
602 if (($survey->getTitle()) and ($survey->author) and (count($survey->questions)))
610 $result[
"evaluation_access"] = $survey->getEvaluationAccess();
630 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_svy SET complete = %s, tstamp = %s WHERE survey_id = %s",
631 array(
'text',
'integer',
'integer'),
649 $question_gui = $this->
getQuestionGUI($questiontype, $question_id);
652 if($this->
getId() == $question_gui->object->getObjId() && !$a_force)
657 $duplicate_id = $question_gui->object->duplicate(
true);
658 return $duplicate_id;
670 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
678 $result = $ilDB->queryF(
"SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
682 $sequence =
$result->numRows();
684 $next_id = $ilDB->nextId(
'svy_svy_qst');
685 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_svy_qst (survey_question_id, survey_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
686 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
687 array($next_id, $this->
getSurveyId(), $duplicate_id, $sequence, time())
703 $result = $ilDB->queryF(
"SELECT svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.show_blocktitle,".
704 " svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst, svy_svy_qst".
705 " WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi".
706 " AND svy_svy_qst.question_fi = svy_qblk_qst.question_fi".
707 " AND svy_qblk.questionblock_id = %s".
708 " ORDER BY svy_svy_qst.sequence",
710 array($questionblock_id)
712 $questions = array();
713 $show_questiontext = 0;
714 $show_blocktitle = 0;
718 array_push($questions, $duplicate_id);
720 $show_questiontext =
$row[
"show_questiontext"];
721 $show_blocktitle =
$row[
"show_blocktitle"];
746 include_once(
"./Services/RTE/classes/class.ilRTE.php");
747 $completecontent =
"";
750 $completecontent .= $content;
760 $next_id = $ilDB->nextId(
'svy_settings');
761 $affectedRows = $ilDB->insert(
"svy_settings", array(
762 "settings_id" => array(
"integer", $next_id),
763 "usr_id" => array(
"integer", $usr_id),
764 "keyword" => array(
"text", $key),
765 "title" => array(
"text",
$title),
766 "value" => array(
"clob", $value)
774 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_settings WHERE settings_id = %s",
778 return $affectedRows;
785 $result = $ilDB->queryF(
"SELECT * FROM svy_settings WHERE usr_id = %s AND keyword = %s",
786 array(
'integer',
'text'),
811 if(is_object($rmd_start))
816 if(is_object($rmd_end))
821 include_once(
"./Services/RTE/classes/class.ilRTE.php");
824 $next_id = $ilDB->nextId(
'svy_svy');
825 $affectedRows = $ilDB->insert(
"svy_svy", array(
826 "survey_id" => array(
"integer", $next_id),
827 "obj_fi" => array(
"integer", $this->
getId()),
828 "author" => array(
"text", $this->
getAuthor()),
831 "status" => array(
"text", $this->
getStatus()),
833 "enddate" => array(
"text", $this->
getEndDate()),
837 "complete" => array(
"text", $this->
isComplete()),
838 "created" => array(
"integer", time()),
844 "tstamp" => array(
"integer", time()),
845 "template_id" => array(
"integer", $this->
getTemplate()),
846 "pool_usage" => array(
"integer", $this->
getPoolUsage()),
848 "mode_360" => array(
"integer", $this->
get360Mode()),
852 "mode_360_results" => array(
"integer", $this->
get360Results()),
856 "reminder_start" => array(
"datetime", $rmd_start),
857 "reminder_end" => array(
"datetime", $rmd_end),
871 $affectedRows = $ilDB->update(
"svy_svy", array(
872 "author" => array(
"text", $this->
getAuthor()),
875 "status" => array(
"text", $this->
getStatus()),
877 "enddate" => array(
"text", $this->
getEndDate()),
881 "complete" => array(
"text", $this->
isComplete()),
887 "tstamp" => array(
"integer", time()),
888 "template_id" => array(
"integer", $this->
getTemplate()),
889 "pool_usage" => array(
"integer", $this->
getPoolUsage()),
891 "mode_360" => array(
"integer", $this->
get360Mode()),
895 "mode_360_results" => array(
"integer", $this->
get360Results()),
899 "reminder_start" => array(
"datetime", $rmd_start),
900 "reminder_end" => array(
"datetime", $rmd_end),
910 "survey_id" => array(
"integer", $this->
getSurveyId())
922 include_once
"./Services/Object/classes/class.ilObjectActivation.php";
938 $item->update($this->ref_id);
952 $old_questions = array();
953 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
961 $old_questions[
$row[
"question_fi"]] =
$row;
966 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_svy_qst WHERE survey_fi = %s",
971 foreach ($this->questions as $key => $value)
973 $next_id = $ilDB->nextId(
'svy_svy_qst');
974 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_svy_qst (survey_question_id, survey_fi, question_fi, heading, sequence, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
975 array(
'integer',
'integer',
'integer',
'text',
'integer',
'integer'),
976 array($next_id, $this->
getSurveyId(), $value, (strlen($old_questions[$value][
"heading"])) ? $old_questions[$value][
"heading"] : NULL, $key, time())
991 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_finished WHERE anonymous_id = %s",
998 return $row[
"anonymous_id"];
1014 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
1028 if ($question_id < 1)
return -1;
1029 $result = $ilDB->queryF(
"SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND " .
1030 "svy_question.questiontype_fi = svy_qtype.questiontype_id",
1037 return $data[
"type_tag"];
1061 switch ($a_anonymize)
1063 case self::ANONYMIZE_OFF:
1064 case self::ANONYMIZE_ON:
1065 case self::ANONYMIZE_FREEACCESS:
1066 case self::ANONYMIZE_CODE_ALL:
1067 $this->anonymize = $a_anonymize;
1070 $this->anonymize = self::ANONYMIZE_OFF;
1082 return ($this->anonymize) ? $this->anonymize : 0;
1092 return ($this->
getAnonymize() == self::ANONYMIZE_OFF ||
1115 $result = $ilDB->queryF(
"SELECT * FROM svy_svy WHERE obj_fi = %s",
1117 array($this->
getId())
1124 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1126 if (strcmp(
$data[
"outro"],
"survey_finished") == 0)
1128 $this->
setOutro($this->lng->txt(
"survey_finished"));
1173 include_once
"./Services/Object/classes/class.ilObjectActivation.php";
1175 switch($activation[
"timing_type"])
1200 $this->questions = array();
1201 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
1207 $this->questions[
$data[
"sequence"]] = $data[
"question_fi"];
1235 $md_life =& $md->getLifecycle();
1238 if (strlen($a_author) == 0)
1241 $a_author = $ilUser->getFullname();
1244 $md_life =& $md->addLifecycle();
1246 $con =& $md_life->addContribute();
1247 $con->setRole(
"Author");
1249 $ent =& $con->addEntity();
1250 $ent->setEntity($a_author);
1265 include_once
"./Services/MetaData/classes/class.ilMD.php";
1267 $md_life =& $md->getLifecycle();
1270 $ids =& $md_life->getContributeIds();
1271 foreach ($ids as
$id)
1273 $md_cont =& $md_life->getContribute($id);
1274 if (strcmp($md_cont->getRole(),
"Author") == 0)
1276 $entids =& $md_cont->getEntityIds();
1277 foreach ($entids as $entid)
1279 $md_ent =& $md_cont->getEntity($entid);
1280 array_push($author, $md_ent->getEntity());
1285 return join($author,
",");
1296 return ($this->display_question_titles) ? 1 : 0;
1307 $this->display_question_titles = ($a_show) ? 1 : 0;
1318 $this->display_question_titles = 1;
1329 $this->display_question_titles = 0;
1341 global
$ilDB, $ilAccess;
1352 $result = $ilDB->query(
"SELECT usr_id FROM usr_data");
1355 if ($ilAccess->checkAccessOfUser(
$row[
"usr_id"],
"read",
"", $this->getRefId(),
"svy", $this->
getId()))
1433 include_once
"./Services/Administration/classes/class.ilSetting.php";
1434 $surveySetting =
new ilSetting(
"survey");
1435 $unlimited_invitation = $surveySetting->get(
"unlimited_invitation");
1436 if (!$unlimited_invitation && $this->invitation_mode == self::MODE_UNLIMITED)
1438 return self::MODE_PREDEFINED_USERS;
1442 return ($this->invitation_mode) ? $this->invitation_mode : self::MODE_UNLIMITED;
1455 return ($this->status) ? $this->status : self::STATUS_OFFLINE;
1467 return ($this->status == self::STATUS_ONLINE) ? true :
false;
1479 return ($this->status == self::STATUS_OFFLINE) ? true :
false;
1493 if (($status == self::STATUS_ONLINE) && (count($this->questions) == 0))
1495 $this->status = self::STATUS_OFFLINE;
1496 $result = $this->lng->txt(
"cannot_switch_to_online_no_questions");
1514 return (strlen($this->start_date)) ? $this->start_date : NULL;
1529 $edit_settings =
false;
1531 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartDate(), $matches))
1533 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
1535 if ($now < $epoch_time)
1537 array_push(
$messages,$this->lng->txt(
'start_date_not_reached').
' ('.
1540 $edit_settings =
true;
1544 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndDate(), $matches))
1546 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
1548 if ($now > $epoch_time)
1550 array_push(
$messages,$this->lng->txt(
'end_date_reached').
' ('.
1553 $edit_settings =
true;
1558 if ($this->
getStatus() == self::STATUS_OFFLINE)
1560 array_push(
$messages, $this->lng->txt(
"survey_is_offline"));
1562 $edit_settings =
true;
1565 if (!$a_no_rbac && !$ilAccess->checkAccess(
"read",
"", $this->ref_id))
1567 array_push(
$messages, $this->lng->txt(
"cannot_participate_survey"));
1586 "edit_settings" => $edit_settings
1612 $y =
''; $m =
'';
$d =
'';
$h =
''; $i =
''; $s =
'';
1613 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/", $start_date, $matches))
1619 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $start_time, $matches))
1625 $this->start_date = sprintf(
'%04d%02d%02d%02d%02d%02d',
$y, $m,
$d,
$h, $i, $s);
1637 return (strlen($this->end_date)) ? $this->end_date : NULL;
1662 $y =
''; $m =
'';
$d =
'';
$h =
''; $i =
''; $s =
'';
1663 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/", $end_date, $matches))
1669 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $end_time, $matches))
1675 $this->end_date = sprintf(
'%04d%02d%02d%02d%02d%02d',
$y, $m,
$d,
$h, $i, $s);
1687 return ($this->evaluation_access) ? $this->evaluation_access : self::EVALUATION_ACCESS_OFF;
1699 $this->evaluation_access = (
$evaluation_access) ? $evaluation_access : self::EVALUATION_ACCESS_OFF;
1704 $this->activation_visibility = (bool) $a_value;
1714 return (
bool)$this->activation_limited;
1719 $this->activation_limited = (bool)$a_value;
1731 return (strlen($this->introduction)) ? $this->introduction : NULL;
1743 return (strlen($this->outro)) ? $this->outro : NULL;
1755 $existing_questions = array();
1756 $result = $ilDB->queryF(
"SELECT svy_question.original_id FROM svy_question, svy_svy_qst WHERE " .
1757 "svy_svy_qst.survey_fi = %s AND svy_svy_qst.question_fi = svy_question.question_id",
1763 if(
$data[
"original_id"])
1765 array_push($existing_questions,
$data[
"original_id"]);
1768 return $existing_questions;
1779 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1791 $move_questions = array($question_id);
1794 foreach ($pages as $idx => $page)
1796 if ($page[0][
"question_id"] == $question_id)
1803 $this->
moveQuestions($move_questions, $pages[$pageindex-1][0][
"question_id"], 0);
1809 $questions = array_keys($questions);
1810 $index = array_search($question_id, $questions);
1811 if (($index !== FALSE) && ($index > 0))
1813 $this->
moveQuestions($move_questions, $questions[$index-1], 0);
1825 $move_questions = array($question_id);
1828 foreach ($pages as $idx => $page)
1830 if (($page[0][
"question_id"] == $question_id) && (strcmp($page[0][
"questionblock_id"],
"") == 0))
1835 if (($pageindex < count($pages)-1) && ($pageindex >= 0))
1837 $this->
moveQuestions($move_questions, $pages[$pageindex+1][count($pages[$pageindex+1])-1][
"question_id"], 1);
1843 $questions = array_keys($questions);
1844 $index = array_search($question_id, $questions);
1845 if (($index !== FALSE) && ($index < count($questions)-1))
1847 $this->
moveQuestions($move_questions, $questions[$index+1], 1);
1861 $move_questions = array();
1863 foreach ($pages as $idx => $page)
1865 if ($page[0][
"questionblock_id"] == $questionblock_id)
1867 foreach ($page as $pageidx => $question)
1869 array_push($move_questions, $question[
"question_id"]);
1876 $this->
moveQuestions($move_questions, $pages[$pageindex-1][0][
"question_id"], 0);
1889 $move_questions = array();
1891 foreach ($pages as $idx => $page)
1893 if ($page[0][
"questionblock_id"] == $questionblock_id)
1895 foreach ($page as $pageidx => $question)
1897 array_push($move_questions, $question[
"question_id"]);
1902 if ($pageindex < count($pages)-1)
1904 $this->
moveQuestions($move_questions, $pages[$pageindex+1][count($pages[$pageindex+1])-1][
"question_id"], 1);
1918 $array_pos = array_search($target_index, $this->questions);
1919 if ($insert_mode == 0)
1921 $part1 = array_slice($this->questions, 0, $array_pos);
1922 $part2 = array_slice($this->questions, $array_pos);
1924 else if ($insert_mode == 1)
1926 $part1 = array_slice($this->questions, 0, $array_pos + 1);
1927 $part2 = array_slice($this->questions, $array_pos + 1);
1929 foreach ($move_questions as $question_id)
1931 if (!(array_search($question_id, $part1) === FALSE))
1933 unset($part1[array_search($question_id, $part1)]);
1935 if (!(array_search($question_id, $part2) === FALSE))
1937 unset($part2[array_search($question_id, $part2)]);
1940 $part1 = array_values($part1);
1941 $part2 = array_values($part2);
1942 $this->questions = array_values(array_merge($part1, $move_questions, $part2));
1943 foreach ($move_questions as $question_id)
1946 foreach ($constraints as $idx => $constraint)
1948 foreach ($part2 as $next_question_id)
1950 if ($constraint[
"question"] == $next_question_id)
1969 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1971 #20610 if no question found, do nothing. 1974 $question->delete($question_id);
1988 $result = $ilDB->queryF(
"SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
1989 array(
'integer',
'integer'),
1994 $remove_constraints = array();
1997 array_push($remove_constraints,
$row[
"constraint_fi"]);
1999 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
2000 array(
'integer',
'integer'),
2003 foreach ($remove_constraints as $key => $constraint_id)
2005 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_constraint WHERE constraint_id = %s",
2007 array($constraint_id)
2024 $block_sizes = array();
2027 if (in_array($question_id, $remove_questions) or in_array(
$data[
"questionblock_id"], $remove_questionblocks))
2029 unset($this->questions[array_search($question_id, $this->questions)]);
2032 else if(
$data[
"questionblock_id"])
2034 $block_sizes[
$data[
"questionblock_id"]]++;
2039 foreach($block_sizes as $block_id =>
$size)
2043 $remove_questionblocks[] = $block_id;
2047 foreach (array_unique($remove_questionblocks) as $questionblock_id)
2049 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk WHERE questionblock_id = %s",
2051 array($questionblock_id)
2053 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
2054 array(
'integer',
'integer'),
2059 $this->questions = array_values($this->questions);
2072 foreach ($questionblocks as $index)
2074 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk WHERE questionblock_id = %s",
2078 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
2079 array(
'integer',
'integer'),
2089 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s AND question_fi = %s",
2090 array(
'integer',
'integer',
'integer'),
2091 array($questionblock_id, $this->
getSurveyId(), $question_id)
2100 $next_id = $ilDB->nextId(
'svy_qblk_qst');
2101 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
2102 "question_fi) VALUES (%s, %s, %s, %s)",
2103 array(
'integer',
'integer',
'integer',
'integer'),
2104 array($next_id, $this->
getSurveyId(), $questionblock_id, $question_id)
2120 $result = $ilDB->queryF(
"SELECT svy_question.title, svy_qblk_qst.question_fi, svy_qblk_qst.survey_fi FROM ".
2121 "svy_qblk, svy_qblk_qst, svy_question WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND " .
2122 "svy_question.question_id = svy_qblk_qst.question_fi AND svy_qblk.questionblock_id = %s",
2124 array($questionblock_id)
2129 $titles[
$row[
"question_fi"]] = $row[
"title"];
2130 $survey_id = $row[
"survey_fi"];
2132 $result = $ilDB->queryF(
"SELECT question_fi, sequence FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
2136 $resultarray = array();
2140 if (array_key_exists(
$row[
"question_fi"], $titles))
2142 $resultarray[$counter++] = $titles[
$row[
"question_fi"]];
2145 return $resultarray;
2159 $result = $ilDB->queryF(
"SELECT a.question_fi FROM svy_qblk_qst a JOIN svy_svy_qst b ON (a.question_fi = b.question_fi) ".
2160 " WHERE a.questionblock_fi = %s ORDER BY b.sequence",
2162 array($questionblock_id)
2169 if (!in_array(
$data[
'question_fi'], $ids))
2171 array_push($ids,
$data[
'question_fi']);
2189 $result = $ilDB->queryF(
"SELECT * FROM svy_qblk WHERE questionblock_id = %s",
2191 array($questionblock_id)
2193 return $ilDB->fetchAssoc(
$result);
2206 $result = $ilDB->queryF(
"SELECT * FROM svy_qblk WHERE questionblock_id = %s",
2208 array($questionblock_id)
2225 $next_id = $ilDB->nextId(
'svy_qblk');
2226 $ilDB->manipulateF(
"INSERT INTO svy_qblk (questionblock_id, title, show_questiontext,".
2227 " show_blocktitle, owner_fi, tstamp) " .
2228 "VALUES (%s, %s, %s, %s, %s, %s)",
2229 array(
'integer',
'text',
'integer',
'integer',
'integer',
'integer'),
2230 array($next_id,
$title, $show_questiontext, $show_blocktitle,
$owner, time())
2252 $next_id = $ilDB->nextId(
'svy_qblk');
2253 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk (questionblock_id, title, show_questiontext,".
2254 " show_blocktitle, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
2255 array(
'integer',
'text',
'text',
'text',
'integer',
'integer'),
2256 array($next_id,
$title, $show_questiontext, $show_blocktitle, $ilUser->getId(), time())
2260 $questionblock_id = $next_id;
2261 foreach ($questions as $index)
2263 $next_id = $ilDB->nextId(
'svy_qblk_qst');
2264 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
2265 "question_fi) VALUES (%s, %s, %s, %s)",
2266 array(
'integer',
'integer',
'integer',
'integer'),
2267 array($next_id, $this->
getSurveyId(), $questionblock_id, $index)
2284 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_qblk SET title = %s, show_questiontext = %s,".
2285 " show_blocktitle = %s WHERE questionblock_id = %s",
2286 array(
'text',
'text',
'text',
'integer'),
2287 array(
$title, $show_questiontext, $show_blocktitle, $questionblock_id)
2300 $result = $ilDB->queryF(
"SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
2301 array(
'integer',
'integer'),
2304 $constraints = array();
2307 array_push($constraints,
$row[
"constraint_fi"]);
2309 foreach ($constraints as $constraint_id)
2325 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_constraint WHERE constraint_id = %s",
2327 array($constraint_id)
2329 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_constraint WHERE constraint_fi = %s",
2331 array($constraint_id)
2345 $all_questions = array();
2346 $result = $ilDB->queryF(
"SELECT svy_qtype.type_tag, svy_qtype.plugin, svy_question.question_id, ".
2347 "svy_svy_qst.heading FROM svy_qtype, svy_question, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
2348 "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
2349 "ORDER BY svy_svy_qst.sequence",
2353 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
2367 $questionrow = $question->_getQuestionDataArray(
$row[
"question_id"]);
2368 foreach (
$row as $key => $value)
2370 $questionrow[$key] = $value;
2372 $all_questions[
$row[
"question_id"]] = $questionrow;
2373 $all_questions[$row[
"question_id"]][
"usableForPrecondition"] = $question->usableForPrecondition();
2374 $all_questions[$row[
"question_id"]][
"availableRelations"] = $question->getAvailableRelations();
2375 if (array_key_exists($row[
"question_id"], $obligatory_states))
2377 $all_questions[$row[
"question_id"]][
"obligatory"] = $obligatory_states[$row[
"question_id"]];
2382 $questionblocks = array();
2383 if (count($all_questions))
2385 $result = $ilDB->queryF(
"SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst WHERE " .
2386 "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
2387 "AND " . $ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions),
false,
'integer'),
2393 $questionblocks[
$row[
'question_fi']] =
$row;
2397 foreach ($all_questions as $question_id =>
$row)
2400 if (isset($questionblocks[$question_id]))
2402 $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
2403 $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
2404 $all_questions[$question_id][
"constraints"] = $constraints;
2408 $all_questions[$question_id][
"questionblock_title"] =
"";
2409 $all_questions[$question_id][
"questionblock_id"] =
"";
2410 $all_questions[$question_id][
"constraints"] = $constraints;
2415 $result = $ilDB->queryF(
"SELECT svy_variable.*, svy_category.title FROM svy_variable, svy_category " .
2416 "WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id ".
2417 "ORDER BY sequence ASC",
2425 array_push($answers,
$data[
"title"]);
2428 $all_questions[$question_id][
"answers"] = $answers;
2431 return $all_questions;
2443 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
2451 if (!array_key_exists(
$row[
"question_fi"], $obligatory_questions))
2453 $obligatory_questions[
$row[
"question_fi"]] = 0;
2459 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_oblig WHERE survey_fi = %s",
2465 foreach ($obligatory_questions as $question_fi => $obligatory)
2467 $next_id = $ilDB->nextId(
'svy_qst_oblig');
2468 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, " .
2469 "obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)",
2470 array(
'integer',
'integer',
'integer',
'text',
'integer'),
2471 array($next_id, $this->
getSurveyId(), $question_fi, (strlen($obligatory)) ? $obligatory : 0, time())
2475 $ilDB->manipulate(
"UPDATE svy_question".
2476 " SET obligatory = ".$ilDB->quote($obligatory,
"integer").
2477 " WHERE question_id = ".$ilDB->quote($question_fi,
"integer"));
2490 $obligatory_states = array();
2491 $result = $ilDB->queryF(
"SELECT * FROM svy_qst_oblig WHERE survey_fi = %s",
2499 $obligatory_states[
$row[
"question_fi"]] = $row[
"obligatory"];
2502 return $obligatory_states;
2515 $all_questions = array();
2516 $result = $ilDB->queryF(
"SELECT svy_question.*, svy_qtype.type_tag, svy_svy_qst.heading FROM " .
2517 "svy_question, svy_qtype, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
2518 "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id ".
2519 "ORDER BY svy_svy_qst.sequence",
2525 $all_questions[
$row[
"question_id"]] =
$row;
2528 $questionblocks = array();
2529 if (count($all_questions))
2531 $result = $ilDB->queryF(
"SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst ".
2532 "WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s ".
2533 "AND " . $ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions),
false,
'integer'),
2539 $questionblocks[
$row[
'question_fi']] =
$row;
2543 $all_pages = array();
2546 foreach ($all_questions as $question_id =>
$row)
2548 if (array_key_exists($question_id, $obligatory_states))
2550 $all_questions[$question_id][
"obligatory"] = $obligatory_states[$question_id];
2552 $constraints = array();
2553 if (isset($questionblocks[$question_id]))
2555 if (!$currentblock or ($currentblock != $questionblocks[$question_id][
'questionblock_id']))
2559 $all_questions[$question_id][
'page'] = $pageindex;
2560 $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
2561 $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
2562 $all_questions[$question_id][
"questionblock_show_questiontext"] = $questionblocks[$question_id][
'show_questiontext'];
2563 $all_questions[$question_id][
"questionblock_show_blocktitle"] = $questionblocks[$question_id][
'show_blocktitle'];
2564 $currentblock = $questionblocks[$question_id][
'questionblock_id'];
2566 $all_questions[$question_id][
"constraints"] = $constraints;
2571 $all_questions[$question_id][
'page'] = $pageindex;
2572 $all_questions[$question_id][
"questionblock_title"] =
"";
2573 $all_questions[$question_id][
"questionblock_id"] =
"";
2574 $all_questions[$question_id][
"questionblock_show_questiontext"] = 1;
2575 $all_questions[$question_id][
"questionblock_show_blocktitle"] = 1;
2578 $all_questions[$question_id][
"constraints"] = $constraints;
2580 if (!isset($all_pages[$pageindex]))
2582 $all_pages[$pageindex] = array();
2584 array_push($all_pages[$pageindex], $all_questions[$question_id]);
2587 $max = count($all_pages);
2589 foreach ($all_pages as $index => $block)
2591 foreach ($block as $blockindex => $question)
2593 $all_pages[$index][$blockindex][
"position"] = $counter / $max;
2612 if (strcmp($active_page_question_id,
"") == 0)
2616 foreach ($pages as $key => $question_array)
2618 foreach ($question_array as $question)
2620 if ($active_page_question_id == $question[
"question_id"])
2626 if ($foundpage == -1)
2632 $foundpage += $direction;
2637 if ($foundpage >= count($pages))
2641 return $pages[$foundpage];
2653 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
2666 $result_array = array();
2667 $result = $ilDB->queryF(
"SELECT svy_constraint.*, svy_relation.*, svy_qst_constraint.question_fi ref_question_fi FROM svy_qst_constraint, svy_constraint, ".
2668 "svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id AND ".
2669 "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_constraint.constraint_id = %s",
2676 $pc = $ilDB->fetchAssoc(
$result);
2690 $result_array = array();
2691 $result = $ilDB->queryF(
"SELECT svy_constraint.*, svy_relation.* FROM svy_qst_constraint, svy_constraint, svy_relation ".
2692 "WHERE svy_constraint.relation_fi = svy_relation.relation_id AND ".
2693 "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.question_fi = %s ".
2694 "AND svy_qst_constraint.survey_fi = %s",
2695 array(
'integer',
'integer'),
2700 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
2703 $question =
new $question_type();
2704 $question->loadFromDb(
$row[
"question_fi"]);
2705 $valueoutput = $question->getPreconditionValueOutput(
$row[
"value"]);
2706 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));
2708 return $result_array;
2719 $result_array = array();
2720 $result = $ilDB->queryF(
"SELECT svy_qst_constraint.question_fi as for_question, svy_constraint.*, svy_relation.* ".
2721 "FROM svy_qst_constraint, svy_constraint, svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id ".
2722 "AND svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.survey_fi = %s",
2728 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']));
2730 return $result_array;
2743 $result_array = array();
2744 $result = $ilDB->queryF(
"SELECT svy_variable.*, svy_category.title FROM svy_variable LEFT JOIN ".
2745 "svy_category ON svy_variable.category_fi = svy_category.category_id WHERE svy_variable.question_fi = %s ".
2746 "ORDER BY svy_variable.sequence",
2752 $result_array[
$row->sequence] =
$row;
2754 return $result_array;
2769 $next_id = $ilDB->nextId(
'svy_constraint');
2770 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_constraint (constraint_id, question_fi, relation_fi, value, conjunction) VALUES ".
2771 "(%s, %s, %s, %s, %s)",
2772 array(
'integer',
'integer',
'integer',
'float',
'integer'),
2773 array($next_id, $if_question_id, $relation, $value, $conjunction)
2796 $next_id = $ilDB->nextId(
'svy_qst_constraint');
2797 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qst_constraint (question_constraint_id, survey_fi, question_fi, ".
2798 "constraint_fi) VALUES (%s, %s, %s, %s)",
2799 array(
'integer',
'integer',
'integer',
'integer'),
2800 array($next_id, $this->
getSurveyId(), $to_question_id, $constraint_id)
2817 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_constraint SET question_fi = %s, relation_fi = %s, value = %s, conjunction = %s ".
2818 "WHERE constraint_id = %s",
2819 array(
'integer',
'integer',
'float',
'integer',
'integer'),
2820 array($if_question_id, $relation, $value, $conjunction, $precondition_id)
2827 foreach ($questions as $question_id)
2829 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_constraint SET conjunction = %s ".
2830 "WHERE constraint_id IN (SELECT constraint_fi FROM svy_qst_constraint WHERE svy_qst_constraint.question_fi = %s)",
2831 array(
'integer',
'integer'),
2832 array($conjunction, $question_id)
2847 $custom_order = array(
"equal",
"not_equal",
"less",
"less_or_equal",
"more",
"more_or_equal");
2848 $custom_order = array_flip($custom_order);
2850 $result_array = array();
2851 $result = $ilDB->query(
"SELECT * FROM svy_relation");
2856 $result_array[
$row[
"shortname"]] = array(
"short" => $row[
"shortname"],
"long" => $row[
"longname"],
"id" => $row[
"relation_id"],
"order" => $custom_order[$row[
"longname"]]);
2860 $result_array[
$row[
"relation_id"]] = array(
"short" => $row[
"shortname"],
"long" => $row[
"longname"],
"order" => $custom_order[$row[
"longname"]]);
2865 foreach($result_array as $idx => $item)
2867 unset($result_array[$idx][
"order"]);
2870 return $result_array;
2879 $result = $ilDB->queryF(
"SELECT user_fi FROM svy_inv_usr WHERE survey_fi = %s",
2898 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_inv_usr WHERE survey_fi = %s AND user_fi = %s",
2899 array(
'integer',
'integer'),
2902 include_once
'./Services/User/classes/class.ilObjUser.php';
2916 $result = $ilDB->queryF(
"SELECT user_fi FROM svy_inv_usr WHERE user_fi = %s AND survey_fi = %s",
2917 array(
'integer',
'integer'),
2922 $next_id = $ilDB->nextId(
'svy_inv_usr');
2923 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_inv_usr (invited_user_id, survey_fi, user_fi, tstamp) " .
2924 "VALUES (%s, %s, %s, %s)",
2925 array(
'integer',
'integer',
'integer',
'integer'),
2926 array($next_id, $this->
getSurveyId(), $user_id, time())
2931 include_once
'./Services/User/classes/class.ilObjUser.php';
2946 include_once
"./Modules/Group/classes/class.ilObjGroup.php";
2948 $members = $group->getGroupMemberIds();
2949 foreach ($members as $user_id)
2951 if ($ilAccess->checkAccessOfUser($user_id,
"read",
"", $this->getRefId(),
"svy", $this->
getId()))
2956 include_once
'./Services/User/classes/class.ilObjUser.php';
2975 $members = $rbacreview->assignedUsers($role_id);
2976 foreach ($members as $user_id)
2978 if ($ilAccess->checkAccessOfUser($user_id,
"read",
"", $this->getRefId(),
"svy", $this->
getId()))
2983 include_once
'./Services/User/classes/class.ilObjUser.php';
3001 $result_array = array();
3002 $result = $ilDB->queryF(
"SELECT user_fi FROM svy_inv_usr WHERE survey_fi = %s",
3008 array_push($result_array,
$row[
"user_fi"]);
3010 return $result_array;
3024 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
3025 array(
'integer',
'integer'),
3026 array($question_id, $active_id)
3041 $result_array = array();
3042 $result = $ilDB->queryF(
"SELECT * FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
3043 array(
'integer',
'integer'),
3044 array($question_id, $active_id)
3050 array_push($result_array,
$row);
3052 return $result_array;
3056 return $result_array;
3073 $active_id = $ilDB->nextId(
'svy_finished');
3074 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_finished (finished_id, survey_fi, user_fi, anonymous_id, state, tstamp) ".
3075 "VALUES (%s, %s, %s, %s, %s, %s)",
3076 array(
'integer',
'integer',
'integer',
'text',
'text',
'integer'),
3077 array($active_id, $this->
getSurveyId(), $user_id, $anonymous_id, 1, time())
3081 foreach ($pages as $key => $question_array)
3083 foreach ($question_array as $question)
3086 require_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3088 $question->saveRandomData($active_id);
3103 if ($this->
getAnonymize() && (strlen($anonymous_id) == 0))
return;
3105 if (strcmp($user_id,
"") == 0)
3107 if ($user_id == ANONYMOUS_USER_ID)
3112 $next_id = $ilDB->nextId(
'svy_finished');
3113 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_finished (finished_id, survey_fi, user_fi, anonymous_id, state, tstamp, appr_id) ".
3114 "VALUES (%s, %s, %s, %s, %s, %s, %s)",
3115 array(
'integer',
'integer',
'integer',
'text',
'text',
'integer',
'integer'),
3116 array($next_id, $this->
getSurveyId(), $user_id, $anonymous_id, 0, time(), $appraisee_id)
3131 $ilDB->manipulateF(
"UPDATE svy_finished SET state = %s, tstamp = %s".
3132 " WHERE survey_fi = %s AND finished_id = %s",
3133 array(
'text',
'integer',
'integer',
'integer'),
3134 array(1, time(), $this->
getSurveyId(), $finished_id)
3151 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_finished SET lastpage = %s WHERE finished_id = %s",
3152 array(
'integer',
'integer'),
3153 array(($page_id) ? $page_id : 0, $finished_id)
3159 include_once
"./Services/User/classes/class.ilObjUser.php";
3160 include_once
"./Services/User/classes/class.ilUserUtil.php";
3163 $placeholders = array(
3164 "FIRST_NAME" =>
"firstname",
3165 "LAST_NAME" =>
"lastname",
3168 "firstname" =>
"firstname" 3171 $recipients = preg_split(
'/,/', $this->mailaddresses);
3172 foreach ($recipients as $recipient)
3175 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
3177 $ntf->setLangModules(array(
"survey"));
3179 $ntf->setSubjectLangId(
'finished_mail_subject');
3182 if(trim($messagetext))
3189 foreach ($placeholders as $key => $mapping)
3193 $messagetext = str_replace(
'[' . $key .
']',
'', $messagetext);
3197 $messagetext = str_replace(
'[' . $key .
']', trim(
$data[$mapping]), $messagetext);
3200 $ntf->setIntroductionDirect($messagetext);
3204 $ntf->setIntroductionLangId(
'survey_notification_finished_introduction');
3210 $ntf->addAdditionalInfo(
'survey_360_appraisee',
3214 $active_id = $this->
getActiveID($user_id, $anonymize_id, $appr_id);
3215 $ntf->addAdditionalInfo(
'results',
3218 $ntf->setGotoLangId(
'survey_notification_tutor_link');
3219 $ntf->setReasonLangId(
'survey_notification_finished_reason');
3221 $ntf->sendMail(array($recipient), null, null);
3230 $questioncounter = 1;
3231 foreach ($questions as $question_id => $question_data)
3233 $textresult .= $questioncounter++ .
". " . $question_data[
"title"] .
"\n";
3234 $found = $userResults[$question_id][$active_id];
3236 if (is_array($found))
3238 $text = implode(
"\n", $found);
3244 if (strlen(
$text) == 0)
$text = self::getSurveySkippedValue();
3246 $textresult .=
$text .
"\n\n";
3256 foreach ($questions as
$data)
3258 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3315 $result = $ilDB->queryF(
"SELECT * FROM svy_finished".
3316 " WHERE survey_fi = %s AND anonymous_id = %s AND appr_id = %s",
3317 array(
'integer',
'text',
'integer'),
3318 array($this->
getSurveyId(), $anonymize_id, $appr_id)
3323 $result = $ilDB->queryF(
"SELECT * FROM svy_finished".
3324 " WHERE survey_fi = %s AND user_fi = %s AND appr_id = %s",
3325 array(
'integer',
'integer',
'integer'),
3340 return (
int)
$row[
"state"];
3400 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished".
3401 " WHERE survey_fi = %s AND anonymous_id = %s AND appr_id = %s",
3402 array(
'integer',
'text',
'integer'),
3403 array($this->
getSurveyId(), $anonymize_id, $appr_id)
3408 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished".
3409 " WHERE survey_fi = %s AND user_fi = %s AND appr_id = %s",
3410 array(
'integer',
'integer',
'integer'),
3421 return $row[
"finished_id"];
3474 $result = $ilDB->queryF(
"SELECT lastpage FROM svy_finished WHERE finished_id = %s",
3485 return (
$row[
"lastpage"]) ?
$row[
"lastpage"] :
'';
3499 if (count($working_data) == 0)
3504 if ((count($working_data) == 1) and (strcmp($working_data[0][
"value"],
"") == 0))
3510 foreach ($working_data as
$data)
3512 switch ($constraint_data[
"short"])
3515 if ($data[
"value"] < $constraint_data[
"value"])
3522 if ($data[
"value"] <= $constraint_data[
"value"])
3529 if ($data[
"value"] == $constraint_data[
"value"])
3536 if ($data[
"value"] <> $constraint_data[
"value"])
3543 if ($data[
"value"] >= $constraint_data[
"value"])
3550 if ($data[
"value"] > $constraint_data[
"value"])
3569 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
3573 return (
$result->numRows()) ?
true :
false;
3587 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s",
3595 array_push($users,
$row[
"finished_id"]);
3611 $evaluation = array();
3613 foreach ($questions as $question_id => $question_data)
3615 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3618 $question =
new $question_type();
3619 $question->loadFromDb($question_id);
3621 $evaluation[$question_id] =
$data;
3637 $surveySetting =
new ilSetting(
"survey");
3638 $use_anonymous_id = array_key_exists(
"use_anonymous_id",
$_GET) ?
$_GET[
"use_anonymous_id"] : $surveySetting->get(
"use_anonymous_id");
3639 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE finished_id = %s",
3644 $foundrows =
$result->numRows();
3649 $name = ($use_anonymous_id) ?
$row[
"anonymous_id"] : $this->lng->txt(
"anonymous");
3651 "fullname" => $name,
3652 "sortname" => $name,
3657 "active_id" =>
"$active_id" 3661 if ((
$row[
"user_fi"] > 0) && (
$row[
"user_fi"] != ANONYMOUS_USER_ID) &&
3665 include_once
'./Services/User/classes/class.ilObjUser.php';
3668 $userdata[
"fullname"] = $userdata[
"sortname"] = $this->lng->txt(
"deleted_user");
3673 $userdata[
"fullname"] = $user->getFullname();
3674 $gender = $user->getGender();
3675 if (strlen($gender) == 1) $gender = $this->lng->txt(
"gender_$gender");
3676 $userdata[
"gender"] = $gender;
3677 $userdata[
"firstname"] = $user->getFirstname();
3678 $userdata[
"lastname"] = $user->getLastname();
3679 $userdata[
"sortname"] = $user->getLastname() .
", " . $user->getFirstname();
3680 $userdata[
"login"] = $user->getLogin();
3702 $result = $ilDB->queryF(
"SELECT * FROM svy_answer WHERE active_fi = %s",
3708 if (!is_array($answers[
$row[
"question_fi"]]))
3710 $answers[$row[
"question_fi"]] = array();
3712 array_push($answers[$row[
"question_fi"]], $row);
3716 "name" => $userdata[
"fullname"],
3717 "firstname" => $userdata[
"firstname"],
3718 "lastname" => $userdata[
"lastname"],
3719 "login" => $userdata[
"login"],
3720 "gender" => $userdata[
"gender"],
3721 "answers" => array()
3723 foreach ($questions as $key => $question)
3725 if (array_key_exists($key, $answers))
3727 $resultset[
"answers"][$key] = $answers[$key];
3731 $resultset[
"answers"][$key] = array();
3733 sort($resultset[
"answers"][$key]);
3752 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
3756 $nr_of_users =
$result->numRows();
3760 $nr_of_users =
sizeof($finished_ids);
3763 $result_array =& $question->getCumulatedResults($this->
getSurveyId(), $nr_of_users, $finished_ids);
3764 return $result_array;
3778 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
3789 $result_array = array();
3790 $result = $ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype WHERE ".
3791 "svy_question.questiontype_fi = svy_qtype.questiontype_id AND svy_question.tstamp > 0 AND ".
3792 $ilDB->in(
'svy_question.question_id', $question_ids,
false,
'integer'));
3795 array_push($result_array,
$row);
3797 return $result_array;
3810 if (is_array($arrFilter))
3812 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
3814 $where .=
" AND " . $ilDB->like(
'svy_question.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
3816 if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description']))
3818 $where .=
" AND " . $ilDB->like(
'svy_question.description',
'text',
"%%" . $arrFilter[
'description'] .
"%%");
3820 if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author']))
3822 $where .=
" AND " . $ilDB->like(
'svy_question.author',
'text',
"%%" . $arrFilter[
'author'] .
"%%");
3824 if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type']))
3826 $where .=
" AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter[
'type'],
'text');
3828 if (array_key_exists(
'spl', $arrFilter) && strlen($arrFilter[
'spl']))
3830 $where .=
" AND svy_question.obj_fi = " . $ilDB->quote($arrFilter[
'spl'],
'integer');
3836 $forbidden =
" AND " . $ilDB->in(
'svy_question.obj_fi', array_keys($spls),
false,
'integer');
3837 $forbidden .=
" AND svy_question.complete = " . $ilDB->quote(
"1",
'text');
3840 if (count($existing_questions))
3842 $existing =
" AND " . $ilDB->in(
'svy_question.question_id', $existing_questions,
true,
'integer');
3845 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
3848 $query_result = $ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin, object_reference.ref_id".
3849 " FROM svy_question, svy_qtype, object_reference".
3850 " WHERE svy_question.original_id IS NULL".$forbidden.$existing.
3851 " AND svy_question.obj_fi = object_reference.obj_id AND svy_question.tstamp > 0".
3852 " AND svy_question.questiontype_fi = svy_qtype.questiontype_id " . $where);
3855 if ($query_result->numRows())
3857 while (
$row = $ilDB->fetchAssoc($query_result))
3859 if (array_key_exists(
'spl_txt', $arrFilter) && strlen($arrFilter[
'spl_txt']))
3861 if(!stristr($spls[
$row[
"obj_fi"]], $arrFilter[
'spl_txt']))
3867 $row[
'ttype'] = $trans[
$row[
'type_tag']];
3872 array_push($rows, $row);
3877 array_push($rows, $row);
3894 if (is_array($arrFilter))
3896 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
3898 $where .=
" AND " . $ilDB->like(
'svy_qblk.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
3902 $query_result = $ilDB->query(
"SELECT svy_qblk.*, svy_svy.obj_fi FROM svy_qblk , svy_qblk_qst, svy_svy WHERE ".
3903 "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_svy.survey_id = svy_qblk_qst.survey_fi ".
3904 "$where GROUP BY svy_qblk.questionblock_id, svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.show_blocktitle, ".
3905 "svy_qblk.owner_fi, svy_qblk.tstamp, svy_svy.obj_fi");
3907 if ($query_result->numRows())
3910 $surveytitles = array();
3911 foreach ($survey_ref_ids as $survey_ref_id)
3916 while (
$row = $ilDB->fetchAssoc($query_result))
3920 foreach ($questions_array as $key => $value)
3922 $questions_array[$key] =
"$counter. $value";
3925 if (strlen($surveytitles[
$row[
"obj_fi"]]))
3927 $rows[$row[
"questionblock_id"]] = array(
3928 "questionblock_id" => $row[
"questionblock_id"],
3929 "title" => $row[
"title"],
3930 "svy" => $surveytitles[$row[
"obj_fi"]],
3931 "contains" => join($questions_array,
", "),
3932 "owner" => $row[
"owner_fi"]
3948 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
3953 "xmlns:xsi" =>
"http://www.w3.org/2001/XMLSchema-instance",
3954 "xsi:noNamespaceSchemaLocation" =>
"http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd" 3956 $a_xml_writer->xmlStartTag(
"surveyobject", $attrs);
3961 $a_xml_writer->xmlStartTag(
"survey", $attrs);
3963 $a_xml_writer->xmlElement(
"description", NULL, $this->
getDescription());
3964 $a_xml_writer->xmlElement(
"author", NULL, $this->
getAuthor());
3965 $a_xml_writer->xmlStartTag(
"objectives");
3967 "label" =>
"introduction" 3974 $a_xml_writer->xmlEndTag(
"objectives");
3978 $attribs = array(
"enabled" =>
"1");
3982 $attribs = array(
"enabled" =>
"0");
3984 $a_xml_writer->xmlElement(
"anonymisation", $attribs);
3985 $a_xml_writer->xmlStartTag(
"restrictions");
3988 $attribs = array(
"type" =>
"free");
3992 $attribs = array(
"type" =>
"restricted");
3994 $a_xml_writer->xmlElement(
"access", $attribs);
3997 $attrs = array(
"type" =>
"date");
3998 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartDate(), $matches);
3999 $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]));
4003 $attrs = array(
"type" =>
"date");
4004 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndDate(), $matches);
4005 $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]));
4008 $a_xml_writer->xmlEndTag(
"restrictions");
4012 $hasconstraints = FALSE;
4013 foreach ($pages as $question_array)
4015 foreach ($question_array as $question)
4017 if (count($question[
"constraints"]))
4019 $hasconstraints = TRUE;
4024 if ($hasconstraints)
4026 $a_xml_writer->xmlStartTag(
"constraints");
4027 foreach ($pages as $question_array)
4029 foreach ($question_array as $question)
4031 if (count($question[
"constraints"]))
4034 foreach ($question[
"constraints"] as $constraint)
4037 "sourceref" => $question[
"question_id"],
4038 "destref" => $constraint[
"question"],
4039 "relation" => $constraint[
"short"],
4040 "value" => $constraint[
"value"],
4041 "conjunction" => $constraint[
"conjunction"]
4043 $a_xml_writer->xmlElement(
"constraint", $attribs);
4048 $a_xml_writer->xmlEndTag(
"constraints");
4052 $a_xml_writer->xmlStartTag(
"metadata");
4054 $custom_properties = array();
4056 $custom_properties[
"status"] = $this->
getStatus();
4058 $custom_properties[
"pool_usage"] = (int)$this->
getPoolUsage();
4063 $custom_properties[
"mode_360"] = (int)$this->
get360Mode();
4067 $custom_properties[
"mode_360_results"] = $this->
get360Results();
4075 foreach($custom_properties as $label => $value)
4077 $a_xml_writer->xmlStartTag(
"metadatafield");
4078 $a_xml_writer->xmlElement(
"fieldlabel", NULL, $label);
4079 $a_xml_writer->xmlElement(
"fieldentry", NULL, $value);
4080 $a_xml_writer->xmlEndTag(
"metadatafield");
4083 $a_xml_writer->xmlStartTag(
"metadatafield");
4084 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"SCORM");
4085 include_once
"./Services/MetaData/classes/class.ilMD.php";
4088 $md->toXml($writer);
4089 $metadata = $writer->xmlDumpMem();
4090 $a_xml_writer->xmlElement(
"fieldentry", NULL, $metadata);
4091 $a_xml_writer->xmlEndTag(
"metadatafield");
4093 $a_xml_writer->xmlEndTag(
"metadata");
4094 $a_xml_writer->xmlEndTag(
"survey");
4096 $attribs = array(
"id" => $this->
getId());
4097 $a_xml_writer->xmlStartTag(
"surveyquestions", $attribs);
4100 foreach ($pages as $question_array)
4102 if (count($question_array) > 1)
4104 $attribs = array(
"id" => $question_array[0][
"question_id"]);
4105 $attribs = array(
"showQuestiontext" => $question_array[0][
"questionblock_show_questiontext"],
4106 "showBlocktitle" => $question_array[0][
"questionblock_show_blocktitle"]);
4107 $a_xml_writer->xmlStartTag(
"questionblock", $attribs);
4108 if (strlen($question_array[0][
"questionblock_title"]))
4110 $a_xml_writer->xmlElement(
"questionblocktitle", NULL, $question_array[0][
"questionblock_title"]);
4113 foreach ($question_array as $question)
4115 if (strlen($question[
"heading"]))
4117 $a_xml_writer->xmlElement(
"textblock", NULL, $question[
"heading"]);
4120 if ($questionObject !== FALSE) $questionObject->insertXML($a_xml_writer, FALSE, $obligatory_states[$question[
"question_id"]]);
4122 if (count($question_array) > 1)
4124 $a_xml_writer->xmlEndTag(
"questionblock");
4128 $a_xml_writer->xmlEndTag(
"surveyquestions");
4129 $a_xml_writer->xmlEndTag(
"surveyobject");
4130 $xml = $a_xml_writer->xmlDumpMem(FALSE);
4143 if ($question_id < 1)
return FALSE;
4144 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
4146 if (strlen($question_type) == 0)
return FALSE;
4148 $question =
new $question_type();
4149 $question->loadFromDb($question_id);
4161 if (!is_dir($a_dir) || is_int(strpos($a_dir,
"..")))
4165 $importDirectory =
"";
4168 $current_dir = opendir($a_dir);
4170 while($entryname = readdir($current_dir))
4172 $files[] = $entryname;
4175 foreach($files as
$file)
4177 if(is_dir($a_dir.
"/".$file) and ($file !=
"." and $file!=
".."))
4180 $importDirectory = $a_dir.
"/".
$file;
4183 closedir($current_dir);
4184 if (strlen($importDirectory))
4187 $current_dir = opendir($importDirectory);
4189 while($entryname = readdir($current_dir))
4191 $files[] = $entryname;
4193 foreach($files as $file)
4195 if(@is_file($importDirectory.
"/".$file) && ($file !=
"." && $file!=
"..") && (ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(svy_)*[0-9]+\.[a-z]{1,3}\$", $file) || ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(survey__)*[0-9]+\.[a-z]{1,3}\$", $file)))
4198 $xmlFile = $importDirectory.
"/".
$file;
4202 return array(
"dir" => $importDirectory,
"xml" => $xmlFile);
4215 if ($svy_qpl_id < 1) $svy_qpl_id = -1;
4217 $source = $file_info[
"tmp_name"];
4219 if (($source ==
'none') || (!$source) || $file_info[
"error"] > UPLOAD_ERR_OK)
4221 $error = $this->lng->txt(
"import_no_file_selected");
4226 if ((strcmp($file_info[
"type"],
"text/xml") == 0) || (strcmp($file_info[
"type"],
"application/xml") == 0))
4231 $suffix = pathinfo($file_info[
"name"]);
4232 if (strcmp(strtolower($suffix[
"extension"]),
"zip") == 0)
4236 if (!$isXml && !$isZip)
4238 $error = $this->lng->txt(
"import_wrong_file_type");
4240 $ilLog->write(
"Survey: Import error. Filetype was \"" . $file_info[
"type"] .
"\"");
4242 if (strlen($error) == 0)
4246 $import_subdir =
"";
4248 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4251 $importfile = $import_dir.
"/".$file_info[
"name"];
4255 if (!((strlen($found[
"dir"]) > 0) && (strlen($found[
"xml"]) > 0)))
4257 $error = $this->lng->txt(
"wrong_import_file_structure");
4260 $importfile = $found[
"xml"];
4261 $import_subdir = $found[
"dir"];
4265 $importfile = tempnam($import_dir,
"survey_import");
4268 $fh = fopen($importfile,
"r");
4271 $error = $this->lng->txt(
"import_error_opening_file");
4274 $xml = fread($fh, filesize($importfile));
4278 $error = $this->lng->txt(
"import_error_closing_file");
4283 if (strpos($xml,
"questestinterop"))
4285 include_once(
"./Modules/Survey/exceptions/class.ilInvalidSurveyImportFileException.php");
4296 include_once
"./Services/Survey/classes/class.SurveyImportParser.php";
4298 $import->setSurveyObject($this);
4299 $import->setXMLContent($xml);
4300 $import->startParsing();
4303 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
4305 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
4306 include_once
"./Services/RTE/classes/class.ilRTE.php";
4307 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
4308 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
4310 $importfile = $import_subdir .
"/" . $mob[
"uri"];
4311 if (file_exists($importfile))
4315 $mob[
"type"] =
"svy:html";
4321 if ($mob[
"type"] ==
"svy:html")
4324 $this->
setIntroduction(str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $this->
getIntroduction()));
4325 $this->
setOutro(str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $this->
getOutro()));
4328 else if($import->questions[$mob[
"id"]])
4330 $new_qid = $import->questions[$mob[
"id"]];
4333 $qtext = $new_question->getQuestiontext();
4335 $qtext = str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $qtext);
4337 $new_question->setQuestiontext($qtext);
4338 $new_question->saveToDb();
4341 if($new_question->getOriginalId())
4344 $pool_question->setQuestiontext($qtext);
4345 $pool_question->saveToDb();
4352 $ilLog->write(
"Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
4381 $newObj = parent::cloneObject($a_target_id,$a_copy_id);
4383 $newObj->updateMetaData();
4387 $newObj->setOutro($this->
getOutro());
4403 $newObj->set360Mode(
true);
4422 $question_pointer = array();
4425 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
4427 foreach ($this->questions as $key => $question_id)
4434 $question->saveToDb($original_id);
4435 $newObj->questions[$key] = $question->getId();
4436 $question_pointer[$question_id] = $question->getId();
4437 $mapping[$question_id] = $question->getId();
4444 if(!$cp_options->isRootNode($this->getRefId()))
4446 $newObj->setStatus($this->
isOnline()?self::STATUS_ONLINE: self::STATUS_OFFLINE);
4449 $newObj->saveToDb();
4450 $newObj->cloneTextblocks($mapping);
4456 include_once
"./Modules/Survey/classes/class.ilSurveySkill.php";
4460 foreach($mapping as $src_qst_id => $tgt_qst_id)
4462 $qst_skill = $src_skills->getSkillForQuestion($src_qst_id);
4465 $tgt_skills->addQuestionSkillAssignment($tgt_qst_id, $qst_skill[
"base_skill_id"], $qst_skill[
"tref_id"]);
4471 $questionblocks = array();
4472 $questionblock_questions = array();
4473 $result = $ilDB->queryF(
"SELECT * FROM svy_qblk_qst WHERE survey_fi = %s",
4481 array_push($questionblock_questions,
$row);
4482 $questionblocks[
$row[
"questionblock_fi"]] = $row[
"questionblock_fi"];
4486 foreach ($questionblocks as $key => $value)
4489 $questionblock_id =
ilObjSurvey::_addQuestionblock($questionblock[
"title"], $questionblock[
"owner_fi"], $questionblock[
"show_questiontext"], $questionblock[
"show_blocktitle"]);
4490 $questionblocks[$key] = $questionblock_id;
4493 foreach ($questionblock_questions as $key => $value)
4495 if($questionblocks[$value[
"questionblock_fi"]] &&
4496 $question_pointer[$value[
"question_fi"]])
4498 $next_id = $ilDB->nextId(
'svy_qblk_qst');
4499 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, question_fi) ".
4500 "VALUES (%s, %s, %s, %s)",
4501 array(
'integer',
'integer',
'integer',
'integer'),
4502 array($next_id, $newObj->getSurveyId(), $questionblocks[$value[
"questionblock_fi"]], $question_pointer[$value[
"question_fi"]])
4509 $newConstraints = array();
4510 foreach ($constraints as $key => $constraint)
4512 if ($question_pointer[$constraint[
"for_question"]] &&
4513 $question_pointer[$constraint[
"question"]])
4515 if (!array_key_exists($constraint[
'id'], $newConstraints))
4517 $constraint_id = $newObj->addConstraint($question_pointer[$constraint[
"question"]], $constraint[
"relation_id"], $constraint[
"value"], $constraint[
'conjunction']);
4518 $newConstraints[$constraint[
'id']] = $constraint_id;
4520 $newObj->addConstraintToQuestion($question_pointer[$constraint[
"for_question"]], $newConstraints[$constraint[
'id']]);
4525 $result = $ilDB->queryF(
"SELECT * FROM svy_qst_oblig WHERE survey_fi = %s",
4533 if($question_pointer[
$row[
"question_fi"]])
4535 $next_id = $ilDB->nextId(
'svy_qst_oblig');
4536 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, ".
4537 "obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)",
4538 array(
'integer',
'integer',
'integer',
'text',
'integer'),
4539 array($next_id, $newObj->getSurveyId(), $question_pointer[$row[
"question_fi"]], $row[
"obligatory"], time())
4546 include_once(
'./Services/Tracking/classes/class.ilLPObjSettings.php');
4548 $obj_settings->cloneSettings($newObj->getId());
4549 unset($obj_settings);
4557 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE question_fi = %s",
4564 return $row[
"heading"];
4579 foreach ($mapping as $original_id => $new_id)
4582 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
4594 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4597 if(!is_writable($svy_data_dir))
4599 $this->
ilias->raiseError(
"Survey Data Directory (".$svy_data_dir
4600 .
") not writeable.",$this->
ilias->error_obj->FATAL);
4604 $svy_dir = $svy_data_dir.
"/svy_".$this->
getId();
4606 if(!@is_dir($svy_dir))
4608 $this->
ilias->raiseError(
"Creation of Survey Directory failed.",$this->
ilias->error_obj->FATAL);
4611 $export_dir = $svy_dir.
"/export";
4613 if(!@is_dir($export_dir))
4615 $this->
ilias->raiseError(
"Creation of Export Directory failed.",$this->
ilias->error_obj->FATAL);
4624 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4637 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4641 if(!is_writable($svy_data_dir))
4643 $this->
ilias->raiseError(
"Survey Data Directory (".$svy_data_dir
4644 .
") not writeable.",$this->
ilias->error_obj->FATAL);
4648 $svy_dir = $svy_data_dir.
"/svy_".$this->
getId();
4650 if(!@is_dir($svy_dir))
4652 $this->
ilias->raiseError(
"Creation of Survey Directory failed.",$this->
ilias->error_obj->FATAL);
4656 $import_dir = $svy_dir.
"/import";
4658 if(!@is_dir($import_dir))
4660 $this->
ilias->raiseError(
"Creation of Import Directory failed.",$this->
ilias->error_obj->FATAL);
4669 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4671 "/svy_".$this->getId().
"/import";
4672 if (!is_dir($import_dir))
4676 if(@is_dir($import_dir))
4691 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
4692 array(
'text',
'integer',
'integer'),
4693 array($heading, $this->
getSurveyId(), $insertbefore)
4698 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
4699 array(
'text',
'integer',
'integer'),
4709 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_anonymous WHERE survey_key = %s AND survey_fi = %s",
4710 array(
'text',
'integer'),
4713 return (
$result->numRows() == 1) ?
true :
false;
4721 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
4722 array(
'integer',
'integer'),
4728 return $row[
"anonymous_id"];
4740 if($user_id == ANONYMOUS_USER_ID)
4747 $ilDB->manipulate(
"UPDATE svy_anonymous".
4748 " SET user_key = ".$ilDB->quote(md5($user_id),
"text").
4749 " WHERE survey_key = ".$ilDB->quote(
$code,
"text"));
4757 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE anonymous_id = %s AND survey_fi = %s",
4758 array(
'text',
'integer'),
4761 return (
$result->numRows() == 1) ?
true :
false;
4793 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND user_key IS NULL",
4811 include_once
"./Services/Link/classes/class.ilLink.php";
4813 $sql =
"SELECT svy_anonymous.*, svy_finished.state".
4814 " FROM svy_anonymous".
4815 " LEFT JOIN svy_finished ON (svy_anonymous.survey_key = svy_finished.anonymous_id)".
4816 " WHERE svy_anonymous.survey_fi = ".$ilDB->quote($this->
getSurveyId(),
"integer").
4817 " AND svy_anonymous.user_key IS NULL";
4821 $sql .=
" AND ".$ilDB->in(
"svy_anonymous.survey_key", $a_codes,
"",
"text");
4825 $sql .=
" AND ".$ilDB->in(
"svy_anonymous.anonymous_id", $a_ids,
"",
"text");
4832 $titles[] =
'"'.$lng->txt(
"survey_code").
'"';
4833 $titles[] =
'"'.$lng->txt(
"email").
'"';
4834 $titles[] =
'"'.$lng->txt(
"lastname").
'"';
4835 $titles[] =
'"'.$lng->txt(
"firstname").
'"';
4836 $titles[] =
'"'.$lng->txt(
"create_date").
'"';
4837 $titles[] =
'"'.$lng->txt(
"used").
'"';
4838 $titles[] =
'"'.$lng->txt(
"mail_sent_short").
'"';
4839 $titles[] =
'"'.$lng->txt(
"survey_code_url").
'"';
4840 $export[] = implode(
";", $titles);
4843 $default_lang = $ilUser->getPref(
"survey_code_language");
4847 $item[] =
$row[
"survey_key"];
4849 if(
$row[
"externaldata"])
4851 $ext = unserialize(
$row[
"externaldata"]);
4852 $item[] = $ext[
"email"];
4853 $item[] = $ext[
"lastname"];
4854 $item[] = $ext[
"firstname"];
4868 $item[] = (
$row[
"sent"]) ? 1 : 0;
4870 $params = array(
"accesscode" =>
$row[
"survey_key"]);
4873 $params[
"lang"] = $default_lang;
4877 $export[] =
'"'.implode(
'";"', $item).
'"';
4879 return implode(
"\n", $export);
4893 include_once
"./Services/Link/classes/class.ilLink.php";
4897 $sql =
"SELECT svy_anonymous.*, svy_finished.state".
4898 " FROM svy_anonymous".
4899 " LEFT JOIN svy_finished ON (svy_anonymous.survey_key = svy_finished.anonymous_id)".
4900 " WHERE svy_anonymous.survey_fi = ".$ilDB->quote($this->
getSurveyId(),
"integer")
4905 $sql .=
" AND ".$ilDB->in(
"svy_anonymous.anonymous_id", $ids,
"",
"integer");
4908 $sql .=
" ORDER BY tstamp, survey_key ASC";
4922 $params = array(
"accesscode" =>
$row[
"survey_key"]);
4932 'id' =>
$row[
"anonymous_id"],
4933 'code' =>
$row[
"survey_key"],
4934 'date' =>
$row[
"tstamp"],
4936 'sent' =>
$row[
'sent'],
4943 if(
$row[
"externaldata"])
4945 $ext = unserialize(
$row[
"externaldata"]);
4946 $item[
'email'] = $ext[
'email'];
4947 $item[
'last_name'] = $ext[
'lastname'];
4948 $item[
'first_name'] = $ext[
'firstname'];
4951 array_push($codes, $item);
4960 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
4961 array(
'integer',
'text'),
4964 return (
$result->numRows() > 0) ?
true :
false;
4970 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
4971 array(
'integer',
'text'),
4974 return (
$result->numRows() > 0) ?
false :
true;
4983 for ($i = 0; $i < $nrOfCodes; $i++)
4985 $next_id = $ilDB->nextId(
'svy_anonymous');
4986 $ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, tstamp) ".
4987 "VALUES (%s, %s, %s, %s)",
4988 array(
'integer',
'text',
'integer',
'integer'),
5001 $next_id = $ilDB->nextId(
'svy_anonymous');
5002 $ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) ".
5003 "VALUES (%s, %s, %s, %s, %s)",
5004 array(
'integer',
'text',
'integer',
'text',
'integer'),
5005 array($next_id, $a_anonymize_key, $this->
getSurveyId(), serialize($a_data), $a_created)
5014 foreach (
$data as $dataset)
5017 $next_id = $ilDB->nextId(
'svy_anonymous');
5018 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) ".
5019 "VALUES (%s, %s, %s, %s, %s)",
5020 array(
'integer',
'text',
'integer',
'text',
'integer'),
5021 array($next_id, $anonymize_key, $this->
getSurveyId(), serialize($dataset), time())
5036 $check_finished = ($not_sent > 1);
5038 include_once
"./Services/Mail/classes/class.ilMail.php";
5039 include_once
"./Services/Link/classes/class.ilLink.php";
5041 $mail =
new ilMail($user_id);
5043 foreach ($recipients as
$data)
5045 if($data[
'email'] && $data[
'code'])
5048 switch ((
int)$not_sent)
5051 $do_send = !(bool)$data[
'sent'];
5055 $do_send = $data[
'finished'];
5059 $do_send = !$data[
'finished'];
5069 $messagetext = $message;
5072 "accesscode" => $data[
"code"],
5075 $messagetext = str_replace(
'[url]',
"<" .
$url .
">", $messagetext);
5076 foreach ($data as $key => $value)
5078 $messagetext = str_replace(
'[' . $key .
']', $value, $messagetext);
5096 $ilDB->manipulateF(
"UPDATE svy_anonymous SET sent = %s WHERE survey_fi = %s AND externaldata IS NOT NULL",
5097 array(
'integer',
'integer'),
5105 $result = $ilDB->queryF(
"SELECT survey_key code, externaldata, sent FROM svy_anonymous WHERE survey_fi = %s",
5112 if(!
$row[
'externaldata'])
5117 $externaldata = unserialize(
$row[
'externaldata']);
5118 if(!$externaldata[
'email'])
5123 $externaldata[
'code'] =
$row[
'code'];
5124 $externaldata[
'sent'] =
$row[
'sent'];
5126 if($a_check_finished)
5131 array_push(
$res, $externaldata);
5145 if (strlen($survey_code) > 0)
5147 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
5148 array(
'integer',
'text'),
5164 $result = $ilDB->queryF(
"SELECT survey_key FROM svy_anonymous WHERE survey_fi = %s AND user_key = %s",
5165 array(
'integer',
'text'),
5171 $access_code =
$row[
"survey_key"];
5173 return $access_code;
5188 $next_id = $ilDB->nextId(
'svy_anonymous');
5189 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, user_key, tstamp) ".
5190 "VALUES (%s, %s, %s, %s, %s)",
5191 array(
'integer',
'text',
'integer',
'text',
'integer'),
5192 array($next_id, $access_code, $this->
getSurveyId(), md5($user_id), time())
5204 $codestring =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
5207 for ($i = 1; $i <=5; $i++)
5209 $index = mt_rand(0, strlen($codestring)-1);
5210 $code .= substr($codestring, $index, 1);
5233 $resultarray = array();
5234 foreach (
$row as $rowindex => $entry)
5236 if(is_array($entry))
5238 $entry = implode(
"/", $entry);
5245 if (strpos($entry,
"\"") !== FALSE)
5247 $entry = str_replace(
"\"",
"\"\"", $entry);
5255 $entry = str_replace(chr(13).chr(10), chr(10), $entry);
5258 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
5262 $resultarray[$rowindex] = utf8_decode($entry);
5265 return $resultarray;
5272 $result = $ilDB->queryF(
"SELECT tstamp FROM svy_answer WHERE active_fi = %s ORDER BY tstamp DESC",
5279 return $row[
"tstamp"];
5283 $result = $ilDB->queryF(
"SELECT tstamp FROM svy_finished WHERE finished_id = %s",
5290 return $row[
"tstamp"];
5304 include_once
"./Services/Utilities/classes/class.ilUtil.php";
5317 if (preg_match(
"/<[^>]*?>/", $a_text))
5335 function addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag = TRUE, $add_mobs = TRUE, $attribs = NULL)
5337 include_once
"./Services/RTE/classes/class.ilRTE.php";
5338 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
5340 $a_xml_writer->xmlStartTag(
"material", $attribs);
5342 "type" =>
"text/plain" 5344 if ($this->
isHTML($a_material))
5346 $attrs[
"type"] =
"text/xhtml";
5349 $a_xml_writer->xmlElement(
"mattext", $attrs, $mattext);
5354 foreach (
$mobs as $mob)
5356 $mob_id =
"il_" . IL_INST_ID .
"_mob_" . $mob;
5357 if (strpos($mattext, $mob_id) !== FALSE)
5362 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle(),
5363 "type" =>
"svy:html",
5364 "id" => $this->
getId()
5366 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
5370 if ($close_material_tag) $a_xml_writer->xmlEndTag(
"material");
5385 if ($this->surveyCodeSecurity == FALSE)
5404 if (extension_loaded(
"tidy"))
5408 "output-xml" =>
true,
5409 "numeric-entities" =>
true 5412 $tidy->parseString($print_output, $config,
'utf8');
5413 $tidy->cleanRepair();
5414 $print_output = tidy_get_output($tidy);
5415 $print_output = preg_replace(
"/^.*?(<html)/",
"\\1", $print_output);
5419 $print_output = str_replace(
" ",
" ", $print_output);
5420 $print_output = str_replace(
"⊗",
"X", $print_output);
5423 $print_output = str_replace(
">",
">", $print_output);
5424 $print_output = str_replace(
"<",
"<", $print_output);
5425 $print_output = str_replace(
" ",
"~|nbsp|~", $print_output);
5426 $print_output = preg_replace(
'/&(?!amp)/',
'&', $print_output);
5427 $print_output = str_replace(
"~|nbsp|~",
" ", $print_output);
5429 $xsl = file_get_contents(
"./Modules/Survey/xml/question2fo.xsl");
5433 'font-family="Helvetica, unifont"',
5434 'font-family="'.
$GLOBALS[
'ilSetting']->
get(
'rpc_pdf_font',
'Helvetica, unifont').
'"',
5438 $args = array(
'/_xml' => $print_output,
'/_xsl' => $xsl );
5441 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args,
$params);
5444 $ilLog->write($output);
5458 include_once
"./Services/Utilities/classes/class.ilUtil.php";
5460 $fp = fopen($fo_file,
"w"); fwrite($fp, $fo); fclose($fp);
5462 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
5471 $ilLog->write(__METHOD__.
': '.$e->getMessage());
5476 $ilLog->write(__METHOD__.
': '.$e->getMessage());
5497 global $ilPluginAdmin;
5498 if ($ilPluginAdmin->isActive(
IL_COMP_MODULE,
"SurveyQuestionPool",
"svyq", $a_pname))
5528 if (!is_array($ids) || count($ids) ==0)
return array();
5530 $result = $ilDB->query(
"SELECT usr_id, login, lastname, firstname FROM usr_data WHERE " . $ilDB->in(
'usr_id', $ids,
false,
'integer') .
" ORDER BY login");
5531 $result_array = array();
5534 $result_array[
$row[
"usr_id"]]=
$row;
5536 return $result_array;
5541 if (!is_array($ids) || count($ids) ==0)
return array();
5553 if (!is_array($ids) || count($ids) ==0)
return array();
5555 foreach ($ids as $obj_id)
5569 $this->mailnotification = ($a_notification) ?
true :
false;
5579 $this->mailaddresses = $a_addresses;
5589 $this->mailparticipantdata = $a_data;
5596 $result = $ilDB->queryF(
"SELECT * FROM svy_times, svy_finished WHERE svy_finished.survey_fi = %s",
5598 array($this->
getId())
5603 if (strlen(
$row[
'left_page']) && strlen(
$row[
'entered_page']))
5604 $times[
$row[
'finished_fi']] += (
$row[
'left_page']-
$row[
'entered_page']);
5614 $id = $ilDB->nextId(
'svy_times');
5616 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_times (id, finished_fi, entered_page, left_page, first_question) VALUES (%s, %s, %s, %s,%s)",
5617 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
5618 array(
$id, $finished_id, $time, NULL, $first_question)
5626 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_times SET left_page = %s WHERE finished_fi = %s AND entered_page = %s",
5627 array(
'integer',
'integer',
'integer'),
5628 array($time, $finished_id,
$_SESSION[
'svy_entered_page'])
5637 $result = $ilDB->queryF(
"SELECT * FROM svy_times WHERE finished_fi = %s",
5644 if (
$row[
'left_page'] > 0 &&
$row[
'entered_page'] > 0)
5652 $this->template_id = (int)$template_id;
5662 if(
sizeof($this->questions) ==
sizeof($a_order))
5664 $this->questions = array_flip($a_order);
5665 $this->saveQuestionsToDB();
5676 $this->pool_usage = (bool)$a_value;
5688 if($template_settings)
5690 include_once
"Services/Administration/classes/class.ilSettingsTemplate.php";
5692 $template_settings = $template_settings->getSettings();
5693 $template_settings = $template_settings[
"use_pool"];
5694 if($template_settings && $template_settings[
"hide"])
5696 $use_pool = (bool)$template_settings[
"value"];
5714 include_once
"Services/Administration/classes/class.ilSettingsTemplate.php";
5716 $template_settings = $template->getSettings();
5717 if($template_settings)
5719 if($template_settings[
"show_question_titles"] !== NULL)
5721 if($template_settings[
"show_question_titles"][
"value"])
5731 if($template_settings[
"use_pool"] !== NULL)
5733 if($template_settings[
"use_pool"][
"value"])
5743 if($template_settings[
"anonymization_options"][
"value"])
5745 $anon_map = array(
'personalized' => self::ANONYMIZE_OFF,
5746 'anonymize_with_code' => self::ANONYMIZE_ON,
5747 'anonymize_without_code' => self::ANONYMIZE_FREEACCESS);
5748 $this->
setAnonymize($anon_map[$template_settings[
"anonymization_options"][
"value"]]);
5762 public function updateCode($a_id, $a_email, $a_last_name, $a_first_name, $a_sent)
5766 $a_email = trim($a_email);
5774 $data = array(
"email" => $a_email,
5775 "lastname" => trim($a_last_name),
5776 "firstname" => trim($a_first_name));
5779 "externaldata" => array(
"text", serialize(
$data)),
5780 "sent" => array(
"integer", $a_sent)
5783 $ilDB->update(
"svy_anonymous", $fields,
5784 array(
"anonymous_id" => array(
"integer", $a_id)));
5794 $this->mode_360 = (bool)$a_value;
5804 $this->mode_360_self_eval = (bool)$a_value;
5814 $this->mode_360_self_appr = (bool)$a_value;
5824 $this->mode_360_self_rate = (bool)$a_value;
5834 $this->mode_360_results = (int)$a_value;
5847 $a_user_id != ANONYMOUS_USER_ID)
5850 "obj_id" => array(
"integer", $this->
getSurveyId()),
5851 "user_id" => array(
"integer", $a_user_id)
5853 $ilDB->insert(
"svy_360_appr", $fields);
5861 $set = $ilDB->query(
"SELECT user_id".
5862 " FROM svy_360_appr".
5863 " WHERE obj_id = ".$ilDB->quote($this->getSurveyId(),
"integer").
5864 " AND user_id = ".$ilDB->quote($a_user_id,
"integer"));
5865 return (
bool)$ilDB->numRows($set);
5872 $set = $ilDB->query(
"SELECT has_closed".
5873 " FROM svy_360_appr".
5874 " WHERE obj_id = ".$ilDB->quote($this->getSurveyId(),
"integer").
5875 " AND user_id = ".$ilDB->quote($a_user_id,
"integer"));
5876 $row = $ilDB->fetchAssoc($set);
5877 return $row[
"has_closed"];
5884 $ilDB->manipulate(
"DELETE FROM svy_360_appr".
5885 " WHERE obj_id = ".$ilDB->quote($this->getSurveyId(),
"integer").
5886 " AND user_id = ".$ilDB->quote($a_user_id,
"integer"));
5888 $set = $ilDB->query(
"SELECT user_id".
5889 " FROM svy_360_rater".
5890 " WHERE obj_id = ".$ilDB->quote($this->getSurveyId(),
"integer").
5891 " AND appr_id = ".$ilDB->quote($a_user_id,
"integer"));
5892 while(
$row = $ilDB->fetchAssoc($set))
5909 $set = $ilDB->query(
"SELECT * FROM svy_360_appr".
5910 " WHERE obj_id = ".$ilDB->quote($this->getSurveyId(),
"integer"));
5911 while(
$row = $ilDB->fetchAssoc($set))
5915 $name[
"name"] = $name[
"lastname"].
", ".$name[
"firstname"];
5920 foreach($raters as $rater)
5922 if($rater[
"finished"])
5927 $res[$row[
"user_id"]][
"finished"] = $finished.
"/".
sizeof($raters);
5928 $res[$row[
"user_id"]][
"closed"] = $row[
"has_closed"];
5934 public function addRater($a_appraisee_id, $a_user_id, $a_anonymous_id = 0)
5939 !$this->
isRater($a_appraisee_id, $a_user_id, $a_anonymous_id))
5942 "obj_id" => array(
"integer", $this->
getSurveyId()),
5943 "appr_id" => array(
"integer", $a_appraisee_id),
5944 "user_id" => array(
"integer", $a_user_id),
5945 "anonymous_id" => array(
"integer", $a_anonymous_id)
5947 $ilDB->insert(
"svy_360_rater", $fields);
5951 public function isRater($a_appraisee_id, $a_user_id, $a_anonymous_id = 0)
5958 (!$a_appraisee_id || $a_appraisee_id == $a_user_id))
5965 $sql =
"SELECT user_id".
5966 " FROM svy_360_rater".
5967 " WHERE obj_id = ".$ilDB->quote($this->
getSurveyId(),
"integer").
5968 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
5969 " AND anonymous_id = ".$ilDB->quote($a_anonymous_id,
"integer");
5972 $sql .=
" AND appr_id = ".$ilDB->quote($a_appraisee_id,
"integer");
5974 $set = $ilDB->query($sql);
5975 return (
bool)$ilDB->numRows($set);
5978 public function deleteRater($a_appraisee_id, $a_user_id, $a_anonymous_id = 0)
5988 $ilDB->manipulate(
"DELETE FROM svy_360_rater".
5989 " WHERE obj_id = ".$ilDB->quote($this->getSurveyId(),
"integer").
5990 " AND appr_id = ".$ilDB->quote($a_appraisee_id,
"integer").
5991 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
5992 " AND anonymous_id = ".$ilDB->quote($a_anonymous_id,
"integer"));
5999 $res = $anonymous_ids = array();
6001 $set = $ilDB->query(
"SELECT * FROM svy_360_rater".
6002 " WHERE obj_id = ".$ilDB->quote($this->getSurveyId(),
"integer").
6003 " AND appr_id = ".$ilDB->quote($a_appraisee_id,
"integer"));
6004 while(
$row = $ilDB->fetchAssoc($set))
6006 if(
$row[
"anonymous_id"])
6008 $res[
"a".$row[
"anonymous_id"]] = array(
6009 "lastname" =>
"unknown code ".
$row[
"anonymous_id"],
6010 "sent" =>
$row[
"mail_sent"],
6013 $anonymous_ids[] =
$row[
"anonymous_id"];
6018 $name[
"user_id"] =
"u".$name[
"user_id"];
6020 $name[
"sent"] =
$row[
"mail_sent"];
6022 $res[
"u".$row[
"user_id"]] = $name;
6026 if(
sizeof($anonymous_ids))
6029 foreach(
$data as $item)
6031 if(isset(
$res[
"a".$item[
"id"]]))
6033 $res[
"a".$item[
"id"]] = array(
6034 "user_id" =>
"a".$item[
"id"],
6035 "lastname" => $item[
"last_name"],
6036 "firstname" => $item[
"first_name"],
6038 "email" => $item[
"email"],
6039 "code" => $item[
"code"],
6040 "href" => $item[
"href"],
6041 "sent" =>
$res[
"a".$item[
"id"]][
"sent"],
6057 $sql =
"SELECT appr_id FROM svy_360_rater".
6058 " WHERE obj_id = ".$ilDB->quote($this->
getSurveyId(),
"integer");
6062 $sql .=
" AND user_id = ".$ilDB->quote($a_user_id,
"integer");
6066 $sql .=
" AND anonymous_id = ".$ilDB->quote($a_anonymous_id,
"integer");
6069 $set = $ilDB->query($sql);
6070 while(
$row = $ilDB->fetchAssoc($set))
6078 !in_array($a_user_id,
$res))
6080 $res[] = $a_user_id;
6090 $set = $ilDB->query(
"SELECT anonymous_id FROM svy_anonymous".
6091 " WHERE survey_fi = ".$ilDB->quote($this->getSurveyId(),
"integer").
6092 " AND survey_key = ".$ilDB->quote($a_code,
"text"));
6093 $res = $ilDB->fetchAssoc($set);
6094 return $res[
"anonymous_id"];
6101 $sql =
"SELECT * FROM svy_finished".
6102 " WHERE survey_fi =".$ilDB->quote($this->
getSurveyId(),
"integer").
6103 " AND appr_id = ".$ilDB->quote($appr_id,
"integer");
6106 $sql .=
" AND user_fi = ".$ilDB->quote($user_id,
"integer");
6110 $sql .=
" AND anonymous_id = ".$ilDB->quote($anonymous_code,
"text");
6120 return (
int)
$row[
"state"];
6128 $user_id = $ilUser->getId();
6137 $user_id != ANONYMOUS_USER_ID &&
6150 else if($user_id == ANONYMOUS_USER_ID ||
6167 $sql =
"SELECT * FROM svy_finished".
6168 " WHERE survey_fi = ".$ilDB->quote($this->
getSurveyId(),
"integer");
6170 if($user_id != ANONYMOUS_USER_ID)
6172 $sql .=
" AND (user_fi = ".$ilDB->quote($user_id,
"integer").
6173 " OR anonymous_id = ".$ilDB->quote($a_code,
"text").
")";
6178 $sql .=
" AND anonymous_id = ".$ilDB->quote($a_code,
"text");
6180 $set = $ilDB->query($sql);
6181 while(
$row = $ilDB->fetchAssoc($set))
6183 $res[
$row[
"finished_id"]] = array(
"appr_id" => $row[
"appr_id"],
6184 "user_id" => $row[
"user_fi"],
6185 "code" => $row[
"anonymous_id"],
6186 "finished" => (
bool)$row[
"state"]);
6189 return array(
"code"=>$a_code,
"runs"=>
$res);
6196 if($a_user_id != ANONYMOUS_USER_ID)
6198 $set = $ilDB->query(
"SELECT sf.anonymous_id FROM svy_finished sf".
6199 " WHERE sf.survey_fi = ".$ilDB->quote($this->getSurveyId(),
"integer").
6200 " AND sf.user_fi = ".$ilDB->quote($a_user_id,
"integer"));
6201 $a_code = $ilDB->fetchAssoc($set);
6202 return $a_code[
"anonymous_id"];
6210 $set = $ilDB->query(
"SELECT user_fi FROM svy_finished".
6211 " WHERE survey_fi = ".$ilDB->quote($this->getSurveyId(),
"integer").
6212 " AND anonymous_id = ".$ilDB->quote($a_code,
"text"));
6213 $user_id = $ilDB->fetchAssoc($set);
6214 $user_id = $user_id[
"user_fi"];
6216 if($user_id && ($user_id != $a_user_id || $user_id == ANONYMOUS_USER_ID))
6229 $set = $ilDB->query(
"SELECT finished_id, user_fi FROM svy_finished".
6230 " WHERE survey_fi = ".$ilDB->quote($this->getSurveyId(),
"integer").
6231 " AND appr_id = ".$ilDB->quote($a_appr_id,
"integer"));
6232 while(
$row = $ilDB->fetchAssoc($set))
6234 if ($a_exclude_appraisee &&
$row[
"user_fi"] == $a_appr_id)
6255 $set = $ilDB->query(
"SELECT finished_id, user_fi FROM svy_finished".
6256 " WHERE survey_fi = ".$ilDB->quote($this->getSurveyId(),
"integer").
6257 " AND appr_id = ".$ilDB->quote($a_appr_id,
"integer").
6258 " AND user_fi = ".$ilDB->quote($a_rat_id,
"integer"));
6259 $row = $ilDB->fetchAssoc($set);
6260 return $row[
"finished_id"];
6273 $this->mode_360_skill_service = $a_val;
6295 $ilDB->manipulate(
"UPDATE svy_360_rater".
6296 " SET mail_sent = ".$ilDB->quote($a_tstamp,
"integer").
6297 " WHERE obj_id = ".$ilDB->quote($this->
getSurveyId(),
"integer").
6298 " AND appr_id = ".$ilDB->quote($a_appraisee_id,
"integer").
6299 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
6300 " AND anonymous_id = ".$ilDB->quote($a_anonymous_id,
"integer"));
6308 $ilDB->manipulate(
"UPDATE svy_360_appr".
6309 " SET has_closed = ".$ilDB->quote(time(),
"integer").
6310 " WHERE obj_id = ".$ilDB->quote($this->
getSurveyId(),
"integer").
6311 " AND user_id = ".$ilDB->quote($a_user_id,
"integer"));
6314 include_once(
"./Services/Skill/classes/class.ilSkillManagementSettings.php");
6318 include_once(
"./Modules/Survey/classes/class.ilSurveySkill.php");
6320 $sskill->writeAppraiseeSkills($a_user_id);
6328 $ilDB->manipulate(
"UPDATE svy_360_appr".
6329 " SET has_closed = ".$ilDB->quote(null,
"integer").
6330 " WHERE obj_id = ".$ilDB->quote($this->
getSurveyId(),
"integer"));
6335 if(!isset(
$_SESSION[
"360_extrtr"][$a_ref_id]))
6337 $svy =
new self($a_ref_id);
6340 if($svy->canStartSurvey(null,
true) &&
6341 $svy->get360Mode() &&
6342 $svy->isAnonymousKey($a_code))
6344 $anonymous_id = $svy->getAnonymousIdByCode($a_code);
6347 if(
sizeof($svy->getAppraiseesToRate(null, $anonymous_id)))
6349 $_SESSION[
"360_extrtr"][$a_ref_id] =
true;
6355 $_SESSION[
"360_extrtr"][$a_ref_id] =
false;
6359 return $_SESSION[
"360_extrtr"][$a_ref_id];
6374 $this->reminder_status = (bool)$a_value;
6384 $this->reminder_start = $a_value;
6394 $this->reminder_end = $a_value;
6404 $this->reminder_frequency = (int)$a_value;
6414 $this->reminder_target = (int)$a_value;
6424 $this->reminder_last_sent = $a_value;
6434 $this->tutor_ntf_status = (bool)$a_value;
6444 $this->tutor_ntf_recipients = $a_value;
6454 $this->tutor_ntf_target = (int)$a_value;
6466 $set = $ilDB->query(
"SELECT COUNT(*) numall FROM svy_finished".
6467 " WHERE survey_fi = ".$ilDB->quote($this->getSurveyId(),
"integer").
6468 " AND state = ".$ilDB->quote(1,
"integer").
6469 " AND ".$ilDB->in(
"user_fi", $user_ids,
"",
"integer"));
6470 $row = $ilDB->fetchAssoc($set);
6471 if(
$row[
"numall"] ==
sizeof($user_ids))
6483 if((
bool)$a_use_invited)
6489 $parent_grp_ref_id = $tree->checkForParentType($this->
getRefId(),
"grp");
6490 if($parent_grp_ref_id)
6492 include_once
"Modules/Group/classes/class.ilGroupParticipants.php";
6494 $user_ids = $part->getMembers();
6498 $parent_crs_ref_id = $tree->checkForParentType($this->
getRefId(),
"crs");
6499 if($parent_crs_ref_id)
6501 include_once
"Modules/Course/classes/class.ilCourseParticipants.php";
6503 $user_ids = $part->getMembers();
6512 include_once
"./Services/Mail/classes/class.ilMail.php";
6513 include_once
"./Services/User/classes/class.ilObjUser.php";
6514 include_once
"./Services/Language/classes/class.ilLanguageFactory.php";
6515 include_once
"./Services/User/classes/class.ilUserUtil.php";
6516 include_once
"./Services/Link/classes/class.ilLink.php";
6523 $ulng->loadLanguageModule(
'survey');
6525 $subject = sprintf($ulng->txt(
'survey_notification_tutor_subject'), $this->
getTitle());
6528 $message .= $ulng->txt(
'survey_notification_tutor_body').
":\n\n";
6529 $message .= $ulng->txt(
'obj_svy').
": ". $this->
getTitle().
"\n";
6530 $message .=
"\n".$ulng->txt(
'survey_notification_tutor_link').
": ".$link;
6532 $mail_obj =
new ilMail(ANONYMOUS_USER_ID);
6533 $mail_obj->appendInstallationSignature(
true);
6535 "",
"", $subject, $message, array(), array(
"system"));
6541 global
$ilDB, $ilAccess;
6544 $now_with_format = date(
"YmdHis", $now);
6545 $today = date(
"Y-m-d");
6567 if($today < $start ||
6568 ($end && $today > $end))
6574 include_once
"Services/Object/classes/class.ilObjectActivation.php";
6577 ($now < $item_data[
"timing_start"] ||
6578 $now > $item_data[
"timing_end"]))
6589 $missing_ids = array();
6596 $finished_ids = array();
6597 $set = $ilDB->query(
"SELECT user_fi FROM svy_finished".
6598 " WHERE survey_fi = ".$ilDB->quote($this->getSurveyId(),
"integer").
6599 " AND state = ".$ilDB->quote(1,
"text").
6600 " AND ".$ilDB->in(
"user_fi", $user_ids,
"",
"integer"));
6601 while(
$row = $ilDB->fetchAssoc($set))
6603 $finished_ids[] =
$row[
"user_fi"];
6607 $missing_ids = array_diff($user_ids, $finished_ids);
6610 foreach($missing_ids as $idx => $user_id)
6613 if(!$ilAccess->checkAccessOfUser($user_id,
"read",
"", $this->getRefId(),
"svy", $this->
getId()))
6615 unset($missing_ids[$idx]);
6628 return sizeof($missing_ids);
6636 include_once
"./Services/Mail/classes/class.ilMail.php";
6637 include_once
"./Services/User/classes/class.ilObjUser.php";
6638 include_once
"./Services/Language/classes/class.ilLanguageFactory.php";
6639 include_once
"./Services/User/classes/class.ilUserUtil.php";
6640 include_once
"./Services/Link/classes/class.ilLink.php";
6643 foreach($a_recipient_ids as $user_id)
6647 $ulng->loadLanguageModule(
'survey');
6649 $subject = sprintf($ulng->txt(
'survey_reminder_subject'), $this->
getTitle());
6652 $message .= $ulng->txt(
'survey_reminder_body').
":\n\n";
6653 $message .= $ulng->txt(
'obj_svy').
": ". $this->
getTitle().
"\n";
6654 $message .=
"\n".$ulng->txt(
'survey_reminder_link').
": ".$link;
6656 $mail_obj =
new ilMail(ANONYMOUS_USER_ID);
6657 $mail_obj->appendInstallationSignature(
true);
6659 "",
"", $subject, $message, array(), array(
"system"));
6665 $this->activation_starting_time = $starting_time;
6670 $this->activation_ending_time = $ending_time;
6675 return (strlen($this->activation_starting_time)) ? $this->activation_starting_time : NULL;
6680 return (strlen($this->activation_ending_time)) ? $this->activation_ending_time : NULL;
6685 $this->view_own_results = (bool)$a_value;
6695 $this->mail_own_results = (bool)$a_value;
6709 include_once
"./Services/Administration/classes/class.ilSetting.php";
6710 $surveySetting =
new ilSetting(
"survey");
6711 if(!$surveySetting->get(
"skipped_is_custom",
false))
6713 return $lng->txt(
"skipped");
6717 return $surveySetting->get(
"skipped_custom_value",
"");
createSurveyCodes($nrOfCodes)
showQuestionTitles()
Sets the question titles visible during the query.
sendNotificationMail($user_id, $anonymize_id, $appr_id)
static _lookupLogin($a_user_id)
lookup login
getTutorNotificationTarget()
static _lookupName($a_user_id)
lookup user name
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.
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)
_getQuestionblock($questionblock_id)
Returns the database row for a given question block.
read($a_force_db=false)
read object data from db into object
setEndDateAndTime($end_date="", $end_time)
Sets the end date of the survey.
isAnonymizedParticipant($key)
& 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)
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...
& 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.
isAllowedToTakeMultipleSurveys($userid="")
Checks if a user is allowed to take multiple survey.
setReminderLastSent($a_value)
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)
setMailNotification($a_notification)
& _getUsedHTMLTagsAsString($a_module="")
Returns a string of all allowed HTML tags for text editing.
disinviteAllUsers()
Disinvite all users.
Skill management settings.
saveUserSettings($usr_id, $key, $title, $value)
getConstraints($question_id)
Returns the constraints to a given question or questionblock.
const EVALUATION_ACCESS_PARTICIPANTS
isOffline()
Gets the survey status.
setTutorNotificationTarget($a_value)
static _getStaticLink($a_ref_id, $a_type='', $a_fallback_goto=true, $append="")
Get static link.
static getSurveySkippedValue()
getQuestionblock($questionblock_id)
Returns the database row for a given question block.
deleteSurveyCode($survey_code)
Deletes a given survey access code.
getWorkingtimeForParticipant($finished_id)
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.
& getSurveyParticipants($finished_ids=null)
isComplete()
Returns 1, if a survey is complete for use.
removeQuestions($remove_questions, $remove_questionblocks)
Remove questions from the survey.
getAnonymousIdByCode($a_code)
Class ilObject Basic functions for all objects.
isAccessibleWithoutCode()
Checks if the survey is accessable without a survey code.
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.
setAuthor($author="")
Sets the authors name of the ilObjSurvey object.
isOnline()
Gets the survey status.
const TIMINGS_DEACTIVATED
static is_email($a_email)
This preg-based function checks whether an e-mail address is formally valid.
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.
prepareTextareaOutput($txt_output)
Prepares a string for a text area output in surveys.
& 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)
getUserAccessCode($user_id)
Returns a survey access code that was saved for a registered user.
closeAppraisee($a_user_id)
bindSurveyCodeToUser($user_id, $code)
moveUpQuestionblock($questionblock_id)
Moves a questionblock up in the list of survey questions.
setTutorNotificationStatus($a_value)
Survey Question Import Parser.
_addQuestionblock($title="", $owner=0, $show_questiontext=true, $show_blocktitle=false)
Adds a questionblock to the database.
setObligatoryStates($obligatory_questions)
Sets the obligatory states for questions in a survey from the questions form.
_cleanupMediaObjectUsage($a_text, $a_usage_type, $a_usage_id)
synchronises appearances of media objects in $a_text with media object usage table ...
getOwner()
get object owner
set360SkillService($a_val)
Set skill service.
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
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...
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.
inviteRole($role_id)
Invites a role to a survey.
addRater($a_appraisee_id, $a_user_id, $a_anonymous_id=0)
_lookupFullname($a_user_id)
Lookup Full Name.
& processCSVRow($row, $quoteAll=FALSE, $separator=";")
Processes an array as a CSV row and converts the array values to correct CSV values.
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.
moveUpQuestion($question_id)
Moves a question up in the list of survey questions.
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)
& getUserSpecificResults($finished_ids)
Calculates the evaluation data for the user specific results.
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.
cloneObject($a_target_id, $a_copy_id=0)
Clone object.
deleteSurveyRecord()
Deletes the survey from the database.
updateConstraint($precondition_id, $if_question_id, $relation, $value, $conjunction)
Updates a precondition.
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)
Default behaviour is:
isPluginActive($a_pname)
Checks whether or not a question plugin with a given name is active.
disinviteUser($user_id)
Disinvites a user from a survey.
getSurveyCodesCount()
Returns the number of generated survey codes for the survey.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
hasAnonymizedResults()
Checks if the survey results are to be anonymized.
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.
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.
_getLastAccess($finished_id)
getId()
get object id public
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.
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.
const NOTIFICATION_PARENT_COURSE
setMailParticipantData($a_data)
setActivationStartDate($starting_time=NULL)
& getObligatoryStates()
Gets specific obligatory states of the survey.
static _lookupDescription($a_id)
lookup object description
getFinishedIdsForAppraiseeId($a_appr_id, $a_exclude_appraisee=false)
Class Mail this class handles base functions for mail handling.
updateCode($a_id, $a_email, $a_last_name, $a_first_name, $a_sent)
notify($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
notifys an object about an event occured Based on the event happend, each object may decide how it re...
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
updateOrder(array $a_order)
getEvaluationAccess()
Gets the learners evaluation access.
static _lookupObjId($a_id)
setActivationVisibility($a_value)
addQuestion($question_id)
Adds a question to the survey.
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
static & _getQuestionGUI($questiontype, $question_id=-1)
Creates a question gui representation.
& getQuestions($question_ids)
getQuestionType($question_id)
Returns the question type of a question with a given id.
setMailOwnResults($a_value)
setReminderStart(ilDate $a_value=null)
static formatDate(ilDateTime $date)
Format a date public.
setTutorNotificationRecipients(array $a_value)
setStatus($status=self::STATUS_OFFLINE)
Sets the survey status.
setIntroduction($introduction="")
Sets the introduction text.
getTitle()
get object title public
ilObjSurvey($a_id=0, $a_call_by_reference=true)
Constructor public.
static _dropDesktopItem($a_usr_id, $a_item_id, $a_type)
drop an item from user's personal desktop
getDescription()
get object description
set360SelfRaters($a_value)
getShowQuestionTitles()
Gets the status of the display_question_titles attribute.
redirection script todo: (a better solution should control the processing via a xml file) ...
cloneMetaData($target_obj)
Copy meta data.
toXML()
Returns a QTI xml representation of the survey.
xmlHeader()
Writes xml header public.
& 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
_lookupEmail($a_user_id)
Lookup email.
getUserDataFromActiveId($active_id)
Returns the user information from an active_id (survey_finished.finished_id)
setSurveyId($survey_id)
Sets the survey id.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
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
fillSurveyForUser($user_id=ANONYMOUS_USER_ID)
Fills a survey randomly with data for a given user.
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.
createImportDirectory()
creates data directory for import files (data_dir/svy_data/svy_<id>/import, depending on data directo...
& getQuestionpoolTitles($could_be_offline=FALSE, $showPath=FALSE)
Get the titles of all available survey question pools.
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.
& getUserData($ids)
Returns a data of all users specified by id list.
getStatus()
Gets the survey status.
finishSurvey($finished_id)
Finishes the survey creating an entry in the database.
const EVALUATION_ACCESS_ALL
& _getGlobalSurveyData($obj_id)
Returns an array with data needed in the repository, personal desktop or courses. ...
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.
static factory($a_package)
Create an XML_RPC2 client instance.
saveCompletionStatus()
Saves the completion status of the survey.
_getOriginalId($question_id, $a_return_question_id_if_no_original=true)
Returns the original id of a question.
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable 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
getAllRTEContent()
Returns the content of all RTE enabled text areas in the test.
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.
_getQuestionType($question_id)
Returns the question type of a question with a given id.
getQuestionsTable($arrFilter)
Calculates the data for the output of the question browser.
saveHeading($heading="", $insertbefore)
getCumulatedResults(&$question, $finished_ids)
Calculates the evaluation data for a question.
getRatersData($a_appraisee_id)
isRater($a_appraisee_id, $a_user_id, $a_anonymous_id=0)
update()
update object data
setStartDateAndTime($start_date="", $start_time)
Sets the start date of the survey.
addConstraint($if_question_id, $relation, $value, $conjunction)
Adds a constraint.
setActivationEndDate($ending_time=NULL)
saveAuthorToMetadata($a_author="")
Saves an authors name into the lifecycle metadata if no lifecycle metadata exists This will only be c...
& getAvailableQuestionpools($use_obj_id=false, $could_be_offline=false, $showPath=FALSE, $permission="read")
Returns the available question pools for the active user.
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
get360SkillService()
Get skill service.
moveDownQuestion($question_id)
Moves a question down in the list of survey questions.
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)
getOutro()
Gets the outro text.
getUserSettings($usr_id, $key)
sentReminder(array $a_recipient_ids)
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
getTutorNotificationStatus()
set360SelfAppraisee($a_value)
getUserSurveyCode($user_id)
sendCodes($not_sent, $subject, $message, $lang)
_isComplete($obj_id)
Returns 1, if a survey is complete for use.
modifyQuestionblock($questionblock_id, $title, $show_questiontext, $show_blocktitle)
Modifies a question block.
Class ilInvalidSurveyImportFileException.
_getNrOfParticipants($survey_id)
Returns the number of participants for a survey.
moveQuestions($move_questions, $target_index, $insert_mode)
Move questions and/or questionblocks to another position.
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
isPoolActive()
Get current pool status.
_isComplete($question_id)
Checks whether the question is complete or not.
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
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
_getConstraints($survey_id)
Returns the constraints to a given question or questionblock.
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
Wrapper classes for system notifications.
getDetailedParticipantResultsAsText()
isAppraiseeClosed($a_user_id)
cleanupMediaobjectUsage()
Cleans up the media objects for all text fields in a test which are using an RTE field.
startSurvey($user_id, $anonymous_id, $appraisee_id)
Starts the survey creating an entry in the database.
setAnonymize($a_anonymize)
set anonymize status
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.
deleteAllUserData()
Deletes all user data of a survey.
_getAvailableQuestionpools($use_object_id=FALSE, $could_be_offline=FALSE, $showPath=FALSE, $permission="read")
Returns the available question pools for the active user.
isSurveyStarted($user_id, $anonymize_id, $appr_id=0)
Checks if a user already started a survey.
loadQuestionsFromDb()
Loads the survey questions from the database.
deleteAppraisee($a_user_id)
setOutro($outro="")
Sets the outro text.
moveDownQuestionblock($questionblock_id)
Moves a questionblock down in the list of survey questions.
static & _getQuestionTypeTranslations()
inviteGroup($group_id)
Invites a group to a survey.
getPrecondition($id)
Returns a precondition with a given id.
addQuestionToBlock($question_id, $questionblock_id)