33 protected \ILIAS\Survey\InternalGUIService
$gui;
34 protected \ILIAS\Survey\PrintView\GUIService
$print;
35 protected \ILIAS\HTTP\Services
$http;
36 protected \ILIAS\DI\UIServices
$ui;
56 $this->
tabs = $DIC->tabs();
57 $this->
help = $DIC[
"ilHelp"];
58 $this->
toolbar = $DIC->toolbar();
59 $this->
user = $DIC->user();
60 $this->tree =
$DIC->repositoryTree();
61 $ilCtrl =
$DIC->ctrl();
65 $this->parent_gui = $a_parent_gui;
68 $this->
object = $survey;
70 $this->
ctrl = $ilCtrl;
74 $this->
ctrl->saveParameter($this, array(
"pgov",
"pgov_pos"));
76 $this->print_options = array(
82 $this->edit_manager =
$DIC->survey()
86 $this->request =
$DIC->survey()
91 $this->requested_pgov = $this->request->getTargetPosition();
92 $this->
ui = $DIC->ui();
93 $this->
http = $DIC->http();
94 $this->print =
$DIC->survey()
98 $this->gui =
$DIC->survey()
101 $this->sequence_manager =
$DIC->survey()->internal()->domain()->sequence(
102 $this->
object->getSurveyId(),
109 $this->requested_pgov = $pgov;
116 $cmd = $this->
ctrl->getCmd(
"questions");
118 $next_class = $this->
ctrl->getNextClass($this);
119 switch ($next_class) {
123 if (stripos($next_class,
"questiongui") !==
false) {
124 $ilTabs->clearTargets();
125 $this->
ctrl->saveParameter($this, array(
"new_for_survey"));
128 $this->request->getQuestionId()
130 if (is_object($q_gui->object)) {
135 $q_gui->setBackUrl($this->
ctrl->getLinkTarget($this,
"questions"));
136 $q_gui->setQuestionTabs();
137 $this->
ctrl->forwardCommand($q_gui);
139 if (!$this->request->getNewForSurvey()) {
141 $this->tpl->setTitle($this->
lng->txt(
"question") .
": " . $q_gui->object->getTitle());
154 $ilTabs = $this->
tabs;
156 if ($a_cmd ===
"questions" && $this->requested_pgov !==
"") {
160 $this->
ctrl->setParameter($this,
"pgov",
"");
163 $this->
lng->txt(
"survey_question_editor"),
164 $this->ctrl->getLinkTarget($this,
"questions")
166 $this->
ctrl->setParameter($this,
"pgov", $this->requested_pgov);
168 if ($this->
object->getSurveyPages()) {
169 if ($a_cmd ===
"page") {
170 $this->
ctrl->setParameterByClass(
"ilsurveyexecutiongui",
"pgov", max(1, $this->request->getPage()));
172 $this->
ctrl->setParameterByClass(
"ilsurveyexecutiongui",
"prvw", 1);
175 $this->
lng->txt(
"preview"),
176 $this->ctrl->getLinkTargetByClass(array(
"ilobjsurveygui",
"ilsurveyexecutiongui"),
"preview")
180 $ilTabs->activateSubTab($a_cmd);
190 $ilToolbar = $this->toolbar;
191 $ilUser = $this->user;
194 if ($this->request->getNewId() > 0) {
196 $existing = $this->
object->getExistingQuestions();
197 if (!in_array($this->request->getNewId(), $existing)) {
198 $inserted = $this->
object->insertQuestion($this->request->getNewId());
200 if (!$this->
object->isQuestionInSurvey($this->request->getNewId())) {
201 $this->tpl->setOnScreenMessage(
203 $this->
lng->txt(
"survey_error_insert_incomplete_question")
208 $this->
ctrl->redirect($this,
"questions");
212 $this->questionsSubtabs(
"questions");
215 $read_only = $hasDatasets;
221 $qtypes[
$data[
"type_tag"]] = $translation;
224 $ilToolbar->setFormAction($this->
ctrl->getFormAction($this));
226 $types->setOptions($qtypes);
227 $ilToolbar->addStickyItem($types,
"");
230 $this->
lng->txt(
"svy_create_question"),
232 )->submit()->toToolbar(
true);
235 $cmd = ((
int) $ilUser->getPref(
'svy_insert_type') === 1 ||
236 ($ilUser->getPref(
'svy_insert_type') ??
'') ===
'')
237 ?
'browseForQuestions'
238 :
'browseForQuestionblocks';
241 $this->
lng->txt(
"browse_for_questions"),
242 $this->
ctrl->getLinkTarget($this, $cmd)
245 if ($this->
object->hasQuestions()) {
246 $ilToolbar->addSeparator();
248 $this->
lng->txt(
"add_heading"),
249 $this->
ctrl->getLinkTarget($this,
"addHeading")
253 $ilToolbar->addSeparator();
254 $print_view = $this->print->list($this->
object->getRefId());
255 $modal_elements = $print_view->getModalElements(
256 $this->
ctrl->getLinkTarget(
258 "printListViewSelection"
261 $ilToolbar->addComponent($modal_elements->button);
262 $ilToolbar->addComponent($modal_elements->modal);
267 $mess = $mbox->getHTML();
277 $this->tpl->setContent($mess . $table->getHTML());
285 bool $allow_blocks =
true,
286 bool $allow_questions =
true,
287 bool $allow_headings =
false,
288 bool $allow_questions_in_blocks =
false
290 $block_map = array();
291 foreach ($this->
object->getSurveyQuestions() as $item) {
292 $block_map[$item[
"question_id"]] = $item[
"questionblock_id"];
295 $questions = $blocks = $headings = array();
296 $ids = $this->request->getIds();
297 if (count($ids) > 0) {
298 foreach ($ids as $key) {
300 if ($allow_questions && preg_match(
"/cb_(\d+)/", $key, $matches)) {
301 if (($allow_questions_in_blocks || !$block_map[$matches[1]]) &&
302 !in_array($block_map[$matches[1]], $blocks)) {
303 $questions[] = $matches[1];
307 if ($allow_blocks && preg_match(
"/cb_qb_(\d+)/", $key, $matches)) {
308 $blocks[] = $matches[1];
311 if ($allow_headings && preg_match(
"/cb_tb_(\d+)/", $key, $matches)) {
312 $headings[] = $matches[1];
317 return array(
"questions" => $questions,
319 "headings" => $headings);
324 $req_order = $this->request->getOrder();
325 $req_block_order = $this->request->getBlockOrder();
326 if (count($req_order) > 0) {
330 foreach (array_keys($req_order) as
$id) {
332 if (strpos(
$id,
"qb_") === 0) {
333 $block_id = substr(
$id, 3);
334 $block = $req_block_order[$block_id];
336 foreach (array_keys($block) as $question_id) {
338 $order[$question_id] = $position;
341 $question_id = substr(
$id, 2);
343 $order[$question_id] = $position;
346 $this->
object->updateOrder($order);
349 $obligatory = $this->request->getObligatory();
350 $this->
object->setObligatoryStates($obligatory);
351 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
352 $this->
ctrl->redirect($this,
"questions");
357 $items = $this->gatherSelectedTableItems(
true,
false,
false,
false);
358 if (count($items[
"blocks"])) {
359 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
360 $this->
object->unfoldQuestionblocks($items[
"blocks"]);
362 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"qpl_unfold_select_none"),
true);
364 $this->
ctrl->redirect($this,
"questions");
369 $items = $this->gatherSelectedTableItems(
true,
true,
false,
false);
371 $move_questions = $items[
"questions"];
372 foreach ($items[
"blocks"] as $block_id) {
373 foreach ($this->
object->getQuestionblockQuestionIds($block_id) as $qid) {
374 $move_questions[] = $qid;
377 if (count($move_questions) === 0) {
378 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"no_question_selected_for_move"),
true);
379 $this->
ctrl->redirect($this,
"questions");
381 $this->edit_manager->setMoveSurveyQuestions($this->
object->getId(), $move_questions);
382 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"select_target_position_for_move_question"));
383 $this->questionsObject();
389 $this->insertQuestions(0);
394 $this->insertQuestions(1);
400 $copy = ($this->edit_manager->getQuestionClipboardMode($this->
object->getRefId()) ===
"copy");
402 $this->copyPasteObject($insert_mode);
407 $ids = $this->request->getIds();
408 if (count($ids) > 0) {
409 $items = $this->gatherSelectedTableItems(
true,
true,
false,
false);
412 while (!$insert_id && count($ids) > 0) {
413 $target = array_shift($ids);
414 if (preg_match(
"/^cb_(\d+)$/", $target, $matches)) {
416 if (in_array($matches[1], $items[
"questions"])) {
417 $insert_id = $matches[1];
420 if (!$insert_id && preg_match(
"/^cb_qb_(\d+)$/", $target, $matches)) {
421 $ids = $this->
object->getQuestionblockQuestionIds($matches[1]);
423 if ($insert_mode === 0) {
424 $insert_id = $ids[0];
425 } elseif ($insert_mode === 1) {
426 $insert_id = $ids[count($ids) - 1];
433 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"no_target_selected_for_move"),
true);
435 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
436 if ($this->edit_manager->getMoveSurveyId() === $this->object->getId()) {
437 $this->
object->moveQuestions(
438 $this->edit_manager->getMoveSurveyQuestions(),
442 $this->edit_manager->clearMoveSurveyQuestions();
446 $this->
ctrl->redirect($this,
"questions");
451 $items = $this->gatherSelectedTableItems(
true,
true,
true,
true);
452 if (count($items[
"blocks"]) + count($items[
"questions"]) + count($items[
"headings"]) > 0) {
453 $this->tpl->setOnScreenMessage(
'question', $this->
lng->txt(
"remove_questions"));
454 $this->removeQuestionsForm($items[
"blocks"], $items[
"questions"], $items[
"headings"]);
456 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"no_question_selected_for_removal"),
true);
457 $this->
ctrl->redirect($this,
"questions");
462 array $checked_questionblocks,
463 array $checked_questions,
464 array $checked_headings
468 $cgui->setFormAction($this->
ctrl->getFormAction($this,
"confirmRemoveQuestions"));
469 $cgui->setCancel($this->
lng->txt(
"cancel"),
"questions");
470 $cgui->setConfirm($this->
lng->txt(
"confirm"),
"confirmRemoveQuestions");
471 $surveyquestions = $this->
object->getSurveyQuestions();
472 foreach ($surveyquestions as $question_id =>
$data) {
473 if (in_array(
$data[
"question_id"], $checked_questions)) {
478 $data[
"question_id"],
479 $type .
": " .
$data[
"title"]
481 } elseif ((in_array(
$data[
"questionblock_id"], $checked_questionblocks))) {
485 "cb[" .
$data[
"questionblock_id"] .
"]",
486 $data[
"questionblock_id"],
487 $data[
"questionblock_title"] .
" - " . $type .
": " .
$data[
"title"]
489 } elseif (in_array(
$data[
"question_id"], $checked_headings)) {
491 "heading[" .
$data[
"question_id"] .
"]",
492 $data[
"question_id"],
498 $this->tpl->setContent($cgui->getHTML());
503 $checked_questions = $this->request->getQuestionIds();
504 $checked_questionblocks = $this->request->getBlockIds();
505 $checked_headings = $this->request->getHeadings();
507 if (count($checked_questions) || count($checked_questionblocks)) {
508 $this->
object->removeQuestions($checked_questions, $checked_questionblocks);
510 if ($checked_headings) {
511 foreach ($checked_headings as $q_id) {
512 $this->
object->saveHeading(
"", $q_id);
515 $this->
object->saveCompletionStatus();
516 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"questions_removed"),
true);
517 $this->
ctrl->redirect($this,
"questions");
522 $items = $this->gatherSelectedTableItems(
true,
true,
false,
true);
525 $copy_questions = $items[
"questions"];
526 foreach ($items[
"blocks"] as $block_id) {
527 foreach ($this->
object->getQuestionblockQuestionIds($block_id) as $qid) {
528 $copy_questions[] = $qid;
531 $copy_questions = array_unique($copy_questions);
534 if (count($copy_questions)) {
535 foreach ($copy_questions as $idx => $question_id) {
537 if ($question->getOriginalId()) {
538 unset($copy_questions[$idx]);
542 if (count($copy_questions) === 0) {
543 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"no_question_selected_for_copy_to_pool"),
true);
544 $this->
ctrl->redirect($this,
"questions");
546 $this->questionsSubtabs(
"questions");
550 $form->setFormAction($this->
ctrl->getFormAction($this,
"executeCreateQuestion"));
553 $ids->setValue(implode(
";", $copy_questions));
554 $form->addItem($ids);
556 $questionpools = $this->
object->getAvailableQuestionpools(
false,
false,
true,
"write");
557 $pools =
new ilSelectInputGUI($this->
lng->txt(
"survey_copy_select_questionpool"),
"sel_spl");
558 $pools->setOptions($questionpools);
559 $form->addItem($pools);
561 $form->addCommandButton(
"executeCopyQuestionsToPool", $this->
lng->txt(
"submit"));
562 $form->addCommandButton(
"questions", $this->
lng->txt(
"cancel"));
564 $this->tpl->setContent($form->getHTML());
570 $question_ids = $this->request->getQuestionIdsFromString();
573 foreach ($question_ids as $qid) {
576 $new_question->setId();
577 $new_question->setObjId($pool_id);
578 $new_question->saveToDb();
584 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"survey_copy_to_questionpool_success"),
true);
585 $this->
ctrl->redirect($this,
"questions");
595 $sel_question_types =
null,
596 ?
string $pgov_pos =
null
598 $this->executeCreateQuestionObject(null, 1, $pgov_pos);
602 ?
string $q_type =
null,
603 ?
int $pool_usage =
null,
604 ?
string $pgov_pos =
null
606 $this->edit_manager->setPoolChoice($this->request->getPoolUsage());
608 if (is_null($q_type)) {
609 $q_type = $this->request->getSelectedQuestionTypes();
612 $pgov = $this->requested_pgov;
613 if (is_null($pgov_pos)) {
614 $pgov_pos = $this->request->getTargetQuestionPosition();
617 if (is_null($pool_usage)) {
618 $pool_usage = $this->request->getPoolUsage();
623 $obj_id = $this->
object->getId();
628 $q_gui->object->setObjId($obj_id);
629 $q_gui->object->createNewQuestion();
630 $q_gui_class = get_class($q_gui);
633 $this->
ctrl->setParameterByClass($q_gui_class,
"pgov", $pgov);
634 $this->
ctrl->setParameterByClass($q_gui_class,
"pgov_pos", $pgov_pos);
637 $this->
ctrl->setParameterByClass($q_gui_class,
"ref_id", $this->
object->getRefId());
638 $this->
ctrl->setParameterByClass($q_gui_class,
"new_for_survey", $this->
object->getRefId());
639 $this->
ctrl->setParameterByClass($q_gui_class,
"q_id", $q_gui->object->getId());
640 $this->
ctrl->setParameterByClass($q_gui_class,
"sel_question_types", $q_gui->getQuestionType());
641 $this->
ctrl->redirectByClass($q_gui_class,
"editQuestion");
651 $qpl->setType(
"spl");
652 $qpl->setTitle($name);
653 $qpl->setDescription(
"");
655 $qpl->createReference();
656 $qpl->putInTree($parent_ref);
657 $qpl->setPermissions($parent_ref);
661 return $qpl->getId();
671 $ilTabs = $this->tabs;
672 $ilToolbar = $this->toolbar;
673 $ilUser = $this->user;
675 $link = $this->
ctrl->getLinkTarget($this,
"questions");
676 $ilTabs->setBackTarget($this->
lng->txt(
"menubacktosurvey"), $link);
680 $types->setOptions(array(
681 1 => $this->
lng->txt(
"questions"),
682 2 => $this->lng->txt(
"questionblocks")
684 $types->setValue($ilUser->getPref(
'svy_insert_type'));
685 $ilToolbar->addInputItem($types,
true);
686 $ilToolbar->addFormButton($this->
lng->txt(
"change"),
"changeDatatype");
687 $ilToolbar->setFormAction($this->
ctrl->getFormAction($this,
"changeDatatype"));
692 $ilUser = $this->user;
694 $ilUser->writePref(
'svy_insert_type', $this->request->getDataType());
696 switch ($this->request->getDataType()) {
698 $this->
ctrl->redirect($this,
'browseForQuestionblocks');
703 $this->
ctrl->redirect($this,
'browseForQuestions');
710 $this->setBrowseForQuestionsSubtabs();
713 $table_gui->setEditable(
true);
714 $this->tpl->setContent($table_gui->getHTML());
720 $table_gui->writeFilterToSession();
721 $this->
ctrl->redirect($this,
'browseForQuestions');
727 $table_gui->resetFilter();
728 $this->
ctrl->redirect($this,
'browseForQuestions');
733 $inserted_objects = 0;
735 $qids = $this->request->getQuestionIds();
736 if (count($qids) > 0) {
737 foreach ($qids as $question_id) {
738 if ($this->requested_pgov ===
"") {
739 $this->
object->insertQuestion($question_id);
743 $page_gui->insertNewQuestion($question_id);
748 if ($inserted_objects) {
749 $this->
object->saveCompletionStatus();
750 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"questions_inserted"),
true);
751 $this->
ctrl->redirect($this,
"questions");
753 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"insert_missing_question"),
true);
754 $this->
ctrl->redirect($this,
'browseForQuestions');
760 $this->setBrowseForQuestionsSubtabs();
763 $table_gui->setEditable(
true);
764 $this->tpl->setContent($table_gui->getHTML());
770 $table_gui->writeFilterToSession();
771 $this->
ctrl->redirect($this,
'browseForQuestionblocks');
777 $table_gui->resetFilter();
778 $this->
ctrl->redirect($this,
'browseForQuestionblocks');
783 $inserted_objects = 0;
785 $block_ids = $this->request->getBlockIds();
786 if (count($block_ids) > 0) {
787 foreach ($block_ids as $questionblock_id) {
788 if ($this->requested_pgov ===
"") {
789 $this->
object->insertQuestionblock($questionblock_id);
791 $page_gui->insertQuestionBlock($questionblock_id);
796 if ($inserted_objects) {
797 $this->
object->saveCompletionStatus();
798 $this->tpl->setOnScreenMessage(
'success', ($inserted_objects === 1) ? $this->
lng->txt(
"questionblock_inserted") : $this->lng->txt(
"questionblocks_inserted"),
true);
799 $this->
ctrl->redirect($this,
"questions");
801 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"insert_missing_questionblock"),
true);
802 $this->
ctrl->redirect($this,
'browseForQuestionblocks');
814 $block_id = $this->request->getBlockId();
815 $this->
ctrl->setParameter($this,
"bl_id", $block_id);
818 $a_form = $this->initQuestionblockForm($block_id);
821 $this->questionsSubtabs(
"questions");
822 $this->tpl->setContent($a_form->getHTML());
830 $items = $this->gatherSelectedTableItems(
false,
true,
false,
false);
832 $qids = $this->request->getQuestionIds();
833 if (count($qids) > 0) {
834 $items[
"questions"] = $qids;
836 if (count($items[
"questions"]) < 2) {
837 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"qpl_define_questionblock_select_missing"),
true);
838 $this->
ctrl->redirect($this,
"questions");
841 $a_form = $this->initQuestionblockForm(
null, $items[
"questions"]);
844 $this->questionsSubtabs(
"questions");
845 $this->tpl->setContent($a_form->getHTML());
849 ?
int $a_block_id =
null,
850 ?array $a_question_ids =
null
852 $questionblock = null;
854 $form->setFormAction($this->
ctrl->getFormAction($this,
"saveDefineQuestionblock"));
855 $form->setTitle($this->
lng->txt(
"define_questionblock"));
858 $title->setRequired(
true);
859 $form->addItem($title);
861 $toggle_blocktitle =
new ilCheckboxInputGUI($this->
lng->txt(
"survey_show_blocktitle"),
"show_blocktitle");
862 $toggle_blocktitle->setInfo($this->
lng->txt(
"survey_show_blocktitle_description"));
863 $form->addItem($toggle_blocktitle);
865 $toggle_questiontitle =
new ilCheckboxInputGUI($this->
lng->txt(
"show_questiontext"),
"show_questiontext");
866 $toggle_questiontitle->setInfo($this->
lng->txt(
"show_questiontext_description"));
867 $form->addItem($toggle_questiontitle);
871 $title->setValue($questionblock[
"title"]);
872 $toggle_blocktitle->setChecked((
bool) $questionblock[
"show_blocktitle"]);
873 $toggle_questiontitle->setChecked((
bool) $questionblock[
"show_questiontext"]);
875 $toggle_blocktitle->setChecked(
true);
876 $toggle_questiontitle->setChecked(
true);
880 $compress_view->setInfo($this->
lng->txt(
"svy_compress_view_info"));
881 $compress_view->setChecked((
bool) ($questionblock[
"compress_view"] ??
false));
882 $form->addItem($compress_view);
884 $form->addCommandButton(
"saveDefineQuestionblock", $this->
lng->txt(
"save"));
885 $form->addCommandButton(
"questions", $this->
lng->txt(
"cancel"));
888 $qids = $this->request->getQuestionIds();
889 if (!$a_question_ids && count($qids) > 0) {
890 $a_question_ids = $qids;
893 if ($a_question_ids) {
894 foreach ($a_question_ids as $q_id) {
896 $hidden->setValue($q_id);
897 $form->addItem($hidden);
906 $block_id = $this->request->getBlockId();
907 $q_ids = $this->request->getQuestionIds();
909 $this->
ctrl->setParameter($this,
"bl_id", $block_id);
911 if (!$block_id && count($q_ids) === 0) {
912 $this->
ctrl->redirect($this,
"questions");
915 $form = $this->initQuestionblockForm($block_id);
916 if ($form->checkInput()) {
917 $title = $form->getInput(
"title");
918 $show_questiontext = $form->getInput(
"show_questiontext");
919 $show_blocktitle = $form->getInput(
"show_blocktitle") ;
920 $compress_view = $form->getInput(
"compress_view") ;
922 $this->
object->modifyQuestionblock(
930 $this->
object->createQuestionblock(
939 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
940 $this->
ctrl->redirect($this,
"questions");
943 $form->setValuesByPost();
944 $this->editQuestionblockObject($form);
953 ?
int $a_question_id =
null
955 $survey_questions = $this->
object->getSurveyQuestions();
958 $form->setFormAction($this->
ctrl->getFormAction($this,
""));
962 $heading->setRows(10);
963 $heading->setCols(80);
964 $heading->setRequired(
true);
965 $form->addItem($heading);
969 foreach ($survey_questions as $key => $value) {
970 $options[$key] = $this->
lng->txt(
"before") .
": \"" . $value[
"title"] .
"\"";
972 $insertbefore->setOptions(
$options);
973 $insertbefore->setRequired(
true);
974 $form->addItem($insertbefore);
976 $form->addCommandButton(
"saveHeading", $this->
lng->txt(
"save"));
977 $form->addCommandButton(
"questions", $this->
lng->txt(
"cancel"));
979 if ($a_question_id) {
980 $form->setTitle($this->
lng->txt(
"edit_heading"));
982 $heading->setValue($this->
object->prepareTextareaOutput($survey_questions[$a_question_id][
"heading"] ??
""));
983 $insertbefore->setValue($a_question_id);
984 $insertbefore->setDisabled(
true);
986 $form->setTitle($this->
lng->txt(
"add_heading"));
995 $q_id = $this->request->getQuestionId();
996 $this->
ctrl->setParameter($this,
"q_id", $q_id);
998 $this->questionsSubtabs(
"questions");
1001 $a_form = $this->initHeadingForm($q_id);
1004 $this->tpl->setContent($a_form->getHTML());
1010 $q_id = $this->request->getQuestionId();
1011 $this->
ctrl->setParameter($this,
"q_id", $q_id);
1013 $this->questionsSubtabs(
"questions");
1016 $a_form = $this->initHeadingForm($q_id);
1019 $this->tpl->setContent($a_form->getHTML());
1025 $q_id = $this->request->getQuestionId();
1026 $this->
ctrl->setParameter($this,
"q_id", $q_id);
1028 $form = $this->initHeadingForm($q_id);
1029 if ($form->checkInput()) {
1031 $heading = $form->getInput(
"heading");
1033 $heading = $purifier->purify($heading);
1035 $this->
object->saveHeading($heading, $form->getInput(
"insertbefore"));
1036 $this->
ctrl->redirect($this,
"questions");
1039 $form->setValuesByPost();
1040 $this->addHeadingObject($form);
1045 $q_id = $this->request->getQuestionId();
1046 $this->
ctrl->setParameter($this,
"q_id", $q_id);
1049 $this->
ctrl->redirect($this,
"questions");
1052 $this->questionsSubtabs(
"questions");
1055 $cgui->setHeaderText($this->
lng->txt(
"confirm_remove_heading"));
1057 $cgui->setFormAction($this->
ctrl->getFormAction($this,
"confirmedRemoveHeading"));
1058 $cgui->setCancel($this->
lng->txt(
"cancel"),
"questions");
1059 $cgui->setConfirm($this->
lng->txt(
"confirm"),
"confirmedRemoveHeading");
1061 $this->tpl->setContent($cgui->getHTML());
1066 $q_id = $this->request->getQuestionId();
1068 $this->
ctrl->redirect($this,
"questions");
1071 $this->
object->saveHeading(
"", $q_id);
1072 $this->
ctrl->redirect($this,
"questions");
1077 $print_view = $this->print->page($this->
object->getRefId());
1078 $print_view->sendPrintView();
1083 $view = $this->print->list($this->
object->getRefId());
1089 $print_view = $this->print->list($this->
object->getRefId());
1090 $print_view->sendPrintView();
1095 $id = $this->request->getQuestionId();
1097 $this->tpl->setOnScreenMessage(
'success',
$lng->txt(
"survey_questions_to_clipboard_copy"),
true);
1100 $this->edit_manager->setQuestionClipboard(
1101 $this->
object->getRefId(),
1106 $this->
ctrl->redirect($this,
"questions");
1116 $ids = $this->request->getIds();
1117 if (count($ids) > 0) {
1118 if (substr($ids[0], 0, 3) ==
"cb_") {
1119 $a_id = (
int) substr($ids[0], 3);
1122 if (is_null($a_id)) {
1126 $qids = $this->edit_manager->getQuestionClipboardQuestions($this->
object->getRefId());
1127 $mode = $this->edit_manager->getQuestionClipboardMode($this->
object->getRefId());
1128 $pages = $this->
object->getSurveyPages();
1130 foreach ($pages as $page) {
1131 foreach ($page as $question) {
1132 if ($question[
"question_id"] === $a_id) {
1137 if (is_null($target)) {
1141 if ($mode !==
"copy") {
1146 foreach ($this->
object->getSurveyPages() as $page) {
1147 foreach ($page as $question) {
1148 $titles[] = $question[
"title"];
1153 $question_pointer = array();
1154 foreach ($qids as $qid) {
1159 $title = $question->getTitle();
1161 foreach ($titles as $existing_title) {
1162 #21278 preg_quote with delimiter
1163 if (preg_match(
"/" . preg_quote($title,
"/") .
" \(([0-9]+)\)$/", $existing_title, $match)) {
1164 $max = max($match[1], $max);
1168 $title .=
" (" . ($max + 1) .
")";
1173 $question->setTitle($title);
1176 $question->saveToDb();
1178 $question_pointer[$qid] = $question->getId();
1179 $this->sequence_manager->appendQuestion($question->getId(),
false);
1183 $this->
object->cloneTextblocks($question_pointer);
1185 $this->
object->loadQuestionsFromDb();
1187 $nodes = array_values($question_pointer);
1193 if (count($target) === 1) {
1194 $this->
object->moveQuestions($nodes, $a_id, $pos);
1198 $target_block_id = $target;
1199 $target_block_id = array_shift($target_block_id);
1200 $target_block_id = $target_block_id[
"questionblock_id"];
1202 foreach ($nodes as $qid) {
1203 $this->
object->addQuestionToBlock($qid, $target_block_id);
1207 $this->
object->moveQuestions($nodes, $a_id, $pos);
1210 $this->clearClipboard();
1211 $this->
ctrl->redirect($this,
"questions");
1216 $this->edit_manager->clearQuestionClipboard($this->
object->getRefId());
1222 return $lng->txt(
"survey_auto_block_title");
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static _getQuestionGUI(?string $questiontype, int $question_id=-1)
Creates a question gui representation.
static _getQuestionTypeName(string $type_tag)
Return the translation for a given question type.
static _changeOriginalId(int $a_question_id, int $a_original_id, int $a_object_id)
Change original id of existing question in db.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setHeaderText(string $a_headertext)
Class ilCtrl provides processing control methods.
setScreenIdComponent(string $a_comp)
@ilCtrl_Calls ilObjSurveyGUI: ilSurveyEvaluationGUI, ilSurveyExecutionGUI @ilCtrl_Calls ilObjSurveyGU...
Class ilObjSurveyQuestionPool.
static _getQuestiontypes()
Get all available question types.
static _getQuestionblock(int $questionblock_id)
get question block properties
static _hasDatasets(int $survey_id)
static _instanciateQuestion(int $question_id)
Creates an instance of a question with a given question id.
static _lookupObjId(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
filterQuestionblockBrowserObject()
copyPasteObject($pos=0)
Paste from clipboard.
gatherSelectedTableItems(bool $allow_blocks=true, bool $allow_questions=true, bool $allow_headings=false, bool $allow_questions_in_blocks=false)
Gather (and filter) selected items from table gui.
browseForQuestionblocksObject()
createQuestionObject(?ilPropertyFormGUI $a_form=null, $sel_question_types=null, ?string $pgov_pos=null)
resetfilterQuestionBrowserObject()
saveDefineQuestionblockObject()
EditManager $edit_manager
insertQuestionsBeforeObject()
ilObjSurveyGUI $parent_gui
confirmRemoveQuestionsObject()
copyQuestionsToPoolObject()
insertQuestionblocksObject()
filterQuestionBrowserObject()
ILIAS Survey InternalGUIService $gui
executeCreateQuestionObject(?string $q_type=null, ?int $pool_usage=null, ?string $pgov_pos=null)
questionsSubtabs(string $a_cmd)
ILIAS HTTP Services $http
createQuestionblockObject(?ilPropertyFormGUI $a_form=null)
addHeadingObject(?ilPropertyFormGUI $a_form=null)
ilGlobalTemplateInterface $tpl
executeCopyQuestionsToPoolObject()
removeQuestionsForm(array $checked_questionblocks, array $checked_questions, array $checked_headings)
initQuestionblockForm(?int $a_block_id=null, ?array $a_question_ids=null)
insertQuestions(int $insert_mode)
setBrowseForQuestionsSubtabs()
unfoldQuestionblockObject()
ILIAS Survey Sequence SequenceManager $sequence_manager
printListViewSelectionObject()
browseForQuestionsObject()
resetfilterQuestionblockBrowserObject()
EditingGUIRequest $request
createQuestionPool($name="dummy")
insertQuestionsAfterObject()
editHeadingObject(?ilPropertyFormGUI $a_form=null)
ILIAS Survey PrintView GUIService $print
editQuestionblockObject(?ilPropertyFormGUI $a_form=null)
confirmedRemoveHeadingObject()
setRequestedPgov(string $pgov)
initHeadingForm(?int $a_question_id=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
getParentId(int $a_node_id)
get parent id of given node
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))