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(
"appendNewQuestionToSurvey svy_svy_qst, id: " . $next_id .
", qfi: " . $survey_question_id .
", seq: " . $sequence);
229 return $survey_question_id;
247 $this->
object->loadQuestionsFromDb();
249 $pos = $_REQUEST[
"pgov_pos"];
252 if (substr($pos, -1) !=
"c") {
254 $current = $this->
object->getSurveyPages();
255 $current = $current[$this->current_page - 1];
256 if (
sizeof($current) == 1) {
260 $this->
object->createQuestionblock(
264 array((
int) $pos, $a_new_id)
267 $block_id = array_pop($current);
268 $block_id = $block_id[
"questionblock_id"];
270 $this->
object->addQuestionToBlock($a_new_id, $block_id);
277 $pos = (int) $pos .
"a";
278 $this->current_page++;
282 $first = $this->
object->getSurveyPages();
284 $first = array_shift($first);
285 $pos = $first[
"question_id"] .
"b";
286 $this->current_page = 1;
291 $this->
object->moveQuestions(
294 ((substr($pos, -1) ==
"a") ? 1 : 0)
297 $this->
object->fixSequenceStructure();
309 $question_ids = $this->
object->getQuestionblockQuestionIds($a_block_id);
310 foreach ($question_ids as $qid) {
314 if (
sizeof($new_ids)) {
315 $this->
object->loadQuestionsFromDb();
317 $pos = $_REQUEST[
"pgov_pos"];
320 if (substr($pos, -1) !=
"c") {
322 $current = $this->
object->getSurveyPages();
323 $current = $current[$this->current_page - 1];
324 if (
sizeof($current) == 1) {
328 $this->
object->createQuestionblock(
332 array((
int) $pos) + $new_ids
335 $block_id = array_pop($current);
336 $block_id = $block_id[
"questionblock_id"];
338 foreach ($new_ids as $qid) {
339 $this->
object->addQuestionToBlock($qid, $block_id);
346 $this->
object->createQuestionblock(
355 $pos = (int) $pos .
"a";
359 $first = $this->
object->getSurveyPages();
361 $first = array_shift($first);
362 $pos = $first[
"question_id"] .
"b";
367 $this->
object->moveQuestions(
370 ((substr($pos, -1) ==
"a") ? 1 : 0)
383 protected function addQuestion($a_type, $a_use_pool, $a_pos, $a_special_position)
390 foreach ($questiontypes as $item) {
391 if ($item[
"questiontype_id"] == $a_type) {
392 $type_trans = $item[
"type_tag"];
399 if ($a_special_position ==
"toolbar") {
400 $id = $this->
object->getSurveyPages();
401 if ($a_pos && $a_pos !=
"fst") {
402 $id = $id[$a_pos - 1];
403 $id = array_pop($id);
404 $id = $id[
"question_id"] .
"c";
410 elseif ($a_special_position ==
"page_end") {
411 $id = $this->
object->getSurveyPages();
412 $id = $id[$this->current_page - 1];
413 $id = array_pop($id);
414 $id = $id[
"question_id"] .
"a";
420 $_GET[
"sel_question_types"] = $type_trans;
421 $_REQUEST[
"pgov_pos"] = $id;
422 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos", $id);
424 $ilTabs->clearSubTabs();
425 $this->editor_gui->createQuestionObject();
427 $this->editor_gui->executeCreateQuestionObject();
434 $q_gui->object->setObjId($this->object->getId());
435 $q_gui->object->createNewQuestion();
436 $q_gui_class = get_class($q_gui);
439 $ilCtrl->setParameterByClass($q_gui_class,
"pgov", $this->current_page);
440 $ilCtrl->setParameterByClass($q_gui_class,
"pgov_pos", $id);
441 $ilCtrl->setParameterByClass($q_gui_class,
"ref_id", $this->ref_id);
442 $ilCtrl->setParameterByClass($q_gui_class,
"new_for_survey", $this->ref_id);
443 $ilCtrl->setParameterByClass($q_gui_class,
"q_id", $q_gui->object->getId());
444 $ilCtrl->setParameterByClass($q_gui_class,
"sel_question_types", $q_gui->getQuestionType());
445 $ilCtrl->redirectByClass($q_gui_class,
"editQuestion");
458 ilUtil::sendSuccess(
$lng->txt(
"survey_questions_to_clipboard_cut"));
459 $this->suppress_clipboard_msg =
true;
462 "source" => $this->current_page,
463 "nodes" => array($a_id),
476 ilUtil::sendSuccess(
$lng->txt(
"survey_questions_to_clipboard_copy"));
477 $this->suppress_clipboard_msg =
true;
480 "source" => $this->current_page,
481 "nodes" => array($a_id),
494 if (is_array($a_id)) {
495 ilUtil::sendSuccess(
$lng->txt(
"survey_questions_to_clipboard_cut"));
496 $this->suppress_clipboard_msg =
true;
499 "source" => $this->current_page,
514 if (is_array($a_id)) {
515 ilUtil::sendSuccess(
$lng->txt(
"survey_questions_to_clipboard_copy"));
516 $this->suppress_clipboard_msg =
true;
519 "source" => $this->current_page,
541 $pages = $this->
object->getSurveyPages();
543 $target = $pages[$this->current_page - 1];
547 foreach (
$source as $src_qst) {
548 if (in_array($src_qst[
"question_id"], $data[
"nodes"])) {
549 $nodes[] = $src_qst[
"question_id"];
555 if ($_REQUEST[
"il_hform_node"] ==
"page_end") {
557 $a_id = array_pop($a_id);
558 $a_id = $a_id[
"question_id"];
563 if ($data[
"mode"] ==
"cut") {
565 if ($data[
"source"] == $this->current_page) {
567 if (
sizeof($nodes) <=
sizeof(
$source)) {
568 $this->
object->moveQuestions($nodes, $a_id, $pos);
574 $source_block_id =
false;
577 $source_block_id = array_shift($source_block_id);
578 $source_block_id = $source_block_id[
"questionblock_id"];
581 if (
sizeof(
$source) >
sizeof($nodes)) {
582 foreach ($nodes as $qid) {
583 $this->
object->removeQuestionFromBlock($qid, $source_block_id);
588 $this->
object->unfoldQuestionblocks(array($source_block_id));
593 if (
sizeof(
$source) ==
sizeof($nodes) && $data[
"source"] < $this->current_page) {
594 $this->current_page--;
600 elseif ($data[
"mode"] ==
"copy") {
602 foreach ($this->object->getSurveyPages() as $page) {
603 foreach ($page as $question) {
604 $titles[] = $question[
"title"];
609 $question_pointer = array();
610 foreach ($nodes as $qid) {
615 $title = $question->getTitle();
617 foreach ($titles as $existing_title) {
618 #21278 preg_quote with delimiter 619 if (preg_match(
"/" . preg_quote($title,
"/") .
" \(([0-9]+)\)$/", $existing_title, $match)) {
620 $max = max($match[1], $max);
624 $title .=
" (" . ($max + 1) .
")";
629 $question->setTitle($title);
632 $question->saveToDb();
634 $question_pointer[$qid] = $question->getId();
639 $this->
object->cloneTextblocks($question_pointer);
641 $this->
object->loadQuestionsFromDb();
643 $nodes = array_values($question_pointer);
650 if (
sizeof($target) == 1) {
651 $nodes = array_merge(array($a_id), $nodes);
654 $this->
object->createQuestionblock(
663 $target_block_id = $target;
664 $target_block_id = array_shift($target_block_id);
665 $target_block_id = $target_block_id[
"questionblock_id"];
667 foreach ($nodes as $qid) {
668 $this->
object->addQuestionToBlock($qid, $target_block_id);
672 $this->
object->moveQuestions($nodes, $a_id, $pos);
683 $source_id = (int) array_pop(explode(
"_", $_REQUEST[
"il_hform_source"]));
684 if ($_REQUEST[
"il_hform_target"] !=
"droparea_end") {
685 $target_id = (int) array_pop(explode(
"_", $_REQUEST[
"il_hform_target"]));
688 $page = $this->
object->getSurveyPages();
689 $page = $page[$this->current_page - 1];
690 $last = array_pop($page);
695 $this->
object->moveQuestions(array($source_id),
$target_id, $pos);
708 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
711 $page = $this->
object->getSurveyPages();
712 $page = $page[$this->current_page - 1];
715 if ($_REQUEST[
"csum"] != md5(print_r($page,
true))) {
716 $ilCtrl->redirect($this,
"renderPage");
719 $page = array_shift($page);
720 $block_id = $page[
"questionblock_id"];
722 $this->editor_gui->removeQuestionsForm(array($block_id), array(), array());
724 $this->editor_gui->removeQuestionsForm(array(), array($page[
"question_id"]), array());
737 if (!is_array($a_id)) {
738 $a_id = array($a_id);
741 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
742 $this->editor_gui->removeQuestionsForm(array(), $a_id, array());
755 foreach (
$_POST as $key => $value) {
756 if (preg_match(
"/id_(\d+)/", $key, $matches)) {
757 array_push($ids, $matches[1]);
762 $pages = $this->
object->getSurveyPages();
763 $source = $pages[$this->current_page - 1];
766 $block_id = array_shift($block_id);
767 $block_id = $block_id[
"questionblock_id"];
769 if (
sizeof($ids) &&
sizeof(
$source) >
sizeof($ids)) {
771 if (
sizeof(
$source) -
sizeof($ids) == 1) {
772 $this->
object->unfoldQuestionblocks(array($block_id));
776 foreach ($ids as $qid) {
777 $this->
object->removeQuestionFromBlock($qid, $block_id);
781 $this->
object->removeQuestions($ids, array());
787 $this->
object->removeQuestions(array(), array($block_id));
791 $this->
object->removeQuestions($ids, array());
795 if ($this->current_page > 1) {
796 $this->current_page--;
800 $this->
object->saveCompletionStatus();
803 $ilCtrl->setParameter($this,
"pgov", $this->current_page);
804 $ilCtrl->redirect($this,
"renderPage");
814 $this->
callEditor(
"editQuestionblockObject",
"bl_id", $a_id);
825 $this->
callEditor(
"addHeadingObject",
"q_id", $a_id);
836 $this->
callEditor(
"editHeadingObject",
"q_id", $a_id);
847 $this->
callEditor(
"removeHeadingObject",
"q_id", $a_id);
855 $ilTabs->clearSubTabs();
856 $_REQUEST[$a_param] = $a_value;
858 call_user_func(array($this->editor_gui, $a_cmd));
868 $pages = $this->
object->getSurveyPages();
869 $source = $pages[$this->current_page - 1];
871 $block_questions = array();
872 $add = $block_id =
false;
873 foreach (
$source as $idx => $item) {
874 if ($item[
"question_id"] == $a_id) {
875 $block_id = $item[
"questionblock_id"];
879 $block_questions[] = $item[
"question_id"];
885 $this->
object->unfoldQuestionblocks(array($block_id));
889 foreach ($block_questions as $qid) {
890 $this->
object->removeQuestionFromBlock($qid, $block_id);
895 if (
sizeof($block_questions) > 1) {
897 $this->
object->createQuestionblock(
905 $this->current_page++;
915 $pages = $this->
object->getSurveyPages();
916 $source = $pages[$this->current_page - 1];
918 if (
sizeof($target)) {
921 $target_block_id =
$target_id[
"questionblock_id"];
927 $block_id = array_shift($block_id);
928 $block_id = $block_id[
"questionblock_id"];
933 $this->
object->unfoldQuestionblocks(array($block_id));
936 $this->
object->removeQuestionFromBlock($a_id, $block_id);
941 $this->
object->moveQuestions(array($a_id),
$target_id, 0);
944 if (
sizeof($target) < 2) {
946 $this->
object->createQuestionblock(
954 $this->
object->addQuestionToBlock($a_id, $target_block_id);
959 $this->current_page++;
971 $pages = $this->
object->getSurveyPages();
972 $source = $pages[$this->current_page - 1];
973 $target = $pages[$this->current_page - 2];
974 if (
sizeof($target)) {
977 $target_block_id =
$target_id[
"questionblock_id"];
983 $block_id = array_shift($block_id);
984 $block_id = $block_id[
"questionblock_id"];
989 $this->
object->unfoldQuestionblocks(array($block_id));
992 $this->
object->removeQuestionFromBlock($a_id, $block_id);
997 $this->
object->moveQuestions(array($a_id),
$target_id, 1);
1000 if (
sizeof($target) < 2) {
1002 $this->
object->createQuestionblock(
1010 $this->
object->addQuestionToBlock($a_id, $target_block_id);
1013 $this->current_page--;
1026 $data = $this->
object->getSurveyQuestions();
1029 $q_gui =
$data[
"type_tag"] .
"GUI";
1030 $ilCtrl->setParameterByClass($q_gui,
"pgov", $this->current_page);
1031 $ilCtrl->setParameterByClass($q_gui,
"q_id", $a_id);
1033 $ilCtrl->redirectByClass($q_gui,
"editQuestion");
1046 $form->setFormAction($ilCtrl->getFormAction($this,
"addQuestionToolbar"));
1047 $form->setTitle(
$lng->txt(
"survey_add_new_question"));
1051 $type_map = array();
1052 foreach ($questiontypes as $trans => $item) {
1053 $type_map[$item[
"questiontype_id"]] = $trans;
1056 $si->setOptions($type_map);
1057 $form->addItem(
$si);
1059 $pages = $this->
object->getSurveyPages();
1061 $pages_drop = array(
"fst" =>
$lng->txt(
"survey_at_beginning"));
1062 foreach ($pages as $idx => $questions) {
1063 $question = array_shift($questions);
1064 if ($question[
"questionblock_id"]) {
1065 $pages_drop[$idx + 1] =
$lng->txt(
"survey_behind_page") .
" " . $question[
"questionblock_title"];
1067 $pages_drop[$idx + 1] =
$lng->txt(
"survey_behind_page") .
" " . strip_tags($question[
"title"]);
1071 $pos->setOptions($pages_drop);
1072 $form->addItem($pos);
1074 $pos->setValue($this->current_page);
1078 $pos->setValue(
"fst");
1079 $form->addItem($pos);
1082 if ($this->object->isPoolActive()) {
1083 $this->editor_gui->createQuestionObject($form);
1086 $form->addCommandButton(
"addQuestionToolbar",
$lng->txt(
"create"));
1087 $form->addCommandButton(
"renderPage",
$lng->txt(
"cancel"));
1089 return $tpl->setContent($form->getHTML());
1100 $pool_active = $this->
object->isPoolActive();
1102 if (!
$_POST[
"usage"] && $pool_active) {
1108 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
1125 $form->setFormAction($ilCtrl->getFormAction($this,
"movePage"));
1126 $form->setTitle(
$lng->txt(
"survey_move_page"));
1129 $old_pos->setValue($this->current_page);
1130 $form->addItem($old_pos);
1132 $pages = $this->
object->getSurveyPages();
1134 $pages_drop = array();
1135 if ($this->current_page != 1) {
1136 $pages_drop[
"fst"] =
$lng->txt(
"survey_at_beginning");
1138 foreach ($pages as $idx => $questions) {
1139 if (($idx + 1) != $this->current_page && ($idx + 2) != $this->current_page) {
1140 $question = array_shift($questions);
1141 if ($question[
"questionblock_id"]) {
1142 $pages_drop[$idx + 1] =
$lng->txt(
"survey_behind_page") .
" " . $question[
"questionblock_title"];
1144 $pages_drop[$idx + 1] =
$lng->txt(
"survey_behind_page") .
" " . strip_tags($question[
"title"]);
1149 $pos->setOptions($pages_drop);
1150 $form->addItem($pos);
1153 $form->addCommandButton(
"movePage",
$lng->txt(
"submit"));
1154 $form->addCommandButton(
"renderPage",
$lng->txt(
"cancel"));
1156 return $tpl->setContent($form->getHTML());
1169 $target_page = $this->current_page - 1;
1170 $source_page = $_REQUEST[
"old_pos"] - 1;
1172 $pages = $this->
object->getSurveyPages();
1173 foreach ($pages[$source_page] as $question) {
1174 $questions[] = $question[
"question_id"];
1179 if ($_REQUEST[
"pgov"] !=
"fst") {
1183 $target = $pages[$target_page];
1184 if ($position == 0) {
1185 $target = array_shift($target);
1187 $target = array_pop($target);
1189 $this->
object->moveQuestions($questions, $target[
"question_id"], $position);
1191 if ($target_page < $source_page && $position) {
1192 $this->current_page++;
1195 ilUtil::sendSuccess(
$lng->txt(
"survey_page_moved"),
true);
1196 $ilCtrl->setParameter($this,
"pgov", $this->current_page);
1197 $ilCtrl->redirect($this,
"renderPage");
1212 if (!$this->has_datasets) {
1214 $button->setCaption(
"survey_add_new_question");
1215 $button->setUrl($ilCtrl->getLinkTarget($this,
"addQuestionToolbarForm"));
1216 $ilToolbar->addStickyItem($button);
1218 if ($this->object->isPoolActive()) {
1223 is_array($a_pages[$this->current_page - 1])) {
1224 $last_on_page = $a_pages[$this->current_page - 1];
1225 $last_on_page = array_pop($last_on_page);
1226 $last_on_page = $last_on_page[
"question_id"];
1229 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
1230 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos", $last_on_page .
"c");
1232 $cmd = (
$ilUser->getPref(
'svy_insert_type') == 1 ||
1233 strlen(
$ilUser->getPref(
'svy_insert_type')) == 0)
1234 ?
'browseForQuestions' 1235 :
'browseForQuestionblocks';
1238 $button->setCaption(
"browse_for_questions");
1239 $button->setUrl($ilCtrl->getLinkTarget($this->editor_gui, $cmd));
1240 $ilToolbar->addStickyItem($button);
1242 $ilCtrl->setParameter($this->editor_gui,
"pgov",
"");
1243 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos",
"");
1247 $ilToolbar->addSeparator();
1255 $ilCtrl->setParameter($this,
"pg", $this->current_page - 1);
1257 $button->setCaption(
"survey_prev_question");
1258 if ($this->has_previous_page) {
1259 $button->setUrl($ilCtrl->getLinkTarget($this,
"renderPage"));
1261 $button->setDisabled(!$this->has_previous_page);
1262 $ilToolbar->addStickyItem($button);
1264 $ilCtrl->setParameter($this,
"pg", $this->current_page + 1);
1266 $button->setCaption(
"survey_next_question");
1267 if ($this->has_next_page) {
1268 $button->setUrl($ilCtrl->getLinkTarget($this,
"renderPage"));
1270 $button->setDisabled(!$this->has_next_page);
1271 $ilToolbar->addStickyItem($button);
1273 $ilCtrl->setParameter($this,
"pg", $this->current_page);
1275 foreach ($a_pages as $idx => $questions) {
1277 $page = array_shift($page);
1278 if ($page[
"questionblock_id"]) {
1279 $pages_drop[$idx + 1] = $page[
"questionblock_title"];
1281 if (
sizeof($questions) > 1) {
1282 foreach ($questions as $question) {
1283 $pages_drop[($idx + 1) .
"__" . $question[
"question_id"]] =
"- " . $question[
"title"];
1287 $pages_drop[$idx + 1] = strip_tags($page[
"title"]);
1293 if (is_array($pages_drop) && count($pages_drop) > 1) {
1296 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1299 $si->addCustomAttribute(
"onChange=\"forms['ilToolbar'].submit();\"");
1300 $si->setOptions($pages_drop);
1301 $si->setValue($this->current_page);
1302 $ilToolbar->addInputItem(
$si,
true);
1306 $cmd->setValue(
"1");
1307 $ilToolbar->addInputItem($cmd);
1309 if (!$this->has_datasets) {
1310 $ilToolbar->addSeparator();
1312 $ilCtrl->setParameter($this,
"csum", md5(print_r($a_pages[$this->current_page - 1],
true)));
1313 $url = $ilCtrl->getLinkTarget($this,
"deleteBlock");
1314 $ilCtrl->setParameter($this,
"csum",
"");
1317 $button->setCaption(
"survey_delete_page");
1318 $button->setUrl(
$url);
1319 $ilToolbar->addButtonInstance($button);
1321 $ilToolbar->addSeparator();
1324 $button->setCaption(
"survey_move_page");
1325 $button->setUrl($ilCtrl->getLinkTarget($this,
"movePageForm"));
1326 $ilToolbar->addButtonInstance($button);
1341 $pages = $this->
object->getSurveyPages();
1342 $this->has_next_page = ($this->current_page <
sizeof($pages));
1343 $this->has_previous_page = ($this->current_page > 1);
1347 if ($this->has_datasets) {
1349 $mess = $mbox->getHTML();
1352 $ilCtrl->setParameter($this,
"pg", $this->current_page);
1353 $ilCtrl->setParameter($this,
"pgov",
"");
1357 $ttpl =
new ilTemplate(
"tpl.il_svy_svy_page_view.html",
true,
true,
"Modules/Survey");
1358 $ttpl->setVariable(
"FORM_ACTION", $ilCtrl->getFormAction($this));
1359 $lng->loadLanguageModule(
"form");
1361 $read_only = ($this->has_datasets || !
$rbacsystem->checkAccess(
"write", $this->ref_id));
1363 $commands = $multi_commands = array();
1367 if (!
$_SESSION[
"survey_page_view"][$this->ref_id][
"clipboard"]) {
1368 $multi_commands[] = array(
"cmd" =>
"multiDelete",
"text" =>
$lng->txt(
"delete"));
1369 $multi_commands[] = array(
"cmd" =>
"multiCut",
"text" =>
$lng->txt(
"cut"));
1370 $multi_commands[] = array(
"cmd" =>
"multiCopy",
"text" =>
$lng->txt(
"copy"));
1371 $multi_commands[] = array(
"cmd" =>
"selectAll",
"text" =>
$lng->txt(
"select_all"));
1373 if (!$this->suppress_clipboard_msg) {
1376 $multi_commands[] = array(
"cmd" =>
"clearClipboard",
"text" =>
$lng->txt(
"survey_dnd_clear_clipboard"));
1380 $lng->loadLanguageModule(
"content");
1381 $ttpl->setCurrentBlock(
"help_section");
1382 $ttpl->setVariable(
"TXT_ADD_EL",
$lng->txt(
"cont_add_elements"));
1385 $ttpl->setVariable(
"TXT_DRAG",
$lng->txt(
"cont_drag_and_drop_elements"));
1386 $ttpl->setVariable(
"TXT_SEL",
$lng->txt(
"cont_double_click_to_delete"));
1387 $ttpl->parseCurrentBlock();
1389 $ttpl->setVariable(
"DND_INIT_JS",
"initDragElements();");
1403 $ttpl->setVariable(
"WYSIWYG_BLOCKFORMATS", $tiny->_buildAdvancedBlockformatsFromHTMLTags($tags));
1404 $ttpl->setVariable(
"WYSIWYG_VALID_ELEMENTS", $tiny->_getValidElementsFromHTMLTags($tags));
1406 $buttons_1 = $tiny->_buildAdvancedButtonsFromHTMLTags(1, $tags);
1407 $buttons_2 = $tiny->_buildAdvancedButtonsFromHTMLTags(2, $tags) .
',' .
1408 $tiny->_buildAdvancedTableButtonsFromHTMLTags($tags) .
1409 ($tiny->getStyleSelect() ?
',styleselect' :
'');
1410 $buttons_3 = $tiny->_buildAdvancedButtonsFromHTMLTags(3, $tags);
1417 if (count($multi_commands) > 0) {
1418 foreach ($multi_commands as $cmd) {
1419 $ttpl->setCurrentBlock(
"multi_cmd");
1420 $ttpl->setVariable(
"ORG_CMD_MULTI",
"renderPage");
1421 $ttpl->setVariable(
"MULTI_CMD", $cmd[
"cmd"]);
1422 $ttpl->setVariable(
"MULTI_CMD_TXT", $cmd[
"text"]);
1423 $ttpl->parseCurrentBlock();
1426 $ttpl->setCurrentBlock(
"multi_cmds");
1427 $ttpl->setVariable(
"MCMD_ALT",
$lng->txt(
"commands"));
1429 $ttpl->parseCurrentBlock();
1434 $pages[$this->current_page - 1],
1435 $this->has_previous_page,
1436 $this->has_next_page,
1440 $tpl->setContent($mess . $ttpl->get());
1444 $tpl->addJavascript(
"./Modules/Survey/js/SurveyPageView.js");
1457 public function getPageNodes(array $a_questions, $a_has_previous_page =
false, $a_has_next_page =
false, $a_readonly =
false)
1462 $ttpl =
new ilTemplate(
"tpl.il_svy_svy_page_view_nodes.html",
true,
true,
"Modules/Survey");
1464 $has_clipboard = (bool)
$_SESSION[
"survey_page_view"][$this->ref_id][
"clipboard"];
1468 $first_question = $a_questions;
1469 $first_question = array_shift($first_question);
1471 $compress_view =
false;
1472 if ($first_question[
"questionblock_id"]) {
1475 if (!$a_readonly && !$has_clipboard) {
1476 $menu[] = array(
"cmd" =>
"editBlock",
"text" =>
$lng->txt(
"edit"));
1479 if ($first_question[
"questionblock_show_blocktitle"]) {
1480 $block_status =
$lng->txt(
"survey_block_visible");
1482 $block_status =
$lng->txt(
"survey_block_hidden");
1488 $first_question[
"questionblock_id"],
1489 $first_question[
"questionblock_title"] .
" (" . $block_status .
")",
1496 if (count($a_questions) > 1) {
1497 $compress_view = $first_question[
"questionblock_compress_view"];
1505 $questionpools = array_keys($this->object->getQuestionpoolTitles(
true));
1507 $counter = $question_count;
1509 foreach ($a_questions as $idx => $question) {
1515 if (!$has_clipboard) {
1516 foreach ($questiontypes as $trans => $item) {
1517 $menu[] = array(
"cmd" =>
"addQuestion_" . $item[
"questiontype_id"],
1518 "text" => sprintf(
$lng->txt(
"svy_page_add_question"), $trans));
1521 if ($this->object->isPoolActive()) {
1522 $menu[] = array(
"cmd" =>
"addPoolQuestion",
1523 "text" =>
$lng->txt(
"browse_for_questions"));
1526 $menu[] = array(
"cmd" =>
"paste",
"text" =>
$lng->txt(
"survey_dnd_paste"));
1530 $this->
renderPageNode($ttpl,
"droparea", $question[
"question_id"], null, $menu,
true);
1533 $question_gui = $this->
object->getQuestionGUI($question[
"type_tag"], $question[
"question_id"]);
1534 $question_form = $question_gui->getWorkingForm(
1536 $this->object->getShowQuestionTitles(),
1537 $question[
"questionblock_show_questiontext"],
1539 $this->
object->getSurveyId(),
1545 if (!$a_readonly && !$has_clipboard) {
1546 $menu[] = array(
"cmd" =>
"editQuestion",
"text" =>
$lng->txt(
"edit"));
1547 $menu[] = array(
"cmd" =>
"cutQuestion",
"text" =>
$lng->txt(
"cut"));
1548 $menu[] = array(
"cmd" =>
"copyQuestion",
"text" =>
$lng->txt(
"copy"));
1550 if (
sizeof($a_questions) > 1 && $idx > 0) {
1551 $menu[] = array(
"cmd" =>
"splitPage",
"text" =>
$lng->txt(
"survey_dnd_split_page"));
1553 if ($a_has_next_page) {
1554 $menu[] = array(
"cmd" =>
"moveNext",
"text" =>
$lng->txt(
"survey_dnd_move_next"));
1556 if ($a_has_previous_page) {
1557 $menu[] = array(
"cmd" =>
"movePrevious",
"text" =>
$lng->txt(
"survey_dnd_move_previous"));
1560 $menu[] = array(
"cmd" =>
"deleteQuestion",
"text" =>
$lng->txt(
"delete"));
1563 if ($question[
"heading"]) {
1564 $menu[] = array(
"cmd" =>
"editHeading",
"text" =>
$lng->txt(
"survey_edit_heading"));
1565 $menu[] = array(
"cmd" =>
"deleteHeading",
"text" =>
$lng->txt(
"survey_delete_heading"));
1567 $menu[] = array(
"cmd" =>
"addHeading",
"text" =>
$lng->txt(
"add_heading"));
1571 if ($first_question[
"questionblock_show_questiontext"]) {
1572 $question_title_status =
$lng->txt(
"survey_question_text_visible");
1574 $question_title_status =
$lng->txt(
"survey_question_text_hidden");
1580 $question[
"question_id"],
1585 $question_title_status,
1586 $question[
"heading"]
1589 $ilCtrl->setParameter($this,
"eqid",
"");
1598 if (!$has_clipboard) {
1599 foreach ($questiontypes as $trans => $item) {
1600 $menu[] = array(
"cmd" =>
"addQuestion_" . $item[
"questiontype_id"],
1601 "text" => sprintf(
$lng->txt(
"svy_page_add_question"), $trans));
1604 if ($this->object->isPoolActive()) {
1605 $menu[] = array(
"cmd" =>
"addPoolQuestion",
1606 "text" =>
$lng->txt(
"browse_for_questions"));
1609 $menu[] = array(
"cmd" =>
"paste",
"text" =>
$lng->txt(
"survey_dnd_paste"));
1615 return $ttpl->get();
1630 public function 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)
1635 $node_id = $a_type .
"_" . $a_id;
1640 foreach ($a_menu as $mcnt => $menu_item) {
1641 $ilCtrl->setParameter($this,
"il_hform_node", $node_id);
1642 $ilCtrl->setParameter($this,
"il_hform_subcmd", $menu_item[
"cmd"]);
1643 $url = $ilCtrl->getLinkTarget($this,
"renderPage");
1644 $ilCtrl->setParameter($this,
"il_hform_subcmd",
"");
1645 $ilCtrl->setParameter($this,
"il_hform_node",
"");
1648 $a_tpl->
setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
1658 } elseif ($a_menu) {
1660 foreach ($a_menu as $mcnt => $menu_item) {
1661 $ilCtrl->setParameter($this,
"il_hform_node", $node_id);
1662 $ilCtrl->setParameter($this,
"il_hform_subcmd", $menu_item[
"cmd"]);
1663 $url = $ilCtrl->getLinkTarget($this,
"renderPage");
1664 $ilCtrl->setParameter($this,
"il_hform_subcmd",
"");
1665 $ilCtrl->setParameter($this,
"il_hform_node",
"");
1668 $a_tpl->
setVariable(
"TXT_ACTION_CMD", $menu_item[
"text"]);
1675 if ($a_content !== null &&
1676 $a_type ==
"question" &&
1678 $a_content =
"<div class=\"questionheading\">" . $a_heading .
"</div>" .
1683 $a_tpl->
setVariable(
"TXT_NODE_CONTENT_ACTIONS", $a_content);
1685 $a_tpl->
setVariable(
"TXT_NODE_CONTENT_NO_ACTIONS", $a_content);
1688 if ($a_content !== null) {
1690 $selectable =
false;
1693 $caption =
$lng->txt(
"questionblock");
1697 $caption =
$lng->txt(
"question") .
": " . $a_subtitle;
1703 $caption =
$lng->txt(
"heading");
1711 $caption .=
" (" . $a_status .
")";
1736 return $lng->txt(
"survey_auto_block_title");
1744 if ($node ==
"page_end") {
1745 $pos = $this->
object->getSurveyPages();
1746 $pos = array_pop($pos[$this->current_page - 1]);
1747 $pos = $pos[
"question_id"] .
"a";
1752 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
1753 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos", $pos);
1755 $cmd = (
$ilUser->getPref(
'svy_insert_type') == 1 || strlen(
$ilUser->getPref(
'svy_insert_type')) == 0) ?
'browseForQuestions' :
'browseForQuestionblocks';
1756 $ilCtrl->redirect($this->editor_gui, $cmd);
multiCopy($a_id)
Add questions to be copied to clipboard.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
movePrevious($a_id)
Move question to previous page.
paste($a_id)
Paste from clipboard.
__construct(ilObjSurvey $a_survey, ilSurveyEditorGUI $a_survey_editor_gui)
Constructor.
static _hasDatasets($survey_id)
deleteQuestion($a_id)
Confirm removing question(s) from survey.
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
movePageForm()
Move current page.
addQuestion($a_type, $a_use_pool, $a_pos, $a_special_position)
Call add question to survey form.
static _isComplete($question_id)
Checks whether the question is complete or not.
static get($a_glyph, $a_text="")
Get glyph html.
getPageNodes(array $a_questions, $a_has_previous_page=false, $a_has_next_page=false, $a_readonly=false)
Get Form HTML.
editHeading($a_id)
Edit question heading.
clearClipboard()
Empty clipboard.
callEditor($a_cmd, $a_param, $a_value)
static _getQuestionGUI($questiontype, $question_id=-1)
Creates a question gui representation.
static removeRedundantSeparators($a_string)
Removes redundant seperators and removes ,, and , at the first or last position of the string...
addHeading($a_id)
Add heading to question.
addPoolQuestion($pos, $node)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
setVariable($variable, $value='')
Sets a variable value.
addQuestionToolbar()
Add question to survey action (used in toolbar)
multiCut($a_id)
Add questions to be cut to clipboard.
deleteHeading($a_id)
Delete question heading.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
touchBlock($block)
overwrites ITX::touchBlock.
Message box for survey, when data is alrady available.
getAutoBlockTitle()
Get name for newly created blocks.
addQuestionToolbarForm()
Add question to survey form (used in toolbar)
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
setCurrentBlock($part="DEFAULT")
Überladene Funktion, die sich hier lokal noch den aktuellen Block merkt.
static initDragDrop(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Drag and Drop.
insertQuestionBlock($a_block_id)
Copy and insert questions from block.
appendNewQuestionToSurvey($a_new_id, $a_duplicate=true, $a_force_duplicate=false)
Add new question to survey (database part)
copyQuestion($a_id)
Add question to be copied to clipboard.
static _getQuestiontypes()
Creates a list of all available question types.
editQuestion($a_id)
Edit question.
getRefId()
get reference id public
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.
cutQuestion($a_id)
Add question to be cut to clipboard.
confirmRemoveQuestions()
Remove question(s) from survey.
static getLogger($a_component_id)
Get component logger.
insertNewQuestion($a_new_id)
Add new question to survey.
movePage()
Move current page to new position.
renderPage()
render questions per page
deleteBlock()
Confirm removing question block.
editBlock($a_id)
Edit question block.
moveNext($a_id)
Move question to next page.
splitPage($a_id)
Split current page in 2 pages.
parseCurrentBlock($part="DEFAULT")
Überladene Funktion, die auf den aktuelle Block vorher noch ein replace ausführt public...
dnd()
Move questions in page.
renderToolbar($a_pages)
Render toolbar form.
determineCurrentPage()
determine current page