5use \ILIAS\Survey\Participants;
 
  212    public function __construct($a_id = 0, $a_call_by_reference = 
true)
 
  216        $this->
user = $DIC->user();
 
  217        $this->lng = 
$DIC->language();
 
  218        $this->db = 
$DIC->database();
 
  219        $this->access = 
$DIC->access();
 
  220        $this->plugin_admin = 
$DIC[
"ilPluginAdmin"];
 
  221        $this->tree = 
$DIC->repositoryTree();
 
  226        $this->survey_id = -1;
 
  227        $this->introduction = 
"";
 
  228        $this->outro = 
$lng->txt(
"survey_finished");
 
  229        $this->author = 
$ilUser->getFullname();
 
  231        $this->questions = array();
 
  234        $this->surveyCodeSecurity = 
true;
 
  235        $this->template_id = 
null;
 
  236        $this->pool_usage = 
true;
 
  249    public function create($a_upload = 
false)
 
  266        parent::createMetaData();
 
  276    public function update($a_upload = 
false)
 
  282        if (!parent::update()) {
 
  293        $result = parent::createReference();
 
  316        array_push($this->questions, $question_id);
 
  325    public function delete()
 
  331            foreach ($this->questions as $question_id) {
 
  339        $remove = parent::delete();
 
  357        $affectedRows = 
$ilDB->manipulateF(
 
  358            "DELETE FROM svy_svy WHERE survey_id = %s",
 
  364            "SELECT questionblock_fi FROM svy_qblk_qst WHERE survey_fi = %s",
 
  368        $questionblocks = array();
 
  370            array_push($questionblocks, $row[
"questionblock_fi"]);
 
  372        if (count($questionblocks)) {
 
  373            $affectedRows = 
$ilDB->manipulate(
"DELETE FROM svy_qblk WHERE " . 
$ilDB->in(
'questionblock_id', $questionblocks, 
false, 
'integer'));
 
  375        $affectedRows = 
$ilDB->manipulateF(
 
  376            "DELETE FROM svy_qblk_qst WHERE survey_fi = %s",
 
  382        $affectedRows = 
$ilDB->manipulateF(
 
  383            "DELETE FROM svy_anonymous WHERE survey_fi = %s",
 
  390        $directory = $svy_data_dir . 
"/svy_" . $this->
getId();
 
  391        if (is_dir($directory)) {
 
  400        foreach (
$mobs as $mob) {
 
  418            "SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
 
  422        $active_array = array();
 
  424            array_push($active_array, $row[
"finished_id"]);
 
  427        $affectedRows = 
$ilDB->manipulateF(
 
  428            "DELETE FROM svy_finished WHERE survey_fi = %s",
 
  433        foreach ($active_array as $active_fi) {
 
  434            $affectedRows = 
$ilDB->manipulateF(
 
  435                "DELETE FROM svy_answer WHERE active_fi = %s",
 
  439            $affectedRows = 
$ilDB->manipulateF(
 
  440                "DELETE FROM svy_times WHERE finished_fi = %s",
 
  448            $lp_obj->resetLPDataForCompleteObject();
 
  463        foreach ($finished_ids as $finished_id) {
 
  465                "SELECT finished_id, user_fi FROM svy_finished WHERE finished_id = %s",
 
  471            if ($row[
"user_fi"]) {
 
  472                $user_ids[] = (int) $row[
"user_fi"];
 
  475            $affectedRows = 
$ilDB->manipulateF(
 
  476                "DELETE FROM svy_answer WHERE active_fi = %s",
 
  478                array($row[
"finished_id"])
 
  481            $affectedRows = 
$ilDB->manipulateF(
 
  482                "DELETE FROM svy_finished WHERE finished_id = %s",
 
  487            $affectedRows = 
$ilDB->manipulateF(
 
  488                "DELETE FROM svy_times WHERE finished_fi = %s",
 
  490                array($row[
"finished_id"])
 
  494        if (
sizeof($user_ids)) {
 
  496            $lp_obj->resetLPDataForUserIds($user_ids);
 
  500    public function &
getSurveyParticipants($finished_ids = 
null, $force_non_anonymous = 
false, $include_invites = 
false)
 
  504        $sql = 
"SELECT * FROM svy_finished" .
 
  507            $sql .= 
" AND " . 
$ilDB->in(
"finished_id", $finished_ids, 
"", 
"integer");
 
  511        $participants = array();
 
  515                $userdata[
"finished"] = (bool) $row[
"state"];
 
  516                $userdata[
"finished_tstamp"] = $row[
"tstamp"];
 
  517                $participants[$userdata[
"sortname"] . $userdata[
"active_id"]] = $userdata;
 
  520        $participant_ids = array_column($participants, 
"usr_id");
 
  521        if ($include_invites) {
 
  522            foreach ($this->invitation_manager->getAllForSurvey($this->getSurveyId()) as $usr_id) {
 
  523                if (!in_array($usr_id, $participant_ids)) {
 
  525                    $participants[
$name[
"lastname"] . 
"," . 
$name[
"firstname"] . $usr_id] = [
 
  527                        "sortname" => 
$name[
"lastname"] . 
"," . 
$name[
"firstname"],
 
  528                        "fistname" => 
$name[
"firstname"],
 
  529                        "lastname" => 
$name[
"lastname"],
 
  530                        "login" => 
$name[
"login"],
 
  534                        "finished_tstamp" => 0,
 
  541        return $participants;
 
  552        if (($this->
getTitle()) and (count($this->questions))) {
 
  573            $affectedRows = 
$ilDB->manipulateF(
 
  574                "UPDATE svy_svy SET complete = %s, tstamp = %s WHERE survey_id = %s",
 
  575                array(
'text',
'integer',
'integer'),
 
  593        $question_gui = $this->
getQuestionGUI($questiontype, $question_id);
 
  596        if ($this->
getId() == $question_gui->object->getObjId() && !$a_force) {
 
  600        $duplicate_id = $question_gui->object->duplicate(
true, 
"", 
"", 
"", $this->
getId());
 
  601        return $duplicate_id;
 
  613        $this->svy_log->debug(
"insert question, id:" . $question_id);
 
  616            $this->svy_log->debug(
"question is not complete");
 
  622                "SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
 
  626            $sequence = 
$result->numRows();
 
  628            $this->svy_log->debug(
"duplicate, id: " . $question_id . 
", duplicate id: " . $duplicate_id);
 
  635            $next_id = 
$ilDB->nextId(
'svy_svy_qst');
 
  636            $affectedRows = 
$ilDB->manipulateF(
 
  637                "INSERT INTO svy_svy_qst (survey_question_id, survey_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
 
  638                array(
'integer', 
'integer', 
'integer', 
'integer', 
'integer'),
 
  639                array($next_id, $this->
getSurveyId(), $duplicate_id, $sequence, time())
 
  642            $this->svy_log->debug(
"added entry to svy_svy_qst, id: " . $next_id . 
", question id: " . $duplicate_id . 
", sequence: " . $sequence);
 
  661        $set = 
$ilDB->query(
"SELECT * FROM svy_svy_qst " .
 
  662            " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
  663            " AND question_fi = " . 
$ilDB->quote($a_question_fi, 
"integer"));
 
  664        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  681            "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;
 
  697            $show_questiontext = $row[
"show_questiontext"];
 
  698            $show_blocktitle = $row[
"show_blocktitle"];
 
  707        $next_id = 
$ilDB->nextId(
'svy_settings');
 
  708        $affectedRows = 
$ilDB->insert(
"svy_settings", array(
 
  709            "settings_id" => array(
"integer", $next_id),
 
  710            "usr_id" => array(
"integer", $usr_id),
 
  711            "keyword" => array(
"text", $key),
 
  712            "title" => array(
"text", 
$title),
 
  713            "value" => array(
"clob", $value)
 
  721        $affectedRows = 
$ilDB->manipulateF(
 
  722            "DELETE FROM svy_settings WHERE settings_id = %s",
 
  726        return $affectedRows;
 
  734            "SELECT * FROM svy_settings WHERE usr_id = %s AND keyword = %s",
 
  735            array(
'integer', 
'text'),
 
  741                $found[$row[
'settings_id']] = $row;
 
  758        if (is_object($rmd_start)) {
 
  762        if (is_object($rmd_end)) {
 
  767            $next_id = 
$ilDB->nextId(
'svy_svy');
 
  768            $affectedRows = 
$ilDB->insert(
"svy_svy", array(
 
  769                "survey_id" => array(
"integer", $next_id),
 
  770                "obj_fi" => array(
"integer", $this->
getId()),
 
  771                "author" => array(
"text", $this->
getAuthor()),
 
  775                "enddate" => array(
"text", $this->
getEndDate()),
 
  777                "complete" => array(
"text", $this->
isComplete()),
 
  778                "created" => array(
"integer", time()),
 
  784                "tstamp" => array(
"integer", time()),
 
  785                "template_id" => array(
"integer", $this->
getTemplate()),
 
  786                "pool_usage" => array(
"integer", $this->
getPoolUsage()),
 
  788                "mode" => array(
"integer", $this->
getMode()),
 
  793                "mode_360_results" => array(
"integer", $this->
get360Results()),
 
  795                "mode_skill_service" => array(
"integer", (
int) $this->
getSkillService()),
 
  800                "reminder_start" => array(
"datetime", $rmd_start),
 
  801                "reminder_end" => array(
"datetime", $rmd_end),
 
  819            $affectedRows = 
$ilDB->update(
"svy_svy", array(
 
  820                "author" => array(
"text", $this->
getAuthor()),
 
  824                "enddate" => array(
"text", $this->
getEndDate()),
 
  826                "complete" => array(
"text", $this->
isComplete()),
 
  832                "tstamp" => array(
"integer", time()),
 
  833                "template_id" => array(
"integer", $this->
getTemplate()),
 
  834                "pool_usage" => array(
"integer", $this->
getPoolUsage()),
 
  836                "mode" => array(
"integer", $this->
getMode()),
 
  841                "mode_360_results" => array(
"integer", $this->
get360Results()),
 
  843                "mode_skill_service" => array(
"integer", (
int) $this->
getSkillService()),
 
  848                "reminder_start" => array(
"datetime", $rmd_start),
 
  849                "reminder_end" => array(
"datetime", $rmd_end),
 
  865            "survey_id" => array(
"integer", $this->
getSurveyId())
 
  887            $item->update($this->ref_id);
 
  901        $this->svy_log->debug(
"save questions");
 
  904        $old_questions = array();
 
  906            "SELECT survey_question_id,question_fi,sequence" .
 
  907            " FROM svy_svy_qst WHERE survey_fi = %s",
 
  912            $old_questions[$row[
"question_fi"]] = $row;         
 
  916        $insert = $update = $delete = array();
 
  917        foreach ($this->questions as $seq => $fi) {
 
  918            if (!array_key_exists($fi, $old_questions)) {               
 
  920            } elseif ($old_questions[$fi][
"sequence"] != $seq) {                                
 
  921                $update[$fi] = $old_questions[$fi][
"survey_question_id"];
 
  924            unset($old_questions[$fi]);                                         
 
  928        if (
sizeof($old_questions)) {
 
  930            foreach ($old_questions as $fi => $old) {
 
  931                $del_ids[] = $old[
"survey_question_id"];
 
  933            $ilDB->manipulate($q = 
"DELETE FROM svy_svy_qst" .
 
  934                " WHERE " . 
$ilDB->in(
"survey_question_id", $del_ids, 
"", 
"integer"));
 
  935            $this->svy_log->debug(
"delete: " . $q);
 
  937        unset($old_questions);
 
  940        foreach ($this->questions as $seq => $fi) {
 
  941            if (in_array($fi, $insert)) {
 
  944                    $next_id = 
$ilDB->nextId(
'svy_svy_qst');
 
  946                        "INSERT INTO svy_svy_qst" .
 
  947                        " (survey_question_id, survey_fi, question_fi, heading, sequence, tstamp)" .
 
  948                        " VALUES (%s, %s, %s, %s, %s, %s)",
 
  949                        array(
'integer', 
'integer', 
'integer', 
'text', 
'integer', 
'integer'),
 
  950                        array($next_id, $this->
getSurveyId(), $fi, 
null, $seq, time())
 
  952                    $this->svy_log->debug(
"insert svy_svy_qst, id:" . $next_id . 
", fi: " . $fi . 
", seq:" . $seq);
 
  954            } elseif (array_key_exists($fi, $update)) {
 
  955                $ilDB->manipulate(
"UPDATE svy_svy_qst" .
 
  956                    " SET sequence = " . 
$ilDB->quote($seq, 
"integer") .
 
  957                    ", tstamp = " . 
$ilDB->quote(time(), 
"integer") .
 
  958                    " WHERE survey_question_id = " . 
$ilDB->quote($update[$fi], 
"integer"));
 
  959                $this->svy_log->debug(
"update svy_svy_qst, id:" . $update[$fi] . 
", fi: " . $fi . 
", seq:" . $seq);
 
  975            "SELECT anonymous_id FROM svy_finished WHERE anonymous_id = %s",
 
  981            return $row[
"anonymous_id"];
 
 1008        if ($question_id < 1) {
 
 1012            "SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND " .
 
 1013            "svy_question.questiontype_fi = svy_qtype.questiontype_id",
 
 1017        if (
$result->numRows() == 1) {
 
 1019            return $data[
"type_tag"];
 
 1041        switch ($a_anonymize) {
 
 1046                $this->anonymize = $a_anonymize;
 
 1061        return ($this->anonymize) ? $this->anonymize : 0;
 
 1070        $this->calculate_sum_score = $a_val;
 
 1089        return ($this->
getAnonymize() == self::ANONYMIZE_OFF ||
 
 1113            "SELECT * FROM svy_svy WHERE obj_fi = %s",
 
 1115            array($this->
getId())
 
 1117        if (
$result->numRows() == 1) {
 
 1122            if (strcmp(
$data[
"outro"], 
"survey_finished") == 0) {
 
 1123                $this->
setOutro($this->lng->txt(
"survey_finished"));
 
 1172        if ($this->ref_id) {
 
 1174            switch ($activation[
"timing_type"]) {
 
 1198        $this->questions = array();
 
 1200            "SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
 
 1205            $this->questions[
$data[
"sequence"]] = 
$data[
"question_fi"];
 
 1220            "SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
 
 1227        $to_delete_ids = array();
 
 1229            if (in_array(
$data[
"question_fi"], $fis)) {         
 
 1230                $to_delete_ids[] = 
$data[
"survey_question_id"];
 
 1232                $fis[] = 
$data[
"question_fi"];
 
 1237        if (count($to_delete_ids) > 0) {
 
 1238            $ilDB->manipulate($q = 
"DELETE FROM svy_svy_qst" .
 
 1239                " WHERE " . 
$ilDB->in(
"survey_question_id", $to_delete_ids, 
false, 
"integer") .
 
 1240                " AND survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer"));
 
 1241            $this->svy_log->debug(
"delete: " . $q);
 
 1243            $ilDB->manipulate($q = 
"DELETE FROM svy_qblk_qst " .
 
 1244                " WHERE " . 
$ilDB->in(
"question_fi", $fis, 
true, 
"integer") .
 
 1245                " AND survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer"));
 
 1246            $this->svy_log->debug(
"delete: " . $q);
 
 1250        $set = 
$ilDB->query(
"SELECT * FROM svy_svy_qst " .
 
 1251            " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") . 
" ORDER BY sequence");
 
 1253        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
 1255                $q = 
"UPDATE svy_svy_qst SET " .
 
 1256                " sequence = " . 
$ilDB->quote($seq++, 
"integer") .
 
 1257                " WHERE survey_question_id = " . 
$ilDB->quote($rec[
"survey_question_id"], 
"integer")
 
 1259            $this->svy_log->debug(
"update: " . $q);
 
 1288        $md_life = &$md->getLifecycle();
 
 1290            if (strlen($a_author) == 0) {
 
 1292                $a_author = 
$ilUser->getFullname();
 
 1295            $md_life = &$md->addLifecycle();
 
 1297            $con = &$md_life->addContribute();
 
 1298            $con->setRole(
"Author");
 
 1300            $ent = &$con->addEntity();
 
 1301            $ent->setEntity($a_author);
 
 1317        $md_life = &$md->getLifecycle();
 
 1319            $ids = &$md_life->getContributeIds();
 
 1320            foreach ($ids as 
$id) {
 
 1321                $md_cont = &$md_life->getContribute(
$id);
 
 1322                if (strcmp($md_cont->getRole(), 
"Author") == 0) {
 
 1323                    $entids = &$md_cont->getEntityIds();
 
 1324                    foreach ($entids as $entid) {
 
 1325                        $md_ent = &$md_cont->getEntity($entid);
 
 1326                        array_push(
$author, $md_ent->getEntity());
 
 1342        return ($this->display_question_titles) ? 1 : 0;
 
 1353        $this->display_question_titles = ($a_show) ? 1 : 0;
 
 1364        $this->display_question_titles = 1;
 
 1375        $this->display_question_titles = 0;
 
 1410        return (strlen($this->start_date)) ? $this->start_date : 
null;
 
 1425        $edit_settings = 
false;
 
 1427        if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartDate(), $matches)) {
 
 1428            $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 1430            if ($now < $epoch_time) {
 
 1431                array_push(
$messages, $this->lng->txt(
'start_date_not_reached') . 
' (' .
 
 1434                $edit_settings = 
true;
 
 1438        if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndDate(), $matches)) {
 
 1439            $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 1441            if ($now > $epoch_time) {
 
 1442                array_push(
$messages, $this->lng->txt(
'end_date_reached') . 
' (' .
 
 1445                $edit_settings = 
true;
 
 1451            array_push(
$messages, $this->lng->txt(
"survey_is_offline"));
 
 1453            $edit_settings = 
true;
 
 1456        if (!$a_no_rbac && !$ilAccess->checkAccess(
"read", 
"", $this->ref_id)) {
 
 1457            array_push(
$messages, $this->lng->txt(
"cannot_participate_survey"));
 
 1476            "edit_settings" => $edit_settings
 
 1508        if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/", 
$start_date, $matches)) {
 
 1513        if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $start_time, $matches)) {
 
 1518        $this->start_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m, 
$d, $h, 
$i, $s);
 
 1530        return (strlen($this->end_date)) ? $this->end_date : 
null;
 
 1561        if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/", 
$end_date, $matches)) {
 
 1566        if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $end_time, $matches)) {
 
 1571        $this->end_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m, 
$d, $h, 
$i, $s);
 
 1600        $this->activation_visibility = (bool) $a_value;
 
 1610        return (
bool) $this->activation_limited;
 
 1615        $this->activation_limited = (bool) $a_value;
 
 1627        return (strlen($this->introduction)) ? $this->introduction : 
null;
 
 1639        return (strlen($this->outro)) ? $this->outro : 
null;
 
 1651        $existing_questions = array();
 
 1653            "SELECT svy_question.original_id FROM svy_question, svy_svy_qst WHERE " .
 
 1654            "svy_svy_qst.survey_fi = %s AND svy_svy_qst.question_fi = svy_question.question_id",
 
 1659            if (
$data[
"original_id"]) {
 
 1660                array_push($existing_questions, 
$data[
"original_id"]);
 
 1663        return $existing_questions;
 
 1687        $this->svy_log->debug(
"move_questions: " . print_r($move_questions, 
true) .
 
 1688            ", target_index: " . $target_index . 
", insert_mode: " . $insert_mode);
 
 1689        $array_pos = array_search($target_index, $this->questions);
 
 1690        if ($insert_mode == 0) {
 
 1691            $part1 = array_slice($this->questions, 0, $array_pos);
 
 1692            $part2 = array_slice($this->questions, $array_pos);
 
 1693        } elseif ($insert_mode == 1) {
 
 1694            $part1 = array_slice($this->questions, 0, $array_pos + 1);
 
 1695            $part2 = array_slice($this->questions, $array_pos + 1);
 
 1698        foreach ($move_questions as $question_id) {
 
 1699            if (!(array_search($question_id, $part1) === 
false)) {
 
 1700                unset($part1[array_search($question_id, $part1)]);
 
 1703            if (!(array_search($question_id, $part2) === 
false)) {
 
 1704                unset($part2[array_search($question_id, $part2)]);
 
 1709        if ($found != count($move_questions)) {
 
 1712        $part1 = array_values($part1);
 
 1713        $part2 = array_values($part2);
 
 1714        $this->questions = array_values(array_merge($part1, $move_questions, $part2));
 
 1715        foreach ($move_questions as $question_id) {
 
 1717            foreach ($constraints as $idx => $constraint) {
 
 1718                foreach ($part2 as $next_question_id) {
 
 1719                    if ($constraint[
"question"] == $next_question_id) {
 
 1738        #20610 if no question found, do nothing. 
 1740            $question->delete($question_id);
 
 1755            "SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
 
 1756            array(
'integer',
'integer'),
 
 1760            $remove_constraints = array();
 
 1762                array_push($remove_constraints, $row[
"constraint_fi"]);
 
 1764            $affectedRows = 
$ilDB->manipulateF(
 
 1765                "DELETE FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
 
 1766                array(
'integer',
'integer'),
 
 1769            foreach ($remove_constraints as $key => $constraint_id) {
 
 1770                $affectedRows = 
$ilDB->manipulateF(
 
 1771                    "DELETE FROM svy_constraint WHERE constraint_id = %s",
 
 1773                    array($constraint_id)
 
 1790        $block_sizes = array();
 
 1792            if (in_array($question_id, $remove_questions) or in_array(
$data[
"questionblock_id"], $remove_questionblocks)) {
 
 1793                unset($this->questions[array_search($question_id, $this->questions)]);
 
 1795            } elseif (
$data[
"questionblock_id"]) {
 
 1796                $block_sizes[
$data[
"questionblock_id"]]++;
 
 1801        foreach ($block_sizes as $block_id => 
$size) {
 
 1803                $remove_questionblocks[] = $block_id;
 
 1807        foreach (array_unique($remove_questionblocks) as $questionblock_id) {
 
 1808            $affectedRows = 
$ilDB->manipulateF(
 
 1809                "DELETE FROM svy_qblk WHERE questionblock_id = %s",
 
 1811                array($questionblock_id)
 
 1813            $affectedRows = 
$ilDB->manipulateF(
 
 1814                "DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
 
 1815                array(
'integer',
'integer'),
 
 1820        $this->questions = array_values($this->questions);
 
 1833        foreach ($questionblocks as 
$index) {
 
 1834            $affectedRows = 
$ilDB->manipulateF(
 
 1835                "DELETE FROM svy_qblk WHERE questionblock_id = %s",
 
 1839            $affectedRows = 
$ilDB->manipulateF(
 
 1840                "DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
 
 1841                array(
'integer',
'integer'),
 
 1851        $affectedRows = 
$ilDB->manipulateF(
 
 1852            "DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s AND question_fi = %s",
 
 1853            array(
'integer',
'integer',
'integer'),
 
 1854            array($questionblock_id, $this->
getSurveyId(), $question_id)
 
 1864            $next_id = 
$ilDB->nextId(
'svy_qblk_qst');
 
 1865            $affectedRows = 
$ilDB->manipulateF(
 
 1866                "INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
 
 1867                "question_fi) VALUES (%s, %s, %s, %s)",
 
 1868                array(
'integer', 
'integer', 
'integer', 
'integer'),
 
 1869                array($next_id, $this->
getSurveyId(), $questionblock_id, $question_id)
 
 1888        $set = 
$ilDB->query(
"SELECT * FROM svy_qblk_qst " .
 
 1889            " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 1890            " AND question_fi = " . 
$ilDB->quote($a_question_fi, 
"integer"));
 
 1891        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
 1909            "SELECT svy_question.title, svy_qblk_qst.question_fi, svy_qblk_qst.survey_fi FROM " .
 
 1910            "svy_qblk, svy_qblk_qst, svy_question WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND " .
 
 1911            "svy_question.question_id = svy_qblk_qst.question_fi AND svy_qblk.questionblock_id = %s",
 
 1913            array($questionblock_id)
 
 1917            $titles[$row[
"question_fi"]] = $row[
"title"];
 
 1921            "SELECT question_fi, sequence FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
 
 1925        $resultarray = array();
 
 1928            if (array_key_exists($row[
"question_fi"], $titles)) {
 
 1929                $resultarray[$counter++] = $titles[$row[
"question_fi"]];
 
 1932        return $resultarray;
 
 1947            "SELECT a.question_fi FROM svy_qblk_qst a JOIN svy_svy_qst b ON (a.question_fi = b.question_fi) " .
 
 1948            " WHERE a.questionblock_fi = %s ORDER BY b.sequence",
 
 1950            array($questionblock_id)
 
 1955                if (!in_array(
$data[
'question_fi'], $ids)) {            
 
 1956                    array_push($ids, 
$data[
'question_fi']);
 
 1977            "SELECT * FROM svy_qblk WHERE questionblock_id = %s",
 
 1979            array($questionblock_id)
 
 1998        $next_id = 
$ilDB->nextId(
'svy_qblk');
 
 2000            "INSERT INTO svy_qblk (questionblock_id, title, show_questiontext," .
 
 2001            " show_blocktitle, owner_fi, tstamp, compress_view) " .
 
 2002            "VALUES (%s, %s, %s, %s, %s, %s, %s)",
 
 2003            array(
'integer',
'text',
'integer',
'integer',
'integer',
'integer',
'integer'),
 
 2004            array($next_id, 
$title, $show_questiontext, $show_blocktitle, 
$owner, time(),$compress_view)
 
 2026        $next_id = 
$ilDB->nextId(
'svy_qblk');
 
 2027        $affectedRows = 
$ilDB->manipulateF(
 
 2028            "INSERT INTO svy_qblk (questionblock_id, title, show_questiontext," .
 
 2029            " show_blocktitle, owner_fi, tstamp, compress_view) VALUES (%s, %s, %s, %s, %s, %s, %s)",
 
 2030            array(
'integer',
'text',
'text',
'text',
'integer',
'integer',
'integer'),
 
 2031            array($next_id, 
$title, $show_questiontext, $show_blocktitle, 
$ilUser->getId(), time(), $compress_view)
 
 2033        if ($affectedRows) {
 
 2034            $questionblock_id = $next_id;
 
 2037                    $next_id = 
$ilDB->nextId(
'svy_qblk_qst');   
 
 2038                    $affectedRows = 
$ilDB->manipulateF(
 
 2039                        "INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
 
 2040                        "question_fi) VALUES (%s, %s, %s, %s)",
 
 2041                        array(
'integer', 
'integer', 
'integer', 
'integer'),
 
 2060        $affectedRows = 
$ilDB->manipulateF(
 
 2061            "UPDATE svy_qblk SET title = %s, show_questiontext = %s," .
 
 2062            " show_blocktitle = %s, compress_view = %s WHERE questionblock_id = %s",
 
 2063            array(
'text',
'text',
'text',
'integer', 
'integer'),
 
 2064            array(
$title, $show_questiontext, $show_blocktitle, $compress_view, $questionblock_id)
 
 2078            "SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
 
 2079            array(
'integer',
'integer'),
 
 2082        $constraints = array();
 
 2084            array_push($constraints, $row[
"constraint_fi"]);
 
 2086        foreach ($constraints as $constraint_id) {
 
 2101        $affectedRows = 
$ilDB->manipulateF(
 
 2102            "DELETE FROM svy_constraint WHERE constraint_id = %s",
 
 2104            array($constraint_id)
 
 2106        $affectedRows = 
$ilDB->manipulateF(
 
 2107            "DELETE FROM svy_qst_constraint WHERE constraint_fi = %s",
 
 2109            array($constraint_id)
 
 2122        $all_questions = array();
 
 2124            "SELECT svy_qtype.type_tag, svy_qtype.plugin, svy_question.question_id, " .
 
 2125            "svy_svy_qst.heading FROM svy_qtype, svy_question, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
 
 2126            "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
 
 2127            "ORDER BY svy_svy_qst.sequence",
 
 2133            if ($row[
"plugin"]) {
 
 2140                $questionrow = $question->getQuestionDataArray($row[
"question_id"]);
 
 2141                foreach ($row as $key => $value) {
 
 2142                    $questionrow[$key] = $value;
 
 2144                $all_questions[$row[
"question_id"]] = $questionrow;
 
 2145                $all_questions[$row[
"question_id"]][
"usableForPrecondition"] = $question->usableForPrecondition();
 
 2146                $all_questions[$row[
"question_id"]][
"availableRelations"] = $question->getAvailableRelations();
 
 2150        $questionblocks = array();
 
 2151        if (count($all_questions)) {
 
 2153                "SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst WHERE " .
 
 2154                "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
 
 2155                "AND " . 
$ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions), 
false, 
'integer'),
 
 2160                $questionblocks[$row[
'question_fi']] = $row;
 
 2164        foreach ($all_questions as $question_id => $row) {
 
 2166            if (isset($questionblocks[$question_id])) {
 
 2167                $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
 
 2168                $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
 
 2169                $all_questions[$question_id][
"constraints"] = $constraints;
 
 2171                $all_questions[$question_id][
"questionblock_title"] = 
"";
 
 2172                $all_questions[$question_id][
"questionblock_id"] = 
"";
 
 2173                $all_questions[$question_id][
"constraints"] = $constraints;
 
 2175            if ($with_answers) {
 
 2178                    "SELECT svy_variable.*, svy_category.title FROM svy_variable, svy_category " .
 
 2179                    "WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id " .
 
 2180                    "ORDER BY sequence ASC",
 
 2186                        array_push($answers, 
$data[
"title"]);
 
 2189                $all_questions[$question_id][
"answers"] = $answers;
 
 2192        return $all_questions;
 
 2205            "SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
 
 2211                if (!array_key_exists($row[
"question_fi"], $obligatory_questions)) {
 
 2212                    $obligatory_questions[$row[
"question_fi"]] = 0;
 
 2218        foreach ($obligatory_questions as $question_fi => $obligatory) {
 
 2220            $ilDB->manipulate(
"UPDATE svy_question" .
 
 2221                " SET obligatory = " . 
$ilDB->quote($obligatory, 
"integer") .
 
 2222                " WHERE question_id = " . 
$ilDB->quote($question_fi, 
"integer"));
 
 2235        $all_questions = array();
 
 2237            "SELECT svy_question.*, svy_qtype.type_tag, svy_svy_qst.heading FROM " .
 
 2238            "svy_question, svy_qtype, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
 
 2239            "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
 
 2240            "ORDER BY svy_svy_qst.sequence",
 
 2245            $all_questions[$row[
"question_id"]] = $row;
 
 2248        $questionblocks = array();
 
 2249        if (count($all_questions)) {
 
 2251                "SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst " .
 
 2252                "WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
 
 2253                "AND " . 
$ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions), 
false, 
'integer'),
 
 2258                $questionblocks[$row[
'question_fi']] = $row;
 
 2262        $all_pages = array();
 
 2265        foreach ($all_questions as $question_id => $row) {
 
 2266            $constraints = array();
 
 2267            if (isset($questionblocks[$question_id])) {
 
 2268                if (!$currentblock or ($currentblock != $questionblocks[$question_id][
'questionblock_id'])) {
 
 2271                $all_questions[$question_id][
'page'] = $pageindex;
 
 2272                $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
 
 2273                $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
 
 2274                $all_questions[$question_id][
"questionblock_show_questiontext"] = $questionblocks[$question_id][
'show_questiontext'];
 
 2275                $all_questions[$question_id][
"questionblock_show_blocktitle"] = $questionblocks[$question_id][
'show_blocktitle'];
 
 2276                $all_questions[$question_id][
"questionblock_compress_view"] = $questionblocks[$question_id][
'compress_view'];
 
 2277                $currentblock = $questionblocks[$question_id][
'questionblock_id'];
 
 2279                $all_questions[$question_id][
"constraints"] = $constraints;
 
 2282                $all_questions[$question_id][
'page'] = $pageindex;
 
 2283                $all_questions[$question_id][
"questionblock_title"] = 
"";
 
 2284                $all_questions[$question_id][
"questionblock_id"] = 
"";
 
 2285                $all_questions[$question_id][
"questionblock_show_questiontext"] = 1;
 
 2286                $all_questions[$question_id][
"questionblock_show_blocktitle"] = 1;
 
 2287                $all_questions[$question_id][
"questionblock_compress_view"] = 
false;
 
 2290                $all_questions[$question_id][
"constraints"] = $constraints;
 
 2292            if (!isset($all_pages[$pageindex])) {
 
 2293                $all_pages[$pageindex] = array();
 
 2295            array_push($all_pages[$pageindex], $all_questions[$question_id]);
 
 2298        $max = count($all_pages);
 
 2300        foreach ($all_pages as 
$index => $block) {
 
 2301            foreach ($block as $blockindex => $question) {
 
 2302                $all_pages[
$index][$blockindex][
"position"] = $counter / $max;
 
 2322        if (strcmp($active_page_question_id, 
"") == 0) {
 
 2325        foreach ($pages as $key => $question_array) {
 
 2326            foreach ($question_array as $question) {
 
 2327                if ($active_page_question_id == $question[
"question_id"]) {
 
 2332        if ($foundpage == -1) {
 
 2335            $foundpage += $direction;
 
 2336            if ($foundpage < 0) {
 
 2339            if ($foundpage >= count($pages)) {
 
 2342            return $pages[$foundpage];
 
 2366        $result_array = array();
 
 2368            "SELECT svy_constraint.*, svy_relation.*, svy_qst_constraint.question_fi ref_question_fi FROM svy_qst_constraint, svy_constraint, " .
 
 2369            "svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id AND " .
 
 2370            "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_constraint.constraint_id = %s",
 
 2390        $result_array = array();
 
 2392            "SELECT svy_constraint.*, svy_relation.* FROM svy_qst_constraint, svy_constraint, svy_relation " .
 
 2393            "WHERE svy_constraint.relation_fi = svy_relation.relation_id AND " .
 
 2394            "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.question_fi = %s " .
 
 2395            "AND svy_qst_constraint.survey_fi = %s",
 
 2396            array(
'integer',
'integer'),
 
 2402            $question = 
new $question_type();
 
 2403            $question->loadFromDb($row[
"question_fi"]);
 
 2404            $valueoutput = $question->getPreconditionValueOutput($row[
"value"]);
 
 2405            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));
 
 2407        return $result_array;
 
 2420        $result_array = array();
 
 2422            "SELECT svy_qst_constraint.question_fi as for_question, svy_constraint.*, svy_relation.* " .
 
 2423            "FROM svy_qst_constraint, svy_constraint, svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id " .
 
 2424            "AND svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.survey_fi = %s",
 
 2429            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']));
 
 2431        return $result_array;
 
 2444        $result_array = array();
 
 2446            "SELECT svy_variable.*, svy_category.title FROM svy_variable LEFT JOIN " .
 
 2447            "svy_category ON svy_variable.category_fi = svy_category.category_id WHERE svy_variable.question_fi = %s " .
 
 2448            "ORDER BY svy_variable.sequence",
 
 2453            $result_array[$row->sequence] = $row;
 
 2455        return $result_array;
 
 2470        $next_id = 
$ilDB->nextId(
'svy_constraint');
 
 2471        $affectedRows = 
$ilDB->manipulateF(
 
 2472            "INSERT INTO svy_constraint (constraint_id, question_fi, relation_fi, value, conjunction) VALUES " .
 
 2473            "(%s, %s, %s, %s, %s)",
 
 2474            array(
'integer',
'integer',
'integer',
'float', 
'integer'),
 
 2475            array($next_id, $if_question_id, $relation, $value, $conjunction)
 
 2477        if ($affectedRows) {
 
 2495        $next_id = 
$ilDB->nextId(
'svy_qst_constraint');
 
 2496        $affectedRows = 
$ilDB->manipulateF(
 
 2497            "INSERT INTO svy_qst_constraint (question_constraint_id, survey_fi, question_fi, " .
 
 2498            "constraint_fi) VALUES (%s, %s, %s, %s)",
 
 2499            array(
'integer',
'integer',
'integer',
'integer'),
 
 2500            array($next_id, $this->
getSurveyId(), $to_question_id, $constraint_id)
 
 2514    public function updateConstraint($precondition_id, $if_question_id, $relation, $value, $conjunction)
 
 2517        $affectedRows = 
$ilDB->manipulateF(
 
 2518            "UPDATE svy_constraint SET question_fi = %s, relation_fi = %s, value = %s, conjunction = %s " .
 
 2519            "WHERE constraint_id = %s",
 
 2520            array(
'integer',
'integer',
'float',
'integer',
'integer'),
 
 2521            array($if_question_id, $relation, $value, $conjunction, $precondition_id)
 
 2529            $affectedRows = 
$ilDB->manipulateF(
 
 2530                "UPDATE svy_constraint SET conjunction = %s " .
 
 2531                "WHERE constraint_id IN (SELECT constraint_fi FROM svy_qst_constraint WHERE svy_qst_constraint.question_fi = %s)",
 
 2532                array(
'integer',
'integer'),
 
 2533                array($conjunction, $question_id)
 
 2548        $custom_order = array(
"equal", 
"not_equal", 
"less", 
"less_or_equal", 
"more", 
"more_or_equal");
 
 2549        $custom_order = array_flip($custom_order);
 
 2551        $result_array = array();
 
 2554            if ($short_as_key) {
 
 2555                $result_array[$row[
"shortname"]] = array(
"short" => $row[
"shortname"], 
"long" => $row[
"longname"], 
"id" => $row[
"relation_id"], 
"order" => $custom_order[$row[
"longname"]]);
 
 2557                $result_array[$row[
"relation_id"]] = array(
"short" => $row[
"shortname"], 
"long" => $row[
"longname"], 
"order" => $custom_order[$row[
"longname"]]);
 
 2562        foreach ($result_array as $idx => $item) {
 
 2563            unset($result_array[$idx][
"order"]);
 
 2566        return $result_array;
 
 2583        $affectedRows = 
$ilDB->manipulateF(
 
 2584            "DELETE FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
 
 2585            array(
'integer',
'integer'),
 
 2586            array($question_id, $active_id)
 
 2601        $result_array = array();
 
 2603            "SELECT * FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
 
 2604            array(
'integer',
'integer'),
 
 2605            array($question_id, $active_id)
 
 2607        if (
$result->numRows() >= 1) {
 
 2609                array_push($result_array, $row);
 
 2611            return $result_array;
 
 2613            return $result_array;
 
 2627        if ($this->
getAnonymize() && (strlen($anonymous_id) == 0)) {
 
 2631        if (strcmp($user_id, 
"") == 0) {
 
 2636        $next_id = 
$ilDB->nextId(
'svy_finished');
 
 2637        $affectedRows = 
$ilDB->manipulateF(
 
 2638            "INSERT INTO svy_finished (finished_id, survey_fi, user_fi, anonymous_id, state, tstamp, appr_id) " .
 
 2639            "VALUES (%s, %s, %s, %s, %s, %s, %s)",
 
 2640            array(
'integer',
'integer',
'integer',
'text',
'text',
'integer',
'integer'),
 
 2641            array($next_id, $this->
getSurveyId(), $user_id, $anonymous_id, 0, time(), $appraisee_id)
 
 2657            "UPDATE svy_finished SET state = %s, tstamp = %s" .
 
 2658            " WHERE survey_fi = %s AND finished_id = %s",
 
 2659            array(
'text',
'integer',
'integer',
'integer'),
 
 2660            array(1, time(), $this->
getSurveyId(), $finished_id)
 
 2667            $sskill->writeAndAddSelfEvalSkills(
$user[
'usr_id']);
 
 2684        $affectedRows = 
$ilDB->manipulateF(
 
 2685            "UPDATE svy_finished SET lastpage = %s WHERE finished_id = %s",
 
 2686            array(
'integer',
'integer'),
 
 2687            array(($page_id) ? $page_id : 0, $finished_id)
 
 2699        $placeholders = array(
 
 2700            "FIRST_NAME" => 
"firstname",
 
 2701            "LAST_NAME" => 
"lastname",
 
 2704            "firstname" => 
"firstname" 
 2709        $recipients = preg_split(
'/,/', $this->mailaddresses);
 
 2710        foreach ($recipients as $recipient) {
 
 2713            $ntf->setLangModules(array(
"survey"));
 
 2715            $ntf->setSubjectLangId(
'finished_mail_subject');
 
 2718            if (trim($messagetext)) {
 
 2723                foreach ($placeholders as $key => $mapping) {
 
 2725                        $messagetext = str_replace(
'[' . $key . 
']', 
'', $messagetext);
 
 2727                        $messagetext = str_replace(
'[' . $key . 
']', trim(
$data[$mapping]), $messagetext);
 
 2730                $ntf->setIntroductionDirect($messagetext);
 
 2732                $ntf->setIntroductionLangId(
'survey_notification_finished_introduction');
 
 2737                $ntf->addAdditionalInfo(
 
 2738                    'survey_360_appraisee',
 
 2743            $active_id = $this->
getActiveID($a_user_id, $a_anonymize_id, $a_appr_id);
 
 2744            $ntf->addAdditionalInfo(
 
 2750            $ntf->setGotoLangId(
'survey_notification_tutor_link');
 
 2751            $ntf->setReasonLangId(
'survey_notification_finished_reason');
 
 2753            if (is_numeric($recipient)) {
 
 2754                $lng = $ntf->getUserLanguage($recipient);
 
 2755                $ntf->sendMail(array($recipient), 
null, 
null);
 
 2757                $recipient = trim($recipient);
 
 2759                if (empty($user_ids)) {
 
 2760                    $ntf->sendMail(array($recipient), 
null, 
null);
 
 2762                    foreach ($user_ids as $user_id) {
 
 2763                        $lng = $ntf->getUserLanguage($user_id);
 
 2764                        $ntf->sendMail(array($user_id), 
null, 
null);
 
 2776        $questioncounter = 1;
 
 2777        foreach (
$questions as $question_id => $question_data) {
 
 2778            $textresult .= $questioncounter++ . 
". " . $question_data[
"title"] . 
"\n";
 
 2779            $found = $userResults[$question_id][$active_id];
 
 2781            if (is_array($found)) {
 
 2782                $text = implode(
"\n", $found);
 
 2786            if (strlen($text) == 0) {
 
 2789            $text = str_replace(
"<br />", 
"\n", $text);
 
 2790            $textresult .= $text . 
"\n\n";
 
 2807        if ($anonymize_id) {
 
 2809                "SELECT * FROM svy_finished" .
 
 2810                " WHERE survey_fi = %s AND anonymous_id = %s AND appr_id = %s",
 
 2811                array(
'integer',
'text',
'integer'),
 
 2812                array($this->
getSurveyId(), $anonymize_id, $appr_id)
 
 2816                "SELECT * FROM svy_finished" .
 
 2817                " WHERE survey_fi = %s AND user_fi = %s AND appr_id = %s",
 
 2818                array(
'integer',
'integer',
'integer'),
 
 2822        if (
$result->numRows() == 0) {
 
 2829            return (
int) $row[
"state"];
 
 2847        if ($anonymize_id) {
 
 2849                "SELECT finished_id FROM svy_finished" .
 
 2850                " WHERE survey_fi = %s AND anonymous_id = %s AND appr_id = %s",
 
 2851                array(
'integer',
'text',
'integer'),
 
 2852                array($this->
getSurveyId(), $anonymize_id, $appr_id)
 
 2856                "SELECT finished_id FROM svy_finished" .
 
 2857                " WHERE survey_fi = %s AND user_fi = %s AND appr_id = %s",
 
 2858                array(
'integer',
'integer',
'integer'),
 
 2862        if (
$result->numRows() == 0) {
 
 2866            return $row[
"finished_id"];
 
 2881            "SELECT lastpage FROM svy_finished WHERE finished_id = %s",
 
 2885        if (
$result->numRows() == 0) {
 
 2889            return ($row[
"lastpage"]) ? $row[
"lastpage"] : 
'';
 
 2903        if (!is_array($working_data) || count($working_data) == 0) {
 
 2907        if ((count($working_data) == 1) and (strcmp($working_data[0][
"value"], 
"") == 0)) {
 
 2912        foreach ($working_data as 
$data) {
 
 2913            switch ($constraint_data[
"short"]) {
 
 2915                    if (
$data[
"value"] < $constraint_data[
"value"]) {
 
 2921                    if (
$data[
"value"] <= $constraint_data[
"value"]) {
 
 2927                    if (
$data[
"value"] == $constraint_data[
"value"]) {
 
 2933                    if (
$data[
"value"] <> $constraint_data[
"value"]) {
 
 2939                    if (
$data[
"value"] >= $constraint_data[
"value"]) {
 
 2945                    if (
$data[
"value"] > $constraint_data[
"value"]) {
 
 2955        return (
int) $found;
 
 2965            "SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
 
 2985            "SELECT * FROM svy_finished WHERE survey_fi = %s",
 
 2991                array_push($users, $row[
"finished_id"]);
 
 3005        $evaluation = array();
 
 3011            $question = 
new $question_type();
 
 3012            $question->loadFromDb($question_id);
 
 3015            $q_res = $q_eval->getResults();
 
 3018            foreach ($finished_ids as $user_id) {
 
 3019                $data[$user_id] = $q_eval->parseUserSpecificResults($q_res, $user_id);
 
 3022            $evaluation[$question_id] = 
$data;
 
 3039        $surveySetting = 
new ilSetting(
"survey");
 
 3040        $use_anonymous_id = $surveySetting->get(
"use_anonymous_id");
 
 3042            "SELECT * FROM svy_finished WHERE finished_id = %s",
 
 3047        $foundrows = 
$result->numRows();
 
 3051        $name = ($use_anonymous_id) ? $row[
"anonymous_id"] : $this->lng->txt(
"anonymous");
 
 3053            "fullname" => 
$name,
 
 3054            "sortname" => 
$name,
 
 3059            "active_id" => 
"$active_id" 
 3062            if (($row[
"user_fi"] > 0) &&
 
 3066                    (
bool) $force_non_anonymous)) {
 
 3068                    $userdata[
"fullname"] = $userdata[
"sortname"] = $this->lng->txt(
"deleted_user");
 
 3071                    $userdata[
'usr_id'] = $row[
'user_fi'];
 
 3072                    $userdata[
"fullname"] = 
$user->getFullname();
 
 3073                    $gender = 
$user->getGender();
 
 3074                    if (strlen($gender) == 1) {
 
 3075                        $gender = $this->lng->txt(
"gender_$gender");
 
 3077                    $userdata[
"gender"] = $gender;
 
 3078                    $userdata[
"firstname"] = 
$user->getFirstname();
 
 3079                    $userdata[
"lastname"] = 
$user->getLastname();
 
 3080                    $userdata[
"sortname"] = 
$user->getLastname() . 
", " . 
$user->getFirstname();
 
 3081                    $userdata[
"login"] = 
$user->getLogin();
 
 3104            "SELECT * FROM svy_answer WHERE active_fi = %s",
 
 3109            if (!is_array($answers[$row[
"question_fi"]])) {
 
 3110                $answers[$row[
"question_fi"]] = array();
 
 3112            array_push($answers[$row[
"question_fi"]], $row);
 
 3116            "name" => $userdata[
"fullname"],
 
 3117            "firstname" => $userdata[
"firstname"],
 
 3118            "lastname" => $userdata[
"lastname"],
 
 3119            "login" => $userdata[
"login"],
 
 3120            "gender" => $userdata[
"gender"],
 
 3121            "answers" => array()
 
 3124            if (array_key_exists($key, $answers)) {
 
 3125                $resultset[
"answers"][$key] = $answers[$key];
 
 3127                $resultset[
"answers"][$key] = array();
 
 3129            sort($resultset[
"answers"][$key]);
 
 3144        if (is_array($arrFilter)) {
 
 3145            if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title'])) {
 
 3146                $where .= 
" AND " . 
$ilDB->like(
'svy_question.title', 
'text', 
"%%" . $arrFilter[
'title'] . 
"%%");
 
 3148            if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description'])) {
 
 3149                $where .= 
" AND " . 
$ilDB->like(
'svy_question.description', 
'text', 
"%%" . $arrFilter[
'description'] . 
"%%");
 
 3151            if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author'])) {
 
 3152                $where .= 
" AND " . 
$ilDB->like(
'svy_question.author', 
'text', 
"%%" . $arrFilter[
'author'] . 
"%%");
 
 3154            if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type'])) {
 
 3155                $where .= 
" AND svy_qtype.type_tag = " . 
$ilDB->quote($arrFilter[
'type'], 
'text');
 
 3157            if (array_key_exists(
'spl', $arrFilter) && strlen($arrFilter[
'spl'])) {
 
 3158                $where .= 
" AND svy_question.obj_fi = " . 
$ilDB->quote($arrFilter[
'spl'], 
'integer');
 
 3164        $forbidden = 
" AND " . 
$ilDB->in(
'svy_question.obj_fi', array_keys($spls), 
false, 
'integer');
 
 3165        $forbidden .= 
" AND svy_question.complete = " . 
$ilDB->quote(
"1", 
'text');
 
 3168        if (count($existing_questions)) {
 
 3169            $existing = 
" AND " . 
$ilDB->in(
'svy_question.question_id', $existing_questions, 
true, 
'integer');
 
 3174        $query_result = 
$ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin, object_reference.ref_id" .
 
 3175            " FROM svy_question, svy_qtype, object_reference" .
 
 3176            " WHERE svy_question.original_id IS NULL" . $forbidden . $existing .
 
 3177            " AND svy_question.obj_fi = object_reference.obj_id AND svy_question.tstamp > 0" .
 
 3178            " AND svy_question.questiontype_fi = svy_qtype.questiontype_id " . $where);
 
 3181        if ($query_result->numRows()) {
 
 3182            while ($row = 
$ilDB->fetchAssoc($query_result)) {
 
 3183                if (array_key_exists(
'spl_txt', $arrFilter) && strlen($arrFilter[
'spl_txt'])) {
 
 3184                    if (!stristr($spls[$row[
"obj_fi"]], $arrFilter[
'spl_txt'])) {
 
 3189                $row[
'ttype'] = $trans[$row[
'type_tag']];
 
 3190                if ($row[
"plugin"]) {
 
 3192                        array_push(
$rows, $row);
 
 3195                    array_push(
$rows, $row);
 
 3213        if (is_array($arrFilter)) {
 
 3214            if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title'])) {
 
 3215                $where .= 
" AND " . 
$ilDB->like(
'svy_qblk.title', 
'text', 
"%%" . $arrFilter[
'title'] . 
"%%");
 
 3219        $query_result = 
$ilDB->query(
"SELECT svy_qblk.*, svy_svy.obj_fi FROM svy_qblk , svy_qblk_qst, svy_svy WHERE " .
 
 3220            "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_svy.survey_id = svy_qblk_qst.survey_fi " .
 
 3221            "$where GROUP BY svy_qblk.questionblock_id, svy_qblk.title, svy_qblk.show_questiontext,  svy_qblk.show_blocktitle, " .
 
 3222            "svy_qblk.owner_fi, svy_qblk.tstamp, svy_svy.obj_fi");
 
 3224        if ($query_result->numRows()) {
 
 3226            $surveytitles = array();
 
 3227            foreach ($survey_ref_ids as $survey_ref_id) {
 
 3231            while ($row = 
$ilDB->fetchAssoc($query_result)) {
 
 3234                foreach ($questions_array as $key => $value) {
 
 3235                    $questions_array[$key] = 
"$counter. $value";
 
 3238                if (strlen($surveytitles[$row[
"obj_fi"]])) { 
 
 3239                    $rows[$row[
"questionblock_id"]] = array(
 
 3240                        "questionblock_id" => $row[
"questionblock_id"],
 
 3241                        "title" => $row[
"title"],
 
 3242                        "svy" => $surveytitles[$row[
"obj_fi"]],
 
 3243                        "contains" => join(
", ", $questions_array),
 
 3244                        "owner" => $row[
"owner_fi"]
 
 3264            "xmlns:xsi" => 
"http://www.w3.org/2001/XMLSchema-instance",
 
 3265            "xsi:noNamespaceSchemaLocation" => 
"http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd" 
 3267        $a_xml_writer->xmlStartTag(
"surveyobject", $attrs);
 
 3272        $a_xml_writer->xmlStartTag(
"survey", $attrs);
 
 3274        $a_xml_writer->xmlElement(
"description", 
null, $this->
getDescription());
 
 3275        $a_xml_writer->xmlElement(
"author", 
null, $this->
getAuthor());
 
 3276        $a_xml_writer->xmlStartTag(
"objectives");
 
 3278            "label" => 
"introduction" 
 3285        $a_xml_writer->xmlEndTag(
"objectives");
 
 3288            $attribs = array(
"enabled" => 
"1");
 
 3290            $attribs = array(
"enabled" => 
"0");
 
 3292        $a_xml_writer->xmlElement(
"anonymisation", $attribs);
 
 3293        $a_xml_writer->xmlStartTag(
"restrictions");
 
 3295            $attribs = array(
"type" => 
"free");
 
 3297            $attribs = array(
"type" => 
"restricted");
 
 3299        $a_xml_writer->xmlElement(
"access", $attribs);
 
 3301            $attrs = array(
"type" => 
"date");
 
 3302            preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartDate(), $matches);
 
 3303            $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]));
 
 3306            $attrs = array(
"type" => 
"date");
 
 3307            preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndDate(), $matches);
 
 3308            $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]));
 
 3310        $a_xml_writer->xmlEndTag(
"restrictions");
 
 3314        $hasconstraints = 
false;
 
 3315        foreach ($pages as $question_array) {
 
 3316            foreach ($question_array as $question) {
 
 3317                if (count($question[
"constraints"])) {
 
 3318                    $hasconstraints = 
true;
 
 3323        if ($hasconstraints) {
 
 3324            $a_xml_writer->xmlStartTag(
"constraints");
 
 3325            foreach ($pages as $question_array) {
 
 3326                foreach ($question_array as $question) {
 
 3327                    if (count($question[
"constraints"])) {
 
 3329                        foreach ($question[
"constraints"] as $constraint) {
 
 3331                                "sourceref" => $question[
"question_id"],
 
 3332                                "destref" => $constraint[
"question"],
 
 3333                                "relation" => $constraint[
"short"],
 
 3334                                "value" => $constraint[
"value"],
 
 3335                                "conjunction" => $constraint[
"conjunction"]
 
 3337                            $a_xml_writer->xmlElement(
"constraint", $attribs);
 
 3342            $a_xml_writer->xmlEndTag(
"constraints");
 
 3346        $a_xml_writer->xmlStartTag(
"metadata");
 
 3348        $custom_properties = array();
 
 3352        $custom_properties[
"pool_usage"] = (int) $this->
getPoolUsage();
 
 3359        $custom_properties[
"mode"] = (int) $this->
getMode();
 
 3361        $custom_properties[
"mode_360_self_rate"] = (int) $this->
get360SelfRaters();
 
 3363        $custom_properties[
"mode_360_results"] = $this->
get360Results();
 
 3364        $custom_properties[
"mode_skill_service"] = (int) $this->
getSkillService();
 
 3372        foreach ($custom_properties as $label => $value) {
 
 3373            $a_xml_writer->xmlStartTag(
"metadatafield");
 
 3374            $a_xml_writer->xmlElement(
"fieldlabel", 
null, $label);
 
 3375            $a_xml_writer->xmlElement(
"fieldentry", 
null, $value);
 
 3376            $a_xml_writer->xmlEndTag(
"metadatafield");
 
 3379        $a_xml_writer->xmlStartTag(
"metadatafield");
 
 3380        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"SCORM");
 
 3383        $md->toXml($writer);
 
 3384        $metadata = $writer->xmlDumpMem();
 
 3385        $a_xml_writer->xmlElement(
"fieldentry", 
null, $metadata);
 
 3386        $a_xml_writer->xmlEndTag(
"metadatafield");
 
 3388        $a_xml_writer->xmlEndTag(
"metadata");
 
 3389        $a_xml_writer->xmlEndTag(
"survey");
 
 3391        $attribs = array(
"id" => $this->
getId());
 
 3392        $a_xml_writer->xmlStartTag(
"surveyquestions", $attribs);
 
 3394        foreach ($pages as $question_array) {
 
 3395            if (count($question_array) > 1) {
 
 3396                $attribs = array(
"id" => $question_array[0][
"question_id"]);
 
 3398                    "showQuestiontext" => $question_array[0][
"questionblock_show_questiontext"],
 
 3399                    "showBlocktitle" => $question_array[0][
"questionblock_show_blocktitle"],
 
 3400                    "compressView" => $question_array[0][
"questionblock_compress_view"]
 
 3402                $a_xml_writer->xmlStartTag(
"questionblock", $attribs);
 
 3403                if (strlen($question_array[0][
"questionblock_title"])) {
 
 3404                    $a_xml_writer->xmlElement(
"questionblocktitle", 
null, $question_array[0][
"questionblock_title"]);
 
 3407            foreach ($question_array as $question) {
 
 3408                if (strlen($question[
"heading"])) {
 
 3409                    $a_xml_writer->xmlElement(
"textblock", 
null, $question[
"heading"]);
 
 3415                if ($questionObject !== 
false) {
 
 3416                    $questionObject->insertXML($a_xml_writer, 
false);
 
 3419            if (count($question_array) > 1) {
 
 3420                $a_xml_writer->xmlEndTag(
"questionblock");
 
 3424        $a_xml_writer->xmlEndTag(
"surveyquestions");
 
 3425        $a_xml_writer->xmlEndTag(
"surveyobject");
 
 3426        $xml = $a_xml_writer->xmlDumpMem(
false);
 
 3439        if ($question_id < 1) {
 
 3443        if (strlen($question_type) == 0) {
 
 3447        $question = 
new $question_type();
 
 3448        $question->loadFromDb($question_id);
 
 3460        if (!is_dir($a_dir) || is_int(strpos($a_dir, 
".."))) {
 
 3463        $importDirectory = 
"";
 
 3466        $current_dir = opendir($a_dir);
 
 3468        while ($entryname = readdir($current_dir)) {
 
 3469            $files[] = $entryname;
 
 3472        foreach ($files as $file) {
 
 3473            if (is_dir($a_dir . 
"/" . $file) and ($file != 
"." and $file != 
"..")) {
 
 3475                $importDirectory = $a_dir . 
"/" . $file;
 
 3478        closedir($current_dir);
 
 3479        if (strlen($importDirectory)) {
 
 3481            $current_dir = opendir($importDirectory);
 
 3483            while ($entryname = readdir($current_dir)) {
 
 3484                $files[] = $entryname;
 
 3486            foreach ($files as $file) {
 
 3487                if (@is_file($importDirectory . 
"/" . $file) &&
 
 3488                    ($file != 
"." && $file != 
"..") &&
 
 3489                    (preg_match(
"/^[0-9]{10}__[0-9]+__(svy_)*[0-9]+\.[A-Za-z]{1,3}$/", $file) ||
 
 3490                        preg_match(
"/^[0-9]{10}__[0-9]+__(survey__)*[0-9]+\.[A-Za-z]{1,3}$/", $file))) {
 
 3492                    $xmlFile = $importDirectory . 
"/" . $file;
 
 3496        return array(
"dir" => $importDirectory, 
"xml" => $xmlFile);
 
 3509        if ($svy_qpl_id < 1) {
 
 3513        $source = $file_info[
"tmp_name"];
 
 3515        if ((
$source == 
'none') || (!
$source) || $file_info[
"error"] > UPLOAD_ERR_OK) {
 
 3516            $error = $this->lng->txt(
"import_no_file_selected");
 
 3521        if ((strcmp($file_info[
"type"], 
"text/xml") == 0) || (strcmp($file_info[
"type"], 
"application/xml") == 0)) {
 
 3522            $this->svy_log->debug(
"isXML");
 
 3526        $suffix = pathinfo($file_info[
"name"]);
 
 3527        if (strcmp(strtolower($suffix[
"extension"]), 
"zip") == 0) {
 
 3528            $this->svy_log->debug(
"isZip");
 
 3531        if (!$isXml && !$isZip) {
 
 3532            $error = $this->lng->txt(
"import_wrong_file_type");
 
 3533            $this->svy_log->debug(
"Survey: Import error. Filetype was \"" . $file_info[
"type"] . 
"\"");
 
 3535        if (strlen(
$error) == 0) {
 
 3538            $import_subdir = 
"";
 
 3541                $importfile = $import_dir . 
"/" . $file_info[
"name"];
 
 3545                if (!((strlen($found[
"dir"]) > 0) && (strlen($found[
"xml"]) > 0))) {
 
 3546                    $error = $this->lng->txt(
"wrong_import_file_structure");
 
 3549                $importfile = $found[
"xml"];
 
 3550                $import_subdir = $found[
"dir"];
 
 3552                $importfile = tempnam($import_dir, 
"survey_import");
 
 3556            $this->svy_log->debug(
"Import file = $importfile");
 
 3557            $this->svy_log->debug(
"Import subdir = $import_subdir");
 
 3559            $fh = fopen($importfile, 
"r");
 
 3561                $error = $this->lng->txt(
"import_error_opening_file");
 
 3564            $xml = fread($fh, filesize($importfile));
 
 3567                $error = $this->lng->txt(
"import_error_closing_file");
 
 3572            if (strpos(
$xml, 
"questestinterop")) {
 
 3575                $this->svy_log->debug(
"survey id = " . $this->
getId());
 
 3576                $this->svy_log->debug(
"question pool id = " . $svy_qpl_id);
 
 3579                $config = $imp->getConfig(
"Modules/Survey");
 
 3580                $config->setQuestionPoolID($svy_qpl_id);
 
 3581                $imp->getMapping()->addMapping(
"Modules/Survey", 
"svy", 0, $this->
getId());
 
 3582                $imp->importFromDirectory($import_subdir, 
"svy", 
"Modules/Survey");
 
 3583                $this->svy_log->debug(
"config(Modules/survey)->getQuestionPoolId =" . 
$config->getQuestionPoolID());
 
 3588                $import->setSurveyObject($this);
 
 3589                $import->setXMLContent(
$xml);
 
 3590                $import->startParsing();
 
 3593            if (is_array(
$_SESSION[
"import_mob_xhtml"])) {
 
 3594                foreach (
$_SESSION[
"import_mob_xhtml"] as $mob) {
 
 3595                    $importfile = $import_subdir . 
"/" . $mob[
"uri"];
 
 3596                    if (file_exists($importfile)) {
 
 3597                        if (!$mob[
"type"]) {
 
 3598                            $mob[
"type"] = 
"svy:html";
 
 3604                        if ($mob[
"type"] == 
"svy:html") {
 
 3606                            $this->
setIntroduction(str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $this->getIntroduction()));
 
 3607                            $this->
setOutro(str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $this->getOutro()));
 
 3610                        elseif ($import->questions[$mob[
"id"]]) {
 
 3611                            $new_qid = $import->questions[$mob[
"id"]];
 
 3614                            $qtext = $new_question->getQuestiontext();
 
 3616                            $qtext = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $qtext);
 
 3618                            $new_question->setQuestiontext($qtext);
 
 3619                            $new_question->saveToDb();
 
 3622                            if ($new_question->getOriginalId()) {
 
 3624                                $pool_question->setQuestiontext($qtext);
 
 3625                                $pool_question->saveToDb();
 
 3630                        $ilLog->write(
"Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
 
 3652    public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = 
false)
 
 3662        $newObj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
 
 3664        $newObj->updateMetaData();
 
 3668        $newObj->setOutro($this->
getOutro());
 
 3715        $question_pointer = array();
 
 3719        foreach ($this->questions as $key => $question_id) {
 
 3725                $question->setObjId($newObj->getId());
 
 3726                $question->saveToDb($original_id);
 
 3727                $newObj->questions[$key] = $question->getId();
 
 3728                $question_pointer[$question_id] = $question->getId();
 
 3729                $mapping[$question_id] = $question->getId();
 
 3736        if (!$cp_options->isRootNode($this->getRefId())) {
 
 3740        $newObj->saveToDb();
 
 3741        $newObj->cloneTextblocks($mapping);
 
 3749            foreach ($mapping as $src_qst_id => $tgt_qst_id) {
 
 3750                $qst_skill = $src_skills->getSkillForQuestion($src_qst_id);
 
 3752                    $tgt_skills->addQuestionSkillAssignment($tgt_qst_id, $qst_skill[
"base_skill_id"], $qst_skill[
"tref_id"]);
 
 3757            $thresholds->cloneTo($newObj, $mapping);
 
 3761        $questionblocks = array();
 
 3762        $questionblock_questions = array();
 
 3764            "SELECT * FROM svy_qblk_qst WHERE survey_fi = %s",
 
 3770                array_push($questionblock_questions, $row);
 
 3771                $questionblocks[$row[
"questionblock_fi"]] = $row[
"questionblock_fi"];
 
 3775        foreach ($questionblocks as $key => $value) {
 
 3778                $questionblock[
"title"],
 
 3779                $questionblock[
"owner_fi"],
 
 3780                $questionblock[
"show_questiontext"],
 
 3781                $questionblock[
"show_blocktitle"],
 
 3782                $questionblock[
"compress_view"]
 
 3784            $questionblocks[$key] = $questionblock_id;
 
 3787        foreach ($questionblock_questions as $key => $value) {
 
 3788            if ($questionblocks[$value[
"questionblock_fi"]] &&
 
 3789                $question_pointer[$value[
"question_fi"]]) {
 
 3790                $next_id = 
$ilDB->nextId(
'svy_qblk_qst');
 
 3791                $affectedRows = 
$ilDB->manipulateF(
 
 3792                    "INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, question_fi) " .
 
 3793                    "VALUES (%s, %s, %s, %s)",
 
 3794                    array(
'integer',
'integer',
'integer',
'integer'),
 
 3795                    array($next_id, $newObj->getSurveyId(), $questionblocks[$value[
"questionblock_fi"]], $question_pointer[$value[
"question_fi"]])
 
 3802        $newConstraints = array();
 
 3803        foreach ($constraints as $key => $constraint) {
 
 3804            if ($question_pointer[$constraint[
"for_question"]] &&
 
 3805                $question_pointer[$constraint[
"question"]]) {
 
 3806                if (!array_key_exists($constraint[
'id'], $newConstraints)) {
 
 3807                    $constraint_id = $newObj->addConstraint($question_pointer[$constraint[
"question"]], $constraint[
"relation_id"], $constraint[
"value"], $constraint[
'conjunction']);
 
 3808                    $newConstraints[$constraint[
'id']] = $constraint_id;
 
 3810                $newObj->addConstraintToQuestion($question_pointer[$constraint[
"for_question"]], $newConstraints[$constraint[
'id']]);
 
 3816        $obj_settings->cloneSettings($newObj->getId());
 
 3817        unset($obj_settings);
 
 3826            "SELECT * FROM svy_svy_qst WHERE question_fi = %s",
 
 3832            return $row[
"heading"];
 
 3845        foreach ($mapping as $original_id => $new_id) {
 
 3862        if (!is_writable($svy_data_dir)) {
 
 3863            throw new ilSurveyException(
"Survey Data Directory (" . $svy_data_dir . 
") not writeable.");
 
 3867        $svy_dir = $svy_data_dir . 
"/svy_" . $this->
getId();
 
 3869        if (!@is_dir($svy_dir)) {
 
 3873        $export_dir = $svy_dir . 
"/export";
 
 3875        if (!@is_dir($export_dir)) {
 
 3902        if (!is_writable($svy_data_dir)) {
 
 3903            throw new ilSurveyException(
"Survey Data Directory (" . $svy_data_dir . 
") not writeable.");
 
 3907        $svy_dir = $svy_data_dir . 
"/svy_" . $this->
getId();
 
 3909        if (!@is_dir($svy_dir)) {
 
 3914        $import_dir = $svy_dir . 
"/import";
 
 3916        if (!@is_dir($import_dir)) {
 
 3927            "/svy_" . $this->
getId() . 
"/import";
 
 3928        if (!is_dir($import_dir)) {
 
 3931        if (@is_dir($import_dir)) {
 
 3942            $affectedRows = 
$ilDB->manipulateF(
 
 3943                "UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
 
 3944                array(
'text',
'integer',
'integer'),
 
 3945                array($heading, $this->
getSurveyId(), $insertbefore)
 
 3948            $affectedRows = 
$ilDB->manipulateF(
 
 3949                "UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
 
 3950                array(
'text',
'integer',
'integer'),
 
 3961            "SELECT anonymous_id FROM svy_anonymous WHERE survey_key = %s AND survey_fi = %s",
 
 3962            array(
'text',
'integer'),
 
 3977            $ilDB->manipulate(
"UPDATE svy_anonymous" .
 
 3978                " SET user_key = " . 
$ilDB->quote(md5($user_id), 
"text") .
 
 3979                " WHERE survey_key = " . 
$ilDB->quote($code, 
"text"));
 
 3988            "SELECT finished_id FROM svy_finished WHERE anonymous_id = %s AND survey_fi = %s",
 
 3989            array(
'text',
'integer'),
 
 4021        $sql = 
"SELECT svy_anonymous.*, svy_finished.state" .
 
 4022            " FROM svy_anonymous" .
 
 4023            " LEFT JOIN svy_finished ON (svy_anonymous.survey_key = svy_finished.anonymous_id)" .
 
 4024            " WHERE svy_anonymous.survey_fi = " . 
$ilDB->quote($this->
getSurveyId(), 
"integer") .
 
 4025            " AND svy_anonymous.user_key IS NULL";
 
 4028            $sql .= 
" AND " . 
$ilDB->in(
"svy_anonymous.survey_key", $a_codes, 
"", 
"text");
 
 4030            $sql .= 
" AND " . 
$ilDB->in(
"svy_anonymous.anonymous_id", $a_ids, 
"", 
"text");
 
 4037        $titles[] = 
'"' . 
$lng->txt(
"survey_code") . 
'"';
 
 4038        $titles[] = 
'"' . 
$lng->txt(
"email") . 
'"';
 
 4039        $titles[] = 
'"' . 
$lng->txt(
"lastname") . 
'"';
 
 4040        $titles[] = 
'"' . 
$lng->txt(
"firstname") . 
'"';
 
 4041        $titles[] = 
'"' . 
$lng->txt(
"create_date") . 
'"';
 
 4042        $titles[] = 
'"' . 
$lng->txt(
"used") . 
'"';
 
 4043        $titles[] = 
'"' . 
$lng->txt(
"mail_sent_short") . 
'"';
 
 4044        $titles[] = 
'"' . 
$lng->txt(
"survey_code_url") . 
'"';
 
 4045        $export[] = implode(
";", $titles);
 
 4048        $default_lang = 
$ilUser->getPref(
"survey_code_language");
 
 4051            $item[] = $row[
"survey_key"];
 
 4053            if ($row[
"externaldata"]) {
 
 4054                $ext = unserialize($row[
"externaldata"]);
 
 4055                $item[] = $ext[
"email"];
 
 4056                $item[] = $ext[
"lastname"];
 
 4057                $item[] = $ext[
"firstname"];
 
 4069            $item[] = ($row[
"sent"]) ? 1 : 0;
 
 4071            $params = array(
"accesscode" => $row[
"survey_key"]);
 
 4072            if ($default_lang) {
 
 4073                $params[
"lang"] = $default_lang;
 
 4077            $export[] = 
'"' . implode(
'";"', $item) . 
'"';
 
 4079        return implode(
"\n", $export);
 
 4095        $sql = 
"SELECT svy_anonymous.*, svy_finished.state" .
 
 4096            " FROM svy_anonymous" .
 
 4097            " LEFT JOIN svy_finished ON (svy_anonymous.survey_key = svy_finished.anonymous_id)" .
 
 4098            " WHERE svy_anonymous.survey_fi = " . 
$ilDB->quote($this->
getSurveyId(), 
"integer") 
 
 4102            $sql .= 
" AND " . 
$ilDB->in(
"svy_anonymous.anonymous_id", $ids, 
"", 
"integer");
 
 4105        $sql .= 
" ORDER BY tstamp, survey_key ASC";
 
 4114                    $params = array(
"accesscode" => $row[
"survey_key"]);
 
 4116                        $params[
"lang"] = 
$lang;
 
 4123                    'id' => $row[
"anonymous_id"],
 
 4124                    'code' => $row[
"survey_key"],
 
 4125                    'date' => $row[
"tstamp"],
 
 4127                    'sent' => $row[
'sent'],
 
 4134                if ($row[
"externaldata"]) {
 
 4135                    $ext = unserialize($row[
"externaldata"]);
 
 4136                    $item[
'email'] = $ext[
'email'];
 
 4137                    $item[
'last_name'] = $ext[
'lastname'];
 
 4138                    $item[
'first_name'] = $ext[
'firstname'];
 
 4141                array_push($codes, $item);
 
 4151            "SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
 
 4152            array(
'integer',
'text'),
 
 4162            "SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
 
 4163            array(
'integer',
'text'),
 
 4166        return (
$result->numRows() > 0) ? false : 
true;
 
 4175        for (
$i = 0; 
$i < $nrOfCodes; 
$i++) {
 
 4176            $next_id = 
$ilDB->nextId(
'svy_anonymous');
 
 4178                "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, tstamp) " .
 
 4179                "VALUES (%s, %s, %s, %s)",
 
 4180                array(
'integer',
'text',
'integer',
'integer'),
 
 4193        $next_id = 
$ilDB->nextId(
'svy_anonymous');
 
 4195            "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) " .
 
 4196            "VALUES (%s, %s, %s, %s, %s)",
 
 4197            array(
'integer',
'text',
'integer',
'text',
'integer'),
 
 4198            array($next_id, $a_anonymize_key, $this->
getSurveyId(), serialize($a_data), $a_created)
 
 4207        foreach (
$data as $dataset) {
 
 4209            $next_id = 
$ilDB->nextId(
'svy_anonymous');
 
 4210            $affectedRows = 
$ilDB->manipulateF(
 
 4211                "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) " .
 
 4212                "VALUES (%s, %s, %s, %s, %s)",
 
 4213                array(
'integer',
'text',
'integer',
'text',
'integer'),
 
 4214                array($next_id, $anonymize_key, $this->
getSurveyId(), serialize($dataset), time())
 
 4230        $check_finished = ($not_sent > 1);
 
 4235        foreach ($recipients as 
$data) {
 
 4238                switch ((
int) $not_sent) {
 
 4240                        $do_send = !(bool) 
$data[
'sent'];
 
 4244                        $do_send = 
$data[
'finished'];
 
 4248                        $do_send = !
$data[
'finished'];
 
 4262                            "accesscode" => 
$data[
"code"],
 
 4266                    $messagetext = str_replace(
'[url]', 
$url, $messagetext);
 
 4267                    foreach (
$data as $key => $value) {
 
 4268                        $messagetext = str_replace(
'[' . $key . 
']', $value, $messagetext);
 
 4286            "UPDATE svy_anonymous SET sent = %s WHERE survey_fi = %s AND externaldata IS NOT NULL",
 
 4287            array(
'integer',
'integer'),
 
 4296            "SELECT survey_key code, externaldata, sent FROM svy_anonymous WHERE survey_fi = %s",
 
 4302            if (!$row[
'externaldata']) {
 
 4306            $externaldata = unserialize($row[
'externaldata']);
 
 4307            if (!$externaldata[
'email']) {
 
 4311            $externaldata[
'code'] = $row[
'code'];
 
 4312            $externaldata[
'sent'] = $row[
'sent'];
 
 4314            if ($a_check_finished) {
 
 4320            array_push(
$res, $externaldata);
 
 4333            "SELECT state FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
 
 4334            array(
'integer',
'text'),
 
 4338        $row = $this->db->fetchAssoc(
$result);
 
 4340        return $row[
'state'];
 
 4352        if (strlen($survey_code) > 0) {
 
 4353            $affectedRows = 
$ilDB->manipulateF(
 
 4354                "DELETE FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
 
 4355                array(
'integer', 
'text'),
 
 4372            "SELECT survey_key FROM svy_anonymous WHERE survey_fi = %s AND user_key = %s",
 
 4373            array(
'integer',
'text'),
 
 4378            $access_code = $row[
"survey_key"];
 
 4380        return $access_code;
 
 4395        $next_id = 
$ilDB->nextId(
'svy_anonymous');
 
 4396        $affectedRows = 
$ilDB->manipulateF(
 
 4397            "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, user_key, tstamp) " .
 
 4398            "VALUES (%s, %s, %s, %s, %s)",
 
 4399            array(
'integer',
'text', 
'integer', 
'text', 
'integer'),
 
 4400            array($next_id, $access_code, $this->
getSurveyId(), md5($user_id), time())
 
 4412        $codestring = 
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
 4415        for (
$i = 1; 
$i <= 5; 
$i++) {
 
 4416            $index = mt_rand(0, strlen($codestring) - 1);
 
 4417            $code .= substr($codestring, 
$index, 1);
 
 4431            "SELECT tstamp FROM svy_answer WHERE active_fi = %s ORDER BY tstamp DESC",
 
 4437            return $row[
"tstamp"];
 
 4440                "SELECT tstamp FROM svy_finished WHERE finished_id = %s",
 
 4446                return $row[
"tstamp"];
 
 4472        if (preg_match(
"/<[^>]*?>/", $a_text)) {
 
 4487    public function addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag = 
true, $add_mobs = 
true, $attribs = 
null)
 
 4489        $a_xml_writer->xmlStartTag(
"material", $attribs);
 
 4491            "type" => 
"text/plain" 
 4493        if ($this->
isHTML($a_material)) {
 
 4494            $attrs[
"type"] = 
"text/xhtml";
 
 4497        $a_xml_writer->xmlElement(
"mattext", $attrs, $mattext);
 
 4501            foreach (
$mobs as $mob) {
 
 4502                $mob_id = 
"il_" . 
IL_INST_ID . 
"_mob_" . $mob;
 
 4503                if (strpos($mattext, $mob_id) !== 
false) {
 
 4507                        "uri" => 
"objects/" . 
"il_" . 
IL_INST_ID . 
"_mob_" . $mob . 
"/" . $mob_obj->getTitle(),
 
 4508                        "type" => 
"svy:html",
 
 4509                        "id" => $this->getId()
 
 4511                    $a_xml_writer->xmlElement(
"matimage", $imgattrs, 
null);
 
 4515        if ($close_material_tag) {
 
 4516            $a_xml_writer->xmlEndTag(
"material");
 
 4531            if ($this->surveyCodeSecurity == 
false) {
 
 4547        if (extension_loaded(
"tidy")) {
 
 4550                "output-xml" => 
true,
 
 4551                "numeric-entities" => 
true 
 4554            $tidy->parseString($print_output, 
$config, 
'utf8');
 
 4555            $tidy->cleanRepair();
 
 4556            $print_output = tidy_get_output($tidy);
 
 4557            $print_output = preg_replace(
"/^.*?(<html)/", 
"\\1", $print_output);
 
 4559            $print_output = str_replace(
" ", 
" ", $print_output);
 
 4560            $print_output = str_replace(
"⊗", 
"X", $print_output);
 
 4563            $print_output = str_replace(
">", 
"~|gt|~", $print_output);               
 
 4564            $print_output = str_replace(
"<", 
"~|lt|~", $print_output);
 
 4565            $print_output = str_replace(
" ", 
"~|nbsp|~", $print_output);
 
 4566            $print_output = preg_replace(
'/&(?!amp)/', 
'&', $print_output);
 
 4567            $print_output = str_replace(
"~|nbsp|~", 
" ", $print_output);
 
 4568            $print_output = str_replace(
"~|gt|~", 
">", $print_output);
 
 4569            $print_output = str_replace(
"~|lt|~", 
"<", $print_output);
 
 4571        $xsl = file_get_contents(
"./Modules/Survey/xml/question2fo.xsl");
 
 4575            'font-family="Helvetica, unifont"',
 
 4576            'font-family="' . 
$GLOBALS[
'ilSetting']->
get(
'rpc_pdf_font', 
'Helvetica, unifont') . 
'"',
 
 4579        $args = array( 
'/_xml' => $print_output, 
'/_xsl' => $xsl );
 
 4583            $output = xslt_process($xh, 
"arg:/_xml", 
"arg:/_xsl", 
null, $args, $params);
 
 4584        } 
catch (Exception 
$e) {
 
 4585            $this->svy_log->error(
"Print XSLT failed:");
 
 4586            $this->svy_log->error(
"Content: " . $print_output);
 
 4587            $this->svy_log->error(
"Xsl: " . $xsl);
 
 4607        $fp = fopen($fo_file, 
"w");
 
 4615        } 
catch (Exception 
$e) {
 
 4616            $ilLog->write(__METHOD__ . 
': ' . 
$e->getMessage());
 
 4630        if ($ilPluginAdmin->isActive(
IL_COMP_MODULE, 
"SurveyQuestionPool", 
"svyq", $a_pname)) {
 
 4657        if (!is_array($ids) || count($ids) == 0) {
 
 4661        $result = 
$ilDB->query(
"SELECT usr_id, login, lastname, firstname FROM usr_data WHERE " . 
$ilDB->in(
'usr_id', $ids, 
false, 
'integer') . 
" ORDER BY login");
 
 4662        $result_array = array();
 
 4664            $result_array[$row[
"usr_id"]] = $row;
 
 4666        return $result_array;
 
 4676        $this->mailnotification = ($a_notification) ? 
true : 
false;
 
 4686        $this->mailaddresses = $a_addresses;
 
 4696        $this->mailparticipantdata = $a_data;
 
 4706        $affectedRows = 
$ilDB->manipulateF(
 
 4707            "INSERT INTO svy_times (id, finished_fi, entered_page, left_page, first_question) VALUES (%s, %s, %s, %s,%s)",
 
 4708            array(
'integer',
'integer', 
'integer', 
'integer', 
'integer'),
 
 4709            array(
$id, $finished_id, $time, 
null, $first_question)
 
 4717        $affectedRows = 
$ilDB->manipulateF(
 
 4718            "UPDATE svy_times SET left_page = %s WHERE finished_fi = %s AND entered_page = %s",
 
 4719            array(
'integer', 
'integer', 
'integer'),
 
 4720            array($time, $finished_id, 
$_SESSION[
'svy_entered_page'])
 
 4730            "SELECT * FROM svy_times WHERE finished_fi = %s",
 
 4736            if ($row[
'left_page'] > 0 && $row[
'entered_page'] > 0) {
 
 4737                $total += $row[
'left_page'] - $row[
'entered_page'];
 
 4755        if (
sizeof($this->questions) == 
sizeof($a_order)) {
 
 4756            $this->questions = array_flip($a_order);
 
 4757            $this->saveQuestionsToDB();
 
 4768        $this->pool_usage = (bool) $a_value;
 
 4780        if ($template_settings) {
 
 4782            $template_settings = $template_settings->getSettings();
 
 4783            $template_settings = $template_settings[
"use_pool"];
 
 4784            if ($template_settings && $template_settings[
"hide"]) {
 
 4785                $use_pool = (bool) $template_settings[
"value"];
 
 4803        $template_settings = $template->getSettings();
 
 4805        if ($template_settings) {
 
 4806            if ($template_settings[
"show_question_titles"] !== 
null) {
 
 4807                if ($template_settings[
"show_question_titles"][
"value"]) {
 
 4814            if ($template_settings[
"use_pool"] !== 
null) {
 
 4815                if ($template_settings[
"use_pool"][
"value"]) {
 
 4834            $codes = (bool) $template_settings[
"acc_codes"][
"value"];
 
 4835            $anon = (bool) $template_settings[
"anonymization_options"][
"value"];
 
 4865    public function updateCode($a_id, $a_email, $a_last_name, $a_first_name, $a_sent)
 
 4869        $a_email = trim($a_email);
 
 4876        $data = array(
"email" => $a_email,
 
 4877            "lastname" => trim($a_last_name),
 
 4878            "firstname" => trim($a_first_name));
 
 4881            "externaldata" => array(
"text", serialize(
$data)),
 
 4882            "sent" => array(
"integer", $a_sent)
 
 4888            array(
"anonymous_id" => array(
"integer", $a_id))
 
 4909        $this->mode_360_self_eval = (bool) $a_value;
 
 4919        $this->mode_360_self_appr = (bool) $a_value;
 
 4929        $this->mode_360_self_rate = (bool) $a_value;
 
 4939        $this->mode_360_results = (int) $a_value;
 
 4957                "obj_id" => array(
"integer", $this->
getSurveyId()),
 
 4958                "user_id" => array(
"integer", $a_user_id)
 
 4960            $ilDB->insert(
"svy_360_appr", $fields);
 
 4963            if (
$access->checkAccessOfUser($a_user_id, 
"read", 
"", $this->getRefId())) {
 
 4977        $ntf->setLangModules(array(
"svy", 
"survey"));
 
 4979        $ntf->setGotoLangId(
'url');
 
 4982        $lng = $ntf->getUserLanguage($a_user_id);
 
 4984        $ntf->setIntroductionLangId(
"svy_user_added_360_appraisee_mail");
 
 4985        $subject = str_replace(
"%1", $this->
getTitle(), 
$lng->txt(
"svy_user_added_360_appraisee"));
 
 4994            $ntf->composeAndGetMessage($a_user_id, 
null, 
"read", 
true),
 
 5007        $ntf->setLangModules(array(
"svy", 
"survey"));
 
 5009        $ntf->setGotoLangId(
'url');
 
 5012        $lng = $ntf->getUserLanguage($a_user_id);
 
 5014        $ntf->setIntroductionLangId(
"svy_user_added_360_appraisee_close_mail");
 
 5015        $subject = str_replace(
"%1", $this->
getTitle(), 
$lng->txt(
"svy_user_added_360_appraisee"));
 
 5024            $ntf->composeAndGetMessage($a_user_id, 
null, 
"read", 
true),
 
 5037        $ntf->setLangModules(array(
"svy", 
"survey"));
 
 5039        $ntf->setGotoLangId(
'url');
 
 5042        $lng = $ntf->getUserLanguage($a_user_id);
 
 5044        $ntf->setIntroductionLangId(
"svy_user_added_360_rater_mail");
 
 5045        $subject = str_replace(
"%1", $this->
getTitle(), 
$lng->txt(
"svy_user_added_360_rater"));
 
 5055            $ntf->composeAndGetMessage($a_user_id, 
null, 
"read", 
true),
 
 5064        $set = 
$ilDB->query(
"SELECT user_id" .
 
 5065            " FROM svy_360_appr" .
 
 5066            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5067            " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer"));
 
 5068        return (
bool) 
$ilDB->numRows($set);
 
 5075        $set = 
$ilDB->query(
"SELECT has_closed" .
 
 5076            " FROM svy_360_appr" .
 
 5077            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5078            " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer"));
 
 5079        $row = 
$ilDB->fetchAssoc($set);
 
 5080        return $row[
"has_closed"];
 
 5087        $ilDB->manipulate(
"DELETE FROM svy_360_appr" .
 
 5088            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5089            " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer"));
 
 5091        $set = 
$ilDB->query(
"SELECT user_id" .
 
 5092            " FROM svy_360_rater" .
 
 5093            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5094            " AND appr_id = " . 
$ilDB->quote($a_user_id, 
"integer"));
 
 5095        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 5110        $set = 
$ilDB->query(
"SELECT * FROM svy_360_appr" .
 
 5111            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer"));
 
 5112        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 5120            foreach ($raters as $rater) {
 
 5121                if ($rater[
"finished"]) {
 
 5125            $res[$row[
"user_id"]][
"finished"] = $finished . 
"/" . 
sizeof($raters);
 
 5126            $res[$row[
"user_id"]][
"closed"] = $row[
"has_closed"];
 
 5132    public function addRater($a_appraisee_id, $a_user_id, $a_anonymous_id = 0)
 
 5140            !$this->
isRater($a_appraisee_id, $a_user_id, $a_anonymous_id)) {
 
 5142                "obj_id" => array(
"integer", $this->
getSurveyId()),
 
 5143                "appr_id" => array(
"integer", $a_appraisee_id),
 
 5144                "user_id" => array(
"integer", $a_user_id),
 
 5145                "anonymous_id" => array(
"integer", $a_anonymous_id)
 
 5147            $ilDB->insert(
"svy_360_rater", $fields);
 
 5150            if (
$access->checkAccessOfUser($a_user_id, 
"read", 
"", $this->getRefId())) {
 
 5156    public function isRater($a_appraisee_id, $a_user_id, $a_anonymous_id = 0)
 
 5163            (!$a_appraisee_id || $a_appraisee_id == $a_user_id)) {
 
 5169        $sql = 
"SELECT user_id" .
 
 5170            " FROM svy_360_rater" .
 
 5172            " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
 5173            " AND anonymous_id = " . 
$ilDB->quote($a_anonymous_id, 
"integer");
 
 5174        if ($a_appraisee_id) {
 
 5175            $sql .= 
" AND appr_id = " . 
$ilDB->quote($a_appraisee_id, 
"integer");
 
 5177        $set = 
$ilDB->query($sql);
 
 5178        return (
bool) 
$ilDB->numRows($set);
 
 5181    public function deleteRater($a_appraisee_id, $a_user_id, $a_anonymous_id = 0)
 
 5190        $ilDB->manipulate(
"DELETE FROM svy_360_rater" .
 
 5191            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5192            " AND appr_id = " . 
$ilDB->quote($a_appraisee_id, 
"integer") .
 
 5193            " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
 5194            " AND anonymous_id = " . 
$ilDB->quote($a_anonymous_id, 
"integer"));
 
 5201        $res = $anonymous_ids = array();
 
 5203        $set = 
$ilDB->query(
"SELECT * FROM svy_360_rater" .
 
 5204            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5205            " AND appr_id = " . 
$ilDB->quote($a_appraisee_id, 
"integer"));
 
 5206        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 5207            if ($row[
"anonymous_id"]) {
 
 5208                $res[
"a" . $row[
"anonymous_id"]] = array(
 
 5209                    "lastname" => 
"unknown code " . $row[
"anonymous_id"],
 
 5210                    "sent" => $row[
"mail_sent"],
 
 5213                $anonymous_ids[] = $row[
"anonymous_id"];
 
 5219                $name[
"sent"] = $row[
"mail_sent"];
 
 5225        if (
sizeof($anonymous_ids)) {
 
 5227            foreach (
$data as $item) {
 
 5228                if (isset(
$res[
"a" . $item[
"id"]])) {
 
 5229                    $res[
"a" . $item[
"id"]] = array(
 
 5230                        "user_id" => 
"a" . $item[
"id"],
 
 5231                        "lastname" => $item[
"last_name"],
 
 5232                        "firstname" => $item[
"first_name"],
 
 5233                        "name" => $item[
"last_name"] . 
", " . $item[
"first_name"],
 
 5235                        "email" => $item[
"email"],
 
 5236                        "code" => $item[
"code"],
 
 5237                        "href" => $item[
"href"],
 
 5238                        "sent" => 
$res[
"a" . $item[
"id"]][
"sent"],
 
 5254        $sql = 
"SELECT appr_id FROM svy_360_rater" .
 
 5258            $sql .= 
" AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer");
 
 5260            $sql .= 
" AND anonymous_id = " . 
$ilDB->quote($a_anonymous_id, 
"integer");
 
 5263        $set = 
$ilDB->query($sql);
 
 5264        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 5265            $res[] = $row[
"appr_id"];
 
 5271            !in_array($a_user_id, 
$res)) {
 
 5272            $res[] = $a_user_id;
 
 5282        $set = 
$ilDB->query(
"SELECT anonymous_id FROM svy_anonymous" .
 
 5283                " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5284                " AND survey_key = " . 
$ilDB->quote($a_code, 
"text"));
 
 5286        return $res[
"anonymous_id"];
 
 5293        $sql = 
"SELECT * FROM svy_finished" .
 
 5295            " AND appr_id = " . 
$ilDB->quote($appr_id, 
"integer");
 
 5297            $sql .= 
" AND user_fi = " . 
$ilDB->quote($user_id, 
"integer");
 
 5299            $sql .= 
" AND anonymous_id = " . 
$ilDB->quote($anonymous_code, 
"text");
 
 5302        if (
$result->numRows() == 0) {
 
 5306            return (
int) $row[
"state"];
 
 5323                    $this->
isRater(0, $user_id)) {
 
 5344        $sql = 
"SELECT * FROM svy_finished" .
 
 5348            $sql .= 
" AND (user_fi = " . 
$ilDB->quote($user_id, 
"integer") .
 
 5349                " OR anonymous_id = " . 
$ilDB->quote($a_code, 
"text") . 
")";
 
 5353            $sql .= 
" AND anonymous_id = " . 
$ilDB->quote($a_code, 
"text");
 
 5355        $set = 
$ilDB->query($sql);
 
 5356        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 5357            $res[$row[
"finished_id"]] = array(
"appr_id" => $row[
"appr_id"],
 
 5358                "user_id" => $row[
"user_fi"],
 
 5359                "code" => $row[
"anonymous_id"],
 
 5360                "finished" => (
bool) $row[
"state"]);
 
 5363        return array(
"code" => $a_code, 
"runs" => 
$res);
 
 5371            $set = 
$ilDB->query(
"SELECT sf.anonymous_id FROM svy_finished sf" .
 
 5372                " WHERE sf.survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5373                " AND sf.user_fi = " . 
$ilDB->quote($a_user_id, 
"integer"));
 
 5374            $a_code = 
$ilDB->fetchAssoc($set);
 
 5375            return $a_code[
"anonymous_id"];
 
 5383        $set = 
$ilDB->query(
"SELECT user_fi FROM svy_finished" .
 
 5384            " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5385            " AND anonymous_id = " . 
$ilDB->quote($a_code, 
"text"));
 
 5386        $user_id = 
$ilDB->fetchAssoc($set);
 
 5387        $user_id = $user_id[
"user_fi"];
 
 5401        $set = 
$ilDB->query(
"SELECT finished_id, user_fi FROM svy_finished" .
 
 5402            " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5403            " AND appr_id = " . 
$ilDB->quote($a_appr_id, 
"integer"));
 
 5404        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 5405            if ($a_exclude_appraisee && $row[
"user_fi"] == $a_appr_id) {
 
 5408            $res[] = $row[
"finished_id"];
 
 5425        $set = 
$ilDB->query(
"SELECT finished_id, user_fi FROM svy_finished" .
 
 5426            " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5427            " AND appr_id = " . 
$ilDB->quote($a_appr_id, 
"integer") .
 
 5428            " AND user_fi = " . 
$ilDB->quote($a_rat_id, 
"integer"));
 
 5429        $row = 
$ilDB->fetchAssoc($set);
 
 5430        return $row[
"finished_id"];
 
 5438        $set = 
$ilDB->query(
"SELECT finished_id, user_fi FROM svy_finished" .
 
 5439            " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5440            " AND user_fi = " . 
$ilDB->quote($a_user_id, 
"integer"));
 
 5441        if ($row = 
$ilDB->fetchAssoc($set)) {
 
 5442            $finished_ids[] = (int) $row[
"finished_id"];
 
 5444        return $finished_ids;
 
 5456        $this->mode_skill_service = $a_val;
 
 5469    public function set360RaterSent($a_appraisee_id, $a_user_id, $a_anonymous_id, $a_tstamp = 
null)
 
 5477        $ilDB->manipulate(
"UPDATE svy_360_rater" .
 
 5478            " SET mail_sent = " . 
$ilDB->quote($a_tstamp, 
"integer") .
 
 5479            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5480            " AND appr_id = " . 
$ilDB->quote($a_appraisee_id, 
"integer") .
 
 5481            " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
 5482            " AND anonymous_id = " . 
$ilDB->quote($a_anonymous_id, 
"integer"));
 
 5493        $ilDB->manipulate(
"UPDATE svy_360_appr" .
 
 5494            " SET has_closed = " . 
$ilDB->quote(time(), 
"integer") .
 
 5495            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5496            " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer"));
 
 5502            $sskill->writeAndAddAppraiseeSkills($a_user_id);
 
 5506        if (
$user->getId() != $a_user_id) {
 
 5515        $ilDB->manipulate(
"UPDATE svy_360_appr" .
 
 5516            " SET has_closed = " . 
$ilDB->quote(
null, 
"integer") .
 
 5517            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer"));
 
 5522        if (!isset(
$_SESSION[
"360_extrtr"][$a_ref_id])) {
 
 5523            $svy = 
new self($a_ref_id);
 
 5526            if ($svy->canStartSurvey(
null, 
true) &&
 
 5527                $svy->get360Mode() &&
 
 5528                $svy->isAnonymousKey($a_code)) {
 
 5529                $anonymous_id = $svy->getAnonymousIdByCode($a_code);
 
 5530                if ($anonymous_id) {
 
 5531                    if (
sizeof($svy->getAppraiseesToRate(
null, $anonymous_id))) {
 
 5532                        $_SESSION[
"360_extrtr"][$a_ref_id] = 
true;
 
 5538            $_SESSION[
"360_extrtr"][$a_ref_id] = 
false;
 
 5542        return $_SESSION[
"360_extrtr"][$a_ref_id];
 
 5557        $this->reminder_status = (bool) $a_value;
 
 5567        $this->reminder_start = $a_value;
 
 5577        $this->reminder_end = $a_value;
 
 5587        $this->reminder_frequency = (int) $a_value;
 
 5597        $this->reminder_target = (int) $a_value;
 
 5607        $this->reminder_last_sent = $a_value;
 
 5616        if ($selectDefault) {
 
 5617            $defaultTemplateId = 0;
 
 5618            $this->getReminderMailTemplates($defaultTemplateId);
 
 5620            if ($defaultTemplateId > 0) {
 
 5621                return $defaultTemplateId;
 
 5630        $this->reminder_tmpl = $a_value;
 
 5640        $this->tutor_ntf_status = (bool) $a_value;
 
 5650        $this->tutor_ntf_recipients = $a_value;
 
 5660        $this->tutor_ntf_target = (int) $a_value;
 
 5670        $this->tutor_res_status = (bool) $a_value;
 
 5680        $this->tutor_res_recipients = $a_value;
 
 5690                $set = 
$ilDB->query(
"SELECT COUNT(*) numall FROM svy_finished" .
 
 5691                    " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5692                    " AND state = " . 
$ilDB->quote(1, 
"integer") .
 
 5693                    " AND " . 
$ilDB->in(
"user_fi", $user_ids, 
"", 
"integer"));
 
 5694                $row = 
$ilDB->fetchAssoc($set);
 
 5695                if ($row[
"numall"] == 
sizeof($user_ids)) {
 
 5715        $rater_ids = array();
 
 5717            $this->svy_log->debug(
"Handle appraisee " . 
$app[
'user_id']);
 
 5725                    $this->svy_log->debug(
"...1");
 
 5728                        $this->svy_log->debug(
"...2");
 
 5729                        if (!is_array($rater_ids[
$app[
'user_id']])) {
 
 5730                            $rater_ids[
$app[
'user_id']] = array();
 
 5732                        if (!in_array(
$app[
"user_id"], $rater_ids[
$app[
'user_id']])) {
 
 5733                            $rater_ids[
$app[
'user_id']][] = 
$app[
"user_id"];
 
 5738                $this->svy_log->debug(
"Check raters.");
 
 5744                        if (!$rater[
"anonymous_id"] && !$rater[
"finished"]) {
 
 5745                            if (!is_array($rater_ids[$rater[
"user_id"]])) {
 
 5746                                $rater_ids[$rater[
"user_id"]] = array();
 
 5748                            if (!in_array(
$app[
"user_id"], $rater_ids[$rater[
"user_id"]])) {
 
 5749                                $rater_ids[$rater[
"user_id"]][] = 
$app[
"user_id"];
 
 5757        $this->svy_log->debug(
"Found raters:" . count($rater_ids));
 
 5759        foreach ($rater_ids as 
$id => 
$app) {
 
 5760            if (
$access->checkAccessOfUser(
$id, 
"read", 
"", $this->getRefId())) {
 
 5773        $this->svy_log->debug(
"Send mail to:" . $a_user_id);
 
 5776        $ntf->setLangModules(array(
"svy", 
"survey"));
 
 5778        $ntf->setGotoLangId(
'url');
 
 5781        $lng = $ntf->getUserLanguage($a_user_id);
 
 5783        $ntf->setIntroductionLangId(
"svy_user_added_360_rater_reminder_mail");
 
 5784        $subject = str_replace(
"%1", $this->
getTitle(), 
$lng->txt(
"svy_user_added_360_rater"));
 
 5786        foreach ($a_appraisee_ids as $appraisee_id) {
 
 5797            $ntf->composeAndGetMessage($a_user_id, 
null, 
"read", 
true),
 
 5807        if ((
bool) $a_use_invited) {
 
 5808            $user_ids = $this->invitation_manager->getAllForSurvey($this->
getSurveyId());
 
 5810            $parent_grp_ref_id = 
$tree->checkForParentType($this->
getRefId(), 
"grp");
 
 5811            if ($parent_grp_ref_id) {
 
 5813                $user_ids = $part->getMembers();
 
 5815                $parent_crs_ref_id = 
$tree->checkForParentType($this->
getRefId(), 
"crs");
 
 5816                if ($parent_crs_ref_id) {
 
 5818                    $user_ids = $part->getMembers();
 
 5832            $ulng->loadLanguageModule(
'survey');
 
 5834            $subject = sprintf($ulng->txt(
'survey_notification_tutor_subject'), $this->getTitle());
 
 5837            $message .= $ulng->txt(
'survey_notification_tutor_body') . 
":\n\n";
 
 5839            $message .= 
"\n" . $ulng->txt(
'survey_notification_tutor_link') . 
": " . $link;
 
 5842            $mail_obj->appendInstallationSignature(
true);
 
 5860        $now_with_format = date(
"YmdHis", $now);
 
 5861        $today = date(
"Y-m-d");
 
 5863        $this->svy_log->debug(
"Check status and dates.");
 
 5883        if ($today < $start ||
 
 5884            ($end && $today > $end)) {
 
 5888        $this->svy_log->debug(
"Check access period.");
 
 5893            ($now < $item_data[
"timing_start"] ||
 
 5894            $now > $item_data[
"timing_end"])) {
 
 5898        $this->svy_log->debug(
"Check frequency.");
 
 5905            $missing_ids = array();
 
 5908                $this->svy_log->debug(
"Entering survey mode.");
 
 5914                    $finished_ids = array();
 
 5915                    $set = 
$ilDB->query(
"SELECT user_fi FROM svy_finished" .
 
 5916                        " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5917                        " AND state = " . 
$ilDB->quote(1, 
"text") .
 
 5918                        " AND " . 
$ilDB->in(
"user_fi", $user_ids, 
"", 
"integer"));
 
 5919                    while ($row = 
$ilDB->fetchAssoc($set)) {
 
 5920                        $finished_ids[] = $row[
"user_fi"];
 
 5924                    $missing_ids = array_diff($user_ids, $finished_ids);
 
 5926                        foreach ($missing_ids as $idx => $user_id) {
 
 5928                            if (!$ilAccess->checkAccessOfUser($user_id, 
"read", 
"", $this->getRefId(), 
"svy", $this->getId())) {
 
 5929                                unset($missing_ids[$idx]);
 
 5934                        $this->sentReminder($missing_ids);
 
 5938                $this->svy_log->debug(
"Entering 360 mode.");
 
 5947            return sizeof($missing_ids);
 
 5953    protected function sentReminder(array $a_recipient_ids)
 
 5961            $templateService = 
$DIC[
'mail.texttemplates.service'];
 
 5964            $tmpl_params = array(
 
 5973        foreach ($a_recipient_ids as $user_id) {
 
 5975                $subject = $tmpl->getSubject();
 
 5982                $ulng->loadLanguageModule(
'survey');
 
 5984                $subject = sprintf($ulng->txt(
'survey_reminder_subject'), $this->getTitle());
 
 5987                $message .= $ulng->txt(
'survey_reminder_body') . 
":\n\n";
 
 5989                $message .= 
"\n" . $ulng->txt(
'survey_reminder_link') . 
": " . $link;
 
 5993            $mail_obj->appendInstallationSignature(
true);
 
 6007        $this->activation_starting_time = $starting_time;
 
 6012        $this->activation_ending_time = $ending_time;
 
 6017        return (strlen($this->activation_starting_time)) ? $this->activation_starting_time : 
null;
 
 6022        return (strlen($this->activation_ending_time)) ? $this->activation_ending_time : 
null;
 
 6027        $this->view_own_results = (bool) $a_value;
 
 6037        $this->mail_own_results = (bool) $a_value;
 
 6047        $this->mail_confirmation = (bool) $a_value;
 
 6057        $this->anon_user_list = (bool) $a_value;
 
 6073        $surveySetting = 
new ilSetting(
"survey");
 
 6074        if (!$surveySetting->get(
"skipped_is_custom", 
false)) {
 
 6075            return $lng->txt(
"skipped");
 
 6077            return $surveySetting->get(
"skipped_custom_value", 
"");
 
 6085    public function getReminderMailTemplates(&$defaultTemplateId = 
null)
 
 6092        $templateService = 
$DIC[
'mail.texttemplates.service'];
 
 6094            $res[$tmpl->getTplId()] = $tmpl->getTitle();
 
 6095            if (
null !== $defaultTemplateId && $tmpl->isDefault()) {
 
 6096                $defaultTemplateId = $tmpl->getTplId();
 
 6109            $user = new \ilObjUser($a_user_id);
 
 6111            $processor = new \ilMailTemplatePlaceholderResolver(
$context, $a_message);
 
 6112            $a_message = $processor->resolve(
$user, $a_context_params);
 
 6113        } 
catch (\Exception 
$e) {
 
 6122        $this->mode = $a_value;
 
 6132        $this->mode_self_eval_results = $a_value;
 
 6149        $q = 
"SELECT obj_fi FROM svy_svy" .
 
 6150            " WHERE tutor_res_cron IS NULL" .
 
 6151            " AND tutor_res_status = " . 
$ilDB->quote(1, 
"integer") .
 
 6152            " AND enddate < " . 
$ilDB->quote(date(
"Ymd000000"), 
"text");
 
 6155            $q = 
"SELECT obj_fi FROM svy_svy" .
 
 6156                " WHERE tutor_res_status = " . 
$ilDB->quote(1, 
"integer") .
 
 6157                " AND enddate < " . 
$ilDB->quote(date(
"Ymd000000"), 
"text");
 
 6160        $set = 
$ilDB->query($q);
 
 6164        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 6165            $res[] = $row[
"obj_fi"];
 
 6173        global $ilCtrl, 
$ilDB;
 
 6177        include_once 
"./Services/Mail/classes/class.ilMail.php";
 
 6178        include_once 
"./Services/User/classes/class.ilObjUser.php";
 
 6179        include_once 
"./Services/Language/classes/class.ilLanguageFactory.php";
 
 6180        include_once 
"./Services/User/classes/class.ilUserUtil.php";
 
 6182        include_once 
"./Services/Link/classes/class.ilLink.php";
 
 6190        $old_ref_id = 
$_GET[
"ref_id"];
 
 6191        $old_base_class = 
$_GET[
"baseClass"];
 
 6193        $ilCtrl->setTargetScript(
"ilias.php");
 
 6194        $_GET[
"baseClass"] = 
"ilObjSurveyGUI";
 
 6196        $ilCtrl->setParameterByClass(
"ilSurveyEvaluationGUI", 
"ref_id", $this->
getRefId());
 
 6200            $html = $gui->evaluation(1, 
true, 
true);
 
 6201        } 
catch (Exception $exception) {
 
 6202            $_GET[
"ref_id"] = $old_ref_id;
 
 6203            $_GET[
"baseClass"] = $old_base_class;
 
 6206        $_GET[
"ref_id"] = $old_ref_id;
 
 6207        $_GET[
"baseClass"] = $old_base_class;
 
 6209        $html = preg_replace(
"/\?dummy\=[0-9]+/", 
"", $html);
 
 6210        $html = preg_replace(
"/\?vers\=[0-9A-Za-z\-]+/", 
"", $html);
 
 6211        $html = str_replace(
'.css$Id$', 
".css", $html);
 
 6212        $html = preg_replace(
"/src=\"\\.\\//ims", 
"src=\"" . ILIAS_HTTP_PATH . 
"/", $html);
 
 6213        $html = preg_replace(
"/href=\"\\.\\//ims", 
"href=\"" . ILIAS_HTTP_PATH . 
"/", $html);
 
 6215        $log->debug(
"--pdf start, ref id " . $this->
getRefId());
 
 6216        $log->debug(
"html length: " . strlen($html));
 
 6217        $log->debug(
"html (first 1000 chars): " . substr($html, 0, 1000));
 
 6220        $attachment_filename = 
"survey_" . $this->
getRefId() . 
"_" . (
new DateTimeImmutable(
'now'))->format(
'Ymd_His') . 
".pdf";
 
 6221        $pdf = $pdf_factory->deliverPDFFromHTMLString(
 
 6223            $attachment_filename,
 
 6228        $log->debug(
"--pdf end");
 
 6231            !file_exists($pdf)) {
 
 6236        require_once 
'Services/Mail/classes/class.ilFileDataMail.php';
 
 6238        $mail_data->copyAttachmentFile($pdf, $attachment_filename);
 
 6243            $ulng->loadLanguageModule(
'survey');
 
 6245            $subject = sprintf($ulng->txt(
'survey_results_tutor_subject'), $this->getTitle());
 
 6248            $message .= $ulng->txt(
'survey_results_tutor_body') . 
":\n\n";
 
 6250            $message .= 
"\n" . $ulng->txt(
'survey_notification_tutor_link') . 
": " . $link;
 
 6253            $mail_obj->appendInstallationSignature(
true);
 
 6261                array($attachment_filename)
 
 6265        $ilDB->manipulate(
"UPDATE svy_svy" .
 
 6266            " SET tutor_res_cron = " . 
$ilDB->quote(1, 
"integer") .
 
 6267            " WHERE survey_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer"));
 
 6280            $sum_score += call_user_func([
$c, 
"getMaxSumScore"], $this->
getSurveyId());
 
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
Survey Question Import Parser.
static _getQuestionGUI($questiontype, $question_id=-1)
Creates a question gui representation.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _getOriginalId($question_id, $a_return_question_id_if_no_original=true)
Returns the original id of a question.
static _isComplete($question_id)
Checks whether the question is complete or not.
static _getQuestionType($question_id)
Returns the question type of a question with a given id.
static _instanciateQuestionEvaluation($question_id, array $a_finished_ids=null)
Creates an instance of a question evaluation with a given question id.
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
Class ilInvalidSurveyImportFileException.
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.
static getLogger($a_component_id)
Get component logger.
static getTemplateContextById($a_id)
static _getUsedHTMLTagsAsString($a_module="")
Returns a string of all allowed HTML tags for text editing.
static _getAvailableQuestionpools($use_object_id=false, $could_be_offline=false, $showPath=false, $permission="read")
Returns the available question pools for the active user.
static _getQuestionClasses()
Get question classes.
static _getQuestionTypeTranslations()
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.
modifyQuestionblock($questionblock_id, $title, $show_questiontext, $show_blocktitle, $compress_view=false)
Modifies a question block.
setActivationVisibility($a_value)
setTutorResultsStatus($a_value)
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 The question is appended to t...
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)
const RESULTS_SELF_EVAL_NONE
getSkillService()
Get skill service.
deleteAppraisee($a_user_id)
deleteSurveyCode($survey_code)
Deletes a given survey access code.
getExportDirectory()
get export directory of survey
removeConstraintsConcerningQuestion($question_id)
Remove constraints concerning a question with a given question_id.
getCalculateSumScore()
Get calculate sum score.
getAnonymize()
get anonymize status
setActivationStartDate($starting_time=null)
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.
getConstraints($question_id)
Returns the constraints to a given question or questionblock.
addQuestion($question_id)
Adds a question to the survey (used in importer!)
getActivationVisibility()
prepareTextareaOutput($txt_output)
Prepares a string for a text area output in surveys.
update($a_upload=false)
update object data
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)
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...
getMaxSumScore()
Get max sum score.
setStartDateAndTime($start_date="", $start_time)
Sets the start date of the survey.
hasAnonymizedResults()
Checks if the survey results are to be anonymized.
updateConstraint($precondition_id, $if_question_id, $relation, $value, $conjunction)
Updates a precondition.
findCodeForUser($a_user_id)
setTutorNotificationTarget($a_value)
updateCode($a_id, $a_email, $a_last_name, $a_first_name, $a_sent)
loadQuestionsFromDb()
Loads the survey questions from the database.
static _getConstraints($survey_id)
Returns the constraints to a given question or questionblock.
setMailAddresses($a_addresses)
addQuestionToBlock($question_id, $questionblock_id)
setSkillService($a_val)
Set skill service.
deleteAllUserData($reset_LP=true)
Deletes all user data of a survey.
__construct($a_id=0, $a_call_by_reference=true)
Constructor @access public.
sendNotificationMail($a_user_id, $a_anonymize_id, $a_appr_id)
processPrintoutput2FO($print_output)
Convert a print output to XSL-FO.
getOutro()
Gets the outro text.
create($a_upload=false)
create survey object
isQuestionInAnyBlock($a_question_fi)
Is question already in a block?
getRatersData($a_appraisee_id)
getTutorNotificationRecipients()
createSurveyCodesForExternalData($data)
getReminderTemplate($selectDefault=false)
getQuestionGUI($questiontype, $question_id)
Returns a question gui object to a given questiontype and question id.
createMetaData()
Create meta data entry.
setSelfEvaluationResults($a_value)
sendAppraiseeCloseNotification($a_user_id)
Send appraisee notification.
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)
setOutro($outro="")
Sets the outro text.
getSelfEvaluationResults()
setActivationEndDate($ending_time=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)
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)
setTutorResultsRecipients(array $a_value)
deleteConstraint($constraint_id)
Deletes a constraint of a question.
getUserSurveyExecutionStatus($a_code=null)
const NOTIFICATION_INVITED_USERS
const RESULTS_SELF_EVAL_ALL
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
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)
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.
setReminderStart(ilDate $a_value=null)
const NOTIFICATION_PARENT_COURSE
setMailConfirmation($a_value)
const EVALUATION_ACCESS_ALL
closeAppraisee($a_user_id)
deleteRater($a_appraisee_id, $a_user_id, $a_anonymous_id=0)
setMailNotification($a_notification)
getTextblock($question_id)
setReminderTemplate($a_value)
applySettingsTemplate($template_id)
Apply settings template.
isUnusedCode($a_code, $a_user_id)
setMailParticipantData($a_data)
moveQuestions($move_questions, $target_index, $insert_mode)
Move questions and/or questionblocks to another position.
canStartSurvey($anonymous_id=null, $a_no_rbac=false)
Checks if the survey can be started.
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
isQuestionInSurvey($a_question_fi)
Check if a question is already in the survey.
isSurveyCodeUnique($code)
getExternalCodeRecipients($a_check_finished=false)
toXML()
Returns a QTI xml representation of the survey.
getEvaluationAccess()
Gets the learners evaluation access.
static _hasDatasets($survey_id)
getAnonymousIdByCode($a_code)
getLastAccess($finished_id)
getAppraiseesToRate($a_user_id, $a_anonymous_id=null)
const NOTIFICATION_APPRAISEES_AND_RATERS
& getSurveyPages()
Returns the survey pages in an array (a page contains one or more questions)
saveToDb()
Saves a survey object to a database.
static getSurveysWithTutorResults()
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.
setAnonymousUserList($a_value)
& getSurveyParticipants($finished_ids=null, $force_non_anonymous=false, $include_invites=false)
const ANONYMIZE_FREEACCESS
saveQuestionsToDb()
Saves the survey questions to the database.
updateOrder(array $a_order)
createQuestionblock($title, $show_questiontext, $show_blocktitle, $questions, $compress_view=false)
Creates a question block for the survey.
createNewAccessCode()
Returns a new, unused survey access code.
read()
read object data from db into object @access public
getTutorResultsRecipients()
loadFromDb()
Loads a survey object from a database.
static _getQuestionblock($questionblock_id)
Returns the database row for a given question block.
setStartTime($finished_id, $first_question)
getQuestionsTable($arrFilter)
Calculates the data for the output of the question browser.
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.
isSurveyFinishedByCode($a_code)
Get if survey is finished for an specific anonymous user code.
setStartDate($start_date="")
Sets the start date of the survey.
removeQuestionFromBlock($question_id, $questionblock_id)
getUserSpecificResults($finished_ids)
Calculates the evaluation data for the user specific results.
sentReminderPlaceholders($a_message, $a_user_id, array $a_context_params)
setEvaluationAccess($evaluation_access=self::EVALUATION_ACCESS_OFF)
Sets the learners evaluation access.
getEndDate()
Gets the end date of the survey.
sendRaterNotification($a_user_id, $a_appraisee_id)
Send rater notification.
set360SelfEvaluation($a_value)
setTutorNotificationRecipients(array $a_value)
send360ReminderToUser($a_user_id, $a_appraisee_ids)
Send rater notification.
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.
getUserDataFromActiveId($active_id, $force_non_anonymous=false)
Returns the user information from an active_id (survey_finished.finished_id)
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.
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.
setCalculateSumScore(bool $a_val)
Set calculate sum score.
static _addQuestionblock($title="", $owner=0, $show_questiontext=true, $show_blocktitle=false, $compress_view=false)
Adds a questionblock to the database.
getFinishedIdsForSelfEval($a_user_id)
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)
const RESULTS_SELF_EVAL_OWN
setReminderStatus($a_value)
startSurvey($user_id, $anonymous_id, $appraisee_id)
Starts the survey creating an entry in the database.
sent360Reminders()
Send 360 reminders.
& 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()
const NOTIFICATION_APPRAISEES
removeQuestions($remove_questions, $remove_questionblocks)
Remove questions from the survey.
fixSequenceStructure()
Remove duplicate sequence entries, see #22018.
& getSurveyFinishedIds()
Get the finished id's of all survey participants.
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.
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.
sendAppraiseeNotification($a_user_id)
Send appraisee notification.
setTemplate($template_id)
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.
& getQuestionpoolTitles($could_be_offline=false, $showPath=false)
Get the titles of all available survey question pools.
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.
isAppraiseeClosed($a_user_id)
addConstraintToQuestion($to_question_id, $constraint_id)
Adds a constraint to a question.
createExportDirectory()
creates data directory for export files (data_dir/svy_data/svy_<id>/export, depending on data directo...
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...
const NOTIFICATION_RATERS
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.
const QUESTIONTITLES_HIDDEN
& getAvailableQuestionpools($use_obj_id=false, $could_be_offline=false, $showPath=false, $permission="read")
Returns the available question pools for the active user.
static _lookupEmail($a_user_id)
Lookup email.
static _getUserData($a_internalids)
return user data for given user ids
static _lookupLogin($a_user_id)
lookup login
static getUserIdsByEmail($a_email)
STATIC METHOD get all user_ids of an email address.
static _lookupName($a_user_id)
lookup user name
static _lookupFullname($a_user_id)
Lookup Full Name.
Class ilObjectActivation.
const TIMINGS_DEACTIVATED
setTimingType($a_type)
Set timing type.
static getItem($a_ref_id)
Get item data.
static getInstance($a_obj_id)
Class ilObject Basic functions for all objects.
getType()
get object type @access public
static _lookupObjId($a_id)
setOfflineStatus($a_status)
Set offline status.
update()
update object in db
static _lookupTitle($a_id)
lookup object title
deleteMetaData()
delete meta data entry
updateMetaData()
update meta data entry
getOfflineStatus()
Get offline status.
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
countReferences()
count references of object
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...
static factory($a_package, $a_timeout=0)
Creates an ilRpcClient instance to our ilServer.
Settings template application class.
Skill management settings.
Survey evaluation graphical output.
Skill tresholds for 360 surveys.
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, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
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 sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
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 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 unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
static is_email($a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
static getASCIIFilename($a_filename)
convert utf8 to ascii filename
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.
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
foreach($_POST as $key=> $value) $res