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;
 
  244        include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
  249            $this->
object->loadQuestionsFromDb();
 
  251            $pos = $_REQUEST[
"pgov_pos"];
 
  254            if (substr($pos, -1) != 
"c") {
 
  256                $current = $this->
object->getSurveyPages();
 
  262                    $this->
object->createQuestionblock(
 
  266                        array((
int) $pos, $a_new_id)
 
  270                    $block_id = $block_id[
"questionblock_id"];
 
  272                    $this->
object->addQuestionToBlock($a_new_id, $block_id);
 
  279                    $pos = (int) $pos . 
"a";
 
  280                    $this->current_page++;
 
  284                    $first = $this->
object->getSurveyPages();
 
  286                    $first = array_shift($first);
 
  287                    $pos = $first[
"question_id"] . 
"b";
 
  288                    $this->current_page = 1;
 
  293            $this->
object->moveQuestions(
 
  296                ((substr($pos, -1) == 
"a") ? 1 : 0)
 
  299            $this->
object->fixSequenceStructure();
 
  311        $question_ids = $this->
object->getQuestionblockQuestionIds($a_block_id);
 
  312        foreach ($question_ids as $qid) {
 
  316        if (
sizeof($new_ids)) {
 
  317            $this->
object->loadQuestionsFromDb();
 
  319            $pos = $_REQUEST[
"pgov_pos"];
 
  322            if (substr($pos, -1) != 
"c") {
 
  324                $current = $this->
object->getSurveyPages();
 
  330                    $this->
object->createQuestionblock(
 
  334                        array((
int) $pos) + $new_ids
 
  338                    $block_id = $block_id[
"questionblock_id"];
 
  340                    foreach ($new_ids as $qid) {
 
  341                        $this->
object->addQuestionToBlock($qid, $block_id);
 
  348                $this->
object->createQuestionblock(
 
  357                    $pos = (int) $pos . 
"a";
 
  361                    $first = $this->
object->getSurveyPages();
 
  363                    $first = array_shift($first);
 
  364                    $pos = $first[
"question_id"] . 
"b";
 
  369            $this->
object->moveQuestions(
 
  372                ((substr($pos, -1) == 
"a") ? 1 : 0)
 
  391        include_once 
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
 
  393        foreach ($questiontypes as $item) {
 
  394            if ($item[
"questiontype_id"] == 
$a_type) {
 
  395                $type_trans = $item[
"type_tag"];
 
  402        if ($a_special_position == 
"toolbar") {
 
  403            $id = $this->
object->getSurveyPages();
 
  404            if ($a_pos && $a_pos != 
"fst") {
 
  407                $id = 
$id[
"question_id"] . 
"c";
 
  413        elseif ($a_special_position == 
"page_end") {
 
  414            $id = $this->
object->getSurveyPages();
 
  415            $id = 
$id[$this->current_page - 1];
 
  417            $id = 
$id[
"question_id"] . 
"a";
 
  423            $_GET[
"sel_question_types"] = $type_trans;
 
  424            $_REQUEST[
"pgov_pos"] = 
$id;
 
  425            $ilCtrl->setParameter($this->editor_gui, 
"pgov_pos", 
$id);
 
  427                $ilTabs->clearSubTabs(); 
 
  428                $this->editor_gui->createQuestionObject();
 
  430                $this->editor_gui->executeCreateQuestionObject();
 
  436            include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
 
  438            $q_gui->object->setObjId($this->object->getId());
 
  439            $q_gui->object->createNewQuestion();
 
  440            $q_gui_class = get_class($q_gui);
 
  443            $ilCtrl->setParameterByClass($q_gui_class, 
"pgov", $this->current_page);
 
  444            $ilCtrl->setParameterByClass($q_gui_class, 
"pgov_pos", 
$id);
 
  445            $ilCtrl->setParameterByClass($q_gui_class, 
"ref_id", $this->ref_id);
 
  446            $ilCtrl->setParameterByClass($q_gui_class, 
"new_for_survey", $this->ref_id);
 
  447            $ilCtrl->setParameterByClass($q_gui_class, 
"q_id", $q_gui->object->getId());
 
  448            $ilCtrl->setParameterByClass($q_gui_class, 
"sel_question_types", $q_gui->getQuestionType());
 
  449            $ilCtrl->redirectByClass($q_gui_class, 
"editQuestion");
 
  462        ilUtil::sendSuccess(
$lng->txt(
"survey_questions_to_clipboard_cut"));
 
  463        $this->suppress_clipboard_msg = 
true;
 
  466                        "source" => $this->current_page,
 
  467                        "nodes" => array($a_id),
 
  480        ilUtil::sendSuccess(
$lng->txt(
"survey_questions_to_clipboard_copy"));
 
  481        $this->suppress_clipboard_msg = 
true;
 
  484                        "source" => $this->current_page,
 
  485                        "nodes" => array($a_id),
 
  498        if (is_array($a_id)) {
 
  499            ilUtil::sendSuccess(
$lng->txt(
"survey_questions_to_clipboard_cut"));
 
  500            $this->suppress_clipboard_msg = 
true;
 
  503                "source" => $this->current_page,
 
  518        if (is_array($a_id)) {
 
  519            ilUtil::sendSuccess(
$lng->txt(
"survey_questions_to_clipboard_copy"));
 
  520            $this->suppress_clipboard_msg = 
true;
 
  523                "source" => $this->current_page,
 
  545        $pages = $this->
object->getSurveyPages();
 
  547        $target = $pages[$this->current_page - 1];
 
  551        foreach (
$source as $src_qst) {
 
  552            if (in_array($src_qst[
"question_id"], 
$data[
"nodes"])) {
 
  553                $nodes[] = $src_qst[
"question_id"];
 
  559        if ($_REQUEST[
"il_hform_node"] == 
"page_end") {
 
  561            $a_id = array_pop($a_id);
 
  562            $a_id = $a_id[
"question_id"];
 
  567        if (
$data[
"mode"] == 
"cut") {
 
  569            if (
$data[
"source"] == $this->current_page) {
 
  572                    $this->
object->moveQuestions(
$nodes, $a_id, $pos);
 
  578                $source_block_id = 
false;
 
  581                    $source_block_id = array_shift($source_block_id);
 
  582                    $source_block_id = $source_block_id[
"questionblock_id"];
 
  586                        foreach (
$nodes as $qid) {
 
  587                            $this->
object->removeQuestionFromBlock($qid, $source_block_id);
 
  592                        $this->
object->unfoldQuestionblocks(array($source_block_id));
 
  598                    $this->current_page--;
 
  604        elseif (
$data[
"mode"] == 
"copy") {
 
  606            foreach ($this->object->getSurveyPages() as $page) {
 
  607                foreach ($page as $question) {
 
  608                    $titles[] = $question[
"title"];
 
  613            $question_pointer = array();
 
  614            foreach (
$nodes as $qid) {
 
  619                $title = $question->getTitle();
 
  621                foreach ($titles as $existing_title) {
 
  622                    #21278 preg_quote with delimiter 
  623                    if (preg_match(
"/" . preg_quote(
$title, 
"/") . 
" \(([0-9]+)\)$/", $existing_title, $match)) {
 
  624                        $max = max($match[1], $max);
 
  628                    $title .= 
" (" . ($max + 1) . 
")";
 
  633                $question->setTitle(
$title);
 
  636                $question->saveToDb();
 
  638                $question_pointer[$qid] = $question->getId();
 
  643            $this->
object->cloneTextblocks($question_pointer);
 
  645            $this->
object->loadQuestionsFromDb();
 
  647            $nodes = array_values($question_pointer);
 
  658            $this->
object->createQuestionblock(
 
  668            $target_block_id = array_shift($target_block_id);
 
  669            $target_block_id = $target_block_id[
"questionblock_id"];
 
  671            foreach (
$nodes as $qid) {
 
  672                $this->
object->addQuestionToBlock($qid, $target_block_id);
 
  676            $this->
object->moveQuestions(
$nodes, $a_id, $pos);
 
  687        $source_id = (int) array_pop(explode(
"_", $_REQUEST[
"il_hform_source"]));
 
  688        if ($_REQUEST[
"il_hform_target"] != 
"droparea_end") {
 
  689            $target_id = (int) array_pop(explode(
"_", $_REQUEST[
"il_hform_target"]));
 
  692            $page = $this->
object->getSurveyPages();
 
  693            $page = $page[$this->current_page - 1];
 
  694            $last = array_pop($page);
 
  699            $this->
object->moveQuestions(array($source_id), 
$target_id, $pos);
 
  712        $ilCtrl->setParameter($this->editor_gui, 
"pgov", $this->current_page);
 
  715        $page = $this->
object->getSurveyPages();
 
  716        $page = $page[$this->current_page - 1];
 
  719        if ($_REQUEST[
"csum"] != md5(print_r($page, 
true))) {
 
  720            $ilCtrl->redirect($this, 
"renderPage");
 
  723        $page = array_shift($page);
 
  724        $block_id = $page[
"questionblock_id"];
 
  726            $this->editor_gui->removeQuestionsForm(array($block_id), array(), array());
 
  728            $this->editor_gui->removeQuestionsForm(array(), array($page[
"question_id"]), array());
 
  741        if (!is_array($a_id)) {
 
  742            $a_id = array($a_id);
 
  745        $ilCtrl->setParameter($this->editor_gui, 
"pgov", $this->current_page);
 
  746        $this->editor_gui->removeQuestionsForm(array(), $a_id, array());
 
  760            if (preg_match(
"/id_(\d+)/", 
$key, $matches)) {
 
  761                array_push($ids, $matches[1]);
 
  766        $pages = $this->
object->getSurveyPages();
 
  767        $source = $pages[$this->current_page - 1];
 
  770        $block_id = array_shift($block_id);
 
  771        $block_id = $block_id[
"questionblock_id"];
 
  773        if (
sizeof($ids) && 
sizeof(
$source) > 
sizeof($ids)) {
 
  775            if (
sizeof(
$source) - 
sizeof($ids) == 1) {
 
  776                $this->
object->unfoldQuestionblocks(array($block_id));
 
  780                foreach ($ids as $qid) {
 
  781                    $this->
object->removeQuestionFromBlock($qid, $block_id);
 
  785            $this->
object->removeQuestions($ids, array());
 
  791                $this->
object->removeQuestions(array(), array($block_id));
 
  795                $this->
object->removeQuestions($ids, array());
 
  799            if ($this->current_page > 1) {
 
  800                $this->current_page--;
 
  804        $this->
object->saveCompletionStatus();
 
  807        $ilCtrl->setParameter($this, 
"pgov", $this->current_page);
 
  808        $ilCtrl->redirect($this, 
"renderPage");
 
  818        $this->
callEditor(
"editQuestionblockObject", 
"bl_id", $a_id);
 
  829        $this->
callEditor(
"addHeadingObject", 
"q_id", $a_id);
 
  840        $this->
callEditor(
"editHeadingObject", 
"q_id", $a_id);
 
  851        $this->
callEditor(
"removeHeadingObject", 
"q_id", $a_id);
 
  859        $ilTabs->clearSubTabs();
 
  860        $_REQUEST[$a_param] = $a_value;
 
  862        call_user_func(array($this->editor_gui, $a_cmd));
 
  872        $pages = $this->
object->getSurveyPages();
 
  873        $source = $pages[$this->current_page - 1];
 
  875        $block_questions = array();
 
  876        $add = $block_id = 
false;
 
  877        foreach (
$source as $idx => $item) {
 
  878            if ($item[
"question_id"] == $a_id) {
 
  879                $block_id = $item[
"questionblock_id"];
 
  883                $block_questions[] = $item[
"question_id"];
 
  889            $this->
object->unfoldQuestionblocks(array($block_id));
 
  893            foreach ($block_questions as $qid) {
 
  894                $this->
object->removeQuestionFromBlock($qid, $block_id);
 
  899        if (
sizeof($block_questions) > 1) {
 
  901            $this->
object->createQuestionblock(
 
  909        $this->current_page++;
 
  919        $pages = $this->
object->getSurveyPages();
 
  920        $source = $pages[$this->current_page - 1];
 
  925            $target_block_id = 
$target_id[
"questionblock_id"];
 
  931                $block_id = array_shift($block_id);
 
  932                $block_id = $block_id[
"questionblock_id"];
 
  937                    $this->
object->unfoldQuestionblocks(array($block_id));
 
  940                    $this->
object->removeQuestionFromBlock($a_id, $block_id);
 
  945            $this->
object->moveQuestions(array($a_id), 
$target_id, 0);
 
  950                $this->
object->createQuestionblock(
 
  958                $this->
object->addQuestionToBlock($a_id, $target_block_id);
 
  963                $this->current_page++;
 
  975        $pages = $this->
object->getSurveyPages();
 
  976        $source = $pages[$this->current_page - 1];
 
  977        $target = $pages[$this->current_page - 2];
 
  981            $target_block_id = 
$target_id[
"questionblock_id"];
 
  987                $block_id = array_shift($block_id);
 
  988                $block_id = $block_id[
"questionblock_id"];
 
  993                    $this->
object->unfoldQuestionblocks(array($block_id));
 
  996                    $this->
object->removeQuestionFromBlock($a_id, $block_id);
 
 1001            $this->
object->moveQuestions(array($a_id), 
$target_id, 1);
 
 1006                $this->
object->createQuestionblock(
 
 1014                $this->
object->addQuestionToBlock($a_id, $target_block_id);
 
 1017            $this->current_page--;
 
 1030        $data = $this->
object->getSurveyQuestions();
 
 1033        $q_gui = 
$data[
"type_tag"] . 
"GUI";
 
 1034        $ilCtrl->setParameterByClass($q_gui, 
"pgov", $this->current_page);
 
 1035        $ilCtrl->setParameterByClass($q_gui, 
"q_id", $a_id);
 
 1037        $ilCtrl->redirectByClass($q_gui, 
"editQuestion");
 
 1049        include_once 
"Services/Form/classes/class.ilPropertyFormGUI.php";
 
 1051        $form->setFormAction(
$ilCtrl->getFormAction($this, 
"addQuestionToolbar"));
 
 1052        $form->setTitle(
$lng->txt(
"survey_add_new_question"));
 
 1055        include_once 
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
 
 1057        $type_map = array();
 
 1058        foreach ($questiontypes as $trans => $item) {
 
 1059            $type_map[$item[
"questiontype_id"]] = $trans;
 
 1061        include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
 
 1063        $si->setOptions($type_map);
 
 1066        $pages = $this->
object->getSurveyPages();
 
 1068            $pages_drop = array(
"fst" => 
$lng->txt(
"survey_at_beginning"));
 
 1069            foreach ($pages as $idx => $questions) {
 
 1070                $question = array_shift($questions);
 
 1071                if ($question[
"questionblock_id"]) {
 
 1072                    $pages_drop[$idx + 1] = 
$lng->txt(
"survey_behind_page") . 
" " . $question[
"questionblock_title"];
 
 1074                    $pages_drop[$idx + 1] = 
$lng->txt(
"survey_behind_page") . 
" " . strip_tags($question[
"title"]);
 
 1078            $pos->setOptions($pages_drop);
 
 1079            $form->addItem($pos);
 
 1081            $pos->setValue($this->current_page);
 
 1085            $pos->setValue(
"fst");
 
 1086            $form->addItem($pos);
 
 1089        if ($this->object->isPoolActive()) {
 
 1090            $this->editor_gui->createQuestionObject(
$form);
 
 1093        $form->addCommandButton(
"addQuestionToolbar", 
$lng->txt(
"create"));
 
 1094        $form->addCommandButton(
"renderPage", 
$lng->txt(
"cancel"));
 
 1096        return $tpl->setContent(
$form->getHTML());
 
 1107        $pool_active = $this->
object->isPoolActive();
 
 1109        if (!
$_POST[
"usage"] && $pool_active) {
 
 1115        $ilCtrl->setParameter($this->editor_gui, 
"pgov", $this->current_page);
 
 1131        include_once 
"Services/Form/classes/class.ilPropertyFormGUI.php";
 
 1133        $form->setFormAction(
$ilCtrl->getFormAction($this, 
"movePage"));
 
 1134        $form->setTitle(
$lng->txt(
"survey_move_page"));
 
 1137        $old_pos->setValue($this->current_page);
 
 1138        $form->addItem($old_pos);
 
 1140        $pages = $this->
object->getSurveyPages();
 
 1142            $pages_drop = array();
 
 1143            if ($this->current_page != 1) {
 
 1144                $pages_drop[
"fst"] = 
$lng->txt(
"survey_at_beginning");
 
 1146            foreach ($pages as $idx => $questions) {
 
 1147                if (($idx + 1) != $this->current_page && ($idx + 2) != $this->current_page) {
 
 1148                    $question = array_shift($questions);
 
 1149                    if ($question[
"questionblock_id"]) {
 
 1150                        $pages_drop[$idx + 1] = 
$lng->txt(
"survey_behind_page") . 
" " . $question[
"questionblock_title"];
 
 1152                        $pages_drop[$idx + 1] = 
$lng->txt(
"survey_behind_page") . 
" " . strip_tags($question[
"title"]);
 
 1157            $pos->setOptions($pages_drop);
 
 1158            $form->addItem($pos);
 
 1161        $form->addCommandButton(
"movePage", 
$lng->txt(
"submit"));
 
 1162        $form->addCommandButton(
"renderPage", 
$lng->txt(
"cancel"));
 
 1164        return $tpl->setContent(
$form->getHTML());
 
 1177        $target_page = $this->current_page - 1;
 
 1178        $source_page = $_REQUEST[
"old_pos"] - 1;
 
 1180        $pages = $this->
object->getSurveyPages();
 
 1181        foreach ($pages[$source_page] as $question) {
 
 1182            $questions[] = $question[
"question_id"];
 
 1187        if ($_REQUEST[
"pgov"] != 
"fst") {
 
 1191        $target = $pages[$target_page];
 
 1192        if ($position == 0) {                                                           
 
 1197        $this->
object->moveQuestions($questions, 
$target[
"question_id"], $position);
 
 1199        if ($target_page < $source_page && $position) {
 
 1200            $this->current_page++;
 
 1203        ilUtil::sendSuccess(
$lng->txt(
"survey_page_moved"), 
true);
 
 1204        $ilCtrl->setParameter($this, 
"pgov", $this->current_page);
 
 1205        $ilCtrl->redirect($this, 
"renderPage");
 
 1220        include_once 
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
 
 1222        if (!$this->has_datasets) {
 
 1224            $button->setCaption(
"survey_add_new_question");
 
 1225            $button->setUrl(
$ilCtrl->getLinkTarget($this, 
"addQuestionToolbarForm"));
 
 1226            $ilToolbar->addStickyItem($button);
 
 1228            if ($this->object->isPoolActive()) {
 
 1233                    is_array($a_pages[$this->current_page - 1])) {
 
 1234                    $last_on_page = $a_pages[$this->current_page - 1];
 
 1235                    $last_on_page = array_pop($last_on_page);
 
 1236                    $last_on_page = $last_on_page[
"question_id"];
 
 1239                $ilCtrl->setParameter($this->editor_gui, 
"pgov", $this->current_page);
 
 1240                $ilCtrl->setParameter($this->editor_gui, 
"pgov_pos", $last_on_page . 
"c");
 
 1242                $cmd = (
$ilUser->getPref(
'svy_insert_type') == 1 ||
 
 1243                    strlen(
$ilUser->getPref(
'svy_insert_type')) == 0)
 
 1244                    ? 
'browseForQuestions' 
 1245                    : 
'browseForQuestionblocks';
 
 1248                $button->setCaption(
"browse_for_questions");
 
 1249                $button->setUrl(
$ilCtrl->getLinkTarget($this->editor_gui, $cmd));
 
 1250                $ilToolbar->addStickyItem($button);
 
 1252                $ilCtrl->setParameter($this->editor_gui, 
"pgov", 
"");
 
 1253                $ilCtrl->setParameter($this->editor_gui, 
"pgov_pos", 
"");
 
 1257                $ilToolbar->addSeparator();
 
 1265            $ilCtrl->setParameter($this, 
"pg", $this->current_page - 1);
 
 1267            $button->setCaption(
"survey_prev_question");
 
 1268            if ($this->has_previous_page) {
 
 1269                $button->setUrl(
$ilCtrl->getLinkTarget($this, 
"renderPage"));
 
 1271            $button->setDisabled(!$this->has_previous_page);
 
 1272            $ilToolbar->addStickyItem($button);
 
 1274            $ilCtrl->setParameter($this, 
"pg", $this->current_page + 1);
 
 1276            $button->setCaption(
"survey_next_question");
 
 1277            if ($this->has_next_page) {
 
 1278                $button->setUrl(
$ilCtrl->getLinkTarget($this, 
"renderPage"));
 
 1280            $button->setDisabled(!$this->has_next_page);
 
 1281            $ilToolbar->addStickyItem($button);
 
 1283            $ilCtrl->setParameter($this, 
"pg", $this->current_page); 
 
 1285            foreach ($a_pages as $idx => $questions) {
 
 1287                $page = array_shift($page);
 
 1288                if ($page[
"questionblock_id"]) {
 
 1289                    $pages_drop[$idx + 1] = $page[
"questionblock_title"];
 
 1291                    if (
sizeof($questions) > 1) {
 
 1292                        foreach ($questions as $question) {
 
 1293                            $pages_drop[($idx + 1) . 
"__" . $question[
"question_id"]] = 
"- " . $question[
"title"];
 
 1297                    $pages_drop[$idx + 1] = strip_tags($page[
"title"]);
 
 1303        if (is_array($pages_drop) && count($pages_drop) > 1) {
 
 1306            $ilToolbar->setFormAction(
$ilCtrl->getFormAction($this));
 
 1308            include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
 
 1310            $si->addCustomAttribute(
"onChange=\"forms['ilToolbar'].submit();\"");
 
 1311            $si->setOptions($pages_drop);
 
 1312            $si->setValue($this->current_page);
 
 1313            $ilToolbar->addInputItem(
$si, 
true);
 
 1317            $cmd->setValue(
"1");
 
 1318            $ilToolbar->addInputItem($cmd);
 
 1320            if (!$this->has_datasets) {
 
 1321                $ilToolbar->addSeparator();
 
 1323                $ilCtrl->setParameter($this, 
"csum", md5(print_r($a_pages[$this->current_page - 1], 
true)));
 
 1324                $url = 
$ilCtrl->getLinkTarget($this, 
"deleteBlock");
 
 1325                $ilCtrl->setParameter($this, 
"csum", 
"");
 
 1328                $button->setCaption(
"survey_delete_page");
 
 1329                $button->setUrl(
$url);
 
 1330                $ilToolbar->addButtonInstance($button);
 
 1332                $ilToolbar->addSeparator();
 
 1335                $button->setCaption(
"survey_move_page");
 
 1336                $button->setUrl(
$ilCtrl->getLinkTarget($this, 
"movePageForm"));
 
 1337                $ilToolbar->addButtonInstance($button);
 
 1352        $pages = $this->
object->getSurveyPages();
 
 1353        $this->has_next_page = ($this->current_page < 
sizeof($pages));
 
 1354        $this->has_previous_page = ($this->current_page > 1);
 
 1358        if ($this->has_datasets) {
 
 1360            $mess = $mbox->getHTML();
 
 1363        $ilCtrl->setParameter($this, 
"pg", $this->current_page);
 
 1364        $ilCtrl->setParameter($this, 
"pgov", 
"");
 
 1369            $ttpl = 
new ilTemplate(
"tpl.il_svy_svy_page_view.html", 
true, 
true, 
"Modules/Survey");
 
 1370            $ttpl->setVariable(
"FORM_ACTION", 
$ilCtrl->getFormAction($this));
 
 1371            $lng->loadLanguageModule(
"form");
 
 1373            $read_only = ($this->has_datasets || !
$rbacsystem->checkAccess(
"write", $this->ref_id));
 
 1375            $commands = $multi_commands = array();
 
 1379                if (!
$_SESSION[
"survey_page_view"][$this->ref_id][
"clipboard"]) {
 
 1380                    $multi_commands[] = array(
"cmd" => 
"multiDelete", 
"text" => 
$lng->txt(
"delete"));
 
 1381                    $multi_commands[] = array(
"cmd" => 
"multiCut", 
"text" => 
$lng->txt(
"cut"));
 
 1382                    $multi_commands[] = array(
"cmd" => 
"multiCopy", 
"text" => 
$lng->txt(
"copy"));
 
 1383                    $multi_commands[] = array(
"cmd" => 
"selectAll", 
"text" => 
$lng->txt(
"select_all"));
 
 1385                    if (!$this->suppress_clipboard_msg) {
 
 1388                    $multi_commands[] = array(
"cmd" => 
"clearClipboard", 
"text" => 
$lng->txt(
"survey_dnd_clear_clipboard"));
 
 1392                $lng->loadLanguageModule(
"content");
 
 1393                $ttpl->setCurrentBlock(
"help_section");
 
 1394                $ttpl->setVariable(
"TXT_ADD_EL", 
$lng->txt(
"cont_add_elements"));
 
 1395                include_once(
"./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
 
 1398                $ttpl->setVariable(
"TXT_DRAG", 
$lng->txt(
"cont_drag_and_drop_elements"));
 
 1399                $ttpl->setVariable(
"TXT_SEL", 
$lng->txt(
"cont_double_click_to_delete"));
 
 1400                $ttpl->parseCurrentBlock();
 
 1402                $ttpl->setVariable(
"DND_INIT_JS", 
"initDragElements();");
 
 1407                include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
 1416                include_once 
"./Services/RTE/classes/class.ilTinyMCE.php";
 
 1418                $ttpl->setVariable(
"WYSIWYG_BLOCKFORMATS", $tiny->_buildAdvancedBlockformatsFromHTMLTags(
$tags));
 
 1419                $ttpl->setVariable(
"WYSIWYG_VALID_ELEMENTS", $tiny->_getValidElementsFromHTMLTags(
$tags));
 
 1421                $buttons_1 = $tiny->_buildAdvancedButtonsFromHTMLTags(1, 
$tags);
 
 1422                $buttons_2 = $tiny->_buildAdvancedButtonsFromHTMLTags(2, 
$tags) . 
',' .
 
 1423                            $tiny->_buildAdvancedTableButtonsFromHTMLTags(
$tags) .
 
 1424                            ($tiny->getStyleSelect() ? 
',styleselect' : 
'');
 
 1425                $buttons_3 = $tiny->_buildAdvancedButtonsFromHTMLTags(3, 
$tags);
 
 1432            if (count($multi_commands) > 0) {
 
 1433                foreach ($multi_commands as $cmd) {
 
 1434                    $ttpl->setCurrentBlock(
"multi_cmd");
 
 1435                    $ttpl->setVariable(
"ORG_CMD_MULTI", 
"renderPage");
 
 1436                    $ttpl->setVariable(
"MULTI_CMD", $cmd[
"cmd"]);
 
 1437                    $ttpl->setVariable(
"MULTI_CMD_TXT", $cmd[
"text"]);
 
 1438                    $ttpl->parseCurrentBlock();
 
 1441                $ttpl->setCurrentBlock(
"multi_cmds");
 
 1442                $ttpl->setVariable(
"MCMD_ALT", 
$lng->txt(
"commands"));
 
 1444                $ttpl->parseCurrentBlock();
 
 1449                $pages[$this->current_page - 1],
 
 1450                $this->has_previous_page,
 
 1451                $this->has_next_page,
 
 1455            $tpl->setContent($mess . $ttpl->get());
 
 1458            include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
 
 1460            $tpl->addJavascript(
"./Modules/Survey/js/SurveyPageView.js");
 
 1473    public function getPageNodes(array $a_questions, $a_has_previous_page = 
false, $a_has_next_page = 
false, $a_readonly = 
false)
 
 1478        $ttpl = 
new ilTemplate(
"tpl.il_svy_svy_page_view_nodes.html", 
true, 
true, 
"Modules/Survey");
 
 1480        $has_clipboard = (bool) 
$_SESSION[
"survey_page_view"][$this->ref_id][
"clipboard"];
 
 1484        $first_question = $a_questions;
 
 1485        $first_question = array_shift($first_question);
 
 1487        if ($first_question[
"questionblock_id"]) {
 
 1490            if (!$a_readonly && !$has_clipboard) {
 
 1491                $menu[] = array(
"cmd" => 
"editBlock", 
"text" => 
$lng->txt(
"edit"));
 
 1494            if ($first_question[
"questionblock_show_blocktitle"]) {
 
 1495                $block_status = 
$lng->txt(
"survey_block_visible");
 
 1497                $block_status = 
$lng->txt(
"survey_block_hidden");
 
 1503                $first_question[
"questionblock_id"],
 
 1504                $first_question[
"questionblock_title"] . 
" (" . $block_status . 
")",
 
 1515        include_once 
"./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
 
 1517        $questionpools = array_keys($this->object->getQuestionpoolTitles(
true));
 
 1519        $counter = $question_count;
 
 1521        foreach ($a_questions as $idx => $question) {
 
 1527                if (!$has_clipboard) {
 
 1528                    foreach ($questiontypes as $trans => $item) {
 
 1529                        $menu[] = array(
"cmd" => 
"addQuestion_" . $item[
"questiontype_id"],
 
 1530                            "text" => sprintf(
$lng->txt(
"svy_page_add_question"), $trans));
 
 1533                    if ($this->object->isPoolActive()) {
 
 1534                        $menu[] = array(
"cmd" => 
"addPoolQuestion",
 
 1535                            "text" => 
$lng->txt(
"browse_for_questions"));
 
 1538                    $menu[] = array(
"cmd" => 
"paste", 
"text" => 
$lng->txt(
"survey_dnd_paste"));
 
 1542            $this->
renderPageNode($ttpl, 
"droparea", $question[
"question_id"], 
null, $menu, 
true);
 
 1545            $question_gui = $this->
object->getQuestionGUI($question[
"type_tag"], $question[
"question_id"]);
 
 1546            $question_form = $question_gui->getWorkingForm(
 
 1548                $this->object->getShowQuestionTitles(),
 
 1549                $question[
"questionblock_show_questiontext"],
 
 1551                $this->object->getSurveyId()
 
 1556            if (!$a_readonly && !$has_clipboard) {
 
 1557                $menu[] = array(
"cmd" => 
"editQuestion", 
"text" => 
$lng->txt(
"edit"));
 
 1558                $menu[] = array(
"cmd" => 
"cutQuestion", 
"text" => 
$lng->txt(
"cut"));
 
 1559                $menu[] = array(
"cmd" => 
"copyQuestion", 
"text" => 
$lng->txt(
"copy"));
 
 1561                if (
sizeof($a_questions) > 1 && $idx > 0) {
 
 1562                    $menu[] = array(
"cmd" => 
"splitPage", 
"text" => 
$lng->txt(
"survey_dnd_split_page"));
 
 1564                if ($a_has_next_page) {
 
 1565                    $menu[] = array(
"cmd" => 
"moveNext", 
"text" => 
$lng->txt(
"survey_dnd_move_next"));
 
 1567                if ($a_has_previous_page) {
 
 1568                    $menu[] = array(
"cmd" => 
"movePrevious", 
"text" => 
$lng->txt(
"survey_dnd_move_previous"));
 
 1571                $menu[] = array(
"cmd" => 
"deleteQuestion", 
"text" => 
$lng->txt(
"delete"));
 
 1574                if ($question[
"heading"]) {
 
 1575                    $menu[] = array(
"cmd" => 
"editHeading", 
"text" => 
$lng->txt(
"survey_edit_heading"));
 
 1576                    $menu[] = array(
"cmd" => 
"deleteHeading", 
"text" => 
$lng->txt(
"survey_delete_heading"));
 
 1578                    $menu[] = array(
"cmd" => 
"addHeading", 
"text" => 
$lng->txt(
"add_heading"));
 
 1582            if ($first_question[
"questionblock_show_questiontext"]) {
 
 1583                $question_title_status = 
$lng->txt(
"survey_question_text_visible");
 
 1585                $question_title_status = 
$lng->txt(
"survey_question_text_hidden");
 
 1591                $question[
"question_id"],
 
 1596                $question_title_status,
 
 1597                $question[
"heading"]
 
 1600            $ilCtrl->setParameter($this, 
"eqid", 
"");
 
 1609            if (!$has_clipboard) {
 
 1610                foreach ($questiontypes as $trans => $item) {
 
 1611                    $menu[] = array(
"cmd" => 
"addQuestion_" . $item[
"questiontype_id"],
 
 1612                        "text" => sprintf(
$lng->txt(
"svy_page_add_question"), $trans));
 
 1615                if ($this->object->isPoolActive()) {
 
 1616                    $menu[] = array(
"cmd" => 
"addPoolQuestion",
 
 1617                        "text" => 
$lng->txt(
"browse_for_questions"));
 
 1620                $menu[] = array(
"cmd" => 
"paste", 
"text" => 
$lng->txt(
"survey_dnd_paste"));
 
 1626        return $ttpl->get();
 
 1646        $node_id = 
$a_type . 
"_" . $a_id;
 
 1651                foreach ($a_menu as $mcnt => $menu_item) {
 
 1652                    $ilCtrl->setParameter($this, 
"il_hform_node", $node_id);
 
 1653                    $ilCtrl->setParameter($this, 
"il_hform_subcmd", $menu_item[
"cmd"]);
 
 1654                    $url = 
$ilCtrl->getLinkTarget($this, 
"renderPage");
 
 1655                    $ilCtrl->setParameter($this, 
"il_hform_subcmd", 
"");
 
 1656                    $ilCtrl->setParameter($this, 
"il_hform_node", 
"");
 
 1659                    $a_tpl->
setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
 
 1666            include_once 
"Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
 
 1670        } elseif ($a_menu) {
 
 1672            foreach ($a_menu as $mcnt => $menu_item) {
 
 1673                $ilCtrl->setParameter($this, 
"il_hform_node", $node_id);
 
 1674                $ilCtrl->setParameter($this, 
"il_hform_subcmd", $menu_item[
"cmd"]);
 
 1675                $url = 
$ilCtrl->getLinkTarget($this, 
"renderPage");
 
 1676                $ilCtrl->setParameter($this, 
"il_hform_subcmd", 
"");
 
 1677                $ilCtrl->setParameter($this, 
"il_hform_node", 
"");
 
 1680                $a_tpl->
setVariable(
"TXT_ACTION_CMD", $menu_item[
"text"]);
 
 1690            $a_content = 
"<div class=\"questionheading\">" . $a_heading . 
"</div>" .
 
 1702            $selectable = 
false;
 
 1705                    $caption = 
$lng->txt(
"questionblock");
 
 1709                    $caption = 
$lng->txt(
"question") . 
": " . $a_subtitle;
 
 1715                    $caption = 
$lng->txt(
"heading");
 
 1723                $caption .= 
" (" . $a_status . 
")";
 
 1748        return $lng->txt(
"survey_auto_block_title");
 
 1756        if ($node == 
"page_end") {
 
 1757            $pos = $this->
object->getSurveyPages();
 
 1758            $pos = array_pop($pos[$this->current_page - 1]);
 
 1759            $pos = $pos[
"question_id"] . 
"a";
 
 1764        $ilCtrl->setParameter($this->editor_gui, 
"pgov", $this->current_page);
 
 1765        $ilCtrl->setParameter($this->editor_gui, 
"pgov_pos", $pos);
 
 1767        $cmd = (
$ilUser->getPref(
'svy_insert_type') == 1 || strlen(
$ilUser->getPref(
'svy_insert_type')) == 0) ? 
'browseForQuestions' : 
'browseForQuestionblocks';
 
 1768        $ilCtrl->redirect($this->editor_gui, $cmd);
 
An exception for terminatinating execution or to throw for unit testing.
setVariable($variable, $value='')
Sets a variable value.
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()
Init YUI Drag and Drop.
if(!array_key_exists('StateId', $_REQUEST)) $id
if(isset($_POST['submit'])) $form