4include_once 
"./Services/Object/classes/class.ilObject.php";
 
  187                $this->survey_id = -1;
 
  188                $this->introduction = 
"";
 
  189                $this->outro = 
$lng->txt(
"survey_finished");
 
  190                $this->author = 
$ilUser->getFullname();
 
  193                $this->questions = array();
 
  198                $this->surveyCodeSecurity = TRUE;
 
  199                $this->template_id = NULL;
 
  200                $this->pool_usage = 
true;
 
  202                parent::__construct($a_id,$a_call_by_reference);
 
  224                parent::createMetaData();
 
  238                if (!parent::update())
 
  250                $result = parent::createReference();
 
  260        function read($a_force_db = 
false)
 
  262                parent::read($a_force_db);
 
  274                array_push($this->questions, $question_id);
 
  286                $remove = parent::delete();
 
  296                foreach ($this->questions as $question_id)
 
  315                $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_svy WHERE survey_id = %s",
 
  320                $result = $ilDB->queryF(
"SELECT questionblock_fi FROM svy_qblk_qst WHERE survey_fi = %s",
 
  324                $questionblocks = array();
 
  327                        array_push($questionblocks, 
$row[
"questionblock_fi"]);
 
  329                if (count($questionblocks))
 
  331                        $affectedRows = 
$ilDB->manipulate(
"DELETE FROM svy_qblk WHERE " . 
$ilDB->in(
'questionblock_id', $questionblocks, 
false, 
'integer'));
 
  333                $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE survey_fi = %s",
 
  339                $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_anonymous WHERE survey_fi = %s",
 
  345                include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  347                $directory = $svy_data_dir.
"/svy_".$this->
getId();
 
  348                if (is_dir($directory))
 
  350                        include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  354                include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
  360                foreach(
$mobs as $mob)
 
  377                $result = 
$ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
 
  381                $active_array = array();
 
  384                        array_push($active_array, 
$row[
"finished_id"]);
 
  387                $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_finished WHERE survey_fi = %s",
 
  392                foreach ($active_array as $active_fi)
 
  394                        $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_answer WHERE active_fi = %s",
 
  398                        $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_times WHERE finished_fi = %s",
 
  414                foreach ($finished_ids as $finished_id)
 
  416                        $result = 
$ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE finished_id = %s",
 
  422                        $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_answer WHERE active_fi = %s",
 
  424                                array(
$row[
"finished_id"])
 
  427                        $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_finished WHERE finished_id = %s",
 
  432                        $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_times WHERE finished_fi = %s",
 
  434                                array(
$row[
"finished_id"])
 
  443                $sql = 
"SELECT * FROM svy_finished".
 
  444                        " WHERE survey_fi = ".$ilDB->quote($this->
getSurveyId(), 
"integer");
 
  447                        $sql .= 
" AND ".$ilDB->in(
"finished_id", $finished_ids, 
"", 
"integer");
 
  451                $participants = array();
 
  457                                $userdata[
"finished"] = (bool)
$row[
"state"];
 
  458                                $userdata[
"finished_tstamp"] = 
$row[
"tstamp"];
 
  459                                $participants[$userdata[
"sortname"] . $userdata[
"active_id"]] = $userdata;
 
  462                return $participants;
 
  478        function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
 
  518                if ($a_node_id==
$_GET[
"ref_id"])
 
  520                        $parent_obj =& $this->
ilias->obj_factory->getInstanceByRefId($a_node_id);
 
  521                        $parent_type = $parent_obj->getType();
 
  522                        if($parent_type == $this->
getType())
 
  524                                $a_node_id = (int) $tree->getParentId($a_node_id);
 
  528                parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
 
  539                if (($this->
getTitle()) and (count($this->questions)))
 
  558                $survey->loadFromDb();
 
  559                if (($survey->getTitle()) and (count($survey->questions)))
 
  578                $survey->loadFromDb();
 
  580                if (($survey->getTitle()) and ($survey->author) and (count($survey->questions)))
 
  588                $result[
"evaluation_access"] = $survey->getEvaluationAccess();
 
  608                        $affectedRows = 
$ilDB->manipulateF(
"UPDATE svy_svy SET complete = %s, tstamp = %s WHERE survey_id = %s",
 
  609                                array(
'text',
'integer',
'integer'),
 
  627                $question_gui = $this->
getQuestionGUI($questiontype, $question_id);
 
  630                if($this->
getId() == $question_gui->object->getObjId() &&  !$a_force)
 
  635                $duplicate_id = $question_gui->object->duplicate(
true);
 
  636                return $duplicate_id;
 
  648                include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
  656                        $result = 
$ilDB->queryF(
"SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
 
  660                        $sequence = 
$result->numRows();
 
  662                        $next_id = 
$ilDB->nextId(
'svy_svy_qst');
 
  663                        $affectedRows = 
$ilDB->manipulateF(
"INSERT INTO svy_svy_qst (survey_question_id, survey_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
 
  664                                array(
'integer', 
'integer', 
'integer', 
'integer', 
'integer'),
 
  665                                array($next_id, $this->
getSurveyId(), $duplicate_id, $sequence, time())
 
  681                $result = 
$ilDB->queryF(
"SELECT svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.show_blocktitle,".
 
  682                        " svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst, svy_svy_qst".
 
  683                        " WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi".
 
  684                        " AND svy_svy_qst.question_fi = svy_qblk_qst.question_fi".
 
  685                        " AND svy_qblk.questionblock_id = %s".
 
  686                        " ORDER BY svy_svy_qst.sequence",
 
  688                        array($questionblock_id)
 
  691                $show_questiontext = 0;
 
  692                $show_blocktitle = 0;
 
  698                        $show_questiontext = 
$row[
"show_questiontext"];
 
  699                        $show_blocktitle = 
$row[
"show_blocktitle"];
 
  724                include_once(
"./Services/RTE/classes/class.ilRTE.php");
 
  725                $completecontent = 
"";
 
  728                        $completecontent .= $content;
 
  738                $next_id = 
$ilDB->nextId(
'svy_settings');
 
  739                $affectedRows = 
$ilDB->insert(
"svy_settings", array(
 
  740                        "settings_id" => array(
"integer", $next_id),
 
  741                        "usr_id" => array(
"integer", $usr_id),
 
  742                        "keyword" => array(
"text", $key),
 
  743                        "title" => array(
"text", 
$title),
 
  744                        "value" => array(
"clob", $value)
 
  752                $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_settings WHERE settings_id = %s",
 
  756                return $affectedRows;
 
  763                $result = 
$ilDB->queryF(
"SELECT * FROM svy_settings WHERE usr_id = %s AND keyword = %s",
 
  764                        array(
'integer', 
'text'),
 
  789                if(is_object($rmd_start))
 
  794                if(is_object($rmd_end))
 
  799                include_once(
"./Services/RTE/classes/class.ilRTE.php");
 
  802                        $next_id = 
$ilDB->nextId(
'svy_svy');
 
  803                        $affectedRows = 
$ilDB->insert(
"svy_svy", array(
 
  804                                "survey_id" => array(
"integer", $next_id),
 
  805                                "obj_fi" => array(
"integer", $this->
getId()),
 
  806                                "author" => array(
"text", $this->
getAuthor()),
 
  809                                "status" => array(
"text", $this->
getStatus()),
 
  811                                "enddate" => array(
"text", $this->
getEndDate()),
 
  815                                "complete" => array(
"text", $this->
isComplete()),
 
  816                                "created" => array(
"integer", time()),
 
  822                                "tstamp" => array(
"integer", time()),
 
  823                                "template_id" => array(
"integer", $this->
getTemplate()),
 
  824                                "pool_usage" => array(
"integer", $this->
getPoolUsage()),
 
  826                                "mode_360" => array(
"integer", $this->
get360Mode()),
 
  830                                "mode_360_results" => array(
"integer", $this->
get360Results()),
 
  834                                "reminder_start" => array(
"datetime", $rmd_start),
 
  835                                "reminder_end" => array(
"datetime", $rmd_end),
 
  849                        $affectedRows = 
$ilDB->update(
"svy_svy", array(
 
  850                                "author" => array(
"text", $this->
getAuthor()),
 
  853                                "status" => array(
"text", $this->
getStatus()),
 
  855                                "enddate" => array(
"text", $this->
getEndDate()),
 
  859                                "complete" => array(
"text", $this->
isComplete()),
 
  865                                "tstamp" => array(
"integer", time()),
 
  866                                "template_id" => array(
"integer", $this->
getTemplate()),
 
  867                                "pool_usage" => array(
"integer", $this->
getPoolUsage()),
 
  869                                "mode_360" => array(
"integer", $this->
get360Mode()),
 
  873                                "mode_360_results" => array(
"integer", $this->
get360Results()),
 
  877                                "reminder_start" => array(
"datetime", $rmd_start),
 
  878                                "reminder_end" => array(
"datetime", $rmd_end),
 
  888                        "survey_id" => array(
"integer", $this->
getSurveyId())
 
  900                        include_once 
"./Services/Object/classes/class.ilObjectActivation.php";          
 
  916                        $item->update($this->ref_id);           
 
  930                $old_questions = array();
 
  931                $result = 
$ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
 
  939                                $old_questions[
$row[
"question_fi"]] = 
$row;
 
  944                $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_svy_qst WHERE survey_fi = %s",
 
  949                foreach ($this->questions as $key => $value) 
 
  951                        $next_id = 
$ilDB->nextId(
'svy_svy_qst');
 
  952                        $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)",
 
  953                                array(
'integer',
'integer',
'integer',
'text',
'integer',
'integer'),
 
  954                                array($next_id, $this->
getSurveyId(), $value, (strlen($old_questions[$value][
"heading"])) ? $old_questions[$value][
"heading"] : NULL, $key, time())
 
  969                $result = 
$ilDB->queryF(
"SELECT anonymous_id FROM svy_finished WHERE anonymous_id = %s",
 
  976                        return $row[
"anonymous_id"];
 
  992                include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
 
 1006                if ($question_id < 1) 
return -1;
 
 1007                $result = 
$ilDB->queryF(
"SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND " .
 
 1008                        "svy_question.questiontype_fi = svy_qtype.questiontype_id",
 
 1015                        return $data[
"type_tag"];
 
 1039                switch ($a_anonymize)
 
 1045                                $this->anonymize = $a_anonymize;
 
 1060                return ($this->anonymize) ? $this->anonymize : 0;
 
 1070                return ($this->
getAnonymize() == self::ANONYMIZE_OFF || 
 
 1093                $result = 
$ilDB->queryF(
"SELECT * FROM svy_svy WHERE obj_fi = %s",
 
 1095                        array($this->
getId())
 
 1102                        include_once(
"./Services/RTE/classes/class.ilRTE.php");
 
 1104                        if (strcmp(
$data[
"outro"], 
"survey_finished") == 0)
 
 1106                                $this->
setOutro($this->lng->txt(
"survey_finished"));
 
 1151                        include_once 
"./Services/Object/classes/class.ilObjectActivation.php";
 
 1153                        switch($activation[
"timing_type"])
 
 1178                $this->questions = array();
 
 1179                $result = 
$ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
 
 1185                        $this->questions[
$data[
"sequence"]] = 
$data[
"question_fi"];
 
 1213                $md_life =& $md->getLifecycle();
 
 1216                        if (strlen($a_author) == 0)
 
 1219                                $a_author = 
$ilUser->getFullname();
 
 1222                        $md_life =& $md->addLifecycle();
 
 1224                        $con =& $md_life->addContribute();
 
 1225                        $con->setRole(
"Author");
 
 1227                        $ent =& $con->addEntity();
 
 1228                        $ent->setEntity($a_author);
 
 1243                include_once 
"./Services/MetaData/classes/class.ilMD.php";
 
 1245                $md_life =& $md->getLifecycle();
 
 1248                        $ids =& $md_life->getContributeIds();
 
 1249                        foreach ($ids as 
$id)
 
 1251                                $md_cont =& $md_life->getContribute(
$id);
 
 1252                                if (strcmp($md_cont->getRole(), 
"Author") == 0)
 
 1254                                        $entids =& $md_cont->getEntityIds();
 
 1255                                        foreach ($entids as $entid)
 
 1257                                                $md_ent =& $md_cont->getEntity($entid);
 
 1258                                                array_push(
$author, $md_ent->getEntity());
 
 1274                return ($this->display_question_titles) ? 1 : 0;
 
 1285                $this->display_question_titles = ($a_show) ? 1 : 0;
 
 1296                $this->display_question_titles = 1;
 
 1307                $this->display_question_titles = 0;
 
 1319                global 
$ilDB, $ilAccess;
 
 1333                                        if ($ilAccess->checkAccessOfUser(
$row[
"usr_id"], 
"read", 
"", $this->getRefId(), 
"svy", $this->getId()))
 
 1411                include_once 
"./Services/Administration/classes/class.ilSetting.php";
 
 1412                $surveySetting = 
new ilSetting(
"survey");
 
 1413                $unlimited_invitation = $surveySetting->get(
"unlimited_invitation");
 
 1414                if (!$unlimited_invitation && $this->invitation_mode == self::MODE_UNLIMITED)
 
 1445                return ($this->status == self::STATUS_ONLINE) ? true : 
false;
 
 1457                return ($this->status == self::STATUS_OFFLINE) ? true : 
false;
 
 1471                if ((
$status == self::STATUS_ONLINE) && (count($this->questions) == 0))
 
 1474                        $result = $this->lng->txt(
"cannot_switch_to_online_no_questions");
 
 1492                return (strlen($this->start_date)) ? $this->start_date : NULL;
 
 1507                $edit_settings = 
false;
 
 1509                if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartDate(), $matches))
 
 1511                        $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);             
 
 1513                        if ($now < $epoch_time) 
 
 1515                                array_push(
$messages,$this->lng->txt(
'start_date_not_reached').
' ('.
 
 1518                                $edit_settings = 
true;
 
 1522                if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndDate(), $matches))
 
 1524                        $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 1526                        if ($now > $epoch_time) 
 
 1528                                array_push(
$messages,$this->lng->txt(
'end_date_reached').
' ('.
 
 1531                                $edit_settings = 
true;
 
 1536                if ($this->
getStatus() == self::STATUS_OFFLINE)
 
 1538                        array_push(
$messages, $this->lng->txt(
"survey_is_offline"));
 
 1540                        $edit_settings = 
true;
 
 1543                if (!$a_no_rbac && !$ilAccess->checkAccess(
"read", 
"", $this->ref_id))
 
 1545                        array_push(
$messages, $this->lng->txt(
"cannot_participate_survey"));
 
 1564                        "edit_settings" => $edit_settings
 
 1590                $y = 
''; $m = 
''; 
$d = 
''; $h = 
''; $i = 
''; $s = 
'';
 
 1591                if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/", 
$start_date, $matches))
 
 1597                if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $start_time, $matches))
 
 1603                $this->start_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m, 
$d, $h, $i, $s);
 
 1615                return (strlen($this->end_date)) ? $this->end_date : NULL;
 
 1640                $y = 
''; $m = 
''; 
$d = 
''; $h = 
''; $i = 
''; $s = 
'';
 
 1641                if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/", 
$end_date, $matches))
 
 1647                if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $end_time, $matches))
 
 1653                $this->end_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m, 
$d, $h, $i, $s);
 
 1682                $this->activation_visibility = (bool) $a_value;
 
 1692           return (
bool)$this->activation_limited;
 
 1697           $this->activation_limited = (bool)$a_value;
 
 1709                return (strlen($this->introduction)) ? $this->introduction : NULL;
 
 1721                return (strlen($this->outro)) ? $this->outro : NULL;
 
 1733                $existing_questions = array();
 
 1734                $result = 
$ilDB->queryF(
"SELECT svy_question.original_id FROM svy_question, svy_svy_qst WHERE " .
 
 1735                        "svy_svy_qst.survey_fi = %s AND svy_svy_qst.question_fi = svy_question.question_id",
 
 1741                        if(
$data[
"original_id"])
 
 1743                                array_push($existing_questions, 
$data[
"original_id"]);
 
 1746                return $existing_questions;
 
 1757                include_once 
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
 
 1769                $move_questions = array($question_id);
 
 1772                foreach ($pages as $idx => $page)
 
 1774                        if ($page[0][
"question_id"] == $question_id)
 
 1781                        $this->
moveQuestions($move_questions, $pages[$pageindex-1][0][
"question_id"], 0);
 
 1788                        $index = array_search($question_id, 
$questions);
 
 1789                        if (($index !== FALSE) && ($index > 0))
 
 1803                $move_questions = array($question_id);
 
 1806                foreach ($pages as $idx => $page)
 
 1808                        if (($page[0][
"question_id"] == $question_id) && (strcmp($page[0][
"questionblock_id"], 
"") == 0))
 
 1813                if (($pageindex < count($pages)-1) && ($pageindex >= 0))
 
 1815                        $this->
moveQuestions($move_questions, $pages[$pageindex+1][count($pages[$pageindex+1])-1][
"question_id"], 1);
 
 1822                        $index = array_search($question_id, 
$questions);
 
 1823                        if (($index !== FALSE) && ($index < count(
$questions)-1))
 
 1839                $move_questions = array();
 
 1841                foreach ($pages as $idx => $page)
 
 1843                        if ($page[0][
"questionblock_id"] == $questionblock_id)
 
 1845                                foreach ($page as $pageidx => $question)
 
 1847                                        array_push($move_questions, $question[
"question_id"]);
 
 1854                        $this->
moveQuestions($move_questions, $pages[$pageindex-1][0][
"question_id"], 0);
 
 1867                $move_questions = array();
 
 1869                foreach ($pages as $idx => $page)
 
 1871                        if ($page[0][
"questionblock_id"] == $questionblock_id)
 
 1873                                foreach ($page as $pageidx => $question)
 
 1875                                        array_push($move_questions, $question[
"question_id"]);
 
 1880                if ($pageindex < count($pages)-1)
 
 1882                        $this->
moveQuestions($move_questions, $pages[$pageindex+1][count($pages[$pageindex+1])-1][
"question_id"], 1);
 
 1896                $array_pos = array_search($target_index, $this->questions);
 
 1897                if ($insert_mode == 0)
 
 1899                        $part1 = array_slice($this->questions, 0, $array_pos);
 
 1900                        $part2 = array_slice($this->questions, $array_pos);
 
 1902                else if ($insert_mode == 1)
 
 1904                        $part1 = array_slice($this->questions, 0, $array_pos + 1);
 
 1905                        $part2 = array_slice($this->questions, $array_pos + 1);
 
 1907                foreach ($move_questions as $question_id)
 
 1909                        if (!(array_search($question_id, $part1) === FALSE))
 
 1911                                unset($part1[array_search($question_id, $part1)]);
 
 1913                        if (!(array_search($question_id, $part2) === FALSE))
 
 1915                                unset($part2[array_search($question_id, $part2)]);
 
 1918                $part1 = array_values($part1);
 
 1919                $part2 = array_values($part2);
 
 1920                $this->questions = array_values(array_merge($part1, $move_questions, $part2));
 
 1921                foreach ($move_questions as $question_id)
 
 1924                        foreach ($constraints as $idx => $constraint)
 
 1926                                foreach ($part2 as $next_question_id)
 
 1928                                        if ($constraint[
"question"] == $next_question_id)
 
 1947                include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
 1949                $question->delete($question_id);
 
 1962                $result = 
$ilDB->queryF(
"SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
 
 1963                        array(
'integer',
'integer'),
 
 1968                        $remove_constraints = array();
 
 1971                                array_push($remove_constraints, 
$row[
"constraint_fi"]);
 
 1973                        $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
 
 1974                                array(
'integer',
'integer'),
 
 1977                        foreach ($remove_constraints as $key => $constraint_id)
 
 1979                                $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_constraint WHERE constraint_id = %s",
 
 1981                                        array($constraint_id)
 
 1998                $block_sizes = array();
 
 2001                        if (in_array($question_id, $remove_questions) or in_array(
$data[
"questionblock_id"], $remove_questionblocks))
 
 2003                                unset($this->questions[array_search($question_id, $this->questions)]);
 
 2006                        else if(
$data[
"questionblock_id"])
 
 2008                                $block_sizes[
$data[
"questionblock_id"]]++;
 
 2013                foreach($block_sizes as $block_id => 
$size)
 
 2017                                $remove_questionblocks[] = $block_id;
 
 2021                foreach (array_unique($remove_questionblocks) as $questionblock_id)
 
 2023                        $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_qblk WHERE questionblock_id = %s",
 
 2025                                array($questionblock_id)
 
 2027                        $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
 
 2028                                array(
'integer',
'integer'),
 
 2033                $this->questions = array_values($this->questions);
 
 2046                foreach ($questionblocks as $index)
 
 2048                        $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_qblk WHERE questionblock_id = %s",
 
 2052                        $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
 
 2053                                array(
'integer',
'integer'),
 
 2063                $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s AND question_fi = %s",
 
 2064                        array(
'integer',
'integer',
'integer'),
 
 2065                        array($questionblock_id, $this->
getSurveyId(), $question_id)
 
 2074                $next_id = 
$ilDB->nextId(
'svy_qblk_qst');
 
 2075                $affectedRows = 
$ilDB->manipulateF(
"INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
 
 2076                        "question_fi) VALUES (%s, %s, %s, %s)",
 
 2077                        array(
'integer',
'integer',
'integer',
'integer'),
 
 2078                        array($next_id, $this->
getSurveyId(), $questionblock_id, $question_id)
 
 2094                $result = 
$ilDB->queryF(
"SELECT svy_question.title, svy_qblk_qst.question_fi, svy_qblk_qst.survey_fi FROM ".
 
 2095                        "svy_qblk, svy_qblk_qst, svy_question WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND " .
 
 2096                        "svy_question.question_id = svy_qblk_qst.question_fi AND svy_qblk.questionblock_id = %s",
 
 2098                        array($questionblock_id)
 
 2103                        $titles[
$row[
"question_fi"]] = 
$row[
"title"];
 
 2106                $result = 
$ilDB->queryF(
"SELECT question_fi, sequence FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
 
 2110                $resultarray = array();
 
 2114                        if (array_key_exists(
$row[
"question_fi"], $titles))
 
 2116                                $resultarray[$counter++] = $titles[
$row[
"question_fi"]];
 
 2119                return $resultarray;
 
 2131                $result = 
$ilDB->queryF(
"SELECT question_fi FROM svy_qblk_qst WHERE questionblock_fi = %s",
 
 2133                        array($questionblock_id)
 
 2140                                array_push($ids, 
$data[
'question_fi']);
 
 2156                $result = 
$ilDB->queryF(
"SELECT * FROM svy_qblk WHERE questionblock_id = %s",
 
 2158                        array($questionblock_id)
 
 2173                $result = 
$ilDB->queryF(
"SELECT * FROM svy_qblk WHERE questionblock_id = %s",
 
 2175                        array($questionblock_id)
 
 2192                $next_id = 
$ilDB->nextId(
'svy_qblk');
 
 2193                $ilDB->manipulateF(
"INSERT INTO svy_qblk (questionblock_id, title, show_questiontext,".
 
 2194                        " show_blocktitle, owner_fi, tstamp) " .
 
 2195                        "VALUES (%s, %s, %s, %s, %s, %s)",
 
 2196                        array(
'integer',
'text',
'integer',
'integer',
'integer',
'integer'),
 
 2197                        array($next_id, 
$title, $show_questiontext, $show_blocktitle, 
$owner, time())
 
 2219                $next_id = 
$ilDB->nextId(
'svy_qblk');
 
 2220                $affectedRows = 
$ilDB->manipulateF(
"INSERT INTO svy_qblk (questionblock_id, title, show_questiontext,".
 
 2221                        " show_blocktitle, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
 
 2222                        array(
'integer',
'text',
'text',
'text',
'integer',
'integer'),
 
 2223                        array($next_id, 
$title, $show_questiontext, $show_blocktitle, 
$ilUser->getId(), time())
 
 2227                        $questionblock_id = $next_id;
 
 2230                                $next_id = 
$ilDB->nextId(
'svy_qblk_qst');
 
 2231                                $affectedRows = 
$ilDB->manipulateF(
"INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
 
 2232                                        "question_fi) VALUES (%s, %s, %s, %s)",
 
 2233                                        array(
'integer',
'integer',
'integer',
'integer'),
 
 2234                                        array($next_id, $this->
getSurveyId(), $questionblock_id, $index)
 
 2251                $affectedRows = 
$ilDB->manipulateF(
"UPDATE svy_qblk SET title = %s, show_questiontext = %s,".
 
 2252                        " show_blocktitle = %s WHERE questionblock_id = %s",
 
 2253                        array(
'text',
'text',
'text',
'integer'),
 
 2254                        array(
$title, $show_questiontext, $show_blocktitle, $questionblock_id)
 
 2267                $result = 
$ilDB->queryF(
"SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
 
 2268                        array(
'integer',
'integer'),
 
 2271                $constraints = array();
 
 2274                        array_push($constraints, 
$row[
"constraint_fi"]);
 
 2276                foreach ($constraints as $constraint_id)
 
 2292                $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_constraint WHERE constraint_id = %s",
 
 2294                        array($constraint_id)
 
 2296                $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_qst_constraint WHERE constraint_fi = %s",
 
 2298                        array($constraint_id)
 
 2312                $all_questions = array();
 
 2313                $result = 
$ilDB->queryF(
"SELECT svy_qtype.type_tag, svy_qtype.plugin, svy_question.question_id, ".
 
 2314                        "svy_svy_qst.heading FROM svy_qtype, svy_question, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
 
 2315                        "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
 
 2316                        "ORDER BY svy_svy_qst.sequence",
 
 2320                include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
 2334                                $questionrow = $question->_getQuestionDataArray(
$row[
"question_id"]);
 
 2335                                foreach (
$row as $key => $value)
 
 2337                                        $questionrow[$key] = $value;
 
 2339                                $all_questions[
$row[
"question_id"]] = $questionrow;
 
 2340                                $all_questions[
$row[
"question_id"]][
"usableForPrecondition"] = $question->usableForPrecondition();
 
 2341                                $all_questions[
$row[
"question_id"]][
"availableRelations"] = $question->getAvailableRelations();
 
 2342                                if (array_key_exists(
$row[
"question_id"], $obligatory_states))
 
 2344                                        $all_questions[
$row[
"question_id"]][
"obligatory"] = $obligatory_states[
$row[
"question_id"]];
 
 2349                $questionblocks = array();
 
 2350                if (count($all_questions))
 
 2352                        $result = 
$ilDB->queryF(
"SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst WHERE " .
 
 2353                                "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
 
 2354                                "AND " . 
$ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions), 
false, 
'integer'),
 
 2360                                $questionblocks[
$row[
'question_fi']] = 
$row;
 
 2364                foreach ($all_questions as $question_id => 
$row)
 
 2367                        if (isset($questionblocks[$question_id]))
 
 2369                                $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
 
 2370                                $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
 
 2371                                $all_questions[$question_id][
"constraints"] = $constraints;
 
 2375                                $all_questions[$question_id][
"questionblock_title"] = 
"";
 
 2376                                $all_questions[$question_id][
"questionblock_id"] = 
"";
 
 2377                                $all_questions[$question_id][
"constraints"] = $constraints;
 
 2382                                $result = 
$ilDB->queryF(
"SELECT svy_variable.*, svy_category.title FROM svy_variable, svy_category " .
 
 2383                                        "WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id ".
 
 2384                                        "ORDER BY sequence ASC",
 
 2392                                                array_push($answers, 
$data[
"title"]);
 
 2395                                $all_questions[$question_id][
"answers"] = $answers;
 
 2398                return $all_questions;
 
 2410                $result = 
$ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
 
 2418                                if (!array_key_exists(
$row[
"question_fi"], $obligatory_questions))
 
 2420                                        $obligatory_questions[
$row[
"question_fi"]] = 0;
 
 2426                $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_qst_oblig WHERE survey_fi = %s",
 
 2432                foreach ($obligatory_questions as $question_fi => $obligatory)
 
 2434                        $next_id = 
$ilDB->nextId(
'svy_qst_oblig');
 
 2435                        $affectedRows = 
$ilDB->manipulateF(
"INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, " .
 
 2436                                "obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)",
 
 2437                                array(
'integer',
'integer',
'integer',
'text',
'integer'),
 
 2438                                array($next_id, $this->
getSurveyId(), $question_fi, (strlen($obligatory)) ? $obligatory : 0, time())
 
 2442                        $ilDB->manipulate(
"UPDATE svy_question".
 
 2443                                " SET obligatory = ".
$ilDB->quote($obligatory, 
"integer").
 
 2444                                " WHERE question_id = ".$ilDB->quote($question_fi, 
"integer"));
 
 2457                $obligatory_states = array();
 
 2458                $result = 
$ilDB->queryF(
"SELECT * FROM svy_qst_oblig WHERE survey_fi = %s",
 
 2466                                $obligatory_states[
$row[
"question_fi"]] = 
$row[
"obligatory"];
 
 2469                return $obligatory_states;
 
 2482                $all_questions = array();
 
 2483                $result = 
$ilDB->queryF(
"SELECT svy_question.*, svy_qtype.type_tag, svy_svy_qst.heading FROM " . 
 
 2484                        "svy_question, svy_qtype, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
 
 2485                        "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id ".
 
 2486                        "ORDER BY svy_svy_qst.sequence",
 
 2492                        $all_questions[
$row[
"question_id"]] = 
$row;
 
 2495                $questionblocks = array();
 
 2496                if (count($all_questions))
 
 2498                        $result = 
$ilDB->queryF(
"SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst ".
 
 2499                                "WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s ".
 
 2500                                "AND " . 
$ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions), 
false, 
'integer'),
 
 2506                                $questionblocks[
$row[
'question_fi']] = 
$row;
 
 2510                $all_pages = array();
 
 2513                foreach ($all_questions as $question_id => 
$row)
 
 2515                        if (array_key_exists($question_id, $obligatory_states))
 
 2517                                $all_questions[$question_id][
"obligatory"] = $obligatory_states[$question_id];
 
 2519                        $constraints = array();
 
 2520                        if (isset($questionblocks[$question_id]))
 
 2522                                if (!$currentblock or ($currentblock != $questionblocks[$question_id][
'questionblock_id']))
 
 2526                                $all_questions[$question_id][
'page'] = $pageindex;
 
 2527                                $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
 
 2528                                $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
 
 2529                                $all_questions[$question_id][
"questionblock_show_questiontext"] = $questionblocks[$question_id][
'show_questiontext'];
 
 2530                                $all_questions[$question_id][
"questionblock_show_blocktitle"] = $questionblocks[$question_id][
'show_blocktitle'];
 
 2531                                $currentblock = $questionblocks[$question_id][
'questionblock_id'];
 
 2533                                $all_questions[$question_id][
"constraints"] = $constraints;
 
 2538                                $all_questions[$question_id][
'page'] = $pageindex;
 
 2539                                $all_questions[$question_id][
"questionblock_title"] = 
"";
 
 2540                                $all_questions[$question_id][
"questionblock_id"] = 
"";
 
 2541                                $all_questions[$question_id][
"questionblock_show_questiontext"] = 1;
 
 2542                                $all_questions[$question_id][
"questionblock_show_blocktitle"] = 1;
 
 2545                                $all_questions[$question_id][
"constraints"] = $constraints;
 
 2547                        if (!isset($all_pages[$pageindex]))
 
 2549                                $all_pages[$pageindex] = array();
 
 2551                        array_push($all_pages[$pageindex], $all_questions[$question_id]);
 
 2554                $max = count($all_pages);
 
 2556                foreach ($all_pages as $index => $block)
 
 2558                        foreach ($block as $blockindex => $question)
 
 2560                                $all_pages[$index][$blockindex][
"position"] = $counter / $max;
 
 2579                if (strcmp($active_page_question_id, 
"") == 0)
 
 2583                foreach ($pages as $key => $question_array)
 
 2585                        foreach ($question_array as $question)
 
 2587                                if ($active_page_question_id == $question[
"question_id"])
 
 2593                if ($foundpage == -1)
 
 2599                        $foundpage += $direction;
 
 2604                        if ($foundpage >= count($pages))
 
 2608                        return $pages[$foundpage];
 
 2620                include_once 
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
 
 2633                $result_array = array();
 
 2634                $result = 
$ilDB->queryF(
"SELECT svy_constraint.*, svy_relation.*, svy_qst_constraint.question_fi ref_question_fi FROM svy_qst_constraint, svy_constraint, ".
 
 2635                        "svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id AND ".
 
 2636                        "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_constraint.constraint_id = %s",
 
 2657                $result_array = array();
 
 2658                $result = 
$ilDB->queryF(
"SELECT svy_constraint.*, svy_relation.* FROM svy_qst_constraint, svy_constraint, svy_relation ".
 
 2659                        "WHERE svy_constraint.relation_fi = svy_relation.relation_id AND ".
 
 2660                        "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.question_fi = %s ".
 
 2661                        "AND svy_qst_constraint.survey_fi = %s",
 
 2662                        array(
'integer',
'integer'),
 
 2667                        include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
 2670                        $question = 
new $question_type();
 
 2671                        $question->loadFromDb(
$row[
"question_fi"]);
 
 2672                        $valueoutput = $question->getPreconditionValueOutput(
$row[
"value"]);
 
 2673                        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));
 
 2675                return $result_array;
 
 2686                $result_array = array();
 
 2687                $result = 
$ilDB->queryF(
"SELECT svy_qst_constraint.question_fi as for_question, svy_constraint.*, svy_relation.* ".
 
 2688                        "FROM svy_qst_constraint, svy_constraint, svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id ".
 
 2689                        "AND svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.survey_fi = %s",
 
 2695                        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']));
 
 2697                return $result_array;
 
 2710                $result_array = array();
 
 2711                $result = 
$ilDB->queryF(
"SELECT svy_variable.*, svy_category.title FROM svy_variable LEFT JOIN ".
 
 2712                        "svy_category ON svy_variable.category_fi = svy_category.category_id WHERE svy_variable.question_fi = %s ".
 
 2713                        "ORDER BY svy_variable.sequence",
 
 2719                        $result_array[
$row->sequence] = 
$row;
 
 2721                return $result_array;
 
 2736                $next_id = 
$ilDB->nextId(
'svy_constraint');
 
 2737                $affectedRows = 
$ilDB->manipulateF(
"INSERT INTO svy_constraint (constraint_id, question_fi, relation_fi, value, conjunction) VALUES ".
 
 2738                        "(%s, %s, %s, %s, %s)",
 
 2739                        array(
'integer',
'integer',
'integer',
'float', 
'integer'),
 
 2740                        array($next_id, $if_question_id, $relation, $value, $conjunction)
 
 2763                $next_id = 
$ilDB->nextId(
'svy_qst_constraint');
 
 2764                $affectedRows = 
$ilDB->manipulateF(
"INSERT INTO svy_qst_constraint (question_constraint_id, survey_fi, question_fi, ".
 
 2765                        "constraint_fi) VALUES (%s, %s, %s, %s)",
 
 2766                        array(
'integer',
'integer',
'integer',
'integer'),
 
 2767                        array($next_id, $this->
getSurveyId(), $to_question_id, $constraint_id)
 
 2784                $affectedRows = 
$ilDB->manipulateF(
"UPDATE svy_constraint SET question_fi = %s, relation_fi = %s, value = %s, conjunction = %s ".
 
 2785                        "WHERE constraint_id = %s",
 
 2786                        array(
'integer',
'integer',
'float',
'integer',
'integer'),
 
 2787                        array($if_question_id, $relation, $value, $conjunction, $precondition_id)
 
 2796                        $affectedRows = 
$ilDB->manipulateF(
"UPDATE svy_constraint SET conjunction = %s ".
 
 2797                                "WHERE constraint_id IN (SELECT constraint_fi FROM svy_qst_constraint WHERE svy_qst_constraint.question_fi = %s)",
 
 2798                                array(
'integer',
'integer'),
 
 2799                                array($conjunction, $question_id)
 
 2814                $custom_order = array(
"equal", 
"not_equal", 
"less", 
"less_or_equal", 
"more", 
"more_or_equal");
 
 2815                $custom_order = array_flip($custom_order);
 
 2817                $result_array = array();
 
 2823                                $result_array[
$row[
"shortname"]] = array(
"short" => 
$row[
"shortname"], 
"long" => 
$row[
"longname"], 
"id" => 
$row[
"relation_id"], 
"order" => $custom_order[
$row[
"longname"]]);
 
 2827                                $result_array[
$row[
"relation_id"]] = array(
"short" => 
$row[
"shortname"], 
"long" => 
$row[
"longname"], 
"order" => $custom_order[
$row[
"longname"]]);
 
 2832                foreach($result_array as $idx => $item)
 
 2834                        unset($result_array[$idx][
"order"]);
 
 2837                return $result_array;
 
 2846                $result = 
$ilDB->queryF(
"SELECT user_fi FROM svy_inv_usr WHERE survey_fi = %s",
 
 2865                $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_inv_usr WHERE survey_fi = %s AND user_fi = %s",
 
 2866                        array(
'integer',
'integer'),
 
 2869                include_once 
'./Services/User/classes/class.ilObjUser.php';
 
 2883                $result = 
$ilDB->queryF(
"SELECT user_fi FROM svy_inv_usr WHERE user_fi = %s AND survey_fi = %s",
 
 2884                        array(
'integer',
'integer'),
 
 2889                        $next_id = 
$ilDB->nextId(
'svy_inv_usr');
 
 2890                        $affectedRows = 
$ilDB->manipulateF(
"INSERT INTO svy_inv_usr (invited_user_id, survey_fi, user_fi, tstamp) " .
 
 2891                                "VALUES (%s, %s, %s, %s)",
 
 2892                                array(
'integer',
'integer',
'integer',
'integer'),
 
 2893                                array($next_id, $this->
getSurveyId(), $user_id, time())
 
 2898                        include_once 
'./Services/User/classes/class.ilObjUser.php';
 
 2913                        include_once 
"./Modules/Group/classes/class.ilObjGroup.php";
 
 2915                        $members = $group->getGroupMemberIds();
 
 2916                        foreach ($members as $user_id)
 
 2918                                if ($ilAccess->checkAccessOfUser($user_id, 
"read", 
"", $this->getRefId(), 
"svy", $this->getId()))
 
 2923                                                include_once 
'./Services/User/classes/class.ilObjUser.php';
 
 2942                        $members = $rbacreview->assignedUsers($role_id);
 
 2943                        foreach ($members as $user_id)
 
 2945                                if ($ilAccess->checkAccessOfUser($user_id, 
"read", 
"", $this->getRefId(), 
"svy", $this->getId()))
 
 2950                                                include_once 
'./Services/User/classes/class.ilObjUser.php';
 
 2968                $result_array = array();
 
 2969                $result = 
$ilDB->queryF(
"SELECT user_fi FROM svy_inv_usr WHERE survey_fi = %s",
 
 2975                        array_push($result_array, 
$row[
"user_fi"]);
 
 2977                return $result_array;
 
 2991                $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
 
 2992                        array(
'integer',
'integer'),
 
 2993                        array($question_id, $active_id)
 
 3008                $result_array = array();
 
 3009                $result = 
$ilDB->queryF(
"SELECT * FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
 
 3010                        array(
'integer',
'integer'),
 
 3011                        array($question_id, $active_id)
 
 3017                                array_push($result_array, 
$row);
 
 3019                        return $result_array;
 
 3023                        return $result_array;
 
 3040                $active_id = 
$ilDB->nextId(
'svy_finished');
 
 3041                $affectedRows = 
$ilDB->manipulateF(
"INSERT INTO svy_finished (finished_id, survey_fi, user_fi, anonymous_id, state, tstamp) ".
 
 3042                        "VALUES (%s, %s, %s, %s, %s, %s)",
 
 3043                        array(
'integer',
'integer',
'integer',
'text',
'text',
'integer'),
 
 3044                        array($active_id, $this->
getSurveyId(), $user_id, $anonymous_id, 1, time())
 
 3048                foreach ($pages as $key => $question_array)
 
 3050                        foreach ($question_array as $question)
 
 3053                                require_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
 3055                                $question->saveRandomData($active_id);
 
 3070                if ($this->
getAnonymize() && (strlen($anonymous_id) == 0)) 
return;
 
 3072                if (strcmp($user_id, 
"") == 0)
 
 3074                        if ($user_id == ANONYMOUS_USER_ID)
 
 3079                $next_id = 
$ilDB->nextId(
'svy_finished');
 
 3080                $affectedRows = 
$ilDB->manipulateF(
"INSERT INTO svy_finished (finished_id, survey_fi, user_fi, anonymous_id, state, tstamp, appr_id) ".
 
 3081                        "VALUES (%s, %s, %s, %s, %s, %s, %s)",
 
 3082                        array(
'integer',
'integer',
'integer',
'text',
'text',
'integer',
'integer'),
 
 3083                        array($next_id, $this->
getSurveyId(), $user_id, $anonymous_id, 0, time(), $appraisee_id)
 
 3098                $ilDB->manipulateF(
"UPDATE svy_finished SET state = %s, tstamp = %s".
 
 3099                        " WHERE survey_fi = %s AND finished_id = %s",
 
 3100                        array(
'text',
'integer',
'integer',
'integer'),
 
 3101                        array(1, time(), $this->
getSurveyId(), $finished_id)
 
 3118                $affectedRows = 
$ilDB->manipulateF(
"UPDATE svy_finished SET lastpage = %s WHERE finished_id = %s",
 
 3119                        array(
'integer',
'integer'),
 
 3120                        array(($page_id) ? $page_id : 0, $finished_id)
 
 3126                include_once 
"./Services/User/classes/class.ilObjUser.php";
 
 3127                include_once 
"./Services/User/classes/class.ilUserUtil.php";    
 
 3130                $placeholders = array(
 
 3131                        "FIRST_NAME" => 
"firstname",
 
 3132                        "LAST_NAME" => 
"lastname",              
 
 3135                        "firstname" => 
"firstname" 
 3138                $recipients = preg_split(
'/,/', $this->mailaddresses);
 
 3139                foreach ($recipients as $recipient)
 
 3142                        include_once 
"./Services/Notification/classes/class.ilSystemNotification.php";
 
 3144                        $ntf->setLangModules(array(
"survey"));
 
 3146                        $ntf->setSubjectLangId(
'finished_mail_subject');
 
 3149                        if(trim($messagetext))
 
 3156                                foreach ($placeholders as $key => $mapping)
 
 3160                                                $messagetext = str_replace(
'[' . $key . 
']', 
'', $messagetext);
 
 3164                                                $messagetext = str_replace(
'[' . $key . 
']', trim(
$data[$mapping]), $messagetext);
 
 3167                                $ntf->setIntroductionDirect($messagetext);
 
 3171                                $ntf->setIntroductionLangId(
'survey_notification_finished_introduction');
 
 3177                                $ntf->addAdditionalInfo(
'survey_360_appraisee', 
 
 3181                        $active_id = $this->
getActiveID($user_id, $anonymize_id, $appr_id);
 
 3182                        $ntf->addAdditionalInfo(
'results', 
 
 3185                        $ntf->setGotoLangId(
'survey_notification_tutor_link');                          
 
 3186                        $ntf->setReasonLangId(
'survey_notification_finished_reason');   
 
 3188                        $ntf->sendMail(array($recipient), 
null, 
null);          
 
 3197                $questioncounter = 1;
 
 3198                foreach (
$questions as $question_id => $question_data)
 
 3200                        $textresult .= $questioncounter++ . 
". " . $question_data[
"title"] . 
"\n";
 
 3201                        $found = $userResults[$question_id][$active_id];
 
 3203                        if (is_array($found))
 
 3205                                $text = implode(
"\n", $found);
 
 3212                        $text = str_replace(
"<br />", 
"\n", $text);
 
 3213                        $textresult .= $text . 
"\n\n";
 
 3225                        include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
 3283                                " WHERE survey_fi = %s AND anonymous_id = %s AND appr_id = %s",
 
 3284                                array(
'integer',
'text',
'integer'),
 
 3285                                array($this->
getSurveyId(), $anonymize_id, $appr_id)
 
 3291                                " WHERE survey_fi = %s AND user_fi = %s AND appr_id = %s",
 
 3292                                array(
'integer',
'integer',
'integer'),
 
 3307                        return (
int)
$row[
"state"];
 
 3367                        $result = 
$ilDB->queryF(
"SELECT finished_id FROM svy_finished".
 
 3368                                " WHERE survey_fi = %s AND anonymous_id = %s AND appr_id = %s",
 
 3369                                array(
'integer',
'text',
'integer'),
 
 3370                                array($this->
getSurveyId(), $anonymize_id, $appr_id)
 
 3375                        $result = 
$ilDB->queryF(
"SELECT finished_id FROM svy_finished".
 
 3376                                " WHERE survey_fi = %s AND user_fi = %s AND appr_id = %s",
 
 3377                                array(
'integer',
'integer',
'integer'),
 
 3388                        return $row[
"finished_id"];
 
 3441                $result = 
$ilDB->queryF(
"SELECT lastpage FROM svy_finished WHERE finished_id = %s",
 
 3452                        return (
$row[
"lastpage"]) ? 
$row[
"lastpage"] : 
'';
 
 3466                if (count($working_data) == 0)
 
 3471                if ((count($working_data) == 1) and (strcmp($working_data[0][
"value"], 
"") == 0))
 
 3477                foreach ($working_data as 
$data)
 
 3479                        switch ($constraint_data[
"short"])
 
 3482                                        if (
$data[
"value"] < $constraint_data[
"value"])
 
 3489                                        if (
$data[
"value"] <= $constraint_data[
"value"])
 
 3496                                        if (
$data[
"value"] == $constraint_data[
"value"])
 
 3503                                        if (
$data[
"value"] <> $constraint_data[
"value"])
 
 3510                                        if (
$data[
"value"] >= $constraint_data[
"value"])
 
 3517                                        if (
$data[
"value"] > $constraint_data[
"value"])
 
 3536                $result = 
$ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
 
 3540                return (
$result->numRows()) ? true : 
false;
 
 3554                $result = 
$ilDB->queryF(
"SELECT * FROM svy_finished WHERE survey_fi = %s",
 
 3562                                array_push($users, 
$row[
"finished_id"]);
 
 3578                $evaluation = array();
 
 3580                foreach ($questions as $question_id => $question_data)
 
 3582                        include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
 3585                        $question = 
new $question_type();
 
 3586                        $question->loadFromDb($question_id);
 
 3588                        $evaluation[$question_id] = 
$data;
 
 3604                $surveySetting = 
new ilSetting(
"survey");
 
 3605                $use_anonymous_id = array_key_exists(
"use_anonymous_id", 
$_GET) ? 
$_GET[
"use_anonymous_id"] : $surveySetting->get(
"use_anonymous_id");
 
 3606                $result = 
$ilDB->queryF(
"SELECT * FROM svy_finished WHERE finished_id = %s",
 
 3611                $foundrows = 
$result->numRows();
 
 3616                $name = ($use_anonymous_id) ? 
$row[
"anonymous_id"] : $this->lng->txt(
"anonymous");
 
 3618                        "fullname" => $name,
 
 3619                        "sortname" => $name,
 
 3624                        "active_id" => 
"$active_id" 
 3628                        if ((
$row[
"user_fi"] > 0) && (
$row[
"user_fi"] != ANONYMOUS_USER_ID) &&                          
 
 3632                                include_once 
'./Services/User/classes/class.ilObjUser.php';
 
 3635                                        $userdata[
"fullname"] = $userdata[
"sortname"] = $this->lng->txt(
"deleted_user");
 
 3640                                        $userdata[
"fullname"] = $user->getFullname();
 
 3641                                        $gender = $user->getGender();
 
 3642                                        if (strlen($gender) == 1) $gender = $this->lng->txt(
"gender_$gender");
 
 3643                                        $userdata[
"gender"] = $gender;
 
 3644                                        $userdata[
"firstname"] = $user->getFirstname();
 
 3645                                        $userdata[
"lastname"] = $user->getLastname();
 
 3646                                        $userdata[
"sortname"] = $user->getLastname() . 
", " . $user->getFirstname();
 
 3647                                        $userdata[
"login"] = $user->getLogin();
 
 3669                $result = 
$ilDB->queryF(
"SELECT * FROM svy_answer WHERE active_fi = %s",
 
 3675                        if (!is_array($answers[
$row[
"question_fi"]]))
 
 3677                                $answers[
$row[
"question_fi"]] = array();
 
 3679                        array_push($answers[
$row[
"question_fi"]], 
$row);
 
 3683                        "name" => $userdata[
"fullname"],
 
 3684                        "firstname" => $userdata[
"firstname"],
 
 3685                        "lastname" => $userdata[
"lastname"],
 
 3686                        "login" => $userdata[
"login"],
 
 3687                        "gender" => $userdata[
"gender"],
 
 3688                        "answers" => array()
 
 3692                        if (array_key_exists($key, $answers))
 
 3694                                $resultset[
"answers"][$key] = $answers[$key];
 
 3698                                $resultset[
"answers"][$key] = array();
 
 3700                        sort($resultset[
"answers"][$key]);
 
 3719                        $result = 
$ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
 
 3723                        $nr_of_users = 
$result->numRows();
 
 3727                        $nr_of_users = 
sizeof($finished_ids);
 
 3730                $result_array =& $question->getCumulatedResults($this->
getSurveyId(), $nr_of_users, $finished_ids);
 
 3731                return $result_array;
 
 3745                $result = 
$ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
 
 3756                $result_array = array();
 
 3757                $result = 
$ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag FROM svy_question, svy_qtype WHERE ".
 
 3758                        "svy_question.questiontype_fi = svy_qtype.questiontype_id AND svy_question.tstamp > 0 AND ".
 
 3759                        $ilDB->in(
'svy_question.question_id', $question_ids, 
false, 
'integer'));
 
 3762                        array_push($result_array, 
$row);
 
 3764                return $result_array;
 
 3777                if (is_array($arrFilter))
 
 3779                        if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
 
 3781                                $where .= 
" AND " . 
$ilDB->like(
'svy_question.title', 
'text', 
"%%" . $arrFilter[
'title'] . 
"%%");
 
 3783                        if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description']))
 
 3785                                $where .= 
" AND " . 
$ilDB->like(
'svy_question.description', 
'text', 
"%%" . $arrFilter[
'description'] . 
"%%");
 
 3787                        if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author']))
 
 3789                                $where .= 
" AND " . 
$ilDB->like(
'svy_question.author', 
'text', 
"%%" . $arrFilter[
'author'] . 
"%%");
 
 3791                        if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type']))
 
 3793                                $where .= 
" AND svy_qtype.type_tag = " . 
$ilDB->quote($arrFilter[
'type'], 
'text');
 
 3795                        if (array_key_exists(
'spl', $arrFilter) && strlen($arrFilter[
'spl']))
 
 3797                                $where .= 
" AND svy_question.obj_fi = " . 
$ilDB->quote($arrFilter[
'spl'], 
'integer');
 
 3803                $forbidden = 
" AND " . 
$ilDB->in(
'svy_question.obj_fi', array_keys($spls), 
false, 
'integer');
 
 3804                $forbidden .= 
" AND svy_question.complete = " . 
$ilDB->quote(
"1", 
'text');
 
 3807                if (count($existing_questions))
 
 3809                        $existing = 
" AND " . 
$ilDB->in(
'svy_question.question_id', $existing_questions, 
true, 
'integer');
 
 3812                include_once 
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
 
 3815                $query_result = 
$ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin, object_reference.ref_id".
 
 3816                        " FROM svy_question, svy_qtype, object_reference".
 
 3817                        " WHERE svy_question.original_id IS NULL".$forbidden.$existing.
 
 3818                        " AND svy_question.obj_fi = object_reference.obj_id AND svy_question.tstamp > 0".
 
 3819                        " AND svy_question.questiontype_fi = svy_qtype.questiontype_id " . $where);
 
 3822                if ($query_result->numRows())
 
 3824                        while (
$row = 
$ilDB->fetchAssoc($query_result))
 
 3826                                if (array_key_exists(
'spl_txt', $arrFilter) && strlen($arrFilter[
'spl_txt']))
 
 3828                                        if(!stristr($spls[
$row[
"obj_fi"]], $arrFilter[
'spl_txt']))
 
 3834                                $row[
'ttype'] = $trans[
$row[
'type_tag']];
 
 3839                                                array_push($rows, 
$row);
 
 3844                                        array_push($rows, 
$row);
 
 3861                if (is_array($arrFilter))
 
 3863                        if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title']))
 
 3865                                $where .= 
" AND " . 
$ilDB->like(
'svy_qblk.title', 
'text', 
"%%" . $arrFilter[
'title'] . 
"%%");
 
 3869                $query_result = 
$ilDB->query(
"SELECT svy_qblk.*, svy_svy.obj_fi FROM svy_qblk , svy_qblk_qst, svy_svy WHERE ".
 
 3870                        "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_svy.survey_id = svy_qblk_qst.survey_fi ".
 
 3871                        "$where GROUP BY svy_qblk.questionblock_id, svy_qblk.title, svy_qblk.show_questiontext,  svy_qblk.show_blocktitle, ".
 
 3872                        "svy_qblk.owner_fi, svy_qblk.tstamp, svy_svy.obj_fi");
 
 3874                if ($query_result->numRows())
 
 3877                        $surveytitles = array();
 
 3878                        foreach ($survey_ref_ids as $survey_ref_id)
 
 3883                        while (
$row = 
$ilDB->fetchAssoc($query_result))
 
 3887                                foreach ($questions_array as $key => $value)
 
 3889                                        $questions_array[$key] = 
"$counter. $value";
 
 3892                                if (strlen($surveytitles[
$row[
"obj_fi"]])) 
 
 3894                                        $rows[
$row[
"questionblock_id"]] = array(
 
 3895                                                "questionblock_id" => 
$row[
"questionblock_id"],
 
 3896                                                "title" => 
$row[
"title"], 
 
 3897                                                "svy" => $surveytitles[
$row[
"obj_fi"]], 
 
 3898                                                "contains" => join($questions_array, 
", "),
 
 3899                                                "owner" => 
$row[
"owner_fi"]
 
 3915                include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
 
 3920                        "xmlns:xsi" => 
"http://www.w3.org/2001/XMLSchema-instance",
 
 3921                        "xsi:noNamespaceSchemaLocation" => 
"http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd" 
 3923                $a_xml_writer->xmlStartTag(
"surveyobject", $attrs);
 
 3928                $a_xml_writer->xmlStartTag(
"survey", $attrs);
 
 3930                $a_xml_writer->xmlElement(
"description", NULL, $this->
getDescription());
 
 3931                $a_xml_writer->xmlElement(
"author", NULL, $this->
getAuthor());
 
 3932                $a_xml_writer->xmlStartTag(
"objectives");
 
 3934                        "label" => 
"introduction" 
 3941                $a_xml_writer->xmlEndTag(
"objectives");
 
 3945                        $attribs = array(
"enabled" => 
"1");
 
 3949                        $attribs = array(
"enabled" => 
"0");
 
 3951                $a_xml_writer->xmlElement(
"anonymisation", $attribs);
 
 3952                $a_xml_writer->xmlStartTag(
"restrictions");
 
 3955                        $attribs = array(
"type" => 
"free");
 
 3959                        $attribs = array(
"type" => 
"restricted");
 
 3961                $a_xml_writer->xmlElement(
"access", $attribs);
 
 3964                        $attrs = array(
"type" => 
"date");                       
 
 3965                        preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartDate(), $matches);
 
 3966                        $a_xml_writer->xmlElement(
"startingtime", $attrs, sprintf(
"%04d-%02d-%02dT%02d:%02d:00", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
 
 3970                        $attrs = array(
"type" => 
"date");
 
 3971                        preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndDate(), $matches);
 
 3972                        $a_xml_writer->xmlElement(
"endingtime", $attrs, sprintf(
"%04d-%02d-%02dT%02d:%02d:00", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]));
 
 3975                $a_xml_writer->xmlEndTag(
"restrictions");
 
 3979                $hasconstraints = FALSE;
 
 3980                foreach ($pages as $question_array)
 
 3982                        foreach ($question_array as $question)
 
 3984                                if (count($question[
"constraints"]))
 
 3986                                        $hasconstraints = TRUE;
 
 3991                if ($hasconstraints)
 
 3993                        $a_xml_writer->xmlStartTag(
"constraints");
 
 3994                        foreach ($pages as $question_array)
 
 3996                                foreach ($question_array as $question)
 
 3998                                        if (count($question[
"constraints"]))
 
 4001                                                foreach ($question[
"constraints"] as $constraint)
 
 4004                                                                "sourceref" => $question[
"question_id"],
 
 4005                                                                "destref" => $constraint[
"question"],
 
 4006                                                                "relation" => $constraint[
"short"],
 
 4007                                                                "value" => $constraint[
"value"],
 
 4008                                                                "conjunction" => $constraint[
"conjunction"]
 
 4010                                                        $a_xml_writer->xmlElement(
"constraint", $attribs);
 
 4015                        $a_xml_writer->xmlEndTag(
"constraints");
 
 4019                $a_xml_writer->xmlStartTag(
"metadata");
 
 4021                $custom_properties = array();
 
 4023                $custom_properties[
"status"] = $this->
getStatus();
 
 4025                $custom_properties[
"pool_usage"] = (int)$this->
getPoolUsage();
 
 4030                $custom_properties[
"mode_360"] = (int)$this->
get360Mode();
 
 4034                $custom_properties[
"mode_360_results"] = $this->
get360Results();
 
 4042                foreach($custom_properties as $label => $value)
 
 4044                        $a_xml_writer->xmlStartTag(
"metadatafield");
 
 4045                        $a_xml_writer->xmlElement(
"fieldlabel", NULL, $label);
 
 4046                        $a_xml_writer->xmlElement(
"fieldentry", NULL, $value);
 
 4047                        $a_xml_writer->xmlEndTag(
"metadatafield");
 
 4050                $a_xml_writer->xmlStartTag(
"metadatafield");
 
 4051                $a_xml_writer->xmlElement(
"fieldlabel", NULL, 
"SCORM");
 
 4052                include_once 
"./Services/MetaData/classes/class.ilMD.php";
 
 4055                $md->toXml($writer);
 
 4056                $metadata = $writer->xmlDumpMem();
 
 4057                $a_xml_writer->xmlElement(
"fieldentry", NULL, $metadata);
 
 4058                $a_xml_writer->xmlEndTag(
"metadatafield");
 
 4060                $a_xml_writer->xmlEndTag(
"metadata");
 
 4061                $a_xml_writer->xmlEndTag(
"survey");
 
 4063                $attribs = array(
"id" => $this->
getId());
 
 4064                $a_xml_writer->xmlStartTag(
"surveyquestions", $attribs);
 
 4067                foreach ($pages as $question_array)
 
 4069                        if (count($question_array) > 1)
 
 4071                                $attribs = array(
"id" => $question_array[0][
"question_id"]);
 
 4072                                $attribs = array(
"showQuestiontext" => $question_array[0][
"questionblock_show_questiontext"],
 
 4073                                        "showBlocktitle" => $question_array[0][
"questionblock_show_blocktitle"]);
 
 4074                                $a_xml_writer->xmlStartTag(
"questionblock", $attribs);
 
 4075                                if (strlen($question_array[0][
"questionblock_title"]))
 
 4077                                        $a_xml_writer->xmlElement(
"questionblocktitle", NULL, $question_array[0][
"questionblock_title"]);
 
 4080                        foreach ($question_array as $question)
 
 4082                                if (strlen($question[
"heading"]))
 
 4084                                        $a_xml_writer->xmlElement(
"textblock", NULL, $question[
"heading"]);
 
 4087                                if ($questionObject !== FALSE) $questionObject->insertXML($a_xml_writer, FALSE, $obligatory_states[$question[
"question_id"]]);
 
 4089                        if (count($question_array) > 1)
 
 4091                                $a_xml_writer->xmlEndTag(
"questionblock");
 
 4095                $a_xml_writer->xmlEndTag(
"surveyquestions");
 
 4096                $a_xml_writer->xmlEndTag(
"surveyobject");
 
 4097                $xml = $a_xml_writer->xmlDumpMem(FALSE);
 
 4110                if ($question_id < 1) 
return FALSE;
 
 4111                include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
 4113                if (strlen($question_type) == 0) 
return FALSE;
 
 4115                $question = 
new $question_type();
 
 4116                $question->loadFromDb($question_id);
 
 4128                if (!is_dir($a_dir) || is_int(strpos($a_dir, 
"..")))
 
 4132                $importDirectory = 
"";
 
 4135                $current_dir = opendir($a_dir);
 
 4137                while($entryname = readdir($current_dir))
 
 4139                        $files[] = $entryname;
 
 4142                foreach($files as 
$file)
 
 4147                                $importDirectory = $a_dir.
"/".
$file;
 
 4150                closedir($current_dir);
 
 4151                if (strlen($importDirectory))
 
 4154                        $current_dir = opendir($importDirectory);
 
 4156                        while($entryname = readdir($current_dir))
 
 4158                                $files[] = $entryname;
 
 4160                        foreach($files as 
$file)
 
 4162                                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)))
 
 4165                                        $xmlFile = $importDirectory.
"/".
$file;
 
 4169                return array(
"dir" => $importDirectory, 
"xml" => $xmlFile);
 
 4180                if ($svy_qpl_id < 1) $svy_qpl_id = -1;
 
 4182                $source = $file_info[
"tmp_name"];
 
 4184                if (($source == 
'none') || (!$source) || $file_info[
"error"] > UPLOAD_ERR_OK)
 
 4186                        $error = $this->lng->txt(
"import_no_file_selected");
 
 4191                if ((strcmp($file_info[
"type"], 
"text/xml") == 0) || (strcmp($file_info[
"type"], 
"application/xml") == 0))
 
 4196                $suffix = pathinfo($file_info[
"name"]);
 
 4197                if (strcmp(strtolower($suffix[
"extension"]), 
"zip") == 0)
 
 4201                if (!$isXml && !$isZip)
 
 4203                        $error = $this->lng->txt(
"import_wrong_file_type");
 
 4205                        $ilLog->write(
"Survey: Import error. Filetype was \"" . $file_info[
"type"] .
"\"");
 
 4207                if (strlen($error) == 0)
 
 4211                        $import_subdir = 
"";
 
 4213                        include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
 4216                                $importfile = $import_dir.
"/".$file_info[
"name"];
 
 4220                                if (!((strlen($found[
"dir"]) > 0) && (strlen($found[
"xml"]) > 0)))
 
 4222                                        $error = $this->lng->txt(
"wrong_import_file_structure");
 
 4225                                $importfile = $found[
"xml"];
 
 4226                                $import_subdir = $found[
"dir"];
 
 4230                                $importfile = tempnam($import_dir, 
"survey_import");
 
 4233                        $fh = fopen($importfile, 
"r");
 
 4236                                $error = $this->lng->txt(
"import_error_opening_file");
 
 4239                        $xml = fread($fh, filesize($importfile));
 
 4243                                $error = $this->lng->txt(
"import_error_closing_file");
 
 4248                        if (strpos($xml, 
"questestinterop"))
 
 4250                                include_once 
"./Services/Survey/classes/class.SurveyImportParserPre38.php";
 
 4252                                $import->setSurveyObject($this);
 
 4253                                $import->setXMLContent($xml);
 
 4254                                $import->startParsing();
 
 4258                                include_once 
"./Services/Survey/classes/class.SurveyImportParser.php";
 
 4260                                $import->setSurveyObject($this);
 
 4261                                $import->setXMLContent($xml);
 
 4262                                $import->startParsing();
 
 4265                        if (is_array(
$_SESSION[
"import_mob_xhtml"]))
 
 4267                                include_once 
"./Services/MediaObjects/classes/class.ilObjMediaObject.php";
 
 4268                                include_once 
"./Services/RTE/classes/class.ilRTE.php";
 
 4269                                include_once 
"./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
 
 4270                                foreach (
$_SESSION[
"import_mob_xhtml"] as $mob)
 
 4272                                        $importfile = $import_subdir . 
"/" . $mob[
"uri"];
 
 4273                                        if (file_exists($importfile))
 
 4277                                                        $mob[
"type"] = 
"svy:html";
 
 4283                                                if ($mob[
"type"] == 
"svy:html")
 
 4286                                                        $this->
setIntroduction(str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $this->getIntroduction()));
 
 4287                                                        $this->
setOutro(str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $this->getOutro()));
 
 4290                                                else if($import->questions[$mob[
"id"]])
 
 4292                                                        $new_qid = $import->questions[$mob[
"id"]];                                                      
 
 4295                                                        $qtext = $new_question->getQuestiontext();
 
 4297                                                        $qtext = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $qtext);                                                   
 
 4299                                                        $new_question->setQuestiontext($qtext);
 
 4300                                                        $new_question->saveToDb();              
 
 4303                                                        if($new_question->getOriginalId())
 
 4306                                                                $pool_question->setQuestiontext($qtext);
 
 4307                                                                $pool_question->saveToDb();             
 
 4314                                                $ilLog->write(
"Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
 
 4343                $newObj = parent::cloneObject($a_target_id,$a_copy_id);
 
 4345                $newObj->updateMetaData();
 
 4349                $newObj->setOutro($this->
getOutro());
 
 4365                        $newObj->set360Mode(
true);
 
 4384                $question_pointer = array();
 
 4387                include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
 4389                foreach ($this->questions as $key => $question_id)
 
 4396                                $question->saveToDb($original_id);
 
 4397                                $newObj->questions[$key] = $question->getId();
 
 4398                                $question_pointer[$question_id] = $question->getId();
 
 4399                                $mapping[$question_id] = $question->getId();                            
 
 4406                if(!$cp_options->isRootNode($this->getRefId()))
 
 4408                        $newObj->setStatus($this->
isOnline()?self::STATUS_ONLINE: self::STATUS_OFFLINE);
 
 4411                $newObj->saveToDb();            
 
 4412                $newObj->cloneTextblocks($mapping);
 
 4418                        include_once 
"./Modules/Survey/classes/class.ilSurveySkill.php";
 
 4422                        foreach($mapping as $src_qst_id => $tgt_qst_id)
 
 4424                                $qst_skill = $src_skills->getSkillForQuestion($src_qst_id);
 
 4427                                        $tgt_skills->addQuestionSkillAssignment($tgt_qst_id, $qst_skill[
"base_skill_id"], $qst_skill[
"tref_id"]);
 
 4433                $questionblocks = array();
 
 4434                $questionblock_questions = array();
 
 4435                $result = 
$ilDB->queryF(
"SELECT * FROM svy_qblk_qst WHERE survey_fi = %s",
 
 4443                                array_push($questionblock_questions, 
$row);
 
 4444                                $questionblocks[
$row[
"questionblock_fi"]] = 
$row[
"questionblock_fi"];
 
 4448                foreach ($questionblocks as $key => $value)
 
 4451                        $questionblock_id = 
ilObjSurvey::_addQuestionblock($questionblock[
"title"], $questionblock[
"owner_fi"], $questionblock[
"show_questiontext"], $questionblock[
"show_blocktitle"]);
 
 4452                        $questionblocks[$key] = $questionblock_id;
 
 4455                foreach ($questionblock_questions as $key => $value)
 
 4457                        if($questionblocks[$value[
"questionblock_fi"]] &&
 
 4458                                $question_pointer[$value[
"question_fi"]])
 
 4460                                $next_id = 
$ilDB->nextId(
'svy_qblk_qst');
 
 4461                                $affectedRows = 
$ilDB->manipulateF(
"INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, question_fi) ".
 
 4462                                        "VALUES (%s, %s, %s, %s)",
 
 4463                                        array(
'integer',
'integer',
'integer',
'integer'),
 
 4464                                        array($next_id, $newObj->getSurveyId(), $questionblocks[$value[
"questionblock_fi"]], $question_pointer[$value[
"question_fi"]])
 
 4471                $newConstraints = array();
 
 4472                foreach ($constraints as $key => $constraint)
 
 4474                        if ($question_pointer[$constraint[
"for_question"]] &&
 
 4475                                $question_pointer[$constraint[
"question"]])
 
 4477                                if (!array_key_exists($constraint[
'id'], $newConstraints))
 
 4479                                        $constraint_id = $newObj->addConstraint($question_pointer[$constraint[
"question"]], $constraint[
"relation_id"], $constraint[
"value"], $constraint[
'conjunction']);
 
 4480                                        $newConstraints[$constraint[
'id']] = $constraint_id;
 
 4482                                $newObj->addConstraintToQuestion($question_pointer[$constraint[
"for_question"]], $newConstraints[$constraint[
'id']]);
 
 4487                $result = 
$ilDB->queryF(
"SELECT * FROM svy_qst_oblig WHERE survey_fi = %s",
 
 4495                                if($question_pointer[
$row[
"question_fi"]])
 
 4497                                        $next_id = 
$ilDB->nextId(
'svy_qst_oblig');
 
 4498                                        $affectedRows = 
$ilDB->manipulateF(
"INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, ".
 
 4499                                                "obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)",
 
 4500                                                array(
'integer',
'integer',
'integer',
'text',
'integer'),
 
 4501                                                array($next_id, $newObj->getSurveyId(), $question_pointer[
$row[
"question_fi"]], 
$row[
"obligatory"], time())
 
 4512                $result = 
$ilDB->queryF(
"SELECT * FROM svy_svy_qst WHERE question_fi = %s",
 
 4519                        return $row[
"heading"];
 
 4534                foreach ($mapping as $original_id => $new_id)
 
 4537                        include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
 4549                include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
 4552                if(!is_writable($svy_data_dir))
 
 4554                        $this->
ilias->raiseError(
"Survey Data Directory (".$svy_data_dir
 
 4555                                .
") not writeable.",$this->
ilias->error_obj->FATAL);
 
 4559                $svy_dir = $svy_data_dir.
"/svy_".$this->
getId();
 
 4561                if(!@is_dir($svy_dir))
 
 4563                        $this->
ilias->raiseError(
"Creation of Survey Directory failed.",$this->
ilias->error_obj->FATAL);
 
 4566                $export_dir = $svy_dir.
"/export";
 
 4568                if(!@is_dir($export_dir))
 
 4570                        $this->
ilias->raiseError(
"Creation of Export Directory failed.",$this->
ilias->error_obj->FATAL);
 
 4579                include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
 4591                if (!@is_dir($dir) or
 
 4592                        !is_writeable($dir))
 
 4604                while ($entry = $dir->read())
 
 4606                        if ($entry != 
"." && $entry != 
".." && ereg(
"^[0-9]{10}_{2}[0-9]+_{2}(svy_)*[0-9]+\.[a-z]{1,3}\$", $entry))
 
 4628                include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
 4632                if(!is_writable($svy_data_dir))
 
 4634                        $this->
ilias->raiseError(
"Survey Data Directory (".$svy_data_dir
 
 4635                                .
") not writeable.",$this->
ilias->error_obj->FATAL);
 
 4639                $svy_dir = $svy_data_dir.
"/svy_".$this->
getId();
 
 4641                if(!@is_dir($svy_dir))
 
 4643                        $this->
ilias->raiseError(
"Creation of Survey Directory failed.",$this->
ilias->error_obj->FATAL);
 
 4647                $import_dir = $svy_dir.
"/import";
 
 4649                if(!@is_dir($import_dir))
 
 4651                        $this->
ilias->raiseError(
"Creation of Import Directory failed.",$this->
ilias->error_obj->FATAL);
 
 4660                include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
 4662                        "/svy_".$this->getId().
"/import";
 
 4663                if (!is_dir($import_dir))
 
 4667                if(@is_dir($import_dir))
 
 4682                        $affectedRows = 
$ilDB->manipulateF(
"UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
 
 4683                                array(
'text',
'integer',
'integer'),
 
 4684                                array($heading, $this->
getSurveyId(), $insertbefore)
 
 4689                        $affectedRows = 
$ilDB->manipulateF(
"UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
 
 4690                                array(
'text',
'integer',
'integer'),
 
 4700                $result = 
$ilDB->queryF(
"SELECT anonymous_id FROM svy_anonymous WHERE survey_key = %s AND survey_fi = %s",
 
 4701                        array(
'text',
'integer'),
 
 4704                return (
$result->numRows() == 1) ? true : 
false;
 
 4712                $result = $ilDB->queryF(
"SELECT anonymous_id FROM svy_finished WHERE survey_fi = %s AND user_fi = %s",
 
 4713                        array(
'integer',
'integer'),
 
 4719                        return $row[
"anonymous_id"];
 
 4731                if($user_id == ANONYMOUS_USER_ID)
 
 4738                        $ilDB->manipulate(
"UPDATE svy_anonymous".
 
 4739                                " SET user_key = ".
$ilDB->quote(md5($user_id), 
"text").
 
 4740                                " WHERE survey_key = ".
$ilDB->quote($code, 
"text"));
 
 4748                $result = 
$ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE anonymous_id = %s AND survey_fi = %s",
 
 4749                        array(
'text',
'integer'),
 
 4752                return (
$result->numRows() == 1) ? true : 
false;
 
 4784                $result = 
$ilDB->queryF(
"SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND user_key IS NULL",
 
 4802                include_once 
"./Services/Link/classes/class.ilLink.php";
 
 4804                $sql = 
"SELECT svy_anonymous.*, svy_finished.state".
 
 4805                        " FROM svy_anonymous".
 
 4806                        " LEFT JOIN svy_finished ON (svy_anonymous.survey_key = svy_finished.anonymous_id)".
 
 4807                        " WHERE svy_anonymous.survey_fi = ".$ilDB->quote($this->
getSurveyId(), 
"integer").
 
 4808                        " AND svy_anonymous.user_key IS NULL";
 
 4812                        $sql .= 
" AND ".$ilDB->in(
"svy_anonymous.survey_key", $a_codes, 
"", 
"text");
 
 4816                        $sql .= 
" AND ".$ilDB->in(
"svy_anonymous.anonymous_id", $a_ids, 
"", 
"text");
 
 4823                $titles[] = 
'"'.$lng->txt(
"survey_code").
'"';
 
 4824                $titles[] = 
'"'.$lng->txt(
"email").
'"';
 
 4825                $titles[] = 
'"'.$lng->txt(
"lastname").
'"';
 
 4826                $titles[] = 
'"'.$lng->txt(
"firstname").
'"';
 
 4827                $titles[] = 
'"'.$lng->txt(
"create_date").
'"';
 
 4828                $titles[] = 
'"'.$lng->txt(
"used").
'"';
 
 4829                $titles[] = 
'"'.$lng->txt(
"mail_sent_short").
'"';
 
 4830                $titles[] = 
'"'.$lng->txt(
"survey_code_url").
'"';
 
 4831                $export[] = implode(
";", $titles);
 
 4834                $default_lang = 
$ilUser->getPref(
"survey_code_language");
 
 4838                        $item[] = 
$row[
"survey_key"];
 
 4840                        if(
$row[
"externaldata"])
 
 4842                                $ext = unserialize(
$row[
"externaldata"]);
 
 4843                                $item[] = $ext[
"email"];
 
 4844                                $item[] = $ext[
"lastname"];
 
 4845                                $item[] = $ext[
"firstname"];                            
 
 4859                        $item[] = (
$row[
"sent"]) ? 1 : 0;
 
 4861                        $params = array(
"accesscode" => 
$row[
"survey_key"]);
 
 4864                                $params[
"lang"] = $default_lang;
 
 4868                        $export[] = 
'"'.implode(
'";"', $item).
'"';
 
 4870                return implode(
"\n", $export);
 
 4884                include_once 
"./Services/Link/classes/class.ilLink.php";
 
 4888                $sql = 
"SELECT svy_anonymous.*, svy_finished.state".
 
 4889                        " FROM svy_anonymous".
 
 4890                        " LEFT JOIN svy_finished ON (svy_anonymous.survey_key = svy_finished.anonymous_id)".
 
 4891                        " WHERE svy_anonymous.survey_fi = ".$ilDB->quote($this->
getSurveyId(), 
"integer") 
 
 4896                        $sql .= 
" AND ".$ilDB->in(
"svy_anonymous.anonymous_id", $ids, 
"", 
"integer");
 
 4899                $sql .= 
" ORDER BY tstamp, survey_key ASC";                     
 
 4913                                        $params = array(
"accesscode" => 
$row[
"survey_key"]);
 
 4916                                                $params[
"lang"] = 
$lang;
 
 4923                                        'id' => 
$row[
"anonymous_id"],
 
 4924                                        'code' => 
$row[
"survey_key"],
 
 4925                                        'date' => 
$row[
"tstamp"], 
 
 4927                                        'sent' => 
$row[
'sent'],
 
 4934                                if(
$row[
"externaldata"])
 
 4936                                        $ext = unserialize(
$row[
"externaldata"]);
 
 4937                                        $item[
'email'] = $ext[
'email'];
 
 4938                                        $item[
'last_name'] = $ext[
'lastname'];
 
 4939                                        $item[
'first_name'] = $ext[
'firstname'];
 
 4942                                array_push($codes, $item);
 
 4951                $result = 
$ilDB->queryF(
"SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
 
 4952                        array(
'integer',
'text'),
 
 4955                return (
$result->numRows() > 0) ? true : 
false;
 
 4961                $result = 
$ilDB->queryF(
"SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
 
 4962                        array(
'integer',
'text'),
 
 4965                return (
$result->numRows() > 0) ? false : 
true;
 
 4974                for ($i = 0; $i < $nrOfCodes; $i++)
 
 4976                        $next_id = 
$ilDB->nextId(
'svy_anonymous');
 
 4977                        $ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, tstamp) ".
 
 4978                                "VALUES (%s, %s, %s, %s)",
 
 4979                                array(
'integer',
'text',
'integer',
'integer'),
 
 4992                $next_id = 
$ilDB->nextId(
'svy_anonymous');
 
 4993                $ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) ".
 
 4994                        "VALUES (%s, %s, %s, %s, %s)",
 
 4995                        array(
'integer',
'text',
'integer',
'text',
'integer'),
 
 4996                        array($next_id, $a_anonymize_key, $this->
getSurveyId(), serialize($a_data), $a_created)
 
 5005                foreach (
$data as $dataset)
 
 5008                        $next_id = 
$ilDB->nextId(
'svy_anonymous');
 
 5009                        $affectedRows = 
$ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) ".
 
 5010                                "VALUES (%s, %s, %s, %s, %s)",
 
 5011                                array(
'integer',
'text',
'integer',
'text',
'integer'),
 
 5012                                array($next_id, $anonymize_key, $this->
getSurveyId(), serialize($dataset), time())
 
 5027                $check_finished = ($not_sent > 1);
 
 5029                include_once 
"./Services/Mail/classes/class.ilMail.php";
 
 5030                include_once 
"./Services/Link/classes/class.ilLink.php";
 
 5032                $mail = 
new ilMail($user_id);
 
 5034                foreach ($recipients as 
$data)
 
 5039                                switch ((
int)$not_sent)
 
 5042                                                $do_send = !(bool)
$data[
'sent'];
 
 5046                                                $do_send = 
$data[
'finished'];
 
 5050                                                $do_send = !
$data[
'finished'];
 
 5060                                        $messagetext = $message;
 
 5063                                                        "accesscode" => 
$data[
"code"],
 
 5066                                        $messagetext = str_replace(
'[url]', 
"<" . $url . 
">", $messagetext);
 
 5067                                        foreach (
$data as $key => $value)
 
 5069                                                $messagetext = str_replace(
'[' . $key . 
']', $value, $messagetext);
 
 5087                $ilDB->manipulateF(
"UPDATE svy_anonymous SET sent = %s WHERE survey_fi = %s AND externaldata IS NOT NULL",
 
 5088                        array(
'integer',
'integer'),
 
 5096                $result = 
$ilDB->queryF(
"SELECT survey_key code, externaldata, sent FROM svy_anonymous WHERE survey_fi = %s",
 
 5103                        if(!
$row[
'externaldata'])
 
 5108                        $externaldata = unserialize(
$row[
'externaldata']);
 
 5109                        if(!$externaldata[
'email'])
 
 5114                        $externaldata[
'code'] = 
$row[
'code'];
 
 5115                        $externaldata[
'sent'] = 
$row[
'sent'];
 
 5117                        if($a_check_finished)
 
 5122                        array_push(
$res, $externaldata);
 
 5136                if (strlen($survey_code) > 0)
 
 5138                        $affectedRows = 
$ilDB->manipulateF(
"DELETE FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
 
 5139                                array(
'integer', 
'text'),
 
 5155                $result = 
$ilDB->queryF(
"SELECT survey_key FROM svy_anonymous WHERE survey_fi = %s AND user_key = %s",
 
 5156                        array(
'integer',
'text'),
 
 5162                        $access_code = 
$row[
"survey_key"];
 
 5164                return $access_code;
 
 5179                $next_id = 
$ilDB->nextId(
'svy_anonymous');
 
 5180                $affectedRows = 
$ilDB->manipulateF(
"INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, user_key, tstamp) ".
 
 5181                        "VALUES (%s, %s, %s, %s, %s)",
 
 5182                        array(
'integer',
'text', 
'integer', 
'text', 
'integer'),
 
 5183                        array($next_id, $access_code, $this->
getSurveyId(), md5($user_id), time())
 
 5195                $codestring = 
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
 5198                for ($i = 1; $i <=5; $i++)
 
 5200                        $index = mt_rand(0, strlen($codestring)-1);
 
 5201                        $code .= substr($codestring, $index, 1);
 
 5224                $resultarray = array();
 
 5225                foreach (
$row as $rowindex => $entry)
 
 5227                        if(is_array($entry))
 
 5229                                $entry = implode(
"/", $entry);
 
 5236                        if (strpos($entry, 
"\"") !== FALSE)
 
 5238                                $entry = str_replace(
"\"", 
"\"\"", $entry);
 
 5246                        $entry = str_replace(chr(13).chr(10), chr(10), $entry);
 
 5249                                $resultarray[$rowindex] = utf8_decode(
"\"" . $entry . 
"\"");
 
 5253                                $resultarray[$rowindex] = utf8_decode($entry);
 
 5256                return $resultarray;
 
 5263                $result = 
$ilDB->queryF(
"SELECT tstamp FROM svy_answer WHERE active_fi = %s ORDER BY tstamp DESC",
 
 5270                        return $row[
"tstamp"];
 
 5274                        $result = 
$ilDB->queryF(
"SELECT tstamp FROM svy_finished WHERE finished_id = %s",
 
 5281                                return $row[
"tstamp"];
 
 5295                include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
 5308                if (preg_match(
"/<[^>]*?>/", $a_text))
 
 5326        function addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag = TRUE, $add_mobs = TRUE, $attribs = NULL)
 
 5328                include_once 
"./Services/RTE/classes/class.ilRTE.php";
 
 5329                include_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
 
 5331                $a_xml_writer->xmlStartTag(
"material", $attribs);
 
 5333                        "type" => 
"text/plain" 
 5335                if ($this->
isHTML($a_material))
 
 5337                        $attrs[
"type"] = 
"text/xhtml";
 
 5340                $a_xml_writer->xmlElement(
"mattext", $attrs, $mattext);
 
 5345                        foreach (
$mobs as $mob)
 
 5347                                $mob_id = 
"il_" . IL_INST_ID . 
"_mob_" . $mob;
 
 5348                                if (strpos($mattext, $mob_id) !== FALSE)
 
 5353                                                "uri" => 
"objects/" . 
"il_" . IL_INST_ID . 
"_mob_" . $mob . 
"/" . $mob_obj->getTitle(),
 
 5354                                                "type" => 
"svy:html",
 
 5355                                                "id" => $this->getId()
 
 5357                                        $a_xml_writer->xmlElement(
"matimage", $imgattrs, NULL);
 
 5361                if ($close_material_tag) $a_xml_writer->xmlEndTag(
"material");
 
 5376                        if ($this->surveyCodeSecurity == FALSE)
 
 5395                if (extension_loaded(
"tidy"))
 
 5399                                "output-xml"     => 
true,
 
 5400                                "numeric-entities" => 
true 
 5403                        $tidy->parseString($print_output, $config, 
'utf8');
 
 5404                        $tidy->cleanRepair();
 
 5405                        $print_output = tidy_get_output($tidy);
 
 5406                        $print_output = preg_replace(
"/^.*?(<html)/", 
"\\1", $print_output);
 
 5410                        $print_output = str_replace(
" ", 
" ", $print_output);
 
 5411                        $print_output = str_replace(
"⊗", 
"X", $print_output);
 
 5414                        $print_output = str_replace(
">", 
">", $print_output);
 
 5415                        $print_output = str_replace(
"<", 
"<", $print_output);
 
 5416                        $print_output = str_replace(
" ", 
"~|nbsp|~", $print_output);
 
 5417                        $print_output = preg_replace(
'/&(?!amp)/', 
'&', $print_output);
 
 5418                        $print_output = str_replace(
"~|nbsp|~", 
" ", $print_output);                       
 
 5420                $xsl = file_get_contents(
"./Modules/Survey/xml/question2fo.xsl");
 
 5424                                'font-family="Helvetica, unifont"',
 
 5425                                'font-family="'.
$GLOBALS[
'ilSetting']->
get(
'rpc_pdf_font',
'Helvetica, unifont').
'"',
 
 5429                $args = array( 
'/_xml' => $print_output, 
'/_xsl' => $xsl );
 
 5432                $output = xslt_process($xh, 
"arg:/_xml", 
"arg:/_xsl", NULL, $args, $params);
 
 5449                include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
 5451                $fp = fopen($fo_file, 
"w"); fwrite($fp, $fo); fclose($fp);
 
 5453                include_once 
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
 
 5462                        $ilLog->write(__METHOD__.
': '.$e->getMessage());
 
 5467                        $ilLog->write(__METHOD__.
': '.$e->getMessage());
 
 5488                global $ilPluginAdmin;
 
 5489                if ($ilPluginAdmin->isActive(
IL_COMP_MODULE, 
"SurveyQuestionPool", 
"svyq", $a_pname))
 
 5519                if (!is_array($ids) || count($ids) ==0) 
return array();
 
 5521                $result = 
$ilDB->query(
"SELECT usr_id, login, lastname, firstname FROM usr_data WHERE " . 
$ilDB->in(
'usr_id', $ids, 
false, 
'integer') . 
" ORDER BY login");
 
 5522                $result_array = array();
 
 5525                        $result_array[
$row[
"usr_id"]]= 
$row;
 
 5527                return $result_array;
 
 5532                if (!is_array($ids) || count($ids) ==0) 
return array();
 
 5544                if (!is_array($ids) || count($ids) ==0) 
return array();
 
 5546                foreach ($ids as $obj_id)
 
 5560                $this->mailnotification = ($a_notification) ? 
true : 
false;
 
 5570                $this->mailaddresses = $a_addresses;
 
 5580                $this->mailparticipantdata = $a_data;
 
 5587                $result = 
$ilDB->queryF(
"SELECT * FROM svy_times, svy_finished WHERE svy_finished.survey_fi = %s",
 
 5589                        array($this->
getId())
 
 5594                        if (strlen(
$row[
'left_page']) && strlen(
$row[
'entered_page']))
 
 5595                                $times[
$row[
'finished_fi']] += (
$row[
'left_page']-
$row[
'entered_page']);
 
 5605                $affectedRows = 
$ilDB->manipulateF(
"INSERT INTO svy_times (finished_fi, entered_page, left_page, first_question) VALUES (%s, %s, %s, %s)",
 
 5606                        array(
'integer', 
'integer', 
'integer', 
'integer'),
 
 5607                        array($finished_id, $time, NULL, $first_question)
 
 5615                $affectedRows = 
$ilDB->manipulateF(
"UPDATE svy_times SET left_page = %s WHERE finished_fi = %s AND entered_page = %s",
 
 5616                        array(
'integer', 
'integer', 
'integer'),
 
 5617                        array($time, $finished_id, 
$_SESSION[
'svy_entered_page'])
 
 5626                $result = 
$ilDB->queryF(
"SELECT * FROM svy_times WHERE finished_fi = %s",
 
 5633                        if (
$row[
'left_page'] > 0 && 
$row[
'entered_page'] > 0)
 
 5651                if(
sizeof($this->questions) == 
sizeof($a_order))
 
 5653                        $this->questions = array_flip($a_order);
 
 5654                        $this->saveQuestionsToDB();
 
 5665                $this->pool_usage = (bool)$a_value;
 
 5677                if($template_settings)
 
 5679                        include_once 
"Services/Administration/classes/class.ilSettingsTemplate.php";
 
 5681                        $template_settings = $template_settings->getSettings();
 
 5682                        $template_settings = $template_settings[
"use_pool"];
 
 5683                        if($template_settings && $template_settings[
"hide"])
 
 5685                                $use_pool = (bool)$template_settings[
"value"];
 
 5703                include_once 
"Services/Administration/classes/class.ilSettingsTemplate.php";
 
 5705                $template_settings = $template->getSettings();
 
 5706                if($template_settings)
 
 5708                        if($template_settings[
"show_question_titles"] !== NULL)
 
 5710                                if($template_settings[
"show_question_titles"][
"value"])
 
 5720                        if($template_settings[
"use_pool"] !== NULL)
 
 5722                                if($template_settings[
"use_pool"][
"value"])
 
 5732                        if($template_settings[
"anonymization_options"][
"value"])
 
 5734                                $anon_map = array(
'personalized' => self::ANONYMIZE_OFF,
 
 5735                                        'anonymize_with_code' => self::ANONYMIZE_ON,
 
 5736                                        'anonymize_without_code' => self::ANONYMIZE_FREEACCESS);
 
 5737                                $this->
setAnonymize($anon_map[$template_settings[
"anonymization_options"][
"value"]]);
 
 5751        public function updateCode($a_id, $a_email, $a_last_name, $a_first_name, $a_sent)
 
 5755                $a_email = trim($a_email);
 
 5763                $data = array(
"email" => $a_email,
 
 5764                        "lastname" => trim($a_last_name),
 
 5765                        "firstname" => trim($a_first_name));
 
 5768                        "externaldata" => array(
"text", serialize(
$data)),
 
 5769                        "sent" => array(
"integer", $a_sent)                     
 
 5772                $ilDB->update(
"svy_anonymous", $fields,
 
 5773                        array(
"anonymous_id" => array(
"integer", $a_id)));                                                      
 
 5783                $this->mode_360 = (bool)$a_value;
 
 5793                $this->mode_360_self_eval = (bool)$a_value;
 
 5803                $this->mode_360_self_appr = (bool)$a_value;
 
 5813                $this->mode_360_self_rate = (bool)$a_value;
 
 5823                $this->mode_360_results = (int)$a_value;
 
 5836                        $a_user_id != ANONYMOUS_USER_ID)
 
 5839                                "obj_id" => array(
"integer", $this->
getSurveyId()),
 
 5840                                "user_id" => array(
"integer", $a_user_id)
 
 5842                        $ilDB->insert(
"svy_360_appr", $fields);                 
 
 5850                $set = 
$ilDB->query(
"SELECT user_id".
 
 5851                        " FROM svy_360_appr".
 
 5852                        " WHERE obj_id = ".
$ilDB->quote($this->getSurveyId(), 
"integer").
 
 5853                        " AND user_id = ".$ilDB->quote($a_user_id, 
"integer"));         
 
 5854                return (
bool)
$ilDB->numRows($set);              
 
 5861                $set = 
$ilDB->query(
"SELECT has_closed".
 
 5862                        " FROM svy_360_appr".
 
 5863                        " WHERE obj_id = ".
$ilDB->quote($this->getSurveyId(), 
"integer").
 
 5864                        " AND user_id = ".$ilDB->quote($a_user_id, 
"integer"));         
 
 5866                return $row[
"has_closed"];                              
 
 5873                $ilDB->manipulate(
"DELETE FROM svy_360_appr".
 
 5874                        " WHERE obj_id = ".
$ilDB->quote($this->getSurveyId(), 
"integer").
 
 5875                        " AND user_id = ".$ilDB->quote($a_user_id, 
"integer"));         
 
 5877                $set = 
$ilDB->query(
"SELECT user_id".
 
 5878                        " FROM svy_360_rater".
 
 5879                        " WHERE obj_id = ".
$ilDB->quote($this->getSurveyId(), 
"integer").               
 
 5880                        " AND appr_id = ".$ilDB->quote($a_user_id, 
"integer"));         
 
 5898                $set = 
$ilDB->query(
"SELECT * FROM svy_360_appr".
 
 5899                        " WHERE obj_id = ".
$ilDB->quote($this->getSurveyId(), 
"integer"));              
 
 5908                        foreach($raters as $rater)
 
 5910                                if($rater[
"finished"])
 
 5915                        $res[
$row[
"user_id"]][
"finished"] = $finished.
"/".
sizeof($raters);
 
 5922        public function addRater($a_appraisee_id, $a_user_id, $a_anonymous_id = 0)
 
 5927                        !$this->
isRater($a_appraisee_id, $a_user_id, $a_anonymous_id))
 
 5930                                "obj_id" => array(
"integer", $this->
getSurveyId()),
 
 5931                                "appr_id" => array(
"integer", $a_appraisee_id),
 
 5932                                "user_id" => array(
"integer", $a_user_id),
 
 5933                                "anonymous_id" => array(
"integer", $a_anonymous_id)
 
 5935                        $ilDB->insert(
"svy_360_rater", $fields);                        
 
 5939        public function isRater($a_appraisee_id, $a_user_id, $a_anonymous_id = 0)
 
 5946                        (!$a_appraisee_id || $a_appraisee_id == $a_user_id))
 
 5953                $sql = 
"SELECT user_id".
 
 5954                        " FROM svy_360_rater".
 
 5955                        " WHERE obj_id = ".$ilDB->quote($this->
getSurveyId(), 
"integer").                       
 
 5956                        " AND user_id = ".$ilDB->quote($a_user_id, 
"integer").          
 
 5957                        " AND anonymous_id = ".$ilDB->quote($a_anonymous_id, 
"integer");                
 
 5960                        $sql .= 
" AND appr_id = ".$ilDB->quote($a_appraisee_id, 
"integer");
 
 5962                $set = 
$ilDB->query($sql);              
 
 5963                return (
bool)
$ilDB->numRows($set);              
 
 5966        public function deleteRater($a_appraisee_id, $a_user_id, $a_anonymous_id = 0)
 
 5976                $ilDB->manipulate(
"DELETE FROM svy_360_rater".
 
 5977                        " WHERE obj_id = ".
$ilDB->quote($this->getSurveyId(), 
"integer").
 
 5978                        " AND appr_id = ".$ilDB->quote($a_appraisee_id, 
"integer").             
 
 5979                        " AND user_id = ".$ilDB->quote($a_user_id, 
"integer").          
 
 5980                        " AND anonymous_id = ".$ilDB->quote($a_anonymous_id, 
"integer"));                       
 
 5987                $res = $anonymous_ids = array();
 
 5989                $set = 
$ilDB->query(
"SELECT * FROM svy_360_rater".
 
 5990                        " WHERE obj_id = ".
$ilDB->quote($this->getSurveyId(), 
"integer").               
 
 5991                        " AND appr_id = ".$ilDB->quote($a_appraisee_id, 
"integer"));            
 
 5994                        if(
$row[
"anonymous_id"])
 
 5996                                $res[
"a".$row[
"anonymous_id"]] = array(
 
 5997                                        "lastname" => 
"unknown code ".
$row[
"anonymous_id"],
 
 5998                                        "sent" => 
$row[
"mail_sent"],
 
 6001                                $anonymous_ids[] = 
$row[
"anonymous_id"];
 
 6006                                $name[
"user_id"] = 
"u".$name[
"user_id"];
 
 6008                                $name[
"sent"] = 
$row[
"mail_sent"];
 
 6010                                $res[
"u".$row[
"user_id"]] = $name;
 
 6014                if(
sizeof($anonymous_ids))
 
 6017                        foreach(
$data as $item)
 
 6019                                if(isset(
$res[
"a".$item[
"id"]]))
 
 6021                                        $res[
"a".$item[
"id"]] = array(
 
 6022                                                "user_id" => 
"a".$item[
"id"],
 
 6023                                                "lastname" => $item[
"last_name"],
 
 6024                                                "firstname" => $item[
"first_name"],                                             
 
 6026                                                "email" => $item[
"email"],
 
 6027                                                "code" => $item[
"code"],
 
 6028                                                "href" => $item[
"href"],
 
 6029                                                "sent" => 
$res[
"a".$item[
"id"]][
"sent"],
 
 6045                $sql = 
"SELECT appr_id FROM svy_360_rater".
 
 6046                        " WHERE obj_id = ".$ilDB->quote($this->
getSurveyId(), 
"integer");
 
 6050                        $sql .= 
" AND user_id = ".$ilDB->quote($a_user_id, 
"integer");          
 
 6054                        $sql .= 
" AND anonymous_id = ".$ilDB->quote($a_anonymous_id, 
"integer");                
 
 6057                $set = 
$ilDB->query($sql);
 
 6066                        !in_array($a_user_id, 
$res))
 
 6068                        $res[] = $a_user_id;                                    
 
 6078                $set = 
$ilDB->query(
"SELECT anonymous_id FROM svy_anonymous".
 
 6079                                " WHERE survey_fi = ".
$ilDB->quote($this->getSurveyId(), 
"integer").            
 
 6080                                " AND survey_key = ".$ilDB->quote($a_code, 
"text"));    
 
 6082                return $res[
"anonymous_id"];
 
 6089                $sql = 
"SELECT * FROM svy_finished".
 
 6090                        " WHERE survey_fi =".$ilDB->quote($this->
getSurveyId(), 
"integer").
 
 6091                        " AND appr_id = ".$ilDB->quote($appr_id, 
"integer");                                    
 
 6094                        $sql .= 
" AND user_fi = ".$ilDB->quote($user_id, 
"integer");
 
 6098                        $sql .= 
" AND anonymous_id = ".$ilDB->quote($anonymous_code, 
"text");
 
 6108                        return (
int)
$row[
"state"];
 
 6125                                        $user_id != ANONYMOUS_USER_ID && 
 
 6138                else if($user_id == ANONYMOUS_USER_ID ||
 
 6155                $sql = 
"SELECT * FROM svy_finished".
 
 6156                        " WHERE survey_fi = ".$ilDB->quote($this->
getSurveyId(), 
"integer");            
 
 6158                if($user_id != ANONYMOUS_USER_ID)
 
 6160                        $sql .= 
" AND (user_fi = ".$ilDB->quote($user_id, 
"integer").
 
 6161                                " OR anonymous_id = ".$ilDB->quote($a_code, 
"text").
")";                
 
 6166                        $sql .= 
" AND anonymous_id = ".$ilDB->quote($a_code, 
"text");   
 
 6168                $set = 
$ilDB->query($sql);
 
 6171                        $res[
$row[
"finished_id"]] = array(
"appr_id" => 
$row[
"appr_id"],
 
 6172                                "user_id" => 
$row[
"user_fi"],
 
 6173                                "code" => 
$row[
"anonymous_id"],
 
 6174                                "finished" => (
bool)
$row[
"state"]);
 
 6177                return array(
"code"=>$a_code, 
"runs"=>
$res);
 
 6184                if($a_user_id != ANONYMOUS_USER_ID)
 
 6186                        $set = 
$ilDB->query(
"SELECT sf.anonymous_id FROM svy_finished sf".                              
 
 6187                                " WHERE sf.survey_fi = ".
$ilDB->quote($this->getSurveyId(), 
"integer").
 
 6188                                " AND sf.user_fi = ".$ilDB->quote($a_user_id, 
"integer"));
 
 6189                        $a_code = 
$ilDB->fetchAssoc($set);
 
 6190                        return $a_code[
"anonymous_id"];
 
 6198                $set = 
$ilDB->query(
"SELECT user_fi FROM svy_finished".
 
 6199                        " WHERE survey_fi = ".
$ilDB->quote($this->getSurveyId(), 
"integer").
 
 6200                        " AND anonymous_id = ".$ilDB->quote($a_code, 
"text"));
 
 6201                $user_id = 
$ilDB->fetchAssoc($set);
 
 6202                $user_id = $user_id[
"user_fi"];
 
 6204                if($user_id && ($user_id != $a_user_id || $user_id == ANONYMOUS_USER_ID))
 
 6217                $set = 
$ilDB->query(
"SELECT finished_id, user_fi FROM svy_finished".
 
 6218                        " WHERE survey_fi = ".
$ilDB->quote($this->getSurveyId(), 
"integer").
 
 6219                        " AND appr_id = ".$ilDB->quote($a_appr_id, 
"integer"));
 
 6222                        if ($a_exclude_appraisee && 
$row[
"user_fi"] == $a_appr_id)
 
 6243                $set = 
$ilDB->query(
"SELECT finished_id, user_fi FROM svy_finished".
 
 6244                        " WHERE survey_fi = ".
$ilDB->quote($this->getSurveyId(), 
"integer").
 
 6245                        " AND appr_id = ".$ilDB->quote($a_appr_id, 
"integer").
 
 6246                        " AND user_fi = ".$ilDB->quote($a_rat_id, 
"integer"));
 
 6248                return $row[
"finished_id"];
 
 6261                $this->mode_360_skill_service = $a_val;
 
 6283                $ilDB->manipulate(
"UPDATE svy_360_rater".
 
 6284                        " SET mail_sent = ".
$ilDB->quote($a_tstamp, 
"integer").
 
 6285                        " WHERE obj_id = ".$ilDB->quote($this->getSurveyId(), 
"integer").
 
 6286                        " AND appr_id = ".$ilDB->quote($a_appraisee_id, 
"integer").             
 
 6287                        " AND user_id = ".$ilDB->quote($a_user_id, 
"integer").          
 
 6288                        " AND anonymous_id = ".$ilDB->quote($a_anonymous_id, 
"integer"));       
 
 6296                $ilDB->manipulate(
"UPDATE svy_360_appr".
 
 6297                        " SET has_closed = ".
$ilDB->quote(time(), 
"integer").
 
 6298                        " WHERE obj_id = ".
$ilDB->quote($this->getSurveyId(), 
"integer").
 
 6299                        " AND user_id = ".$ilDB->quote($a_user_id, 
"integer"));
 
 6302                include_once(
"./Services/Skill/classes/class.ilSkillManagementSettings.php");
 
 6306                        include_once(
"./Modules/Survey/classes/class.ilSurveySkill.php");
 
 6308                        $sskill->writeAppraiseeSkills($a_user_id);
 
 6316                $ilDB->manipulate(
"UPDATE svy_360_appr".
 
 6317                        " SET has_closed = ".
$ilDB->quote(
null, 
"integer").
 
 6318                        " WHERE obj_id = ".$ilDB->quote($this->getSurveyId(), 
"integer"));
 
 6323                if(!isset(
$_SESSION[
"360_extrtr"][$a_ref_id]))
 
 6325                        $svy = 
new self($a_ref_id);
 
 6328                        if($svy->canStartSurvey(
null, 
true) &&
 
 6329                                $svy->get360Mode() &&
 
 6330                                $svy->isAnonymousKey($a_code))
 
 6332                                $anonymous_id = $svy->getAnonymousIdByCode($a_code);
 
 6335                                        if(
sizeof($svy->getAppraiseesToRate(
null, $anonymous_id)))
 
 6337                                                $_SESSION[
"360_extrtr"][$a_ref_id] = 
true;
 
 6343                        $_SESSION[
"360_extrtr"][$a_ref_id] = 
false;     
 
 6347                return $_SESSION[
"360_extrtr"][$a_ref_id];
 
 6362                $this->reminder_status = (bool)$a_value;
 
 6372                $this->reminder_start = $a_value;
 
 6382                $this->reminder_end = $a_value;
 
 6392                $this->reminder_frequency = (int)$a_value;
 
 6402                $this->reminder_target = (int)$a_value;
 
 6412                $this->reminder_last_sent = $a_value;
 
 6422                $this->tutor_ntf_status = (bool)$a_value;
 
 6432                $this->tutor_ntf_recipients = $a_value;                 
 
 6442                $this->tutor_ntf_target = (int)$a_value;
 
 6454                                $set = 
$ilDB->query(
"SELECT COUNT(*) numall FROM svy_finished".
 
 6455                                        " WHERE survey_fi = ".
$ilDB->quote($this->getSurveyId(), 
"integer").
 
 6456                                        " AND state = ".$ilDB->quote(1, 
"integer").
 
 6457                                        " AND ".$ilDB->in(
"user_fi", $user_ids, 
"", 
"integer"));
 
 6459                                if(
$row[
"numall"] == 
sizeof($user_ids))
 
 6471                if((
bool)$a_use_invited)
 
 6477                        $parent_grp_ref_id = $tree->checkForParentType($this->
getRefId(), 
"grp");
 
 6478                        if($parent_grp_ref_id)
 
 6480                                include_once 
"Modules/Group/classes/class.ilGroupParticipants.php";
 
 6482                                $user_ids = $part->getMembers();                                        
 
 6486                                $parent_crs_ref_id = $tree->checkForParentType($this->
getRefId(), 
"crs");
 
 6487                                if($parent_crs_ref_id)
 
 6489                                        include_once 
"Modules/Course/classes/class.ilCourseParticipants.php";
 
 6491                                        $user_ids = $part->getMembers();                                        
 
 6500                include_once 
"./Services/Mail/classes/class.ilMail.php";
 
 6501                include_once 
"./Services/User/classes/class.ilObjUser.php";
 
 6502                include_once 
"./Services/Language/classes/class.ilLanguageFactory.php";
 
 6503                include_once 
"./Services/User/classes/class.ilUserUtil.php";            
 
 6504                include_once 
"./Services/Link/classes/class.ilLink.php";
 
 6511                        $ulng->loadLanguageModule(
'survey');
 
 6513                        $subject = sprintf($ulng->txt(
'survey_notification_tutor_subject'), $this->getTitle());
 
 6516                        $message .= $ulng->txt(
'survey_notification_tutor_body').
":\n\n";
 
 6517                        $message .= $ulng->txt(
'obj_svy').
": ". $this->
getTitle().
"\n";                 
 
 6518                        $message .= 
"\n".$ulng->txt(
'survey_notification_tutor_link').
": ".$link;                               
 
 6520                        $mail_obj = 
new ilMail(ANONYMOUS_USER_ID);
 
 6521                        $mail_obj->appendInstallationSignature(
true);
 
 6523                                "", 
"", $subject, $message, array(), array(
"system"));
 
 6529                global 
$ilDB, $ilAccess;
 
 6532                $today = date(
"Y-m-d");
 
 6554                if($today < $start ||
 
 6555                        ($end && $today > $end))
 
 6561                include_once 
"Services/Object/classes/class.ilObjectActivation.php";    
 
 6564                        ($now < $item_data[
"timing_start"] ||
 
 6565                        $now > $item_data[
"timing_end"]))
 
 6576                        $missing_ids = array();
 
 6583                                $finished_ids = array();
 
 6584                                $set = 
$ilDB->query(
"SELECT user_fi FROM svy_finished".
 
 6585                                " WHERE survey_fi = ".
$ilDB->quote($this->getSurveyId(), 
"integer").
 
 6586                                " AND state = ".$ilDB->quote(1, 
"text").
 
 6587                                " AND ".$ilDB->in(
"user_fi", $user_ids, 
"", 
"integer"));
 
 6590                                        $finished_ids[] = 
$row[
"user_fi"];                                              
 
 6594                                $missing_ids = array_diff($user_ids, $finished_ids);
 
 6597                                        foreach($missing_ids as $idx => $user_id)
 
 6600                                                if(!$ilAccess->checkAccessOfUser($user_id, 
"read", 
"", $this->getRefId(), 
"svy", $this->getId()))
 
 6602                                                        unset($missing_ids[$idx]);
 
 6615                        return sizeof($missing_ids);
 
 6623                include_once 
"./Services/Mail/classes/class.ilMail.php";
 
 6624                include_once 
"./Services/User/classes/class.ilObjUser.php";
 
 6625                include_once 
"./Services/Language/classes/class.ilLanguageFactory.php";
 
 6626                include_once 
"./Services/User/classes/class.ilUserUtil.php";            
 
 6627                include_once 
"./Services/Link/classes/class.ilLink.php";
 
 6630                foreach($a_recipient_ids as $user_id)
 
 6634                        $ulng->loadLanguageModule(
'survey');
 
 6636                        $subject = sprintf($ulng->txt(
'survey_reminder_subject'), $this->getTitle());
 
 6639                        $message .= $ulng->txt(
'survey_reminder_body').
":\n\n";
 
 6640                        $message .= $ulng->txt(
'obj_svy').
": ". $this->
getTitle().
"\n";                 
 
 6641                        $message .= 
"\n".$ulng->txt(
'survey_reminder_link').
": ".$link;                         
 
 6643                        $mail_obj = 
new ilMail(ANONYMOUS_USER_ID);
 
 6644                        $mail_obj->appendInstallationSignature(
true);
 
 6646                                "", 
"", $subject, $message, array(), array(
"system"));
 
 6652                $this->activation_starting_time = $starting_time;
 
 6657                $this->activation_ending_time = $ending_time;
 
 6662                return (strlen($this->activation_starting_time)) ? $this->activation_starting_time : NULL;
 
 6667                return (strlen($this->activation_ending_time)) ? $this->activation_ending_time : NULL;
 
 6672                $this->view_own_results = (bool)$a_value;
 
 6682                $this->mail_own_results = (bool)$a_value;
 
 6696                include_once 
"./Services/Administration/classes/class.ilSetting.php";
 
 6697                $surveySetting = 
new ilSetting(
"survey");
 
 6698                if(!$surveySetting->get(
"skipped_is_custom", 
false))
 
 6700                        return $lng->txt(
"skipped");
 
 6704                        return $surveySetting->get(
"skipped_custom_value", 
"");
 
Survey Question Import Parser.
Survey Question Import Parser.
static & _getQuestionGUI($questiontype, $question_id=-1)
Creates a question gui representation.
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
_getQuestionType($question_id)
Returns the question type of a question with a given id.
_getOriginalId($question_id, $a_return_question_id_if_no_original=true)
Returns the original id of a question.
_isComplete($question_id)
Checks whether the question is complete or not.
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
static _getLanguageOfUser($a_usr_id)
Get language object of user.
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
static _getStaticLink($a_ref_id, $a_type='', $a_fallback_goto=true, $append="")
Get static link.
Class Mail this class handles base functions for mail handling.
& _getUsedHTMLTagsAsString($a_module="")
Returns a string of all allowed HTML tags for text editing.
static & _getQuestionTypeTranslations()
_getAvailableQuestionpools($use_object_id=FALSE, $could_be_offline=FALSE, $showPath=FALSE, $permission="read")
Returns the available question pools for the active user.
setShowQuestionTitles($a_show)
Sets the status of the display_question_titles attribute.
isAccessibleWithoutCode()
Checks if the survey is accessable without a survey code.
setAuthor($author="")
Sets the authors name of the ilObjSurvey object.
setActivationVisibility($a_value)
moveUpQuestionblock($questionblock_id)
Moves a questionblock up in the list of survey questions.
const MODE_PREDEFINED_USERS
getUserAccessCode($user_id)
Returns a survey access code that was saved for a registered user.
getParticipantTextResults($active_id)
deleteConstraints($question_id)
Deletes the constraints for a question.
insertQuestion($question_id)
Inserts a question in the survey and saves the relation to the database.
moveUpQuestion($question_id)
Moves a question up in the list of survey questions.
const EVALUATION_ACCESS_PARTICIPANTS
finishSurvey($finished_id)
Finishes the survey creating an entry in the database.
getActiveID($user_id, $anonymize_id, $appr_id)
Checks if a user already started a survey.
setTutorNotificationStatus($a_value)
& _getGlobalSurveyData($obj_id)
Returns an array with data needed in the repository, personal desktop or courses.
deleteAppraisee($a_user_id)
inviteGroup($group_id)
Invites a group to a survey.
deleteSurveyCode($survey_code)
Deletes a given survey access code.
getExportDirectory()
get export directory of survey
getStatus()
Gets the survey status.
& getQuestions($question_ids)
removeConstraintsConcerningQuestion($question_id)
Remove constraints concerning a question with a given question_id.
isOffline()
Gets the survey status.
getInvitation()
Gets the invitation status.
getAnonymize()
get anonymize status
& getAvailableQuestionpools($use_obj_id=false, $could_be_offline=false, $showPath=FALSE, $permission="read")
Returns the available question pools for the active user.
getConstraints($question_id)
Returns the constraints to a given question or questionblock.
addQuestion($question_id)
Adds a question to the survey.
canStartSurvey($anonymous_id=NULL, $a_no_rbac=false)
Checks if the survey can be started.
getActivationVisibility()
prepareTextareaOutput($txt_output)
Prepares a string for a text area output in surveys.
getQuestionType($question_id)
Returns the question type of a question with a given id.
setIntroduction($introduction="")
Sets the introduction text.
showQuestionTitles()
Sets the question titles visible during the query.
setMailOwnResults($a_value)
inviteRole($role_id)
Invites a role to a survey.
deleteWorkingData($question_id, $active_id)
Deletes the working data of a question in the database.
setActivationLimited($a_value)
createImportDirectory()
creates data directory for import files (data_dir/svy_data/svy_<id>/import, depending on data directo...
& getObligatoryStates()
Gets specific obligatory states of the survey.
setStartDateAndTime($start_date="", $start_time)
Sets the start date of the survey.
setInvitationMode($invitation_mode=0)
Sets the invitation mode.
hasAnonymizedResults()
Checks if the survey results are to be anonymized.
updateConstraint($precondition_id, $if_question_id, $relation, $value, $conjunction)
Updates a precondition.
cloneObject($a_target_id, $a_copy_id=0)
Clone object.
findCodeForUser($a_user_id)
setTutorNotificationTarget($a_value)
disinviteUser($user_id)
Disinvites a user from a survey.
updateCode($a_id, $a_email, $a_last_name, $a_first_name, $a_sent)
loadQuestionsFromDb()
Loads the survey questions from the database.
setMailAddresses($a_addresses)
addQuestionToBlock($question_id, $questionblock_id)
_getConstraints($survey_id)
Returns the constraints to a given question or questionblock.
cleanupMediaobjectUsage()
Cleans up the media objects for all text fields in a test which are using an RTE field.
processPrintoutput2FO($print_output)
Convert a print output to XSL-FO.
setActivationStartDate($starting_time=NULL)
getOutro()
Gets the outro text.
create($a_upload=false)
create survey object
notify($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
notifys an object about an event occured Based on the event happend, each object may decide how it re...
setActivationEndDate($ending_time=NULL)
getRatersData($a_appraisee_id)
getTutorNotificationRecipients()
isAllowedToTakeMultipleSurveys($userid="")
Checks if a user is allowed to take multiple survey.
createSurveyCodesForExternalData($data)
& processCSVRow($row, $quoteAll=FALSE, $separator=";")
Processes an array as a CSV row and converts the array values to correct CSV values.
& getQuestionpoolTitles($could_be_offline=FALSE, $showPath=FALSE)
Get the titles of all available survey question pools.
getQuestionGUI($questiontype, $question_id)
Returns a question gui object to a given questiontype and question id.
createMetaData()
Create meta data entry.
cloneTextblocks($mapping)
Clones the textblocks of survey questions.
getPrecondition($id)
Returns a precondition with a given id.
setReminderLastSent($a_value)
importSurveyCode($a_anonymize_key, $a_created, $a_data)
moveDownQuestionblock($questionblock_id)
Moves a questionblock down in the list of survey questions.
setOutro($outro="")
Sets the outro text.
& getSurveyParticipants($finished_ids=null)
setObligatoryStates($obligatory_questions)
Sets the obligatory states for questions in a survey from the questions form.
isRater($a_appraisee_id, $a_user_id, $a_anonymous_id=0)
saveHeading($heading="", $insertbefore)
getSurveyCodesCount()
Returns the number of generated survey codes for the survey.
getFinishedIdForAppraiseeIdAndRaterId($a_appr_id, $a_rat_id)
Get finished id for an appraisee and a rater.
addRater($a_appraisee_id, $a_user_id, $a_anonymous_id=0)
deleteConstraint($constraint_id)
Deletes a constraint of a question.
fillSurveyForUser($user_id=ANONYMOUS_USER_ID)
Fills a survey randomly with data for a given user.
getUserSurveyExecutionStatus($a_code=null)
const NOTIFICATION_INVITED_USERS
getInvitationMode()
Gets the invitation mode.
locateImportFiles($a_dir)
Locates the import directory and the xml file in a directory with an unzipped import file.
sendCodes($not_sent, $subject, $message, $lang)
getExportFiles($dir)
get export files
duplicateQuestionForSurvey($question_id, $a_force=false)
Takes a question and creates a copy of the question for use in the survey.
isHTML($a_text)
Checks if a given string contains HTML or not.
getWorkingtimeForParticipant($finished_id)
checkConstraint($constraint_data, $working_data)
Checks if a constraint is valid.
setSurveyId($survey_id)
Sets the survey id.
getDetailedParticipantResultsAsText()
getCumulatedResults(&$question, $finished_ids)
Calculates the evaluation data for a question.
disinviteAllUsers()
Disinvite all users.
setReminderStart(ilDate $a_value=null)
deleteAllUserData()
Deletes all user data of a survey.
const NOTIFICATION_PARENT_COURSE
const EVALUATION_ACCESS_ALL
closeAppraisee($a_user_id)
getUserSurveyCode($user_id)
setStatus($status=self::STATUS_OFFLINE)
Sets the survey status.
deleteRater($a_appraisee_id, $a_user_id, $a_anonymous_id=0)
setMailNotification($a_notification)
getTextblock($question_id)
applySettingsTemplate($template_id)
Apply settings template.
isUnusedCode($a_code, $a_user_id)
& getUserSpecificResults($finished_ids)
Calculates the evaluation data for the user specific results.
setMailParticipantData($a_data)
setInvitation($invitation=0)
Sets the invitation status.
moveQuestions($move_questions, $target_index, $insert_mode)
Move questions and/or questionblocks to another position.
isAnonymizedParticipant($key)
updateConjunctionForQuestions($questions, $conjunction)
getQuestionblocksTable($arrFilter)
Calculates the data for the output of the questionblock browser.
getTutorNotificationTarget()
isPoolActive()
Get current pool status.
getUserSettings($usr_id, $key)
getFinishedIdsForAppraiseeId($a_appr_id, $a_exclude_appraisee=false)
const QUESTIONTITLES_VISIBLE
isSurveyCodeUnique($code)
& getInvitedUsers()
Returns a list of all invited users in a survey.
moveDownQuestion($question_id)
Moves a question down in the list of survey questions.
getExternalCodeRecipients($a_check_finished=false)
toXML()
Returns a QTI xml representation of the survey.
getEvaluationAccess()
Gets the learners evaluation access.
createQuestionblock($title, $show_questiontext, $show_blocktitle, $questions)
Creates a question block for the survey.
getAnonymousIdByCode($a_code)
getAppraiseesToRate($a_user_id, $a_anonymous_id=null)
_addQuestionblock($title="", $owner=0, $show_questiontext=true, $show_blocktitle=false)
Adds a questionblock to the database.
& getSurveyPages()
Returns the survey pages in an array (a page contains one or more questions)
saveToDb()
Saves a survey object to a database.
insertQuestionblock($questionblock_id)
Inserts a questionblock in the survey and saves the relation to the database.
hideQuestionTitles()
Sets the question titles hidden during the query.
getAllRTEContent()
Returns the content of all RTE enabled text areas in the test.
const ANONYMIZE_FREEACCESS
saveQuestionsToDb()
Saves the survey questions to the database.
modifyQuestionblock($questionblock_id, $title, $show_questiontext, $show_blocktitle)
Modifies a question block.
updateOrder(array $a_order)
createNewAccessCode()
Returns a new, unused survey access code.
loadFromDb()
Loads a survey object from a database.
setStartTime($finished_id, $first_question)
getQuestionsTable($arrFilter)
Calculates the data for the output of the question browser.
sendNotificationMail($user_id, $anonymize_id, $appr_id)
saveUserSettings($usr_id, $key, $title, $value)
unfoldQuestionblocks($questionblocks)
Unfolds question blocks of a question pool.
deliverPDFfromFO($fo)
Delivers a PDF file from a XSL-FO string.
is360SurveyStarted($appr_id, $user_id, $anonymous_code=null)
removeSelectedSurveyResults($finished_ids)
Deletes the user data of a given array of survey participants.
setViewOwnResults($a_value)
& getSurveyQuestions($with_answers=false)
Returns the survey questions and questionblocks in an array.
getSurveyId()
Returns the survey database id.
setStartDate($start_date="")
Sets the start date of the survey.
removeQuestionFromBlock($question_id, $questionblock_id)
_getLastAccess($finished_id)
setInvitationAndMode($invitation=0, $invitation_mode=0)
Sets the invitation status and mode (a more performant solution if you change both)
update()
update object data
setEvaluationAccess($evaluation_access=self::EVALUATION_ACCESS_OFF)
Sets the learners evaluation access.
_isComplete($obj_id)
Returns 1, if a survey is complete for use.
getEndDate()
Gets the end date of the survey.
set360SelfEvaluation($a_value)
setTutorNotificationRecipients(array $a_value)
isComplete()
Returns 1, if a survey is complete for use.
getSurveyCodesForExport(array $a_codes=null, array $a_ids=null)
Returns a list of survey codes for file export.
setReminderTarget($a_value)
$activation_starting_time
set360RaterSent($a_appraisee_id, $a_user_id, $a_anonymous_id, $a_tstamp=null)
saveCompletionStatus()
Saves the completion status of the survey.
static getSurveySkippedValue()
getAllRelations($short_as_key=false)
Returns all available relations.
getNextPage($active_page_question_id, $direction)
Returns the next "page" of a running test.
ilObjSurvey($a_id=0, $a_call_by_reference=true)
Constructor @access public.
const EVALUATION_ACCESS_OFF
& getUserData($ids)
Returns a data of all users specified by id list.
createReference()
creates reference for object
static validateExternalRaterCode($a_ref_id, $a_code)
removeQuestion($question_id)
Remove a question from the survey.
bindSurveyCodeToUser($user_id, $code)
& getEvaluationByUser($questions, $active_id)
Calculates the evaluation data for a given user or anonymous id.
getStartDate()
Gets the start date of the survey.
& getVariables($question_id)
Returns all variables of a question.
getImportDirectory()
get import directory of survey
deleteSurveyRecord()
Deletes the survey from the database.
getSurveyCodesTableData(array $ids=null, $lang=null)
Fetches the data for the survey codes table.
getNotificationTargetUserIds($a_use_invited)
setReminderStatus($a_value)
startSurvey($user_id, $anonymous_id, $appraisee_id)
Starts the survey creating an entry in the database.
& getQuestionblockQuestions($questionblock_id)
Returns the question titles of all questions of a question block.
saveUserAccessCode($user_id, $access_code)
Saves a survey access code for a registered user to the database.
getTutorNotificationStatus()
removeQuestions($remove_questions, $remove_questionblocks)
Remove questions from the survey.
getQuestionblock($questionblock_id)
Returns the database row for a given question block.
read($a_force_db=false)
read object data from db into object
sentReminder(array $a_recipient_ids)
_getQuestionblock($questionblock_id)
Returns the database row for a given question block.
& getSurveyFinishedIds()
Get the finished id's of all survey participants.
getUserDataFromActiveId($active_id)
Returns the user information from an active_id (survey_finished.finished_id)
set360SelfAppraisee($a_value)
getLastActivePage($active_id)
Returns the question id of the last active page a user visited in a survey.
getIntroduction()
Gets the introduction text.
_getNrOfParticipants($survey_id)
Returns the number of participants for a survey.
setReminderEnd(ilDate $a_value=null)
setEndDateAndTime($end_date="", $end_time)
Sets the end date of the survey.
setEndDate($end_date="")
Sets the end date of the survey.
setTemplate($template_id)
addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag=TRUE, $add_mobs=TRUE, $attribs=NULL)
Creates an XML material tag from a plain text or xhtml text.
setReminderFrequency($a_value)
createSurveyCodes($nrOfCodes)
getAuthor()
Gets the authors name of the ilObjSurvey object.
& getExistingQuestions()
Gets the question id's of the questions which are already in the survey.
& getQuestionblockQuestionIds($questionblock_id)
Returns the question id's of all questions of a question block.
getShowQuestionTitles()
Gets the status of the display_question_titles attribute.
setAnonymize($a_anonymize)
set anonymize status
isSurveyStarted($user_id, $anonymize_id, $appr_id=0)
Checks if a user already started a survey.
addConstraint($if_question_id, $relation, $value, $conjunction)
Adds a constraint.
set360SelfRaters($a_value)
getAnonymousId($id)
Checks for an anomyous survey id in the database an returns the id.
loadWorkingData($question_id, $active_id)
Gets the working data of question from the database.
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
isAppraiseeClosed($a_user_id)
addConstraintToQuestion($to_question_id, $constraint_id)
Adds a constraint to a question.
set360SkillService($a_val)
Set skill service.
createExportDirectory()
creates data directory for export files (data_dir/svy_data/svy_<id>/export, depending on data directo...
isOnline()
Gets the survey status.
setPage($finished_id, $page_id)
Sets the number of the active survey page.
saveAuthorToMetadata($a_author="")
Saves an authors name into the lifecycle metadata if no lifecycle metadata exists This will only be c...
get360SkillService()
Get skill service.
canExportSurveyCode()
Checks if the survey code can be exported with the survey evaluation.
importObject($file_info, $svy_qpl_id)
Imports a survey from XML into the ILIAS database.
isPluginActive($a_pname)
Checks whether or not a question plugin with a given name is active.
inviteUser($user_id)
Invites a user to a survey.
const QUESTIONTITLES_HIDDEN
static _getUserData($a_internalids)
return user data for given user ids
static _dropDesktopItem($a_usr_id, $a_item_id, $a_type)
drop an item from user's personal desktop
_lookupLogin($a_user_id)
lookup login
_lookupFullname($a_user_id)
Lookup Full Name.
static _lookupName($a_user_id)
lookup user name
_lookupEmail($a_user_id)
Lookup email.
static _addDesktopItem($a_usr_id, $a_item_id, $a_type, $a_par="")
add an item to user's personal desktop
Class ilObjectActivation.
const TIMINGS_DEACTIVATED
setTimingType($a_type)
Set timing type.
static getItem($a_ref_id)
Get item data.
Class ilObject Basic functions for all objects.
getType()
get object type @access public
getOwner()
get object owner
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
deleteMetaData()
delete meta data entry
static _lookupDescription($a_id)
lookup object description
updateMetaData()
update meta data entry
getRefId()
get reference id @access public
getDescription()
get object description
cloneMetaData($target_obj)
Copy meta data.
getId()
get object id @access public
getTitle()
get object title @access public
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
_cleanupMediaObjectUsage($a_text, $a_usage_type, $a_usage_id)
synchronises appearances of media objects in $a_text with media object usage table
static factory($a_package)
Create an XML_RPC2 client instance.
Settings template application class.
Skill management settings.
Skill/Competence handling in surveys.
Wrapper classes for system notifications.
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true)
Default behaviour is:
static is_email($a_email)
This preg-based function checks whether an e-mail address is formally valid.
static getDataDir()
get data directory (outside webspace)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static prepareTextareaOutput($txt_output, $prepare_for_latex_output=FALSE, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free,...
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static _getObjectsByOperations($a_obj_type, $a_operation, $a_usr_id=0, $limit=0)
Get all objects of a specific type and check access This function is not recursive,...
static ilTempnam()
Create a temporary file in an ILIAS writable directory.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
xmlHeader()
Writes xml header @access public.
redirection script todo: (a better solution should control the processing via a xml file)