27 protected \ILIAS\Survey\PrintView\GUIService
$print;
28 protected \ILIAS\HTTP\Services
$http;
29 protected \ILIAS\DI\UIServices
$ui;
58 $this->
lng = $DIC->language();
59 $this->
ctrl = $DIC->ctrl();
60 $this->rbacsystem = $DIC->rbac()->system();
61 $this->db = $DIC->database();
62 $this->
tabs = $DIC->tabs();
63 $this->tpl = $DIC[
"tpl"];
64 $this->
toolbar = $DIC->toolbar();
65 $this->
user = $DIC->user();
66 $this->editor_gui = $a_survey_editor_gui;
67 $this->ref_id = $a_survey->
getRefId();
68 $this->
object = $a_survey;
70 $this->edit_manager = $DIC->survey()
74 $this->svy_request = $DIC->survey()
79 $this->pgov = $this->svy_request->getTargetPosition();
80 $this->
ui = $DIC->ui();
81 $this->
http = $DIC->http();
82 $this->print = $DIC->survey()
94 $cmd = $ilCtrl->getCmd(
"renderPage");
95 $next_class = $ilCtrl->getNextClass($this);
97 switch ($next_class) {
101 $has_content =
false;
103 if ($rbacsystem->
checkAccess(
"write", $this->ref_id)) {
105 if ($this->svy_request->getNewId()) {
107 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
108 $ilCtrl->redirect($this,
"questions");
112 if ($this->svy_request->getHForm(
"subcmd")) {
113 $subcmd = $this->svy_request->getHForm(
"subcmd");
116 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
120 $this->editor_gui->setRequestedPgov($this->pgov);
122 $id = explode(
"_", $this->svy_request->getHForm(
"node"));
123 $id = (
int) ($id[1] ?? 0);
126 if (strpos($this->svy_request->getHForm(
"subcmd"),
"multi") === 0) {
127 if ($this->svy_request->getHForm(
"multi")) {
130 foreach (explode(
";", $this->svy_request->getHForm(
"multi")) as $item) {
131 $item_arr = explode(
"_", $item);
132 $id[] = (
int) array_pop($item_arr);
135 if ($subcmd ===
"multiDelete") {
136 $subcmd =
"deleteQuestion";
138 } elseif ($subcmd ===
"multiDelete") {
140 $this->tpl->setOnScreenMessage(
'failure', $lng->
txt(
"no_checkbox"),
true);
141 $ilCtrl->redirect($this,
"renderPage");
143 $this->tpl->setOnScreenMessage(
'failure', $lng->
txt(
"no_checkbox"));
147 if (strpos($subcmd,
"addQuestion") === 0) {
148 $type = explode(
"_", $subcmd);
152 $this->
object->getPoolUsage(),
154 $this->svy_request->getHForm(
"node")
158 case "deleteQuestion":
160 $ids = (!is_array($id))
166 if ($id === 0 && in_array($subcmd, [
"multiCut",
"multiCopy"])) {
169 $has_content = $this->$subcmd($id, $this->svy_request->getHForm(
"node"));
186 $current_page = null;
187 $jump = $this->svy_request->getJump();
189 $jump_parts = explode(
"__", $jump);
190 $current_page = (
int) ($jump_parts[0] ?? 1);
193 if (!$current_page) {
196 if (!$current_page) {
197 $current_page = $this->svy_request->getPage();
199 if (!$current_page) {
202 $this->current_page = (
int) $current_page;
212 bool $a_duplicate =
true,
213 bool $a_force_duplicate =
false 216 $this->log->debug(
"append question, id: " . $a_new_id .
", duplicate: " . $a_duplicate .
", force: " . $a_force_duplicate);
219 $result =
$ilDB->queryF(
220 "SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
222 array($this->
object->getSurveyId())
224 $sequence = $result->numRows();
229 $survey_question_id = $this->
object->duplicateQuestionForSurvey($a_new_id, $a_force_duplicate);
233 $survey_question_id = $a_new_id;
237 if ($this->
object->isQuestionInSurvey($survey_question_id)) {
238 return $survey_question_id;
241 $next_id =
$ilDB->nextId(
'svy_svy_qst');
242 $affectedRows =
$ilDB->manipulateF(
243 "INSERT INTO svy_svy_qst (survey_question_id, survey_fi," .
244 "question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
245 array(
'integer',
'integer',
'integer',
'integer',
'integer'),
246 array($next_id, $this->
object->getSurveyId(), $survey_question_id, $sequence, time())
249 $this->log->debug(
"insert svy_svy_qst, id: " . $next_id .
", qfi: " . $survey_question_id .
", seq: " . $sequence);
251 return $survey_question_id;
262 $this->tpl->setOnScreenMessage(
'failure', $lng->
txt(
"survey_error_insert_incomplete_question"));
265 $this->
object->loadQuestionsFromDb();
266 $this->
object->saveCompletionStatus();
268 $pos = $this->svy_request->getTargetQuestionPosition();
271 if (substr($pos, -1) !==
"c") {
273 $current = $this->
object->getSurveyPages();
274 $current = $current[$this->current_page - 1];
275 if (count($current) === 1) {
279 $this->
object->createQuestionblock(
283 array((
int) $pos, $a_new_id)
286 $block_id = array_pop($current);
287 $block_id = $block_id[
"questionblock_id"];
289 $this->
object->addQuestionToBlock($a_new_id, $block_id);
293 elseif ((
int) $pos) {
294 $pos = (
int) $pos .
"a";
295 $this->current_page++;
299 $first = $this->
object->getSurveyPages();
301 $first = array_shift($first);
302 $pos = $first[
"question_id"] .
"b";
303 $this->current_page = 1;
307 $this->
object->moveQuestions(
310 ((substr($pos, -1) ===
"a") ? 1 : 0)
313 $this->
object->fixSequenceStructure();
324 $question_ids = $this->
object->getQuestionblockQuestionIds($a_block_id);
325 foreach ($question_ids as $qid) {
329 if (count($new_ids)) {
330 $this->
object->loadQuestionsFromDb();
332 $pos = $this->svy_request->getTargetQuestionPosition();
335 if (substr($pos, -1) !==
"c") {
337 $current = $this->
object->getSurveyPages();
338 $current = $current[$this->current_page - 1];
339 if (count($current) === 1) {
343 $this->
object->createQuestionblock(
347 array((
int) $pos) + $new_ids
350 $block_id = array_pop($current);
351 $block_id = $block_id[
"questionblock_id"];
353 foreach ($new_ids as $qid) {
354 $this->
object->addQuestionToBlock($qid, $block_id);
361 $this->
object->createQuestionblock(
370 $pos = (
int) $pos .
"a";
374 $first = $this->
object->getSurveyPages();
376 $first = array_shift($first);
377 $pos = $first[
"question_id"] .
"b";
382 $this->
object->moveQuestions(
385 ((substr($pos, -1) ===
"a") ? 1 : 0)
402 string $a_special_position
410 foreach ($questiontypes as $item) {
411 if ($item[
"questiontype_id"] == $a_type) {
412 $type_trans = $item[
"type_tag"];
419 if ($a_special_position ===
"toolbar") {
420 $id = $this->
object->getSurveyPages();
421 if ($a_pos && $a_pos !==
"fst") {
423 $id = array_pop($id);
424 $id = $id[
"question_id"] .
"c";
430 elseif ($a_special_position ===
"page_end") {
431 $id = $this->
object->getSurveyPages();
432 $id =
$id[$this->current_page - 1];
434 $id =
$id[
"question_id"] .
"a";
440 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos",
$id);
441 $ilCtrl->setParameter($this->editor_gui,
"sel_question_types", $type_trans);
442 if ($this->svy_request->getPoolUsage() === 0) {
443 $ilTabs->clearSubTabs();
444 $this->editor_gui->createQuestionObject(null, $type_trans,
$id);
446 $this->editor_gui->executeCreateQuestionObject($type_trans, null,
$id);
453 $q_gui->object->setObjId($this->
object->getId());
454 $q_gui->object->createNewQuestion();
455 $q_gui_class = get_class($q_gui);
458 $ilCtrl->setParameterByClass($q_gui_class,
"pgov", $this->current_page);
459 $ilCtrl->setParameterByClass($q_gui_class,
"pgov_pos",
$id);
460 $ilCtrl->setParameterByClass($q_gui_class,
"ref_id", $this->ref_id);
461 $ilCtrl->setParameterByClass($q_gui_class,
"new_for_survey", $this->ref_id);
462 $ilCtrl->setParameterByClass($q_gui_class,
"q_id", $q_gui->object->getId());
463 $ilCtrl->setParameterByClass($q_gui_class,
"sel_question_types", $q_gui->getQuestionType());
464 $ilCtrl->redirectByClass($q_gui_class,
"editQuestion");
476 $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
"survey_questions_to_clipboard_cut"));
477 $this->suppress_clipboard_msg =
true;
479 $this->edit_manager->setQuestionClipboard(
494 $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
"survey_questions_to_clipboard_copy"));
495 $this->suppress_clipboard_msg =
true;
497 $this->edit_manager->setQuestionClipboard(
514 if (count($a_id) > 0) {
515 $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
"survey_questions_to_clipboard_cut"));
516 $this->suppress_clipboard_msg =
true;
518 $this->edit_manager->setQuestionClipboard(
535 if (count($a_id) > 0) {
536 $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
"survey_questions_to_clipboard_copy"));
537 $this->suppress_clipboard_msg =
true;
539 $this->edit_manager->setQuestionClipboard(
553 $this->edit_manager->clearQuestionClipboard($this->ref_id);
560 protected function paste(
int $a_id): void
562 $source_page = $this->edit_manager->getQuestionClipboardSourcePage($this->ref_id);
563 $qids = $this->edit_manager->getQuestionClipboardQuestions($this->ref_id);
564 $mode = $this->edit_manager->getQuestionClipboardMode($this->ref_id);
565 $pages = $this->
object->getSurveyPages();
566 $source = $pages[$source_page - 1];
567 $target = $pages[$this->current_page - 1];
571 foreach (
$source as $src_qst) {
572 if (in_array($src_qst[
"question_id"], $qids)) {
573 $nodes[] = $src_qst[
"question_id"];
579 if ($this->svy_request->getHForm(
"node") ===
"page_end") {
581 $a_id = array_pop($a_id);
582 $a_id = $a_id[
"question_id"];
587 if ($mode ===
"cut") {
589 if ($source_page == $this->current_page) {
591 if (count($nodes) <= count(
$source)) {
592 $this->
object->moveQuestions($nodes, $a_id, $pos);
598 $source_block_id =
false;
601 $source_block_id = array_shift($source_block_id);
602 $source_block_id = $source_block_id[
"questionblock_id"];
605 if (count(
$source) > count($nodes)) {
606 foreach ($nodes as $qid) {
607 $this->
object->removeQuestionFromBlock($qid, $source_block_id);
612 $this->
object->unfoldQuestionblocks(array($source_block_id));
617 if (count(
$source) === count($nodes) && $source_page < $this->current_page) {
618 $this->current_page--;
624 elseif ($mode ===
"copy") {
626 foreach ($this->
object->getSurveyPages() as $page) {
627 foreach ($page as $question) {
628 $titles[] = $question[
"title"];
633 $question_pointer = array();
634 foreach ($nodes as $qid) {
638 $title = $question->getTitle();
640 foreach ($titles as $existing_title) {
641 #21278 preg_quote with delimiter 642 if (preg_match(
"/" . preg_quote($title,
"/") .
" \(([0-9]+)\)$/", $existing_title, $match)) {
643 $max = max($match[1], $max);
647 $title .=
" (" . ($max + 1) .
")";
652 $question->setTitle($title);
655 $question->saveToDb();
657 $question_pointer[$qid] = $question->getId();
662 $this->
object->cloneTextblocks($question_pointer);
664 $this->
object->loadQuestionsFromDb();
666 $nodes = array_values($question_pointer);
673 if (count($target) === 1) {
674 $nodes = array_merge(array($a_id), $nodes);
677 $this->
object->createQuestionblock(
686 $target_block_id = $target;
687 $target_block_id = array_shift($target_block_id);
688 $target_block_id = $target_block_id[
"questionblock_id"];
690 foreach ($nodes as $qid) {
691 $this->
object->addQuestionToBlock($qid, $target_block_id);
695 $this->
object->moveQuestions($nodes, $a_id, $pos);
704 protected function dnd(): void
706 $source_arr = explode(
"_", $this->svy_request->getHForm(
"source"));
707 $target_arr = explode(
"_", $this->svy_request->getHForm(
"target"));
708 $source_id = (
int) array_pop($source_arr);
709 if ($this->svy_request->getHForm(
"target") !==
"droparea_end") {
713 $page = $this->
object->getSurveyPages();
714 $page = $page[$this->current_page - 1];
715 $last = array_pop($page);
720 $this->
object->moveQuestions(array($source_id),
$target_id, $pos);
732 $ilCtrl->
setParameter($this->editor_gui,
"pgov", $this->current_page);
733 $this->tpl->setOnScreenMessage(
'question', $lng->
txt(
"remove_questions"));
735 $page = $this->
object->getSurveyPages();
736 $page = $page[$this->current_page - 1];
739 if ($this->svy_request->getCheckSum() !== md5(print_r($page,
true))) {
740 $ilCtrl->redirect($this,
"renderPage");
743 $page = array_shift($page);
744 $block_id = $page[
"questionblock_id"];
746 $this->editor_gui->removeQuestionsForm(array($block_id), array(), array());
748 $this->editor_gui->removeQuestionsForm(array(), array($page[
"question_id"]), array());
761 $ilCtrl->
setParameter($this->editor_gui,
"pgov", $this->current_page);
762 $this->editor_gui->removeQuestionsForm(array(), $a_id, array());
771 $ids = $this->svy_request->getQuestionIds();
773 $pages = $this->
object->getSurveyPages();
774 $source = $pages[$this->current_page - 1];
777 $block_id = array_shift($block_id);
778 $block_id = $block_id[
"questionblock_id"];
780 if (count($ids) && count(
$source) > count($ids)) {
782 if (count(
$source) - count($ids) === 1) {
783 $this->
object->unfoldQuestionblocks(array($block_id));
787 foreach ($ids as $qid) {
788 $this->
object->removeQuestionFromBlock($qid, $block_id);
792 $this->
object->removeQuestions($ids, array());
798 $this->
object->removeQuestions(array(), array($block_id));
802 $this->
object->removeQuestions($ids, array());
806 if ($this->current_page > 1) {
807 $this->current_page--;
811 $this->
object->saveCompletionStatus();
814 $ilCtrl->setParameter($this,
"pgov", $this->current_page);
815 $ilCtrl->redirect($this,
"renderPage");
823 $this->
callEditor(
"editQuestionblock",
"bl_id", $a_id);
831 $this->
callEditor(
"addHeading",
"q_id", $a_id);
839 $this->
callEditor(
"editHeadingObject",
"q_id", $a_id);
847 $this->
callEditor(
"removeHeading",
"q_id", $a_id);
860 $ctrl->
setParameter($this->editor_gui, $a_param, $a_value);
861 $ctrl->
redirect($this->editor_gui, $a_cmd);
873 $pages = $this->
object->getSurveyPages();
874 $source = $pages[$this->current_page - 1];
876 $block_questions = array();
877 $add = $block_id =
false;
878 foreach (
$source as $idx => $item) {
879 if ($item[
"question_id"] == $a_id) {
880 $block_id = $item[
"questionblock_id"];
884 $block_questions[] = $item[
"question_id"];
890 $this->
object->unfoldQuestionblocks(array($block_id));
894 foreach ($block_questions as $qid) {
895 $this->
object->removeQuestionFromBlock($qid, $block_id);
900 if (count($block_questions) > 1) {
902 $this->
object->createQuestionblock(
910 $this->current_page++;
918 $pages = $this->
object->getSurveyPages();
919 $source = $pages[$this->current_page - 1];
921 if (count($target)) {
924 $target_block_id =
$target_id[
"questionblock_id"];
930 $block_id = array_shift($block_id);
931 $block_id = $block_id[
"questionblock_id"];
936 $this->
object->unfoldQuestionblocks(array($block_id));
939 $this->
object->removeQuestionFromBlock($a_id, $block_id);
944 $this->
object->moveQuestions(array($a_id),
$target_id, 0);
947 if (count($target) < 2) {
949 $this->
object->createQuestionblock(
957 $this->
object->addQuestionToBlock($a_id, $target_block_id);
962 $this->current_page++;
973 $pages = $this->
object->getSurveyPages();
974 $source = $pages[$this->current_page - 1];
975 $target = $pages[$this->current_page - 2];
976 if (count($target)) {
979 $target_block_id =
$target_id[
"questionblock_id"];
985 $block_id = array_shift($block_id);
986 $block_id = $block_id[
"questionblock_id"];
991 $this->
object->unfoldQuestionblocks(array($block_id));
994 $this->
object->removeQuestionFromBlock($a_id, $block_id);
999 $this->
object->moveQuestions(array($a_id),
$target_id, 1);
1002 if (count($target) < 2) {
1004 $this->
object->createQuestionblock(
1012 $this->
object->addQuestionToBlock($a_id, $target_block_id);
1015 $this->current_page--;
1023 $data = $this->
object->getSurveyQuestions();
1026 $q_gui =
$data[
"type_tag"] .
"GUI";
1027 $ilCtrl->setParameterByClass($q_gui,
"pgov", $this->current_page);
1028 $ilCtrl->setParameterByClass($q_gui,
"q_id", $a_id);
1030 $ilCtrl->redirectByClass($q_gui,
"editQuestion");
1043 $form->setFormAction($ilCtrl->getFormAction($this,
"addQuestionToolbar"));
1044 $form->setTitle($lng->
txt(
"survey_add_new_question"));
1048 $type_map = array();
1049 foreach ($questiontypes as $trans => $item) {
1050 $type_map[$item[
"questiontype_id"]] = $trans;
1053 $si->setOptions($type_map);
1054 $form->addItem($si);
1056 $pages = $this->
object->getSurveyPages();
1058 $pages_drop = array(
"fst" => $lng->
txt(
"survey_at_beginning"));
1059 foreach ($pages as $idx => $questions) {
1060 $question = array_shift($questions);
1061 if ($question[
"questionblock_id"]) {
1062 $pages_drop[$idx + 1] = $lng->
txt(
"survey_behind_page") .
" " . $question[
"questionblock_title"];
1064 $pages_drop[$idx + 1] = $lng->
txt(
"survey_behind_page") .
" " . strip_tags($question[
"title"]);
1068 $pos->setOptions($pages_drop);
1069 $form->addItem($pos);
1071 $pos->setValue($this->current_page);
1075 $pos->setValue(
"fst");
1076 $form->addItem($pos);
1079 if ($this->
object->getPoolUsage()) {
1080 $this->editor_gui->createQuestionObject($form);
1083 $form->addCommandButton(
"addQuestionToolbar", $lng->
txt(
"create"));
1084 $form->addCommandButton(
"renderPage", $lng->
txt(
"cancel"));
1097 $pool_active = $this->
object->getPoolUsage();
1099 if ($this->svy_request->getPoolUsage() === 0 && $pool_active) {
1100 $this->tpl->setOnScreenMessage(
'failure', $lng->
txt(
"select_one"),
true);
1106 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
1108 $this->svy_request->getQuestionType(),
1127 $form->setFormAction($ilCtrl->getFormAction($this,
"movePage"));
1128 $form->setTitle($lng->
txt(
"survey_move_page"));
1131 $old_pos->setValue($this->current_page);
1132 $form->addItem($old_pos);
1134 $pages = $this->
object->getSurveyPages();
1136 $pages_drop = array();
1137 if ((
int) $this->current_page !== 1) {
1138 $pages_drop[
"fst"] = $lng->
txt(
"survey_at_beginning");
1140 foreach ($pages as $idx => $questions) {
1141 if (($idx + 1) != $this->current_page && ($idx + 2) != $this->current_page) {
1142 $question = array_shift($questions);
1143 if ($question[
"questionblock_id"]) {
1144 $pages_drop[$idx + 1] = $lng->
txt(
"survey_behind_page") .
" " . $question[
"questionblock_title"];
1146 $pages_drop[$idx + 1] = $lng->
txt(
"survey_behind_page") .
" " . strip_tags($question[
"title"]);
1151 $pos->setOptions($pages_drop);
1152 $form->addItem($pos);
1155 $form->addCommandButton(
"movePage", $lng->
txt(
"submit"));
1156 $form->addCommandButton(
"renderPage", $lng->
txt(
"cancel"));
1173 $target_page = $this->current_page - 1;
1174 $source_page = $this->svy_request->getOldPosition() - 1;
1176 $pages = $this->
object->getSurveyPages();
1177 foreach ($pages[$source_page] as $question) {
1178 $questions[] = $question[
"question_id"];
1183 if ($this->pgov !==
"fst") {
1187 $target = $pages[$target_page];
1188 if ($position === 0) {
1189 $target = array_shift($target);
1191 $target = array_pop($target);
1193 $this->
object->moveQuestions($questions, $target[
"question_id"], $position);
1195 if ($target_page < $source_page && $position) {
1196 $this->current_page++;
1199 $this->tpl->setOnScreenMessage(
'success', $lng->
txt(
"survey_page_moved"),
true);
1200 $ilCtrl->setParameter($this,
"pgov", $this->current_page);
1201 $ilCtrl->redirect($this,
"renderPage");
1215 if (!$this->has_datasets) {
1217 $button->setCaption(
"survey_add_new_question");
1218 $button->setUrl($ilCtrl->getLinkTarget($this,
"addQuestionToolbarForm"));
1219 $ilToolbar->addStickyItem($button);
1221 if ($this->
object->getPoolUsage()) {
1226 isset($a_pages[$this->current_page - 1])) {
1227 $last_on_page = $a_pages[$this->current_page - 1];
1228 $last_on_page = array_pop($last_on_page);
1229 $last_on_page = $last_on_page[
"question_id"];
1232 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
1233 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos", $last_on_page .
"c");
1235 $cmd = ((
int)
$ilUser->getPref(
'svy_insert_type') === 1 ||
1236 (
$ilUser->getPref(
'svy_insert_type') ??
'') ===
'')
1237 ?
'browseForQuestions' 1238 :
'browseForQuestionblocks';
1241 $button->setCaption(
"browse_for_questions");
1242 $button->setUrl($ilCtrl->getLinkTarget($this->editor_gui, $cmd));
1243 $ilToolbar->addStickyItem($button);
1245 $ilCtrl->setParameter($this->editor_gui,
"pgov",
"");
1246 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos",
"");
1258 $ilCtrl->setParameter($this,
"pg", $this->current_page - 1);
1260 $button->setCaption(
"survey_prev_question");
1261 if ($this->has_previous_page) {
1262 $button->setUrl($ilCtrl->getLinkTarget($this,
"renderPage"));
1264 $button->setDisabled(!$this->has_previous_page);
1265 $ilToolbar->addStickyItem($button);
1267 $ilCtrl->setParameter($this,
"pg", (
string) ((
int) $this->current_page + 1));
1269 $button->setCaption(
"survey_next_question");
1270 if ($this->has_next_page) {
1271 $button->setUrl($ilCtrl->getLinkTarget($this,
"renderPage"));
1273 $button->setDisabled(!$this->has_next_page);
1274 $ilToolbar->addStickyItem($button);
1276 $ilCtrl->setParameter($this,
"pg", $this->current_page);
1278 foreach ($a_pages as $idx => $questions) {
1280 $page = array_shift($page);
1281 if ($page[
"questionblock_id"]) {
1282 $pages_drop[$idx + 1] = $page[
"questionblock_title"];
1284 if (count($questions) > 1) {
1285 foreach ($questions as $question) {
1286 $pages_drop[($idx + 1) .
"__" . $question[
"question_id"]] =
"- " . $question[
"title"];
1290 $pages_drop[$idx + 1] = strip_tags($page[
"title"]);
1296 if (is_array($pages_drop) && count($pages_drop) > 1) {
1299 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1302 $si->addCustomAttribute(
"onChange=\"forms['ilToolbar'].submit();\"");
1303 $si->setOptions($pages_drop);
1304 $si->setValue($this->current_page);
1305 $ilToolbar->addInputItem($si,
true);
1309 $cmd->setValue(
"1");
1310 $ilToolbar->addInputItem($cmd);
1312 if (!$this->has_datasets) {
1313 $ilToolbar->addSeparator();
1315 $ilCtrl->setParameter($this,
"csum", md5(print_r($a_pages[$this->current_page - 1],
true)));
1316 $url = $ilCtrl->getLinkTarget($this,
"deleteBlock");
1317 $ilCtrl->setParameter($this,
"csum",
"");
1320 $button->setCaption(
"survey_delete_page");
1321 $button->setUrl(
$url);
1322 $ilToolbar->addButtonInstance($button);
1324 $ilToolbar->addSeparator();
1327 $button->setCaption(
"survey_move_page");
1328 $button->setUrl($ilCtrl->getLinkTarget($this,
"movePageForm"));
1329 $ilToolbar->addButtonInstance($button);
1334 if (is_array($pages_drop)) {
1335 $ilToolbar->addSeparator();
1336 $print_view = $this->print->page($this->ref_id);
1337 $modal_elements = $print_view->getModalElements(
1338 $this->
ctrl->getLinkTarget(
1340 "printViewSelection" 1343 $ilToolbar->addComponent($modal_elements->button);
1344 $ilToolbar->addComponent($modal_elements->modal);
1358 $pages = $this->
object->getSurveyPages();
1359 $this->has_next_page = ($this->current_page < count($pages));
1360 $this->has_previous_page = ($this->current_page > 1);
1364 if ($this->has_datasets) {
1366 $mess = $mbox->getHTML();
1369 $ilCtrl->setParameter($this,
"pg", $this->current_page);
1370 $ilCtrl->setParameter($this,
"pgov",
"");
1374 $ttpl =
new ilTemplate(
"tpl.il_svy_svy_page_view.html",
true,
true,
"Modules/Survey");
1376 $ttpl->setVariable(
"FORM_ACTION", $ilCtrl->getFormAction($this));
1379 $read_only = ($this->has_datasets || !$rbacsystem->
checkAccess(
"write", $this->ref_id));
1381 $commands = $multi_commands = array();
1385 if ($this->edit_manager->isQuestionClipboardEmpty($this->ref_id)) {
1386 $multi_commands[] = array(
"cmd" =>
"multiDelete",
"text" => $lng->
txt(
"delete"));
1387 $multi_commands[] = array(
"cmd" =>
"multiCut",
"text" => $lng->
txt(
"cut"));
1388 $multi_commands[] = array(
"cmd" =>
"multiCopy",
"text" => $lng->
txt(
"copy"));
1389 $multi_commands[] = array(
"cmd" =>
"selectAll",
"text" => $lng->
txt(
"select_all"));
1391 if (!$this->suppress_clipboard_msg) {
1392 $this->tpl->setOnScreenMessage(
'info', $lng->
txt(
"survey_clipboard_notice"));
1394 $multi_commands[] = array(
"cmd" =>
"clearClipboard",
"text" => $lng->
txt(
"survey_dnd_clear_clipboard"));
1399 $ttpl->setCurrentBlock(
"help_section");
1400 $ttpl->setVariable(
"TXT_ADD_EL", $lng->
txt(
"cont_add_elements"));
1403 $ttpl->setVariable(
"TXT_DRAG", $lng->
txt(
"cont_drag_and_drop_elements"));
1404 $ttpl->setVariable(
"TXT_SEL", $lng->
txt(
"cont_double_click_to_delete"));
1405 $ttpl->parseCurrentBlock();
1407 $ttpl->setVariable(
"DND_INIT_JS",
"initDragElements();");
1421 $ttpl->setVariable(
"WYSIWYG_BLOCKFORMATS", $tiny->_buildAdvancedBlockformatsFromHTMLTags($tags));
1422 $ttpl->setVariable(
"WYSIWYG_VALID_ELEMENTS", $tiny->_getValidElementsFromHTMLTags($tags));
1424 $buttons_1 = $tiny->_buildAdvancedButtonsFromHTMLTags(1, $tags);
1425 $buttons_2 = $tiny->_buildAdvancedButtonsFromHTMLTags(2, $tags) .
',' .
1426 $tiny->_buildAdvancedTableButtonsFromHTMLTags($tags) .
1427 ($tiny->getStyleSelect() ?
',styleselect' :
'');
1428 $buttons_3 = $tiny->_buildAdvancedButtonsFromHTMLTags(3, $tags);
1435 if (count($multi_commands) > 0) {
1436 foreach ($multi_commands as $cmd) {
1437 $ttpl->setCurrentBlock(
"multi_cmd");
1438 $ttpl->setVariable(
"ORG_CMD_MULTI",
"renderPage");
1439 $ttpl->setVariable(
"MULTI_CMD", $cmd[
"cmd"]);
1440 $ttpl->setVariable(
"MULTI_CMD_TXT", $cmd[
"text"]);
1441 $ttpl->parseCurrentBlock();
1444 $ttpl->setCurrentBlock(
"multi_cmds");
1445 $ttpl->setVariable(
"MCMD_ALT", $lng->
txt(
"commands"));
1447 $ttpl->parseCurrentBlock();
1452 $pages[$this->current_page - 1] ?? [],
1453 $this->has_previous_page,
1454 $this->has_next_page,
1462 $tpl->
addJavaScript(
"./Modules/Survey/js/SurveyPageView.js");
1472 bool $a_has_previous_page =
false,
1473 bool $a_has_next_page =
false,
1474 bool $a_readonly =
false 1479 $ttpl =
new ilTemplate(
"tpl.il_svy_svy_page_view_nodes.html",
true,
true,
"Modules/Survey");
1481 $has_clipboard = !$this->edit_manager->isQuestionClipboardEmpty($this->ref_id);
1485 $first_question = $a_questions;
1486 $first_question = array_shift($first_question);
1488 $compress_view =
false;
1489 if ($first_question[
"questionblock_id"] ??
false) {
1492 if (!$a_readonly && !$has_clipboard) {
1493 $menu[] = array(
"cmd" =>
"editBlock",
"text" => $lng->
txt(
"edit"));
1496 if ($first_question[
"questionblock_show_blocktitle"]) {
1497 $block_status = $lng->
txt(
"survey_block_visible");
1499 $block_status = $lng->
txt(
"survey_block_hidden");
1505 $first_question[
"questionblock_id"],
1506 $first_question[
"questionblock_title"] .
" (" . $block_status .
")",
1513 if (count($a_questions) > 1) {
1514 $compress_view = $first_question[
"questionblock_compress_view"];
1522 foreach ($a_questions as $idx => $question) {
1528 if (!$has_clipboard) {
1529 foreach ($questiontypes as $trans => $item) {
1530 $menu[] = array(
"cmd" =>
"addQuestion_" . $item[
"questiontype_id"],
1531 "text" => sprintf($lng->
txt(
"svy_page_add_question"), $trans));
1534 if ($this->
object->getPoolUsage()) {
1535 $menu[] = array(
"cmd" =>
"addPoolQuestion",
1536 "text" => $lng->
txt(
"browse_for_questions"));
1539 $menu[] = array(
"cmd" =>
"paste",
"text" => $lng->
txt(
"survey_dnd_paste"));
1543 $this->
renderPageNode($ttpl,
"droparea", $question[
"question_id"], null, $menu,
true);
1546 $question_gui = $this->
object->getQuestionGUI($question[
"type_tag"], $question[
"question_id"]);
1547 $question_form = $question_gui->getWorkingForm(
1549 $this->
object->getShowQuestionTitles(),
1550 $question[
"questionblock_show_questiontext"],
1552 $this->
object->getSurveyId(),
1558 if (!$a_readonly && !$has_clipboard) {
1559 $menu[] = array(
"cmd" =>
"editQuestion",
"text" => $lng->
txt(
"edit"));
1560 $menu[] = array(
"cmd" =>
"cutQuestion",
"text" => $lng->
txt(
"cut"));
1561 $menu[] = array(
"cmd" =>
"copyQuestion",
"text" => $lng->
txt(
"copy"));
1563 if (count($a_questions) > 1 && $idx > 0) {
1564 $menu[] = array(
"cmd" =>
"splitPage",
"text" => $lng->
txt(
"survey_dnd_split_page"));
1566 if ($a_has_next_page) {
1567 $menu[] = array(
"cmd" =>
"moveNext",
"text" => $lng->
txt(
"survey_dnd_move_next"));
1569 if ($a_has_previous_page) {
1570 $menu[] = array(
"cmd" =>
"movePrevious",
"text" => $lng->
txt(
"survey_dnd_move_previous"));
1573 $menu[] = array(
"cmd" =>
"deleteQuestion",
"text" => $lng->
txt(
"delete"));
1576 if ($question[
"heading"]) {
1577 $menu[] = array(
"cmd" =>
"editHeading",
"text" => $lng->
txt(
"survey_edit_heading"));
1578 $menu[] = array(
"cmd" =>
"deleteHeading",
"text" => $lng->
txt(
"survey_delete_heading"));
1580 $menu[] = array(
"cmd" =>
"addHeading",
"text" => $lng->
txt(
"add_heading"));
1584 if ($first_question[
"questionblock_show_questiontext"]) {
1585 $question_title_status = $lng->
txt(
"survey_question_text_visible");
1587 $question_title_status = $lng->
txt(
"survey_question_text_hidden");
1593 $question[
"question_id"],
1598 $question_title_status,
1599 $question[
"heading"]
1602 $ilCtrl->setParameter($this,
"eqid",
"");
1611 if (!$has_clipboard) {
1612 foreach ($questiontypes as $trans => $item) {
1613 $menu[] = array(
"cmd" =>
"addQuestion_" . $item[
"questiontype_id"],
1614 "text" => sprintf($lng->
txt(
"svy_page_add_question"), $trans));
1617 if ($this->
object->getPoolUsage()) {
1618 $menu[] = array(
"cmd" =>
"addPoolQuestion",
1619 "text" => $lng->
txt(
"browse_for_questions"));
1622 $menu[] = array(
"cmd" =>
"paste",
"text" => $lng->
txt(
"survey_dnd_paste"));
1628 return $ttpl->get();
1638 ?
string $a_content = null,
1639 ?array $a_menu = null,
1640 bool $a_spacer =
false,
1641 string $a_subtitle =
"",
1642 ?
string $a_status = null,
1643 ?
string $a_heading = null
1648 $node_id = $a_type .
"_" . $a_id;
1653 foreach ($a_menu as $mcnt => $menu_item) {
1654 $ilCtrl->setParameter($this,
"il_hform_node", $node_id);
1655 $ilCtrl->setParameter($this,
"il_hform_subcmd", $menu_item[
"cmd"]);
1656 $url = $ilCtrl->getLinkTarget($this,
"renderPage");
1657 $ilCtrl->setParameter($this,
"il_hform_subcmd",
"");
1658 $ilCtrl->setParameter($this,
"il_hform_node",
"");
1661 $a_tpl->
setVariable(
"TXT_MENU_CMD", $menu_item[
"text"]);
1671 } elseif ($a_menu) {
1673 foreach ($a_menu as $mcnt => $menu_item) {
1674 $ilCtrl->setParameter($this,
"il_hform_node", $node_id);
1675 $ilCtrl->setParameter($this,
"il_hform_subcmd", $menu_item[
"cmd"]);
1676 $url = $ilCtrl->getLinkTarget($this,
"renderPage");
1677 $ilCtrl->setParameter($this,
"il_hform_subcmd",
"");
1678 $ilCtrl->setParameter($this,
"il_hform_node",
"");
1681 $a_tpl->
setVariable(
"TXT_ACTION_CMD", $menu_item[
"text"]);
1688 if ($a_content !== null &&
1689 $a_type ===
"question" &&
1691 $a_content =
"<div class=\"questionheading\">" . $a_heading .
"</div>" .
1696 $a_tpl->
setVariable(
"TXT_NODE_CONTENT_ACTIONS", $a_content);
1698 $a_tpl->
setVariable(
"TXT_NODE_CONTENT_NO_ACTIONS", $a_content);
1701 if ($a_content !== null) {
1703 $selectable =
false;
1706 $caption = $lng->
txt(
"questionblock");
1710 $caption = $lng->
txt(
"question") .
": " . $a_subtitle;
1716 $caption = $lng->
txt(
"heading");
1724 $caption .=
" (" . $a_status .
")";
1746 return $lng->
txt(
"survey_auto_block_title");
1756 if ($node ===
"page_end") {
1757 $pages = $this->
object->getSurveyPages();
1758 $page = array_pop($pages[$this->current_page - 1]);
1759 $pos = $page[
"question_id"] .
"a";
1764 $ilCtrl->setParameter($this->editor_gui,
"pgov", $this->current_page);
1765 $ilCtrl->setParameter($this->editor_gui,
"pgov_pos", $pos);
1767 $cmd = ((
int)
$ilUser->getPref(
'svy_insert_type') === 1 || (
$ilUser->getPref(
'svy_insert_type') ??
'') ===
'') ?
'browseForQuestions' :
'browseForQuestionblocks';
1768 $ilCtrl->redirect($this->editor_gui, $cmd);
1773 $view = $this->print->page($this->ref_id);
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
confirmRemoveQuestions()
Remove question(s) from survey.
addQuestionToolbar()
Add question to survey action (used in toolbar)
splitPage(int $a_id)
Split current page in 2 pages.
__construct(ilObjSurvey $a_survey, ilSurveyEditorGUI $a_survey_editor_gui)
ILIAS Survey PrintView GUIService $print
static getLogger(string $a_component_id)
Get component logger.
static _hasDatasets(int $survey_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static get(string $a_glyph, string $a_text="")
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
movePageForm()
Move current page.
movePrevious(int $a_id)
Move question to previous page.
renderToolbar(?array $a_pages)
Render toolbar form.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
insertNewQuestion(int $a_new_id)
Add new question to survey.
ilGlobalTemplateInterface $tpl
multiCopy(array $a_id)
Add questions to be copied to clipboard.
loadLanguageModule(string $a_module)
Load language module.
ILIAS HTTP Services $http
dnd()
Move questions in page.
ILIAS Survey Editing EditingGUIRequest $svy_request
editBlock(int $a_id)
Edit question block.
editHeading(int $a_id)
Edit question heading.
deleteHeading(int $a_id)
Delete question heading.
multiCut(array $a_id)
Add questions to be cut to clipboard.
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
touchBlock(string $block)
static _getQuestionGUI(?string $questiontype, int $question_id=-1)
Creates a question gui representation.
renderPageNode(ilTemplate $a_tpl, string $a_type, string $a_id, ?string $a_content=null, ?array $a_menu=null, bool $a_spacer=false, string $a_subtitle="", ?string $a_status=null, ?string $a_heading=null)
Render single node of dnd page view.
static _isComplete(int $question_id)
Checks whether the question is complete or not.
static http()
Fetches the global http state from ILIAS.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setVariable($variable, $value='')
Sets a variable value.
setContent(string $a_html)
Sets content for standard template.
static _instanciateQuestion(int $question_id)
Creates an instance of a question with a given question id.
ilSurveyEditorGUI $editor_gui
static removeRedundantSeparators(string $a_string)
Removes redundant seperators and removes ,, and , at the first or last position of the string...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
clearClipboard()
Empty clipboard.
moveNext(int $a_id)
Move question to next page.
addQuestionToolbarForm()
Add question to survey form (used in toolbar)
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
static initDragDrop(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Drag and Drop used in Modules/Survey, Services/Calendar, Services/COPage, Services/Form (Jan 2022)
insertQuestionBlock(int $a_block_id)
Copy and insert questions from block.
addQuestion(int $a_type, bool $a_use_pool, string $a_pos, string $a_special_position)
Call add question to survey form.
addPoolQuestion(string $pos, string $node)
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
deleteBlock()
Confirm removing question block.
copyQuestion(int $a_id)
Add question to be copied to clipboard.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
cutQuestion(int $a_id)
Add question to be cut to clipboard.
callEditor(string $a_cmd, string $a_param, string $a_value)
static _getQuestiontypes()
Get all available question types.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
getAutoBlockTitle()
Get name for newly created blocks.
bool $suppress_clipboard_msg
ILIAS Survey Editing EditManager $edit_manager
renderPage()
render questions per page
movePage()
Move current page to new position.
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
appendNewQuestionToSurvey(int $a_new_id, bool $a_duplicate=true, bool $a_force_duplicate=false)
Add new question to survey (database part)
getPageNodes(array $a_questions, bool $a_has_previous_page=false, bool $a_has_next_page=false, bool $a_readonly=false)
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.
deleteQuestion(array $a_id)
Confirm removing question(s) from survey.
addHeading(int $a_id)
Add heading to question.
paste(int $a_id)
Paste from clipboard.