34 include_once
"./classes/class.ilObject.php";
35 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
165 $this->
ilObject($a_id,$a_call_by_reference);
167 $this->survey_id = -1;
168 $this->introduction =
"";
169 $this->outro = $this->lng->txt(
"survey_finished");
170 $this->author = $ilUser->fullname;
173 $this->startdate_enabled = 0;
174 $this->enddate_enabled = 0;
175 $this->questions = array();
180 $this->surveyCodeSecurity = TRUE;
181 $this->mailnotification =
false;
217 if (!parent::update())
239 function read($a_force_db =
false)
253 array_push($this->questions, $question_id);
275 foreach ($this->questions as $question_id)
294 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_svy WHERE survey_id = %s",
299 $result = $ilDB->queryF(
"SELECT questionblock_fi FROM svy_qblk_qst WHERE survey_fi = %s",
303 $questionblocks = array();
306 array_push($questionblocks,
$row[
"questionblock_fi"]);
308 if (count($questionblocks))
310 $affectedRows = $ilDB->manipulate(
"DELETE FROM svy_qblk WHERE " . $ilDB->in(
'questionblock_id', $questionblocks,
false,
'integer'));
312 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE survey_fi = %s",
318 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_anonymous WHERE survey_fi = %s",
324 include_once
"./Services/Utilities/classes/class.ilUtil.php";
326 $directory = $svy_data_dir.
"/svy_".$this->
getId();
327 if (is_dir($directory))
329 include_once
"./Services/Utilities/classes/class.ilUtil.php";
333 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
339 foreach(
$mobs as $mob)
356 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
360 $active_array = array();
363 array_push($active_array,
$row[
"finished_id"]);
366 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_finished WHERE survey_fi = %s",
371 foreach ($active_array as $active_fi)
373 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_answer WHERE active_fi = %s",
377 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_times WHERE finished_fi = %s",
393 foreach ($finished_ids as $finished_id)
395 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE finished_id = %s",
401 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_answer WHERE active_fi = %s",
403 array(
$row[
"finished_id"])
406 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_finished WHERE finished_id = %s",
411 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_times WHERE finished_fi = %s",
413 array(
$row[
"finished_id"])
422 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s",
426 $participants = array();
432 $participants[$userdata[
"sortname"] . $userdata[
"active_id"]] = $userdata;
435 return $participants;
451 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
491 if ($a_node_id==
$_GET[
"ref_id"])
493 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
494 $parent_type = $parent_obj->getType();
495 if($parent_type == $this->
getType())
497 $a_node_id = (int) $tree->getParentId($a_node_id);
501 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
512 if (($this->
getTitle()) and (count($this->questions)))
531 $survey->loadFromDb();
532 if (($survey->getTitle()) and (count($survey->questions)))
551 $survey->loadFromDb();
553 if (($survey->getTitle()) and ($survey->author) and (count($survey->questions)))
561 $result[
"evaluation_access"] = $survey->getEvaluationAccess();
581 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_svy SET complete = %s, tstamp = %s WHERE survey_id = %s",
582 array(
'text',
'integer',
'integer'),
600 $question_gui = $this->
getQuestionGUI($questiontype, $question_id);
601 $duplicate_id = $question_gui->object->duplicate(
true);
602 return $duplicate_id;
614 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
622 $result = $ilDB->queryF(
"SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
626 $sequence =
$result->numRows();
628 $next_id = $ilDB->nextId(
'svy_svy_qst');
629 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_svy_qst (survey_question_id, survey_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
630 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
631 array($next_id, $this->
getSurveyId(), $duplicate_id, $sequence, time())
647 $result = $ilDB->queryF(
"SELECT svy_qblk.title, svy_qblk.show_questiontext, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst, svy_svy_qst WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_svy_qst.question_fi = svy_qblk_qst.question_fi AND svy_qblk.questionblock_id = %s ORDER BY svy_svy_qst.sequence",
649 array($questionblock_id)
652 $show_questiontext = 0;
658 $show_questiontext =
$row[
"show_questiontext"];
683 include_once(
"./Services/RTE/classes/class.ilRTE.php");
684 $completecontent =
"";
687 $completecontent .= $content;
697 $next_id = $ilDB->nextId(
'svy_settings');
698 $affectedRows = $ilDB->insert(
"svy_settings", array(
699 "settings_id" => array(
"integer", $next_id),
700 "usr_id" => array(
"integer",
$usr_id),
701 "keyword" => array(
"text", $key),
702 "title" => array(
"text",
$title),
703 "value" => array(
"clob", $value)
711 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_settings WHERE settings_id = %s",
715 return $affectedRows;
722 $result = $ilDB->queryF(
"SELECT * FROM svy_settings WHERE usr_id = %s AND keyword = %s",
723 array(
'integer',
'text'),
746 include_once(
"./Services/RTE/classes/class.ilRTE.php");
749 $next_id = $ilDB->nextId(
'svy_svy');
750 $affectedRows = $ilDB->insert(
"svy_svy", array(
751 "survey_id" => array(
"integer", $next_id),
752 "obj_fi" => array(
"integer", $this->
getId()),
753 "author" => array(
"text", $this->
getAuthor()),
756 "status" => array(
"text", $this->
getStatus()),
758 "enddate" => array(
"text", $this->
getEndDate()),
762 "complete" => array(
"text", $this->
isComplete()),
763 "created" => array(
"integer", time()),
769 "tstamp" => array(
"integer", time())
775 $affectedRows = $ilDB->update(
"svy_svy", array(
776 "author" => array(
"text", $this->
getAuthor()),
779 "status" => array(
"text", $this->
getStatus()),
781 "enddate" => array(
"text", $this->
getEndDate()),
785 "complete" => array(
"text", $this->
isComplete()),
791 "tstamp" => array(
"integer", time())
793 "survey_id" => array(
"integer", $this->
getSurveyId())
813 $old_questions = array();
814 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
822 $old_questions[
$row[
"question_fi"]] =
$row;
827 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_svy_qst WHERE survey_fi = %s",
832 foreach ($this->questions as $key => $value)
834 $next_id = $ilDB->nextId(
'svy_svy_qst');
835 $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)",
836 array(
'integer',
'integer',
'integer',
'text',
'integer',
'integer'),
837 array($next_id, $this->
getSurveyId(), $value, (strlen($old_questions[$value][
"heading"])) ? $old_questions[$value][
"heading"] : NULL, $key, time())
852 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_finished WHERE anonymous_id = %s",
859 return $row[
"anonymous_id"];
875 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
889 if ($question_id < 1)
return -1;
890 $result = $ilDB->queryF(
"SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND " .
891 "svy_question.questiontype_fi = svy_qtype.questiontype_id",
898 return $data[
"type_tag"];
922 switch ($a_anonymize)
927 $this->anonymize = $a_anonymize;
942 return ($this->anonymize) ? $this->anonymize : 0;
970 $result = $ilDB->queryF(
"SELECT * FROM svy_svy WHERE obj_fi = %s",
972 array($this->
getId())
979 include_once(
"./Services/RTE/classes/class.ilRTE.php");
981 if (strcmp(
$data[
"outro"],
"survey_finished") == 0)
983 $this->
setOutro($this->lng->txt(
"survey_finished"));
1015 $this->questions = array();
1016 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
1022 $this->questions[
$data[
"sequence"]] = $data[
"question_fi"];
1035 $this->startdate_enabled = ($enabled) ? $enabled : 0;
1047 return ($this->startdate_enabled) ? $this->startdate_enabled : 0;
1059 $this->enddate_enabled = ($enabled) ? $enabled : 0;
1071 return ($this->enddate_enabled) ? $this->enddate_enabled : 0;
1098 $md_life =& $md->getLifecycle();
1101 if (strlen($a_author) == 0)
1104 $a_author = $ilUser->getFullname();
1107 $md_life =& $md->addLifecycle();
1109 $con =& $md_life->addContribute();
1110 $con->setRole(
"Author");
1112 $ent =& $con->addEntity();
1113 $ent->setEntity($a_author);
1128 include_once
"./Services/MetaData/classes/class.ilMD.php";
1130 $md_life =& $md->getLifecycle();
1133 $ids =& $md_life->getContributeIds();
1134 foreach ($ids as
$id)
1136 $md_cont =& $md_life->getContribute($id);
1137 if (strcmp($md_cont->getRole(),
"Author") == 0)
1139 $entids =& $md_cont->getEntityIds();
1140 foreach ($entids as $entid)
1142 $md_ent =& $md_cont->getEntity($entid);
1143 array_push(
$author, $md_ent->getEntity());
1159 return ($this->display_question_titles) ? 1 : 0;
1170 $this->display_question_titles = ($a_show) ? 1 : 0;
1181 $this->display_question_titles = 1;
1192 $this->display_question_titles = 0;
1215 $result = $ilDB->query(
"SELECT usr_id FROM usr_data");
1218 if ($ilAccess->checkAccessOfUser(
$row[
"usr_id"],
"read",
"", $this->getRefId(),
"svy", $this->
getId()))
1296 include_once
"./Services/Administration/classes/class.ilSetting.php";
1297 $surveySetting =
new ilSetting(
"survey");
1298 $unlimited_invitation = $surveySetting->get(
"unlimited_invitation");
1299 if (!$unlimited_invitation && $this->invitation_mode ==
MODE_UNLIMITED)
1305 return ($this->invitation_mode) ? $this->invitation_mode :
MODE_UNLIMITED;
1359 $result = $this->lng->txt(
"cannot_switch_to_online_no_questions");
1377 return (strlen($this->start_date)) ? $this->start_date : NULL;
1395 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartDate(), $matches))
1397 $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
1399 if ($now < $epoch_time)
1401 array_push(
$messages,$this->lng->txt(
'start_date_not_reached').
' ('.
1410 if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndDate(), $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(
'end_date_reached').
' ('.
1425 array_push(
$messages, $this->lng->txt(
"survey_is_offline"));
1429 if (!$ilAccess->checkAccess(
"read",
"", $this->ref_id))
1431 array_push(
$messages, $this->lng->txt(
"cannot_participate_survey"));
1438 $survey_started = $this->
isSurveyStarted($ilUser->getId(), $anonymous_id);
1439 if ($survey_started === 1)
1441 array_push(
$messages, $this->lng->txt(
"already_completed_survey"));
1473 $y =
''; $m =
'';
$d =
''; $h =
''; $i =
''; $s =
'';
1474 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/",
$start_date, $matches))
1480 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $start_time, $matches))
1486 $this->start_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m,
$d, $h, $i, $s);
1563 return (strlen($this->end_date)) ? $this->end_date : NULL;
1588 $y =
''; $m =
'';
$d =
''; $h =
''; $i =
''; $s =
'';
1589 if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/",
$end_date, $matches))
1595 if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $end_time, $matches))
1601 $this->end_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m,
$d, $h, $i, $s);
1702 return (strlen($this->introduction)) ? $this->introduction : NULL;
1714 return (strlen($this->outro)) ? $this->outro : NULL;
1726 $existing_questions = array();
1727 $result = $ilDB->queryF(
"SELECT svy_question.original_id FROM svy_question, svy_svy_qst WHERE " .
1728 "svy_svy_qst.survey_fi = %s AND svy_svy_qst.question_fi = svy_question.question_id",
1734 array_push($existing_questions,
$data[
"original_id"]);
1736 return $existing_questions;
1747 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1759 $move_questions = array($question_id);
1762 foreach ($pages as $idx => $page)
1764 if ($page[0][
"question_id"] == $question_id)
1771 $this->
moveQuestions($move_questions, $pages[$pageindex-1][0][
"question_id"], 0);
1778 $index = array_search($question_id,
$questions);
1779 if (($index !== FALSE) && ($index > 0))
1793 $move_questions = array($question_id);
1796 foreach ($pages as $idx => $page)
1798 if (($page[0][
"question_id"] == $question_id) && (strcmp($page[0][
"questionblock_id"],
"") == 0))
1803 if (($pageindex < count($pages)-1) && ($pageindex >= 0))
1805 $this->
moveQuestions($move_questions, $pages[$pageindex+1][count($pages[$pageindex+1])-1][
"question_id"], 1);
1812 $index = array_search($question_id,
$questions);
1813 if (($index !== FALSE) && ($index < count(
$questions)-1))
1829 $move_questions = array();
1831 foreach ($pages as $idx => $page)
1833 if ($page[0][
"questionblock_id"] == $questionblock_id)
1835 foreach ($page as $pageidx => $question)
1837 array_push($move_questions, $question[
"question_id"]);
1844 $this->
moveQuestions($move_questions, $pages[$pageindex-1][0][
"question_id"], 0);
1857 $move_questions = array();
1859 foreach ($pages as $idx => $page)
1861 if ($page[0][
"questionblock_id"] == $questionblock_id)
1863 foreach ($page as $pageidx => $question)
1865 array_push($move_questions, $question[
"question_id"]);
1870 if ($pageindex < count($pages)-1)
1872 $this->
moveQuestions($move_questions, $pages[$pageindex+1][count($pages[$pageindex+1])-1][
"question_id"], 1);
1886 $array_pos = array_search($target_index, $this->questions);
1887 if ($insert_mode == 0)
1889 $part1 = array_slice($this->questions, 0, $array_pos);
1890 $part2 = array_slice($this->questions, $array_pos);
1892 else if ($insert_mode == 1)
1894 $part1 = array_slice($this->questions, 0, $array_pos + 1);
1895 $part2 = array_slice($this->questions, $array_pos + 1);
1897 foreach ($move_questions as $question_id)
1899 if (!(array_search($question_id, $part1) === FALSE))
1901 unset($part1[array_search($question_id, $part1)]);
1903 if (!(array_search($question_id, $part2) === FALSE))
1905 unset($part2[array_search($question_id, $part2)]);
1908 $part1 = array_values($part1);
1909 $part2 = array_values($part2);
1910 $this->questions = array_values(array_merge($part1, $move_questions, $part2));
1911 foreach ($move_questions as $question_id)
1914 foreach ($constraints as $idx => $constraint)
1916 foreach ($part2 as $next_question_id)
1918 if ($constraint[
"question"] == $next_question_id)
1937 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
1939 $question->delete($question_id);
1952 $result = $ilDB->queryF(
"SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
1953 array(
'integer',
'integer'),
1958 $remove_constraints = array();
1961 array_push($remove_constraints,
$row[
"constraint_fi"]);
1963 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
1964 array(
'integer',
'integer'),
1967 foreach ($remove_constraints as $key => $constraint_id)
1969 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_constraint WHERE constraint_id = %s",
1971 array($constraint_id)
1990 if (in_array($question_id, $remove_questions) or in_array(
$data[
"questionblock_id"], $remove_questionblocks))
1992 unset($this->questions[array_search($question_id, $this->questions)]);
1996 foreach ($remove_questionblocks as $questionblock_id)
1998 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk WHERE questionblock_id = %s",
2000 array($questionblock_id)
2002 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
2003 array(
'integer',
'integer'),
2007 $this->questions = array_values($this->questions);
2020 foreach ($questionblocks as $index)
2022 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk WHERE questionblock_id = %s",
2026 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
2027 array(
'integer',
'integer'),
2043 $result = $ilDB->queryF(
"SELECT svy_question.title, svy_qblk_qst.question_fi, svy_qblk_qst.survey_fi FROM ".
2044 "svy_qblk, svy_qblk_qst, svy_question WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND " .
2045 "svy_question.question_id = svy_qblk_qst.question_fi AND svy_qblk.questionblock_id = %s",
2047 array($questionblock_id)
2052 $titles[
$row[
"question_fi"]] = $row[
"title"];
2055 $result = $ilDB->queryF(
"SELECT question_fi, sequence FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
2059 $resultarray = array();
2063 if (array_key_exists(
$row[
"question_fi"], $titles))
2065 $resultarray[$counter++] = $titles[
$row[
"question_fi"]];
2068 return $resultarray;
2080 $result = $ilDB->queryF(
"SELECT question_fi FROM svy_qblk_qst WHERE questionblock_fi = %s",
2082 array($questionblock_id)
2089 array_push($ids,
$data[
'question_fi']);
2105 $result = $ilDB->queryF(
"SELECT * FROM svy_qblk WHERE questionblock_id = %s",
2107 array($questionblock_id)
2109 return $ilDB->fetchAssoc(
$result);
2122 $result = $ilDB->queryF(
"SELECT * FROM svy_qblk WHERE questionblock_id = %s",
2124 array($questionblock_id)
2141 $next_id = $ilDB->nextId(
'svy_qblk');
2142 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk (questionblock_id, title, owner_fi, tstamp) " .
2143 "VALUES (%s, %s, %s, %s)",
2144 array(
'integer',
'text',
'integer',
'integer'),
2166 $next_id = $ilDB->nextId(
'svy_qblk');
2167 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk (questionblock_id, title, show_questiontext, owner_fi, ".
2168 "tstamp) VALUES (%s, %s, %s, %s, %s)",
2169 array(
'integer',
'text',
'text',
'integer',
'integer'),
2170 array($next_id,
$title, $show_questiontext, $ilUser->getId(), time())
2174 $questionblock_id = $next_id;
2177 $next_id = $ilDB->nextId(
'svy_qblk_qst');
2178 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
2179 "question_fi) VALUES (%s, %s, %s, %s)",
2180 array(
'integer',
'integer',
'integer',
'integer'),
2181 array($next_id, $this->
getSurveyId(), $questionblock_id, $index)
2198 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_qblk SET title = %s, show_questiontext = %s WHERE " .
2199 "questionblock_id = %s",
2200 array(
'text',
'text',
'integer'),
2201 array(
$title, $show_questiontext, $questionblock_id)
2214 $result = $ilDB->queryF(
"SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
2215 array(
'integer',
'integer'),
2218 $constraints = array();
2221 array_push($constraints,
$row[
"constraint_fi"]);
2223 foreach ($constraints as $constraint_id)
2239 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_constraint WHERE constraint_id = %s",
2241 array($constraint_id)
2243 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_constraint WHERE constraint_fi = %s",
2245 array($constraint_id)
2259 $all_questions = array();
2260 $result = $ilDB->queryF(
"SELECT svy_qtype.type_tag, svy_qtype.plugin, svy_question.question_id, ".
2261 "svy_svy_qst.heading FROM svy_qtype, svy_question, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
2262 "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
2263 "ORDER BY svy_svy_qst.sequence",
2267 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
2281 $questionrow = $question->_getQuestionDataArray(
$row[
"question_id"]);
2282 foreach (
$row as $key => $value)
2284 $questionrow[$key] = $value;
2286 $all_questions[
$row[
"question_id"]] = $questionrow;
2287 $all_questions[$row[
"question_id"]][
"usableForPrecondition"] = $question->usableForPrecondition();
2288 $all_questions[$row[
"question_id"]][
"availableRelations"] = $question->getAvailableRelations();
2289 if (array_key_exists($row[
"question_id"], $obligatory_states))
2291 $all_questions[$row[
"question_id"]][
"obligatory"] = $obligatory_states[$row[
"question_id"]];
2296 $questionblocks = array();
2297 if (count($all_questions))
2299 $result = $ilDB->queryF(
"SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst WHERE " .
2300 "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
2301 "AND " . $ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions),
false,
'integer'),
2307 $questionblocks[
$row[
'question_fi']] =
$row;
2311 foreach ($all_questions as $question_id =>
$row)
2314 if (isset($questionblocks[$question_id]))
2316 $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
2317 $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
2318 $all_questions[$question_id][
"constraints"] = $constraints;
2322 $all_questions[$question_id][
"questionblock_title"] =
"";
2323 $all_questions[$question_id][
"questionblock_id"] =
"";
2324 $all_questions[$question_id][
"constraints"] = $constraints;
2329 $result = $ilDB->queryF(
"SELECT svy_variable.*, svy_category.title FROM svy_variable, svy_category " .
2330 "WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id ".
2331 "ORDER BY sequence ASC",
2339 array_push($answers,
$data[
"title"]);
2342 $all_questions[$question_id][
"answers"] = $answers;
2345 return $all_questions;
2357 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
2365 if (!array_key_exists(
$row[
"question_fi"], $obligatory_questions))
2367 $obligatory_questions[
$row[
"question_fi"]] = 0;
2373 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_qst_oblig WHERE survey_fi = %s",
2379 foreach ($obligatory_questions as $question_fi => $obligatory)
2381 $next_id = $ilDB->nextId(
'svy_qst_oblig');
2382 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, " .
2383 "obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)",
2384 array(
'integer',
'integer',
'integer',
'text',
'integer'),
2385 array($next_id, $this->
getSurveyId(), $question_fi, (strlen($obligatory)) ? $obligatory : 0, time())
2399 $obligatory_states = array();
2400 $result = $ilDB->queryF(
"SELECT * FROM svy_qst_oblig WHERE survey_fi = %s",
2408 $obligatory_states[
$row[
"question_fi"]] = $row[
"obligatory"];
2411 return $obligatory_states;
2424 $all_questions = array();
2425 $result = $ilDB->queryF(
"SELECT svy_question.*, svy_qtype.type_tag, svy_svy_qst.heading FROM " .
2426 "svy_question, svy_qtype, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
2427 "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id ".
2428 "ORDER BY svy_svy_qst.sequence",
2434 $all_questions[
$row[
"question_id"]] =
$row;
2437 $questionblocks = array();
2438 if (count($all_questions))
2440 $result = $ilDB->queryF(
"SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst ".
2441 "WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s ".
2442 "AND " . $ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions),
false,
'integer'),
2448 $questionblocks[
$row[
'question_fi']] =
$row;
2452 $all_pages = array();
2455 foreach ($all_questions as $question_id =>
$row)
2457 if (array_key_exists($question_id, $obligatory_states))
2459 $all_questions[$question_id][
"obligatory"] = $obligatory_states[$question_id];
2461 $constraints = array();
2462 if (isset($questionblocks[$question_id]))
2464 if (!$currentblock or ($currentblock != $questionblocks[$question_id][
'questionblock_id']))
2468 $all_questions[$question_id][
'page'] = $pageindex;
2469 $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
2470 $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
2471 $all_questions[$question_id][
"questionblock_show_questiontext"] = $questionblocks[$question_id][
'show_questiontext'];
2472 $currentblock = $questionblocks[$question_id][
'questionblock_id'];
2474 $all_questions[$question_id][
"constraints"] = $constraints;
2479 $all_questions[$question_id][
'page'] = $pageindex;
2480 $all_questions[$question_id][
"questionblock_title"] =
"";
2481 $all_questions[$question_id][
"questionblock_id"] =
"";
2482 $all_questions[$question_id][
"questionblock_show_questiontext"] = 1;
2485 $all_questions[$question_id][
"constraints"] = $constraints;
2487 if (!isset($all_pages[$pageindex]))
2489 $all_pages[$pageindex] = array();
2491 array_push($all_pages[$pageindex], $all_questions[$question_id]);
2494 $max = count($all_pages);
2496 foreach ($all_pages as $index => $block)
2498 foreach ($block as $blockindex => $question)
2500 $all_pages[$index][$blockindex][
"position"] = $counter / $max;
2519 if (strcmp($active_page_question_id,
"") == 0)
2523 foreach ($pages as $key => $question_array)
2525 foreach ($question_array as $question)
2527 if ($active_page_question_id == $question[
"question_id"])
2533 if ($foundpage == -1)
2539 $foundpage += $direction;
2544 if ($foundpage >= count($pages))
2548 return $pages[$foundpage];
2560 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
2573 $result_array = array();
2574 $result = $ilDB->queryF(
"SELECT svy_constraint.*, svy_relation.* FROM svy_qst_constraint, svy_constraint, ".
2575 "svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id AND ".
2576 "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_constraint.constraint_id = %s",
2583 $pc = $ilDB->fetchAssoc(
$result);
2597 $result_array = array();
2598 $result = $ilDB->queryF(
"SELECT svy_constraint.*, svy_relation.* FROM svy_qst_constraint, svy_constraint, svy_relation ".
2599 "WHERE svy_constraint.relation_fi = svy_relation.relation_id AND ".
2600 "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.question_fi = %s ".
2601 "AND svy_qst_constraint.survey_fi = %s",
2602 array(
'integer',
'integer'),
2607 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
2610 $question =
new $question_type();
2611 $question->loadFromDb(
$row[
"question_fi"]);
2612 $valueoutput = $question->getPreconditionValueOutput(
$row[
"value"]);
2613 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));
2615 return $result_array;
2626 $result_array = array();
2627 $result = $ilDB->queryF(
"SELECT svy_qst_constraint.question_fi as for_question, svy_constraint.*, svy_relation.* ".
2628 "FROM svy_qst_constraint, svy_constraint, svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id ".
2629 "AND svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.survey_fi = %s",
2635 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']));
2637 return $result_array;
2650 $result_array = array();
2651 $result = $ilDB->queryF(
"SELECT svy_variable.*, svy_category.title FROM svy_variable LEFT JOIN ".
2652 "svy_category ON svy_variable.category_fi = svy_category.category_id WHERE svy_variable.question_fi = %s ".
2653 "ORDER BY svy_variable.sequence",
2659 $result_array[
$row->sequence] =
$row;
2661 return $result_array;
2676 $next_id = $ilDB->nextId(
'svy_constraint');
2677 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_constraint (constraint_id, question_fi, relation_fi, value, conjunction) VALUES ".
2678 "(%s, %s, %s, %s, %s)",
2679 array(
'integer',
'integer',
'integer',
'float',
'integer'),
2680 array($next_id, $if_question_id, $relation, $value, $conjunction)
2703 $next_id = $ilDB->nextId(
'svy_qst_constraint');
2704 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qst_constraint (question_constraint_id, survey_fi, question_fi, ".
2705 "constraint_fi) VALUES (%s, %s, %s, %s)",
2706 array(
'integer',
'integer',
'integer',
'integer'),
2707 array($next_id, $this->
getSurveyId(), $to_question_id, $constraint_id)
2724 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_constraint SET question_fi = %s, relation_fi = %s, value = %s, conjunction = %s ".
2725 "WHERE constraint_id = %s",
2726 array(
'integer',
'integer',
'float',
'integer',
'integer'),
2727 array($if_question_id, $relation, $value, $conjunction, $precondition_id)
2736 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_constraint SET conjunction = %s ".
2737 "WHERE constraint_id IN (SELECT constraint_fi FROM svy_qst_constraint WHERE svy_qst_constraint.question_fi = %s)",
2738 array(
'integer',
'integer'),
2739 array($conjunction, $question_id)
2753 $result_array = array();
2754 $result = $ilDB->query(
"SELECT * FROM svy_relation");
2759 $result_array[
$row[
"shortname"]] = array(
"short" => $row[
"shortname"],
"long" => $row[
"longname"],
"id" => $row[
"relation_id"]);
2763 $result_array[
$row[
"relation_id"]] = array(
"short" => $row[
"shortname"],
"long" => $row[
"longname"]);
2766 return $result_array;
2775 $result = $ilDB->queryF(
"SELECT user_fi FROM svy_inv_usr WHERE survey_fi = %s",
2794 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_inv_usr WHERE survey_fi = %s AND user_fi = %s",
2795 array(
'integer',
'integer'),
2798 include_once
'./Services/User/classes/class.ilObjUser.php';
2812 $result = $ilDB->queryF(
"SELECT user_fi FROM svy_inv_usr WHERE user_fi = %s AND survey_fi = %s",
2813 array(
'integer',
'integer'),
2818 $next_id = $ilDB->nextId(
'svy_inv_usr');
2819 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_inv_usr (invited_user_id, survey_fi, user_fi, tstamp) " .
2820 "VALUES (%s, %s, %s, %s)",
2821 array(
'integer',
'integer',
'integer',
'integer'),
2822 array($next_id, $this->
getSurveyId(), $user_id, time())
2827 include_once
'./Services/User/classes/class.ilObjUser.php';
2842 include_once
"./Modules/Group/classes/class.ilObjGroup.php";
2844 $members = $group->getGroupMemberIds();
2845 foreach ($members as $user_id)
2847 if ($ilAccess->checkAccessOfUser($user_id,
"read",
"", $this->getRefId(),
"svy", $this->
getId()))
2852 include_once
'./Services/User/classes/class.ilObjUser.php';
2871 $members = $rbacreview->assignedUsers($role_id);
2872 foreach ($members as $user_id)
2874 if ($ilAccess->checkAccessOfUser($user_id,
"read",
"", $this->getRefId(),
"svy", $this->
getId()))
2879 include_once
'./Services/User/classes/class.ilObjUser.php';
2897 $result_array = array();
2898 $result = $ilDB->queryF(
"SELECT user_fi FROM svy_inv_usr WHERE survey_fi = %s",
2904 array_push($result_array,
$row[
"user_fi"]);
2906 return $result_array;
2920 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
2921 array(
'integer',
'integer'),
2922 array($question_id, $active_id)
2937 $result_array = array();
2938 $result = $ilDB->queryF(
"SELECT * FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
2939 array(
'integer',
'integer'),
2940 array($question_id, $active_id)
2946 array_push($result_array,
$row);
2948 return $result_array;
2952 return $result_array;
2969 $active_id = $ilDB->nextId(
'svy_finished');
2970 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_finished (finished_id, survey_fi, user_fi, anonymous_id, state, tstamp) ".
2971 "VALUES (%s, %s, %s, %s, %s, %s)",
2972 array(
'integer',
'integer',
'integer',
'text',
'text',
'integer'),
2973 array($active_id, $this->
getSurveyId(), $user_id, $anonymous_id, 1, time())
2977 foreach ($pages as $key => $question_array)
2979 foreach ($question_array as $question)
2982 require_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
2984 $question->saveRandomData($active_id);
3000 if ($this->
getAnonymize() && (strlen($anonymous_id) == 0))
return;
3002 if (strcmp($user_id,
"") == 0)
3004 if ($user_id == ANONYMOUS_USER_ID)
3009 $next_id = $ilDB->nextId(
'svy_finished');
3010 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_finished (finished_id, survey_fi, user_fi, anonymous_id, state, tstamp) ".
3011 "VALUES (%s, %s, %s, %s, %s, %s)",
3012 array(
'integer',
'integer',
'integer',
'text',
'text',
'integer'),
3013 array($next_id, $this->
getSurveyId(), $user_id, $anonymous_id, 0, time())
3030 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_finished SET state = %s, user_fi = %s, tstamp = %s ".
3031 "WHERE survey_fi = %s AND anonymous_id = %s",
3032 array(
'text',
'integer',
'integer',
'integer',
'text'),
3033 array(1, $user_id, time(), $this->
getSurveyId(), $anonymize_id)
3038 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_finished SET state = %s, tstamp = %s WHERE survey_fi = %s AND user_fi = %s",
3039 array(
'text',
'integer',
'integer',
'integer'),
3060 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_finished SET lastpage = %s WHERE finished_id = %s",
3061 array(
'integer',
'integer'),
3062 array(($page_id) ? $page_id : 0, $finished_id)
3068 include_once
"./Services/User/classes/class.ilObjUser.php";
3069 include_once
"./Services/Mail/classes/class.ilMail.php";
3070 $mail =
new ilMail(ANONYMOUS_USER_ID);
3071 $recipients = preg_split(
'/,/', $this->mailaddresses);
3072 foreach ($recipients as $recipient)
3076 foreach (
$data[0] as $key => $value)
3080 $messagetext = str_replace(
'[' . $key .
']',
'', $messagetext);
3084 $messagetext = str_replace(
'[' . $key .
']', $value, $messagetext);
3087 $active_id = $this->
getActiveID($user_id, $anonymize_id);
3088 $messagetext .= ((strlen($messagetext)) ?
"\n\n\n" :
'') . $this->lng->txt(
'results') .
"\n\n". $this->
getParticipantTextResults($active_id);
3089 if (($not_sent != 1) ||
$data[
'sent'] == 0)
3091 $res = $mail->sendMail(
3095 $this->lng->txt(
'finished_mail_subject') .
': ' . $this->
getTitle(),
3109 $questioncounter = 1;
3110 foreach (
$questions as $question_id => $question_data)
3112 $textresult .= $questioncounter++ .
". " . $question_data[
"title"] .
"\n";
3113 $found = $userResults[$question_id][$active_id];
3115 if (is_array($found))
3117 $text = implode(
"\n", $found);
3123 if (strlen($text) == 0) $text = $this->lng->txt(
"skipped");
3124 $text = str_replace(
"<br />",
"\n", $text);
3125 $textresult .= $text .
"\n\n";
3137 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3158 if (strlen($username) == 0)
3161 $userid = $ilUser->getId();
3164 $surveysetting =
new ilSetting(
"survey");
3165 $allowedUsers = strlen($surveysetting->get(
"multiple_survey_users")) ? explode(
",",$surveysetting->get(
"multiple_survey_users")) : array();
3166 if (in_array($userid, $allowedUsers))
3190 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
3191 array(
'integer',
'integer'),
3197 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
3198 array(
'integer',
'text'),
3205 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
3206 array(
'integer',
'integer'),
3218 return (
int)
$row[
"state"];
3237 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
3238 array(
'integer',
'integer'),
3244 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
3245 array(
'integer',
'text'),
3252 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
3253 array(
'integer',
'integer'),
3264 return $row[
"finished_id"];
3278 $result = $ilDB->queryF(
"SELECT lastpage FROM svy_finished WHERE finished_id = %s",
3289 return (
$row[
"lastpage"]) ?
$row[
"lastpage"] :
'';
3303 if (count($working_data) == 0)
3308 if ((count($working_data) == 1) and (strcmp($working_data[0][
"value"],
"") == 0))
3314 foreach ($working_data as
$data)
3316 switch ($constraint_data[
"short"])
3319 if ($data[
"value"] < $constraint_data[
"value"])
3326 if ($data[
"value"] <= $constraint_data[
"value"])
3333 if ($data[
"value"] == $constraint_data[
"value"])
3340 if ($data[
"value"] <> $constraint_data[
"value"])
3347 if ($data[
"value"] >= $constraint_data[
"value"])
3354 if ($data[
"value"] > $constraint_data[
"value"])
3373 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
3377 return (
$result->numRows()) ?
true :
false;
3391 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s",
3399 array_push($users,
$row[
"finished_id"]);
3416 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s",
3424 array_push($users,
$row);
3427 $evaluation = array();
3429 foreach (
$questions as $question_id => $question_data)
3431 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3434 $question =
new $question_type();
3435 $question->loadFromDb($question_id);
3437 $evaluation[$question_id] =
$data;
3453 $surveySetting =
new ilSetting(
"survey");
3454 $use_anonymous_id = array_key_exists(
"use_anonymous_id",
$_GET) ?
$_GET[
"use_anonymous_id"] : $surveySetting->get(
"use_anonymous_id");
3455 $result = $ilDB->queryF(
"SELECT * FROM svy_finished WHERE finished_id = %s",
3460 $foundrows =
$result->numRows();
3465 $name = ($use_anonymous_id) ?
$row[
"anonymous_id"] : $this->lng->txt(
"anonymous");
3467 "fullname" => $name,
3468 "sortname" => $name,
3473 "active_id" =>
"$active_id"
3477 if ((
$row[
"user_fi"] > 0) && (
$row[
"user_fi"] != ANONYMOUS_USER_ID) && ($this->
getAnonymize() == 0))
3479 include_once
'./Services/User/classes/class.ilObjUser.php';
3482 $userdata[
"fullname"] = $this->lng->txt(
"deleted_user");
3487 $userdata[
"fullname"] =
$user->getFullname();
3488 $gender =
$user->getGender();
3489 if (strlen($gender) == 1) $gender = $this->lng->txt(
"gender_$gender");
3490 $userdata[
"gender"] = $gender;
3491 $userdata[
"firstname"] =
$user->getFirstname();
3492 $userdata[
"lastname"] =
$user->getLastname();
3493 $userdata[
"sortname"] =
$user->getLastname() .
", " .
$user->getFirstname();
3494 $userdata[
"login"] =
$user->getLogin();
3516 $result = $ilDB->queryF(
"SELECT * FROM svy_answer WHERE active_fi = %s",
3522 if (!is_array($answers[
$row[
"question_fi"]]))
3524 $answers[$row[
"question_fi"]] = array();
3526 array_push($answers[$row[
"question_fi"]], $row);
3530 "name" => $userdata[
"fullname"],
3531 "gender" => $userdata[
"gender"],
3532 "answers" => array()
3536 if (array_key_exists($key, $answers))
3538 $resultset[
"answers"][$key] = $answers[$key];
3542 $resultset[
"answers"][$key] = array();
3544 sort($resultset[
"answers"][$key]);
3561 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
3565 $nr_of_users =
$result->numRows();
3567 $result_array =& $question->getCumulatedResults($this->
getSurveyId(), $nr_of_users);
3568 return $result_array;
3582 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
3591 $result_array = array();
3592 $result =
$ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype WHERE ".
3593 "svy_question.questiontype_fi = svy_qtype.questiontype_id AND svy_question.tstamp > 0 AND ".
3594 $ilDB->in(
'svy_question.question_id', $question_ids,
false,
'integer'));
3597 array_push($result_array,
$row);
3599 return $result_array;
3612 if (is_array($arrFilter))
3614 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
3616 $where .=
" AND " . $ilDB->like(
'svy_question.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
3618 if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description']))
3620 $where .=
" AND " . $ilDB->like(
'svy_question.description',
'text',
"%%" . $arrFilter[
'description'] .
"%%");
3622 if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author']))
3624 $where .=
" AND " . $ilDB->like(
'svy_question.author',
'text',
"%%" . $arrFilter[
'author'] .
"%%");
3626 if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type']))
3628 $where .=
" AND svy_qtype.type_tag = " . $ilDB->quote($arrFilter[
'type'],
'text');
3630 if (array_key_exists(
'spl', $arrFilter) && strlen($arrFilter[
'spl']))
3632 $where .=
" AND svy_question.obj_fi = " . $ilDB->quote($arrFilter[
'spl'],
'integer');
3638 $forbidden =
" AND " . $ilDB->in(
'svy_question.obj_fi', array_keys($spls),
false,
'integer');
3639 $forbidden .=
" AND svy_question.complete = " . $ilDB->quote(
"1",
'text');
3642 if (count($existing_questions))
3644 $existing =
" AND " . $ilDB->in(
'svy_question.question_id', $existing_questions,
true,
'integer');
3647 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
3650 $query_result = $ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin, object_reference.ref_id FROM svy_question, svy_qtype, object_reference WHERE svy_question.original_id IS NULL$forbidden$existing AND svy_question.obj_fi = object_reference.obj_id AND svy_question.tstamp > 0 AND svy_question.questiontype_fi = svy_qtype.questiontype_id " . $where);
3653 if ($query_result->numRows())
3655 while (
$row = $ilDB->fetchAssoc($query_result))
3657 $row[
'ttype'] = $trans[
$row[
'type_tag']];
3662 array_push($rows, $row);
3667 array_push($rows, $row);
3684 if (is_array($arrFilter))
3686 if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
3688 $where .=
" AND " . $ilDB->like(
'svy_qblk.title',
'text',
"%%" . $arrFilter[
'title'] .
"%%");
3692 $query_result = $ilDB->query(
"SELECT svy_qblk.*, svy_svy.obj_fi FROM svy_qblk , svy_qblk_qst, svy_svy WHERE ".
3693 "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_svy.survey_id = svy_qblk_qst.survey_fi ".
3694 "$where GROUP BY svy_qblk.questionblock_id, svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.owner_fi, svy_qblk.tstamp, svy_svy.obj_fi");
3696 if ($query_result->numRows())
3699 $surveytitles = array();
3700 foreach ($surveys as
$data)
3702 $surveytitles[$data[
'id']] = $data[
'title'];
3704 while (
$row = $ilDB->fetchAssoc($query_result))
3708 foreach ($questions_array as $key => $value)
3710 $questions_array[$key] =
"$counter. $value";
3713 if (strlen($surveytitles[
$row[
"obj_fi"]]))
3715 $rows[$row[
"questionblock_id"]] = array(
3716 "questionblock_id" => $row[
"questionblock_id"],
3717 "title" => $row[
"title"],
3718 "svy" => $surveytitles[$row[
"obj_fi"]],
3719 "contains" => join($questions_array,
", "),
3720 "owner" => $row[
"owner_fi"]
3736 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
3741 "xmlns:xsi" =>
"http://www.w3.org/2001/XMLSchema-instance",
3742 "xsi:noNamespaceSchemaLocation" =>
"http://www.ilias.de/download/xsd/ilias_survey_3_8.xsd"
3744 $a_xml_writer->xmlStartTag(
"surveyobject", $attrs);
3749 $a_xml_writer->xmlStartTag(
"survey", $attrs);
3751 $a_xml_writer->xmlElement(
"description", NULL, $this->
getDescription());
3752 $a_xml_writer->xmlElement(
"author", NULL, $this->
getAuthor());
3753 $a_xml_writer->xmlStartTag(
"objectives");
3755 "label" =>
"introduction"
3762 $a_xml_writer->xmlEndTag(
"objectives");
3766 $attribs = array(
"enabled" =>
"1");
3770 $attribs = array(
"enabled" =>
"0");
3772 $a_xml_writer->xmlElement(
"anonymisation", $attribs);
3773 $a_xml_writer->xmlStartTag(
"restrictions");
3776 $attribs = array(
"type" =>
"free");
3780 $attribs = array(
"type" =>
"restricted");
3782 $a_xml_writer->xmlElement(
"access", $attribs);
3785 $attrs = array(
"type" =>
"date");
3790 $attrs = array(
"type" =>
"date");
3793 $a_xml_writer->xmlEndTag(
"restrictions");
3797 $hasconstraints = FALSE;
3798 foreach ($pages as $question_array)
3800 foreach ($question_array as $question)
3802 if (count($question[
"constraints"]))
3804 $hasconstraints = TRUE;
3809 if ($hasconstraints)
3811 $a_xml_writer->xmlStartTag(
"constraints");
3812 foreach ($pages as $question_array)
3814 foreach ($question_array as $question)
3816 if (count($question[
"constraints"]))
3819 foreach ($question[
"constraints"] as $constraint)
3822 "sourceref" => $question[
"question_id"],
3823 "destref" => $constraint[
"question"],
3824 "relation" => $constraint[
"short"],
3825 "value" => $constraint[
"value"]
3827 $a_xml_writer->xmlElement(
"constraint", $attribs);
3832 $a_xml_writer->xmlEndTag(
"constraints");
3836 $a_xml_writer->xmlStartTag(
"metadata");
3838 $a_xml_writer->xmlStartTag(
"metadatafield");
3839 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"evaluation_access");
3841 $a_xml_writer->xmlEndTag(
"metadatafield");
3843 $a_xml_writer->xmlStartTag(
"metadatafield");
3844 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"status");
3845 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getStatus());
3846 $a_xml_writer->xmlEndTag(
"metadatafield");
3848 $a_xml_writer->xmlStartTag(
"metadatafield");
3849 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"display_question_titles");
3851 $a_xml_writer->xmlEndTag(
"metadatafield");
3853 $a_xml_writer->xmlStartTag(
"metadatafield");
3854 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"SCORM");
3855 include_once
"./Services/MetaData/classes/class.ilMD.php";
3858 $md->toXml($writer);
3859 $metadata = $writer->xmlDumpMem();
3860 $a_xml_writer->xmlElement(
"fieldentry", NULL, $metadata);
3861 $a_xml_writer->xmlEndTag(
"metadatafield");
3863 $a_xml_writer->xmlEndTag(
"metadata");
3864 $a_xml_writer->xmlEndTag(
"survey");
3866 $attribs = array(
"id" => $this->
getId());
3867 $a_xml_writer->xmlStartTag(
"surveyquestions", $attribs);
3870 foreach ($pages as $question_array)
3872 if (count($question_array) > 1)
3874 $attribs = array(
"id" => $question_array[0][
"question_id"]);
3875 $attribs = array(
"showQuestiontext" => $question_array[0][
"questionblock_show_questiontext"]);
3876 $a_xml_writer->xmlStartTag(
"questionblock", $attribs);
3877 if (strlen($question_array[0][
"questionblock_title"]))
3879 $a_xml_writer->xmlElement(
"questionblocktitle", NULL, $question_array[0][
"questionblock_title"]);
3882 foreach ($question_array as $question)
3884 if (strlen($question[
"heading"]))
3886 $a_xml_writer->xmlElement(
"textblock", NULL, $question[
"heading"]);
3889 if ($questionObject !== FALSE) $questionObject->insertXML($a_xml_writer, FALSE, $obligatory_states[$question[
"question_id"]]);
3891 if (count($question_array) > 1)
3893 $a_xml_writer->xmlEndTag(
"questionblock");
3897 $a_xml_writer->xmlEndTag(
"surveyquestions");
3898 $a_xml_writer->xmlEndTag(
"surveyobject");
3899 $xml = $a_xml_writer->xmlDumpMem(FALSE);
3912 if ($question_id < 1)
return FALSE;
3913 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
3915 if (strlen($question_type) == 0)
return FALSE;
3917 $question =
new $question_type();
3918 $question->loadFromDb($question_id);
3930 if (!is_dir($a_dir) || is_int(strpos($a_dir,
"..")))
3934 $importDirectory =
"";
3937 $current_dir = opendir($a_dir);
3939 while($entryname = readdir($current_dir))
3946 if(is_dir($a_dir.
"/".$file) and ($file !=
"." and $file!=
".."))
3949 $importDirectory = $a_dir.
"/".
$file;
3952 closedir($current_dir);
3953 if (strlen($importDirectory))
3956 $current_dir = opendir($importDirectory);
3958 while($entryname = readdir($current_dir))
3964 if(@is_file($importDirectory.
"/".$file) && ($file !=
"." && $file!=
"..") && (strcmp(strtolower(substr($file, -4, 4)),
".xml") == 0))
3967 $xmlFile = $importDirectory.
"/".
$file;
3971 return array(
"dir" => $importDirectory,
"xml" => $xmlFile);
3983 $source = $file_info[
"tmp_name"];
3985 if (($source ==
'none') || (!$source) || $file_info[
"error"] > UPLOAD_ERR_OK)
3987 $error = $this->lng->txt(
"import_no_file_selected");
3992 if ((strcmp($file_info[
"type"],
"text/xml") == 0) || (strcmp($file_info[
"type"],
"application/xml") == 0))
3996 if (strpos($file_info[
"type"],
"zip") !== FALSE)
4000 if (!$isXml && !$isZip)
4002 $error = $this->lng->txt(
"import_wrong_file_type");
4004 $ilLog->write(
"Survey: Import error. Filetype was \"" . $file_info[
"type"] .
"\"");
4006 if (strlen($error) == 0)
4010 $import_subdir =
"";
4012 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4015 $importfile = $import_dir.
"/".$file_info[
"name"];
4019 if (!((strlen($found[
"dir"]) > 0) && (strlen($found[
"xml"]) > 0)))
4021 $error = $this->lng->txt(
"wrong_import_file_structure");
4024 $importfile = $found[
"xml"];
4025 $import_subdir = $found[
"dir"];
4029 $importfile = tempnam($import_dir,
"survey_import");
4032 $fh = fopen($importfile,
"r");
4035 $error = $this->lng->txt(
"import_error_opening_file");
4038 $xml = fread($fh, filesize($importfile));
4042 $error = $this->lng->txt(
"import_error_closing_file");
4047 if (strpos($xml,
"questestinterop"))
4049 include_once
"./Services/Survey/classes/class.SurveyImportParserPre38.php";
4050 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
4053 $import->setSurveyObject($this);
4054 $import->setXMLContent($xml);
4055 $import->startParsing();
4059 include_once
"./Services/Survey/classes/class.SurveyImportParser.php";
4060 include_once
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
4063 $import->setSurveyObject($this);
4064 $import->setXMLContent($xml);
4065 $import->startParsing();
4068 if (is_array(
$_SESSION[
"import_mob_xhtml"]))
4070 include_once
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
4071 include_once
"./Services/RTE/classes/class.ilRTE.php";
4072 include_once
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
4073 foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
4075 $importfile = $import_subdir .
"/" . $mob[
"uri"];
4076 if (file_exists($importfile))
4080 $this->
setIntroduction(str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $this->
getIntroduction()));
4081 $this->
setOutro(str_replace(
"src=\"" . $mob[
"mob"] .
"\"",
"src=\"" .
"il_" . IL_INST_ID .
"_mob_" . $media_object->getId() .
"\"", $this->
getOutro()));
4086 $ilLog->write(
"Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
4121 $newObj->setOutro($this->
getOutro());
4134 $question_pointer = array();
4137 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
4138 foreach ($this->questions as $key => $question_id)
4143 $question->saveToDb($original_id);
4144 $newObj->questions[$key] = $question->getId();
4145 $question_pointer[$question_id] = $question->getId();
4146 $mapping[$question_id] = $question->getId();
4149 $newObj->saveToDb();
4150 $newObj->cloneTextblocks($mapping);
4153 $questionblocks = array();
4154 $questionblock_questions = array();
4155 $result = $ilDB->queryF(
"SELECT * FROM svy_qblk_qst WHERE survey_fi = %s",
4163 array_push($questionblock_questions,
$row);
4164 $questionblocks[
$row[
"questionblock_fi"]] = $row[
"questionblock_fi"];
4168 foreach ($questionblocks as $key => $value)
4172 $questionblocks[$key] = $questionblock_id;
4175 foreach ($questionblock_questions as $key => $value)
4177 $next_id = $ilDB->nextId(
'svy_qblk_qst');
4178 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, question_fi) ".
4179 "VALUES (%s, %s, %s, %s)",
4180 array(
'integer',
'integer',
'integer',
'integer'),
4181 array($next_id, $newObj->getSurveyId(), $questionblocks[$value[
"questionblock_fi"]], $question_pointer[$value[
"question_fi"]])
4187 $newConstraints = array();
4188 foreach ($constraints as $key => $constraint)
4190 if (!array_key_exists($constraint[
'id'], $newConstraints))
4192 $constraint_id = $newObj->addConstraint($question_pointer[$constraint[
"question"]], $constraint[
"relation_id"], $constraint[
"value"], $constraint[
'conjunction']);
4193 $newConstraints[$constraint[
'id']] = $constraint_id;
4195 $newObj->addConstraintToQuestion($question_pointer[$constraint[
"for_question"]], $newConstraints[$constraint[
'id']]);
4199 $result = $ilDB->queryF(
"SELECT * FROM svy_qst_oblig WHERE survey_fi = %s",
4207 $next_id = $ilDB->nextId(
'svy_qst_oblig');
4208 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, ".
4209 "obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)",
4210 array(
'integer',
'integer',
'integer',
'text',
'integer'),
4211 array($next_id, $newObj->getSurveyId(), $question_pointer[
$row[
"question_fi"]], $row[
"obligatory"], time())
4221 $result = $ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE question_fi = %s",
4228 return $row[
"heading"];
4243 foreach ($mapping as $original_id => $new_id)
4246 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
4258 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4261 if(!is_writable($svy_data_dir))
4263 $this->ilias->raiseError(
"Survey Data Directory (".$svy_data_dir
4264 .
") not writeable.",$this->ilias->error_obj->FATAL);
4268 $svy_dir = $svy_data_dir.
"/svy_".$this->
getId();
4270 if(!@is_dir($svy_dir))
4272 $this->ilias->raiseError(
"Creation of Survey Directory failed.",$this->ilias->error_obj->FATAL);
4275 $export_dir = $svy_dir.
"/export";
4277 if(!@is_dir($export_dir))
4279 $this->ilias->raiseError(
"Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
4288 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4300 if (!@is_dir(
$dir) or
4301 !is_writeable(
$dir))
4313 while ($entry =
$dir->read())
4315 if ($entry !=
"." and
4317 ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(survey__)*[0-9]+\.xml|zip\$", $entry))
4339 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4343 if(!is_writable($svy_data_dir))
4345 $this->ilias->raiseError(
"Survey Data Directory (".$svy_data_dir
4346 .
") not writeable.",$this->ilias->error_obj->FATAL);
4350 $svy_dir = $svy_data_dir.
"/svy_".$this->
getId();
4352 if(!@is_dir($svy_dir))
4354 $this->ilias->raiseError(
"Creation of Survey Directory failed.",$this->ilias->error_obj->FATAL);
4358 $import_dir = $svy_dir.
"/import";
4360 if(!@is_dir($import_dir))
4362 $this->ilias->raiseError(
"Creation of Import Directory failed.",$this->ilias->error_obj->FATAL);
4371 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4373 "/svy_".$this->getId().
"/import";
4374 if (!is_dir($import_dir))
4378 if(@is_dir($import_dir))
4393 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
4394 array(
'text',
'integer',
'integer'),
4395 array($heading, $this->
getSurveyId(), $insertbefore)
4400 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
4401 array(
'text',
'integer',
'integer'),
4411 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_anonymous WHERE survey_key = %s AND survey_fi = %s",
4412 array(
'text',
'integer'),
4415 return (
$result->numRows() == 1) ?
true :
false;
4423 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
4424 array(
'integer',
'integer'),
4430 return $row[
"anonymous_id"];
4442 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE anonymous_id = %s AND survey_fi = %s",
4443 array(
'text',
'integer'),
4446 return (
$result->numRows() == 1) ?
true :
false;
4478 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND user_key IS NULL",
4494 global
$ilDB, $ilUser;
4496 $result = $ilDB->queryF(
"SELECT svy_anonymous.*, svy_finished.state FROM svy_anonymous ".
4497 "LEFT JOIN svy_finished ON svy_anonymous.survey_key = svy_finished.anonymous_id ".
4498 "WHERE svy_anonymous.survey_fi = %s AND svy_anonymous.user_key IS NULL",
4503 $default_lang = $ilUser->getPref(
"survey_code_language");
4504 $lang = (strlen($default_lang)) ?
"&lang=" . $default_lang :
"";
4507 if (in_array(
$row[
"survey_key"], $a_array) || (count($a_array) == 0))
4509 $export .=
$row[
"survey_key"] .
",";
4514 $export .=
"$created,";
4523 $url = ILIAS_HTTP_PATH.
"/goto.php?cmd=infoScreen&target=svy_".$this->
getRefId() .
"&client_id=" . CLIENT_ID .
"&accesscode=".$row[
"survey_key"].$lang;
4524 $export .= $url .
"\n";
4541 include_once
"./classes/class.ilFormat.php";
4544 $order =
"ORDER BY tstamp, survey_key ASC";
4546 $result = $ilDB->queryF(
"SELECT svy_anonymous.anonymous_id, svy_anonymous.survey_key, svy_anonymous.survey_fi, ".
4547 "svy_anonymous.tstamp, svy_finished.state FROM svy_anonymous LEFT JOIN svy_finished ".
4548 "ON svy_anonymous.survey_key = svy_finished.anonymous_id WHERE svy_anonymous.survey_fi = %s ".
4549 "AND svy_anonymous.user_key IS NULL $order",
4570 $addlang =
"&lang=$lang";
4572 $href = ILIAS_HTTP_PATH.
"/goto.php?cmd=infoScreen&target=svy_".$this->
getRefId() .
"&client_id=" . CLIENT_ID .
"&accesscode=".$row[
"survey_key"].$addlang;
4573 $url = $this->lng->txt(
"survey_code_url_name");
4575 array_push($codes, array(
'code' =>
$row[
"survey_key"],
'date' => $created,
'used' => $state,
'url' => $url,
'href' => $href));
4584 $result = $ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
4585 array(
'integer',
'text'),
4588 return (
$result->numRows() > 0) ?
true :
false;
4594 $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
4595 array(
'integer',
'text'),
4598 return (
$result->numRows() > 0) ?
false :
true;
4604 for ($i = 0; $i < $nrOfCodes; $i++)
4607 $next_id = $ilDB->nextId(
'svy_anonymous');
4608 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, tstamp) ".
4609 "VALUES (%s, %s, %s, %s)",
4610 array(
'integer',
'text',
'integer',
'integer'),
4611 array($next_id, $anonymize_key, $this->
getSurveyId(), time())
4619 foreach (
$data as $dataset)
4622 $next_id = $ilDB->nextId(
'svy_anonymous');
4623 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) ".
4624 "VALUES (%s, %s, %s, %s, %s)",
4625 array(
'integer',
'text',
'integer',
'text',
'integer'),
4626 array($next_id, $anonymize_key, $this->
getSurveyId(), serialize($dataset), time())
4633 include_once
"./Services/Mail/classes/class.ilMail.php";
4635 $mail =
new ilMail($user_id);
4637 foreach ($recipients as
$data)
4639 $messagetext = $message;
4640 $url = ILIAS_HTTP_PATH.
"/goto.php?cmd=infoScreen&target=svy_".$this->
getRefId() .
"&client_id=" . CLIENT_ID .
"&accesscode=".$data[
"code"];
4641 $messagetext = str_replace(
'[url]',
"<" . $url .
">", $messagetext);
4642 foreach ($data as $key => $value)
4644 $messagetext = str_replace(
'[' . $key .
']', $value, $messagetext);
4646 if (($not_sent != 1) || $data[
'sent'] == 0)
4648 $res = $mail->sendMail(
4661 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_anonymous SET sent = %s WHERE survey_fi = %s AND externaldata IS NOT NULL",
4662 array(
'integer',
'integer'),
4670 $result = $ilDB->queryF(
"SELECT survey_key code, externaldata, sent FROM svy_anonymous WHERE survey_fi = %s AND externaldata IS NOT NULL",
4677 $externaldata = unserialize(
$row[
'externaldata']);
4678 $externaldata[
'code'] =
$row[
'code'];
4679 $externaldata[
'sent'] =
$row[
'sent'];
4680 array_push(
$res, $externaldata);
4694 if (strlen($survey_code) > 0)
4696 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
4697 array(
'integer',
'text'),
4713 $result = $ilDB->queryF(
"SELECT survey_key FROM svy_anonymous WHERE survey_fi = %s AND user_key = %s",
4714 array(
'integer',
'text'),
4720 $access_code =
$row[
"survey_key"];
4722 return $access_code;
4734 $next_id = $ilDB->nextId(
'svy_anonymous');
4735 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, user_key, tstamp) ".
4736 "VALUES (%s, %s, %s, %s, %s)",
4737 array(
'integer',
'text',
'integer',
'text',
'integer'),
4738 array($next_id, $access_code, $this->
getSurveyId(), md5($user_id), time())
4750 $codestring =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
4753 for ($i = 1; $i <=5; $i++)
4755 $index = mt_rand(0, strlen($codestring)-1);
4756 $code .= substr($codestring, $index, 1);
4779 $resultarray = array();
4780 foreach (
$row as $rowindex => $entry)
4782 if(is_array($entry))
4784 $entry = implode(
"/", $entry);
4791 if (strpos($entry,
"\"") !== FALSE)
4793 $entry = str_replace(
"\"",
"\"\"", $entry);
4801 $entry = str_replace(chr(13).chr(10), chr(10), $entry);
4804 $resultarray[$rowindex] = utf8_decode(
"\"" . $entry .
"\"");
4808 $resultarray[$rowindex] = utf8_decode($entry);
4811 return $resultarray;
4818 $result = $ilDB->queryF(
"SELECT tstamp FROM svy_answer WHERE active_fi = %s ORDER BY tstamp DESC",
4825 return $row[
"tstamp"];
4829 $result = $ilDB->queryF(
"SELECT tstamp FROM svy_finished WHERE finished_id = %s",
4836 return $row[
"tstamp"];
4850 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4863 if (preg_match(
"/<[^>]*?>/", $a_text))
4881 function addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag = TRUE, $add_mobs = TRUE, $attribs = NULL)
4883 include_once
"./Services/RTE/classes/class.ilRTE.php";
4884 include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
4886 $a_xml_writer->xmlStartTag(
"material", $attribs);
4888 "type" =>
"text/plain"
4890 if ($this->
isHTML($a_material))
4892 $attrs[
"type"] =
"text/xhtml";
4895 $a_xml_writer->xmlElement(
"mattext", $attrs, $mattext);
4900 foreach (
$mobs as $mob)
4902 $mob_id =
"il_" . IL_INST_ID .
"_mob_" . $mob;
4903 if (strpos($mattext, $mob_id) !== FALSE)
4908 "uri" =>
"objects/" .
"il_" . IL_INST_ID .
"_mob_" . $mob .
"/" . $mob_obj->getTitle()
4910 $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
4914 if ($close_material_tag) $a_xml_writer->xmlEndTag(
"material");
4929 if ($this->surveyCodeSecurity == FALSE)
4946 $print_output = str_replace(
" ",
" ", $print_output);
4947 $print_output = str_replace(
"⊗",
"X", $print_output);
4948 $xsl = file_get_contents(
"./Modules/Survey/xml/question2fo.xsl");
4949 $args = array(
'/_xml' => $print_output,
'/_xsl' => $xsl );
4952 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args, $params);
4955 global
$ilLog; $ilLog->write($output);
4969 include_once
"./Services/Utilities/classes/class.ilUtil.php";
4971 $fp = fopen($fo_file,
"w"); fwrite($fp, $fo); fclose($fp);
4973 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
4982 $ilLog->write(__METHOD__.
': '.$e->getMessage());
4987 $ilLog->write(__METHOD__.
': '.$e->getMessage());
5004 $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId();
5010 include_once(
"./Modules/Survey/classes/class.ilObjSurveyAccess.php");
5035 global $ilPluginAdmin;
5036 if ($ilPluginAdmin->isActive(
IL_COMP_MODULE,
"SurveyQuestionPool",
"svyq", $a_pname))
5066 if (!is_array($ids) || count($ids) ==0)
return array();
5068 $result = $ilDB->query(
"SELECT usr_id, login, lastname, firstname FROM usr_data WHERE " . $ilDB->in(
'usr_id', $ids,
false,
'integer') .
" ORDER BY login");
5069 $result_array = array();
5072 $result_array[
$row[
"usr_id"]]=
$row;
5074 return $result_array;
5079 if (!is_array($ids) || count($ids) ==0)
return array();
5091 if (!is_array($ids) || count($ids) ==0)
return array();
5093 foreach ($ids as $obj_id)
5107 $this->mailnotification = ($a_notification) ?
true :
false;
5117 $this->mailaddresses = $a_addresses;
5127 $this->mailparticipantdata = $a_data;
5134 $result = $ilDB->queryF(
"SELECT * FROM svy_times, svy_finished WHERE svy_finished.survey_fi = %s",
5136 array($this->
getId())
5141 if (strlen(
$row[
'left_page']) && strlen(
$row[
'entered_page']))
5142 $times[
$row[
'finished_fi']] += (
$row[
'left_page']-
$row[
'entered_page']);
5152 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_times (finished_fi, entered_page, left_page, first_question) VALUES (%s, %s, %s, %s)",
5153 array(
'integer',
'integer',
'integer',
'integer'),
5154 array($finished_id, $time, NULL, $first_question)
5162 $affectedRows = $ilDB->manipulateF(
"UPDATE svy_times SET left_page = %s WHERE finished_fi = %s AND entered_page = %s",
5163 array(
'integer',
'integer',
'integer'),
5164 array($time, $finished_id,
$_SESSION[
'svy_entered_page'])
5173 $result = $ilDB->queryF(
"SELECT * FROM svy_times WHERE finished_fi = %s",
5180 if (
$row[
'left_page'] > 0 &&
$row[
'entered_page'] > 0)