34 include_once
"./Services/Object/classes/class.ilObject.php";
35 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
157 $this->
ilObject($a_id,$a_call_by_reference);
159 $this->survey_id = -1;
160 $this->introduction =
"";
161 $this->outro = $this->lng->txt(
"survey_finished");
162 $this->author = $ilUser->fullname;
165 $this->questions = array();
170 $this->surveyCodeSecurity = TRUE;
171 $this->template_id = NULL;
172 $this->pool_usage =
true;
208 if (!parent::update())
230 function read($a_force_db =
false)
244 array_push($this->questions, $question_id);
266 foreach ($this->questions as $question_id)
285 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_svy WHERE survey_id = %s",
290 $result = $ilDB->queryF(
"SELECT questionblock_fi FROM svy_qblk_qst WHERE survey_fi = %s",
294 $questionblocks = array();
297 array_push($questionblocks,
$row[
"questionblock_fi"]);
299 if (count($questionblocks))
301 $affectedRows = $ilDB->manipulate(
"DELETE FROM svy_qblk WHERE " . $ilDB->in(
'questionblock_id', $questionblocks,
false,
'integer'));
303 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE survey_fi = %s",
309 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_anonymous WHERE survey_fi = %s",
315 include_once
"./Services/Utilities/classes/class.ilUtil.php";
317 $directory = $svy_data_dir.
"/svy_".$this->
getId();
318 if (is_dir($directory))
320 include_once
"./Services/Utilities/classes/class.ilUtil.php";
324 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
330 foreach(
$mobs as $mob)
347 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
351 $active_array = array();
354 array_push($active_array,
$row[
"finished_id"]);
357 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_finished WHERE survey_fi = %s",
362 foreach ($active_array as $active_fi)
364 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_answer WHERE active_fi = %s",
368 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_times WHERE finished_fi = %s",
384 foreach ($finished_ids as $finished_id)
386 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE finished_id = %s",
392 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_answer WHERE active_fi = %s",
394 array(
$row[
"finished_id"])
397 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_finished WHERE finished_id = %s",
402 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_times WHERE finished_fi = %s",
404 array(
$row[
"finished_id"])
413 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s",
417 $participants = array();
423 $participants[$userdata[
"sortname"] . $userdata[
"active_id"]] = $userdata;
426 return $participants;
442 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
482 if ($a_node_id==
$_GET[
"ref_id"])
484 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
485 $parent_type = $parent_obj->getType();
486 if($parent_type == $this->
getType())
488 $a_node_id = (int) $tree->getParentId($a_node_id);
492 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
503 if (($this->
getTitle()) and (count($this->questions)))
522 $survey->loadFromDb();
523 if (($survey->getTitle()) and (count($survey->questions)))
542 $survey->loadFromDb();
544 if (($survey->getTitle()) and ($survey->author) and (count($survey->questions)))
552 $result[
"evaluation_access"] = $survey->getEvaluationAccess();
572 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_svy SET complete = %s, tstamp = %s WHERE survey_id = %s",
573 array(
'text',
'integer',
'integer'),
591 $question_gui = $this->
getQuestionGUI($questiontype, $question_id);
594 if($this->
getId() == $question_gui->object->getObjId() && !$a_force)
599 $duplicate_id = $question_gui->object->duplicate(
true);
600 return $duplicate_id;
612 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
620 $result = $ilDB->queryF(
"SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
624 $sequence =
$result->numRows();
626 $next_id = $ilDB->nextId(
'svy_svy_qst');
627 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_svy_qst (survey_question_id, survey_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
628 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
629 array($next_id, $this->
getSurveyId(), $duplicate_id, $sequence, time())
645 $result = $ilDB->queryF(
"SELECT svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.show_blocktitle,".
646 " svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst, svy_svy_qst".
647 " WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi".
648 " AND svy_svy_qst.question_fi = svy_qblk_qst.question_fi".
649 " AND svy_qblk.questionblock_id = %s".
650 " ORDER BY svy_svy_qst.sequence",
652 array($questionblock_id)
655 $show_questiontext = 0;
656 $show_blocktitle = 0;
662 $show_questiontext =
$row[
"show_questiontext"];
663 $show_blocktitle =
$row[
"show_blocktitle"];
688 include_once(
"./Services/RTE/classes/class.ilRTE.php");
689 $completecontent =
"";
692 $completecontent .= $content;
702 $next_id = $ilDB->nextId(
'svy_settings');
703 $affectedRows = $ilDB->insert(
"svy_settings", array(
704 "settings_id" => array(
"integer", $next_id),
705 "usr_id" => array(
"integer",
$usr_id),
706 "keyword" => array(
"text", $key),
707 "title" => array(
"text",
$title),
708 "value" => array(
"clob", $value)
716 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_settings WHERE settings_id = %s",
720 return $affectedRows;
727 $result = $ilDB->queryF(
"SELECT * FROM svy_settings WHERE usr_id = %s AND keyword = %s",
728 array(
'integer',
'text'),
751 include_once(
"./Services/RTE/classes/class.ilRTE.php");
754 $next_id = $ilDB->nextId(
'svy_svy');
755 $affectedRows = $ilDB->insert(
"svy_svy", array(
756 "survey_id" => array(
"integer", $next_id),
757 "obj_fi" => array(
"integer", $this->
getId()),
758 "author" => array(
"text", $this->
getAuthor()),
761 "status" => array(
"text", $this->
getStatus()),
763 "enddate" => array(
"text", $this->
getEndDate()),
767 "complete" => array(
"text", $this->
isComplete()),
768 "created" => array(
"integer", time()),
774 "tstamp" => array(
"integer", time()),
775 "template_id" => array(
"integer", $this->
getTemplate()),
782 $affectedRows = $ilDB->update(
"svy_svy", array(
783 "author" => array(
"text", $this->
getAuthor()),
786 "status" => array(
"text", $this->
getStatus()),
788 "enddate" => array(
"text", $this->
getEndDate()),
792 "complete" => array(
"text", $this->
isComplete()),
798 "tstamp" => array(
"integer", time()),
799 "template_id" => array(
"integer", $this->
getTemplate()),
802 "survey_id" => array(
"integer", $this->
getSurveyId())
814 include_once
"./Services/Object/classes/class.ilObjectActivation.php";
830 $item->update($this->ref_id);
844 $old_questions = array();
845 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
853 $old_questions[
$row[
"question_fi"]] =
$row;
858 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_svy_qst WHERE survey_fi = %s",
863 foreach ($this->questions as $key => $value)
865 $next_id = $ilDB->nextId(
'svy_svy_qst');
866 $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)",
867 array(
'integer',
'integer',
'integer',
'text',
'integer',
'integer'),
868 array($next_id, $this->
getSurveyId(), $value, (strlen($old_questions[$value][
"heading"])) ? $old_questions[$value][
"heading"] : NULL, $key, time())
883 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_finished WHERE anonymous_id = %s",
890 return $row[
"anonymous_id"];
906 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
920 if ($question_id < 1)
return -1;
921 $result = $ilDB->queryF(
"SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND " .
922 "svy_question.questiontype_fi = svy_qtype.questiontype_id",
929 return $data[
"type_tag"];
953 switch ($a_anonymize)
959 $this->anonymize = $a_anonymize;
974 return ($this->anonymize) ? $this->anonymize : 0;
1014 $result = $ilDB->queryF(
"SELECT * FROM svy_svy WHERE obj_fi = %s",
1016 array($this->
getId())
1023 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1025 if (strcmp(
$data[
"outro"],
"survey_finished") == 0)
1027 $this->
setOutro($this->lng->txt(
"survey_finished"));
1052 include_once
"./Services/Object/classes/class.ilObjectActivation.php";
1054 switch($activation[
"timing_type"])
1079 $this->questions = array();
1080 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
1086 $this->questions[
$data[
"sequence"]] = $data[
"question_fi"];
1114 $md_life =& $md->getLifecycle();
1117 if (strlen($a_author) == 0)
1120 $a_author = $ilUser->getFullname();
1123 $md_life =& $md->addLifecycle();
1125 $con =& $md_life->addContribute();
1126 $con->setRole(
"Author");
1128 $ent =& $con->addEntity();
1129 $ent->setEntity($a_author);
1144 include_once
"./Services/MetaData/classes/class.ilMD.php";
1146 $md_life =& $md->getLifecycle();
1149 $ids =& $md_life->getContributeIds();
1150 foreach ($ids as
$id)
1152 $md_cont =& $md_life->getContribute($id);
1153 if (strcmp($md_cont->getRole(),
"Author") == 0)
1155 $entids =& $md_cont->getEntityIds();
1156 foreach ($entids as $entid)
1158 $md_ent =& $md_cont->getEntity($entid);
1159 array_push(
$author, $md_ent->getEntity());
1175 return ($this->display_question_titles) ? 1 : 0;
1186 $this->display_question_titles = ($a_show) ? 1 : 0;
1197 $this->display_question_titles = 1;
1208 $this->display_question_titles = 0;
1231 $result = $ilDB->query(
"SELECT usr_id FROM usr_data");
1234 if ($ilAccess->checkAccessOfUser(
$row[
"usr_id"],
"read",
"", $this->getRefId(),
"svy", $this->
getId()))
1312 include_once
"./Services/Administration/classes/class.ilSetting.php";
1313 $surveySetting =
new ilSetting(
"survey");
1314 $unlimited_invitation = $surveySetting->get(
"unlimited_invitation");
1315 if (!$unlimited_invitation && $this->invitation_mode ==
MODE_UNLIMITED)
1321 return ($this->invitation_mode) ? $this->invitation_mode :
MODE_UNLIMITED;
1375 $result = $this->lng->txt(
"cannot_switch_to_online_no_questions");
1393 return (strlen($this->start_date)) ? $this->start_date : NULL;
1408 $edit_settings =
false;
1410 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartDate(), $matches))
1412 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
1414 if ($now < $epoch_time)
1416 array_push(
$messages,$this->lng->txt(
'start_date_not_reached').
' ('.
1419 $edit_settings =
true;
1423 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndDate(), $matches))
1425 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
1427 if ($now > $epoch_time)
1429 array_push(
$messages,$this->lng->txt(
'end_date_reached').
' ('.
1432 $edit_settings =
true;
1439 array_push(
$messages, $this->lng->txt(
"survey_is_offline"));
1441 $edit_settings =
true;
1444 if (!$ilAccess->checkAccess(
"read",
"", $this->ref_id))
1446 array_push(
$messages, $this->lng->txt(
"cannot_participate_survey"));
1453 $survey_started = $this->
isSurveyStarted($ilUser->getId(), $anonymous_id);
1454 if ($survey_started === 1)
1456 array_push(
$messages, $this->lng->txt(
"already_completed_survey"));
1463 "edit_settings" => $edit_settings
1489 $y =
''; $m =
'';
$d =
''; $h =
''; $i =
''; $s =
'';
1490 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/",
$start_date, $matches))
1496 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $start_time, $matches))
1502 $this->start_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m,
$d, $h, $i, $s);
1514 return (strlen($this->end_date)) ? $this->end_date : NULL;
1539 $y =
''; $m =
'';
$d =
''; $h =
''; $i =
''; $s =
'';
1540 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/",
$end_date, $matches))
1546 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $end_time, $matches))
1552 $this->end_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m,
$d, $h, $i, $s);
1581 $this->activation_visibility = (bool) $a_value;
1591 return (
bool)$this->activation_limited;
1596 $this->activation_limited = (bool)$a_value;
1608 return (strlen($this->introduction)) ? $this->introduction : NULL;
1620 return (strlen($this->outro)) ? $this->outro : NULL;
1632 $existing_questions = array();
1633 $result = $ilDB->queryF(
"SELECT svy_question.original_id FROM svy_question, svy_svy_qst WHERE " .
1634 "svy_svy_qst.survey_fi = %s AND svy_svy_qst.question_fi = svy_question.question_id",
1640 if(
$data[
"original_id"])
1642 array_push($existing_questions,
$data[
"original_id"]);
1645 return $existing_questions;
1656 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1668 $move_questions = array($question_id);
1671 foreach ($pages as $idx => $page)
1673 if ($page[0][
"question_id"] == $question_id)
1680 $this->
moveQuestions($move_questions, $pages[$pageindex-1][0][
"question_id"], 0);
1687 $index = array_search($question_id,
$questions);
1688 if (($index !== FALSE) && ($index > 0))
1702 $move_questions = array($question_id);
1705 foreach ($pages as $idx => $page)
1707 if (($page[0][
"question_id"] == $question_id) && (strcmp($page[0][
"questionblock_id"],
"") == 0))
1712 if (($pageindex < count($pages)-1) && ($pageindex >= 0))
1714 $this->
moveQuestions($move_questions, $pages[$pageindex+1][count($pages[$pageindex+1])-1][
"question_id"], 1);
1721 $index = array_search($question_id,
$questions);
1722 if (($index !== FALSE) && ($index < count(
$questions)-1))
1738 $move_questions = array();
1740 foreach ($pages as $idx => $page)
1742 if ($page[0][
"questionblock_id"] == $questionblock_id)
1744 foreach ($page as $pageidx => $question)
1746 array_push($move_questions, $question[
"question_id"]);
1753 $this->
moveQuestions($move_questions, $pages[$pageindex-1][0][
"question_id"], 0);
1766 $move_questions = array();
1768 foreach ($pages as $idx => $page)
1770 if ($page[0][
"questionblock_id"] == $questionblock_id)
1772 foreach ($page as $pageidx => $question)
1774 array_push($move_questions, $question[
"question_id"]);
1779 if ($pageindex < count($pages)-1)
1781 $this->
moveQuestions($move_questions, $pages[$pageindex+1][count($pages[$pageindex+1])-1][
"question_id"], 1);
1795 $array_pos = array_search($target_index, $this->questions);
1796 if ($insert_mode == 0)
1798 $part1 = array_slice($this->questions, 0, $array_pos);
1799 $part2 = array_slice($this->questions, $array_pos);
1801 else if ($insert_mode == 1)
1803 $part1 = array_slice($this->questions, 0, $array_pos + 1);
1804 $part2 = array_slice($this->questions, $array_pos + 1);
1806 foreach ($move_questions as $question_id)
1808 if (!(array_search($question_id, $part1) === FALSE))
1810 unset($part1[array_search($question_id, $part1)]);
1812 if (!(array_search($question_id, $part2) === FALSE))
1814 unset($part2[array_search($question_id, $part2)]);
1817 $part1 = array_values($part1);
1818 $part2 = array_values($part2);
1819 $this->questions = array_values(array_merge($part1, $move_questions, $part2));
1820 foreach ($move_questions as $question_id)
1823 foreach ($constraints as $idx => $constraint)
1825 foreach ($part2 as $next_question_id)
1827 if ($constraint[
"question"] == $next_question_id)
1846 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1848 $question->delete($question_id);
1861 $result = $ilDB->queryF(
"SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
1862 array(
'integer',
'integer'),
1867 $remove_constraints = array();
1870 array_push($remove_constraints,
$row[
"constraint_fi"]);
1872 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
1873 array(
'integer',
'integer'),
1876 foreach ($remove_constraints as $key => $constraint_id)
1878 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_constraint WHERE constraint_id = %s",
1880 array($constraint_id)
1897 $block_sizes = array();
1900 if (in_array($question_id, $remove_questions) or in_array(
$data[
"questionblock_id"], $remove_questionblocks))
1902 unset($this->questions[array_search($question_id, $this->questions)]);
1905 else if(
$data[
"questionblock_id"])
1907 $block_sizes[
$data[
"questionblock_id"]]++;
1912 foreach($block_sizes as $block_id =>
$size)
1916 $remove_questionblocks[] = $block_id;
1920 foreach (array_unique($remove_questionblocks) as $questionblock_id)
1922 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk WHERE questionblock_id = %s",
1924 array($questionblock_id)
1926 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
1927 array(
'integer',
'integer'),
1932 $this->questions = array_values($this->questions);
1945 foreach ($questionblocks as $index)
1947 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk WHERE questionblock_id = %s",
1951 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
1952 array(
'integer',
'integer'),
1962 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s AND question_fi = %s",
1963 array(
'integer',
'integer',
'integer'),
1964 array($questionblock_id, $this->
getSurveyId(), $question_id)
1973 $next_id = $ilDB->nextId(
'svy_qblk_qst');
1974 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
1975 "question_fi) VALUES (%s, %s, %s, %s)",
1976 array(
'integer',
'integer',
'integer',
'integer'),
1977 array($next_id, $this->
getSurveyId(), $questionblock_id, $question_id)
1993 $result = $ilDB->queryF(
"SELECT svy_question.title, svy_qblk_qst.question_fi, svy_qblk_qst.survey_fi FROM ".
1994 "svy_qblk, svy_qblk_qst, svy_question WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND " .
1995 "svy_question.question_id = svy_qblk_qst.question_fi AND svy_qblk.questionblock_id = %s",
1997 array($questionblock_id)
2002 $titles[
$row[
"question_fi"]] = $row[
"title"];
2005 $result = $ilDB->queryF(
"SELECT question_fi, sequence FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
2009 $resultarray = array();
2013 if (array_key_exists(
$row[
"question_fi"], $titles))
2015 $resultarray[$counter++] = $titles[
$row[
"question_fi"]];
2018 return $resultarray;
2030 $result = $ilDB->queryF(
"SELECT question_fi FROM svy_qblk_qst WHERE questionblock_fi = %s",
2032 array($questionblock_id)
2039 array_push($ids,
$data[
'question_fi']);
2055 $result = $ilDB->queryF(
"SELECT * FROM svy_qblk WHERE questionblock_id = %s",
2057 array($questionblock_id)
2059 return $ilDB->fetchAssoc(
$result);
2072 $result = $ilDB->queryF(
"SELECT * FROM svy_qblk WHERE questionblock_id = %s",
2074 array($questionblock_id)
2091 $next_id = $ilDB->nextId(
'svy_qblk');
2092 $ilDB->manipulateF(
"INSERT INTO svy_qblk (questionblock_id, title, show_questiontext,".
2093 " show_blocktitle, owner_fi, tstamp) " .
2094 "VALUES (%s, %s, %s, %s, %s, %s)",
2095 array(
'integer',
'text',
'integer',
'integer',
'integer',
'integer'),
2096 array($next_id,
$title, $show_questiontext, $show_blocktitle,
$owner, time())
2118 $next_id = $ilDB->nextId(
'svy_qblk');
2119 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk (questionblock_id, title, show_questiontext,".
2120 " show_blocktitle, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
2121 array(
'integer',
'text',
'text',
'text',
'integer',
'integer'),
2122 array($next_id,
$title, $show_questiontext, $show_blocktitle, $ilUser->getId(), time())
2126 $questionblock_id = $next_id;
2129 $next_id = $ilDB->nextId(
'svy_qblk_qst');
2130 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
2131 "question_fi) VALUES (%s, %s, %s, %s)",
2132 array(
'integer',
'integer',
'integer',
'integer'),
2133 array($next_id, $this->
getSurveyId(), $questionblock_id, $index)
2150 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_qblk SET title = %s, show_questiontext = %s,".
2151 " show_blocktitle = %s WHERE questionblock_id = %s",
2152 array(
'text',
'text',
'text',
'integer'),
2153 array(
$title, $show_questiontext, $show_blocktitle, $questionblock_id)
2166 $result = $ilDB->queryF(
"SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
2167 array(
'integer',
'integer'),
2170 $constraints = array();
2173 array_push($constraints,
$row[
"constraint_fi"]);
2175 foreach ($constraints as $constraint_id)
2191 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_constraint WHERE constraint_id = %s",
2193 array($constraint_id)
2195 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_constraint WHERE constraint_fi = %s",
2197 array($constraint_id)
2211 $all_questions = array();
2212 $result = $ilDB->queryF(
"SELECT svy_qtype.type_tag, svy_qtype.plugin, svy_question.question_id, ".
2213 "svy_svy_qst.heading FROM svy_qtype, svy_question, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
2214 "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
2215 "ORDER BY svy_svy_qst.sequence",
2219 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
2233 $questionrow = $question->_getQuestionDataArray(
$row[
"question_id"]);
2234 foreach (
$row as $key => $value)
2236 $questionrow[$key] = $value;
2238 $all_questions[
$row[
"question_id"]] = $questionrow;
2239 $all_questions[$row[
"question_id"]][
"usableForPrecondition"] = $question->usableForPrecondition();
2240 $all_questions[$row[
"question_id"]][
"availableRelations"] = $question->getAvailableRelations();
2241 if (array_key_exists($row[
"question_id"], $obligatory_states))
2243 $all_questions[$row[
"question_id"]][
"obligatory"] = $obligatory_states[$row[
"question_id"]];
2248 $questionblocks = array();
2249 if (count($all_questions))
2251 $result = $ilDB->queryF(
"SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst WHERE " .
2252 "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
2253 "AND " . $ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions),
false,
'integer'),
2259 $questionblocks[
$row[
'question_fi']] =
$row;
2263 foreach ($all_questions as $question_id =>
$row)
2266 if (isset($questionblocks[$question_id]))
2268 $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
2269 $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
2270 $all_questions[$question_id][
"constraints"] = $constraints;
2274 $all_questions[$question_id][
"questionblock_title"] =
"";
2275 $all_questions[$question_id][
"questionblock_id"] =
"";
2276 $all_questions[$question_id][
"constraints"] = $constraints;
2281 $result = $ilDB->queryF(
"SELECT svy_variable.*, svy_category.title FROM svy_variable, svy_category " .
2282 "WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id ".
2283 "ORDER BY sequence ASC",
2291 array_push($answers,
$data[
"title"]);
2294 $all_questions[$question_id][
"answers"] = $answers;
2297 return $all_questions;
2309 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
2317 if (!array_key_exists(
$row[
"question_fi"], $obligatory_questions))
2319 $obligatory_questions[
$row[
"question_fi"]] = 0;
2325 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_oblig WHERE survey_fi = %s",
2331 foreach ($obligatory_questions as $question_fi => $obligatory)
2333 $next_id = $ilDB->nextId(
'svy_qst_oblig');
2334 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, " .
2335 "obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)",
2336 array(
'integer',
'integer',
'integer',
'text',
'integer'),
2337 array($next_id, $this->
getSurveyId(), $question_fi, (strlen($obligatory)) ? $obligatory : 0, time())
2341 $ilDB->manipulate(
"UPDATE svy_question".
2342 " SET obligatory = ".$ilDB->quote($obligatory,
"integer").
2343 " WHERE question_id = ".$ilDB->quote($question_fi,
"integer"));
2356 $obligatory_states = array();
2357 $result = $ilDB->queryF(
"SELECT * FROM svy_qst_oblig WHERE survey_fi = %s",
2365 $obligatory_states[
$row[
"question_fi"]] = $row[
"obligatory"];
2368 return $obligatory_states;
2381 $all_questions = array();
2382 $result = $ilDB->queryF(
"SELECT svy_question.*, svy_qtype.type_tag, svy_svy_qst.heading FROM " .
2383 "svy_question, svy_qtype, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
2384 "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id ".
2385 "ORDER BY svy_svy_qst.sequence",
2391 $all_questions[
$row[
"question_id"]] =
$row;
2394 $questionblocks = array();
2395 if (count($all_questions))
2397 $result = $ilDB->queryF(
"SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst ".
2398 "WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s ".
2399 "AND " . $ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions),
false,
'integer'),
2405 $questionblocks[
$row[
'question_fi']] =
$row;
2409 $all_pages = array();
2412 foreach ($all_questions as $question_id =>
$row)
2414 if (array_key_exists($question_id, $obligatory_states))
2416 $all_questions[$question_id][
"obligatory"] = $obligatory_states[$question_id];
2418 $constraints = array();
2419 if (isset($questionblocks[$question_id]))
2421 if (!$currentblock or ($currentblock != $questionblocks[$question_id][
'questionblock_id']))
2425 $all_questions[$question_id][
'page'] = $pageindex;
2426 $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
2427 $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
2428 $all_questions[$question_id][
"questionblock_show_questiontext"] = $questionblocks[$question_id][
'show_questiontext'];
2429 $all_questions[$question_id][
"questionblock_show_blocktitle"] = $questionblocks[$question_id][
'show_blocktitle'];
2430 $currentblock = $questionblocks[$question_id][
'questionblock_id'];
2432 $all_questions[$question_id][
"constraints"] = $constraints;
2437 $all_questions[$question_id][
'page'] = $pageindex;
2438 $all_questions[$question_id][
"questionblock_title"] =
"";
2439 $all_questions[$question_id][
"questionblock_id"] =
"";
2440 $all_questions[$question_id][
"questionblock_show_questiontext"] = 1;
2441 $all_questions[$question_id][
"questionblock_show_blocktitle"] = 1;
2444 $all_questions[$question_id][
"constraints"] = $constraints;
2446 if (!isset($all_pages[$pageindex]))
2448 $all_pages[$pageindex] = array();
2450 array_push($all_pages[$pageindex], $all_questions[$question_id]);
2453 $max = count($all_pages);
2455 foreach ($all_pages as $index => $block)
2457 foreach ($block as $blockindex => $question)
2459 $all_pages[$index][$blockindex][
"position"] = $counter / $max;
2478 if (strcmp($active_page_question_id,
"") == 0)
2482 foreach ($pages as $key => $question_array)
2484 foreach ($question_array as $question)
2486 if ($active_page_question_id == $question[
"question_id"])
2492 if ($foundpage == -1)
2498 $foundpage += $direction;
2503 if ($foundpage >= count($pages))
2507 return $pages[$foundpage];
2519 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
2532 $result_array = array();
2533 $result = $ilDB->queryF(
"SELECT svy_constraint.*, svy_relation.* FROM svy_qst_constraint, svy_constraint, ".
2534 "svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id AND ".
2535 "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_constraint.constraint_id = %s",
2542 $pc = $ilDB->fetchAssoc(
$result);
2556 $result_array = array();
2557 $result = $ilDB->queryF(
"SELECT svy_constraint.*, svy_relation.* FROM svy_qst_constraint, svy_constraint, svy_relation ".
2558 "WHERE svy_constraint.relation_fi = svy_relation.relation_id AND ".
2559 "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.question_fi = %s ".
2560 "AND svy_qst_constraint.survey_fi = %s",
2561 array(
'integer',
'integer'),
2566 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
2569 $question =
new $question_type();
2570 $question->loadFromDb(
$row[
"question_fi"]);
2571 $valueoutput = $question->getPreconditionValueOutput(
$row[
"value"]);
2572 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));
2574 return $result_array;
2585 $result_array = array();
2586 $result = $ilDB->queryF(
"SELECT svy_qst_constraint.question_fi as for_question, svy_constraint.*, svy_relation.* ".
2587 "FROM svy_qst_constraint, svy_constraint, svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id ".
2588 "AND svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.survey_fi = %s",
2594 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']));
2596 return $result_array;
2609 $result_array = array();
2610 $result = $ilDB->queryF(
"SELECT svy_variable.*, svy_category.title FROM svy_variable LEFT JOIN ".
2611 "svy_category ON svy_variable.category_fi = svy_category.category_id WHERE svy_variable.question_fi = %s ".
2612 "ORDER BY svy_variable.sequence",
2618 $result_array[
$row->sequence] =
$row;
2620 return $result_array;
2635 $next_id = $ilDB->nextId(
'svy_constraint');
2636 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_constraint (constraint_id, question_fi, relation_fi, value, conjunction) VALUES ".
2637 "(%s, %s, %s, %s, %s)",
2638 array(
'integer',
'integer',
'integer',
'float',
'integer'),
2639 array($next_id, $if_question_id, $relation, $value, $conjunction)
2662 $next_id = $ilDB->nextId(
'svy_qst_constraint');
2663 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qst_constraint (question_constraint_id, survey_fi, question_fi, ".
2664 "constraint_fi) VALUES (%s, %s, %s, %s)",
2665 array(
'integer',
'integer',
'integer',
'integer'),
2666 array($next_id, $this->
getSurveyId(), $to_question_id, $constraint_id)
2683 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_constraint SET question_fi = %s, relation_fi = %s, value = %s, conjunction = %s ".
2684 "WHERE constraint_id = %s",
2685 array(
'integer',
'integer',
'float',
'integer',
'integer'),
2686 array($if_question_id, $relation, $value, $conjunction, $precondition_id)
2695 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_constraint SET conjunction = %s ".
2696 "WHERE constraint_id IN (SELECT constraint_fi FROM svy_qst_constraint WHERE svy_qst_constraint.question_fi = %s)",
2697 array(
'integer',
'integer'),
2698 array($conjunction, $question_id)
2713 $custom_order = array(
"equal",
"not_equal",
"less",
"less_or_equal",
"more",
"more_or_equal");
2714 $custom_order = array_flip($custom_order);
2716 $result_array = array();
2717 $result = $ilDB->query(
"SELECT * FROM svy_relation");
2722 $result_array[
$row[
"shortname"]] = array(
"short" => $row[
"shortname"],
"long" => $row[
"longname"],
"id" => $row[
"relation_id"],
"order" => $custom_order[$row[
"longname"]]);
2726 $result_array[
$row[
"relation_id"]] = array(
"short" => $row[
"shortname"],
"long" => $row[
"longname"],
"order" => $custom_order[$row[
"longname"]]);
2731 foreach($result_array as $idx => $item)
2733 unset($result_array[$idx][
"order"]);
2736 return $result_array;
2745 $result = $ilDB->queryF(
"SELECT user_fi FROM svy_inv_usr WHERE survey_fi = %s",
2764 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_inv_usr WHERE survey_fi = %s AND user_fi = %s",
2765 array(
'integer',
'integer'),
2768 include_once
'./Services/User/classes/class.ilObjUser.php';
2782 $result = $ilDB->queryF(
"SELECT user_fi FROM svy_inv_usr WHERE user_fi = %s AND survey_fi = %s",
2783 array(
'integer',
'integer'),
2788 $next_id = $ilDB->nextId(
'svy_inv_usr');
2789 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_inv_usr (invited_user_id, survey_fi, user_fi, tstamp) " .
2790 "VALUES (%s, %s, %s, %s)",
2791 array(
'integer',
'integer',
'integer',
'integer'),
2792 array($next_id, $this->
getSurveyId(), $user_id, time())
2797 include_once
'./Services/User/classes/class.ilObjUser.php';
2812 include_once
"./Modules/Group/classes/class.ilObjGroup.php";
2814 $members = $group->getGroupMemberIds();
2815 foreach ($members as $user_id)
2817 if ($ilAccess->checkAccessOfUser($user_id,
"read",
"", $this->getRefId(),
"svy", $this->
getId()))
2822 include_once
'./Services/User/classes/class.ilObjUser.php';
2841 $members = $rbacreview->assignedUsers($role_id);
2842 foreach ($members as $user_id)
2844 if ($ilAccess->checkAccessOfUser($user_id,
"read",
"", $this->getRefId(),
"svy", $this->
getId()))
2849 include_once
'./Services/User/classes/class.ilObjUser.php';
2867 $result_array = array();
2868 $result = $ilDB->queryF(
"SELECT user_fi FROM svy_inv_usr WHERE survey_fi = %s",
2874 array_push($result_array,
$row[
"user_fi"]);
2876 return $result_array;
2890 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
2891 array(
'integer',
'integer'),
2892 array($question_id, $active_id)
2907 $result_array = array();
2908 $result = $ilDB->queryF(
"SELECT * FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
2909 array(
'integer',
'integer'),
2910 array($question_id, $active_id)
2916 array_push($result_array,
$row);
2918 return $result_array;
2922 return $result_array;
2939 $active_id = $ilDB->nextId(
'svy_finished');
2940 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_finished (finished_id, survey_fi, user_fi, anonymous_id, state, tstamp) ".
2941 "VALUES (%s, %s, %s, %s, %s, %s)",
2942 array(
'integer',
'integer',
'integer',
'text',
'text',
'integer'),
2943 array($active_id, $this->
getSurveyId(), $user_id, $anonymous_id, 1, time())
2947 foreach ($pages as $key => $question_array)
2949 foreach ($question_array as $question)
2952 require_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
2954 $question->saveRandomData($active_id);
2970 if ($this->
getAnonymize() && (strlen($anonymous_id) == 0))
return;
2972 if (strcmp($user_id,
"") == 0)
2974 if ($user_id == ANONYMOUS_USER_ID)
2979 $next_id = $ilDB->nextId(
'svy_finished');
2980 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_finished (finished_id, survey_fi, user_fi, anonymous_id, state, tstamp) ".
2981 "VALUES (%s, %s, %s, %s, %s, %s)",
2982 array(
'integer',
'integer',
'integer',
'text',
'text',
'integer'),
2983 array($next_id, $this->
getSurveyId(), $user_id, $anonymous_id, 0, time())
3000 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_finished SET state = %s, user_fi = %s, tstamp = %s ".
3001 "WHERE survey_fi = %s AND anonymous_id = %s",
3002 array(
'text',
'integer',
'integer',
'integer',
'text'),
3003 array(1, $user_id, time(), $this->
getSurveyId(), $anonymize_id)
3008 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_finished SET state = %s, tstamp = %s WHERE survey_fi = %s AND user_fi = %s",
3009 array(
'text',
'integer',
'integer',
'integer'),
3030 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_finished SET lastpage = %s WHERE finished_id = %s",
3031 array(
'integer',
'integer'),
3032 array(($page_id) ? $page_id : 0, $finished_id)
3038 include_once
"./Services/User/classes/class.ilObjUser.php";
3039 include_once
"./Services/Mail/classes/class.ilMail.php";
3042 $placeholders = array(
3043 "FIRST_NAME" =>
"firstname",
3044 "LAST_NAME" =>
"lastname",
3047 "firstname" =>
"firstname"
3050 $mail =
new ilMail(ANONYMOUS_USER_ID);
3051 $recipients = preg_split(
'/,/', $this->mailaddresses);
3052 foreach ($recipients as $recipient)
3057 foreach ($placeholders as $key => $mapping)
3061 $messagetext = str_replace(
'[' . $key .
']',
'', $messagetext);
3065 $messagetext = str_replace(
'[' . $key .
']', trim(
$data[$mapping]), $messagetext);
3068 $active_id = $this->
getActiveID($user_id, $anonymize_id);
3069 $messagetext .= ((strlen($messagetext)) ?
"\n\n\n" :
'') . $this->lng->txt(
'results') .
"\n\n". $this->
getParticipantTextResults($active_id);
3072 include_once
"./Services/Link/classes/class.ilLink.php";
3074 $messagetext .=
"\n\n".$this->lng->txt(
'obj_svy').
": ". $this->
getTitle().
"\n";
3075 $messagetext .=
"\n".$this->lng->txt(
'survey_notification_tutor_link').
": ".$link;
3076 $mail->appendInstallationSignature(
true);
3082 $this->lng->txt(
'finished_mail_subject') .
': ' . $this->
getTitle(),
3095 $questioncounter = 1;
3096 foreach (
$questions as $question_id => $question_data)
3098 $textresult .= $questioncounter++ .
". " . $question_data[
"title"] .
"\n";
3099 $found = $userResults[$question_id][$active_id];
3101 if (is_array($found))
3103 $text = implode(
"\n", $found);
3109 if (strlen($text) == 0) $text = $this->lng->txt(
"skipped");
3110 $text = str_replace(
"<br />",
"\n", $text);
3111 $textresult .= $text .
"\n\n";
3123 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3181 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
3182 array(
'integer',
'integer'),
3188 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
3189 array(
'integer',
'text'),
3196 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
3197 array(
'integer',
'integer'),
3209 return (
int)
$row[
"state"];
3228 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
3229 array(
'integer',
'integer'),
3235 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
3236 array(
'integer',
'text'),
3243 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
3244 array(
'integer',
'integer'),
3255 return $row[
"finished_id"];
3269 $result = $ilDB->queryF(
"SELECT lastpage FROM svy_finished WHERE finished_id = %s",
3280 return (
$row[
"lastpage"]) ?
$row[
"lastpage"] :
'';
3294 if (count($working_data) == 0)
3299 if ((count($working_data) == 1) and (strcmp($working_data[0][
"value"],
"") == 0))
3305 foreach ($working_data as
$data)
3307 switch ($constraint_data[
"short"])
3310 if ($data[
"value"] < $constraint_data[
"value"])
3317 if ($data[
"value"] <= $constraint_data[
"value"])
3324 if ($data[
"value"] == $constraint_data[
"value"])
3331 if ($data[
"value"] <> $constraint_data[
"value"])
3338 if ($data[
"value"] >= $constraint_data[
"value"])
3345 if ($data[
"value"] > $constraint_data[
"value"])
3364 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
3368 return (
$result->numRows()) ?
true :
false;
3382 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s",
3390 array_push($users,
$row[
"finished_id"]);
3407 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s",
3415 array_push($users,
$row);
3418 $evaluation = array();
3420 foreach (
$questions as $question_id => $question_data)
3422 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3425 $question =
new $question_type();
3426 $question->loadFromDb($question_id);
3428 $evaluation[$question_id] =
$data;
3444 $surveySetting =
new ilSetting(
"survey");
3445 $use_anonymous_id = array_key_exists(
"use_anonymous_id",
$_GET) ?
$_GET[
"use_anonymous_id"] : $surveySetting->get(
"use_anonymous_id");
3446 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE finished_id = %s",
3451 $foundrows =
$result->numRows();
3456 $name = ($use_anonymous_id) ?
$row[
"anonymous_id"] : $this->lng->txt(
"anonymous");
3458 "fullname" => $name,
3459 "sortname" => $name,
3464 "active_id" =>
"$active_id"
3468 if ((
$row[
"user_fi"] > 0) && (
$row[
"user_fi"] != ANONYMOUS_USER_ID) && ($this->
getAnonymize() == 0))
3470 include_once
'./Services/User/classes/class.ilObjUser.php';
3473 $userdata[
"fullname"] = $userdata[
"sortname"] = $this->lng->txt(
"deleted_user");
3478 $userdata[
"fullname"] = $user->getFullname();
3479 $gender = $user->getGender();
3480 if (strlen($gender) == 1) $gender = $this->lng->txt(
"gender_$gender");
3481 $userdata[
"gender"] = $gender;
3482 $userdata[
"firstname"] = $user->getFirstname();
3483 $userdata[
"lastname"] = $user->getLastname();
3484 $userdata[
"sortname"] = $user->getLastname() .
", " . $user->getFirstname();
3485 $userdata[
"login"] = $user->getLogin();
3507 $result = $ilDB->queryF(
"SELECT * FROM svy_answer WHERE active_fi = %s",
3513 if (!is_array($answers[
$row[
"question_fi"]]))
3515 $answers[$row[
"question_fi"]] = array();
3517 array_push($answers[$row[
"question_fi"]], $row);
3521 "name" => $userdata[
"fullname"],
3522 "firstname" => $userdata[
"firstname"],
3523 "lastname" => $userdata[
"lastname"],
3524 "login" => $userdata[
"login"],
3525 "gender" => $userdata[
"gender"],
3526 "answers" => array()
3530 if (array_key_exists($key, $answers))
3532 $resultset[
"answers"][$key] = $answers[$key];
3536 $resultset[
"answers"][$key] = array();
3538 sort($resultset[
"answers"][$key]);
3555 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
3559 $nr_of_users =
$result->numRows();
3561 $result_array =& $question->getCumulatedResults($this->
getSurveyId(), $nr_of_users);
3562 return $result_array;
3576 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
3587 $result_array = array();
3588 $result = $ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype WHERE ".
3589 "svy_question.questiontype_fi = svy_qtype.questiontype_id AND svy_question.tstamp > 0 AND ".
3590 $ilDB->in(
'svy_question.question_id', $question_ids,
false,
'integer'));
3593 array_push($result_array,
$row);
3595 return $result_array;
3608 if (is_array($arrFilter))
3610 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
3612 $where .=
" AND " . $ilDB->like(
'svy_question.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
3614 if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description']))
3616 $where .=
" AND " . $ilDB->like(
'svy_question.description',
'text',
"%%" . $arrFilter[
'description'] .
"%%");
3618 if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author']))
3620 $where .=
" AND " . $ilDB->like(
'svy_question.author',
'text',
"%%" . $arrFilter[
'author'] .
"%%");
3622 if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type']))
3624 $where .=
" AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter[
'type'],
'text');
3626 if (array_key_exists(
'spl', $arrFilter) && strlen($arrFilter[
'spl']))
3628 $where .=
" AND svy_question.obj_fi = " . $ilDB->quote($arrFilter[
'spl'],
'integer');
3634 $forbidden =
" AND " . $ilDB->in(
'svy_question.obj_fi', array_keys($spls),
false,
'integer');
3635 $forbidden .=
" AND svy_question.complete = " . $ilDB->quote(
"1",
'text');
3638 if (count($existing_questions))
3640 $existing =
" AND " . $ilDB->in(
'svy_question.question_id', $existing_questions,
true,
'integer');
3643 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
3646 $query_result = $ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin, object_reference.ref_id".
3647 " FROM svy_question, svy_qtype, object_reference".
3648 " WHERE svy_question.original_id IS NULL".$forbidden.$existing.
3649 " AND svy_question.obj_fi = object_reference.obj_id AND svy_question.tstamp > 0".
3650 " AND svy_question.questiontype_fi = svy_qtype.questiontype_id " . $where);
3653 if ($query_result->numRows())
3655 while (
$row = $ilDB->fetchAssoc($query_result))
3657 if (array_key_exists(
'spl_txt', $arrFilter) && strlen($arrFilter[
'spl_txt']))
3659 if(!stristr($spls[
$row[
"obj_fi"]], $arrFilter[
'spl_txt']))
3665 $row[
'ttype'] = $trans[
$row[
'type_tag']];
3670 array_push($rows, $row);
3675 array_push($rows, $row);
3692 if (is_array($arrFilter))
3694 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
3696 $where .=
" AND " . $ilDB->like(
'svy_qblk.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
3700 $query_result = $ilDB->query(
"SELECT svy_qblk.*, svy_svy.obj_fi FROM svy_qblk , svy_qblk_qst, svy_svy WHERE ".
3701 "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_svy.survey_id = svy_qblk_qst.survey_fi ".
3702 "$where GROUP BY svy_qblk.questionblock_id, svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.show_blocktitle, ".
3703 "svy_qblk.owner_fi, svy_qblk.tstamp, svy_svy.obj_fi");
3705 if ($query_result->numRows())
3708 $surveytitles = array();
3709 foreach ($survey_ref_ids as $survey_ref_id)
3714 while (
$row = $ilDB->fetchAssoc($query_result))
3718 foreach ($questions_array as $key => $value)
3720 $questions_array[$key] =
"$counter. $value";
3723 if (strlen($surveytitles[
$row[
"obj_fi"]]))
3725 $rows[$row[
"questionblock_id"]] = array(
3726 "questionblock_id" => $row[
"questionblock_id"],
3727 "title" => $row[
"title"],
3728 "svy" => $surveytitles[$row[
"obj_fi"]],
3729 "contains" => join($questions_array,
", "),
3730 "owner" => $row[
"owner_fi"]
3746 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
3751 "xmlns:xsi" =>
"http://www.w3.org/2001/XMLSchema-instance",
3752 "xsi:noNamespaceSchemaLocation" =>
"http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd"
3754 $a_xml_writer->xmlStartTag(
"surveyobject", $attrs);
3759 $a_xml_writer->xmlStartTag(
"survey", $attrs);
3761 $a_xml_writer->xmlElement(
"description", NULL, $this->
getDescription());
3762 $a_xml_writer->xmlElement(
"author", NULL, $this->
getAuthor());
3763 $a_xml_writer->xmlStartTag(
"objectives");
3765 "label" =>
"introduction"
3772 $a_xml_writer->xmlEndTag(
"objectives");
3776 $attribs = array(
"enabled" =>
"1");
3780 $attribs = array(
"enabled" =>
"0");
3782 $a_xml_writer->xmlElement(
"anonymisation", $attribs);
3783 $a_xml_writer->xmlStartTag(
"restrictions");
3786 $attribs = array(
"type" =>
"free");
3790 $attribs = array(
"type" =>
"restricted");
3792 $a_xml_writer->xmlElement(
"access", $attribs);
3795 $attrs = array(
"type" =>
"date");
3796 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartDate(), $matches);
3797 $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]));
3801 $attrs = array(
"type" =>
"date");
3802 preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndDate(), $matches);
3803 $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]));
3806 $a_xml_writer->xmlEndTag(
"restrictions");
3810 $hasconstraints = FALSE;
3811 foreach ($pages as $question_array)
3813 foreach ($question_array as $question)
3815 if (count($question[
"constraints"]))
3817 $hasconstraints = TRUE;
3822 if ($hasconstraints)
3824 $a_xml_writer->xmlStartTag(
"constraints");
3825 foreach ($pages as $question_array)
3827 foreach ($question_array as $question)
3829 if (count($question[
"constraints"]))
3832 foreach ($question[
"constraints"] as $constraint)
3835 "sourceref" => $question[
"question_id"],
3836 "destref" => $constraint[
"question"],
3837 "relation" => $constraint[
"short"],
3838 "value" => $constraint[
"value"],
3839 "conjunction" => $constraint[
"conjunction"]
3841 $a_xml_writer->xmlElement(
"constraint", $attribs);
3846 $a_xml_writer->xmlEndTag(
"constraints");
3850 $a_xml_writer->xmlStartTag(
"metadata");
3852 $a_xml_writer->xmlStartTag(
"metadatafield");
3853 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"evaluation_access");
3855 $a_xml_writer->xmlEndTag(
"metadatafield");
3857 $a_xml_writer->xmlStartTag(
"metadatafield");
3858 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"status");
3859 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getStatus());
3860 $a_xml_writer->xmlEndTag(
"metadatafield");
3862 $a_xml_writer->xmlStartTag(
"metadatafield");
3863 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"display_question_titles");
3865 $a_xml_writer->xmlEndTag(
"metadatafield");
3867 $a_xml_writer->xmlStartTag(
"metadatafield");
3868 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"SCORM");
3869 include_once
"./Services/MetaData/classes/class.ilMD.php";
3872 $md->toXml($writer);
3873 $metadata = $writer->xmlDumpMem();
3874 $a_xml_writer->xmlElement(
"fieldentry", NULL, $metadata);
3875 $a_xml_writer->xmlEndTag(
"metadatafield");
3877 $a_xml_writer->xmlEndTag(
"metadata");
3878 $a_xml_writer->xmlEndTag(
"survey");
3880 $attribs = array(
"id" => $this->
getId());
3881 $a_xml_writer->xmlStartTag(
"surveyquestions", $attribs);
3884 foreach ($pages as $question_array)
3886 if (count($question_array) > 1)
3888 $attribs = array(
"id" => $question_array[0][
"question_id"]);
3889 $attribs = array(
"showQuestiontext" => $question_array[0][
"questionblock_show_questiontext"],
3890 "showBlocktitle" => $question_array[0][
"questionblock_show_blocktitle"]);
3891 $a_xml_writer->xmlStartTag(
"questionblock", $attribs);
3892 if (strlen($question_array[0][
"questionblock_title"]))
3894 $a_xml_writer->xmlElement(
"questionblocktitle", NULL, $question_array[0][
"questionblock_title"]);
3897 foreach ($question_array as $question)
3899 if (strlen($question[
"heading"]))
3901 $a_xml_writer->xmlElement(
"textblock", NULL, $question[
"heading"]);
3904 if ($questionObject !== FALSE) $questionObject->insertXML($a_xml_writer, FALSE, $obligatory_states[$question[
"question_id"]]);
3906 if (count($question_array) > 1)
3908 $a_xml_writer->xmlEndTag(
"questionblock");
3912 $a_xml_writer->xmlEndTag(
"surveyquestions");
3913 $a_xml_writer->xmlEndTag(
"surveyobject");
3914 $xml = $a_xml_writer->xmlDumpMem(FALSE);
3927 if ($question_id < 1)
return FALSE;
3928 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3930 if (strlen($question_type) == 0)
return FALSE;
3932 $question =
new $question_type();
3933 $question->loadFromDb($question_id);
3945 if (!is_dir($a_dir) || is_int(strpos($a_dir,
"..")))
3949 $importDirectory =
"";
3952 $current_dir = opendir($a_dir);
3954 while($entryname = readdir($current_dir))
3956 $files[] = $entryname;
3959 foreach($files as
$file)
3961 if(is_dir($a_dir.
"/".$file) and ($file !=
"." and $file!=
".."))
3964 $importDirectory = $a_dir.
"/".
$file;
3967 closedir($current_dir);
3968 if (strlen($importDirectory))
3971 $current_dir = opendir($importDirectory);
3973 while($entryname = readdir($current_dir))
3975 $files[] = $entryname;
3977 foreach($files as $file)
3979 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)))
3982 $xmlFile = $importDirectory.
"/".
$file;
3986 return array(
"dir" => $importDirectory,
"xml" => $xmlFile);
3997 if ($svy_qpl_id < 1) $svy_qpl_id = -1;
3999 $source = $file_info[
"tmp_name"];
4001 if (($source ==
'none') || (!$source) || $file_info[
"error"] > UPLOAD_ERR_OK)
4003 $error = $this->lng->txt(
"import_no_file_selected");
4008 if ((strcmp($file_info[
"type"],
"text/xml") == 0) || (strcmp($file_info[
"type"],
"application/xml") == 0))
4013 $suffix = pathinfo($file_info[
"name"]);
4014 if (strcmp(strtolower($suffix[
"extension"]),
"zip") == 0)
4018 if (!$isXml && !$isZip)
4020 $error = $this->lng->txt(
"import_wrong_file_type");
4022 $ilLog->write(
"Survey: Import error. Filetype was \"" . $file_info[
"type"] .
"\"");
4024 if (strlen($error) == 0)
4028 $import_subdir =
"";
4030 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4033 $importfile = $import_dir.
"/".$file_info[
"name"];
4037 if (!((strlen($found[
"dir"]) > 0) && (strlen($found[
"xml"]) > 0)))
4039 $error = $this->lng->txt(
"wrong_import_file_structure");
4042 $importfile = $found[
"xml"];
4043 $import_subdir = $found[
"dir"];
4047 $importfile = tempnam($import_dir,
"survey_import");
4050 $fh = fopen($importfile,
"r");
4053 $error = $this->lng->txt(
"import_error_opening_file");
4056 $xml = fread($fh, filesize($importfile));
4060 $error = $this->lng->txt(
"import_error_closing_file");
4065 if (strpos($xml,
"questestinterop"))
4067 include_once
"./Services/Survey/classes/class.SurveyImportParserPre38.php";
4069 $import->setSurveyObject($this);
4070 $import->setXMLContent($xml);
4071 $import->startParsing();
4075 include_once
"./Services/Survey/classes/class.SurveyImportParser.php";
4077 $import->setSurveyObject($this);
4078 $import->setXMLContent($xml);
4079 $import->startParsing();
4082 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
4084 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
4085 include_once
"./Services/RTE/classes/class.ilRTE.php";
4086 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
4087 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
4089 $importfile = $import_subdir .
"/" . $mob[
"uri"];
4090 if (file_exists($importfile))
4094 $this->
setIntroduction(str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $this->
getIntroduction()));
4095 $this->
setOutro(str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $this->
getOutro()));
4100 $ilLog->write(
"Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
4131 $newObj->updateMetaData();
4135 $newObj->setOutro($this->
getOutro());
4147 $question_pointer = array();
4150 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
4151 foreach ($this->questions as $key => $question_id)
4158 $question->saveToDb($original_id);
4159 $newObj->questions[$key] = $question->getId();
4160 $question_pointer[$question_id] = $question->getId();
4161 $mapping[$question_id] = $question->getId();
4165 $newObj->saveToDb();
4166 $newObj->cloneTextblocks($mapping);
4169 $questionblocks = array();
4170 $questionblock_questions = array();
4171 $result = $ilDB->queryF(
"SELECT * FROM svy_qblk_qst WHERE survey_fi = %s",
4179 array_push($questionblock_questions,
$row);
4180 $questionblocks[
$row[
"questionblock_fi"]] = $row[
"questionblock_fi"];
4184 foreach ($questionblocks as $key => $value)
4187 $questionblock_id =
ilObjSurvey::_addQuestionblock($questionblock[
"title"], $questionblock[
"owner_fi"], $questionblock[
"show_questiontext"], $questionblock[
"show_blocktitle"]);
4188 $questionblocks[$key] = $questionblock_id;
4191 foreach ($questionblock_questions as $key => $value)
4193 if($questionblocks[$value[
"questionblock_fi"]] &&
4194 $question_pointer[$value[
"question_fi"]])
4196 $next_id = $ilDB->nextId(
'svy_qblk_qst');
4197 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, question_fi) ".
4198 "VALUES (%s, %s, %s, %s)",
4199 array(
'integer',
'integer',
'integer',
'integer'),
4200 array($next_id, $newObj->getSurveyId(), $questionblocks[$value[
"questionblock_fi"]], $question_pointer[$value[
"question_fi"]])
4207 $newConstraints = array();
4208 foreach ($constraints as $key => $constraint)
4210 if ($question_pointer[$constraint[
"for_question"]] &&
4211 $question_pointer[$constraint[
"question"]])
4213 if (!array_key_exists($constraint[
'id'], $newConstraints))
4215 $constraint_id = $newObj->addConstraint($question_pointer[$constraint[
"question"]], $constraint[
"relation_id"], $constraint[
"value"], $constraint[
'conjunction']);
4216 $newConstraints[$constraint[
'id']] = $constraint_id;
4218 $newObj->addConstraintToQuestion($question_pointer[$constraint[
"for_question"]], $newConstraints[$constraint[
'id']]);
4223 $result = $ilDB->queryF(
"SELECT * FROM svy_qst_oblig WHERE survey_fi = %s",
4231 if($question_pointer[
$row[
"question_fi"]])
4233 $next_id = $ilDB->nextId(
'svy_qst_oblig');
4234 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, ".
4235 "obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)",
4236 array(
'integer',
'integer',
'integer',
'text',
'integer'),
4237 array($next_id, $newObj->getSurveyId(), $question_pointer[$row[
"question_fi"]], $row[
"obligatory"], time())
4248 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE question_fi = %s",
4255 return $row[
"heading"];
4270 foreach ($mapping as $original_id => $new_id)
4273 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
4285 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4288 if(!is_writable($svy_data_dir))
4290 $this->ilias->raiseError(
"Survey Data Directory (".$svy_data_dir
4291 .
") not writeable.",$this->ilias->error_obj->FATAL);
4295 $svy_dir = $svy_data_dir.
"/svy_".$this->
getId();
4297 if(!@is_dir($svy_dir))
4299 $this->ilias->raiseError(
"Creation of Survey Directory failed.",$this->ilias->error_obj->FATAL);
4302 $export_dir = $svy_dir.
"/export";
4304 if(!@is_dir($export_dir))
4306 $this->ilias->raiseError(
"Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
4315 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4327 if (!@is_dir($dir) or
4328 !is_writeable($dir))
4340 while ($entry = $dir->read())
4342 if ($entry !=
"." && $entry !=
".." && ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(svy_)*[0-9]+\.[a-z]{1,3}\$", $entry))
4364 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4368 if(!is_writable($svy_data_dir))
4370 $this->ilias->raiseError(
"Survey Data Directory (".$svy_data_dir
4371 .
") not writeable.",$this->ilias->error_obj->FATAL);
4375 $svy_dir = $svy_data_dir.
"/svy_".$this->
getId();
4377 if(!@is_dir($svy_dir))
4379 $this->ilias->raiseError(
"Creation of Survey Directory failed.",$this->ilias->error_obj->FATAL);
4383 $import_dir = $svy_dir.
"/import";
4385 if(!@is_dir($import_dir))
4387 $this->ilias->raiseError(
"Creation of Import Directory failed.",$this->ilias->error_obj->FATAL);
4396 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4398 "/svy_".$this->getId().
"/import";
4399 if (!is_dir($import_dir))
4403 if(@is_dir($import_dir))
4418 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
4419 array(
'text',
'integer',
'integer'),
4420 array($heading, $this->
getSurveyId(), $insertbefore)
4425 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
4426 array(
'text',
'integer',
'integer'),
4436 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_anonymous WHERE survey_key = %s AND survey_fi = %s",
4437 array(
'text',
'integer'),
4440 return (
$result->numRows() == 1) ?
true :
false;
4448 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
4449 array(
'integer',
'integer'),
4455 return $row[
"anonymous_id"];
4467 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE anonymous_id = %s AND survey_fi = %s",
4468 array(
'text',
'integer'),
4471 return (
$result->numRows() == 1) ?
true :
false;
4503 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND user_key IS NULL",
4521 $result = $ilDB->queryF(
"SELECT svy_anonymous.*, svy_finished.state FROM svy_anonymous ".
4522 "LEFT JOIN svy_finished ON svy_anonymous.survey_key = svy_finished.anonymous_id ".
4523 "WHERE svy_anonymous.survey_fi = %s AND svy_anonymous.user_key IS NULL",
4528 $default_lang = $ilUser->getPref(
"survey_code_language");
4529 $lang = (strlen($default_lang)) ?
"&lang=" . $default_lang :
"";
4532 if (in_array(
$row[
"survey_key"], $a_array) || (count($a_array) == 0))
4534 $export .=
$row[
"survey_key"] .
",";
4539 $export .=
"$created,";
4548 $url = ILIAS_HTTP_PATH.
"/goto.php?cmd=infoScreen&target=svy_".$this->
getRefId() .
"&client_id=" . CLIENT_ID .
"&accesscode=".$row[
"survey_key"].$lang;
4549 $export .= $url .
"\n";
4568 $order =
"ORDER BY tstamp, survey_key ASC";
4570 $result = $ilDB->queryF(
"SELECT svy_anonymous.anonymous_id, svy_anonymous.survey_key, svy_anonymous.survey_fi, ".
4571 "svy_anonymous.tstamp, svy_finished.state FROM svy_anonymous LEFT JOIN svy_finished ".
4572 "ON svy_anonymous.survey_key = svy_finished.anonymous_id WHERE svy_anonymous.survey_fi = %s ".
4573 "AND svy_anonymous.user_key IS NULL $order",
4594 $addlang =
"&lang=$lang";
4596 $href = ILIAS_HTTP_PATH.
"/goto.php?cmd=infoScreen&target=svy_".$this->
getRefId() .
"&client_id=" . CLIENT_ID .
"&accesscode=".$row[
"survey_key"].$addlang;
4597 $url = $this->lng->txt(
"survey_code_url_name");
4599 array_push($codes, array(
'code' =>
$row[
"survey_key"],
'date' => $created,
'used' => $state,
'url' => $url,
'href' => $href));
4608 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
4609 array(
'integer',
'text'),
4612 return (
$result->numRows() > 0) ?
true :
false;
4618 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
4619 array(
'integer',
'text'),
4622 return (
$result->numRows() > 0) ?
false :
true;
4628 for ($i = 0; $i < $nrOfCodes; $i++)
4631 $next_id = $ilDB->nextId(
'svy_anonymous');
4632 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, tstamp) ".
4633 "VALUES (%s, %s, %s, %s)",
4634 array(
'integer',
'text',
'integer',
'integer'),
4635 array($next_id, $anonymize_key, $this->
getSurveyId(), time())
4643 foreach (
$data as $dataset)
4646 $next_id = $ilDB->nextId(
'svy_anonymous');
4647 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) ".
4648 "VALUES (%s, %s, %s, %s, %s)",
4649 array(
'integer',
'text',
'integer',
'text',
'integer'),
4650 array($next_id, $anonymize_key, $this->
getSurveyId(), serialize($dataset), time())
4663 $check_finished = ($not_sent > 1);
4665 include_once
"./Services/Mail/classes/class.ilMail.php";
4667 $mail =
new ilMail($user_id);
4669 foreach ($recipients as
$data)
4671 if($data[
'email'] && $data[
'code'])
4674 switch ((
int)$not_sent)
4677 $do_send = !(bool)$data[
'sent'];
4681 $do_send = $data[
'finished'];
4685 $do_send = !$data[
'finished'];
4695 $messagetext = $message;
4696 $url = ILIAS_HTTP_PATH.
"/goto.php?cmd=infoScreen&target=svy_".$this->
getRefId() .
"&client_id=" . CLIENT_ID .
"&accesscode=".$data[
"code"].
"&lang=".
$lang;
4697 $messagetext = str_replace(
'[url]',
"<" . $url .
">", $messagetext);
4698 foreach ($data as $key => $value)
4700 $messagetext = str_replace(
'[' . $key .
']', $value, $messagetext);
4718 $ilDB->manipulateF(
"UPDATE svy_anonymous SET sent = %s WHERE survey_fi = %s AND externaldata IS NOT NULL",
4719 array(
'integer',
'integer'),
4727 $result = $ilDB->queryF(
"SELECT survey_key code, externaldata, sent FROM svy_anonymous WHERE survey_fi = %s AND externaldata IS NOT NULL",
4734 $externaldata = unserialize(
$row[
'externaldata']);
4735 $externaldata[
'code'] =
$row[
'code'];
4736 $externaldata[
'sent'] =
$row[
'sent'];
4738 if($a_check_finished)
4743 array_push(
$res, $externaldata);
4757 if (strlen($survey_code) > 0)
4759 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
4760 array(
'integer',
'text'),
4776 $result = $ilDB->queryF(
"SELECT survey_key FROM svy_anonymous WHERE survey_fi = %s AND user_key = %s",
4777 array(
'integer',
'text'),
4783 $access_code =
$row[
"survey_key"];
4785 return $access_code;
4797 $next_id = $ilDB->nextId(
'svy_anonymous');
4798 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, user_key, tstamp) ".
4799 "VALUES (%s, %s, %s, %s, %s)",
4800 array(
'integer',
'text',
'integer',
'text',
'integer'),
4801 array($next_id, $access_code, $this->
getSurveyId(), md5($user_id), time())
4813 $codestring =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
4816 for ($i = 1; $i <=5; $i++)
4818 $index = mt_rand(0, strlen($codestring)-1);
4819 $code .= substr($codestring, $index, 1);
4842 $resultarray = array();
4843 foreach (
$row as $rowindex => $entry)
4845 if(is_array($entry))
4847 $entry = implode(
"/", $entry);
4854 if (strpos($entry,
"\"") !== FALSE)
4856 $entry = str_replace(
"\"",
"\"\"", $entry);
4864 $entry = str_replace(chr(13).chr(10), chr(10), $entry);
4867 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
4871 $resultarray[$rowindex] = utf8_decode($entry);
4874 return $resultarray;
4881 $result = $ilDB->queryF(
"SELECT tstamp FROM svy_answer WHERE active_fi = %s ORDER BY tstamp DESC",
4888 return $row[
"tstamp"];
4892 $result = $ilDB->queryF(
"SELECT tstamp FROM svy_finished WHERE finished_id = %s",
4899 return $row[
"tstamp"];
4913 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4926 if (preg_match(
"/<[^>]*?>/", $a_text))
4944 function addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag = TRUE, $add_mobs = TRUE, $attribs = NULL)
4946 include_once
"./Services/RTE/classes/class.ilRTE.php";
4947 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
4949 $a_xml_writer->xmlStartTag(
"material", $attribs);
4951 "type" =>
"text/plain"
4953 if ($this->
isHTML($a_material))
4955 $attrs[
"type"] =
"text/xhtml";
4958 $a_xml_writer->xmlElement(
"mattext", $attrs, $mattext);
4963 foreach (
$mobs as $mob)
4965 $mob_id =
"il_" . IL_INST_ID .
"_mob_" . $mob;
4966 if (strpos($mattext, $mob_id) !== FALSE)
4971 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle()
4973 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
4977 if ($close_material_tag) $a_xml_writer->xmlEndTag(
"material");
4992 if ($this->surveyCodeSecurity == FALSE)
5011 if (extension_loaded(
"tidy"))
5015 "output-xml" =>
true,
5016 "numeric-entities" =>
true
5019 $tidy->parseString($print_output, $config,
'utf8');
5020 $tidy->cleanRepair();
5021 $print_output = tidy_get_output($tidy);
5022 $print_output = preg_replace(
"/^.*?(<html)/",
"\\1", $print_output);
5026 $print_output = str_replace(
" ",
" ", $print_output);
5027 $print_output = str_replace(
"⊗",
"X", $print_output);
5029 $xsl = file_get_contents(
"./Modules/Survey/xml/question2fo.xsl");
5033 'font-family="Helvetica, unifont"',
5034 'font-family="'.
$GLOBALS[
'ilSetting']->
get(
'rpc_pdf_font',
'Helvetica, unifont').
'"',
5038 $args = array(
'/_xml' => $print_output,
'/_xsl' => $xsl );
5041 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args, $params);
5044 $ilLog->write($output);
5058 include_once
"./Services/Utilities/classes/class.ilUtil.php";
5060 $fp = fopen($fo_file,
"w"); fwrite($fp, $fo); fclose($fp);
5062 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
5071 $ilLog->write(__METHOD__.
': '.$e->getMessage());
5076 $ilLog->write(__METHOD__.
': '.$e->getMessage());
5093 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
5099 include_once(
"./Modules/Survey/classes/class.ilObjSurveyAccess.php");
5124 global $ilPluginAdmin;
5125 if ($ilPluginAdmin->isActive(
IL_COMP_MODULE,
"SurveyQuestionPool",
"svyq", $a_pname))
5155 if (!is_array($ids) || count($ids) ==0)
return array();
5157 $result = $ilDB->query(
"SELECT usr_id, login, lastname, firstname FROM usr_data WHERE " . $ilDB->in(
'usr_id', $ids,
false,
'integer') .
" ORDER BY login");
5158 $result_array = array();
5161 $result_array[
$row[
"usr_id"]]=
$row;
5163 return $result_array;
5168 if (!is_array($ids) || count($ids) ==0)
return array();
5180 if (!is_array($ids) || count($ids) ==0)
return array();
5182 foreach ($ids as $obj_id)
5196 $this->mailnotification = ($a_notification) ?
true :
false;
5206 $this->mailaddresses = $a_addresses;
5216 $this->mailparticipantdata = $a_data;
5223 $result = $ilDB->queryF(
"SELECT * FROM svy_times, svy_finished WHERE svy_finished.survey_fi = %s",
5225 array($this->
getId())
5230 if (strlen(
$row[
'left_page']) && strlen(
$row[
'entered_page']))
5231 $times[
$row[
'finished_fi']] += (
$row[
'left_page']-
$row[
'entered_page']);
5241 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_times (finished_fi, entered_page, left_page, first_question) VALUES (%s, %s, %s, %s)",
5242 array(
'integer',
'integer',
'integer',
'integer'),
5243 array($finished_id, $time, NULL, $first_question)
5251 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_times SET left_page = %s WHERE finished_fi = %s AND entered_page = %s",
5252 array(
'integer',
'integer',
'integer'),
5253 array($time, $finished_id,
$_SESSION[
'svy_entered_page'])
5262 $result = $ilDB->queryF(
"SELECT * FROM svy_times WHERE finished_fi = %s",
5269 if (
$row[
'left_page'] > 0 &&
$row[
'entered_page'] > 0)
5287 if(
sizeof($this->questions) ==
sizeof($a_order))
5289 $this->questions = array_flip($a_order);
5290 $this->saveQuestionsToDB();
5301 $this->pool_usage = (bool)$a_value;
5313 if($template_settings)
5315 include_once
"Services/Administration/classes/class.ilSettingsTemplate.php";
5317 $template_settings = $template_settings->getSettings();
5318 $template_settings = $template_settings[
"use_pool"];
5319 if($template_settings && $template_settings[
"hide"])
5321 $use_pool = (bool)$template_settings[
"value"];
5339 include_once
"Services/Administration/classes/class.ilSettingsTemplate.php";
5341 $template_settings = $template->getSettings();
5342 if($template_settings)
5344 if($template_settings[
"show_question_titles"] !== NULL)
5346 if($template_settings[
"show_question_titles"][
"value"])
5356 if($template_settings[
"use_pool"] !== NULL)
5358 if($template_settings[
"use_pool"][
"value"])
5368 if($template_settings[
"anonymization_options"][
"value"])
5373 $this->
setAnonymize($anon_map[$template_settings[
"anonymization_options"][
"value"]]);
5389 $this->activation_starting_time = $starting_time;
5394 $this->activation_ending_time = $ending_time;
5399 return (strlen($this->activation_starting_time)) ? $this->activation_starting_time : NULL;
5404 return (strlen($this->activation_ending_time)) ? $this->activation_ending_time : NULL;