34 include_once
"./classes/class.ilObject.php";
35 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
167 $this->
ilObject($a_id,$a_call_by_reference);
169 $this->survey_id = -1;
170 $this->introduction =
"";
171 $this->outro = $this->lng->txt(
"survey_finished");
172 $this->author = $ilUser->fullname;
175 $this->startdate_enabled = 0;
176 $this->enddate_enabled = 0;
177 $this->questions = array();
182 $this->surveyCodeSecurity = TRUE;
183 $this->template_id = NULL;
184 $this->pool_usage =
true;
220 if (!parent::update())
242 function read($a_force_db =
false)
256 array_push($this->questions, $question_id);
278 foreach ($this->questions as $question_id)
297 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_svy WHERE survey_id = %s",
302 $result = $ilDB->queryF(
"SELECT questionblock_fi FROM svy_qblk_qst WHERE survey_fi = %s",
306 $questionblocks = array();
309 array_push($questionblocks,
$row[
"questionblock_fi"]);
311 if (count($questionblocks))
313 $affectedRows = $ilDB->manipulate(
"DELETE FROM svy_qblk WHERE " . $ilDB->in(
'questionblock_id', $questionblocks,
false,
'integer'));
315 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE survey_fi = %s",
321 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_anonymous WHERE survey_fi = %s",
327 include_once
"./Services/Utilities/classes/class.ilUtil.php";
329 $directory = $svy_data_dir.
"/svy_".$this->
getId();
330 if (is_dir($directory))
332 include_once
"./Services/Utilities/classes/class.ilUtil.php";
336 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
342 foreach(
$mobs as $mob)
359 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
363 $active_array = array();
366 array_push($active_array,
$row[
"finished_id"]);
369 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_finished WHERE survey_fi = %s",
374 foreach ($active_array as $active_fi)
376 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_answer WHERE active_fi = %s",
380 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_times WHERE finished_fi = %s",
396 foreach ($finished_ids as $finished_id)
398 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE finished_id = %s",
404 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_answer WHERE active_fi = %s",
406 array(
$row[
"finished_id"])
409 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_finished WHERE finished_id = %s",
414 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_times WHERE finished_fi = %s",
416 array(
$row[
"finished_id"])
425 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s",
429 $participants = array();
435 $participants[$userdata[
"sortname"] . $userdata[
"active_id"]] = $userdata;
438 return $participants;
454 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
494 if ($a_node_id==
$_GET[
"ref_id"])
496 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
497 $parent_type = $parent_obj->getType();
498 if($parent_type == $this->
getType())
500 $a_node_id = (int) $tree->getParentId($a_node_id);
504 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
515 if (($this->
getTitle()) and (count($this->questions)))
534 $survey->loadFromDb();
535 if (($survey->getTitle()) and (count($survey->questions)))
554 $survey->loadFromDb();
556 if (($survey->getTitle()) and ($survey->author) and (count($survey->questions)))
564 $result[
"evaluation_access"] = $survey->getEvaluationAccess();
584 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_svy SET complete = %s, tstamp = %s WHERE survey_id = %s",
585 array(
'text',
'integer',
'integer'),
603 $question_gui = $this->
getQuestionGUI($questiontype, $question_id);
606 if($this->
getId() == $question_gui->object->getObjId() && !$a_force)
611 $duplicate_id = $question_gui->object->duplicate(
true);
612 return $duplicate_id;
624 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
632 $result = $ilDB->queryF(
"SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
636 $sequence =
$result->numRows();
638 $next_id = $ilDB->nextId(
'svy_svy_qst');
639 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_svy_qst (survey_question_id, survey_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
640 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
641 array($next_id, $this->
getSurveyId(), $duplicate_id, $sequence, time())
657 $result = $ilDB->queryF(
"SELECT svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.show_blocktitle,".
658 " svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst, svy_svy_qst".
659 " WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi".
660 " AND svy_svy_qst.question_fi = svy_qblk_qst.question_fi".
661 " AND svy_qblk.questionblock_id = %s".
662 " ORDER BY svy_svy_qst.sequence",
664 array($questionblock_id)
667 $show_questiontext = 0;
668 $show_blocktitle = 0;
674 $show_questiontext =
$row[
"show_questiontext"];
675 $show_blocktitle =
$row[
"show_blocktitle"];
700 include_once(
"./Services/RTE/classes/class.ilRTE.php");
701 $completecontent =
"";
704 $completecontent .= $content;
714 $next_id = $ilDB->nextId(
'svy_settings');
715 $affectedRows = $ilDB->insert(
"svy_settings", array(
716 "settings_id" => array(
"integer", $next_id),
717 "usr_id" => array(
"integer",
$usr_id),
718 "keyword" => array(
"text", $key),
719 "title" => array(
"text",
$title),
720 "value" => array(
"clob", $value)
728 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_settings WHERE settings_id = %s",
732 return $affectedRows;
739 $result = $ilDB->queryF(
"SELECT * FROM svy_settings WHERE usr_id = %s AND keyword = %s",
740 array(
'integer',
'text'),
763 include_once(
"./Services/RTE/classes/class.ilRTE.php");
766 $next_id = $ilDB->nextId(
'svy_svy');
767 $affectedRows = $ilDB->insert(
"svy_svy", array(
768 "survey_id" => array(
"integer", $next_id),
769 "obj_fi" => array(
"integer", $this->
getId()),
770 "author" => array(
"text", $this->
getAuthor()),
773 "status" => array(
"text", $this->
getStatus()),
775 "enddate" => array(
"text", $this->
getEndDate()),
779 "complete" => array(
"text", $this->
isComplete()),
780 "created" => array(
"integer", time()),
786 "tstamp" => array(
"integer", time()),
787 "template_id" => array(
"integer", $this->
getTemplate()),
794 $affectedRows = $ilDB->update(
"svy_svy", array(
795 "author" => array(
"text", $this->
getAuthor()),
798 "status" => array(
"text", $this->
getStatus()),
800 "enddate" => array(
"text", $this->
getEndDate()),
804 "complete" => array(
"text", $this->
isComplete()),
810 "tstamp" => array(
"integer", time()),
811 "template_id" => array(
"integer", $this->
getTemplate()),
814 "survey_id" => array(
"integer", $this->
getSurveyId())
834 $old_questions = array();
835 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
843 $old_questions[
$row[
"question_fi"]] =
$row;
848 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_svy_qst WHERE survey_fi = %s",
853 foreach ($this->questions as $key => $value)
855 $next_id = $ilDB->nextId(
'svy_svy_qst');
856 $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)",
857 array(
'integer',
'integer',
'integer',
'text',
'integer',
'integer'),
858 array($next_id, $this->
getSurveyId(), $value, (strlen($old_questions[$value][
"heading"])) ? $old_questions[$value][
"heading"] : NULL, $key, time())
873 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_finished WHERE anonymous_id = %s",
880 return $row[
"anonymous_id"];
896 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
910 if ($question_id < 1)
return -1;
911 $result = $ilDB->queryF(
"SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND " .
912 "svy_question.questiontype_fi = svy_qtype.questiontype_id",
919 return $data[
"type_tag"];
943 switch ($a_anonymize)
949 $this->anonymize = $a_anonymize;
964 return ($this->anonymize) ? $this->anonymize : 0;
1004 $result = $ilDB->queryF(
"SELECT * FROM svy_svy WHERE obj_fi = %s",
1006 array($this->
getId())
1013 include_once(
"./Services/RTE/classes/class.ilRTE.php");
1015 if (strcmp(
$data[
"outro"],
"survey_finished") == 0)
1017 $this->
setOutro($this->lng->txt(
"survey_finished"));
1051 $this->questions = array();
1052 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
1058 $this->questions[
$data[
"sequence"]] = $data[
"question_fi"];
1071 $this->startdate_enabled = ($enabled) ? $enabled : 0;
1083 return ($this->startdate_enabled) ? $this->startdate_enabled : 0;
1095 $this->enddate_enabled = ($enabled) ? $enabled : 0;
1107 return ($this->enddate_enabled) ? $this->enddate_enabled : 0;
1134 $md_life =& $md->getLifecycle();
1137 if (strlen($a_author) == 0)
1140 $a_author = $ilUser->getFullname();
1143 $md_life =& $md->addLifecycle();
1145 $con =& $md_life->addContribute();
1146 $con->setRole(
"Author");
1148 $ent =& $con->addEntity();
1149 $ent->setEntity($a_author);
1164 include_once
"./Services/MetaData/classes/class.ilMD.php";
1166 $md_life =& $md->getLifecycle();
1169 $ids =& $md_life->getContributeIds();
1170 foreach ($ids as
$id)
1172 $md_cont =& $md_life->getContribute($id);
1173 if (strcmp($md_cont->getRole(),
"Author") == 0)
1175 $entids =& $md_cont->getEntityIds();
1176 foreach ($entids as $entid)
1178 $md_ent =& $md_cont->getEntity($entid);
1179 array_push(
$author, $md_ent->getEntity());
1195 return ($this->display_question_titles) ? 1 : 0;
1206 $this->display_question_titles = ($a_show) ? 1 : 0;
1217 $this->display_question_titles = 1;
1228 $this->display_question_titles = 0;
1251 $result = $ilDB->query(
"SELECT usr_id FROM usr_data");
1254 if ($ilAccess->checkAccessOfUser(
$row[
"usr_id"],
"read",
"", $this->getRefId(),
"svy", $this->
getId()))
1332 include_once
"./Services/Administration/classes/class.ilSetting.php";
1333 $surveySetting =
new ilSetting(
"survey");
1334 $unlimited_invitation = $surveySetting->get(
"unlimited_invitation");
1335 if (!$unlimited_invitation && $this->invitation_mode ==
MODE_UNLIMITED)
1341 return ($this->invitation_mode) ? $this->invitation_mode :
MODE_UNLIMITED;
1395 $result = $this->lng->txt(
"cannot_switch_to_online_no_questions");
1413 return (strlen($this->start_date)) ? $this->start_date : NULL;
1428 $edit_settings =
false;
1432 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartDate(), $matches))
1434 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
1436 if ($now < $epoch_time)
1438 array_push(
$messages,$this->lng->txt(
'start_date_not_reached').
' ('.
1441 $edit_settings =
true;
1448 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndDate(), $matches))
1450 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
1452 if ($now > $epoch_time)
1454 array_push(
$messages,$this->lng->txt(
'end_date_reached').
' ('.
1457 $edit_settings =
true;
1464 array_push(
$messages, $this->lng->txt(
"survey_is_offline"));
1466 $edit_settings =
true;
1469 if (!$ilAccess->checkAccess(
"read",
"", $this->ref_id))
1471 array_push(
$messages, $this->lng->txt(
"cannot_participate_survey"));
1478 $survey_started = $this->
isSurveyStarted($ilUser->getId(), $anonymous_id);
1479 if ($survey_started === 1)
1481 array_push(
$messages, $this->lng->txt(
"already_completed_survey"));
1488 "edit_settings" => $edit_settings
1514 $y =
''; $m =
'';
$d =
''; $h =
''; $i =
''; $s =
'';
1515 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/",
$start_date, $matches))
1521 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $start_time, $matches))
1527 $this->start_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m,
$d, $h, $i, $s);
1604 return (strlen($this->end_date)) ? $this->end_date : NULL;
1629 $y =
''; $m =
'';
$d =
''; $h =
''; $i =
''; $s =
'';
1630 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/",
$end_date, $matches))
1636 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $end_time, $matches))
1642 $this->end_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m,
$d, $h, $i, $s);
1743 return (strlen($this->introduction)) ? $this->introduction : NULL;
1755 return (strlen($this->outro)) ? $this->outro : NULL;
1767 $existing_questions = array();
1768 $result = $ilDB->queryF(
"SELECT svy_question.original_id FROM svy_question, svy_svy_qst WHERE " .
1769 "svy_svy_qst.survey_fi = %s AND svy_svy_qst.question_fi = svy_question.question_id",
1775 if(
$data[
"original_id"])
1777 array_push($existing_questions,
$data[
"original_id"]);
1780 return $existing_questions;
1791 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1803 $move_questions = array($question_id);
1806 foreach ($pages as $idx => $page)
1808 if ($page[0][
"question_id"] == $question_id)
1815 $this->
moveQuestions($move_questions, $pages[$pageindex-1][0][
"question_id"], 0);
1822 $index = array_search($question_id,
$questions);
1823 if (($index !== FALSE) && ($index > 0))
1837 $move_questions = array($question_id);
1840 foreach ($pages as $idx => $page)
1842 if (($page[0][
"question_id"] == $question_id) && (strcmp($page[0][
"questionblock_id"],
"") == 0))
1847 if (($pageindex < count($pages)-1) && ($pageindex >= 0))
1849 $this->
moveQuestions($move_questions, $pages[$pageindex+1][count($pages[$pageindex+1])-1][
"question_id"], 1);
1856 $index = array_search($question_id,
$questions);
1857 if (($index !== FALSE) && ($index < count(
$questions)-1))
1873 $move_questions = array();
1875 foreach ($pages as $idx => $page)
1877 if ($page[0][
"questionblock_id"] == $questionblock_id)
1879 foreach ($page as $pageidx => $question)
1881 array_push($move_questions, $question[
"question_id"]);
1888 $this->
moveQuestions($move_questions, $pages[$pageindex-1][0][
"question_id"], 0);
1901 $move_questions = array();
1903 foreach ($pages as $idx => $page)
1905 if ($page[0][
"questionblock_id"] == $questionblock_id)
1907 foreach ($page as $pageidx => $question)
1909 array_push($move_questions, $question[
"question_id"]);
1914 if ($pageindex < count($pages)-1)
1916 $this->
moveQuestions($move_questions, $pages[$pageindex+1][count($pages[$pageindex+1])-1][
"question_id"], 1);
1930 $array_pos = array_search($target_index, $this->questions);
1931 if ($insert_mode == 0)
1933 $part1 = array_slice($this->questions, 0, $array_pos);
1934 $part2 = array_slice($this->questions, $array_pos);
1936 else if ($insert_mode == 1)
1938 $part1 = array_slice($this->questions, 0, $array_pos + 1);
1939 $part2 = array_slice($this->questions, $array_pos + 1);
1941 foreach ($move_questions as $question_id)
1943 if (!(array_search($question_id, $part1) === FALSE))
1945 unset($part1[array_search($question_id, $part1)]);
1947 if (!(array_search($question_id, $part2) === FALSE))
1949 unset($part2[array_search($question_id, $part2)]);
1952 $part1 = array_values($part1);
1953 $part2 = array_values($part2);
1954 $this->questions = array_values(array_merge($part1, $move_questions, $part2));
1955 foreach ($move_questions as $question_id)
1958 foreach ($constraints as $idx => $constraint)
1960 foreach ($part2 as $next_question_id)
1962 if ($constraint[
"question"] == $next_question_id)
1981 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1983 $question->delete($question_id);
1996 $result = $ilDB->queryF(
"SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
1997 array(
'integer',
'integer'),
2002 $remove_constraints = array();
2005 array_push($remove_constraints,
$row[
"constraint_fi"]);
2007 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
2008 array(
'integer',
'integer'),
2011 foreach ($remove_constraints as $key => $constraint_id)
2013 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_constraint WHERE constraint_id = %s",
2015 array($constraint_id)
2032 $block_sizes = array();
2035 if (in_array($question_id, $remove_questions) or in_array(
$data[
"questionblock_id"], $remove_questionblocks))
2037 unset($this->questions[array_search($question_id, $this->questions)]);
2040 else if(
$data[
"questionblock_id"])
2042 $block_sizes[
$data[
"questionblock_id"]]++;
2047 foreach($block_sizes as $block_id =>
$size)
2051 $remove_questionblocks[] = $block_id;
2055 foreach (array_unique($remove_questionblocks) as $questionblock_id)
2057 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk WHERE questionblock_id = %s",
2059 array($questionblock_id)
2061 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
2062 array(
'integer',
'integer'),
2067 $this->questions = array_values($this->questions);
2080 foreach ($questionblocks as $index)
2082 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk WHERE questionblock_id = %s",
2086 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
2087 array(
'integer',
'integer'),
2097 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s AND question_fi = %s",
2098 array(
'integer',
'integer',
'integer'),
2099 array($questionblock_id, $this->
getSurveyId(), $question_id)
2108 $next_id = $ilDB->nextId(
'svy_qblk_qst');
2109 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
2110 "question_fi) VALUES (%s, %s, %s, %s)",
2111 array(
'integer',
'integer',
'integer',
'integer'),
2112 array($next_id, $this->
getSurveyId(), $questionblock_id, $question_id)
2126 $result = $ilDB->queryF(
"SELECT svy_question.title, svy_qblk_qst.question_fi, svy_qblk_qst.survey_fi FROM ".
2127 "svy_qblk, svy_qblk_qst, svy_question WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND " .
2128 "svy_question.question_id = svy_qblk_qst.question_fi AND svy_qblk.questionblock_id = %s",
2130 array($questionblock_id)
2135 $titles[
$row[
"question_fi"]] = $row[
"title"];
2138 $result = $ilDB->queryF(
"SELECT question_fi, sequence FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
2142 $resultarray = array();
2146 if (array_key_exists(
$row[
"question_fi"], $titles))
2148 $resultarray[$counter++] = $titles[
$row[
"question_fi"]];
2151 return $resultarray;
2163 $result = $ilDB->queryF(
"SELECT question_fi FROM svy_qblk_qst WHERE questionblock_fi = %s",
2165 array($questionblock_id)
2172 array_push($ids,
$data[
'question_fi']);
2188 $result = $ilDB->queryF(
"SELECT * FROM svy_qblk WHERE questionblock_id = %s",
2190 array($questionblock_id)
2192 return $ilDB->fetchAssoc(
$result);
2205 $result = $ilDB->queryF(
"SELECT * FROM svy_qblk WHERE questionblock_id = %s",
2207 array($questionblock_id)
2224 $next_id = $ilDB->nextId(
'svy_qblk');
2225 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk (questionblock_id, title, owner_fi, tstamp) " .
2226 "VALUES (%s, %s, %s, %s)",
2227 array(
'integer',
'text',
'integer',
'integer'),
2250 $next_id = $ilDB->nextId(
'svy_qblk');
2251 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk (questionblock_id, title, show_questiontext,".
2252 " show_blocktitle, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
2253 array(
'integer',
'text',
'text',
'text',
'integer',
'integer'),
2254 array($next_id,
$title, $show_questiontext, $show_blocktitle, $ilUser->getId(), time())
2258 $questionblock_id = $next_id;
2261 $next_id = $ilDB->nextId(
'svy_qblk_qst');
2262 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
2263 "question_fi) VALUES (%s, %s, %s, %s)",
2264 array(
'integer',
'integer',
'integer',
'integer'),
2265 array($next_id, $this->
getSurveyId(), $questionblock_id, $index)
2282 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_qblk SET title = %s, show_questiontext = %s,".
2283 " show_blocktitle = %s WHERE questionblock_id = %s",
2284 array(
'text',
'text',
'text',
'integer'),
2285 array(
$title, $show_questiontext, $show_blocktitle, $questionblock_id)
2298 $result = $ilDB->queryF(
"SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
2299 array(
'integer',
'integer'),
2302 $constraints = array();
2305 array_push($constraints,
$row[
"constraint_fi"]);
2307 foreach ($constraints as $constraint_id)
2323 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_constraint WHERE constraint_id = %s",
2325 array($constraint_id)
2327 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_constraint WHERE constraint_fi = %s",
2329 array($constraint_id)
2343 $all_questions = array();
2344 $result = $ilDB->queryF(
"SELECT svy_qtype.type_tag, svy_qtype.plugin, svy_question.question_id, ".
2345 "svy_svy_qst.heading FROM svy_qtype, svy_question, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
2346 "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
2347 "ORDER BY svy_svy_qst.sequence",
2351 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
2365 $questionrow = $question->_getQuestionDataArray(
$row[
"question_id"]);
2366 foreach (
$row as $key => $value)
2368 $questionrow[$key] = $value;
2370 $all_questions[
$row[
"question_id"]] = $questionrow;
2371 $all_questions[$row[
"question_id"]][
"usableForPrecondition"] = $question->usableForPrecondition();
2372 $all_questions[$row[
"question_id"]][
"availableRelations"] = $question->getAvailableRelations();
2373 if (array_key_exists($row[
"question_id"], $obligatory_states))
2375 $all_questions[$row[
"question_id"]][
"obligatory"] = $obligatory_states[$row[
"question_id"]];
2380 $questionblocks = array();
2381 if (count($all_questions))
2383 $result = $ilDB->queryF(
"SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst WHERE " .
2384 "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
2385 "AND " . $ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions),
false,
'integer'),
2391 $questionblocks[
$row[
'question_fi']] =
$row;
2395 foreach ($all_questions as $question_id =>
$row)
2398 if (isset($questionblocks[$question_id]))
2400 $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
2401 $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
2402 $all_questions[$question_id][
"constraints"] = $constraints;
2406 $all_questions[$question_id][
"questionblock_title"] =
"";
2407 $all_questions[$question_id][
"questionblock_id"] =
"";
2408 $all_questions[$question_id][
"constraints"] = $constraints;
2413 $result = $ilDB->queryF(
"SELECT svy_variable.*, svy_category.title FROM svy_variable, svy_category " .
2414 "WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id ".
2415 "ORDER BY sequence ASC",
2423 array_push($answers,
$data[
"title"]);
2426 $all_questions[$question_id][
"answers"] = $answers;
2429 return $all_questions;
2441 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
2449 if (!array_key_exists(
$row[
"question_fi"], $obligatory_questions))
2451 $obligatory_questions[
$row[
"question_fi"]] = 0;
2457 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_oblig WHERE survey_fi = %s",
2463 foreach ($obligatory_questions as $question_fi => $obligatory)
2465 $next_id = $ilDB->nextId(
'svy_qst_oblig');
2466 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, " .
2467 "obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)",
2468 array(
'integer',
'integer',
'integer',
'text',
'integer'),
2469 array($next_id, $this->
getSurveyId(), $question_fi, (strlen($obligatory)) ? $obligatory : 0, time())
2473 $ilDB->manipulate(
"UPDATE svy_question".
2474 " SET obligatory = ".$ilDB->quote($obligatory,
"integer").
2475 " WHERE question_id = ".$ilDB->quote($question_fi,
"integer"));
2488 $obligatory_states = array();
2489 $result = $ilDB->queryF(
"SELECT * FROM svy_qst_oblig WHERE survey_fi = %s",
2497 $obligatory_states[
$row[
"question_fi"]] = $row[
"obligatory"];
2500 return $obligatory_states;
2513 $all_questions = array();
2514 $result = $ilDB->queryF(
"SELECT svy_question.*, svy_qtype.type_tag, svy_svy_qst.heading FROM " .
2515 "svy_question, svy_qtype, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
2516 "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id ".
2517 "ORDER BY svy_svy_qst.sequence",
2523 $all_questions[
$row[
"question_id"]] =
$row;
2526 $questionblocks = array();
2527 if (count($all_questions))
2529 $result = $ilDB->queryF(
"SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst ".
2530 "WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s ".
2531 "AND " . $ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions),
false,
'integer'),
2537 $questionblocks[
$row[
'question_fi']] =
$row;
2541 $all_pages = array();
2544 foreach ($all_questions as $question_id =>
$row)
2546 if (array_key_exists($question_id, $obligatory_states))
2548 $all_questions[$question_id][
"obligatory"] = $obligatory_states[$question_id];
2550 $constraints = array();
2551 if (isset($questionblocks[$question_id]))
2553 if (!$currentblock or ($currentblock != $questionblocks[$question_id][
'questionblock_id']))
2557 $all_questions[$question_id][
'page'] = $pageindex;
2558 $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
2559 $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
2560 $all_questions[$question_id][
"questionblock_show_questiontext"] = $questionblocks[$question_id][
'show_questiontext'];
2561 $all_questions[$question_id][
"questionblock_show_blocktitle"] = $questionblocks[$question_id][
'show_blocktitle'];
2562 $currentblock = $questionblocks[$question_id][
'questionblock_id'];
2564 $all_questions[$question_id][
"constraints"] = $constraints;
2569 $all_questions[$question_id][
'page'] = $pageindex;
2570 $all_questions[$question_id][
"questionblock_title"] =
"";
2571 $all_questions[$question_id][
"questionblock_id"] =
"";
2572 $all_questions[$question_id][
"questionblock_show_questiontext"] = 1;
2573 $all_questions[$question_id][
"questionblock_show_blocktitle"] = 1;
2576 $all_questions[$question_id][
"constraints"] = $constraints;
2578 if (!isset($all_pages[$pageindex]))
2580 $all_pages[$pageindex] = array();
2582 array_push($all_pages[$pageindex], $all_questions[$question_id]);
2585 $max = count($all_pages);
2587 foreach ($all_pages as $index => $block)
2589 foreach ($block as $blockindex => $question)
2591 $all_pages[$index][$blockindex][
"position"] = $counter / $max;
2610 if (strcmp($active_page_question_id,
"") == 0)
2614 foreach ($pages as $key => $question_array)
2616 foreach ($question_array as $question)
2618 if ($active_page_question_id == $question[
"question_id"])
2624 if ($foundpage == -1)
2630 $foundpage += $direction;
2635 if ($foundpage >= count($pages))
2639 return $pages[$foundpage];
2651 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
2664 $result_array = array();
2665 $result = $ilDB->queryF(
"SELECT svy_constraint.*, svy_relation.* FROM svy_qst_constraint, svy_constraint, ".
2666 "svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id AND ".
2667 "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_constraint.constraint_id = %s",
2674 $pc = $ilDB->fetchAssoc(
$result);
2688 $result_array = array();
2689 $result = $ilDB->queryF(
"SELECT svy_constraint.*, svy_relation.* FROM svy_qst_constraint, svy_constraint, svy_relation ".
2690 "WHERE svy_constraint.relation_fi = svy_relation.relation_id AND ".
2691 "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.question_fi = %s ".
2692 "AND svy_qst_constraint.survey_fi = %s",
2693 array(
'integer',
'integer'),
2698 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
2701 $question =
new $question_type();
2702 $question->loadFromDb(
$row[
"question_fi"]);
2703 $valueoutput = $question->getPreconditionValueOutput(
$row[
"value"]);
2704 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));
2706 return $result_array;
2717 $result_array = array();
2718 $result = $ilDB->queryF(
"SELECT svy_qst_constraint.question_fi as for_question, svy_constraint.*, svy_relation.* ".
2719 "FROM svy_qst_constraint, svy_constraint, svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id ".
2720 "AND svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.survey_fi = %s",
2726 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']));
2728 return $result_array;
2741 $result_array = array();
2742 $result = $ilDB->queryF(
"SELECT svy_variable.*, svy_category.title FROM svy_variable LEFT JOIN ".
2743 "svy_category ON svy_variable.category_fi = svy_category.category_id WHERE svy_variable.question_fi = %s ".
2744 "ORDER BY svy_variable.sequence",
2750 $result_array[
$row->sequence] =
$row;
2752 return $result_array;
2767 $next_id = $ilDB->nextId(
'svy_constraint');
2768 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_constraint (constraint_id, question_fi, relation_fi, value, conjunction) VALUES ".
2769 "(%s, %s, %s, %s, %s)",
2770 array(
'integer',
'integer',
'integer',
'float',
'integer'),
2771 array($next_id, $if_question_id, $relation, $value, $conjunction)
2794 $next_id = $ilDB->nextId(
'svy_qst_constraint');
2795 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qst_constraint (question_constraint_id, survey_fi, question_fi, ".
2796 "constraint_fi) VALUES (%s, %s, %s, %s)",
2797 array(
'integer',
'integer',
'integer',
'integer'),
2798 array($next_id, $this->
getSurveyId(), $to_question_id, $constraint_id)
2815 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_constraint SET question_fi = %s, relation_fi = %s, value = %s, conjunction = %s ".
2816 "WHERE constraint_id = %s",
2817 array(
'integer',
'integer',
'float',
'integer',
'integer'),
2818 array($if_question_id, $relation, $value, $conjunction, $precondition_id)
2827 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_constraint SET conjunction = %s ".
2828 "WHERE constraint_id IN (SELECT constraint_fi FROM svy_qst_constraint WHERE svy_qst_constraint.question_fi = %s)",
2829 array(
'integer',
'integer'),
2830 array($conjunction, $question_id)
2845 $custom_order = array(
"equal",
"not_equal",
"less",
"less_or_equal",
"more",
"more_or_equal");
2846 $custom_order = array_flip($custom_order);
2848 $result_array = array();
2849 $result = $ilDB->query(
"SELECT * FROM svy_relation");
2854 $result_array[
$row[
"shortname"]] = array(
"short" => $row[
"shortname"],
"long" => $row[
"longname"],
"id" => $row[
"relation_id"],
"order" => $custom_order[$row[
"longname"]]);
2858 $result_array[
$row[
"relation_id"]] = array(
"short" => $row[
"shortname"],
"long" => $row[
"longname"],
"order" => $custom_order[$row[
"longname"]]);
2863 foreach($result_array as $idx => $item)
2865 unset($result_array[$idx][
"order"]);
2868 return $result_array;
2877 $result = $ilDB->queryF(
"SELECT user_fi FROM svy_inv_usr WHERE survey_fi = %s",
2896 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_inv_usr WHERE survey_fi = %s AND user_fi = %s",
2897 array(
'integer',
'integer'),
2900 include_once
'./Services/User/classes/class.ilObjUser.php';
2914 $result = $ilDB->queryF(
"SELECT user_fi FROM svy_inv_usr WHERE user_fi = %s AND survey_fi = %s",
2915 array(
'integer',
'integer'),
2920 $next_id = $ilDB->nextId(
'svy_inv_usr');
2921 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_inv_usr (invited_user_id, survey_fi, user_fi, tstamp) " .
2922 "VALUES (%s, %s, %s, %s)",
2923 array(
'integer',
'integer',
'integer',
'integer'),
2924 array($next_id, $this->
getSurveyId(), $user_id, time())
2929 include_once
'./Services/User/classes/class.ilObjUser.php';
2944 include_once
"./Modules/Group/classes/class.ilObjGroup.php";
2946 $members = $group->getGroupMemberIds();
2947 foreach ($members as $user_id)
2949 if ($ilAccess->checkAccessOfUser($user_id,
"read",
"", $this->getRefId(),
"svy", $this->
getId()))
2954 include_once
'./Services/User/classes/class.ilObjUser.php';
2973 $members = $rbacreview->assignedUsers($role_id);
2974 foreach ($members as $user_id)
2976 if ($ilAccess->checkAccessOfUser($user_id,
"read",
"", $this->getRefId(),
"svy", $this->
getId()))
2981 include_once
'./Services/User/classes/class.ilObjUser.php';
2999 $result_array = array();
3000 $result = $ilDB->queryF(
"SELECT user_fi FROM svy_inv_usr WHERE survey_fi = %s",
3006 array_push($result_array,
$row[
"user_fi"]);
3008 return $result_array;
3022 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
3023 array(
'integer',
'integer'),
3024 array($question_id, $active_id)
3039 $result_array = array();
3040 $result = $ilDB->queryF(
"SELECT * FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
3041 array(
'integer',
'integer'),
3042 array($question_id, $active_id)
3048 array_push($result_array,
$row);
3050 return $result_array;
3054 return $result_array;
3071 $active_id = $ilDB->nextId(
'svy_finished');
3072 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_finished (finished_id, survey_fi, user_fi, anonymous_id, state, tstamp) ".
3073 "VALUES (%s, %s, %s, %s, %s, %s)",
3074 array(
'integer',
'integer',
'integer',
'text',
'text',
'integer'),
3075 array($active_id, $this->
getSurveyId(), $user_id, $anonymous_id, 1, time())
3079 foreach ($pages as $key => $question_array)
3081 foreach ($question_array as $question)
3084 require_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3086 $question->saveRandomData($active_id);
3102 if ($this->
getAnonymize() && (strlen($anonymous_id) == 0))
return;
3104 if (strcmp($user_id,
"") == 0)
3106 if ($user_id == ANONYMOUS_USER_ID)
3111 $next_id = $ilDB->nextId(
'svy_finished');
3112 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_finished (finished_id, survey_fi, user_fi, anonymous_id, state, tstamp) ".
3113 "VALUES (%s, %s, %s, %s, %s, %s)",
3114 array(
'integer',
'integer',
'integer',
'text',
'text',
'integer'),
3115 array($next_id, $this->
getSurveyId(), $user_id, $anonymous_id, 0, time())
3132 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_finished SET state = %s, user_fi = %s, tstamp = %s ".
3133 "WHERE survey_fi = %s AND anonymous_id = %s",
3134 array(
'text',
'integer',
'integer',
'integer',
'text'),
3135 array(1, $user_id, time(), $this->
getSurveyId(), $anonymize_id)
3140 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_finished SET state = %s, tstamp = %s WHERE survey_fi = %s AND user_fi = %s",
3141 array(
'text',
'integer',
'integer',
'integer'),
3162 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_finished SET lastpage = %s WHERE finished_id = %s",
3163 array(
'integer',
'integer'),
3164 array(($page_id) ? $page_id : 0, $finished_id)
3170 include_once
"./Services/User/classes/class.ilObjUser.php";
3171 include_once
"./Services/Mail/classes/class.ilMail.php";
3174 $placeholders = array(
3175 "FIRST_NAME" =>
"firstname",
3176 "LAST_NAME" =>
"lastname",
3179 "firstname" =>
"firstname"
3182 $mail =
new ilMail(ANONYMOUS_USER_ID);
3183 $recipients = preg_split(
'/,/', $this->mailaddresses);
3184 foreach ($recipients as $recipient)
3189 foreach ($placeholders as $key => $mapping)
3193 $messagetext = str_replace(
'[' . $key .
']',
'', $messagetext);
3197 $messagetext = str_replace(
'[' . $key .
']', trim(
$data[$mapping]), $messagetext);
3200 $active_id = $this->
getActiveID($user_id, $anonymize_id);
3201 $messagetext .= ((strlen($messagetext)) ?
"\n\n\n" :
'') . $this->lng->txt(
'results') .
"\n\n". $this->
getParticipantTextResults($active_id);
3207 $this->lng->txt(
'finished_mail_subject') .
': ' . $this->
getTitle(),
3220 $questioncounter = 1;
3221 foreach (
$questions as $question_id => $question_data)
3223 $textresult .= $questioncounter++ .
". " . $question_data[
"title"] .
"\n";
3224 $found = $userResults[$question_id][$active_id];
3226 if (is_array($found))
3228 $text = implode(
"\n", $found);
3234 if (strlen($text) == 0) $text = $this->lng->txt(
"skipped");
3235 $text = str_replace(
"<br />",
"\n", $text);
3236 $textresult .= $text .
"\n\n";
3248 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3306 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
3307 array(
'integer',
'integer'),
3313 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
3314 array(
'integer',
'text'),
3321 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
3322 array(
'integer',
'integer'),
3334 return (
int)
$row[
"state"];
3353 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
3354 array(
'integer',
'integer'),
3360 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
3361 array(
'integer',
'text'),
3368 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
3369 array(
'integer',
'integer'),
3380 return $row[
"finished_id"];
3394 $result = $ilDB->queryF(
"SELECT lastpage FROM svy_finished WHERE finished_id = %s",
3405 return (
$row[
"lastpage"]) ?
$row[
"lastpage"] :
'';
3419 if (count($working_data) == 0)
3424 if ((count($working_data) == 1) and (strcmp($working_data[0][
"value"],
"") == 0))
3430 foreach ($working_data as
$data)
3432 switch ($constraint_data[
"short"])
3435 if ($data[
"value"] < $constraint_data[
"value"])
3442 if ($data[
"value"] <= $constraint_data[
"value"])
3449 if ($data[
"value"] == $constraint_data[
"value"])
3456 if ($data[
"value"] <> $constraint_data[
"value"])
3463 if ($data[
"value"] >= $constraint_data[
"value"])
3470 if ($data[
"value"] > $constraint_data[
"value"])
3489 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
3493 return (
$result->numRows()) ?
true :
false;
3507 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s",
3515 array_push($users,
$row[
"finished_id"]);
3532 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s",
3540 array_push($users,
$row);
3543 $evaluation = array();
3545 foreach (
$questions as $question_id => $question_data)
3547 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3550 $question =
new $question_type();
3551 $question->loadFromDb($question_id);
3553 $evaluation[$question_id] =
$data;
3569 $surveySetting =
new ilSetting(
"survey");
3570 $use_anonymous_id = array_key_exists(
"use_anonymous_id",
$_GET) ?
$_GET[
"use_anonymous_id"] : $surveySetting->get(
"use_anonymous_id");
3571 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE finished_id = %s",
3576 $foundrows =
$result->numRows();
3581 $name = ($use_anonymous_id) ?
$row[
"anonymous_id"] : $this->lng->txt(
"anonymous");
3583 "fullname" => $name,
3584 "sortname" => $name,
3589 "active_id" =>
"$active_id"
3593 if ((
$row[
"user_fi"] > 0) && (
$row[
"user_fi"] != ANONYMOUS_USER_ID) && ($this->
getAnonymize() == 0))
3595 include_once
'./Services/User/classes/class.ilObjUser.php';
3598 $userdata[
"fullname"] = $userdata[
"sortname"] = $this->lng->txt(
"deleted_user");
3603 $userdata[
"fullname"] = $user->getFullname();
3604 $gender = $user->getGender();
3605 if (strlen($gender) == 1) $gender = $this->lng->txt(
"gender_$gender");
3606 $userdata[
"gender"] = $gender;
3607 $userdata[
"firstname"] = $user->getFirstname();
3608 $userdata[
"lastname"] = $user->getLastname();
3609 $userdata[
"sortname"] = $user->getLastname() .
", " . $user->getFirstname();
3610 $userdata[
"login"] = $user->getLogin();
3632 $result = $ilDB->queryF(
"SELECT * FROM svy_answer WHERE active_fi = %s",
3638 if (!is_array($answers[
$row[
"question_fi"]]))
3640 $answers[$row[
"question_fi"]] = array();
3642 array_push($answers[$row[
"question_fi"]], $row);
3646 "name" => $userdata[
"fullname"],
3647 "login" => $userdata[
"login"],
3648 "gender" => $userdata[
"gender"],
3649 "answers" => array()
3653 if (array_key_exists($key, $answers))
3655 $resultset[
"answers"][$key] = $answers[$key];
3659 $resultset[
"answers"][$key] = array();
3661 sort($resultset[
"answers"][$key]);
3678 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
3682 $nr_of_users =
$result->numRows();
3684 $result_array =& $question->getCumulatedResults($this->
getSurveyId(), $nr_of_users);
3685 return $result_array;
3699 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
3710 $result_array = array();
3711 $result = $ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype WHERE ".
3712 "svy_question.questiontype_fi = svy_qtype.questiontype_id AND svy_question.tstamp > 0 AND ".
3713 $ilDB->in(
'svy_question.question_id', $question_ids,
false,
'integer'));
3716 array_push($result_array,
$row);
3718 return $result_array;
3731 if (is_array($arrFilter))
3733 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
3735 $where .=
" AND " . $ilDB->like(
'svy_question.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
3737 if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description']))
3739 $where .=
" AND " . $ilDB->like(
'svy_question.description',
'text',
"%%" . $arrFilter[
'description'] .
"%%");
3741 if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author']))
3743 $where .=
" AND " . $ilDB->like(
'svy_question.author',
'text',
"%%" . $arrFilter[
'author'] .
"%%");
3745 if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type']))
3747 $where .=
" AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter[
'type'],
'text');
3749 if (array_key_exists(
'spl', $arrFilter) && strlen($arrFilter[
'spl']))
3751 $where .=
" AND svy_question.obj_fi = " . $ilDB->quote($arrFilter[
'spl'],
'integer');
3757 $forbidden =
" AND " . $ilDB->in(
'svy_question.obj_fi', array_keys($spls),
false,
'integer');
3758 $forbidden .=
" AND svy_question.complete = " . $ilDB->quote(
"1",
'text');
3761 if (count($existing_questions))
3763 $existing =
" AND " . $ilDB->in(
'svy_question.question_id', $existing_questions,
true,
'integer');
3766 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
3769 $query_result = $ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin, object_reference.ref_id".
3770 " FROM svy_question, svy_qtype, object_reference".
3771 " WHERE svy_question.original_id IS NULL".$forbidden.$existing.
3772 " AND svy_question.obj_fi = object_reference.obj_id AND svy_question.tstamp > 0".
3773 " AND svy_question.questiontype_fi = svy_qtype.questiontype_id " . $where);
3776 if ($query_result->numRows())
3778 while (
$row = $ilDB->fetchAssoc($query_result))
3780 if (array_key_exists(
'spl_txt', $arrFilter) && strlen($arrFilter[
'spl_txt']))
3782 if(!stristr($spls[
$row[
"obj_fi"]], $arrFilter[
'spl_txt']))
3788 $row[
'ttype'] = $trans[
$row[
'type_tag']];
3793 array_push($rows, $row);
3798 array_push($rows, $row);
3812 global $ilUser,
$ilDB;
3815 if (is_array($arrFilter))
3817 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
3819 $where .=
" AND " . $ilDB->like(
'svy_qblk.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
3823 $query_result = $ilDB->query(
"SELECT svy_qblk.*, svy_svy.obj_fi FROM svy_qblk , svy_qblk_qst, svy_svy WHERE ".
3824 "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_svy.survey_id = svy_qblk_qst.survey_fi ".
3825 "$where GROUP BY svy_qblk.questionblock_id, svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.show_blocktitle, ".
3826 "svy_qblk.owner_fi, svy_qblk.tstamp, svy_svy.obj_fi");
3828 if ($query_result->numRows())
3831 $surveytitles = array();
3832 foreach ($survey_ref_ids as $survey_ref_id)
3837 while (
$row = $ilDB->fetchAssoc($query_result))
3841 foreach ($questions_array as $key => $value)
3843 $questions_array[$key] =
"$counter. $value";
3846 if (strlen($surveytitles[
$row[
"obj_fi"]]))
3848 $rows[$row[
"questionblock_id"]] = array(
3849 "questionblock_id" => $row[
"questionblock_id"],
3850 "title" => $row[
"title"],
3851 "svy" => $surveytitles[$row[
"obj_fi"]],
3852 "contains" => join($questions_array,
", "),
3853 "owner" => $row[
"owner_fi"]
3869 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
3874 "xmlns:xsi" =>
"http://www.w3.org/2001/XMLSchema-instance",
3875 "xsi:noNamespaceSchemaLocation" =>
"http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd"
3877 $a_xml_writer->xmlStartTag(
"surveyobject", $attrs);
3882 $a_xml_writer->xmlStartTag(
"survey", $attrs);
3884 $a_xml_writer->xmlElement(
"description", NULL, $this->
getDescription());
3885 $a_xml_writer->xmlElement(
"author", NULL, $this->
getAuthor());
3886 $a_xml_writer->xmlStartTag(
"objectives");
3888 "label" =>
"introduction"
3895 $a_xml_writer->xmlEndTag(
"objectives");
3899 $attribs = array(
"enabled" =>
"1");
3903 $attribs = array(
"enabled" =>
"0");
3905 $a_xml_writer->xmlElement(
"anonymisation", $attribs);
3906 $a_xml_writer->xmlStartTag(
"restrictions");
3909 $attribs = array(
"type" =>
"free");
3913 $attribs = array(
"type" =>
"restricted");
3915 $a_xml_writer->xmlElement(
"access", $attribs);
3918 $attrs = array(
"type" =>
"date");
3923 $attrs = array(
"type" =>
"date");
3926 $a_xml_writer->xmlEndTag(
"restrictions");
3930 $hasconstraints = FALSE;
3931 foreach ($pages as $question_array)
3933 foreach ($question_array as $question)
3935 if (count($question[
"constraints"]))
3937 $hasconstraints = TRUE;
3942 if ($hasconstraints)
3944 $a_xml_writer->xmlStartTag(
"constraints");
3945 foreach ($pages as $question_array)
3947 foreach ($question_array as $question)
3949 if (count($question[
"constraints"]))
3952 foreach ($question[
"constraints"] as $constraint)
3955 "sourceref" => $question[
"question_id"],
3956 "destref" => $constraint[
"question"],
3957 "relation" => $constraint[
"short"],
3958 "value" => $constraint[
"value"],
3959 "conjunction" => $constraint[
"conjunction"]
3961 $a_xml_writer->xmlElement(
"constraint", $attribs);
3966 $a_xml_writer->xmlEndTag(
"constraints");
3970 $a_xml_writer->xmlStartTag(
"metadata");
3972 $a_xml_writer->xmlStartTag(
"metadatafield");
3973 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"evaluation_access");
3975 $a_xml_writer->xmlEndTag(
"metadatafield");
3977 $a_xml_writer->xmlStartTag(
"metadatafield");
3978 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"status");
3979 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getStatus());
3980 $a_xml_writer->xmlEndTag(
"metadatafield");
3982 $a_xml_writer->xmlStartTag(
"metadatafield");
3983 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"display_question_titles");
3985 $a_xml_writer->xmlEndTag(
"metadatafield");
3987 $a_xml_writer->xmlStartTag(
"metadatafield");
3988 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"SCORM");
3989 include_once
"./Services/MetaData/classes/class.ilMD.php";
3992 $md->toXml($writer);
3993 $metadata = $writer->xmlDumpMem();
3994 $a_xml_writer->xmlElement(
"fieldentry", NULL, $metadata);
3995 $a_xml_writer->xmlEndTag(
"metadatafield");
3997 $a_xml_writer->xmlEndTag(
"metadata");
3998 $a_xml_writer->xmlEndTag(
"survey");
4000 $attribs = array(
"id" => $this->
getId());
4001 $a_xml_writer->xmlStartTag(
"surveyquestions", $attribs);
4004 foreach ($pages as $question_array)
4006 if (count($question_array) > 1)
4008 $attribs = array(
"id" => $question_array[0][
"question_id"]);
4009 $attribs = array(
"showQuestiontext" => $question_array[0][
"questionblock_show_questiontext"],
4010 "showBlocktitle" => $question_array[0][
"questionblock_show_blocktitle"]);
4011 $a_xml_writer->xmlStartTag(
"questionblock", $attribs);
4012 if (strlen($question_array[0][
"questionblock_title"]))
4014 $a_xml_writer->xmlElement(
"questionblocktitle", NULL, $question_array[0][
"questionblock_title"]);
4017 foreach ($question_array as $question)
4019 if (strlen($question[
"heading"]))
4021 $a_xml_writer->xmlElement(
"textblock", NULL, $question[
"heading"]);
4024 if ($questionObject !== FALSE) $questionObject->insertXML($a_xml_writer, FALSE, $obligatory_states[$question[
"question_id"]]);
4026 if (count($question_array) > 1)
4028 $a_xml_writer->xmlEndTag(
"questionblock");
4032 $a_xml_writer->xmlEndTag(
"surveyquestions");
4033 $a_xml_writer->xmlEndTag(
"surveyobject");
4034 $xml = $a_xml_writer->xmlDumpMem(FALSE);
4047 if ($question_id < 1)
return FALSE;
4048 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
4050 if (strlen($question_type) == 0)
return FALSE;
4052 $question =
new $question_type();
4053 $question->loadFromDb($question_id);
4065 if (!is_dir($a_dir) || is_int(strpos($a_dir,
"..")))
4069 $importDirectory =
"";
4072 $current_dir = opendir($a_dir);
4074 while($entryname = readdir($current_dir))
4081 if(is_dir($a_dir.
"/".$file) and ($file !=
"." and $file!=
".."))
4084 $importDirectory = $a_dir.
"/".
$file;
4087 closedir($current_dir);
4088 if (strlen($importDirectory))
4091 $current_dir = opendir($importDirectory);
4093 while($entryname = readdir($current_dir))
4099 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)))
4102 $xmlFile = $importDirectory.
"/".
$file;
4106 return array(
"dir" => $importDirectory,
"xml" => $xmlFile);
4117 if ($svy_qpl_id < 1) $svy_qpl_id = -1;
4119 $source = $file_info[
"tmp_name"];
4121 if (($source ==
'none') || (!$source) || $file_info[
"error"] > UPLOAD_ERR_OK)
4123 $error = $this->lng->txt(
"import_no_file_selected");
4128 if ((strcmp($file_info[
"type"],
"text/xml") == 0) || (strcmp($file_info[
"type"],
"application/xml") == 0))
4133 $suffix = pathinfo($file_info[
"name"]);
4134 if (strcmp(strtolower($suffix[
"extension"]),
"zip") == 0)
4138 if (!$isXml && !$isZip)
4140 $error = $this->lng->txt(
"import_wrong_file_type");
4142 $ilLog->write(
"Survey: Import error. Filetype was \"" . $file_info[
"type"] .
"\"");
4144 if (strlen($error) == 0)
4148 $import_subdir =
"";
4150 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4153 $importfile = $import_dir.
"/".$file_info[
"name"];
4157 if (!((strlen($found[
"dir"]) > 0) && (strlen($found[
"xml"]) > 0)))
4159 $error = $this->lng->txt(
"wrong_import_file_structure");
4162 $importfile = $found[
"xml"];
4163 $import_subdir = $found[
"dir"];
4167 $importfile = tempnam($import_dir,
"survey_import");
4170 $fh = fopen($importfile,
"r");
4173 $error = $this->lng->txt(
"import_error_opening_file");
4176 $xml = fread($fh, filesize($importfile));
4180 $error = $this->lng->txt(
"import_error_closing_file");
4185 if (strpos($xml,
"questestinterop"))
4187 include_once
"./Services/Survey/classes/class.SurveyImportParserPre38.php";
4189 $import->setSurveyObject($this);
4190 $import->setXMLContent($xml);
4191 $import->startParsing();
4195 include_once
"./Services/Survey/classes/class.SurveyImportParser.php";
4197 $import->setSurveyObject($this);
4198 $import->setXMLContent($xml);
4199 $import->startParsing();
4202 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
4204 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
4205 include_once
"./Services/RTE/classes/class.ilRTE.php";
4206 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
4207 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
4209 $importfile = $import_subdir .
"/" . $mob[
"uri"];
4210 if (file_exists($importfile))
4214 $this->
setIntroduction(str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $this->
getIntroduction()));
4215 $this->
setOutro(str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $this->
getOutro()));
4220 $ilLog->write(
"Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
4251 $newObj->updateMetaData();
4255 $newObj->setOutro($this->
getOutro());
4269 $question_pointer = array();
4272 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
4273 foreach ($this->questions as $key => $question_id)
4280 $question->saveToDb($original_id);
4281 $newObj->questions[$key] = $question->getId();
4282 $question_pointer[$question_id] = $question->getId();
4283 $mapping[$question_id] = $question->getId();
4287 $newObj->saveToDb();
4288 $newObj->cloneTextblocks($mapping);
4291 $questionblocks = array();
4292 $questionblock_questions = array();
4293 $result = $ilDB->queryF(
"SELECT * FROM svy_qblk_qst WHERE survey_fi = %s",
4301 array_push($questionblock_questions,
$row);
4302 $questionblocks[
$row[
"questionblock_fi"]] = $row[
"questionblock_fi"];
4306 foreach ($questionblocks as $key => $value)
4310 $questionblocks[$key] = $questionblock_id;
4313 foreach ($questionblock_questions as $key => $value)
4315 if($questionblocks[$value[
"questionblock_fi"]] &&
4316 $question_pointer[$value[
"question_fi"]])
4318 $next_id = $ilDB->nextId(
'svy_qblk_qst');
4319 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, question_fi) ".
4320 "VALUES (%s, %s, %s, %s)",
4321 array(
'integer',
'integer',
'integer',
'integer'),
4322 array($next_id, $newObj->getSurveyId(), $questionblocks[$value[
"questionblock_fi"]], $question_pointer[$value[
"question_fi"]])
4329 $newConstraints = array();
4330 foreach ($constraints as $key => $constraint)
4332 if ($question_pointer[$constraint[
"for_question"]] &&
4333 $question_pointer[$constraint[
"question"]])
4335 if (!array_key_exists($constraint[
'id'], $newConstraints))
4337 $constraint_id = $newObj->addConstraint($question_pointer[$constraint[
"question"]], $constraint[
"relation_id"], $constraint[
"value"], $constraint[
'conjunction']);
4338 $newConstraints[$constraint[
'id']] = $constraint_id;
4340 $newObj->addConstraintToQuestion($question_pointer[$constraint[
"for_question"]], $newConstraints[$constraint[
'id']]);
4345 $result = $ilDB->queryF(
"SELECT * FROM svy_qst_oblig WHERE survey_fi = %s",
4353 if($question_pointer[
$row[
"question_fi"]])
4355 $next_id = $ilDB->nextId(
'svy_qst_oblig');
4356 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, ".
4357 "obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)",
4358 array(
'integer',
'integer',
'integer',
'text',
'integer'),
4359 array($next_id, $newObj->getSurveyId(), $question_pointer[$row[
"question_fi"]], $row[
"obligatory"], time())
4370 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE question_fi = %s",
4377 return $row[
"heading"];
4392 foreach ($mapping as $original_id => $new_id)
4395 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
4407 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4410 if(!is_writable($svy_data_dir))
4412 $this->ilias->raiseError(
"Survey Data Directory (".$svy_data_dir
4413 .
") not writeable.",$this->ilias->error_obj->FATAL);
4417 $svy_dir = $svy_data_dir.
"/svy_".$this->
getId();
4419 if(!@is_dir($svy_dir))
4421 $this->ilias->raiseError(
"Creation of Survey Directory failed.",$this->ilias->error_obj->FATAL);
4424 $export_dir = $svy_dir.
"/export";
4426 if(!@is_dir($export_dir))
4428 $this->ilias->raiseError(
"Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
4437 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4449 if (!@is_dir(
$dir) or
4450 !is_writeable(
$dir))
4462 while ($entry =
$dir->read())
4464 if ($entry !=
"." && $entry !=
".." && ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(svy_)*[0-9]+\.[a-z]{1,3}\$", $entry))
4486 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4490 if(!is_writable($svy_data_dir))
4492 $this->ilias->raiseError(
"Survey Data Directory (".$svy_data_dir
4493 .
") not writeable.",$this->ilias->error_obj->FATAL);
4497 $svy_dir = $svy_data_dir.
"/svy_".$this->
getId();
4499 if(!@is_dir($svy_dir))
4501 $this->ilias->raiseError(
"Creation of Survey Directory failed.",$this->ilias->error_obj->FATAL);
4505 $import_dir = $svy_dir.
"/import";
4507 if(!@is_dir($import_dir))
4509 $this->ilias->raiseError(
"Creation of Import Directory failed.",$this->ilias->error_obj->FATAL);
4518 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4520 "/svy_".$this->getId().
"/import";
4521 if (!is_dir($import_dir))
4525 if(@is_dir($import_dir))
4540 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
4541 array(
'text',
'integer',
'integer'),
4542 array($heading, $this->
getSurveyId(), $insertbefore)
4547 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
4548 array(
'text',
'integer',
'integer'),
4558 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_anonymous WHERE survey_key = %s AND survey_fi = %s",
4559 array(
'text',
'integer'),
4562 return (
$result->numRows() == 1) ?
true :
false;
4570 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
4571 array(
'integer',
'integer'),
4577 return $row[
"anonymous_id"];
4589 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE anonymous_id = %s AND survey_fi = %s",
4590 array(
'text',
'integer'),
4593 return (
$result->numRows() == 1) ?
true :
false;
4625 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND user_key IS NULL",
4641 global
$ilDB, $ilUser;
4643 $result = $ilDB->queryF(
"SELECT svy_anonymous.*, svy_finished.state FROM svy_anonymous ".
4644 "LEFT JOIN svy_finished ON svy_anonymous.survey_key = svy_finished.anonymous_id ".
4645 "WHERE svy_anonymous.survey_fi = %s AND svy_anonymous.user_key IS NULL",
4650 $default_lang = $ilUser->getPref(
"survey_code_language");
4651 $lang = (strlen($default_lang)) ?
"&lang=" . $default_lang :
"";
4654 if (in_array(
$row[
"survey_key"], $a_array) || (count($a_array) == 0))
4656 $export .=
$row[
"survey_key"] .
",";
4661 $export .=
"$created,";
4670 $url = ILIAS_HTTP_PATH.
"/goto.php?cmd=infoScreen&target=svy_".$this->
getRefId() .
"&client_id=" . CLIENT_ID .
"&accesscode=".$row[
"survey_key"].$lang;
4671 $export .= $url .
"\n";
4688 include_once
"./classes/class.ilFormat.php";
4691 $order =
"ORDER BY tstamp, survey_key ASC";
4693 $result = $ilDB->queryF(
"SELECT svy_anonymous.anonymous_id, svy_anonymous.survey_key, svy_anonymous.survey_fi, ".
4694 "svy_anonymous.tstamp, svy_finished.state FROM svy_anonymous LEFT JOIN svy_finished ".
4695 "ON svy_anonymous.survey_key = svy_finished.anonymous_id WHERE svy_anonymous.survey_fi = %s ".
4696 "AND svy_anonymous.user_key IS NULL $order",
4717 $addlang =
"&lang=$lang";
4719 $href = ILIAS_HTTP_PATH.
"/goto.php?cmd=infoScreen&target=svy_".$this->
getRefId() .
"&client_id=" . CLIENT_ID .
"&accesscode=".$row[
"survey_key"].$addlang;
4720 $url = $this->lng->txt(
"survey_code_url_name");
4722 array_push($codes, array(
'code' =>
$row[
"survey_key"],
'date' => $created,
'used' => $state,
'url' => $url,
'href' => $href));
4731 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
4732 array(
'integer',
'text'),
4735 return (
$result->numRows() > 0) ?
true :
false;
4741 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
4742 array(
'integer',
'text'),
4745 return (
$result->numRows() > 0) ?
false :
true;
4751 for ($i = 0; $i < $nrOfCodes; $i++)
4754 $next_id = $ilDB->nextId(
'svy_anonymous');
4755 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, tstamp) ".
4756 "VALUES (%s, %s, %s, %s)",
4757 array(
'integer',
'text',
'integer',
'integer'),
4758 array($next_id, $anonymize_key, $this->
getSurveyId(), time())
4766 foreach (
$data as $dataset)
4769 $next_id = $ilDB->nextId(
'svy_anonymous');
4770 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) ".
4771 "VALUES (%s, %s, %s, %s, %s)",
4772 array(
'integer',
'text',
'integer',
'text',
'integer'),
4773 array($next_id, $anonymize_key, $this->
getSurveyId(), serialize($dataset), time())
4786 $check_finished = ($not_sent > 1);
4788 include_once
"./Services/Mail/classes/class.ilMail.php";
4790 $mail =
new ilMail($user_id);
4792 foreach ($recipients as
$data)
4794 if($data[
'email'] && $data[
'code'])
4797 switch ((
int)$not_sent)
4800 $do_send = !(bool)$data[
'sent'];
4804 $do_send = $data[
'finished'];
4808 $do_send = !$data[
'finished'];
4818 $messagetext = $message;
4819 $url = ILIAS_HTTP_PATH.
"/goto.php?cmd=infoScreen&target=svy_".$this->
getRefId() .
"&client_id=" . CLIENT_ID .
"&accesscode=".$data[
"code"].
"&lang=".
$lang;
4820 $messagetext = str_replace(
'[url]',
"<" . $url .
">", $messagetext);
4821 foreach ($data as $key => $value)
4823 $messagetext = str_replace(
'[' . $key .
']', $value, $messagetext);
4841 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_anonymous SET sent = %s WHERE survey_fi = %s AND externaldata IS NOT NULL",
4842 array(
'integer',
'integer'),
4850 $result = $ilDB->queryF(
"SELECT survey_key code, externaldata, sent FROM svy_anonymous WHERE survey_fi = %s AND externaldata IS NOT NULL",
4857 $externaldata = unserialize(
$row[
'externaldata']);
4858 $externaldata[
'code'] =
$row[
'code'];
4859 $externaldata[
'sent'] =
$row[
'sent'];
4861 if($a_check_finished)
4866 array_push(
$res, $externaldata);
4880 if (strlen($survey_code) > 0)
4882 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
4883 array(
'integer',
'text'),
4899 $result = $ilDB->queryF(
"SELECT survey_key FROM svy_anonymous WHERE survey_fi = %s AND user_key = %s",
4900 array(
'integer',
'text'),
4906 $access_code =
$row[
"survey_key"];
4908 return $access_code;
4920 $next_id = $ilDB->nextId(
'svy_anonymous');
4921 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, user_key, tstamp) ".
4922 "VALUES (%s, %s, %s, %s, %s)",
4923 array(
'integer',
'text',
'integer',
'text',
'integer'),
4924 array($next_id, $access_code, $this->
getSurveyId(), md5($user_id), time())
4936 $codestring =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
4939 for ($i = 1; $i <=5; $i++)
4941 $index = mt_rand(0, strlen($codestring)-1);
4942 $code .= substr($codestring, $index, 1);
4965 $resultarray = array();
4966 foreach (
$row as $rowindex => $entry)
4968 if(is_array($entry))
4970 $entry = implode(
"/", $entry);
4977 if (strpos($entry,
"\"") !== FALSE)
4979 $entry = str_replace(
"\"",
"\"\"", $entry);
4987 $entry = str_replace(chr(13).chr(10), chr(10), $entry);
4990 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
4994 $resultarray[$rowindex] = utf8_decode($entry);
4997 return $resultarray;
5004 $result = $ilDB->queryF(
"SELECT tstamp FROM svy_answer WHERE active_fi = %s ORDER BY tstamp DESC",
5011 return $row[
"tstamp"];
5015 $result = $ilDB->queryF(
"SELECT tstamp FROM svy_finished WHERE finished_id = %s",
5022 return $row[
"tstamp"];
5036 include_once
"./Services/Utilities/classes/class.ilUtil.php";
5049 if (preg_match(
"/<[^>]*?>/", $a_text))
5067 function addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag = TRUE, $add_mobs = TRUE, $attribs = NULL)
5069 include_once
"./Services/RTE/classes/class.ilRTE.php";
5070 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
5072 $a_xml_writer->xmlStartTag(
"material", $attribs);
5074 "type" =>
"text/plain"
5076 if ($this->
isHTML($a_material))
5078 $attrs[
"type"] =
"text/xhtml";
5081 $a_xml_writer->xmlElement(
"mattext", $attrs, $mattext);
5086 foreach (
$mobs as $mob)
5088 $mob_id =
"il_" . IL_INST_ID .
"_mob_" . $mob;
5089 if (strpos($mattext, $mob_id) !== FALSE)
5094 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle()
5096 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
5100 if ($close_material_tag) $a_xml_writer->xmlEndTag(
"material");
5115 if ($this->surveyCodeSecurity == FALSE)
5132 $print_output = str_replace(
" ",
" ", $print_output);
5133 $print_output = str_replace(
"⊗",
"X", $print_output);
5134 $xsl = file_get_contents(
"./Modules/Survey/xml/question2fo.xsl");
5135 $args = array(
'/_xml' => $print_output,
'/_xsl' => $xsl );
5138 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args, $params);
5141 global
$ilLog; $ilLog->write($output);
5155 include_once
"./Services/Utilities/classes/class.ilUtil.php";
5157 $fp = fopen($fo_file,
"w"); fwrite($fp, $fo); fclose($fp);
5159 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
5168 $ilLog->write(__METHOD__.
': '.$e->getMessage());
5173 $ilLog->write(__METHOD__.
': '.$e->getMessage());
5190 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
5196 include_once(
"./Modules/Survey/classes/class.ilObjSurveyAccess.php");
5221 global $ilPluginAdmin;
5222 if ($ilPluginAdmin->isActive(
IL_COMP_MODULE,
"SurveyQuestionPool",
"svyq", $a_pname))
5252 if (!is_array($ids) || count($ids) ==0)
return array();
5254 $result = $ilDB->query(
"SELECT usr_id, login, lastname, firstname FROM usr_data WHERE " . $ilDB->in(
'usr_id', $ids,
false,
'integer') .
" ORDER BY login");
5255 $result_array = array();
5258 $result_array[
$row[
"usr_id"]]=
$row;
5260 return $result_array;
5265 if (!is_array($ids) || count($ids) ==0)
return array();
5277 if (!is_array($ids) || count($ids) ==0)
return array();
5279 foreach ($ids as $obj_id)
5293 $this->mailnotification = ($a_notification) ?
true :
false;
5303 $this->mailaddresses = $a_addresses;
5313 $this->mailparticipantdata = $a_data;
5320 $result = $ilDB->queryF(
"SELECT * FROM svy_times, svy_finished WHERE svy_finished.survey_fi = %s",
5322 array($this->
getId())
5327 if (strlen(
$row[
'left_page']) && strlen(
$row[
'entered_page']))
5328 $times[
$row[
'finished_fi']] += (
$row[
'left_page']-
$row[
'entered_page']);
5338 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_times (finished_fi, entered_page, left_page, first_question) VALUES (%s, %s, %s, %s)",
5339 array(
'integer',
'integer',
'integer',
'integer'),
5340 array($finished_id, $time, NULL, $first_question)
5348 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_times SET left_page = %s WHERE finished_fi = %s AND entered_page = %s",
5349 array(
'integer',
'integer',
'integer'),
5350 array($time, $finished_id,
$_SESSION[
'svy_entered_page'])
5359 $result = $ilDB->queryF(
"SELECT * FROM svy_times WHERE finished_fi = %s",
5366 if (
$row[
'left_page'] > 0 &&
$row[
'entered_page'] > 0)
5384 if(
sizeof($this->questions) ==
sizeof($a_order))
5386 $this->questions = array_flip($a_order);
5387 $this->saveQuestionsToDB();
5398 $this->pool_usage = (bool)$a_value;
5410 if($template_settings)
5412 include_once
"Services/Administration/classes/class.ilSettingsTemplate.php";
5414 $template_settings = $template_settings->getSettings();
5415 $template_settings = $template_settings[
"use_pool"];
5416 if($template_settings && $template_settings[
"hide"])
5418 $use_pool = (bool)$template_settings[
"value"];
5436 include_once
"Services/Administration/classes/class.ilSettingsTemplate.php";
5438 $template_settings = $template->getSettings();
5439 if($template_settings)
5441 if($template_settings[
"show_question_titles"] !== NULL)
5443 if($template_settings[
"show_question_titles"][
"value"])
5453 if($template_settings[
"use_pool"] !== NULL)
5455 if($template_settings[
"use_pool"][
"value"])
5465 if($template_settings[
"anonymization_options"][
"value"])
5470 $this->
setAnonymize($anon_map[$template_settings[
"anonymization_options"][
"value"]]);