5use \ILIAS\Survey\Participants;
 
  202    public function __construct($a_id = 0, $a_call_by_reference = 
true)
 
  206        $this->
user = $DIC->user();
 
  207        $this->lng = 
$DIC->language();
 
  208        $this->db = 
$DIC->database();
 
  209        $this->access = 
$DIC->access();
 
  210        $this->log = 
$DIC[
"ilLog"];
 
  211        $this->plugin_admin = 
$DIC[
"ilPluginAdmin"];
 
  212        $this->tree = 
$DIC->repositoryTree();
 
  217        $this->survey_id = -1;
 
  218        $this->introduction = 
"";
 
  219        $this->outro = 
$lng->txt(
"survey_finished");
 
  220        $this->author = 
$ilUser->getFullname();
 
  222        $this->questions = array();
 
  225        $this->surveyCodeSecurity = 
true;
 
  226        $this->template_id = 
null;
 
  227        $this->pool_usage = 
true;
 
  240    public function create($a_upload = 
false)
 
  257        parent::createMetaData();
 
  267    public function update($a_upload = 
false)
 
  273        if (!parent::update()) {
 
  284        $result = parent::createReference();
 
  307        array_push($this->questions, $question_id);
 
  316    public function delete()
 
  322            foreach ($this->questions as $question_id) {
 
  330        $remove = parent::delete();
 
  348        $affectedRows = 
$ilDB->manipulateF(
 
  349            "DELETE FROM svy_svy WHERE survey_id = %s",
 
  355            "SELECT questionblock_fi FROM svy_qblk_qst WHERE survey_fi = %s",
 
  359        $questionblocks = array();
 
  361            array_push($questionblocks, $row[
"questionblock_fi"]);
 
  363        if (count($questionblocks)) {
 
  364            $affectedRows = 
$ilDB->manipulate(
"DELETE FROM svy_qblk WHERE " . 
$ilDB->in(
'questionblock_id', $questionblocks, 
false, 
'integer'));
 
  366        $affectedRows = 
$ilDB->manipulateF(
 
  367            "DELETE FROM svy_qblk_qst WHERE survey_fi = %s",
 
  373        $affectedRows = 
$ilDB->manipulateF(
 
  374            "DELETE FROM svy_anonymous WHERE survey_fi = %s",
 
  381        $directory = $svy_data_dir . 
"/svy_" . $this->
getId();
 
  382        if (is_dir($directory)) {
 
  391        foreach (
$mobs as $mob) {
 
  409            "SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
 
  413        $active_array = array();
 
  415            array_push($active_array, $row[
"finished_id"]);
 
  418        $affectedRows = 
$ilDB->manipulateF(
 
  419            "DELETE FROM svy_finished WHERE survey_fi = %s",
 
  424        foreach ($active_array as $active_fi) {
 
  425            $affectedRows = 
$ilDB->manipulateF(
 
  426                "DELETE FROM svy_answer WHERE active_fi = %s",
 
  430            $affectedRows = 
$ilDB->manipulateF(
 
  431                "DELETE FROM svy_times WHERE finished_fi = %s",
 
  439            $lp_obj->resetLPDataForCompleteObject();
 
  452        $user_ids[] = array();
 
  454        foreach ($finished_ids as $finished_id) {
 
  456                "SELECT finished_id FROM svy_finished WHERE finished_id = %s",
 
  462            if ($row[
"user_fi"]) {
 
  463                $user_ids[] = $row[
"user_fi"];
 
  466            $affectedRows = 
$ilDB->manipulateF(
 
  467                "DELETE FROM svy_answer WHERE active_fi = %s",
 
  469                array($row[
"finished_id"])
 
  472            $affectedRows = 
$ilDB->manipulateF(
 
  473                "DELETE FROM svy_finished WHERE finished_id = %s",
 
  478            $affectedRows = 
$ilDB->manipulateF(
 
  479                "DELETE FROM svy_times WHERE finished_fi = %s",
 
  481                array($row[
"finished_id"])
 
  485        if (
sizeof($user_ids)) {
 
  487            $lp_obj->resetLPDataForUserIds($user_ids);
 
  491    public function &
getSurveyParticipants($finished_ids = 
null, $force_non_anonymous = 
false, $include_invites = 
false)
 
  495        $sql = 
"SELECT * FROM svy_finished" .
 
  498            $sql .= 
" AND " . 
$ilDB->in(
"finished_id", $finished_ids, 
"", 
"integer");
 
  502        $participants = array();
 
  506                $userdata[
"finished"] = (bool) $row[
"state"];
 
  507                $userdata[
"finished_tstamp"] = $row[
"tstamp"];
 
  508                $participants[$userdata[
"sortname"] . $userdata[
"active_id"]] = $userdata;
 
  511        $participant_ids = array_column($participants, 
"usr_id");
 
  512        if ($include_invites) {
 
  513            foreach ($this->invitation_manager->getAllForSurvey($this->getSurveyId()) as $usr_id) {
 
  514                if (!in_array($usr_id, $participant_ids)) {
 
  516                    $participants[
$name[
"lastname"] . 
"," . 
$name[
"firstname"] . $usr_id] = [
 
  518                        "sortname" => 
$name[
"lastname"] . 
"," . 
$name[
"firstname"],
 
  519                        "fistname" => 
$name[
"firstname"],
 
  520                        "lastname" => 
$name[
"lastname"],
 
  521                        "login" => 
$name[
"login"],
 
  525                        "finished_tstamp" => 0,
 
  532        return $participants;
 
  543        if (($this->
getTitle()) and (count($this->questions))) {
 
  564            $affectedRows = 
$ilDB->manipulateF(
 
  565                "UPDATE svy_svy SET complete = %s, tstamp = %s WHERE survey_id = %s",
 
  566                array(
'text',
'integer',
'integer'),
 
  584        $question_gui = $this->
getQuestionGUI($questiontype, $question_id);
 
  587        if ($this->
getId() == $question_gui->object->getObjId() && !$a_force) {
 
  591        $duplicate_id = $question_gui->object->duplicate(
true, 
"", 
"", 
"", $this->
getId());
 
  592        return $duplicate_id;
 
  604        $this->log->debug(
"insert question, id:" . $question_id);
 
  607            $this->log->debug(
"question is not complete");
 
  613                "SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
 
  617            $sequence = 
$result->numRows();
 
  619            $this->log->debug(
"duplicate, id: " . $question_id . 
", duplicate id: " . $duplicate_id);
 
  626            $next_id = 
$ilDB->nextId(
'svy_svy_qst');
 
  627            $affectedRows = 
$ilDB->manipulateF(
 
  628                "INSERT INTO svy_svy_qst (survey_question_id, survey_fi, question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
 
  629                array(
'integer', 
'integer', 
'integer', 
'integer', 
'integer'),
 
  630                array($next_id, $this->
getSurveyId(), $duplicate_id, $sequence, time())
 
  633            $this->log->debug(
"added entry to svy_svy_qst, id: " . $next_id . 
", question id: " . $duplicate_id . 
", sequence: " . $sequence);
 
  652        $set = 
$ilDB->query(
"SELECT * FROM svy_svy_qst " .
 
  653            " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
  654            " AND question_fi = " . 
$ilDB->quote($a_question_fi, 
"integer"));
 
  655        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  672            "SELECT svy_qblk.title, svy_qblk.show_questiontext, svy_qblk.show_blocktitle," .
 
  673            " svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst, svy_svy_qst" .
 
  674            " WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi" .
 
  675            " AND svy_svy_qst.question_fi = svy_qblk_qst.question_fi" .
 
  676            " AND svy_qblk.questionblock_id = %s" .
 
  677            " ORDER BY svy_svy_qst.sequence",
 
  679            array($questionblock_id)
 
  682        $show_questiontext = 0;
 
  683        $show_blocktitle = 0;
 
  688            $show_questiontext = $row[
"show_questiontext"];
 
  689            $show_blocktitle = $row[
"show_blocktitle"];
 
  698        $next_id = 
$ilDB->nextId(
'svy_settings');
 
  699        $affectedRows = 
$ilDB->insert(
"svy_settings", array(
 
  700            "settings_id" => array(
"integer", $next_id),
 
  701            "usr_id" => array(
"integer", $usr_id),
 
  702            "keyword" => array(
"text", $key),
 
  703            "title" => array(
"text", 
$title),
 
  704            "value" => array(
"clob", $value)
 
  712        $affectedRows = 
$ilDB->manipulateF(
 
  713            "DELETE FROM svy_settings WHERE settings_id = %s",
 
  717        return $affectedRows;
 
  725            "SELECT * FROM svy_settings WHERE usr_id = %s AND keyword = %s",
 
  726            array(
'integer', 
'text'),
 
  732                $found[$row[
'settings_id']] = $row;
 
  749        if (is_object($rmd_start)) {
 
  753        if (is_object($rmd_end)) {
 
  758            $next_id = 
$ilDB->nextId(
'svy_svy');
 
  759            $affectedRows = 
$ilDB->insert(
"svy_svy", array(
 
  760                "survey_id" => array(
"integer", $next_id),
 
  761                "obj_fi" => array(
"integer", $this->
getId()),
 
  762                "author" => array(
"text", $this->
getAuthor()),
 
  766                "enddate" => array(
"text", $this->
getEndDate()),
 
  768                "complete" => array(
"text", $this->
isComplete()),
 
  769                "created" => array(
"integer", time()),
 
  775                "tstamp" => array(
"integer", time()),
 
  776                "template_id" => array(
"integer", $this->
getTemplate()),
 
  777                "pool_usage" => array(
"integer", $this->
getPoolUsage()),
 
  779                "mode" => array(
"integer", $this->
getMode()),
 
  784                "mode_360_results" => array(
"integer", $this->
get360Results()),
 
  786                "mode_skill_service" => array(
"integer", (
int) $this->
getSkillService()),
 
  791                "reminder_start" => array(
"datetime", $rmd_start),
 
  792                "reminder_end" => array(
"datetime", $rmd_end),
 
  809            $affectedRows = 
$ilDB->update(
"svy_svy", array(
 
  810                "author" => array(
"text", $this->
getAuthor()),
 
  814                "enddate" => array(
"text", $this->
getEndDate()),
 
  816                "complete" => array(
"text", $this->
isComplete()),
 
  822                "tstamp" => array(
"integer", time()),
 
  823                "template_id" => array(
"integer", $this->
getTemplate()),
 
  824                "pool_usage" => array(
"integer", $this->
getPoolUsage()),
 
  826                "mode" => array(
"integer", $this->
getMode()),
 
  831                "mode_360_results" => array(
"integer", $this->
get360Results()),
 
  833                "mode_skill_service" => array(
"integer", (
int) $this->
getSkillService()),
 
  838                "reminder_start" => array(
"datetime", $rmd_start),
 
  839                "reminder_end" => array(
"datetime", $rmd_end),
 
  854            "survey_id" => array(
"integer", $this->
getSurveyId())
 
  876            $item->update($this->ref_id);
 
  890        $this->log->debug(
"save questions");
 
  893        $old_questions = array();
 
  895            "SELECT survey_question_id,question_fi,sequence" .
 
  896            " FROM svy_svy_qst WHERE survey_fi = %s",
 
  901            $old_questions[$row[
"question_fi"]] = $row;         
 
  905        $insert = $update = $delete = array();
 
  906        foreach ($this->questions as $seq => $fi) {
 
  907            if (!array_key_exists($fi, $old_questions)) {               
 
  909            } elseif ($old_questions[$fi][
"sequence"] != $seq) {                                
 
  910                $update[$fi] = $old_questions[$fi][
"survey_question_id"];
 
  913            unset($old_questions[$fi]);                                         
 
  917        if (
sizeof($old_questions)) {
 
  919            foreach ($old_questions as $fi => $old) {
 
  920                $del_ids[] = $old[
"survey_question_id"];
 
  922            $ilDB->manipulate($q = 
"DELETE FROM svy_svy_qst" .
 
  923                " WHERE " . 
$ilDB->in(
"survey_question_id", $del_ids, 
"", 
"integer"));
 
  924            $this->log->debug(
"delete: " . $q);
 
  926        unset($old_questions);
 
  929        foreach ($this->questions as $seq => $fi) {
 
  930            if (in_array($fi, $insert)) {
 
  933                    $next_id = 
$ilDB->nextId(
'svy_svy_qst');
 
  935                        "INSERT INTO svy_svy_qst" .
 
  936                        " (survey_question_id, survey_fi, question_fi, heading, sequence, tstamp)" .
 
  937                        " VALUES (%s, %s, %s, %s, %s, %s)",
 
  938                        array(
'integer', 
'integer', 
'integer', 
'text', 
'integer', 
'integer'),
 
  939                        array($next_id, $this->
getSurveyId(), $fi, 
null, $seq, time())
 
  941                    $this->log->debug(
"insert svy_svy_qst, id:" . $next_id . 
", fi: " . $fi . 
", seq:" . $seq);
 
  943            } elseif (array_key_exists($fi, $update)) {
 
  944                $ilDB->manipulate(
"UPDATE svy_svy_qst" .
 
  945                    " SET sequence = " . 
$ilDB->quote($seq, 
"integer") .
 
  946                    ", tstamp = " . 
$ilDB->quote(time(), 
"integer") .
 
  947                    " WHERE survey_question_id = " . 
$ilDB->quote($update[$fi], 
"integer"));
 
  948                $this->log->debug(
"update svy_svy_qst, id:" . $update[$fi] . 
", fi: " . $fi . 
", seq:" . $seq);
 
  964            "SELECT anonymous_id FROM svy_finished WHERE anonymous_id = %s",
 
  970            return $row[
"anonymous_id"];
 
  997        if ($question_id < 1) {
 
 1001            "SELECT type_tag FROM svy_question, svy_qtype WHERE svy_question.question_id = %s AND " .
 
 1002            "svy_question.questiontype_fi = svy_qtype.questiontype_id",
 
 1006        if (
$result->numRows() == 1) {
 
 1008            return $data[
"type_tag"];
 
 1030        switch ($a_anonymize) {
 
 1035                $this->anonymize = $a_anonymize;
 
 1050        return ($this->anonymize) ? $this->anonymize : 0;
 
 1060        return ($this->
getAnonymize() == self::ANONYMIZE_OFF ||
 
 1084            "SELECT * FROM svy_svy WHERE obj_fi = %s",
 
 1086            array($this->
getId())
 
 1088        if (
$result->numRows() == 1) {
 
 1093            if (strcmp(
$data[
"outro"], 
"survey_finished") == 0) {
 
 1094                $this->
setOutro($this->lng->txt(
"survey_finished"));
 
 1142        if ($this->ref_id) {
 
 1144            switch ($activation[
"timing_type"]) {
 
 1168        $this->questions = array();
 
 1170            "SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
 
 1175            $this->questions[
$data[
"sequence"]] = 
$data[
"question_fi"];
 
 1190            "SELECT * FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
 
 1197        $to_delete_ids = array();
 
 1199            if (in_array(
$data[
"question_fi"], $fis)) {         
 
 1200                $to_delete_ids[] = 
$data[
"survey_question_id"];
 
 1202                $fis[] = 
$data[
"question_fi"];
 
 1207        if (count($to_delete_ids) > 0) {
 
 1208            $ilDB->manipulate($q = 
"DELETE FROM svy_svy_qst" .
 
 1209                " WHERE " . 
$ilDB->in(
"survey_question_id", $to_delete_ids, 
false, 
"integer") .
 
 1210                " AND survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer"));
 
 1211            $this->log->debug(
"delete: " . $q);
 
 1213            $ilDB->manipulate($q = 
"DELETE FROM svy_qblk_qst " .
 
 1214                " WHERE " . 
$ilDB->in(
"question_fi", $fis, 
true, 
"integer") .
 
 1215                " AND survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer"));
 
 1216            $this->log->debug(
"delete: " . $q);
 
 1220        $set = 
$ilDB->query(
"SELECT * FROM svy_svy_qst " .
 
 1221            " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") . 
" ORDER BY sequence");
 
 1223        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
 1225                $q = 
"UPDATE svy_svy_qst SET " .
 
 1226                " sequence = " . 
$ilDB->quote($seq++, 
"integer") .
 
 1227                " WHERE survey_question_id = " . 
$ilDB->quote($rec[
"survey_question_id"], 
"integer")
 
 1229            $this->log->debug(
"update: " . $q);
 
 1258        $md_life = &$md->getLifecycle();
 
 1260            if (strlen($a_author) == 0) {
 
 1262                $a_author = 
$ilUser->getFullname();
 
 1265            $md_life = &$md->addLifecycle();
 
 1267            $con = &$md_life->addContribute();
 
 1268            $con->setRole(
"Author");
 
 1270            $ent = &$con->addEntity();
 
 1271            $ent->setEntity($a_author);
 
 1287        $md_life = &$md->getLifecycle();
 
 1289            $ids = &$md_life->getContributeIds();
 
 1290            foreach ($ids as 
$id) {
 
 1291                $md_cont = &$md_life->getContribute(
$id);
 
 1292                if (strcmp($md_cont->getRole(), 
"Author") == 0) {
 
 1293                    $entids = &$md_cont->getEntityIds();
 
 1294                    foreach ($entids as $entid) {
 
 1295                        $md_ent = &$md_cont->getEntity($entid);
 
 1296                        array_push(
$author, $md_ent->getEntity());
 
 1312        return ($this->display_question_titles) ? 1 : 0;
 
 1323        $this->display_question_titles = ($a_show) ? 1 : 0;
 
 1334        $this->display_question_titles = 1;
 
 1345        $this->display_question_titles = 0;
 
 1380        return (strlen($this->start_date)) ? $this->start_date : 
null;
 
 1395        $edit_settings = 
false;
 
 1397        if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartDate(), $matches)) {
 
 1398            $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 1400            if ($now < $epoch_time) {
 
 1401                array_push(
$messages, $this->lng->txt(
'start_date_not_reached') . 
' (' .
 
 1404                $edit_settings = 
true;
 
 1408        if (preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndDate(), $matches)) {
 
 1409            $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
 
 1411            if ($now > $epoch_time) {
 
 1412                array_push(
$messages, $this->lng->txt(
'end_date_reached') . 
' (' .
 
 1415                $edit_settings = 
true;
 
 1421            array_push(
$messages, $this->lng->txt(
"survey_is_offline"));
 
 1423            $edit_settings = 
true;
 
 1426        if (!$a_no_rbac && !$ilAccess->checkAccess(
"read", 
"", $this->ref_id)) {
 
 1427            array_push(
$messages, $this->lng->txt(
"cannot_participate_survey"));
 
 1446            "edit_settings" => $edit_settings
 
 1478        if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/", 
$start_date, $matches)) {
 
 1483        if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $start_time, $matches)) {
 
 1488        $this->start_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m, 
$d, $h, 
$i, $s);
 
 1500        return (strlen($this->end_date)) ? $this->end_date : 
null;
 
 1531        if (preg_match(
"/(\d{4})-(\d{2})-(\d{2})/", 
$end_date, $matches)) {
 
 1536        if (preg_match(
"/(\d{2}):(\d{2}):(\d{2})/", $end_time, $matches)) {
 
 1541        $this->end_date = sprintf(
'%04d%02d%02d%02d%02d%02d', $y, $m, 
$d, $h, 
$i, $s);
 
 1570        $this->activation_visibility = (bool) $a_value;
 
 1580        return (
bool) $this->activation_limited;
 
 1585        $this->activation_limited = (bool) $a_value;
 
 1597        return (strlen($this->introduction)) ? $this->introduction : 
null;
 
 1609        return (strlen($this->outro)) ? $this->outro : 
null;
 
 1621        $existing_questions = array();
 
 1623            "SELECT svy_question.original_id FROM svy_question, svy_svy_qst WHERE " .
 
 1624            "svy_svy_qst.survey_fi = %s AND svy_svy_qst.question_fi = svy_question.question_id",
 
 1629            if (
$data[
"original_id"]) {
 
 1630                array_push($existing_questions, 
$data[
"original_id"]);
 
 1633        return $existing_questions;
 
 1657        $array_pos = array_search($target_index, $this->questions);
 
 1658        if ($insert_mode == 0) {
 
 1659            $part1 = array_slice($this->questions, 0, $array_pos);
 
 1660            $part2 = array_slice($this->questions, $array_pos);
 
 1661        } elseif ($insert_mode == 1) {
 
 1662            $part1 = array_slice($this->questions, 0, $array_pos + 1);
 
 1663            $part2 = array_slice($this->questions, $array_pos + 1);
 
 1666        foreach ($move_questions as $question_id) {
 
 1667            if (!(array_search($question_id, $part1) === 
false)) {
 
 1668                unset($part1[array_search($question_id, $part1)]);
 
 1671            if (!(array_search($question_id, $part2) === 
false)) {
 
 1672                unset($part2[array_search($question_id, $part2)]);
 
 1677        if ($found != count($move_questions)) {
 
 1680        $part1 = array_values($part1);
 
 1681        $part2 = array_values($part2);
 
 1682        $this->questions = array_values(array_merge($part1, $move_questions, $part2));
 
 1683        foreach ($move_questions as $question_id) {
 
 1685            foreach ($constraints as $idx => $constraint) {
 
 1686                foreach ($part2 as $next_question_id) {
 
 1687                    if ($constraint[
"question"] == $next_question_id) {
 
 1706        #20610 if no question found, do nothing. 
 1708            $question->delete($question_id);
 
 1723            "SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
 
 1724            array(
'integer',
'integer'),
 
 1728            $remove_constraints = array();
 
 1730                array_push($remove_constraints, $row[
"constraint_fi"]);
 
 1732            $affectedRows = 
$ilDB->manipulateF(
 
 1733                "DELETE FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
 
 1734                array(
'integer',
'integer'),
 
 1737            foreach ($remove_constraints as $key => $constraint_id) {
 
 1738                $affectedRows = 
$ilDB->manipulateF(
 
 1739                    "DELETE FROM svy_constraint WHERE constraint_id = %s",
 
 1741                    array($constraint_id)
 
 1758        $block_sizes = array();
 
 1760            if (in_array($question_id, $remove_questions) or in_array(
$data[
"questionblock_id"], $remove_questionblocks)) {
 
 1761                unset($this->questions[array_search($question_id, $this->questions)]);
 
 1763            } elseif (
$data[
"questionblock_id"]) {
 
 1764                $block_sizes[
$data[
"questionblock_id"]]++;
 
 1769        foreach ($block_sizes as $block_id => 
$size) {
 
 1771                $remove_questionblocks[] = $block_id;
 
 1775        foreach (array_unique($remove_questionblocks) as $questionblock_id) {
 
 1776            $affectedRows = 
$ilDB->manipulateF(
 
 1777                "DELETE FROM svy_qblk WHERE questionblock_id = %s",
 
 1779                array($questionblock_id)
 
 1781            $affectedRows = 
$ilDB->manipulateF(
 
 1782                "DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
 
 1783                array(
'integer',
'integer'),
 
 1788        $this->questions = array_values($this->questions);
 
 1801        foreach ($questionblocks as 
$index) {
 
 1802            $affectedRows = 
$ilDB->manipulateF(
 
 1803                "DELETE FROM svy_qblk WHERE questionblock_id = %s",
 
 1807            $affectedRows = 
$ilDB->manipulateF(
 
 1808                "DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s",
 
 1809                array(
'integer',
'integer'),
 
 1819        $affectedRows = 
$ilDB->manipulateF(
 
 1820            "DELETE FROM svy_qblk_qst WHERE questionblock_fi = %s AND survey_fi = %s AND question_fi = %s",
 
 1821            array(
'integer',
'integer',
'integer'),
 
 1822            array($questionblock_id, $this->
getSurveyId(), $question_id)
 
 1832            $next_id = 
$ilDB->nextId(
'svy_qblk_qst');
 
 1833            $affectedRows = 
$ilDB->manipulateF(
 
 1834                "INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
 
 1835                "question_fi) VALUES (%s, %s, %s, %s)",
 
 1836                array(
'integer', 
'integer', 
'integer', 
'integer'),
 
 1837                array($next_id, $this->
getSurveyId(), $questionblock_id, $question_id)
 
 1856        $set = 
$ilDB->query(
"SELECT * FROM svy_qblk_qst " .
 
 1857            " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 1858            " AND question_fi = " . 
$ilDB->quote($a_question_fi, 
"integer"));
 
 1859        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
 1877            "SELECT svy_question.title, svy_qblk_qst.question_fi, svy_qblk_qst.survey_fi FROM " .
 
 1878            "svy_qblk, svy_qblk_qst, svy_question WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND " .
 
 1879            "svy_question.question_id = svy_qblk_qst.question_fi AND svy_qblk.questionblock_id = %s",
 
 1881            array($questionblock_id)
 
 1885            $titles[$row[
"question_fi"]] = $row[
"title"];
 
 1889            "SELECT question_fi, sequence FROM svy_svy_qst WHERE survey_fi = %s ORDER BY sequence",
 
 1893        $resultarray = array();
 
 1896            if (array_key_exists($row[
"question_fi"], $titles)) {
 
 1897                $resultarray[$counter++] = $titles[$row[
"question_fi"]];
 
 1900        return $resultarray;
 
 1915            "SELECT a.question_fi FROM svy_qblk_qst a JOIN svy_svy_qst b ON (a.question_fi = b.question_fi) " .
 
 1916            " WHERE a.questionblock_fi = %s ORDER BY b.sequence",
 
 1918            array($questionblock_id)
 
 1923                if (!in_array(
$data[
'question_fi'], $ids)) {            
 
 1924                    array_push($ids, 
$data[
'question_fi']);
 
 1945            "SELECT * FROM svy_qblk WHERE questionblock_id = %s",
 
 1947            array($questionblock_id)
 
 1966        $next_id = 
$ilDB->nextId(
'svy_qblk');
 
 1968            "INSERT INTO svy_qblk (questionblock_id, title, show_questiontext," .
 
 1969            " show_blocktitle, owner_fi, tstamp) " .
 
 1970            "VALUES (%s, %s, %s, %s, %s, %s)",
 
 1971            array(
'integer',
'text',
'integer',
'integer',
'integer',
'integer'),
 
 1972            array($next_id, 
$title, $show_questiontext, $show_blocktitle, 
$owner, time())
 
 1994        $next_id = 
$ilDB->nextId(
'svy_qblk');
 
 1995        $affectedRows = 
$ilDB->manipulateF(
 
 1996            "INSERT INTO svy_qblk (questionblock_id, title, show_questiontext," .
 
 1997            " show_blocktitle, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
 
 1998            array(
'integer',
'text',
'text',
'text',
'integer',
'integer'),
 
 1999            array($next_id, 
$title, $show_questiontext, $show_blocktitle, 
$ilUser->getId(), time())
 
 2001        if ($affectedRows) {
 
 2002            $questionblock_id = $next_id;
 
 2005                    $next_id = 
$ilDB->nextId(
'svy_qblk_qst');   
 
 2006                    $affectedRows = 
$ilDB->manipulateF(
 
 2007                        "INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, " .
 
 2008                        "question_fi) VALUES (%s, %s, %s, %s)",
 
 2009                        array(
'integer', 
'integer', 
'integer', 
'integer'),
 
 2028        $affectedRows = 
$ilDB->manipulateF(
 
 2029            "UPDATE svy_qblk SET title = %s, show_questiontext = %s," .
 
 2030            " show_blocktitle = %s WHERE questionblock_id = %s",
 
 2031            array(
'text',
'text',
'text',
'integer'),
 
 2032            array(
$title, $show_questiontext, $show_blocktitle, $questionblock_id)
 
 2046            "SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s AND survey_fi = %s",
 
 2047            array(
'integer',
'integer'),
 
 2050        $constraints = array();
 
 2052            array_push($constraints, $row[
"constraint_fi"]);
 
 2054        foreach ($constraints as $constraint_id) {
 
 2069        $affectedRows = 
$ilDB->manipulateF(
 
 2070            "DELETE FROM svy_constraint WHERE constraint_id = %s",
 
 2072            array($constraint_id)
 
 2074        $affectedRows = 
$ilDB->manipulateF(
 
 2075            "DELETE FROM svy_qst_constraint WHERE constraint_fi = %s",
 
 2077            array($constraint_id)
 
 2090        $all_questions = array();
 
 2092            "SELECT svy_qtype.type_tag, svy_qtype.plugin, svy_question.question_id, " .
 
 2093            "svy_svy_qst.heading FROM svy_qtype, svy_question, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
 
 2094            "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
 
 2095            "ORDER BY svy_svy_qst.sequence",
 
 2101            if ($row[
"plugin"]) {
 
 2108                $questionrow = $question->getQuestionDataArray($row[
"question_id"]);
 
 2109                foreach ($row as $key => $value) {
 
 2110                    $questionrow[$key] = $value;
 
 2112                $all_questions[$row[
"question_id"]] = $questionrow;
 
 2113                $all_questions[$row[
"question_id"]][
"usableForPrecondition"] = $question->usableForPrecondition();
 
 2114                $all_questions[$row[
"question_id"]][
"availableRelations"] = $question->getAvailableRelations();
 
 2118        $questionblocks = array();
 
 2119        if (count($all_questions)) {
 
 2121                "SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst WHERE " .
 
 2122                "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
 
 2123                "AND " . 
$ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions), 
false, 
'integer'),
 
 2128                $questionblocks[$row[
'question_fi']] = $row;
 
 2132        foreach ($all_questions as $question_id => $row) {
 
 2134            if (isset($questionblocks[$question_id])) {
 
 2135                $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
 
 2136                $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
 
 2137                $all_questions[$question_id][
"constraints"] = $constraints;
 
 2139                $all_questions[$question_id][
"questionblock_title"] = 
"";
 
 2140                $all_questions[$question_id][
"questionblock_id"] = 
"";
 
 2141                $all_questions[$question_id][
"constraints"] = $constraints;
 
 2143            if ($with_answers) {
 
 2146                    "SELECT svy_variable.*, svy_category.title FROM svy_variable, svy_category " .
 
 2147                    "WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id " .
 
 2148                    "ORDER BY sequence ASC",
 
 2154                        array_push($answers, 
$data[
"title"]);
 
 2157                $all_questions[$question_id][
"answers"] = $answers;
 
 2160        return $all_questions;
 
 2173            "SELECT * FROM svy_svy_qst WHERE survey_fi = %s",
 
 2179                if (!array_key_exists($row[
"question_fi"], $obligatory_questions)) {
 
 2180                    $obligatory_questions[$row[
"question_fi"]] = 0;
 
 2186        foreach ($obligatory_questions as $question_fi => $obligatory) {
 
 2188            $ilDB->manipulate(
"UPDATE svy_question" .
 
 2189                " SET obligatory = " . 
$ilDB->quote($obligatory, 
"integer") .
 
 2190                " WHERE question_id = " . 
$ilDB->quote($question_fi, 
"integer"));
 
 2203        $all_questions = array();
 
 2205            "SELECT svy_question.*, svy_qtype.type_tag, svy_svy_qst.heading FROM " .
 
 2206            "svy_question, svy_qtype, svy_svy_qst WHERE svy_svy_qst.survey_fi = %s AND " .
 
 2207            "svy_svy_qst.question_fi = svy_question.question_id AND svy_question.questiontype_fi = svy_qtype.questiontype_id " .
 
 2208            "ORDER BY svy_svy_qst.sequence",
 
 2213            $all_questions[$row[
"question_id"]] = $row;
 
 2216        $questionblocks = array();
 
 2217        if (count($all_questions)) {
 
 2219                "SELECT svy_qblk.*, svy_qblk_qst.question_fi FROM svy_qblk, svy_qblk_qst " .
 
 2220                "WHERE svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_qblk_qst.survey_fi = %s " .
 
 2221                "AND " . 
$ilDB->in(
'svy_qblk_qst.question_fi', array_keys($all_questions), 
false, 
'integer'),
 
 2226                $questionblocks[$row[
'question_fi']] = $row;
 
 2230        $all_pages = array();
 
 2233        foreach ($all_questions as $question_id => $row) {
 
 2234            $constraints = array();
 
 2235            if (isset($questionblocks[$question_id])) {
 
 2236                if (!$currentblock or ($currentblock != $questionblocks[$question_id][
'questionblock_id'])) {
 
 2239                $all_questions[$question_id][
'page'] = $pageindex;
 
 2240                $all_questions[$question_id][
"questionblock_title"] = $questionblocks[$question_id][
'title'];
 
 2241                $all_questions[$question_id][
"questionblock_id"] = $questionblocks[$question_id][
'questionblock_id'];
 
 2242                $all_questions[$question_id][
"questionblock_show_questiontext"] = $questionblocks[$question_id][
'show_questiontext'];
 
 2243                $all_questions[$question_id][
"questionblock_show_blocktitle"] = $questionblocks[$question_id][
'show_blocktitle'];
 
 2244                $currentblock = $questionblocks[$question_id][
'questionblock_id'];
 
 2246                $all_questions[$question_id][
"constraints"] = $constraints;
 
 2249                $all_questions[$question_id][
'page'] = $pageindex;
 
 2250                $all_questions[$question_id][
"questionblock_title"] = 
"";
 
 2251                $all_questions[$question_id][
"questionblock_id"] = 
"";
 
 2252                $all_questions[$question_id][
"questionblock_show_questiontext"] = 1;
 
 2253                $all_questions[$question_id][
"questionblock_show_blocktitle"] = 1;
 
 2256                $all_questions[$question_id][
"constraints"] = $constraints;
 
 2258            if (!isset($all_pages[$pageindex])) {
 
 2259                $all_pages[$pageindex] = array();
 
 2261            array_push($all_pages[$pageindex], $all_questions[$question_id]);
 
 2264        $max = count($all_pages);
 
 2266        foreach ($all_pages as 
$index => $block) {
 
 2267            foreach ($block as $blockindex => $question) {
 
 2268                $all_pages[
$index][$blockindex][
"position"] = $counter / $max;
 
 2288        if (strcmp($active_page_question_id, 
"") == 0) {
 
 2291        foreach ($pages as $key => $question_array) {
 
 2292            foreach ($question_array as $question) {
 
 2293                if ($active_page_question_id == $question[
"question_id"]) {
 
 2298        if ($foundpage == -1) {
 
 2301            $foundpage += $direction;
 
 2302            if ($foundpage < 0) {
 
 2305            if ($foundpage >= count($pages)) {
 
 2308            return $pages[$foundpage];
 
 2332        $result_array = array();
 
 2334            "SELECT svy_constraint.*, svy_relation.*, svy_qst_constraint.question_fi ref_question_fi FROM svy_qst_constraint, svy_constraint, " .
 
 2335            "svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id AND " .
 
 2336            "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_constraint.constraint_id = %s",
 
 2356        $result_array = array();
 
 2358            "SELECT svy_constraint.*, svy_relation.* FROM svy_qst_constraint, svy_constraint, svy_relation " .
 
 2359            "WHERE svy_constraint.relation_fi = svy_relation.relation_id AND " .
 
 2360            "svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.question_fi = %s " .
 
 2361            "AND svy_qst_constraint.survey_fi = %s",
 
 2362            array(
'integer',
'integer'),
 
 2368            $question = 
new $question_type();
 
 2369            $question->loadFromDb($row[
"question_fi"]);
 
 2370            $valueoutput = $question->getPreconditionValueOutput($row[
"value"]);
 
 2371            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));
 
 2373        return $result_array;
 
 2386        $result_array = array();
 
 2388            "SELECT svy_qst_constraint.question_fi as for_question, svy_constraint.*, svy_relation.* " .
 
 2389            "FROM svy_qst_constraint, svy_constraint, svy_relation WHERE svy_constraint.relation_fi = svy_relation.relation_id " .
 
 2390            "AND svy_qst_constraint.constraint_fi = svy_constraint.constraint_id AND svy_qst_constraint.survey_fi = %s",
 
 2395            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']));
 
 2397        return $result_array;
 
 2410        $result_array = array();
 
 2412            "SELECT svy_variable.*, svy_category.title FROM svy_variable LEFT JOIN " .
 
 2413            "svy_category ON svy_variable.category_fi = svy_category.category_id WHERE svy_variable.question_fi = %s " .
 
 2414            "ORDER BY svy_variable.sequence",
 
 2419            $result_array[$row->sequence] = $row;
 
 2421        return $result_array;
 
 2436        $next_id = 
$ilDB->nextId(
'svy_constraint');
 
 2437        $affectedRows = 
$ilDB->manipulateF(
 
 2438            "INSERT INTO svy_constraint (constraint_id, question_fi, relation_fi, value, conjunction) VALUES " .
 
 2439            "(%s, %s, %s, %s, %s)",
 
 2440            array(
'integer',
'integer',
'integer',
'float', 
'integer'),
 
 2441            array($next_id, $if_question_id, $relation, $value, $conjunction)
 
 2443        if ($affectedRows) {
 
 2461        $next_id = 
$ilDB->nextId(
'svy_qst_constraint');
 
 2462        $affectedRows = 
$ilDB->manipulateF(
 
 2463            "INSERT INTO svy_qst_constraint (question_constraint_id, survey_fi, question_fi, " .
 
 2464            "constraint_fi) VALUES (%s, %s, %s, %s)",
 
 2465            array(
'integer',
'integer',
'integer',
'integer'),
 
 2466            array($next_id, $this->
getSurveyId(), $to_question_id, $constraint_id)
 
 2480    public function updateConstraint($precondition_id, $if_question_id, $relation, $value, $conjunction)
 
 2483        $affectedRows = 
$ilDB->manipulateF(
 
 2484            "UPDATE svy_constraint SET question_fi = %s, relation_fi = %s, value = %s, conjunction = %s " .
 
 2485            "WHERE constraint_id = %s",
 
 2486            array(
'integer',
'integer',
'float',
'integer',
'integer'),
 
 2487            array($if_question_id, $relation, $value, $conjunction, $precondition_id)
 
 2495            $affectedRows = 
$ilDB->manipulateF(
 
 2496                "UPDATE svy_constraint SET conjunction = %s " .
 
 2497                "WHERE constraint_id IN (SELECT constraint_fi FROM svy_qst_constraint WHERE svy_qst_constraint.question_fi = %s)",
 
 2498                array(
'integer',
'integer'),
 
 2499                array($conjunction, $question_id)
 
 2514        $custom_order = array(
"equal", 
"not_equal", 
"less", 
"less_or_equal", 
"more", 
"more_or_equal");
 
 2515        $custom_order = array_flip($custom_order);
 
 2517        $result_array = array();
 
 2520            if ($short_as_key) {
 
 2521                $result_array[$row[
"shortname"]] = array(
"short" => $row[
"shortname"], 
"long" => $row[
"longname"], 
"id" => $row[
"relation_id"], 
"order" => $custom_order[$row[
"longname"]]);
 
 2523                $result_array[$row[
"relation_id"]] = array(
"short" => $row[
"shortname"], 
"long" => $row[
"longname"], 
"order" => $custom_order[$row[
"longname"]]);
 
 2528        foreach ($result_array as $idx => $item) {
 
 2529            unset($result_array[$idx][
"order"]);
 
 2532        return $result_array;
 
 2549        $affectedRows = 
$ilDB->manipulateF(
 
 2550            "DELETE FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
 
 2551            array(
'integer',
'integer'),
 
 2552            array($question_id, $active_id)
 
 2567        $result_array = array();
 
 2569            "SELECT * FROM svy_answer WHERE question_fi = %s AND active_fi = %s",
 
 2570            array(
'integer',
'integer'),
 
 2571            array($question_id, $active_id)
 
 2573        if (
$result->numRows() >= 1) {
 
 2575                array_push($result_array, $row);
 
 2577            return $result_array;
 
 2579            return $result_array;
 
 2593        if ($this->
getAnonymize() && (strlen($anonymous_id) == 0)) {
 
 2597        if (strcmp($user_id, 
"") == 0) {
 
 2598            if ($user_id == ANONYMOUS_USER_ID) {
 
 2602        $next_id = 
$ilDB->nextId(
'svy_finished');
 
 2603        $affectedRows = 
$ilDB->manipulateF(
 
 2604            "INSERT INTO svy_finished (finished_id, survey_fi, user_fi, anonymous_id, state, tstamp, appr_id) " .
 
 2605            "VALUES (%s, %s, %s, %s, %s, %s, %s)",
 
 2606            array(
'integer',
'integer',
'integer',
'text',
'text',
'integer',
'integer'),
 
 2607            array($next_id, $this->
getSurveyId(), $user_id, $anonymous_id, 0, time(), $appraisee_id)
 
 2623            "UPDATE svy_finished SET state = %s, tstamp = %s" .
 
 2624            " WHERE survey_fi = %s AND finished_id = %s",
 
 2625            array(
'text',
'integer',
'integer',
'integer'),
 
 2626            array(1, time(), $this->
getSurveyId(), $finished_id)
 
 2633            $sskill->writeAndAddSelfEvalSkills(
$user[
'usr_id']);
 
 2650        $affectedRows = 
$ilDB->manipulateF(
 
 2651            "UPDATE svy_finished SET lastpage = %s WHERE finished_id = %s",
 
 2652            array(
'integer',
'integer'),
 
 2653            array(($page_id) ? $page_id : 0, $finished_id)
 
 2665        $placeholders = array(
 
 2666            "FIRST_NAME" => 
"firstname",
 
 2667            "LAST_NAME" => 
"lastname",
 
 2670            "firstname" => 
"firstname" 
 2675        $recipients = preg_split(
'/,/', $this->mailaddresses);
 
 2676        foreach ($recipients as $recipient) {
 
 2679            $ntf->setLangModules(array(
"survey"));
 
 2681            $ntf->setSubjectLangId(
'finished_mail_subject');
 
 2684            if (trim($messagetext)) {
 
 2689                foreach ($placeholders as $key => $mapping) {
 
 2691                        $messagetext = str_replace(
'[' . $key . 
']', 
'', $messagetext);
 
 2693                        $messagetext = str_replace(
'[' . $key . 
']', trim(
$data[$mapping]), $messagetext);
 
 2696                $ntf->setIntroductionDirect($messagetext);
 
 2698                $ntf->setIntroductionLangId(
'survey_notification_finished_introduction');
 
 2703                $ntf->addAdditionalInfo(
 
 2704                    'survey_360_appraisee',
 
 2709            $active_id = $this->
getActiveID($a_user_id, $a_anonymize_id, $a_appr_id);
 
 2710            $ntf->addAdditionalInfo(
 
 2716            $ntf->setGotoLangId(
'survey_notification_tutor_link');
 
 2717            $ntf->setReasonLangId(
'survey_notification_finished_reason');
 
 2719            if (is_numeric($recipient)) {
 
 2720                $lng = $ntf->getUserLanguage($recipient);
 
 2721                $ntf->sendMail(array($recipient), 
null, 
null);
 
 2723                $recipient = trim($recipient);
 
 2725                if (empty($user_ids)) {
 
 2726                    $ntf->sendMail(array($recipient), 
null, 
null);
 
 2728                    foreach ($user_ids as $user_id) {
 
 2729                        $lng = $ntf->getUserLanguage($user_id);
 
 2730                        $ntf->sendMail(array($user_id), 
null, 
null);
 
 2742        $questioncounter = 1;
 
 2743        foreach (
$questions as $question_id => $question_data) {
 
 2744            $textresult .= $questioncounter++ . 
". " . $question_data[
"title"] . 
"\n";
 
 2745            $found = $userResults[$question_id][$active_id];
 
 2747            if (is_array($found)) {
 
 2748                $text = implode(
"\n", $found);
 
 2752            if (strlen($text) == 0) {
 
 2755            $text = str_replace(
"<br />", 
"\n", $text);
 
 2756            $textresult .= $text . 
"\n\n";
 
 2773        if ($anonymize_id) {
 
 2775                "SELECT * FROM svy_finished" .
 
 2776                " WHERE survey_fi = %s AND anonymous_id = %s AND appr_id = %s",
 
 2777                array(
'integer',
'text',
'integer'),
 
 2778                array($this->
getSurveyId(), $anonymize_id, $appr_id)
 
 2782                "SELECT * FROM svy_finished" .
 
 2783                " WHERE survey_fi = %s AND user_fi = %s AND appr_id = %s",
 
 2784                array(
'integer',
'integer',
'integer'),
 
 2788        if (
$result->numRows() == 0) {
 
 2795            return (
int) $row[
"state"];
 
 2813        if ($anonymize_id) {
 
 2815                "SELECT finished_id FROM svy_finished" .
 
 2816                " WHERE survey_fi = %s AND anonymous_id = %s AND appr_id = %s",
 
 2817                array(
'integer',
'text',
'integer'),
 
 2818                array($this->
getSurveyId(), $anonymize_id, $appr_id)
 
 2822                "SELECT finished_id FROM svy_finished" .
 
 2823                " WHERE survey_fi = %s AND user_fi = %s AND appr_id = %s",
 
 2824                array(
'integer',
'integer',
'integer'),
 
 2828        if (
$result->numRows() == 0) {
 
 2832            return $row[
"finished_id"];
 
 2847            "SELECT lastpage FROM svy_finished WHERE finished_id = %s",
 
 2851        if (
$result->numRows() == 0) {
 
 2855            return ($row[
"lastpage"]) ? $row[
"lastpage"] : 
'';
 
 2869        if (!is_array($working_data) || count($working_data) == 0) {
 
 2873        if ((count($working_data) == 1) and (strcmp($working_data[0][
"value"], 
"") == 0)) {
 
 2878        foreach ($working_data as 
$data) {
 
 2879            switch ($constraint_data[
"short"]) {
 
 2881                    if (
$data[
"value"] < $constraint_data[
"value"]) {
 
 2887                    if (
$data[
"value"] <= $constraint_data[
"value"]) {
 
 2893                    if (
$data[
"value"] == $constraint_data[
"value"]) {
 
 2899                    if (
$data[
"value"] <> $constraint_data[
"value"]) {
 
 2905                    if (
$data[
"value"] >= $constraint_data[
"value"]) {
 
 2911                    if (
$data[
"value"] > $constraint_data[
"value"]) {
 
 2921        return (
int) $found;
 
 2931            "SELECT finished_id FROM svy_finished WHERE survey_fi = %s",
 
 2935        return (
$result->numRows()) ? true : 
false;
 
 2951            "SELECT * FROM svy_finished WHERE survey_fi = %s",
 
 2957                array_push($users, $row[
"finished_id"]);
 
 2971        $evaluation = array();
 
 2977            $question = 
new $question_type();
 
 2978            $question->loadFromDb($question_id);
 
 2981            $q_res = $q_eval->getResults();
 
 2984            foreach ($finished_ids as $user_id) {
 
 2985                $data[$user_id] = $q_eval->parseUserSpecificResults($q_res, $user_id);
 
 2988            $evaluation[$question_id] = 
$data;
 
 3005        $surveySetting = 
new ilSetting(
"survey");
 
 3006        $use_anonymous_id = $surveySetting->get(
"use_anonymous_id");
 
 3008            "SELECT * FROM svy_finished WHERE finished_id = %s",
 
 3013        $foundrows = 
$result->numRows();
 
 3017        $name = ($use_anonymous_id) ? $row[
"anonymous_id"] : $this->lng->txt(
"anonymous");
 
 3019            "fullname" => 
$name,
 
 3020            "sortname" => 
$name,
 
 3025            "active_id" => 
"$active_id" 
 3028            if (($row[
"user_fi"] > 0) &&
 
 3029                    (($row[
"user_fi"] != ANONYMOUS_USER_ID &&
 
 3032                    (
bool) $force_non_anonymous)) {
 
 3034                    $userdata[
"fullname"] = $userdata[
"sortname"] = $this->lng->txt(
"deleted_user");
 
 3037                    $userdata[
'usr_id'] = $row[
'user_fi'];
 
 3038                    $userdata[
"fullname"] = 
$user->getFullname();
 
 3039                    $gender = 
$user->getGender();
 
 3040                    if (strlen($gender) == 1) {
 
 3041                        $gender = $this->lng->txt(
"gender_$gender");
 
 3043                    $userdata[
"gender"] = $gender;
 
 3044                    $userdata[
"firstname"] = 
$user->getFirstname();
 
 3045                    $userdata[
"lastname"] = 
$user->getLastname();
 
 3046                    $userdata[
"sortname"] = 
$user->getLastname() . 
", " . 
$user->getFirstname();
 
 3047                    $userdata[
"login"] = 
$user->getLogin();
 
 3070            "SELECT * FROM svy_answer WHERE active_fi = %s",
 
 3075            if (!is_array($answers[$row[
"question_fi"]])) {
 
 3076                $answers[$row[
"question_fi"]] = array();
 
 3078            array_push($answers[$row[
"question_fi"]], $row);
 
 3082            "name" => $userdata[
"fullname"],
 
 3083            "firstname" => $userdata[
"firstname"],
 
 3084            "lastname" => $userdata[
"lastname"],
 
 3085            "login" => $userdata[
"login"],
 
 3086            "gender" => $userdata[
"gender"],
 
 3087            "answers" => array()
 
 3090            if (array_key_exists($key, $answers)) {
 
 3091                $resultset[
"answers"][$key] = $answers[$key];
 
 3093                $resultset[
"answers"][$key] = array();
 
 3095            sort($resultset[
"answers"][$key]);
 
 3110        if (is_array($arrFilter)) {
 
 3111            if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title'])) {
 
 3112                $where .= 
" AND " . 
$ilDB->like(
'svy_question.title', 
'text', 
"%%" . $arrFilter[
'title'] . 
"%%");
 
 3114            if (array_key_exists(
'description', $arrFilter) && strlen($arrFilter[
'description'])) {
 
 3115                $where .= 
" AND " . 
$ilDB->like(
'svy_question.description', 
'text', 
"%%" . $arrFilter[
'description'] . 
"%%");
 
 3117            if (array_key_exists(
'author', $arrFilter) && strlen($arrFilter[
'author'])) {
 
 3118                $where .= 
" AND " . 
$ilDB->like(
'svy_question.author', 
'text', 
"%%" . $arrFilter[
'author'] . 
"%%");
 
 3120            if (array_key_exists(
'type', $arrFilter) && strlen($arrFilter[
'type'])) {
 
 3121                $where .= 
" AND svy_qtype.type_tag = " . 
$ilDB->quote($arrFilter[
'type'], 
'text');
 
 3123            if (array_key_exists(
'spl', $arrFilter) && strlen($arrFilter[
'spl'])) {
 
 3124                $where .= 
" AND svy_question.obj_fi = " . 
$ilDB->quote($arrFilter[
'spl'], 
'integer');
 
 3130        $forbidden = 
" AND " . 
$ilDB->in(
'svy_question.obj_fi', array_keys($spls), 
false, 
'integer');
 
 3131        $forbidden .= 
" AND svy_question.complete = " . 
$ilDB->quote(
"1", 
'text');
 
 3134        if (count($existing_questions)) {
 
 3135            $existing = 
" AND " . 
$ilDB->in(
'svy_question.question_id', $existing_questions, 
true, 
'integer');
 
 3140        $query_result = 
$ilDB->query(
"SELECT svy_question.*, svy_qtype.type_tag, svy_qtype.plugin, object_reference.ref_id" .
 
 3141            " FROM svy_question, svy_qtype, object_reference" .
 
 3142            " WHERE svy_question.original_id IS NULL" . $forbidden . $existing .
 
 3143            " AND svy_question.obj_fi = object_reference.obj_id AND svy_question.tstamp > 0" .
 
 3144            " AND svy_question.questiontype_fi = svy_qtype.questiontype_id " . $where);
 
 3147        if ($query_result->numRows()) {
 
 3148            while ($row = 
$ilDB->fetchAssoc($query_result)) {
 
 3149                if (array_key_exists(
'spl_txt', $arrFilter) && strlen($arrFilter[
'spl_txt'])) {
 
 3150                    if (!stristr($spls[$row[
"obj_fi"]], $arrFilter[
'spl_txt'])) {
 
 3155                $row[
'ttype'] = $trans[$row[
'type_tag']];
 
 3156                if ($row[
"plugin"]) {
 
 3158                        array_push(
$rows, $row);
 
 3161                    array_push(
$rows, $row);
 
 3179        if (is_array($arrFilter)) {
 
 3180            if (array_key_exists(
'title', $arrFilter) && strlen($arrFilter[
'title'])) {
 
 3181                $where .= 
" AND " . 
$ilDB->like(
'svy_qblk.title', 
'text', 
"%%" . $arrFilter[
'title'] . 
"%%");
 
 3185        $query_result = 
$ilDB->query(
"SELECT svy_qblk.*, svy_svy.obj_fi FROM svy_qblk , svy_qblk_qst, svy_svy WHERE " .
 
 3186            "svy_qblk.questionblock_id = svy_qblk_qst.questionblock_fi AND svy_svy.survey_id = svy_qblk_qst.survey_fi " .
 
 3187            "$where GROUP BY svy_qblk.questionblock_id, svy_qblk.title, svy_qblk.show_questiontext,  svy_qblk.show_blocktitle, " .
 
 3188            "svy_qblk.owner_fi, svy_qblk.tstamp, svy_svy.obj_fi");
 
 3190        if ($query_result->numRows()) {
 
 3192            $surveytitles = array();
 
 3193            foreach ($survey_ref_ids as $survey_ref_id) {
 
 3197            while ($row = 
$ilDB->fetchAssoc($query_result)) {
 
 3200                foreach ($questions_array as $key => $value) {
 
 3201                    $questions_array[$key] = 
"$counter. $value";
 
 3204                if (strlen($surveytitles[$row[
"obj_fi"]])) { 
 
 3205                    $rows[$row[
"questionblock_id"]] = array(
 
 3206                        "questionblock_id" => $row[
"questionblock_id"],
 
 3207                        "title" => $row[
"title"],
 
 3208                        "svy" => $surveytitles[$row[
"obj_fi"]],
 
 3209                        "contains" => join(
", ", $questions_array),
 
 3210                        "owner" => $row[
"owner_fi"]
 
 3230            "xmlns:xsi" => 
"http://www.w3.org/2001/XMLSchema-instance",
 
 3231            "xsi:noNamespaceSchemaLocation" => 
"http://www.ilias.de/download/xsd/ilias_survey_4_2.xsd" 
 3233        $a_xml_writer->xmlStartTag(
"surveyobject", $attrs);
 
 3238        $a_xml_writer->xmlStartTag(
"survey", $attrs);
 
 3240        $a_xml_writer->xmlElement(
"description", 
null, $this->
getDescription());
 
 3241        $a_xml_writer->xmlElement(
"author", 
null, $this->
getAuthor());
 
 3242        $a_xml_writer->xmlStartTag(
"objectives");
 
 3244            "label" => 
"introduction" 
 3251        $a_xml_writer->xmlEndTag(
"objectives");
 
 3254            $attribs = array(
"enabled" => 
"1");
 
 3256            $attribs = array(
"enabled" => 
"0");
 
 3258        $a_xml_writer->xmlElement(
"anonymisation", $attribs);
 
 3259        $a_xml_writer->xmlStartTag(
"restrictions");
 
 3261            $attribs = array(
"type" => 
"free");
 
 3263            $attribs = array(
"type" => 
"restricted");
 
 3265        $a_xml_writer->xmlElement(
"access", $attribs);
 
 3267            $attrs = array(
"type" => 
"date");
 
 3268            preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getStartDate(), $matches);
 
 3269            $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]));
 
 3272            $attrs = array(
"type" => 
"date");
 
 3273            preg_match(
"/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->
getEndDate(), $matches);
 
 3274            $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]));
 
 3276        $a_xml_writer->xmlEndTag(
"restrictions");
 
 3280        $hasconstraints = 
false;
 
 3281        foreach ($pages as $question_array) {
 
 3282            foreach ($question_array as $question) {
 
 3283                if (count($question[
"constraints"])) {
 
 3284                    $hasconstraints = 
true;
 
 3289        if ($hasconstraints) {
 
 3290            $a_xml_writer->xmlStartTag(
"constraints");
 
 3291            foreach ($pages as $question_array) {
 
 3292                foreach ($question_array as $question) {
 
 3293                    if (count($question[
"constraints"])) {
 
 3295                        foreach ($question[
"constraints"] as $constraint) {
 
 3297                                "sourceref" => $question[
"question_id"],
 
 3298                                "destref" => $constraint[
"question"],
 
 3299                                "relation" => $constraint[
"short"],
 
 3300                                "value" => $constraint[
"value"],
 
 3301                                "conjunction" => $constraint[
"conjunction"]
 
 3303                            $a_xml_writer->xmlElement(
"constraint", $attribs);
 
 3308            $a_xml_writer->xmlEndTag(
"constraints");
 
 3312        $a_xml_writer->xmlStartTag(
"metadata");
 
 3314        $custom_properties = array();
 
 3318        $custom_properties[
"pool_usage"] = (int) $this->
getPoolUsage();
 
 3325        $custom_properties[
"mode"] = (int) $this->
getMode();
 
 3327        $custom_properties[
"mode_360_self_rate"] = (int) $this->
get360SelfRaters();
 
 3329        $custom_properties[
"mode_360_results"] = $this->
get360Results();
 
 3330        $custom_properties[
"mode_skill_service"] = (int) $this->
getSkillService();
 
 3338        foreach ($custom_properties as $label => $value) {
 
 3339            $a_xml_writer->xmlStartTag(
"metadatafield");
 
 3340            $a_xml_writer->xmlElement(
"fieldlabel", 
null, $label);
 
 3341            $a_xml_writer->xmlElement(
"fieldentry", 
null, $value);
 
 3342            $a_xml_writer->xmlEndTag(
"metadatafield");
 
 3345        $a_xml_writer->xmlStartTag(
"metadatafield");
 
 3346        $a_xml_writer->xmlElement(
"fieldlabel", 
null, 
"SCORM");
 
 3349        $md->toXml($writer);
 
 3350        $metadata = $writer->xmlDumpMem();
 
 3351        $a_xml_writer->xmlElement(
"fieldentry", 
null, $metadata);
 
 3352        $a_xml_writer->xmlEndTag(
"metadatafield");
 
 3354        $a_xml_writer->xmlEndTag(
"metadata");
 
 3355        $a_xml_writer->xmlEndTag(
"survey");
 
 3357        $attribs = array(
"id" => $this->
getId());
 
 3358        $a_xml_writer->xmlStartTag(
"surveyquestions", $attribs);
 
 3360        foreach ($pages as $question_array) {
 
 3361            if (count($question_array) > 1) {
 
 3362                $attribs = array(
"id" => $question_array[0][
"question_id"]);
 
 3363                $attribs = array(
"showQuestiontext" => $question_array[0][
"questionblock_show_questiontext"],
 
 3364                    "showBlocktitle" => $question_array[0][
"questionblock_show_blocktitle"]);
 
 3365                $a_xml_writer->xmlStartTag(
"questionblock", $attribs);
 
 3366                if (strlen($question_array[0][
"questionblock_title"])) {
 
 3367                    $a_xml_writer->xmlElement(
"questionblocktitle", 
null, $question_array[0][
"questionblock_title"]);
 
 3370            foreach ($question_array as $question) {
 
 3371                if (strlen($question[
"heading"])) {
 
 3372                    $a_xml_writer->xmlElement(
"textblock", 
null, $question[
"heading"]);
 
 3378                if ($questionObject !== 
false) {
 
 3379                    $questionObject->insertXML($a_xml_writer, 
false);
 
 3382            if (count($question_array) > 1) {
 
 3383                $a_xml_writer->xmlEndTag(
"questionblock");
 
 3387        $a_xml_writer->xmlEndTag(
"surveyquestions");
 
 3388        $a_xml_writer->xmlEndTag(
"surveyobject");
 
 3389        $xml = $a_xml_writer->xmlDumpMem(
false);
 
 3402        if ($question_id < 1) {
 
 3406        if (strlen($question_type) == 0) {
 
 3410        $question = 
new $question_type();
 
 3411        $question->loadFromDb($question_id);
 
 3423        if (!is_dir($a_dir) || is_int(strpos($a_dir, 
".."))) {
 
 3426        $importDirectory = 
"";
 
 3429        $current_dir = opendir($a_dir);
 
 3431        while ($entryname = readdir($current_dir)) {
 
 3432            $files[] = $entryname;
 
 3435        foreach ($files as $file) {
 
 3436            if (is_dir($a_dir . 
"/" . $file) and ($file != 
"." and $file != 
"..")) {
 
 3438                $importDirectory = $a_dir . 
"/" . $file;
 
 3441        closedir($current_dir);
 
 3442        if (strlen($importDirectory)) {
 
 3444            $current_dir = opendir($importDirectory);
 
 3446            while ($entryname = readdir($current_dir)) {
 
 3447                $files[] = $entryname;
 
 3449            foreach ($files as $file) {
 
 3450                if (@is_file($importDirectory . 
"/" . $file) &&
 
 3451                    ($file != 
"." && $file != 
"..") &&
 
 3452                    (preg_match(
"/^[0-9]{10}__[0-9]+__(svy_)*[0-9]+\.[A-Za-z]{1,3}$/", $file) ||
 
 3453                        preg_match(
"/^[0-9]{10}__[0-9]+__(survey__)*[0-9]+\.[A-Za-z]{1,3}$/", $file))) {
 
 3455                    $xmlFile = $importDirectory . 
"/" . $file;
 
 3459        return array(
"dir" => $importDirectory, 
"xml" => $xmlFile);
 
 3472        if ($svy_qpl_id < 1) {
 
 3476        $source = $file_info[
"tmp_name"];
 
 3478        if ((
$source == 
'none') || (!
$source) || $file_info[
"error"] > UPLOAD_ERR_OK) {
 
 3479            $error = $this->lng->txt(
"import_no_file_selected");
 
 3484        if ((strcmp($file_info[
"type"], 
"text/xml") == 0) || (strcmp($file_info[
"type"], 
"application/xml") == 0)) {
 
 3485            $this->log->debug(
"isXML");
 
 3489        $suffix = pathinfo($file_info[
"name"]);
 
 3490        if (strcmp(strtolower($suffix[
"extension"]), 
"zip") == 0) {
 
 3491            $this->log->debug(
"isZip");
 
 3494        if (!$isXml && !$isZip) {
 
 3495            $error = $this->lng->txt(
"import_wrong_file_type");
 
 3496            $this->log->debug(
"Survey: Import error. Filetype was \"" . $file_info[
"type"] . 
"\"");
 
 3498        if (strlen(
$error) == 0) {
 
 3501            $import_subdir = 
"";
 
 3504                $importfile = $import_dir . 
"/" . $file_info[
"name"];
 
 3508                if (!((strlen($found[
"dir"]) > 0) && (strlen($found[
"xml"]) > 0))) {
 
 3509                    $error = $this->lng->txt(
"wrong_import_file_structure");
 
 3512                $importfile = $found[
"xml"];
 
 3513                $import_subdir = $found[
"dir"];
 
 3515                $importfile = tempnam($import_dir, 
"survey_import");
 
 3519            $this->log->debug(
"Import file = $importfile");
 
 3520            $this->log->debug(
"Import subdir = $import_subdir");
 
 3522            $fh = fopen($importfile, 
"r");
 
 3524                $error = $this->lng->txt(
"import_error_opening_file");
 
 3527            $xml = fread($fh, filesize($importfile));
 
 3530                $error = $this->lng->txt(
"import_error_closing_file");
 
 3535            if (strpos(
$xml, 
"questestinterop")) {
 
 3538                $this->log->debug(
"survey id = " . $this->
getId());
 
 3539                $this->log->debug(
"question pool id = " . $svy_qpl_id);
 
 3542                $config = $imp->getConfig(
"Modules/Survey");
 
 3543                $config->setQuestionPoolID($svy_qpl_id);
 
 3544                $imp->getMapping()->addMapping(
"Modules/Survey", 
"svy", 0, $this->
getId());
 
 3545                $imp->importFromDirectory($import_subdir, 
"svy", 
"Modules/Survey");
 
 3546                $this->log->debug(
"config(Modules/survey)->getQuestionPoolId =" . 
$config->getQuestionPoolID());
 
 3551                $import->setSurveyObject($this);
 
 3552                $import->setXMLContent(
$xml);
 
 3553                $import->startParsing();
 
 3556            if (is_array(
$_SESSION[
"import_mob_xhtml"])) {
 
 3557                foreach (
$_SESSION[
"import_mob_xhtml"] as $mob) {
 
 3558                    $importfile = $import_subdir . 
"/" . $mob[
"uri"];
 
 3559                    if (file_exists($importfile)) {
 
 3560                        if (!$mob[
"type"]) {
 
 3561                            $mob[
"type"] = 
"svy:html";
 
 3567                        if ($mob[
"type"] == 
"svy:html") {
 
 3569                            $this->
setIntroduction(str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $this->getIntroduction()));
 
 3570                            $this->
setOutro(str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $this->getOutro()));
 
 3573                        elseif ($import->questions[$mob[
"id"]]) {
 
 3574                            $new_qid = $import->questions[$mob[
"id"]];
 
 3577                            $qtext = $new_question->getQuestiontext();
 
 3579                            $qtext = str_replace(
"src=\"" . $mob[
"mob"] . 
"\"", 
"src=\"" . 
"il_" . IL_INST_ID . 
"_mob_" . $media_object->getId() . 
"\"", $qtext);
 
 3581                            $new_question->setQuestiontext($qtext);
 
 3582                            $new_question->saveToDb();
 
 3585                            if ($new_question->getOriginalId()) {
 
 3587                                $pool_question->setQuestiontext($qtext);
 
 3588                                $pool_question->saveToDb();
 
 3593                        $ilLog->write(
"Error: Could not open XHTML mob file for test introduction during test import. File $importfile does not exist!");
 
 3615    public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = 
false)
 
 3625        $newObj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
 
 3627        $newObj->updateMetaData();
 
 3631        $newObj->setOutro($this->
getOutro());
 
 3678        $question_pointer = array();
 
 3682        foreach ($this->questions as $key => $question_id) {
 
 3688                $question->setObjId($newObj->getId());
 
 3689                $question->saveToDb($original_id);
 
 3690                $newObj->questions[$key] = $question->getId();
 
 3691                $question_pointer[$question_id] = $question->getId();
 
 3692                $mapping[$question_id] = $question->getId();
 
 3699        if (!$cp_options->isRootNode($this->getRefId())) {
 
 3703        $newObj->saveToDb();
 
 3704        $newObj->cloneTextblocks($mapping);
 
 3712            foreach ($mapping as $src_qst_id => $tgt_qst_id) {
 
 3713                $qst_skill = $src_skills->getSkillForQuestion($src_qst_id);
 
 3715                    $tgt_skills->addQuestionSkillAssignment($tgt_qst_id, $qst_skill[
"base_skill_id"], $qst_skill[
"tref_id"]);
 
 3721        $questionblocks = array();
 
 3722        $questionblock_questions = array();
 
 3724            "SELECT * FROM svy_qblk_qst WHERE survey_fi = %s",
 
 3730                array_push($questionblock_questions, $row);
 
 3731                $questionblocks[$row[
"questionblock_fi"]] = $row[
"questionblock_fi"];
 
 3735        foreach ($questionblocks as $key => $value) {
 
 3737            $questionblock_id = 
self::_addQuestionblock($questionblock[
"title"], $questionblock[
"owner_fi"], $questionblock[
"show_questiontext"], $questionblock[
"show_blocktitle"]);
 
 3738            $questionblocks[$key] = $questionblock_id;
 
 3741        foreach ($questionblock_questions as $key => $value) {
 
 3742            if ($questionblocks[$value[
"questionblock_fi"]] &&
 
 3743                $question_pointer[$value[
"question_fi"]]) {
 
 3744                $next_id = 
$ilDB->nextId(
'svy_qblk_qst');
 
 3745                $affectedRows = 
$ilDB->manipulateF(
 
 3746                    "INSERT INTO svy_qblk_qst (qblk_qst_id, survey_fi, questionblock_fi, question_fi) " .
 
 3747                    "VALUES (%s, %s, %s, %s)",
 
 3748                    array(
'integer',
'integer',
'integer',
'integer'),
 
 3749                    array($next_id, $newObj->getSurveyId(), $questionblocks[$value[
"questionblock_fi"]], $question_pointer[$value[
"question_fi"]])
 
 3756        $newConstraints = array();
 
 3757        foreach ($constraints as $key => $constraint) {
 
 3758            if ($question_pointer[$constraint[
"for_question"]] &&
 
 3759                $question_pointer[$constraint[
"question"]]) {
 
 3760                if (!array_key_exists($constraint[
'id'], $newConstraints)) {
 
 3761                    $constraint_id = $newObj->addConstraint($question_pointer[$constraint[
"question"]], $constraint[
"relation_id"], $constraint[
"value"], $constraint[
'conjunction']);
 
 3762                    $newConstraints[$constraint[
'id']] = $constraint_id;
 
 3764                $newObj->addConstraintToQuestion($question_pointer[$constraint[
"for_question"]], $newConstraints[$constraint[
'id']]);
 
 3770        $obj_settings->cloneSettings($newObj->getId());
 
 3771        unset($obj_settings);
 
 3780            "SELECT * FROM svy_svy_qst WHERE question_fi = %s",
 
 3786            return $row[
"heading"];
 
 3799        foreach ($mapping as $original_id => $new_id) {
 
 3816        if (!is_writable($svy_data_dir)) {
 
 3817            throw new ilSurveyException(
"Survey Data Directory (" . $svy_data_dir . 
") not writeable.");
 
 3821        $svy_dir = $svy_data_dir . 
"/svy_" . $this->
getId();
 
 3823        if (!@is_dir($svy_dir)) {
 
 3827        $export_dir = $svy_dir . 
"/export";
 
 3829        if (!@is_dir($export_dir)) {
 
 3856        if (!is_writable($svy_data_dir)) {
 
 3857            throw new ilSurveyException(
"Survey Data Directory (" . $svy_data_dir . 
") not writeable.");
 
 3861        $svy_dir = $svy_data_dir . 
"/svy_" . $this->
getId();
 
 3863        if (!@is_dir($svy_dir)) {
 
 3868        $import_dir = $svy_dir . 
"/import";
 
 3870        if (!@is_dir($import_dir)) {
 
 3881            "/svy_" . $this->
getId() . 
"/import";
 
 3882        if (!is_dir($import_dir)) {
 
 3885        if (@is_dir($import_dir)) {
 
 3896            $affectedRows = 
$ilDB->manipulateF(
 
 3897                "UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
 
 3898                array(
'text',
'integer',
'integer'),
 
 3899                array($heading, $this->
getSurveyId(), $insertbefore)
 
 3902            $affectedRows = 
$ilDB->manipulateF(
 
 3903                "UPDATE svy_svy_qst SET heading=%s WHERE survey_fi=%s AND question_fi=%s",
 
 3904                array(
'text',
'integer',
'integer'),
 
 3915            "SELECT anonymous_id FROM svy_anonymous WHERE survey_key = %s AND survey_fi = %s",
 
 3916            array(
'text',
'integer'),
 
 3919        return (
$result->numRows() == 1) ? true : 
false;
 
 3926        if ($user_id == ANONYMOUS_USER_ID) {
 
 3931            $ilDB->manipulate(
"UPDATE svy_anonymous" .
 
 3932                " SET user_key = " . 
$ilDB->quote(md5($user_id), 
"text") .
 
 3933                " WHERE survey_key = " . 
$ilDB->quote($code, 
"text"));
 
 3942            "SELECT finished_id FROM svy_finished WHERE anonymous_id = %s AND survey_fi = %s",
 
 3943            array(
'text',
'integer'),
 
 3946        return (
$result->numRows() == 1) ? true : 
false;
 
 3975        $sql = 
"SELECT svy_anonymous.*, svy_finished.state" .
 
 3976            " FROM svy_anonymous" .
 
 3977            " LEFT JOIN svy_finished ON (svy_anonymous.survey_key = svy_finished.anonymous_id)" .
 
 3978            " WHERE svy_anonymous.survey_fi = " . 
$ilDB->quote($this->
getSurveyId(), 
"integer") .
 
 3979            " AND svy_anonymous.user_key IS NULL";
 
 3982            $sql .= 
" AND " . 
$ilDB->in(
"svy_anonymous.survey_key", $a_codes, 
"", 
"text");
 
 3984            $sql .= 
" AND " . 
$ilDB->in(
"svy_anonymous.anonymous_id", $a_ids, 
"", 
"text");
 
 3991        $titles[] = 
'"' . 
$lng->txt(
"survey_code") . 
'"';
 
 3992        $titles[] = 
'"' . 
$lng->txt(
"email") . 
'"';
 
 3993        $titles[] = 
'"' . 
$lng->txt(
"lastname") . 
'"';
 
 3994        $titles[] = 
'"' . 
$lng->txt(
"firstname") . 
'"';
 
 3995        $titles[] = 
'"' . 
$lng->txt(
"create_date") . 
'"';
 
 3996        $titles[] = 
'"' . 
$lng->txt(
"used") . 
'"';
 
 3997        $titles[] = 
'"' . 
$lng->txt(
"mail_sent_short") . 
'"';
 
 3998        $titles[] = 
'"' . 
$lng->txt(
"survey_code_url") . 
'"';
 
 3999        $export[] = implode(
";", $titles);
 
 4002        $default_lang = 
$ilUser->getPref(
"survey_code_language");
 
 4005            $item[] = $row[
"survey_key"];
 
 4007            if ($row[
"externaldata"]) {
 
 4008                $ext = unserialize($row[
"externaldata"]);
 
 4009                $item[] = $ext[
"email"];
 
 4010                $item[] = $ext[
"lastname"];
 
 4011                $item[] = $ext[
"firstname"];
 
 4023            $item[] = ($row[
"sent"]) ? 1 : 0;
 
 4025            $params = array(
"accesscode" => $row[
"survey_key"]);
 
 4026            if ($default_lang) {
 
 4027                $params[
"lang"] = $default_lang;
 
 4031            $export[] = 
'"' . implode(
'";"', $item) . 
'"';
 
 4033        return implode(
"\n", $export);
 
 4049        $sql = 
"SELECT svy_anonymous.*, svy_finished.state" .
 
 4050            " FROM svy_anonymous" .
 
 4051            " LEFT JOIN svy_finished ON (svy_anonymous.survey_key = svy_finished.anonymous_id)" .
 
 4052            " WHERE svy_anonymous.survey_fi = " . 
$ilDB->quote($this->
getSurveyId(), 
"integer") 
 
 4056            $sql .= 
" AND " . 
$ilDB->in(
"svy_anonymous.anonymous_id", $ids, 
"", 
"integer");
 
 4059        $sql .= 
" ORDER BY tstamp, survey_key ASC";
 
 4068                    $params = array(
"accesscode" => $row[
"survey_key"]);
 
 4070                        $params[
"lang"] = 
$lang;
 
 4077                    'id' => $row[
"anonymous_id"],
 
 4078                    'code' => $row[
"survey_key"],
 
 4079                    'date' => $row[
"tstamp"],
 
 4081                    'sent' => $row[
'sent'],
 
 4088                if ($row[
"externaldata"]) {
 
 4089                    $ext = unserialize($row[
"externaldata"]);
 
 4090                    $item[
'email'] = $ext[
'email'];
 
 4091                    $item[
'last_name'] = $ext[
'lastname'];
 
 4092                    $item[
'first_name'] = $ext[
'firstname'];
 
 4095                array_push($codes, $item);
 
 4105            "SELECT finished_id FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
 
 4106            array(
'integer',
'text'),
 
 4109        return (
$result->numRows() > 0) ? true : 
false;
 
 4116            "SELECT anonymous_id FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
 
 4117            array(
'integer',
'text'),
 
 4120        return (
$result->numRows() > 0) ? false : 
true;
 
 4129        for (
$i = 0; 
$i < $nrOfCodes; 
$i++) {
 
 4130            $next_id = 
$ilDB->nextId(
'svy_anonymous');
 
 4132                "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, tstamp) " .
 
 4133                "VALUES (%s, %s, %s, %s)",
 
 4134                array(
'integer',
'text',
'integer',
'integer'),
 
 4147        $next_id = 
$ilDB->nextId(
'svy_anonymous');
 
 4149            "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) " .
 
 4150            "VALUES (%s, %s, %s, %s, %s)",
 
 4151            array(
'integer',
'text',
'integer',
'text',
'integer'),
 
 4152            array($next_id, $a_anonymize_key, $this->
getSurveyId(), serialize($a_data), $a_created)
 
 4161        foreach (
$data as $dataset) {
 
 4163            $next_id = 
$ilDB->nextId(
'svy_anonymous');
 
 4164            $affectedRows = 
$ilDB->manipulateF(
 
 4165                "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, externaldata, tstamp) " .
 
 4166                "VALUES (%s, %s, %s, %s, %s)",
 
 4167                array(
'integer',
'text',
'integer',
'text',
'integer'),
 
 4168                array($next_id, $anonymize_key, $this->
getSurveyId(), serialize($dataset), time())
 
 4184        $check_finished = ($not_sent > 1);
 
 4187        $mail = 
new ilMail(ANONYMOUS_USER_ID);
 
 4189        foreach ($recipients as 
$data) {
 
 4192                switch ((
int) $not_sent) {
 
 4194                        $do_send = !(bool) 
$data[
'sent'];
 
 4198                        $do_send = 
$data[
'finished'];
 
 4202                        $do_send = !
$data[
'finished'];
 
 4216                            "accesscode" => 
$data[
"code"],
 
 4220                    $messagetext = str_replace(
'[url]', 
$url, $messagetext);
 
 4221                    foreach (
$data as $key => $value) {
 
 4222                        $messagetext = str_replace(
'[' . $key . 
']', $value, $messagetext);
 
 4240            "UPDATE svy_anonymous SET sent = %s WHERE survey_fi = %s AND externaldata IS NOT NULL",
 
 4241            array(
'integer',
'integer'),
 
 4250            "SELECT survey_key code, externaldata, sent FROM svy_anonymous WHERE survey_fi = %s",
 
 4256            if (!$row[
'externaldata']) {
 
 4260            $externaldata = unserialize($row[
'externaldata']);
 
 4261            if (!$externaldata[
'email']) {
 
 4265            $externaldata[
'code'] = $row[
'code'];
 
 4266            $externaldata[
'sent'] = $row[
'sent'];
 
 4268            if ($a_check_finished) {
 
 4274            array_push(
$res, $externaldata);
 
 4287            "SELECT state FROM svy_finished WHERE survey_fi = %s AND anonymous_id = %s",
 
 4288            array(
'integer',
'text'),
 
 4292        $row = $this->db->fetchAssoc(
$result);
 
 4294        return $row[
'state'];
 
 4306        if (strlen($survey_code) > 0) {
 
 4307            $affectedRows = 
$ilDB->manipulateF(
 
 4308                "DELETE FROM svy_anonymous WHERE survey_fi = %s AND survey_key = %s",
 
 4309                array(
'integer', 
'text'),
 
 4326            "SELECT survey_key FROM svy_anonymous WHERE survey_fi = %s AND user_key = %s",
 
 4327            array(
'integer',
'text'),
 
 4332            $access_code = $row[
"survey_key"];
 
 4334        return $access_code;
 
 4349        $next_id = 
$ilDB->nextId(
'svy_anonymous');
 
 4350        $affectedRows = 
$ilDB->manipulateF(
 
 4351            "INSERT INTO svy_anonymous (anonymous_id, survey_key, survey_fi, user_key, tstamp) " .
 
 4352            "VALUES (%s, %s, %s, %s, %s)",
 
 4353            array(
'integer',
'text', 
'integer', 
'text', 
'integer'),
 
 4354            array($next_id, $access_code, $this->
getSurveyId(), md5($user_id), time())
 
 4366        $codestring = 
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
 4369        for (
$i = 1; 
$i <= 5; 
$i++) {
 
 4370            $index = mt_rand(0, strlen($codestring) - 1);
 
 4371            $code .= substr($codestring, 
$index, 1);
 
 4385            "SELECT tstamp FROM svy_answer WHERE active_fi = %s ORDER BY tstamp DESC",
 
 4391            return $row[
"tstamp"];
 
 4394                "SELECT tstamp FROM svy_finished WHERE finished_id = %s",
 
 4400                return $row[
"tstamp"];
 
 4426        if (preg_match(
"/<[^>]*?>/", $a_text)) {
 
 4441    public function addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag = 
true, $add_mobs = 
true, $attribs = 
null)
 
 4443        $a_xml_writer->xmlStartTag(
"material", $attribs);
 
 4445            "type" => 
"text/plain" 
 4447        if ($this->
isHTML($a_material)) {
 
 4448            $attrs[
"type"] = 
"text/xhtml";
 
 4451        $a_xml_writer->xmlElement(
"mattext", $attrs, $mattext);
 
 4455            foreach (
$mobs as $mob) {
 
 4456                $mob_id = 
"il_" . IL_INST_ID . 
"_mob_" . $mob;
 
 4457                if (strpos($mattext, $mob_id) !== 
false) {
 
 4461                        "uri" => 
"objects/" . 
"il_" . IL_INST_ID . 
"_mob_" . $mob . 
"/" . $mob_obj->getTitle(),
 
 4462                        "type" => 
"svy:html",
 
 4463                        "id" => $this->getId()
 
 4465                    $a_xml_writer->xmlElement(
"matimage", $imgattrs, 
null);
 
 4469        if ($close_material_tag) {
 
 4470            $a_xml_writer->xmlEndTag(
"material");
 
 4485            if ($this->surveyCodeSecurity == 
false) {
 
 4501        if (extension_loaded(
"tidy")) {
 
 4504                "output-xml" => 
true,
 
 4505                "numeric-entities" => 
true 
 4508            $tidy->parseString($print_output, 
$config, 
'utf8');
 
 4509            $tidy->cleanRepair();
 
 4510            $print_output = tidy_get_output($tidy);
 
 4511            $print_output = preg_replace(
"/^.*?(<html)/", 
"\\1", $print_output);
 
 4513            $print_output = str_replace(
" ", 
" ", $print_output);
 
 4514            $print_output = str_replace(
"⊗", 
"X", $print_output);
 
 4517            $print_output = str_replace(
">", 
"~|gt|~", $print_output);               
 
 4518            $print_output = str_replace(
"<", 
"~|lt|~", $print_output);
 
 4519            $print_output = str_replace(
" ", 
"~|nbsp|~", $print_output);
 
 4520            $print_output = preg_replace(
'/&(?!amp)/', 
'&', $print_output);
 
 4521            $print_output = str_replace(
"~|nbsp|~", 
" ", $print_output);
 
 4522            $print_output = str_replace(
"~|gt|~", 
">", $print_output);
 
 4523            $print_output = str_replace(
"~|lt|~", 
"<", $print_output);
 
 4525        $xsl = file_get_contents(
"./Modules/Survey/xml/question2fo.xsl");
 
 4529            'font-family="Helvetica, unifont"',
 
 4530            'font-family="' . 
$GLOBALS[
'ilSetting']->
get(
'rpc_pdf_font', 
'Helvetica, unifont') . 
'"',
 
 4533        $args = array( 
'/_xml' => $print_output, 
'/_xsl' => $xsl );
 
 4537            $output = xslt_process($xh, 
"arg:/_xml", 
"arg:/_xsl", 
null, $args, $params);
 
 4538        } 
catch (Exception 
$e) {
 
 4539            $this->log->error(
"Print XSLT failed:");
 
 4540            $this->log->error(
"Content: " . $print_output);
 
 4541            $this->log->error(
"Xsl: " . $xsl);
 
 4561        $fp = fopen($fo_file, 
"w");
 
 4569        } 
catch (Exception 
$e) {
 
 4570            $ilLog->write(__METHOD__ . 
': ' . 
$e->getMessage());
 
 4584        if ($ilPluginAdmin->isActive(
IL_COMP_MODULE, 
"SurveyQuestionPool", 
"svyq", $a_pname)) {
 
 4611        if (!is_array($ids) || count($ids) == 0) {
 
 4615        $result = 
$ilDB->query(
"SELECT usr_id, login, lastname, firstname FROM usr_data WHERE " . 
$ilDB->in(
'usr_id', $ids, 
false, 
'integer') . 
" ORDER BY login");
 
 4616        $result_array = array();
 
 4618            $result_array[$row[
"usr_id"]] = $row;
 
 4620        return $result_array;
 
 4630        $this->mailnotification = ($a_notification) ? 
true : 
false;
 
 4640        $this->mailaddresses = $a_addresses;
 
 4650        $this->mailparticipantdata = $a_data;
 
 4660        $affectedRows = 
$ilDB->manipulateF(
 
 4661            "INSERT INTO svy_times (id, finished_fi, entered_page, left_page, first_question) VALUES (%s, %s, %s, %s,%s)",
 
 4662            array(
'integer',
'integer', 
'integer', 
'integer', 
'integer'),
 
 4663            array(
$id, $finished_id, $time, 
null, $first_question)
 
 4671        $affectedRows = 
$ilDB->manipulateF(
 
 4672            "UPDATE svy_times SET left_page = %s WHERE finished_fi = %s AND entered_page = %s",
 
 4673            array(
'integer', 
'integer', 
'integer'),
 
 4674            array($time, $finished_id, 
$_SESSION[
'svy_entered_page'])
 
 4684            "SELECT * FROM svy_times WHERE finished_fi = %s",
 
 4690            if ($row[
'left_page'] > 0 && $row[
'entered_page'] > 0) {
 
 4691                $total += $row[
'left_page'] - $row[
'entered_page'];
 
 4709        if (
sizeof($this->questions) == 
sizeof($a_order)) {
 
 4710            $this->questions = array_flip($a_order);
 
 4711            $this->saveQuestionsToDB();
 
 4722        $this->pool_usage = (bool) $a_value;
 
 4734        if ($template_settings) {
 
 4736            $template_settings = $template_settings->getSettings();
 
 4737            $template_settings = $template_settings[
"use_pool"];
 
 4738            if ($template_settings && $template_settings[
"hide"]) {
 
 4739                $use_pool = (bool) $template_settings[
"value"];
 
 4757        $template_settings = $template->getSettings();
 
 4759        if ($template_settings) {
 
 4760            if ($template_settings[
"show_question_titles"] !== 
null) {
 
 4761                if ($template_settings[
"show_question_titles"][
"value"]) {
 
 4768            if ($template_settings[
"use_pool"] !== 
null) {
 
 4769                if ($template_settings[
"use_pool"][
"value"]) {
 
 4788            $codes = (bool) $template_settings[
"acc_codes"][
"value"];
 
 4789            $anon = (bool) $template_settings[
"anonymization_options"][
"value"];
 
 4819    public function updateCode($a_id, $a_email, $a_last_name, $a_first_name, $a_sent)
 
 4823        $a_email = trim($a_email);
 
 4830        $data = array(
"email" => $a_email,
 
 4831            "lastname" => trim($a_last_name),
 
 4832            "firstname" => trim($a_first_name));
 
 4835            "externaldata" => array(
"text", serialize(
$data)),
 
 4836            "sent" => array(
"integer", $a_sent)
 
 4842            array(
"anonymous_id" => array(
"integer", $a_id))
 
 4863        $this->mode_360_self_eval = (bool) $a_value;
 
 4873        $this->mode_360_self_appr = (bool) $a_value;
 
 4883        $this->mode_360_self_rate = (bool) $a_value;
 
 4893        $this->mode_360_results = (int) $a_value;
 
 4909            $a_user_id != ANONYMOUS_USER_ID) {
 
 4911                "obj_id" => array(
"integer", $this->
getSurveyId()),
 
 4912                "user_id" => array(
"integer", $a_user_id)
 
 4914            $ilDB->insert(
"svy_360_appr", $fields);
 
 4917            if (
$access->checkAccessOfUser($a_user_id, 
"read", 
"", $this->getRefId())) {
 
 4931        $ntf->setLangModules(array(
"svy", 
"survey"));
 
 4933        $ntf->setGotoLangId(
'url');
 
 4936        $lng = $ntf->getUserLanguage($a_user_id);
 
 4938        $ntf->setIntroductionLangId(
"svy_user_added_360_appraisee_mail");
 
 4939        $subject = str_replace(
"%1", $this->
getTitle(), 
$lng->txt(
"svy_user_added_360_appraisee"));
 
 4942        $mail = 
new ilMail(ANONYMOUS_USER_ID);
 
 4948            $ntf->composeAndGetMessage($a_user_id, 
null, 
"read", 
true),
 
 4961        $ntf->setLangModules(array(
"svy", 
"survey"));
 
 4963        $ntf->setGotoLangId(
'url');
 
 4966        $lng = $ntf->getUserLanguage($a_user_id);
 
 4968        $ntf->setIntroductionLangId(
"svy_user_added_360_appraisee_close_mail");
 
 4969        $subject = str_replace(
"%1", $this->
getTitle(), 
$lng->txt(
"svy_user_added_360_appraisee"));
 
 4972        $mail = 
new ilMail(ANONYMOUS_USER_ID);
 
 4978            $ntf->composeAndGetMessage($a_user_id, 
null, 
"read", 
true),
 
 4991        $ntf->setLangModules(array(
"svy", 
"survey"));
 
 4993        $ntf->setGotoLangId(
'url');
 
 4996        $lng = $ntf->getUserLanguage($a_user_id);
 
 4998        $ntf->setIntroductionLangId(
"svy_user_added_360_rater_mail");
 
 4999        $subject = str_replace(
"%1", $this->
getTitle(), 
$lng->txt(
"svy_user_added_360_rater"));
 
 5003        $mail = 
new ilMail(ANONYMOUS_USER_ID);
 
 5009            $ntf->composeAndGetMessage($a_user_id, 
null, 
"read", 
true),
 
 5018        $set = 
$ilDB->query(
"SELECT user_id" .
 
 5019            " FROM svy_360_appr" .
 
 5020            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5021            " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer"));
 
 5022        return (
bool) 
$ilDB->numRows($set);
 
 5029        $set = 
$ilDB->query(
"SELECT has_closed" .
 
 5030            " FROM svy_360_appr" .
 
 5031            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5032            " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer"));
 
 5033        $row = 
$ilDB->fetchAssoc($set);
 
 5034        return $row[
"has_closed"];
 
 5041        $ilDB->manipulate(
"DELETE FROM svy_360_appr" .
 
 5042            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5043            " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer"));
 
 5045        $set = 
$ilDB->query(
"SELECT user_id" .
 
 5046            " FROM svy_360_rater" .
 
 5047            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5048            " AND appr_id = " . 
$ilDB->quote($a_user_id, 
"integer"));
 
 5049        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 5064        $set = 
$ilDB->query(
"SELECT * FROM svy_360_appr" .
 
 5065            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer"));
 
 5066        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 5074            foreach ($raters as $rater) {
 
 5075                if ($rater[
"finished"]) {
 
 5079            $res[$row[
"user_id"]][
"finished"] = $finished . 
"/" . 
sizeof($raters);
 
 5080            $res[$row[
"user_id"]][
"closed"] = $row[
"has_closed"];
 
 5086    public function addRater($a_appraisee_id, $a_user_id, $a_anonymous_id = 0)
 
 5094            !$this->
isRater($a_appraisee_id, $a_user_id, $a_anonymous_id)) {
 
 5096                "obj_id" => array(
"integer", $this->
getSurveyId()),
 
 5097                "appr_id" => array(
"integer", $a_appraisee_id),
 
 5098                "user_id" => array(
"integer", $a_user_id),
 
 5099                "anonymous_id" => array(
"integer", $a_anonymous_id)
 
 5101            $ilDB->insert(
"svy_360_rater", $fields);
 
 5104            if (
$access->checkAccessOfUser($a_user_id, 
"read", 
"", $this->getRefId())) {
 
 5110    public function isRater($a_appraisee_id, $a_user_id, $a_anonymous_id = 0)
 
 5117            (!$a_appraisee_id || $a_appraisee_id == $a_user_id)) {
 
 5123        $sql = 
"SELECT user_id" .
 
 5124            " FROM svy_360_rater" .
 
 5126            " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
 5127            " AND anonymous_id = " . 
$ilDB->quote($a_anonymous_id, 
"integer");
 
 5128        if ($a_appraisee_id) {
 
 5129            $sql .= 
" AND appr_id = " . 
$ilDB->quote($a_appraisee_id, 
"integer");
 
 5131        $set = 
$ilDB->query($sql);
 
 5132        return (
bool) 
$ilDB->numRows($set);
 
 5135    public function deleteRater($a_appraisee_id, $a_user_id, $a_anonymous_id = 0)
 
 5144        $ilDB->manipulate(
"DELETE FROM svy_360_rater" .
 
 5145            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5146            " AND appr_id = " . 
$ilDB->quote($a_appraisee_id, 
"integer") .
 
 5147            " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
 5148            " AND anonymous_id = " . 
$ilDB->quote($a_anonymous_id, 
"integer"));
 
 5155        $res = $anonymous_ids = array();
 
 5157        $set = 
$ilDB->query(
"SELECT * FROM svy_360_rater" .
 
 5158            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5159            " AND appr_id = " . 
$ilDB->quote($a_appraisee_id, 
"integer"));
 
 5160        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 5161            if ($row[
"anonymous_id"]) {
 
 5162                $res[
"a" . $row[
"anonymous_id"]] = array(
 
 5163                    "lastname" => 
"unknown code " . $row[
"anonymous_id"],
 
 5164                    "sent" => $row[
"mail_sent"],
 
 5167                $anonymous_ids[] = $row[
"anonymous_id"];
 
 5173                $name[
"sent"] = $row[
"mail_sent"];
 
 5179        if (
sizeof($anonymous_ids)) {
 
 5181            foreach (
$data as $item) {
 
 5182                if (isset(
$res[
"a" . $item[
"id"]])) {
 
 5183                    $res[
"a" . $item[
"id"]] = array(
 
 5184                        "user_id" => 
"a" . $item[
"id"],
 
 5185                        "lastname" => $item[
"last_name"],
 
 5186                        "firstname" => $item[
"first_name"],
 
 5187                        "name" => $item[
"last_name"] . 
", " . $item[
"first_name"],
 
 5189                        "email" => $item[
"email"],
 
 5190                        "code" => $item[
"code"],
 
 5191                        "href" => $item[
"href"],
 
 5192                        "sent" => 
$res[
"a" . $item[
"id"]][
"sent"],
 
 5208        $sql = 
"SELECT appr_id FROM svy_360_rater" .
 
 5212            $sql .= 
" AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer");
 
 5214            $sql .= 
" AND anonymous_id = " . 
$ilDB->quote($a_anonymous_id, 
"integer");
 
 5217        $set = 
$ilDB->query($sql);
 
 5218        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 5219            $res[] = $row[
"appr_id"];
 
 5225            !in_array($a_user_id, 
$res)) {
 
 5226            $res[] = $a_user_id;
 
 5236        $set = 
$ilDB->query(
"SELECT anonymous_id FROM svy_anonymous" .
 
 5237                " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5238                " AND survey_key = " . 
$ilDB->quote($a_code, 
"text"));
 
 5240        return $res[
"anonymous_id"];
 
 5247        $sql = 
"SELECT * FROM svy_finished" .
 
 5249            " AND appr_id = " . 
$ilDB->quote($appr_id, 
"integer");
 
 5251            $sql .= 
" AND user_fi = " . 
$ilDB->quote($user_id, 
"integer");
 
 5253            $sql .= 
" AND anonymous_id = " . 
$ilDB->quote($anonymous_code, 
"text");
 
 5256        if (
$result->numRows() == 0) {
 
 5260            return (
int) $row[
"state"];
 
 5276                    $user_id != ANONYMOUS_USER_ID &&
 
 5277                    $this->
isRater(0, $user_id)) {
 
 5285        } elseif ($user_id == ANONYMOUS_USER_ID ||
 
 5298        $sql = 
"SELECT * FROM svy_finished" .
 
 5301        if ($user_id != ANONYMOUS_USER_ID) {
 
 5302            $sql .= 
" AND (user_fi = " . 
$ilDB->quote($user_id, 
"integer") .
 
 5303                " OR anonymous_id = " . 
$ilDB->quote($a_code, 
"text") . 
")";
 
 5307            $sql .= 
" AND anonymous_id = " . 
$ilDB->quote($a_code, 
"text");
 
 5309        $set = 
$ilDB->query($sql);
 
 5310        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 5311            $res[$row[
"finished_id"]] = array(
"appr_id" => $row[
"appr_id"],
 
 5312                "user_id" => $row[
"user_fi"],
 
 5313                "code" => $row[
"anonymous_id"],
 
 5314                "finished" => (
bool) $row[
"state"]);
 
 5317        return array(
"code" => $a_code, 
"runs" => 
$res);
 
 5324        if ($a_user_id != ANONYMOUS_USER_ID) {
 
 5325            $set = 
$ilDB->query(
"SELECT sf.anonymous_id FROM svy_finished sf" .
 
 5326                " WHERE sf.survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5327                " AND sf.user_fi = " . 
$ilDB->quote($a_user_id, 
"integer"));
 
 5328            $a_code = 
$ilDB->fetchAssoc($set);
 
 5329            return $a_code[
"anonymous_id"];
 
 5337        $set = 
$ilDB->query(
"SELECT user_fi FROM svy_finished" .
 
 5338            " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5339            " AND anonymous_id = " . 
$ilDB->quote($a_code, 
"text"));
 
 5340        $user_id = 
$ilDB->fetchAssoc($set);
 
 5341        $user_id = $user_id[
"user_fi"];
 
 5343        if ($user_id && ($user_id != $a_user_id || $user_id == ANONYMOUS_USER_ID)) {
 
 5355        $set = 
$ilDB->query(
"SELECT finished_id, user_fi FROM svy_finished" .
 
 5356            " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5357            " AND appr_id = " . 
$ilDB->quote($a_appr_id, 
"integer"));
 
 5358        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 5359            if ($a_exclude_appraisee && $row[
"user_fi"] == $a_appr_id) {
 
 5362            $res[] = $row[
"finished_id"];
 
 5379        $set = 
$ilDB->query(
"SELECT finished_id, user_fi FROM svy_finished" .
 
 5380            " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5381            " AND appr_id = " . 
$ilDB->quote($a_appr_id, 
"integer") .
 
 5382            " AND user_fi = " . 
$ilDB->quote($a_rat_id, 
"integer"));
 
 5383        $row = 
$ilDB->fetchAssoc($set);
 
 5384        return $row[
"finished_id"];
 
 5397        $this->mode_skill_service = $a_val;
 
 5410    public function set360RaterSent($a_appraisee_id, $a_user_id, $a_anonymous_id, $a_tstamp = 
null)
 
 5418        $ilDB->manipulate(
"UPDATE svy_360_rater" .
 
 5419            " SET mail_sent = " . 
$ilDB->quote($a_tstamp, 
"integer") .
 
 5420            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5421            " AND appr_id = " . 
$ilDB->quote($a_appraisee_id, 
"integer") .
 
 5422            " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
 5423            " AND anonymous_id = " . 
$ilDB->quote($a_anonymous_id, 
"integer"));
 
 5434        $ilDB->manipulate(
"UPDATE svy_360_appr" .
 
 5435            " SET has_closed = " . 
$ilDB->quote(time(), 
"integer") .
 
 5436            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5437            " AND user_id = " . 
$ilDB->quote($a_user_id, 
"integer"));
 
 5443            $sskill->writeAndAddAppraiseeSkills($a_user_id);
 
 5447        if (
$user->getId() != $a_user_id) {
 
 5456        $ilDB->manipulate(
"UPDATE svy_360_appr" .
 
 5457            " SET has_closed = " . 
$ilDB->quote(
null, 
"integer") .
 
 5458            " WHERE obj_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer"));
 
 5463        if (!isset(
$_SESSION[
"360_extrtr"][$a_ref_id])) {
 
 5464            $svy = 
new self($a_ref_id);
 
 5467            if ($svy->canStartSurvey(
null, 
true) &&
 
 5468                $svy->get360Mode() &&
 
 5469                $svy->isAnonymousKey($a_code)) {
 
 5470                $anonymous_id = $svy->getAnonymousIdByCode($a_code);
 
 5471                if ($anonymous_id) {
 
 5472                    if (
sizeof($svy->getAppraiseesToRate(
null, $anonymous_id))) {
 
 5473                        $_SESSION[
"360_extrtr"][$a_ref_id] = 
true;
 
 5479            $_SESSION[
"360_extrtr"][$a_ref_id] = 
false;
 
 5483        return $_SESSION[
"360_extrtr"][$a_ref_id];
 
 5498        $this->reminder_status = (bool) $a_value;
 
 5508        $this->reminder_start = $a_value;
 
 5518        $this->reminder_end = $a_value;
 
 5528        $this->reminder_frequency = (int) $a_value;
 
 5538        $this->reminder_target = (int) $a_value;
 
 5548        $this->reminder_last_sent = $a_value;
 
 5557        if ($selectDefault) {
 
 5558            $defaultTemplateId = 0;
 
 5559            $this->getReminderMailTemplates($defaultTemplateId);
 
 5561            if ($defaultTemplateId > 0) {
 
 5562                return $defaultTemplateId;
 
 5571        $this->reminder_tmpl = $a_value;
 
 5581        $this->tutor_ntf_status = (bool) $a_value;
 
 5591        $this->tutor_ntf_recipients = $a_value;
 
 5601        $this->tutor_ntf_target = (int) $a_value;
 
 5611        $this->tutor_res_status = (bool) $a_value;
 
 5621        $this->tutor_res_recipients = $a_value;
 
 5631                $set = 
$ilDB->query(
"SELECT COUNT(*) numall FROM svy_finished" .
 
 5632                    " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5633                    " AND state = " . 
$ilDB->quote(1, 
"integer") .
 
 5634                    " AND " . 
$ilDB->in(
"user_fi", $user_ids, 
"", 
"integer"));
 
 5635                $row = 
$ilDB->fetchAssoc($set);
 
 5636                if ($row[
"numall"] == 
sizeof($user_ids)) {
 
 5656        $rater_ids = array();
 
 5658            $this->log->debug(
"Handle appraisee " . 
$app[
'user_id']);
 
 5666                    $this->log->debug(
"...1");
 
 5669                        $this->log->debug(
"...2");
 
 5670                        if (!is_array($rater_ids[
$app[
'user_id']])) {
 
 5671                            $rater_ids[
$app[
'user_id']] = array();
 
 5673                        if (!in_array(
$app[
"user_id"], $rater_ids[
$app[
'user_id']])) {
 
 5674                            $rater_ids[
$app[
'user_id']][] = 
$app[
"user_id"];
 
 5679                $this->log->debug(
"Check raters.");
 
 5685                        if (!$rater[
"anonymous_id"] && !$rater[
"finished"]) {
 
 5686                            if (!is_array($rater_ids[$rater[
"user_id"]])) {
 
 5687                                $rater_ids[$rater[
"user_id"]] = array();
 
 5689                            if (!in_array(
$app[
"user_id"], $rater_ids[$rater[
"user_id"]])) {
 
 5690                                $rater_ids[$rater[
"user_id"]][] = 
$app[
"user_id"];
 
 5698        $this->log->debug(
"Found raters:" . count($rater_ids));
 
 5700        foreach ($rater_ids as 
$id => 
$app) {
 
 5701            if (
$access->checkAccessOfUser(
$id, 
"read", 
"", $this->getRefId())) {
 
 5714        $this->log->debug(
"Send mail to:" . $a_user_id);
 
 5717        $ntf->setLangModules(array(
"svy", 
"survey"));
 
 5719        $ntf->setGotoLangId(
'url');
 
 5722        $lng = $ntf->getUserLanguage($a_user_id);
 
 5724        $ntf->setIntroductionLangId(
"svy_user_added_360_rater_reminder_mail");
 
 5725        $subject = str_replace(
"%1", $this->
getTitle(), 
$lng->txt(
"svy_user_added_360_rater"));
 
 5727        foreach ($a_appraisee_ids as $appraisee_id) {
 
 5732        $mail = 
new ilMail(ANONYMOUS_USER_ID);
 
 5738            $ntf->composeAndGetMessage($a_user_id, 
null, 
"read", 
true),
 
 5748        if ((
bool) $a_use_invited) {
 
 5749            $user_ids = $this->invitation_manager->getAllForSurvey($this->
getSurveyId());
 
 5751            $parent_grp_ref_id = 
$tree->checkForParentType($this->
getRefId(), 
"grp");
 
 5752            if ($parent_grp_ref_id) {
 
 5754                $user_ids = $part->getMembers();
 
 5756                $parent_crs_ref_id = 
$tree->checkForParentType($this->
getRefId(), 
"crs");
 
 5757                if ($parent_crs_ref_id) {
 
 5759                    $user_ids = $part->getMembers();
 
 5773            $ulng->loadLanguageModule(
'survey');
 
 5775            $subject = sprintf($ulng->txt(
'survey_notification_tutor_subject'), $this->getTitle());
 
 5778            $message .= $ulng->txt(
'survey_notification_tutor_body') . 
":\n\n";
 
 5780            $message .= 
"\n" . $ulng->txt(
'survey_notification_tutor_link') . 
": " . $link;
 
 5782            $mail_obj = 
new ilMail(ANONYMOUS_USER_ID);
 
 5783            $mail_obj->appendInstallationSignature(
true);
 
 5801        $now_with_format = date(
"YmdHis", $now);
 
 5802        $today = date(
"Y-m-d");
 
 5804        $this->log->debug(
"Check status and dates.");
 
 5824        if ($today < $start ||
 
 5825            ($end && $today > $end)) {
 
 5829        $this->log->debug(
"Check access period.");
 
 5834            ($now < $item_data[
"timing_start"] ||
 
 5835            $now > $item_data[
"timing_end"])) {
 
 5839        $this->log->debug(
"Check frequency.");
 
 5846            $missing_ids = array();
 
 5849                $this->log->debug(
"Entering survey mode.");
 
 5855                    $finished_ids = array();
 
 5856                    $set = 
$ilDB->query(
"SELECT user_fi FROM svy_finished" .
 
 5857                        " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer") .
 
 5858                        " AND state = " . 
$ilDB->quote(1, 
"text") .
 
 5859                        " AND " . 
$ilDB->in(
"user_fi", $user_ids, 
"", 
"integer"));
 
 5860                    while ($row = 
$ilDB->fetchAssoc($set)) {
 
 5861                        $finished_ids[] = $row[
"user_fi"];
 
 5865                    $missing_ids = array_diff($user_ids, $finished_ids);
 
 5867                        foreach ($missing_ids as $idx => $user_id) {
 
 5869                            if (!$ilAccess->checkAccessOfUser($user_id, 
"read", 
"", $this->getRefId(), 
"svy", $this->getId())) {
 
 5870                                unset($missing_ids[$idx]);
 
 5875                        $this->sentReminder($missing_ids);
 
 5879                $this->log->debug(
"Entering 360 mode.");
 
 5888            return sizeof($missing_ids);
 
 5894    protected function sentReminder(array $a_recipient_ids)
 
 5902            $templateService = 
$DIC[
'mail.texttemplates.service'];
 
 5905            $tmpl_params = array(
 
 5914        foreach ($a_recipient_ids as $user_id) {
 
 5916                $subject = $tmpl->getSubject();
 
 5923                $ulng->loadLanguageModule(
'survey');
 
 5925                $subject = sprintf($ulng->txt(
'survey_reminder_subject'), $this->getTitle());
 
 5928                $message .= $ulng->txt(
'survey_reminder_body') . 
":\n\n";
 
 5930                $message .= 
"\n" . $ulng->txt(
'survey_reminder_link') . 
": " . $link;
 
 5933            $mail_obj = 
new ilMail(ANONYMOUS_USER_ID);
 
 5934            $mail_obj->appendInstallationSignature(
true);
 
 5948        $this->activation_starting_time = $starting_time;
 
 5953        $this->activation_ending_time = $ending_time;
 
 5958        return (strlen($this->activation_starting_time)) ? $this->activation_starting_time : 
null;
 
 5963        return (strlen($this->activation_ending_time)) ? $this->activation_ending_time : 
null;
 
 5968        $this->view_own_results = (bool) $a_value;
 
 5978        $this->mail_own_results = (bool) $a_value;
 
 5988        $this->mail_confirmation = (bool) $a_value;
 
 5998        $this->anon_user_list = (bool) $a_value;
 
 6014        $surveySetting = 
new ilSetting(
"survey");
 
 6015        if (!$surveySetting->get(
"skipped_is_custom", 
false)) {
 
 6016            return $lng->txt(
"skipped");
 
 6018            return $surveySetting->get(
"skipped_custom_value", 
"");
 
 6026    public function getReminderMailTemplates(&$defaultTemplateId = 
null)
 
 6033        $templateService = 
$DIC[
'mail.texttemplates.service'];
 
 6035            $res[$tmpl->getTplId()] = $tmpl->getTitle();
 
 6036            if (
null !== $defaultTemplateId && $tmpl->isDefault()) {
 
 6037                $defaultTemplateId = $tmpl->getTplId();
 
 6050            $user = new \ilObjUser($a_user_id);
 
 6052            $processor = new \ilMailTemplatePlaceholderResolver(
$context, $a_message);
 
 6053            $a_message = $processor->resolve(
$user, $a_context_params);
 
 6054        } 
catch (\Exception 
$e) {
 
 6063        $this->mode = $a_value;
 
 6073        $this->mode_self_eval_results = $a_value;
 
 6090        $q = 
"SELECT obj_fi FROM svy_svy" .
 
 6091            " WHERE tutor_res_cron IS NULL" .
 
 6092            " AND tutor_res_status = " . 
$ilDB->quote(1, 
"integer") .
 
 6093            " AND enddate < " . 
$ilDB->quote(date(
"Ymd000000"), 
"text");
 
 6096            $q = 
"SELECT obj_fi FROM svy_svy" .
 
 6097                " WHERE tutor_res_status = " . 
$ilDB->quote(1, 
"integer") .
 
 6098                " AND enddate < " . 
$ilDB->quote(date(
"Ymd000000"), 
"text");
 
 6101        $set = 
$ilDB->query($q);
 
 6105        while ($row = 
$ilDB->fetchAssoc($set)) {
 
 6106            $res[] = $row[
"obj_fi"];
 
 6118        include_once 
"./Services/Mail/classes/class.ilMail.php";
 
 6119        include_once 
"./Services/User/classes/class.ilObjUser.php";
 
 6120        include_once 
"./Services/Language/classes/class.ilLanguageFactory.php";
 
 6121        include_once 
"./Services/User/classes/class.ilUserUtil.php";
 
 6123        include_once 
"./Services/Link/classes/class.ilLink.php";
 
 6131        $old_ref_id = 
$_GET[
"ref_id"];
 
 6132        $old_base_class = 
$_GET[
"baseClass"];
 
 6134        $ilCtrl->setTargetScript(
"ilias.php");
 
 6135        $_GET[
"baseClass"] = 
"ilObjSurveyGUI";
 
 6137        $ilCtrl->setParameterByClass(
"ilSurveyEvaluationGUI", 
"ref_id", $this->
getRefId());
 
 6141            $html = $gui->evaluation(1, 
true, 
true);
 
 6142        } 
catch (Exception $exception) {
 
 6143            $_GET[
"ref_id"] = $old_ref_id;
 
 6144            $_GET[
"baseClass"] = $old_base_class;
 
 6147        $_GET[
"ref_id"] = $old_ref_id;
 
 6148        $_GET[
"baseClass"] = $old_base_class;
 
 6150        $html = preg_replace(
"/\?dummy\=[0-9]+/", 
"", $html);
 
 6151        $html = preg_replace(
"/\?vers\=[0-9A-Za-z\-]+/", 
"", $html);
 
 6152        $html = str_replace(
'.css$Id$', 
".css", $html);
 
 6153        $html = preg_replace(
"/src=\"\\.\\//ims", 
"src=\"" . 
ILIAS_HTTP_PATH . 
"/", $html);
 
 6154        $html = preg_replace(
"/href=\"\\.\\//ims", 
"href=\"" . 
ILIAS_HTTP_PATH . 
"/", $html);
 
 6156        $log->debug(
"--pdf start, ref id " . $this->
getRefId());
 
 6157        $log->debug(
"html length: " . strlen($html));
 
 6158        $log->debug(
"html (first 1000 chars): " . substr($html, 0, 1000));
 
 6162        $log->debug(
"--pdf end");
 
 6172            !file_exists($pdf)) {
 
 6177        require_once 
'Services/Mail/classes/class.ilFileDataMail.php';
 
 6178        $att = 
"survey_" . $this->
getRefId() . 
".pdf";
 
 6180        $mail_data->copyAttachmentFile($pdf, $att);
 
 6185            $ulng->loadLanguageModule(
'survey');
 
 6187            $subject = sprintf($ulng->txt(
'survey_results_tutor_subject'), $this->getTitle());
 
 6190            $message .= $ulng->txt(
'survey_results_tutor_body') . 
":\n\n";
 
 6192            $message .= 
"\n" . $ulng->txt(
'survey_notification_tutor_link') . 
": " . $link;
 
 6194            $mail_obj = 
new ilMail(ANONYMOUS_USER_ID);
 
 6195            $mail_obj->appendInstallationSignature(
true);
 
 6207        $ilDB->manipulate(
"UPDATE svy_svy" .
 
 6208            " SET tutor_res_cron = " . 
$ilDB->quote(1, 
"integer") .
 
 6209            " WHERE survey_id = " . 
$ilDB->quote($this->getSurveyId(), 
"integer"));
 
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.
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 _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.
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.
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.
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...
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.
createQuestionblock($title, $show_questiontext, $show_blocktitle, $questions)
Creates a question block for the survey.
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.
modifyQuestionblock($questionblock_id, $title, $show_questiontext, $show_blocktitle)
Modifies a question block.
updateOrder(array $a_order)
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.
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.
static _addQuestionblock($title="", $owner=0, $show_questiontext=true, $show_blocktitle=false)
Adds a questionblock to the database.
& 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/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 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 unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
xmlHeader()
Writes xml header @access public.
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