ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilSurveyPageGUI Class Reference

Survey per page view. More...

+ Collaboration diagram for ilSurveyPageGUI:

Public Member Functions

 __construct (ilObjSurvey $a_survey, ilSurveyEditorGUI $a_survey_editor_gui)
 Constructor. More...
 
 executeCommand ()
 Routing. More...
 
 determineCurrentPage ()
 determine current page More...
 
 insertNewQuestion ($a_new_id)
 Add new question to survey. More...
 
 insertQuestionBlock ($a_block_id)
 Copy and insert questions from block. More...
 
 getPageNodes (array $a_questions, $a_has_previous_page=false, $a_has_next_page=false, $a_readonly=false)
 Get Form HTML. More...
 
 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. More...
 
 getAutoBlockTitle ()
 Get name for newly created blocks. More...
 
 addPoolQuestion ($pos, $node)
 

Protected Member Functions

 appendNewQuestionToSurvey ($a_new_id, $a_duplicate=true, $a_force_duplicate=false)
 Add new question to survey (database part) More...
 
 addQuestion ($a_type, $a_use_pool, $a_pos, $a_special_position)
 Call add question to survey form. More...
 
 cutQuestion ($a_id)
 Add question to be cut to clipboard. More...
 
 copyQuestion ($a_id)
 Add question to be copied to clipboard. More...
 
 multiCut ($a_id)
 Add questions to be cut to clipboard. More...
 
 multiCopy ($a_id)
 Add questions to be copied to clipboard. More...
 
 clearClipboard ()
 Empty clipboard. More...
 
 paste ($a_id)
 Paste from clipboard. More...
 
 dnd ()
 Move questions in page. More...
 
 deleteBlock ()
 Confirm removing question block. More...
 
 deleteQuestion ($a_id)
 Confirm removing question(s) from survey. More...
 
 confirmRemoveQuestions ()
 Remove question(s) from survey. More...
 
 editBlock ($a_id)
 Edit question block. More...
 
 addHeading ($a_id)
 Add heading to question. More...
 
 editHeading ($a_id)
 Edit question heading. More...
 
 deleteHeading ($a_id)
 Delete question heading. More...
 
 callEditor ($a_cmd, $a_param, $a_value)
 
 splitPage ($a_id)
 Split current page in 2 pages. More...
 
 moveNext ($a_id)
 Move question to next page. More...
 
 movePrevious ($a_id)
 Move question to previous page. More...
 
 editQuestion ($a_id)
 Edit question. More...
 
 addQuestionToolbarForm ()
 Add question to survey form (used in toolbar) More...
 
 addQuestionToolbar ()
 Add question to survey action (used in toolbar) More...
 
 movePageForm ()
 Move current page. More...
 
 movePage ()
 Move current page to new position. More...
 
 renderToolbar ($a_pages)
 Render toolbar form. More...
 
 renderPage ()
 render questions per page More...
 

Protected Attributes

 $ref_id
 
 $lng
 
 $object
 
 $editor_gui
 
 $current_page
 
 $has_previous_page
 
 $has_next_page
 
 $has_datasets
 
 $use_pool
 

Detailed Description

Survey per page view.

Author
Jörg Lützenkirchen <luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id
class.ilObjSurveyGUI.php 26720 2010-11-25 17:06:26Z jluetzen

@ilCtrl_Calls ilSurveyPageGUI:

Definition at line 14 of file class.ilSurveyPageGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSurveyPageGUI::__construct ( ilObjSurvey  $a_survey,
ilSurveyEditorGUI  $a_survey_editor_gui 
)

Constructor.

Parameters
ilObjSurvey$a_survey
ilSurveyEditorGUI$a_survey_editor_gui

Definition at line 32 of file class.ilSurveyPageGUI.php.

33 {
34 $this->editor_gui = $a_survey_editor_gui;
35 $this->ref_id = $a_survey->getRefId();
36 $this->object = $a_survey;
37 }
getRefId()
get reference id @access public

References ilObject\getRefId().

+ Here is the call graph for this function:

Member Function Documentation

◆ addHeading()

ilSurveyPageGUI::addHeading (   $a_id)
protected

Add heading to question.

Parameters
int$a_id

Definition at line 829 of file class.ilSurveyPageGUI.php.

830 {
831 $this->callEditor("addHeadingObject", "q_id", $a_id);
832 return true;
833 }
callEditor($a_cmd, $a_param, $a_value)

References callEditor().

+ Here is the call graph for this function:

◆ addPoolQuestion()

ilSurveyPageGUI::addPoolQuestion (   $pos,
  $node 
)

Definition at line 1804 of file class.ilSurveyPageGUI.php.

1805 {
1806 global $ilCtrl, $ilUser;
1807
1808 if($node == "page_end")
1809 {
1810 $pos = $this->object->getSurveyPages();
1811 $pos = array_pop($pos[$this->current_page-1]);
1812 $pos = $pos["question_id"]."a";
1813 }
1814 else
1815 {
1816 $pos = $pos."b";
1817 }
1818
1819 $ilCtrl->setParameter($this->editor_gui, "pgov", $this->current_page);
1820 $ilCtrl->setParameter($this->editor_gui, "pgov_pos", $pos);
1821
1822 $cmd = ($ilUser->getPref('svy_insert_type') == 1 || strlen($ilUser->getPref('svy_insert_type')) == 0) ? 'browseForQuestions' : 'browseForQuestionblocks';
1823 $ilCtrl->redirect($this->editor_gui, $cmd);
1824 }
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35
global $ilUser
Definition: imgupload.php:15

References $cmd, $ilCtrl, and $ilUser.

◆ addQuestion()

ilSurveyPageGUI::addQuestion (   $a_type,
  $a_use_pool,
  $a_pos,
  $a_special_position 
)
protected

Call add question to survey form.

Parameters
int$a_typequestion type
bool$a_use_pooladd question to pool
int$a_postarget position
string$a_special_positionspecial positions (toolbar | page_end)

Definition at line 339 of file class.ilSurveyPageGUI.php.

340 {
341 global $ilCtrl, $ilTabs;
342
343 // get translated type
344 include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
346 foreach($questiontypes as $item)
347 {
348 if($item["questiontype_id"] == $a_type)
349 {
350 $type_trans = $item["type_tag"];
351 }
352 }
353
354 $id = $a_pos;
355
356 // new page behind current (from toolbar)
357 if($a_special_position == "toolbar")
358 {
359 $id = $this->object->getSurveyPages();
360 if($a_pos && $a_pos != "fst")
361 {
362 $id = $id[$a_pos-1];
363 $id = array_pop($id);
364 $id = $id["question_id"]."c";
365 }
366 else
367 {
368 $id = "0c";
369 }
370 }
371 // append current page
372 else if($a_special_position == "page_end")
373 {
374 $id = $this->object->getSurveyPages();
375 $id = $id[$this->current_page-1];
376 $id = array_pop($id);
377 $id = $id["question_id"]."a";
378 }
379 else
380 {
381 $id .= "b";
382 }
383
384 if($a_use_pool)
385 {
386 $_GET["sel_question_types"] = $type_trans;
387 $_REQUEST["pgov_pos"] = $id;
388 $ilCtrl->setParameter($this->editor_gui, "pgov_pos", $id);
389 if(!$_POST["usage"])
390 {
391 $ilTabs->clearSubTabs(); // #17193
392 $this->editor_gui->createQuestionObject();
393 }
394 else
395 {
396 $this->editor_gui->executeCreateQuestionObject();
397 }
398 return true;
399 }
400 else
401 {
402 // create question and redirect to question form
403
404 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
405 $q_gui = SurveyQuestionGUI::_getQuestionGUI($type_trans);
406 $q_gui->object->setObjId($this->object->getId());
407 $q_gui->object->createNewQuestion();
408 $q_gui_class = get_class($q_gui);
409
410 // #12531
411 $ilCtrl->setParameterByClass($q_gui_class, "pgov", $this->current_page);
412 $ilCtrl->setParameterByClass($q_gui_class, "pgov_pos",$id);
413 $ilCtrl->setParameterByClass($q_gui_class, "ref_id", $this->ref_id);
414 $ilCtrl->setParameterByClass($q_gui_class, "new_for_survey", $this->ref_id);
415 $ilCtrl->setParameterByClass($q_gui_class, "q_id", $q_gui->object->getId());
416 $ilCtrl->setParameterByClass($q_gui_class, "sel_question_types", $q_gui->getQuestionType());
417 $ilCtrl->redirectByClass($q_gui_class, "editQuestion");
418 }
419 }
$_GET["client_id"]
static & _getQuestionGUI($questiontype, $question_id=-1)
Creates a question gui representation.
& _getQuestiontypes()
Creates a list of all available question types.
$_POST['username']
Definition: cron.php:12
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7

References $_GET, $_POST, $_REQUEST, $ilCtrl, SurveyQuestionGUI\_getQuestionGUI(), and ilObjSurveyQuestionPool\_getQuestiontypes().

Referenced by addQuestionToolbar(), and executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addQuestionToolbar()

ilSurveyPageGUI::addQuestionToolbar ( )
protected

Add question to survey action (used in toolbar)

Definition at line 1123 of file class.ilSurveyPageGUI.php.

1124 {
1125 global $ilCtrl, $lng;
1126
1127 $pool_active = $this->object->isPoolActive();
1128
1129 if(!$_POST["usage"] && $pool_active)
1130 {
1131 ilUtil::sendFailure($lng->txt("select_one"), true);
1132 return $this->addQuestionToolbarForm();
1133 }
1134
1135 // make sure that it is set for current and next requests
1136 $ilCtrl->setParameter($this->editor_gui, "pgov", $this->current_page);
1137
1138 if(!$this->addQuestion($_POST["qtype"], $pool_active, $_POST["pgov"], "toolbar"))
1139 {
1140 $this->renderPage();
1141 }
1142 }
addQuestionToolbarForm()
Add question to survey form (used in toolbar)
addQuestion($a_type, $a_use_pool, $a_pos, $a_special_position)
Call add question to survey form.
renderPage()
render questions per page
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References $_POST, $ilCtrl, $lng, addQuestion(), addQuestionToolbarForm(), renderPage(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ addQuestionToolbarForm()

ilSurveyPageGUI::addQuestionToolbarForm ( )
protected

Add question to survey form (used in toolbar)

Definition at line 1057 of file class.ilSurveyPageGUI.php.

1058 {
1059 global $lng, $ilCtrl, $tpl;
1060
1061 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
1062 $form = new ilPropertyFormGUI();
1063 $form->setFormAction($ilCtrl->getFormAction($this, "addQuestionToolbar"));
1064 $form->setTitle($lng->txt("survey_add_new_question"));
1065
1066 // question types
1067 include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1069 $type_map = array();
1070 foreach($questiontypes as $trans => $item)
1071 {
1072 $type_map[$item["questiontype_id"]] = $trans;
1073 }
1074 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1075 $si = new ilSelectInputGUI($lng->txt("question_type"), "qtype");
1076 $si->setOptions($type_map);
1077 $form->addItem($si);
1078
1079 $pages = $this->object->getSurveyPages();
1080 if($pages)
1081 {
1082 $pages_drop = array("fst"=>$lng->txt("survey_at_beginning"));
1083 foreach($pages as $idx => $questions)
1084 {
1085 $question = array_shift($questions);
1086 if($question["questionblock_id"])
1087 {
1088 $pages_drop[$idx+1] = $lng->txt("survey_behind_page")." ".$question["questionblock_title"];
1089 }
1090 else
1091 {
1092 $pages_drop[$idx+1] = $lng->txt("survey_behind_page")." ".strip_tags($question["title"]);
1093 }
1094 }
1095 $pos = new ilSelectInputGUI($lng->txt("position"), "pgov");
1096 $pos->setOptions($pages_drop);
1097 $form->addItem($pos);
1098
1099 $pos->setValue($this->current_page);
1100 }
1101 else
1102 {
1103 // #9089: 1st page
1104 $pos = new ilHiddenInputGUI("pgov");
1105 $pos->setValue("fst");
1106 $form->addItem($pos);
1107 }
1108
1109 if($this->object->isPoolActive())
1110 {
1111 $this->editor_gui->createQuestionObject($form);
1112 }
1113
1114 $form->addCommandButton("addQuestionToolbar", $lng->txt("create"));
1115 $form->addCommandButton("renderPage", $lng->txt("cancel"));
1116
1117 return $tpl->setContent($form->getHTML());
1118 }
global $tpl
Definition: ilias.php:8
This class represents a hidden form property in a property form.
This class represents a property form user interface.
This class represents a selection list property in a property form.

References $ilCtrl, $lng, $si, $tpl, and ilObjSurveyQuestionPool\_getQuestiontypes().

Referenced by addQuestionToolbar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ appendNewQuestionToSurvey()

ilSurveyPageGUI::appendNewQuestionToSurvey (   $a_new_id,
  $a_duplicate = true,
  $a_force_duplicate = false 
)
protected

Add new question to survey (database part)

@param int $a_new_id
@param bool $a_duplicate

Definition at line 156 of file class.ilSurveyPageGUI.php.

157 {
158 global $ilDB;
159
160 // get maximum sequence index in test
161 $result = $ilDB->queryF("SELECT survey_question_id FROM svy_svy_qst WHERE survey_fi = %s",
162 array('integer'),
163 array($this->object->getSurveyId())
164 );
165 $sequence = $result->numRows();
166
167 // create duplicate if pool question (or forced for question blocks copy)
168 if($a_duplicate)
169 {
170 $survey_question_id = $this->object->duplicateQuestionForSurvey($a_new_id, $a_force_duplicate);
171 }
172 // used by copy & paste
173 else
174 {
175 $survey_question_id = $a_new_id;
176 }
177
178 // append to survey
179 $next_id = $ilDB->nextId('svy_svy_qst');
180 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_svy_qst (survey_question_id, survey_fi,".
181 "question_fi, sequence, tstamp) VALUES (%s, %s, %s, %s, %s)",
182 array('integer', 'integer', 'integer', 'integer', 'integer'),
183 array($next_id, $this->object->getSurveyId(), $survey_question_id, $sequence, time())
184 );
185
186 return $survey_question_id;
187 }
$result
global $ilDB

References $ilDB, and $result.

Referenced by insertNewQuestion(), insertQuestionBlock(), and paste().

+ Here is the caller graph for this function:

◆ callEditor()

ilSurveyPageGUI::callEditor (   $a_cmd,
  $a_param,
  $a_value 
)
protected

Definition at line 857 of file class.ilSurveyPageGUI.php.

858 {
859 global $ilTabs;
860
861 $ilTabs->clearSubTabs();
862 $_REQUEST[$a_param] = $a_value;
863
864 call_user_func(array($this->editor_gui, $a_cmd));
865 }

References $_REQUEST.

Referenced by addHeading(), deleteHeading(), editBlock(), and editHeading().

+ Here is the caller graph for this function:

◆ clearClipboard()

ilSurveyPageGUI::clearClipboard ( )
protected

Empty clipboard.

Definition at line 496 of file class.ilSurveyPageGUI.php.

497 {
498 $_SESSION["survey_page_view"][$this->ref_id]["clipboard"] = null;
499 }
$_SESSION["AccountId"]

References $_SESSION, and $ref_id.

Referenced by paste().

+ Here is the caller graph for this function:

◆ confirmRemoveQuestions()

ilSurveyPageGUI::confirmRemoveQuestions ( )
protected

Remove question(s) from survey.

Definition at line 745 of file class.ilSurveyPageGUI.php.

746 {
747 global $ilCtrl;
748
749 // gather ids
750 $ids = array();
751 foreach ($_POST as $key => $value)
752 {
753 if (preg_match("/id_(\d+)/", $key, $matches))
754 {
755 array_push($ids, $matches[1]);
756 }
757 }
758
759
760 $pages = $this->object->getSurveyPages();
761 $source = $pages[$this->current_page-1];
762
763 $block_id = $source;
764 $block_id = array_shift($block_id);
765 $block_id = $block_id["questionblock_id"];
766
767 if(sizeof($ids) && sizeof($source) > sizeof($ids))
768 {
769 // block is obsolete
770 if(sizeof($source)-sizeof($ids) == 1)
771 {
772 $this->object->unfoldQuestionblocks(array($block_id));
773 }
774 // block will remain, remove question(s) from block
775 else
776 {
777 foreach($ids as $qid)
778 {
779 $this->object->removeQuestionFromBlock($qid, $block_id);
780 }
781 }
782
783 $this->object->removeQuestions($ids, array());
784 }
785 // all items on page
786 else
787 {
788 // remove complete block
789 if($block_id)
790 {
791 $this->object->removeQuestions(array(), array($block_id));
792 }
793 // remove single question
794 else
795 {
796 $this->object->removeQuestions($ids, array());
797 }
798
799 // render previous page
800 if($this->current_page > 1)
801 {
802 $this->current_page--;
803 }
804 }
805
806 $this->object->saveCompletionStatus();
807
808 // #10567
809 $ilCtrl->setParameter($this, "pgov", $this->current_page);
810 $ilCtrl->redirect($this, "renderPage");
811 }

References $_POST, and $ilCtrl.

◆ copyQuestion()

ilSurveyPageGUI::copyQuestion (   $a_id)
protected

Add question to be copied to clipboard.

Parameters
int$a_idquestion id

Definition at line 444 of file class.ilSurveyPageGUI.php.

445 {
446 global $lng;
447
448 ilUtil::sendSuccess($lng->txt("survey_questions_to_clipboard_copy"));
449 $this->suppress_clipboard_msg = true;
450
451 $_SESSION["survey_page_view"][$this->ref_id]["clipboard"] = array(
452 "source" => $this->current_page,
453 "nodes" => array($a_id),
454 "mode" => "copy");
455 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.

References $_SESSION, $lng, $ref_id, and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ cutQuestion()

ilSurveyPageGUI::cutQuestion (   $a_id)
protected

Add question to be cut to clipboard.

Parameters
int$a_idquestion id

Definition at line 426 of file class.ilSurveyPageGUI.php.

427 {
428 global $lng;
429
430 ilUtil::sendSuccess($lng->txt("survey_questions_to_clipboard_cut"));
431 $this->suppress_clipboard_msg = true;
432
433 $_SESSION["survey_page_view"][$this->ref_id]["clipboard"] = array(
434 "source" => $this->current_page,
435 "nodes" => array($a_id),
436 "mode" => "cut");
437 }

References $_SESSION, $lng, $ref_id, and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ deleteBlock()

ilSurveyPageGUI::deleteBlock ( )
protected

Confirm removing question block.

Parameters
int$a_id

Definition at line 695 of file class.ilSurveyPageGUI.php.

696 {
697 global $lng, $ilCtrl;
698
699 $ilCtrl->setParameter($this->editor_gui, "pgov", $this->current_page);
700 ilUtil::sendQuestion($lng->txt("remove_questions"));
701
702 $page = $this->object->getSurveyPages();
703 $page = $page[$this->current_page-1];
704
705 // #10567
706 if($_REQUEST["csum"] != md5(print_r($page, true)))
707 {
708 $ilCtrl->redirect($this, "renderPage");
709 }
710
711 $page = array_shift($page);
712 $block_id = $page["questionblock_id"];
713 if($block_id)
714 {
715 $this->editor_gui->removeQuestionsForm(array($block_id), array(), array());
716 }
717 else
718 {
719 $this->editor_gui->removeQuestionsForm(array(), array($page["question_id"]), array());
720 }
721 }
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.

References $_REQUEST, $ilCtrl, $lng, and ilUtil\sendQuestion().

+ Here is the call graph for this function:

◆ deleteHeading()

ilSurveyPageGUI::deleteHeading (   $a_id)
protected

Delete question heading.

Parameters
int$a_id

Definition at line 851 of file class.ilSurveyPageGUI.php.

852 {
853 $this->callEditor("removeHeadingObject", "q_id", $a_id);
854 return true;
855 }

References callEditor().

+ Here is the call graph for this function:

◆ deleteQuestion()

ilSurveyPageGUI::deleteQuestion (   $a_id)
protected

Confirm removing question(s) from survey.

Parameters
int | array$a_id

Definition at line 728 of file class.ilSurveyPageGUI.php.

729 {
730 global $ilCtrl;
731
732 if(!is_array($a_id))
733 {
734 $a_id = array($a_id);
735 }
736
737 $ilCtrl->setParameter($this->editor_gui, "pgov", $this->current_page);
738 $this->editor_gui->removeQuestionsForm(array(), $a_id, array());
739 return true;
740 }

References $ilCtrl.

◆ determineCurrentPage()

ilSurveyPageGUI::determineCurrentPage ( )

determine current page

Definition at line 132 of file class.ilSurveyPageGUI.php.

133 {
134 $current_page = (int)$_REQUEST["jump"];
135 if(!$current_page)
136 {
137 $current_page = (int)$_REQUEST["pgov"];
138 }
139 if(!$current_page)
140 {
141 $current_page = (int)$_REQUEST["pg"];
142 }
143 if(!$current_page)
144 {
145 $current_page = 1;
146 }
147 $this->current_page = $current_page;
148 }

References $_REQUEST, and $current_page.

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ dnd()

ilSurveyPageGUI::dnd ( )
protected

Move questions in page.

Definition at line 669 of file class.ilSurveyPageGUI.php.

670 {
671 $source_id = (int)array_pop(explode("_", $_REQUEST["il_hform_source"]));
672 if($_REQUEST["il_hform_target"] != "droparea_end")
673 {
674 $target_id = (int)array_pop(explode("_", $_REQUEST["il_hform_target"]));
675 $pos = 0;
676 }
677 else
678 {
679 $page = $this->object->getSurveyPages();
680 $page = $page[$this->current_page-1];
681 $last = array_pop($page);
682 $target_id = (int)$last["question_id"];
683 $pos = 1;
684 }
685 if($source_id != $target_id)
686 {
687 $this->object->moveQuestions(array($source_id), $target_id, $pos);
688 }
689 }
$target_id
Definition: goto.php:88

References $_REQUEST, and $target_id.

◆ editBlock()

ilSurveyPageGUI::editBlock (   $a_id)
protected

Edit question block.

Parameters
int$a_id

Definition at line 818 of file class.ilSurveyPageGUI.php.

819 {
820 $this->callEditor("editQuestionblockObject", "bl_id", $a_id);
821 return true;
822 }

References callEditor().

+ Here is the call graph for this function:

◆ editHeading()

ilSurveyPageGUI::editHeading (   $a_id)
protected

Edit question heading.

Parameters
int$a_id

Definition at line 840 of file class.ilSurveyPageGUI.php.

841 {
842 $this->callEditor("editHeadingObject", "q_id", $a_id);
843 return true;
844 }

References callEditor().

+ Here is the call graph for this function:

◆ editQuestion()

ilSurveyPageGUI::editQuestion (   $a_id)
protected

Edit question.

Parameters
int$a_id

Definition at line 1040 of file class.ilSurveyPageGUI.php.

1041 {
1042 global $ilCtrl;
1043
1044 $data = $this->object->getSurveyQuestions();
1045 $data = $data[$a_id];
1046
1047 $q_gui = $data["type_tag"]."GUI";
1048 $ilCtrl->setParameterByClass($q_gui, "pgov", $this->current_page);
1049 $ilCtrl->setParameterByClass($q_gui, "q_id", $a_id);
1050
1051 $ilCtrl->redirectByClass($q_gui, "editQuestion");
1052 }
$data

References $data, and $ilCtrl.

◆ executeCommand()

ilSurveyPageGUI::executeCommand ( )

Routing.

Definition at line 42 of file class.ilSurveyPageGUI.php.

43 {
44 global $lng, $ilCtrl, $rbacsystem;
45
46 $cmd = $ilCtrl->getCmd("renderPage");
47 $next_class = $ilCtrl->getNextClass($this);
48
49 switch($next_class)
50 {
51 default:
52 $this->determineCurrentPage();
53
54 $has_content = false;
55
56 if($rbacsystem->checkAccess("write", $this->ref_id))
57 {
58 // add page?
59 if($_REQUEST["new_id"])
60 {
61 $this->insertNewQuestion($_REQUEST["new_id"]);
62 }
63
64 // subcommands
65 if($_REQUEST["il_hform_subcmd"])
66 {
67 $subcmd = $_REQUEST["il_hform_subcmd"];
68
69 // make sure that it is set for current and next requests
70 $ilCtrl->setParameter($this->editor_gui, "pgov", $this->current_page);
72
73 $id = explode("_", $_REQUEST["il_hform_node"]);
74 $id = (int)$id[1];
75
76 // multi operation
77 if(substr($_REQUEST["il_hform_subcmd"], 0, 5) == "multi")
78 {
79 if($_REQUEST["il_hform_multi"])
80 {
81 // removing types as we only allow questions anyway
82 $id = array();
83 foreach(explode(";", $_REQUEST["il_hform_multi"]) as $item)
84 {
85 $id[] = (int)array_pop(explode("_", $item));
86 }
87
88 if($subcmd == "multiDelete")
89 {
90 $subcmd = "deleteQuestion";
91 }
92 }
93 else
94 {
95 // #9525
96 if($subcmd == "multiDelete")
97 {
98 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
99 $ilCtrl->redirect($this, "renderPage");
100 }
101 else
102 {
103 ilUtil::sendFailure($lng->txt("no_checkbox"));
104 }
105 }
106 }
107
108 if(substr($subcmd, 0, 11) == "addQuestion")
109 {
110 $type = explode("_", $subcmd);
111 $type = (int)$type[1];
112 $has_content = $this->addQuestion($type, $this->object->isPoolActive(), $id, $_REQUEST["il_hform_node"]);
113 }
114 else
115 {
116 $has_content = $this->$subcmd($id, $_REQUEST["il_hform_node"]);
117 }
118 }
119 }
120
121 if(!$has_content)
122 {
123 $this->$cmd();
124 }
125 break;
126 }
127 }
determineCurrentPage()
determine current page
insertNewQuestion($a_new_id)
Add new question to survey.

References $_REQUEST, $cmd, $current_page, $ilCtrl, $lng, addQuestion(), determineCurrentPage(), insertNewQuestion(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ getAutoBlockTitle()

ilSurveyPageGUI::getAutoBlockTitle ( )

Get name for newly created blocks.

Returns
string

Definition at line 1797 of file class.ilSurveyPageGUI.php.

1798 {
1799 global $lng;
1800
1801 return $lng->txt("survey_auto_block_title");
1802 }

References $lng.

Referenced by insertNewQuestion(), insertQuestionBlock(), moveNext(), movePrevious(), paste(), and splitPage().

+ Here is the caller graph for this function:

◆ getPageNodes()

ilSurveyPageGUI::getPageNodes ( array  $a_questions,
  $a_has_previous_page = false,
  $a_has_next_page = false,
  $a_readonly = false 
)

Get Form HTML.

Parameters
array$questions
bool$a_has_previous_page
bool$a_has_next_page
bool$a_readonly
Returns
string

Definition at line 1508 of file class.ilSurveyPageGUI.php.

1509 {
1510 global $ilCtrl, $lng;
1511
1512 $ttpl = new ilTemplate("tpl.il_svy_svy_page_view_nodes.html", true, true, "Modules/Survey");
1513
1514 $has_clipboard = (bool)$_SESSION["survey_page_view"][$this->ref_id]["clipboard"];
1515
1516 // question block ?
1517
1518 $first_question = $a_questions;
1519 $first_question = array_shift($first_question);
1520
1521 if($first_question["questionblock_id"])
1522 {
1523 $menu = array();
1524
1525 if(!$a_readonly && !$has_clipboard)
1526 {
1527 $menu[] = array("cmd" => "editBlock", "text" => $lng->txt("edit"));
1528 }
1529
1530 if($first_question["questionblock_show_blocktitle"])
1531 {
1532 $block_status = $lng->txt("survey_block_visible");
1533 }
1534 else
1535 {
1536 $block_status = $lng->txt("survey_block_hidden");
1537 }
1538
1539 $this->renderPageNode($ttpl, "block", $first_question["questionblock_id"],
1540 $first_question["questionblock_title"]." (".$block_status.")", $menu, false, false, $block_status);
1541 }
1542
1543
1544 // questions/headings
1545
1546 include_once "./Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php";
1548 $questionpools = array_keys($this->object->getQuestionpoolTitles(true));
1549
1550 $counter = $question_count;
1551 $block_done = null;
1552 foreach($a_questions as $idx => $question)
1553 {
1554 // drop area
1555
1556 $menu = array();
1557
1558 if(!$a_readonly)
1559 {
1560 if(!$has_clipboard)
1561 {
1562 foreach($questiontypes as $trans => $item)
1563 {
1564 $menu[] = array("cmd"=> "addQuestion_".$item["questiontype_id"],
1565 "text"=> sprintf($lng->txt("svy_page_add_question"), $trans));
1566 }
1567
1568 if($this->object->isPoolActive())
1569 {
1570 $menu[] = array("cmd"=> "addPoolQuestion",
1571 "text"=> $lng->txt("browse_for_questions"));
1572 }
1573 }
1574 else
1575 {
1576 $menu[] = array("cmd" => "paste", "text" => $lng->txt("survey_dnd_paste"));
1577 }
1578 }
1579
1580 $this->renderPageNode($ttpl, "droparea", $question["question_id"], null, $menu, true);
1581
1582 // question
1583 $question_gui = $this->object->getQuestionGUI($question["type_tag"], $question["question_id"]);
1584 $question_form = $question_gui->getWorkingForm(array(), $this->object->getShowQuestionTitles(),
1585 $question["questionblock_show_questiontext"], null, $this->object->getSurveyId());
1586
1587 $menu = array();
1588
1589 if(!$a_readonly && !$has_clipboard)
1590 {
1591 $menu[] = array("cmd" => "editQuestion", "text" => $lng->txt("edit"));
1592 $menu[] = array("cmd" => "cutQuestion", "text" => $lng->txt("cut"));
1593 $menu[] = array("cmd" => "copyQuestion", "text" => $lng->txt("copy"));
1594
1595 if(sizeof($a_questions) > 1 && $idx > 0)
1596 {
1597 $menu[] = array("cmd" => "splitPage", "text" => $lng->txt("survey_dnd_split_page"));
1598 }
1599 if($a_has_next_page)
1600 {
1601 $menu[] = array("cmd" => "moveNext", "text" => $lng->txt("survey_dnd_move_next"));
1602 }
1603 if($a_has_previous_page)
1604 {
1605 $menu[] = array("cmd" => "movePrevious", "text" => $lng->txt("survey_dnd_move_previous"));
1606 }
1607
1608 $menu[] = array("cmd" => "deleteQuestion", "text" => $lng->txt("delete"));
1609
1610 // heading
1611 if($question["heading"])
1612 {
1613 $menu[] = array("cmd" => "editHeading", "text" => $lng->txt("survey_edit_heading"));
1614 $menu[] = array("cmd" => "deleteHeading", "text" => $lng->txt("survey_delete_heading"));
1615 }
1616 else
1617 {
1618 $menu[] = array("cmd" => "addHeading", "text" => $lng->txt("add_heading"));
1619 }
1620 }
1621
1622 if($first_question["questionblock_show_questiontext"])
1623 {
1624 $question_title_status = $lng->txt("survey_question_text_visible");
1625 }
1626 else
1627 {
1628 $question_title_status = $lng->txt("survey_question_text_hidden");
1629 }
1630
1631 $this->renderPageNode($ttpl, "question", $question["question_id"], $question_form, $menu,
1632 false, $question["title"], $question_title_status, $question["heading"]);
1633
1634 $ilCtrl->setParameter($this, "eqid", "");
1635 }
1636
1637
1638 // last position (no question id)
1639
1640 $menu = array();
1641
1642 if(!$a_readonly)
1643 {
1644 if(!$has_clipboard)
1645 {
1646 foreach($questiontypes as $trans => $item)
1647 {
1648 $menu[] = array("cmd"=> "addQuestion_".$item["questiontype_id"],
1649 "text"=> sprintf($lng->txt("svy_page_add_question"), $trans));
1650 }
1651
1652 if($this->object->isPoolActive())
1653 {
1654 $menu[] = array("cmd"=> "addPoolQuestion",
1655 "text"=> $lng->txt("browse_for_questions"));
1656 }
1657 }
1658 else
1659 {
1660 $menu[] = array("cmd" => "paste", "text" => $lng->txt("survey_dnd_paste"));
1661 }
1662 }
1663
1664 $this->renderPageNode($ttpl, "page", "end", null, $menu, true);
1665
1666 return $ttpl->get();
1667 }
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.
special template class to simplify handling of ITX/PEAR

References $_SESSION, $ilCtrl, $lng, ilObjSurveyQuestionPool\_getQuestiontypes(), and renderPageNode().

Referenced by renderPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertNewQuestion()

ilSurveyPageGUI::insertNewQuestion (   $a_new_id)

Add new question to survey.

Parameters
int$a_new_id

Definition at line 194 of file class.ilSurveyPageGUI.php.

195 {
196 global $rbacsystem, $ilDB, $lng;
197
198 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
199 if (!SurveyQuestion::_isComplete($a_new_id))
200 {
201 ilUtil::sendFailure($lng->txt("survey_error_insert_incomplete_question"));
202 }
203 else
204 {
205 $a_new_id = $this->appendNewQuestionToSurvey($a_new_id);
206 $this->object->loadQuestionsFromDb();
207
208 $pos = $_REQUEST["pgov_pos"];
209
210 // a[fter]/b[efore] on same page
211 if(substr($pos, -1) != "c")
212 {
213 // block handling
214 $current = $this->object->getSurveyPages();
215 $current = $current[$this->current_page-1];
216 if(sizeof($current) == 1)
217 {
218 // as questions are moved to first block question
219 // always use existing as first
220 // the new question is moved later on (see below)
221 $this->object->createQuestionblock($this->getAutoBlockTitle(), true, false,
222 array((int)$pos, $a_new_id));
223 }
224 else
225 {
226 $block_id = array_pop($current);
227 $block_id = $block_id["questionblock_id"];
228
229 $this->object->addQuestionToBlock($a_new_id, $block_id);
230 }
231 }
232 // c: as new page (from toolbar/pool)
233 else
234 {
235 // after given question
236 if((int)$pos)
237 {
238 $pos = (int)$pos."a";
239 $this->current_page++;
240 }
241 // at the beginning
242 else
243 {
244 $first = $this->object->getSurveyPages();
245 $first = $first[0];
246 $first = array_shift($first);
247 $pos = $first["question_id"]."b";
248 $this->current_page = 1;
249 }
250 }
251
252 // move to target position
253 $this->object->moveQuestions(array($a_new_id), (int)$pos,
254 ((substr($pos, -1) == "a") ? 1 : 0));
255 }
256 }
_isComplete($question_id)
Checks whether the question is complete or not.
appendNewQuestionToSurvey($a_new_id, $a_duplicate=true, $a_force_duplicate=false)
Add new question to survey (database part)
getAutoBlockTitle()
Get name for newly created blocks.

References $_REQUEST, $ilDB, $lng, SurveyQuestion\_isComplete(), appendNewQuestionToSurvey(), getAutoBlockTitle(), and ilUtil\sendFailure().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertQuestionBlock()

ilSurveyPageGUI::insertQuestionBlock (   $a_block_id)

Copy and insert questions from block.

Parameters
int$a_block_id

Definition at line 263 of file class.ilSurveyPageGUI.php.

264 {
265 $new_ids = array();
266 $question_ids = $this->object->getQuestionblockQuestionIds($a_block_id);
267 foreach($question_ids as $qid)
268 {
269 $new_ids[] = $this->appendNewQuestionToSurvey($qid, true, true);
270 }
271
272 if(sizeof($new_ids))
273 {
274 $this->object->loadQuestionsFromDb();
275
276 $pos = $_REQUEST["pgov_pos"];
277
278 // a[fter]/b[efore] on same page
279 if(substr($pos, -1) != "c")
280 {
281 // block handling
282 $current = $this->object->getSurveyPages();
283 $current = $current[$this->current_page-1];
284 if(sizeof($current) == 1)
285 {
286 // as questions are moved to first block question
287 // always use existing as first
288 // the new question is moved later on (see below)
289 $this->object->createQuestionblock($this->getAutoBlockTitle(), true, false,
290 array((int)$pos)+$new_ids);
291 }
292 else
293 {
294 $block_id = array_pop($current);
295 $block_id = $block_id["questionblock_id"];
296
297 foreach($new_ids as $qid)
298 {
299 $this->object->addQuestionToBlock($qid, $block_id);
300 }
301 }
302 }
303 // c: as new page (from toolbar/pool)
304 else
305 {
306 // re-create block
307 $this->object->createQuestionblock($this->getAutoBlockTitle(), true, false,
308 $new_ids);
309
310 // after given question
311 if((int)$pos)
312 {
313 $pos = (int)$pos."a";
314 }
315 // at the beginning
316 else
317 {
318 $first = $this->object->getSurveyPages();
319 $first = $first[0];
320 $first = array_shift($first);
321 $pos = $first["question_id"]."b";
322 }
323 }
324
325 // move to target position
326 $this->object->moveQuestions($new_ids, (int)$pos,
327 ((substr($pos, -1) == "a") ? 1 : 0));
328 }
329 }

References $_REQUEST, appendNewQuestionToSurvey(), and getAutoBlockTitle().

+ Here is the call graph for this function:

◆ moveNext()

ilSurveyPageGUI::moveNext (   $a_id)
protected

Move question to next page.

Parameters
int$a_id

Definition at line 922 of file class.ilSurveyPageGUI.php.

923 {
924 $pages = $this->object->getSurveyPages();
925 $source = $pages[$this->current_page-1];
926 $target = $pages[$this->current_page];
927 if(sizeof($target))
928 {
929 $target_id = $target;
930 $target_id = array_shift($target_id);
931 $target_block_id = $target_id["questionblock_id"];
932 $target_id = $target_id["question_id"];
933
934 // nothing to do if no block
935 if(sizeof($source) > 1)
936 {
937 $block_id = $source;
938 $block_id = array_shift($block_id);
939 $block_id = $block_id["questionblock_id"];
940
941 // source pages block is obsolete
942 if(sizeof($source) == 2)
943 {
944 // delete block
945 $this->object->unfoldQuestionblocks(array($block_id));
946 }
947 else
948 {
949 // remove question from block
950 $this->object->removeQuestionFromBlock($a_id, $block_id);
951 }
952 }
953
954 // move source question to target
955 $this->object->moveQuestions(array($a_id), $target_id, 0);
956
957 // new page has no block yet
958 if(sizeof($target) < 2)
959 {
960 // create block and move target question and source into block
961 $this->object->createQuestionblock($this->getAutoBlockTitle(), true, false,
962 array($a_id, $target_id));
963 }
964 else
965 {
966 // add source question to block
967 $this->object->addQuestionToBlock($a_id, $target_block_id);
968 }
969
970 // only if current page is not "deleted"
971 if(sizeof($source) > 1)
972 {
973 $this->current_page++;
974 }
975 }
976 }

References $current_page, $target_id, and getAutoBlockTitle().

+ Here is the call graph for this function:

◆ movePage()

ilSurveyPageGUI::movePage ( )
protected

Move current page to new position.

Todo:
this needs to be refactored outside of a GUI class, same with ilSurveyEditorGUI->insertQuestions

Definition at line 1198 of file class.ilSurveyPageGUI.php.

1199 {
1200 global $lng, $ilCtrl;
1201
1202 // current_page is already set to new position
1203 $target_page = $this->current_page-1;
1204 $source_page = $_REQUEST["old_pos"]-1;
1205
1206 $pages = $this->object->getSurveyPages();
1207 foreach($pages[$source_page] as $question)
1208 {
1209 $questions[] = $question["question_id"];
1210 }
1211
1212 // move to first position
1213 $position = 0;
1214 if($_REQUEST["pgov"] != "fst")
1215 {
1216 $position = 1;
1217 }
1218
1219 $target = $pages[$target_page];
1220 if ($position == 0) // before
1221 {
1222 $target = array_shift($target); // ... use always the first question of the page
1223 }
1224 else // after
1225 {
1226 $target = array_pop($target); // ... use always the last question of the page
1227 }
1228 $this->object->moveQuestions($questions, $target["question_id"], $position);
1229
1230 if($target_page < $source_page && $position)
1231 {
1232 $this->current_page++;
1233 }
1234
1235 ilUtil::sendSuccess($lng->txt("survey_page_moved"), true);
1236 $ilCtrl->setParameter($this, "pgov", $this->current_page);
1237 $ilCtrl->redirect($this, "renderPage");
1238 }

References $_REQUEST, $ilCtrl, $lng, and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ movePageForm()

ilSurveyPageGUI::movePageForm ( )
protected

Move current page.

Definition at line 1147 of file class.ilSurveyPageGUI.php.

1148 {
1149 global $lng, $ilCtrl, $tpl;
1150
1151 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
1152 $form = new ilPropertyFormGUI();
1153 $form->setFormAction($ilCtrl->getFormAction($this, "movePage"));
1154 $form->setTitle($lng->txt("survey_move_page"));
1155
1156 $old_pos = new ilHiddenInputGUI("old_pos");
1157 $old_pos->setValue($this->current_page);
1158 $form->addItem($old_pos);
1159
1160 $pages = $this->object->getSurveyPages();
1161 if($pages)
1162 {
1163 $pages_drop = array();
1164 if($this->current_page != 1)
1165 {
1166 $pages_drop["fst"] = $lng->txt("survey_at_beginning");
1167 }
1168 foreach($pages as $idx => $questions)
1169 {
1170 if(($idx+1) != $this->current_page && ($idx+2) != $this->current_page)
1171 {
1172 $question = array_shift($questions);
1173 if($question["questionblock_id"])
1174 {
1175 $pages_drop[$idx+1] = $lng->txt("survey_behind_page")." ".$question["questionblock_title"];
1176 }
1177 else
1178 {
1179 $pages_drop[$idx+1] = $lng->txt("survey_behind_page")." ".strip_tags($question["title"]);
1180 }
1181 }
1182 }
1183 $pos = new ilSelectInputGUI($lng->txt("position"), "pgov");
1184 $pos->setOptions($pages_drop);
1185 $form->addItem($pos);
1186 }
1187
1188 $form->addCommandButton("movePage", $lng->txt("submit"));
1189 $form->addCommandButton("renderPage", $lng->txt("cancel"));
1190
1191 return $tpl->setContent($form->getHTML());
1192 }

References $ilCtrl, $lng, and $tpl.

◆ movePrevious()

ilSurveyPageGUI::movePrevious (   $a_id)
protected

Move question to previous page.

Parameters
int$a_id

Definition at line 983 of file class.ilSurveyPageGUI.php.

984 {
985 $pages = $this->object->getSurveyPages();
986 $source = $pages[$this->current_page-1];
987 $target = $pages[$this->current_page-2];
988 if(sizeof($target))
989 {
990 $target_id = $target;
991 $target_id = array_pop($target_id);
992 $target_block_id = $target_id["questionblock_id"];
993 $target_id = $target_id["question_id"];
994
995 // nothing to do if no block
996 if(sizeof($source) > 1)
997 {
998 $block_id = $source;
999 $block_id = array_shift($block_id);
1000 $block_id = $block_id["questionblock_id"];
1001
1002 // source pages block is obsolete
1003 if(sizeof($source) == 2)
1004 {
1005 // delete block
1006 $this->object->unfoldQuestionblocks(array($block_id));
1007 }
1008 else
1009 {
1010 // remove question from block
1011 $this->object->removeQuestionFromBlock($a_id, $block_id);
1012 }
1013 }
1014
1015 // move source question to target
1016 $this->object->moveQuestions(array($a_id), $target_id, 1);
1017
1018 // new page has no block yet
1019 if(sizeof($target) < 2)
1020 {
1021 // create block and move target question and source into block
1022 $this->object->createQuestionblock($this->getAutoBlockTitle(), true, false,
1023 array($target_id, $a_id));
1024 }
1025 else
1026 {
1027 // add source question to block
1028 $this->object->addQuestionToBlock($a_id, $target_block_id);
1029 }
1030
1031 $this->current_page--;
1032 }
1033 }

References $target_id, and getAutoBlockTitle().

+ Here is the call graph for this function:

◆ multiCopy()

ilSurveyPageGUI::multiCopy (   $a_id)
protected

Add questions to be copied to clipboard.

Parameters
array$a_idquestion ids

Definition at line 480 of file class.ilSurveyPageGUI.php.

481 {
482 global $lng;
483
484 ilUtil::sendSuccess($lng->txt("survey_questions_to_clipboard_copy"));
485 $this->suppress_clipboard_msg = true;
486
487 $_SESSION["survey_page_view"][$this->ref_id]["clipboard"] = array(
488 "source" => $this->current_page,
489 "nodes" => $a_id,
490 "mode" => "copy");
491 }

References $_SESSION, $lng, $ref_id, and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ multiCut()

ilSurveyPageGUI::multiCut (   $a_id)
protected

Add questions to be cut to clipboard.

Parameters
array$a_idquestion ids

Definition at line 462 of file class.ilSurveyPageGUI.php.

463 {
464 global $lng;
465
466 ilUtil::sendSuccess($lng->txt("survey_questions_to_clipboard_cut"));
467 $this->suppress_clipboard_msg = true;
468
469 $_SESSION["survey_page_view"][$this->ref_id]["clipboard"] = array(
470 "source" => $this->current_page,
471 "nodes" => $a_id,
472 "mode" => "cut");
473 }

References $_SESSION, $lng, $ref_id, and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ paste()

ilSurveyPageGUI::paste (   $a_id)
protected

Paste from clipboard.

Parameters
int$a_idtarget position

Definition at line 506 of file class.ilSurveyPageGUI.php.

507 {
508 $data = $_SESSION["survey_page_view"][$this->ref_id]["clipboard"];
509 $pages = $this->object->getSurveyPages();
510 $source = $pages[$data["source"]-1];
511 $target = $pages[$this->current_page-1];
512
513 // #12558 - use order of source page
514 $nodes = array();
515 foreach($source as $src_qst)
516 {
517 if(in_array($src_qst["question_id"], $data["nodes"]))
518 {
519 $nodes[] = $src_qst["question_id"];
520 }
521 }
522
523 // append to last position?
524 $pos = 0;
525 if($_REQUEST["il_hform_node"] == "page_end")
526 {
527 $a_id = $target;
528 $a_id = array_pop($a_id);
529 $a_id = $a_id["question_id"];
530 $pos = 1;
531 }
532
533 // cut
534 if($data["mode"] == "cut")
535 {
536 // special case: paste cut on same page (no block handling needed)
537 if($data["source"] == $this->current_page)
538 {
539 // re-order nodes in page
540 if(sizeof($nodes) <= sizeof($source))
541 {
542 $this->object->moveQuestions($nodes, $a_id, $pos);
543 }
544 $this->clearClipboard();
545 return;
546 }
547 else
548 {
549 // only if source has block
550 $source_block_id = false;
551 if(sizeof($source) > 1)
552 {
553 $source_block_id = $source;
554 $source_block_id = array_shift($source_block_id);
555 $source_block_id = $source_block_id["questionblock_id"];
556
557 // remove from block
558 if(sizeof($source) > sizeof($nodes))
559 {
560 foreach($nodes as $qid)
561 {
562 $this->object->removeQuestionFromBlock($qid, $source_block_id);
563 }
564 }
565 // remove complete block
566 else
567 {
568 $this->object->unfoldQuestionblocks(array($source_block_id));
569 }
570 }
571
572 // page will be "deleted" by operation
573 if(sizeof($source) == sizeof($nodes) && $data["source"] < $this->current_page)
574 {
575 $this->current_page--;
576 }
577 }
578 }
579
580 // copy
581 else if($data["mode"] == "copy")
582 {
583 $titles = array();
584 foreach($this->object->getSurveyPages() as $page)
585 {
586 foreach($page as $question)
587 {
588 $titles[] = $question["title"];
589 }
590 }
591
592 // copy questions
593 $question_pointer = array();
594 foreach($nodes as $qid)
595 {
596 // create new questions
597 $question = ilObjSurvey::_instanciateQuestion($qid);
598
599 // handle exisiting copies
600 $title = $question->getTitle();
601 $max = 0;
602 foreach($titles as $existing_title)
603 {
604 if(preg_match("/".preg_quote($title)." \‍(([0-9]+)\‍)$/", $existing_title, $match))
605 {
606 $max = max($match[1], $max);
607 }
608 }
609 if($max)
610 {
611 $title .= " (".($max+1).")";
612 }
613 else
614 {
615 $title .= " (2)";
616 }
617 $titles[] = $title;
618 $question->setTitle($title);
619
620 $question->id = -1;
621 $question->saveToDb();
622
623 $question_pointer[$qid] = $question->getId();
624 $this->appendNewQuestionToSurvey($question->getId(), false);
625 }
626
627 // copy textblocks
628 $this->object->cloneTextblocks($question_pointer);
629
630 $this->object->loadQuestionsFromDb();
631
632 $nodes = array_values($question_pointer);
633 }
634
635
636 // paste
637
638 // create new block
639 if(sizeof($target) == 1)
640 {
641 $nodes = array_merge(array($a_id), $nodes);
642
643 // moveQuestions() is called within
644 $this->object->createQuestionblock($this->getAutoBlockTitle(), true, false,
645 $nodes);
646 }
647 // add to existing block
648 else
649 {
650 $target_block_id = $target;
651 $target_block_id = array_shift($target_block_id);
652 $target_block_id = $target_block_id["questionblock_id"];
653
654 foreach($nodes as $qid)
655 {
656 $this->object->addQuestionToBlock($qid, $target_block_id);
657 }
658
659 // move to new position
660 $this->object->moveQuestions($nodes, $a_id, $pos);
661 }
662
663 $this->clearClipboard();
664 }
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
clearClipboard()
Empty clipboard.

References $_REQUEST, $_SESSION, $data, $ref_id, ilObjSurvey\_instanciateQuestion(), appendNewQuestionToSurvey(), clearClipboard(), and getAutoBlockTitle().

+ Here is the call graph for this function:

◆ renderPage()

ilSurveyPageGUI::renderPage ( )
protected

render questions per page

Definition at line 1383 of file class.ilSurveyPageGUI.php.

1384 {
1385 global $ilCtrl, $lng, $tpl, $rbacsystem;
1386
1387 $pages = $this->object->getSurveyPages();
1388 $this->has_next_page = ($this->current_page < sizeof($pages));
1389 $this->has_previous_page = ($this->current_page > 1);
1390 $this->has_datasets = $this->object->_hasDatasets($this->object->getSurveyId());
1391
1392 if($this->has_datasets)
1393 {
1394 $link = $ilCtrl->getLinkTargetByClass(array("ilobjsurveygui", "ilsurveyparticipantsgui"), "maintenance");
1395 $link = "<a href=\"".$link."\">".$lng->txt("survey_has_datasets_warning_page_view_link")."</a>";
1396 ilUtil::sendInfo($lng->txt("survey_has_datasets_warning_page_view")." ".$link);
1397 }
1398
1399 $ilCtrl->setParameter($this, "pg", $this->current_page);
1400 $ilCtrl->setParameter($this, "pgov", "");
1401
1402 $this->renderToolbar($pages);
1403
1404 if($pages)
1405 {
1406 $ttpl = new ilTemplate("tpl.il_svy_svy_page_view.html", true, true, "Modules/Survey");
1407 $ttpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this));
1408 $lng->loadLanguageModule("form");
1409
1410 $read_only = ($this->has_datasets || !$rbacsystem->checkAccess("write", $this->ref_id));
1411
1412 $commands = $multi_commands = array();
1413
1414 if(!$read_only)
1415 {
1416 // clipboard is empty
1417 if(!$_SESSION["survey_page_view"][$this->ref_id]["clipboard"])
1418 {
1419 $multi_commands[] = array("cmd"=>"multiDelete", "text"=>$lng->txt("delete"));
1420 $multi_commands[] = array("cmd"=>"multiCut", "text"=>$lng->txt("cut"));
1421 $multi_commands[] = array("cmd"=>"multiCopy", "text"=>$lng->txt("copy"));
1422 $multi_commands[] = array("cmd"=>"selectAll", "text"=>$lng->txt("select_all"));
1423 }
1424 else
1425 {
1426 if(!$this->suppress_clipboard_msg)
1427 {
1428 ilUtil::sendInfo($lng->txt("survey_clipboard_notice"));
1429 }
1430 $multi_commands[] = array("cmd"=>"clearClipboard", "text"=>$lng->txt("survey_dnd_clear_clipboard"));
1431 }
1432
1433 // help - see ilPageObjectGUI::insertHelp()
1434 $lng->loadLanguageModule("content");
1435 $ttpl->setCurrentBlock("help_section");
1436 $ttpl->setVariable("TXT_ADD_EL", $lng->txt("cont_add_elements"));
1437 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
1438 $ttpl->setVariable("PLUS", ilGlyphGUI::get(ilGlyphGUI::ADD));
1439 $ttpl->setVariable("DRAG_ARROW", ilGlyphGUI::get(ilGlyphGUI::DRAG));
1440 $ttpl->setVariable("TXT_DRAG", $lng->txt("cont_drag_and_drop_elements"));
1441 $ttpl->setVariable("TXT_SEL", $lng->txt("cont_double_click_to_delete"));
1442 $ttpl->parseCurrentBlock();
1443
1444 $ttpl->setVariable("DND_INIT_JS", "initDragElements();");
1445
1446
1447 // tiny mce
1448
1449 include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1451
1452 include_once "./Services/RTE/classes/class.ilTinyMCE.php";
1453 $tiny = new ilTinyMCE();
1454 $ttpl->setVariable("WYSIWYG_BLOCKFORMATS", $tiny->_buildAdvancedBlockformatsFromHTMLTags($tags));
1455 $ttpl->setVariable("WYSIWYG_VALID_ELEMENTS", $tiny->_getValidElementsFromHTMLTags($tags));
1456
1457 $buttons_1 = $tiny->_buildAdvancedButtonsFromHTMLTags(1, $tags);
1458 $buttons_2 = $tiny->_buildAdvancedButtonsFromHTMLTags(2, $tags).','.
1459 $tiny->_buildAdvancedTableButtonsFromHTMLTags($tags).
1460 ($tiny->getStyleSelect() ? ',styleselect' : '');
1461 $buttons_3 = $tiny->_buildAdvancedButtonsFromHTMLTags(3, $tags);
1462 $ttpl->setVariable('WYSIWYG_BUTTONS_1', $tiny->_removeRedundantSeparators($buttons_1));
1463 $ttpl->setVariable('WYSIWYG_BUTTONS_2', $tiny->_removeRedundantSeparators($buttons_2));
1464 $ttpl->setVariable('WYSIWYG_BUTTONS_3', $tiny->_removeRedundantSeparators($buttons_3));
1465 }
1466
1467 // commands
1468 if (count($multi_commands) > 0)
1469 {
1470 foreach($multi_commands as $cmd)
1471 {
1472 $ttpl->setCurrentBlock("multi_cmd");
1473 $ttpl->setVariable("ORG_CMD_MULTI", "renderPage");
1474 $ttpl->setVariable("MULTI_CMD", $cmd["cmd"]);
1475 $ttpl->setVariable("MULTI_CMD_TXT", $cmd["text"]);
1476 $ttpl->parseCurrentBlock();
1477 }
1478
1479 $ttpl->setCurrentBlock("multi_cmds");
1480 $ttpl->setVariable("MCMD_ALT", $lng->txt("commands"));
1481 $ttpl->setVariable("MCMD_IMG", ilUtil::getImagePath("arrow_downright.svg"));
1482 $ttpl->parseCurrentBlock();
1483 }
1484
1485 // nodes
1486 $ttpl->setVariable("NODES", $this->getPageNodes($pages[$this->current_page-1],
1487 $this->has_previous_page, $this->has_next_page, $read_only));
1488
1489 $tpl->setContent($ttpl->get());
1490
1491 // add js to template
1492 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1494 $tpl->addJavascript("./Modules/Survey/js/SurveyPageView.js");
1495 $tpl->addJavascript("./Services/RTE/tiny_mce_3_5_11/tiny_mce_src.js");
1496 }
1497 }
static get($a_glyph, $a_text="")
Get glyph html.
& _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
getPageNodes(array $a_questions, $a_has_previous_page=false, $a_has_next_page=false, $a_readonly=false)
Get Form HTML.
renderToolbar($a_pages)
Render toolbar form.
Tiny MCE editor class.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static initDragDrop()
Init YUI Drag and Drop.

References $_SESSION, $cmd, $ilCtrl, $lng, $tpl, ilObjAdvancedEditing\_getUsedHTMLTags(), ilGlyphGUI\ADD, ilGlyphGUI\DRAG, ilGlyphGUI\get(), ilUtil\getImagePath(), getPageNodes(), ilYuiUtil\initDragDrop(), renderToolbar(), and ilUtil\sendInfo().

Referenced by addQuestionToolbar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderPageNode()

ilSurveyPageGUI::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.

Parameters
ilTemplate$a_tpl
string$a_type
int$a_id
string$a_content
array$a_menu
bool$a_spacer
string$a_subtitle
string$a_heading

Definition at line 1681 of file class.ilSurveyPageGUI.php.

1682 {
1683 global $ilCtrl, $lng;
1684
1685 $node_id = $a_type."_".$a_id;
1686
1687 if($a_spacer)
1688 {
1689 if($a_menu)
1690 {
1691 // drop area menu
1692 foreach($a_menu as $mcnt => $menu_item)
1693 {
1694 $ilCtrl->setParameter($this, "il_hform_node", $node_id);
1695 $ilCtrl->setParameter($this, "il_hform_subcmd", $menu_item["cmd"]);
1696 $url = $ilCtrl->getLinkTarget($this, "renderPage");
1697 $ilCtrl->setParameter($this, "il_hform_subcmd", "");
1698 $ilCtrl->setParameter($this, "il_hform_node", "");
1699
1700 $a_tpl->setCurrentBlock("menu_cmd");
1701 $a_tpl->setVariable("TXT_MENU_CMD", $menu_item["text"]);
1702 $a_tpl->setVariable("URL_MENU_CMD", $url);
1703 $a_tpl->parseCurrentBlock();
1704 }
1705 }
1706
1707 $a_tpl->setCurrentBlock("drop_area");
1708 include_once "Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php";
1709 $a_tpl->setVariable("ICON_ADD", ilGlyphGUI::get(ilGlyphGUI::ADD));
1710 $a_tpl->setVariable("DROP_ID", $a_id);
1711 $a_tpl->parseCurrentBlock();
1712 }
1713 else if($a_menu)
1714 {
1715 // question action menu
1716 foreach($a_menu as $mcnt => $menu_item)
1717 {
1718 $ilCtrl->setParameter($this, "il_hform_node", $node_id);
1719 $ilCtrl->setParameter($this, "il_hform_subcmd", $menu_item["cmd"]);
1720 $url = $ilCtrl->getLinkTarget($this, "renderPage");
1721 $ilCtrl->setParameter($this, "il_hform_subcmd", "");
1722 $ilCtrl->setParameter($this, "il_hform_node", "");
1723
1724 $a_tpl->setCurrentBlock("action_cmd");
1725 $a_tpl->setVariable("TXT_ACTION_CMD", $menu_item["text"]);
1726 $a_tpl->setVariable("URL_ACTION_CMD", $url);
1727 $a_tpl->parseCurrentBlock();
1728 }
1729 }
1730
1731 // add heading to content
1732 if($a_content !== null &&
1733 $a_type == "question" &&
1734 $a_heading)
1735 {
1736 $a_content = "<div class=\"questionheading\">".$a_heading."</div>".
1737 $a_content;
1738 }
1739
1740 if($a_menu)
1741 {
1742 $a_tpl->setVariable("TXT_NODE_CONTENT_ACTIONS", $a_content);
1743 }
1744 else
1745 {
1746 $a_tpl->setVariable("TXT_NODE_CONTENT_NO_ACTIONS", $a_content);
1747 }
1748
1749 if($a_content !== null)
1750 {
1751 $drag = "";
1752 $selectable = false;
1753 switch($a_type)
1754 {
1755 case "block":
1756 $caption = $lng->txt("questionblock");
1757 break;
1758
1759 case "question":
1760 $caption = $lng->txt("question").": ".$a_subtitle;
1761 $drag = "_drag";
1762 $selectable = true;
1763 break;
1764
1765 case "heading":
1766 $caption = $lng->txt("heading");
1767 break;
1768
1769 default:
1770 return;
1771 }
1772
1773 if($a_status)
1774 {
1775 $caption .= " (".$a_status.")";
1776 }
1777
1778 $a_tpl->setCurrentBlock("list_item");
1779 $a_tpl->setVariable("NODE_ID", $node_id);
1780 $a_tpl->setVariable("NODE_DRAG", $drag);
1781 $a_tpl->setVariable("TXT_NODE_TYPE", $caption);
1782 if($selectable)
1783 {
1784 $a_tpl->setVariable("SELECTABLE", " selectable");
1785 }
1786 $a_tpl->parseCurrentBlock();
1787 }
1788
1789 $a_tpl->touchBlock("element");
1790 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:626
touchBlock($block)
overwrites ITX::touchBlock.
parseCurrentBlock($part="DEFAULT")
Überladene Funktion, die auf den aktuelle Block vorher noch ein replace ausführt @access public.
setCurrentBlock($part="DEFAULT")
Überladene Funktion, die sich hier lokal noch den aktuellen Block merkt.
$url
Definition: shib_logout.php:72

References $ilCtrl, $lng, $url, ilGlyphGUI\ADD, ilGlyphGUI\get(), ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), and ilTemplate\touchBlock().

Referenced by getPageNodes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderToolbar()

ilSurveyPageGUI::renderToolbar (   $a_pages)
protected

Render toolbar form.

Parameters
array$a_pages

Definition at line 1245 of file class.ilSurveyPageGUI.php.

1246 {
1247 global $ilToolbar, $ilCtrl, $lng, $ilUser;
1248
1249 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
1250
1251 if(!$this->has_datasets)
1252 {
1253 $button = ilLinkButton::getInstance();
1254 $button->setCaption("survey_add_new_question");
1255 $button->setUrl($ilCtrl->getLinkTarget($this, "addQuestionToolbarForm"));
1256 $ilToolbar->addStickyItem($button);
1257
1258 if($this->object->isPoolActive())
1259 {
1260 $ilToolbar->addSeparator();
1261
1262 $last_on_page = 0;
1263 if($a_pages &&
1264 is_array($a_pages[$this->current_page-1]))
1265 {
1266 $last_on_page = $a_pages[$this->current_page-1];
1267 $last_on_page = array_pop($last_on_page);
1268 $last_on_page = $last_on_page["question_id"];
1269 }
1270
1271 $ilCtrl->setParameter($this->editor_gui, "pgov", $this->current_page);
1272 $ilCtrl->setParameter($this->editor_gui, "pgov_pos", $last_on_page."c");
1273
1274 $cmd = ($ilUser->getPref('svy_insert_type') == 1 ||
1275 strlen($ilUser->getPref('svy_insert_type')) == 0)
1276 ? 'browseForQuestions'
1277 : 'browseForQuestionblocks';
1278
1279 $button = ilLinkButton::getInstance();
1280 $button->setCaption("browse_for_questions");
1281 $button->setUrl($ilCtrl->getLinkTarget($this->editor_gui, $cmd));
1282 $ilToolbar->addStickyItem($button);
1283
1284 $ilCtrl->setParameter($this->editor_gui, "pgov", "");
1285 $ilCtrl->setParameter($this->editor_gui, "pgov_pos", "");
1286 }
1287
1288 if($a_pages)
1289 {
1290 $ilToolbar->addSeparator();
1291 }
1292 }
1293
1294 // parse data for pages drop-down
1295 if($a_pages)
1296 {
1297 // previous/next
1298
1299 $ilCtrl->setParameter($this, "pg", $this->current_page-1);
1300 $button = ilLinkButton::getInstance();
1301 $button->setCaption("survey_prev_question");
1302 $button->setUrl($ilCtrl->getLinkTarget($this, "renderPage"));
1303 $button->setDisabled(!$this->has_previous_page);
1304 $ilToolbar->addStickyItem($button);
1305
1306 $ilCtrl->setParameter($this, "pg", $this->current_page+1);
1307 $button = ilLinkButton::getInstance();
1308 $button->setCaption("survey_next_question");
1309 $button->setUrl($ilCtrl->getLinkTarget($this, "renderPage"));
1310 $button->setDisabled(!$this->has_next_page);
1311 $ilToolbar->addStickyItem($button);
1312
1313 $ilCtrl->setParameter($this, "pg", $this->current_page); // #14615
1314
1315 foreach($a_pages as $idx => $questions)
1316 {
1317 $page = $questions;
1318 $page = array_shift($page);
1319 if($page["questionblock_id"])
1320 {
1321 $pages_drop[$idx+1] = $page["questionblock_title"];
1322
1323 if(sizeof($questions) > 1)
1324 {
1325 foreach($questions as $question)
1326 {
1327 $pages_drop[($idx+1)."__".$question["question_id"]] = "- ".$question["title"];
1328 }
1329 }
1330 }
1331 else
1332 {
1333 $pages_drop[$idx+1] = strip_tags($page["title"]);
1334 }
1335 }
1336 }
1337
1338 // jump to page
1339 if(sizeof($pages_drop) > 1)
1340 {
1341 $ilToolbar->addSeparator();
1342
1343 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1344
1345 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1346 $si = new ilSelectInputGUI($lng->txt("survey_jump_to"), "jump");
1347 $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
1348 $si->setOptions($pages_drop);
1349 $si->setValue($this->current_page);
1350 $ilToolbar->addInputItem($si, true);
1351
1352 // we need this to have to right cmd
1353 $cmd = new ilHiddenInputGUI("cmd[renderPage]");
1354 $cmd->setValue("1");
1355 $ilToolbar->addInputItem($cmd);
1356
1357 if(!$this->has_datasets)
1358 {
1359 $ilToolbar->addSeparator();
1360
1361 $ilCtrl->setParameter($this, "csum", md5(print_r($a_pages[$this->current_page-1], true)));
1362 $url = $ilCtrl->getLinkTarget($this, "deleteBlock");
1363 $ilCtrl->setParameter($this, "csum", "");
1364
1365 $button = ilLinkButton::getInstance();
1366 $button->setCaption("survey_delete_page");
1367 $button->setUrl($url);
1368 $ilToolbar->addButtonInstance($button);
1369
1370 $ilToolbar->addSeparator();
1371
1372 $button = ilLinkButton::getInstance();
1373 $button->setCaption("survey_move_page");
1374 $button->setUrl($ilCtrl->getLinkTarget($this, "movePageForm"));
1375 $ilToolbar->addButtonInstance($button);
1376 }
1377 }
1378 }
static getInstance()
Factory.

References $cmd, $ilCtrl, $ilUser, $lng, $si, $url, and ilLinkButton\getInstance().

Referenced by renderPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ splitPage()

ilSurveyPageGUI::splitPage (   $a_id)
protected

Split current page in 2 pages.

Parameters
int$a_id

Definition at line 872 of file class.ilSurveyPageGUI.php.

873 {
874 $pages = $this->object->getSurveyPages();
875 $source = $pages[$this->current_page-1];
876
877 $block_questions = array();
878 $add = $block_id = false;
879 foreach($source as $idx => $item)
880 {
881 if($item["question_id"] == $a_id)
882 {
883 $block_id = $item["questionblock_id"];
884 $add = $idx;
885 }
886 if($add)
887 {
888 $block_questions[] = $item["question_id"];
889 }
890 }
891
892 // just 1 question left: block is obsolete
893 if($add == 1)
894 {
895 $this->object->unfoldQuestionblocks(array($block_id));
896 }
897 // remove questions from block
898 else
899 {
900 foreach($block_questions as $qid)
901 {
902 $this->object->removeQuestionFromBlock($qid, $block_id);
903 }
904 }
905
906 // more than 1 moved?
907 if(sizeof($block_questions) > 1)
908 {
909 // create new block and move target questions
910 $this->object->createQuestionblock($this->getAutoBlockTitle(), true, false,
911 $block_questions);
912 }
913
914 $this->current_page++;
915 }

References getAutoBlockTitle().

+ Here is the call graph for this function:

Field Documentation

◆ $current_page

ilSurveyPageGUI::$current_page
protected

Definition at line 20 of file class.ilSurveyPageGUI.php.

Referenced by determineCurrentPage(), executeCommand(), and moveNext().

◆ $editor_gui

ilSurveyPageGUI::$editor_gui
protected

Definition at line 19 of file class.ilSurveyPageGUI.php.

◆ $has_datasets

ilSurveyPageGUI::$has_datasets
protected

Definition at line 23 of file class.ilSurveyPageGUI.php.

◆ $has_next_page

ilSurveyPageGUI::$has_next_page
protected

Definition at line 22 of file class.ilSurveyPageGUI.php.

◆ $has_previous_page

ilSurveyPageGUI::$has_previous_page
protected

Definition at line 21 of file class.ilSurveyPageGUI.php.

◆ $lng

◆ $object

ilSurveyPageGUI::$object
protected

Definition at line 18 of file class.ilSurveyPageGUI.php.

◆ $ref_id

ilSurveyPageGUI::$ref_id
protected

◆ $use_pool

ilSurveyPageGUI::$use_pool
protected

Definition at line 24 of file class.ilSurveyPageGUI.php.


The documentation for this class was generated from the following file: