76        $this->lng = 
$DIC->language();
 
   77        $this->ctrl = 
$DIC->ctrl();
 
   78        $this->rbacsystem = 
$DIC->rbac()->system();
 
   79        $this->db = 
$DIC->database();
 
   80        $this->tabs = 
$DIC->tabs();
 
   81        $this->tpl = 
$DIC[
"tpl"];
 
   82        $this->toolbar = 
$DIC->toolbar();
 
   83        $this->
user = $DIC->user();
 
   84        $this->editor_gui = $a_survey_editor_gui;
 
   85        $this->ref_id = $a_survey->
getRefId();
 
   86        $this->
object = $a_survey;
 
   99        $cmd = 
$ilCtrl->getCmd(
"renderPage");
 
  100        $next_class = 
$ilCtrl->getNextClass($this);
 
  102        switch ($next_class) {
 
  106                $has_content = 
false;
 
  108                if (
$rbacsystem->checkAccess(
"write", $this->ref_id)) {
 
  110                    if ($_REQUEST[
"new_id"]) {
 
  115                    if ($_REQUEST[
"il_hform_subcmd"]) {
 
  116                        $subcmd = $_REQUEST[
"il_hform_subcmd"];
 
  119                        $ilCtrl->setParameter($this->editor_gui, 
"pgov", $this->current_page);
 
  122                        $id = explode(
"_", $_REQUEST[
"il_hform_node"]);
 
  126                        if (substr($_REQUEST[
"il_hform_subcmd"], 0, 5) == 
"multi") {
 
  127                            if ($_REQUEST[
"il_hform_multi"]) {
 
  130                                foreach (explode(
";", $_REQUEST[
"il_hform_multi"]) as $item) {
 
  131                                    $id[] = (int) array_pop(explode(
"_", $item));
 
  134                                if ($subcmd == 
"multiDelete") {
 
  135                                    $subcmd = 
"deleteQuestion";
 
  139                                if ($subcmd == 
"multiDelete") {
 
  141                                    $ilCtrl->redirect($this, 
"renderPage");
 
  148                        if (substr($subcmd, 0, 11) == 
"addQuestion") {
 
  149                            $type = explode(
"_", $subcmd);
 
  151                            $has_content = $this->
addQuestion(
$type, $this->object->isPoolActive(), $id, $_REQUEST[
"il_hform_node"]);
 
  153                            $has_content = $this->$subcmd($id, $_REQUEST[
"il_hform_node"]);
 
  194        $this->log->debug(
"append question, id: " . $a_new_id . 
", duplicate: " . $a_duplicate . 
", force: " . $a_force_duplicate);
 
  198            "SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
 
  200            array($this->object->getSurveyId())
 
  202        $sequence = 
$result->numRows();
 
  207            $survey_question_id = $this->
object->duplicateQuestionForSurvey($a_new_id, $a_force_duplicate);
 
  211            $survey_question_id = $a_new_id;
 
  215        if ($this->object->isQuestionInSurvey($survey_question_id)) {
 
  216            return $survey_question_id;
 
  220        $next_id = 
$ilDB->nextId(
'svy_svy_qst');
 
  221        $affectedRows = 
$ilDB->manipulateF(
 
  222            "INSERT INTO svy_svy_qst (survey_question_id, survey_fi," .
 
  223            "question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
 
  224            array(
'integer', 
'integer', 
'integer', 
'integer', 
'integer'),
 
  225            array($next_id, $this->object->getSurveyId(), $survey_question_id, $sequence, time())
 
  228        $this->log->debug(
"insert svy_svy_qst, id: " . $next_id . 
", qfi: " . $survey_question_id . 
", seq: " . $sequence);
 
  230        return $survey_question_id;
 
  248            $this->
object->loadQuestionsFromDb();
 
  250            $pos = $_REQUEST[
"pgov_pos"];
 
  253            if (substr($pos, -1) != 
"c") {
 
  255                $current = $this->
object->getSurveyPages();
 
  256                $current = $current[$this->current_page - 1];
 
  257                if (
sizeof($current) == 1) {
 
  261                    $this->
object->createQuestionblock(
 
  265                        array((
int) $pos, $a_new_id)
 
  268                    $block_id = array_pop($current);
 
  269                    $block_id = $block_id[
"questionblock_id"];
 
  271                    $this->
object->addQuestionToBlock($a_new_id, $block_id);
 
  278                    $pos = (int) $pos . 
"a";
 
  279                    $this->current_page++;
 
  283                    $first = $this->
object->getSurveyPages();
 
  285                    $first = array_shift($first);
 
  286                    $pos = $first[
"question_id"] . 
"b";
 
  287                    $this->current_page = 1;
 
  292            $this->
object->moveQuestions(
 
  295                ((substr($pos, -1) == 
"a") ? 1 : 0)
 
  298            $this->
object->fixSequenceStructure();
 
  310        $question_ids = $this->
object->getQuestionblockQuestionIds($a_block_id);
 
  311        foreach ($question_ids as $qid) {
 
  315        if (
sizeof($new_ids)) {
 
  316            $this->
object->loadQuestionsFromDb();
 
  318            $pos = $_REQUEST[
"pgov_pos"];
 
  321            if (substr($pos, -1) != 
"c") {
 
  323                $current = $this->
object->getSurveyPages();
 
  324                $current = $current[$this->current_page - 1];
 
  325                if (
sizeof($current) == 1) {
 
  329                    $this->
object->createQuestionblock(
 
  333                        array((
int) $pos) + $new_ids
 
  336                    $block_id = array_pop($current);
 
  337                    $block_id = $block_id[
"questionblock_id"];
 
  339                    foreach ($new_ids as $qid) {
 
  340                        $this->
object->addQuestionToBlock($qid, $block_id);
 
  347                $this->
object->createQuestionblock(
 
  356                    $pos = (int) $pos . 
"a";
 
  360                    $first = $this->
object->getSurveyPages();
 
  362                    $first = array_shift($first);
 
  363                    $pos = $first[
"question_id"] . 
"b";
 
  368            $this->
object->moveQuestions(
 
  371                ((substr($pos, -1) == 
"a") ? 1 : 0)
 
  391        foreach ($questiontypes as $item) {
 
  392            if ($item[
"questiontype_id"] == 
$a_type) {
 
  393                $type_trans = $item[
"type_tag"];
 
  400        if ($a_special_position == 
"toolbar") {
 
  401            $id = $this->
object->getSurveyPages();
 
  402            if ($a_pos && $a_pos != 
"fst") {
 
  403                $id = $id[$a_pos - 1];
 
  404                $id = array_pop($id);
 
  405                $id = $id[
"question_id"] . 
"c";
 
  411        elseif ($a_special_position == 
"page_end") {
 
  412            $id = $this->
object->getSurveyPages();
 
  413            $id = $id[$this->current_page - 1];
 
  414            $id = array_pop($id);
 
  415            $id = $id[
"question_id"] . 
"a";
 
  421            $_GET[
"sel_question_types"] = $type_trans;
 
  422            $_REQUEST[
"pgov_pos"] = $id;
 
  423            $ilCtrl->setParameter($this->editor_gui, 
"pgov_pos", $id);
 
  425                $ilTabs->clearSubTabs(); 
 
  426                $this->editor_gui->createQuestionObject();
 
  428                $this->editor_gui->executeCreateQuestionObject();
 
  435            $q_gui->object->setObjId($this->object->getId());
 
  436            $q_gui->object->createNewQuestion();
 
  437            $q_gui_class = get_class($q_gui);
 
  440            $ilCtrl->setParameterByClass($q_gui_class, 
"pgov", $this->current_page);
 
  441            $ilCtrl->setParameterByClass($q_gui_class, 
"pgov_pos", $id);
 
  442            $ilCtrl->setParameterByClass($q_gui_class, 
"ref_id", $this->ref_id);
 
  443            $ilCtrl->setParameterByClass($q_gui_class, 
"new_for_survey", $this->ref_id);
 
  444            $ilCtrl->setParameterByClass($q_gui_class, 
"q_id", $q_gui->object->getId());
 
  445            $ilCtrl->setParameterByClass($q_gui_class, 
"sel_question_types", $q_gui->getQuestionType());
 
  446            $ilCtrl->redirectByClass($q_gui_class, 
"editQuestion");
 
  459        ilUtil::sendSuccess(
$lng->txt(
"survey_questions_to_clipboard_cut"));
 
  460        $this->suppress_clipboard_msg = 
true;
 
  463                        "source" => $this->current_page,
 
  464                        "nodes" => array($a_id),
 
  477        ilUtil::sendSuccess(
$lng->txt(
"survey_questions_to_clipboard_copy"));
 
  478        $this->suppress_clipboard_msg = 
true;
 
  481                        "source" => $this->current_page,
 
  482                        "nodes" => array($a_id),
 
  495        if (is_array($a_id)) {
 
  496            ilUtil::sendSuccess(
$lng->txt(
"survey_questions_to_clipboard_cut"));
 
  497            $this->suppress_clipboard_msg = 
true;
 
  500                "source" => $this->current_page,
 
  515        if (is_array($a_id)) {
 
  516            ilUtil::sendSuccess(
$lng->txt(
"survey_questions_to_clipboard_copy"));
 
  517            $this->suppress_clipboard_msg = 
true;
 
  520                "source" => $this->current_page,
 
  542        $pages = $this->
object->getSurveyPages();
 
  544        $target = $pages[$this->current_page - 1];
 
  548        foreach (
$source as $src_qst) {
 
  549            if (in_array($src_qst[
"question_id"], 
$data[
"nodes"])) {
 
  550                $nodes[] = $src_qst[
"question_id"];
 
  556        if ($_REQUEST[
"il_hform_node"] == 
"page_end") {
 
  558            $a_id = array_pop($a_id);
 
  559            $a_id = $a_id[
"question_id"];
 
  564        if (
$data[
"mode"] == 
"cut") {
 
  566            if (
$data[
"source"] == $this->current_page) {
 
  568                if (
sizeof($nodes) <= 
sizeof(
$source)) {
 
  569                    $this->
object->moveQuestions($nodes, $a_id, $pos);
 
  575                $source_block_id = 
false;
 
  578                    $source_block_id = array_shift($source_block_id);
 
  579                    $source_block_id = $source_block_id[
"questionblock_id"];
 
  582                    if (
sizeof(
$source) > 
sizeof($nodes)) {
 
  583                        foreach ($nodes as $qid) {
 
  584                            $this->
object->removeQuestionFromBlock($qid, $source_block_id);
 
  589                        $this->
object->unfoldQuestionblocks(array($source_block_id));
 
  594                if (
sizeof(
$source) == 
sizeof($nodes) && 
$data[
"source"] < $this->current_page) {
 
  595                    $this->current_page--;
 
  601        elseif (
$data[
"mode"] == 
"copy") {
 
  603            foreach ($this->object->getSurveyPages() as $page) {
 
  604                foreach ($page as $question) {
 
  605                    $titles[] = $question[
"title"];
 
  610            $question_pointer = array();
 
  611            foreach ($nodes as $qid) {
 
  616                $title = $question->getTitle();
 
  618                foreach ($titles as $existing_title) {
 
  619                    #21278 preg_quote with delimiter 
  620                    if (preg_match(
"/" . preg_quote($title, 
"/") . 
" \(([0-9]+)\)$/", $existing_title, $match)) {
 
  621                        $max = max($match[1], $max);
 
  625                    $title .= 
" (" . ($max + 1) . 
")";
 
  630                $question->setTitle($title);
 
  633                $question->saveToDb();
 
  635                $question_pointer[$qid] = $question->getId();
 
  640            $this->
object->cloneTextblocks($question_pointer);
 
  642            $this->
object->loadQuestionsFromDb();
 
  644            $nodes = array_values($question_pointer);
 
  651        if (
sizeof($target) == 1) {
 
  652            $nodes = array_merge(array($a_id), $nodes);
 
  655            $this->
object->createQuestionblock(
 
  664            $target_block_id = $target;
 
  665            $target_block_id = array_shift($target_block_id);
 
  666            $target_block_id = $target_block_id[
"questionblock_id"];
 
  668            foreach ($nodes as $qid) {
 
  669                $this->
object->addQuestionToBlock($qid, $target_block_id);
 
  673            $this->
object->moveQuestions($nodes, $a_id, $pos);
 
  684        $source_id = (int) array_pop(explode(
"_", $_REQUEST[
"il_hform_source"]));
 
  685        if ($_REQUEST[
"il_hform_target"] != 
"droparea_end") {
 
  686            $target_id = (int) array_pop(explode(
"_", $_REQUEST[
"il_hform_target"]));
 
  689            $page = $this->
object->getSurveyPages();
 
  690            $page = $page[$this->current_page - 1];
 
  691            $last = array_pop($page);
 
  696            $this->
object->moveQuestions(array($source_id), 
$target_id, $pos);
 
  709        $ilCtrl->setParameter($this->editor_gui, 
"pgov", $this->current_page);
 
  712        $page = $this->
object->getSurveyPages();
 
  713        $page = $page[$this->current_page - 1];
 
  716        if ($_REQUEST[
"csum"] != md5(print_r($page, 
true))) {
 
  717            $ilCtrl->redirect($this, 
"renderPage");
 
  720        $page = array_shift($page);
 
  721        $block_id = $page[
"questionblock_id"];
 
  723            $this->editor_gui->removeQuestionsForm(array($block_id), array(), array());
 
  725            $this->editor_gui->removeQuestionsForm(array(), array($page[
"question_id"]), array());
 
  738        if (!is_array($a_id)) {
 
  739            $a_id = array($a_id);
 
  742        $ilCtrl->setParameter($this->editor_gui, 
"pgov", $this->current_page);
 
  743        $this->editor_gui->removeQuestionsForm(array(), $a_id, array());
 
  756        foreach (
$_POST as $key => $value) {
 
  757            if (preg_match(
"/id_(\d+)/", $key, $matches)) {
 
  758                array_push($ids, $matches[1]);
 
  763        $pages = $this->
object->getSurveyPages();
 
  764        $source = $pages[$this->current_page - 1];
 
  767        $block_id = array_shift($block_id);
 
  768        $block_id = $block_id[
"questionblock_id"];
 
  770        if (
sizeof($ids) && 
sizeof(
$source) > 
sizeof($ids)) {
 
  772            if (
sizeof(
$source) - 
sizeof($ids) == 1) {
 
  773                $this->
object->unfoldQuestionblocks(array($block_id));
 
  777                foreach ($ids as $qid) {
 
  778                    $this->
object->removeQuestionFromBlock($qid, $block_id);
 
  782            $this->
object->removeQuestions($ids, array());
 
  788                $this->
object->removeQuestions(array(), array($block_id));
 
  792                $this->
object->removeQuestions($ids, array());
 
  796            if ($this->current_page > 1) {
 
  797                $this->current_page--;
 
  801        $this->
object->saveCompletionStatus();
 
  804        $ilCtrl->setParameter($this, 
"pgov", $this->current_page);
 
  805        $ilCtrl->redirect($this, 
"renderPage");
 
  815        $this->
callEditor(
"editQuestionblockObject", 
"bl_id", $a_id);
 
  826        $this->
callEditor(
"addHeadingObject", 
"q_id", $a_id);
 
  837        $this->
callEditor(
"editHeadingObject", 
"q_id", $a_id);
 
  848        $this->
callEditor(
"removeHeadingObject", 
"q_id", $a_id);
 
  856        $ilTabs->clearSubTabs();
 
  857        $_REQUEST[$a_param] = $a_value;
 
  859        call_user_func(array($this->editor_gui, $a_cmd));
 
  869        $pages = $this->
object->getSurveyPages();
 
  870        $source = $pages[$this->current_page - 1];
 
  872        $block_questions = array();
 
  873        $add = $block_id = 
false;
 
  874        foreach (
$source as $idx => $item) {
 
  875            if ($item[
"question_id"] == $a_id) {
 
  876                $block_id = $item[
"questionblock_id"];
 
  880                $block_questions[] = $item[
"question_id"];
 
  886            $this->
object->unfoldQuestionblocks(array($block_id));
 
  890            foreach ($block_questions as $qid) {
 
  891                $this->
object->removeQuestionFromBlock($qid, $block_id);
 
  896        if (
sizeof($block_questions) > 1) {
 
  898            $this->
object->createQuestionblock(
 
  906        $this->current_page++;
 
  916        $pages = $this->
object->getSurveyPages();
 
  917        $source = $pages[$this->current_page - 1];
 
  919        if (
sizeof($target)) {
 
  922            $target_block_id = 
$target_id[
"questionblock_id"];
 
  928                $block_id = array_shift($block_id);
 
  929                $block_id = $block_id[
"questionblock_id"];
 
  934                    $this->
object->unfoldQuestionblocks(array($block_id));
 
  937                    $this->
object->removeQuestionFromBlock($a_id, $block_id);
 
  942            $this->
object->moveQuestions(array($a_id), 
$target_id, 0);
 
  945            if (
sizeof($target) < 2) {
 
  947                $this->
object->createQuestionblock(
 
  955                $this->
object->addQuestionToBlock($a_id, $target_block_id);
 
  960                $this->current_page++;
 
  972        $pages = $this->
object->getSurveyPages();
 
  973        $source = $pages[$this->current_page - 1];
 
  974        $target = $pages[$this->current_page - 2];
 
  975        if (
sizeof($target)) {
 
  978            $target_block_id = 
$target_id[
"questionblock_id"];
 
  984                $block_id = array_shift($block_id);
 
  985                $block_id = $block_id[
"questionblock_id"];
 
  990                    $this->
object->unfoldQuestionblocks(array($block_id));
 
  993                    $this->
object->removeQuestionFromBlock($a_id, $block_id);
 
  998            $this->
object->moveQuestions(array($a_id), 
$target_id, 1);
 
 1001            if (
sizeof($target) < 2) {
 
 1003                $this->
object->createQuestionblock(
 
 1011                $this->
object->addQuestionToBlock($a_id, $target_block_id);
 
 1014            $this->current_page--;
 
 1027        $data = $this->
object->getSurveyQuestions();
 
 1030        $q_gui = 
$data[
"type_tag"] . 
"GUI";
 
 1031        $ilCtrl->setParameterByClass($q_gui, 
"pgov", $this->current_page);
 
 1032        $ilCtrl->setParameterByClass($q_gui, 
"q_id", $a_id);
 
 1034        $ilCtrl->redirectByClass($q_gui, 
"editQuestion");
 
 1047        $form->setFormAction(
$ilCtrl->getFormAction($this, 
"addQuestionToolbar"));
 
 1048        $form->setTitle(
$lng->txt(
"survey_add_new_question"));
 
 1052        $type_map = array();
 
 1053        foreach ($questiontypes as $trans => $item) {
 
 1054            $type_map[$item[
"questiontype_id"]] = $trans;
 
 1057        $si->setOptions($type_map);
 
 1058        $form->addItem(
$si);
 
 1060        $pages = $this->
object->getSurveyPages();
 
 1062            $pages_drop = array(
"fst" => 
$lng->txt(
"survey_at_beginning"));
 
 1063            foreach ($pages as $idx => $questions) {
 
 1064                $question = array_shift($questions);
 
 1065                if ($question[
"questionblock_id"]) {
 
 1066                    $pages_drop[$idx + 1] = 
$lng->txt(
"survey_behind_page") . 
" " . $question[
"questionblock_title"];
 
 1068                    $pages_drop[$idx + 1] = 
$lng->txt(
"survey_behind_page") . 
" " . strip_tags($question[
"title"]);
 
 1072            $pos->setOptions($pages_drop);
 
 1073            $form->addItem($pos);
 
 1075            $pos->setValue($this->current_page);
 
 1079            $pos->setValue(
"fst");
 
 1080            $form->addItem($pos);
 
 1083        if ($this->object->isPoolActive()) {
 
 1084            $this->editor_gui->createQuestionObject($form);
 
 1087        $form->addCommandButton(
"addQuestionToolbar", 
$lng->txt(
"create"));
 
 1088        $form->addCommandButton(
"renderPage", 
$lng->txt(
"cancel"));
 
 1090        return $tpl->setContent($form->getHTML());
 
 1101        $pool_active = $this->
object->isPoolActive();
 
 1103        if (!
$_POST[
"usage"] && $pool_active) {
 
 1109        $ilCtrl->setParameter($this->editor_gui, 
"pgov", $this->current_page);
 
 1126        $form->setFormAction(
$ilCtrl->getFormAction($this, 
"movePage"));
 
 1127        $form->setTitle(
$lng->txt(
"survey_move_page"));
 
 1130        $old_pos->setValue($this->current_page);
 
 1131        $form->addItem($old_pos);
 
 1133        $pages = $this->
object->getSurveyPages();
 
 1135            $pages_drop = array();
 
 1136            if ($this->current_page != 1) {
 
 1137                $pages_drop[
"fst"] = 
$lng->txt(
"survey_at_beginning");
 
 1139            foreach ($pages as $idx => $questions) {
 
 1140                if (($idx + 1) != $this->current_page && ($idx + 2) != $this->current_page) {
 
 1141                    $question = array_shift($questions);
 
 1142                    if ($question[
"questionblock_id"]) {
 
 1143                        $pages_drop[$idx + 1] = 
$lng->txt(
"survey_behind_page") . 
" " . $question[
"questionblock_title"];
 
 1145                        $pages_drop[$idx + 1] = 
$lng->txt(
"survey_behind_page") . 
" " . strip_tags($question[
"title"]);
 
 1150            $pos->setOptions($pages_drop);
 
 1151            $form->addItem($pos);
 
 1154        $form->addCommandButton(
"movePage", 
$lng->txt(
"submit"));
 
 1155        $form->addCommandButton(
"renderPage", 
$lng->txt(
"cancel"));
 
 1157        return $tpl->setContent($form->getHTML());
 
 1170        $target_page = $this->current_page - 1;
 
 1171        $source_page = $_REQUEST[
"old_pos"] - 1;
 
 1173        $pages = $this->
object->getSurveyPages();
 
 1174        foreach ($pages[$source_page] as $question) {
 
 1175            $questions[] = $question[
"question_id"];
 
 1180        if ($_REQUEST[
"pgov"] != 
"fst") {
 
 1184        $target = $pages[$target_page];
 
 1185        if ($position == 0) {                                                           
 
 1186            $target = array_shift($target);             
 
 1188            $target = array_pop($target);             
 
 1190        $this->
object->moveQuestions($questions, $target[
"question_id"], $position);
 
 1192        if ($target_page < $source_page && $position) {
 
 1193            $this->current_page++;
 
 1196        ilUtil::sendSuccess(
$lng->txt(
"survey_page_moved"), 
true);
 
 1197        $ilCtrl->setParameter($this, 
"pgov", $this->current_page);
 
 1198        $ilCtrl->redirect($this, 
"renderPage");
 
 1213        if (!$this->has_datasets) {
 
 1215            $button->setCaption(
"survey_add_new_question");
 
 1216            $button->setUrl(
$ilCtrl->getLinkTarget($this, 
"addQuestionToolbarForm"));
 
 1217            $ilToolbar->addStickyItem($button);
 
 1219            if ($this->object->isPoolActive()) {
 
 1224                    is_array($a_pages[$this->current_page - 1])) {
 
 1225                    $last_on_page = $a_pages[$this->current_page - 1];
 
 1226                    $last_on_page = array_pop($last_on_page);
 
 1227                    $last_on_page = $last_on_page[
"question_id"];
 
 1230                $ilCtrl->setParameter($this->editor_gui, 
"pgov", $this->current_page);
 
 1231                $ilCtrl->setParameter($this->editor_gui, 
"pgov_pos", $last_on_page . 
"c");
 
 1233                $cmd = (
$ilUser->getPref(
'svy_insert_type') == 1 ||
 
 1234                    strlen(
$ilUser->getPref(
'svy_insert_type')) == 0)
 
 1235                    ? 
'browseForQuestions' 
 1236                    : 
'browseForQuestionblocks';
 
 1239                $button->setCaption(
"browse_for_questions");
 
 1240                $button->setUrl(
$ilCtrl->getLinkTarget($this->editor_gui, $cmd));
 
 1241                $ilToolbar->addStickyItem($button);
 
 1243                $ilCtrl->setParameter($this->editor_gui, 
"pgov", 
"");
 
 1244                $ilCtrl->setParameter($this->editor_gui, 
"pgov_pos", 
"");
 
 1248                $ilToolbar->addSeparator();
 
 1256            $ilCtrl->setParameter($this, 
"pg", $this->current_page - 1);
 
 1258            $button->setCaption(
"survey_prev_question");
 
 1259            if ($this->has_previous_page) {
 
 1260                $button->setUrl(
$ilCtrl->getLinkTarget($this, 
"renderPage"));
 
 1262            $button->setDisabled(!$this->has_previous_page);
 
 1263            $ilToolbar->addStickyItem($button);
 
 1265            $ilCtrl->setParameter($this, 
"pg", $this->current_page + 1);
 
 1267            $button->setCaption(
"survey_next_question");
 
 1268            if ($this->has_next_page) {
 
 1269                $button->setUrl(
$ilCtrl->getLinkTarget($this, 
"renderPage"));
 
 1271            $button->setDisabled(!$this->has_next_page);
 
 1272            $ilToolbar->addStickyItem($button);
 
 1274            $ilCtrl->setParameter($this, 
"pg", $this->current_page); 
 
 1276            foreach ($a_pages as $idx => $questions) {
 
 1278                $page = array_shift($page);
 
 1279                if ($page[
"questionblock_id"]) {
 
 1280                    $pages_drop[$idx + 1] = $page[
"questionblock_title"];
 
 1282                    if (
sizeof($questions) > 1) {
 
 1283                        foreach ($questions as $question) {
 
 1284                            $pages_drop[($idx + 1) . 
"__" . $question[
"question_id"]] = 
"- " . $question[
"title"];
 
 1288                    $pages_drop[$idx + 1] = strip_tags($page[
"title"]);
 
 1294        if (is_array($pages_drop) && count($pages_drop) > 1) {
 
 1297            $ilToolbar->setFormAction(
$ilCtrl->getFormAction($this));
 
 1300            $si->addCustomAttribute(
"onChange=\"forms['ilToolbar'].submit();\"");
 
 1301            $si->setOptions($pages_drop);
 
 1302            $si->setValue($this->current_page);
 
 1303            $ilToolbar->addInputItem(
$si, 
true);
 
 1307            $cmd->setValue(
"1");
 
 1308            $ilToolbar->addInputItem($cmd);
 
 1310            if (!$this->has_datasets) {
 
 1311                $ilToolbar->addSeparator();
 
 1313                $ilCtrl->setParameter($this, 
"csum", md5(print_r($a_pages[$this->current_page - 1], 
true)));
 
 1314                $url = 
$ilCtrl->getLinkTarget($this, 
"deleteBlock");
 
 1315                $ilCtrl->setParameter($this, 
"csum", 
"");
 
 1318                $button->setCaption(
"survey_delete_page");
 
 1319                $button->setUrl(
$url);
 
 1320                $ilToolbar->addButtonInstance($button);
 
 1322                $ilToolbar->addSeparator();
 
 1325                $button->setCaption(
"survey_move_page");
 
 1326                $button->setUrl(
$ilCtrl->getLinkTarget($this, 
"movePageForm"));
 
 1327                $ilToolbar->addButtonInstance($button);
 
 1342        $pages = $this->
object->getSurveyPages();
 
 1343        $this->has_next_page = ($this->current_page < 
sizeof($pages));
 
 1344        $this->has_previous_page = ($this->current_page > 1);
 
 1348        if ($this->has_datasets) {
 
 1350            $mess = $mbox->getHTML();
 
 1353        $ilCtrl->setParameter($this, 
"pg", $this->current_page);
 
 1354        $ilCtrl->setParameter($this, 
"pgov", 
"");
 
 1359            $ttpl = 
new ilTemplate(
"tpl.il_svy_svy_page_view.html", 
true, 
true, 
"Modules/Survey");
 
 1360            $ttpl->setVariable(
"FORM_ACTION", 
$ilCtrl->getFormAction($this));
 
 1361            $lng->loadLanguageModule(
"form");
 
 1363            $read_only = ($this->has_datasets || !
$rbacsystem->checkAccess(
"write", $this->ref_id));
 
 1365            $commands = $multi_commands = array();
 
 1369                if (!
$_SESSION[
"survey_page_view"][$this->ref_id][
"clipboard"]) {
 
 1370                    $multi_commands[] = array(
"cmd" => 
"multiDelete", 
"text" => 
$lng->txt(
"delete"));
 
 1371                    $multi_commands[] = array(
"cmd" => 
"multiCut", 
"text" => 
$lng->txt(
"cut"));
 
 1372                    $multi_commands[] = array(
"cmd" => 
"multiCopy", 
"text" => 
$lng->txt(
"copy"));
 
 1373                    $multi_commands[] = array(
"cmd" => 
"selectAll", 
"text" => 
$lng->txt(
"select_all"));
 
 1375                    if (!$this->suppress_clipboard_msg) {
 
 1378                    $multi_commands[] = array(
"cmd" => 
"clearClipboard", 
"text" => 
$lng->txt(
"survey_dnd_clear_clipboard"));
 
 1382                $lng->loadLanguageModule(
"content");
 
 1383                $ttpl->setCurrentBlock(
"help_section");
 
 1384                $ttpl->setVariable(
"TXT_ADD_EL", 
$lng->txt(
"cont_add_elements"));
 
 1387                $ttpl->setVariable(
"TXT_DRAG", 
$lng->txt(
"cont_drag_and_drop_elements"));
 
 1388                $ttpl->setVariable(
"TXT_SEL", 
$lng->txt(
"cont_double_click_to_delete"));
 
 1389                $ttpl->parseCurrentBlock();
 
 1391                $ttpl->setVariable(
"DND_INIT_JS", 
"initDragElements();");
 
 1405                $ttpl->setVariable(
"WYSIWYG_BLOCKFORMATS", $tiny->_buildAdvancedBlockformatsFromHTMLTags($tags));
 
 1406                $ttpl->setVariable(
"WYSIWYG_VALID_ELEMENTS", $tiny->_getValidElementsFromHTMLTags($tags));
 
 1408                $buttons_1 = $tiny->_buildAdvancedButtonsFromHTMLTags(1, $tags);
 
 1409                $buttons_2 = $tiny->_buildAdvancedButtonsFromHTMLTags(2, $tags) . 
',' .
 
 1410                            $tiny->_buildAdvancedTableButtonsFromHTMLTags($tags) .
 
 1411                            ($tiny->getStyleSelect() ? 
',styleselect' : 
'');
 
 1412                $buttons_3 = $tiny->_buildAdvancedButtonsFromHTMLTags(3, $tags);
 
 1419            if (count($multi_commands) > 0) {
 
 1420                foreach ($multi_commands as $cmd) {
 
 1421                    $ttpl->setCurrentBlock(
"multi_cmd");
 
 1422                    $ttpl->setVariable(
"ORG_CMD_MULTI", 
"renderPage");
 
 1423                    $ttpl->setVariable(
"MULTI_CMD", $cmd[
"cmd"]);
 
 1424                    $ttpl->setVariable(
"MULTI_CMD_TXT", $cmd[
"text"]);
 
 1425                    $ttpl->parseCurrentBlock();
 
 1428                $ttpl->setCurrentBlock(
"multi_cmds");
 
 1429                $ttpl->setVariable(
"MCMD_ALT", 
$lng->txt(
"commands"));
 
 1431                $ttpl->parseCurrentBlock();
 
 1436                $pages[$this->current_page - 1],
 
 1437                $this->has_previous_page,
 
 1438                $this->has_next_page,
 
 1442            $tpl->setContent($mess . $ttpl->get());
 
 1446            $tpl->addJavascript(
"./Modules/Survey/js/SurveyPageView.js");
 
 1459    public function getPageNodes(array $a_questions, $a_has_previous_page = 
false, $a_has_next_page = 
false, $a_readonly = 
false)
 
 1464        $ttpl = 
new ilTemplate(
"tpl.il_svy_svy_page_view_nodes.html", 
true, 
true, 
"Modules/Survey");
 
 1466        $has_clipboard = (bool) 
$_SESSION[
"survey_page_view"][$this->ref_id][
"clipboard"];
 
 1470        $first_question = $a_questions;
 
 1471        $first_question = array_shift($first_question);
 
 1473        if ($first_question[
"questionblock_id"]) {
 
 1476            if (!$a_readonly && !$has_clipboard) {
 
 1477                $menu[] = array(
"cmd" => 
"editBlock", 
"text" => 
$lng->txt(
"edit"));
 
 1480            if ($first_question[
"questionblock_show_blocktitle"]) {
 
 1481                $block_status = 
$lng->txt(
"survey_block_visible");
 
 1483                $block_status = 
$lng->txt(
"survey_block_hidden");
 
 1489                $first_question[
"questionblock_id"],
 
 1490                $first_question[
"questionblock_title"] . 
" (" . $block_status . 
")",
 
 1502        $questionpools = array_keys($this->object->getQuestionpoolTitles(
true));
 
 1504        $counter = $question_count;
 
 1506        foreach ($a_questions as $idx => $question) {
 
 1512                if (!$has_clipboard) {
 
 1513                    foreach ($questiontypes as $trans => $item) {
 
 1514                        $menu[] = array(
"cmd" => 
"addQuestion_" . $item[
"questiontype_id"],
 
 1515                            "text" => sprintf(
$lng->txt(
"svy_page_add_question"), $trans));
 
 1518                    if ($this->object->isPoolActive()) {
 
 1519                        $menu[] = array(
"cmd" => 
"addPoolQuestion",
 
 1520                            "text" => 
$lng->txt(
"browse_for_questions"));
 
 1523                    $menu[] = array(
"cmd" => 
"paste", 
"text" => 
$lng->txt(
"survey_dnd_paste"));
 
 1527            $this->
renderPageNode($ttpl, 
"droparea", $question[
"question_id"], 
null, $menu, 
true);
 
 1530            $question_gui = $this->
object->getQuestionGUI($question[
"type_tag"], $question[
"question_id"]);
 
 1531            $question_form = $question_gui->getWorkingForm(
 
 1533                $this->object->getShowQuestionTitles(),
 
 1534                $question[
"questionblock_show_questiontext"],
 
 1536                $this->object->getSurveyId()
 
 1541            if (!$a_readonly && !$has_clipboard) {
 
 1542                $menu[] = array(
"cmd" => 
"editQuestion", 
"text" => 
$lng->txt(
"edit"));
 
 1543                $menu[] = array(
"cmd" => 
"cutQuestion", 
"text" => 
$lng->txt(
"cut"));
 
 1544                $menu[] = array(
"cmd" => 
"copyQuestion", 
"text" => 
$lng->txt(
"copy"));
 
 1546                if (
sizeof($a_questions) > 1 && $idx > 0) {
 
 1547                    $menu[] = array(
"cmd" => 
"splitPage", 
"text" => 
$lng->txt(
"survey_dnd_split_page"));
 
 1549                if ($a_has_next_page) {
 
 1550                    $menu[] = array(
"cmd" => 
"moveNext", 
"text" => 
$lng->txt(
"survey_dnd_move_next"));
 
 1552                if ($a_has_previous_page) {
 
 1553                    $menu[] = array(
"cmd" => 
"movePrevious", 
"text" => 
$lng->txt(
"survey_dnd_move_previous"));
 
 1556                $menu[] = array(
"cmd" => 
"deleteQuestion", 
"text" => 
$lng->txt(
"delete"));
 
 1559                if ($question[
"heading"]) {
 
 1560                    $menu[] = array(
"cmd" => 
"editHeading", 
"text" => 
$lng->txt(
"survey_edit_heading"));
 
 1561                    $menu[] = array(
"cmd" => 
"deleteHeading", 
"text" => 
$lng->txt(
"survey_delete_heading"));
 
 1563                    $menu[] = array(
"cmd" => 
"addHeading", 
"text" => 
$lng->txt(
"add_heading"));
 
 1567            if ($first_question[
"questionblock_show_questiontext"]) {
 
 1568                $question_title_status = 
$lng->txt(
"survey_question_text_visible");
 
 1570                $question_title_status = 
$lng->txt(
"survey_question_text_hidden");
 
 1576                $question[
"question_id"],
 
 1581                $question_title_status,
 
 1582                $question[
"heading"]
 
 1585            $ilCtrl->setParameter($this, 
"eqid", 
"");
 
 1594            if (!$has_clipboard) {
 
 1595                foreach ($questiontypes as $trans => $item) {
 
 1596                    $menu[] = array(
"cmd" => 
"addQuestion_" . $item[
"questiontype_id"],
 
 1597                        "text" => sprintf(
$lng->txt(
"svy_page_add_question"), $trans));
 
 1600                if ($this->object->isPoolActive()) {
 
 1601                    $menu[] = array(
"cmd" => 
"addPoolQuestion",
 
 1602                        "text" => 
$lng->txt(
"browse_for_questions"));
 
 1605                $menu[] = array(
"cmd" => 
"paste", 
"text" => 
$lng->txt(
"survey_dnd_paste"));
 
 1611        return $ttpl->get();
 
 1631        $node_id = 
$a_type . 
"_" . $a_id;
 
 1636                foreach ($a_menu as $mcnt => $menu_item) {
 
 1637                    $ilCtrl->setParameter($this, 
"il_hform_node", $node_id);
 
 1638                    $ilCtrl->setParameter($this, 
"il_hform_subcmd", $menu_item[
"cmd"]);
 
 1639                    $url = 
$ilCtrl->getLinkTarget($this, 
"renderPage");
 
 1640                    $ilCtrl->setParameter($this, 
"il_hform_subcmd", 
"");
 
 1641                    $ilCtrl->setParameter($this, 
"il_hform_node", 
"");
 
 1644                    $a_tpl->
setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
 
 1654        } elseif ($a_menu) {
 
 1656            foreach ($a_menu as $mcnt => $menu_item) {
 
 1657                $ilCtrl->setParameter($this, 
"il_hform_node", $node_id);
 
 1658                $ilCtrl->setParameter($this, 
"il_hform_subcmd", $menu_item[
"cmd"]);
 
 1659                $url = 
$ilCtrl->getLinkTarget($this, 
"renderPage");
 
 1660                $ilCtrl->setParameter($this, 
"il_hform_subcmd", 
"");
 
 1661                $ilCtrl->setParameter($this, 
"il_hform_node", 
"");
 
 1664                $a_tpl->
setVariable(
"TXT_ACTION_CMD", $menu_item[
"text"]);
 
 1674            $a_content = 
"<div class=\"questionheading\">" . $a_heading . 
"</div>" .
 
 1686            $selectable = 
false;
 
 1689                    $caption = 
$lng->txt(
"questionblock");
 
 1693                    $caption = 
$lng->txt(
"question") . 
": " . $a_subtitle;
 
 1699                    $caption = 
$lng->txt(
"heading");
 
 1707                $caption .= 
" (" . $a_status . 
")";
 
 1732        return $lng->txt(
"survey_auto_block_title");
 
 1740        if ($node == 
"page_end") {
 
 1741            $pos = $this->
object->getSurveyPages();
 
 1742            $pos = array_pop($pos[$this->current_page - 1]);
 
 1743            $pos = $pos[
"question_id"] . 
"a";
 
 1748        $ilCtrl->setParameter($this->editor_gui, 
"pgov", $this->current_page);
 
 1749        $ilCtrl->setParameter($this->editor_gui, 
"pgov_pos", $pos);
 
 1751        $cmd = (
$ilUser->getPref(
'svy_insert_type') == 1 || strlen(
$ilUser->getPref(
'svy_insert_type')) == 0) ? 
'browseForQuestions' : 
'browseForQuestionblocks';
 
 1752        $ilCtrl->redirect($this->editor_gui, $cmd);
 
An exception for terminatinating execution or to throw for unit testing.
static _getQuestionGUI($questiontype, $question_id=-1)
Creates a question gui representation.
static _isComplete($question_id)
Checks whether the question is complete or not.
static get($a_glyph, $a_text="")
Get glyph html.
static getLogger($a_component_id)
Get component logger.
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
static _getQuestiontypes()
Creates a list of all available question types.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _hasDatasets($survey_id)
getRefId()
get reference id @access public
Message box for survey, when data is alrady available.
cutQuestion($a_id)
Add question to be cut to clipboard.
appendNewQuestionToSurvey($a_new_id, $a_duplicate=true, $a_force_duplicate=false)
Add new question to survey (database part)
determineCurrentPage()
determine current page
insertQuestionBlock($a_block_id)
Copy and insert questions from block.
movePage()
Move current page to new position.
__construct(ilObjSurvey $a_survey, ilSurveyEditorGUI $a_survey_editor_gui)
Constructor.
copyQuestion($a_id)
Add question to be copied to clipboard.
addHeading($a_id)
Add heading to question.
getPageNodes(array $a_questions, $a_has_previous_page=false, $a_has_next_page=false, $a_readonly=false)
Get Form HTML.
renderPageNode(ilTemplate $a_tpl, $a_type, $a_id, $a_content=null, array $a_menu=null, $a_spacer=false, $a_subtitle=false, $a_status=false, $a_heading=false)
Render single of dnd page view.
multiCut($a_id)
Add questions to be cut to clipboard.
deleteBlock()
Confirm removing question block.
editBlock($a_id)
Edit question block.
addQuestionToolbarForm()
Add question to survey form (used in toolbar)
paste($a_id)
Paste from clipboard.
addQuestion($a_type, $a_use_pool, $a_pos, $a_special_position)
Call add question to survey form.
clearClipboard()
Empty clipboard.
dnd()
Move questions in page.
addQuestionToolbar()
Add question to survey action (used in toolbar)
moveNext($a_id)
Move question to next page.
editQuestion($a_id)
Edit question.
splitPage($a_id)
Split current page in 2 pages.
confirmRemoveQuestions()
Remove question(s) from survey.
renderToolbar($a_pages)
Render toolbar form.
movePrevious($a_id)
Move question to previous page.
addPoolQuestion($pos, $node)
getAutoBlockTitle()
Get name for newly created blocks.
deleteHeading($a_id)
Delete question heading.
callEditor($a_cmd, $a_param, $a_value)
movePageForm()
Move current page.
renderPage()
render questions per page
editHeading($a_id)
Edit question heading.
deleteQuestion($a_id)
Confirm removing question(s) from survey.
insertNewQuestion($a_new_id)
Add new question to survey.
multiCopy($a_id)
Add questions to be copied to clipboard.
special template class to simplify handling of ITX/PEAR
touchBlock($block)
overwrites ITX::touchBlock.
parseCurrentBlock($part="DEFAULT")
Überladene Funktion, die auf den aktuelle Block vorher noch ein replace ausführt @access public.
setCurrentBlock($part="DEFAULT")
Überladene Funktion, die sich hier lokal noch den aktuellen Block merkt.
static removeRedundantSeparators($a_string)
Removes redundant seperators and removes ,, and , at the first or last position of the string.
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static initDragDrop(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Drag and Drop.
setVariable($variable, $value='')