ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
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

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.

References ilObject\getRefId().

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 public
+ 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 828 of file class.ilSurveyPageGUI.php.

References callEditor().

829  {
830  $this->callEditor("addHeadingObject", "q_id", $a_id);
831  return true;
832  }
callEditor($a_cmd, $a_param, $a_value)
+ Here is the call graph for this function:

◆ addPoolQuestion()

ilSurveyPageGUI::addPoolQuestion (   $pos,
  $node 
)

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

References $cmd, $ilCtrl, and $ilUser.

1796  {
1797  global $ilCtrl, $ilUser;
1798 
1799  if($node == "page_end")
1800  {
1801  $pos = $this->object->getSurveyPages();
1802  $pos = array_pop($pos[$this->current_page-1]);
1803  $pos = $pos["question_id"]."a";
1804  }
1805  else
1806  {
1807  $pos = $pos."b";
1808  }
1809 
1810  $ilCtrl->setParameter($this->editor_gui, "pgov", $this->current_page);
1811  $ilCtrl->setParameter($this->editor_gui, "pgov_pos", $pos);
1812 
1813  $cmd = ($ilUser->getPref('svy_insert_type') == 1 || strlen($ilUser->getPref('svy_insert_type')) == 0) ? 'browseForQuestions' : 'browseForQuestionblocks';
1814  $ilCtrl->redirect($this->editor_gui, $cmd);
1815  }
$cmd
Definition: sahs_server.php:35
global $ilCtrl
Definition: ilias.php:18
global $ilUser
Definition: imgupload.php:15

◆ 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.

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

Referenced by addQuestionToolbar(), and executeCommand().

340  {
341  global $ilCtrl;
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  $this->editor_gui->createQuestionObject();
392  }
393  else
394  {
395  $this->editor_gui->executeCreateQuestionObject();
396  }
397  return true;
398  }
399  else
400  {
401  // create question and redirect to question form
402 
403  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
404  $q_gui = SurveyQuestionGUI::_getQuestionGUI($type_trans);
405  $q_gui->object->setObjId($this->object->getId());
406  $q_gui->object->createNewQuestion();
407  $q_gui_class = get_class($q_gui);
408 
409  // #12531
410  $ilCtrl->setParameterByClass($q_gui_class, "pgov", $this->current_page);
411  $ilCtrl->setParameterByClass($q_gui_class, "pgov_pos",$id);
412  $ilCtrl->setParameterByClass($q_gui_class, "ref_id", $this->ref_id);
413  $ilCtrl->setParameterByClass($q_gui_class, "new_for_survey", $this->ref_id);
414  $ilCtrl->setParameterByClass($q_gui_class, "q_id", $q_gui->object->getId());
415  $ilCtrl->setParameterByClass($q_gui_class, "sel_question_types", $q_gui->getQuestionType());
416  $ilCtrl->redirectByClass($q_gui_class, "editQuestion");
417  }
418  }
$_POST['username']
Definition: cron.php:12
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
static & _getQuestionGUI($questiontype, $question_id=-1)
Creates a question gui representation.
& _getQuestiontypes()
Creates a list of all available question types.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
+ 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 1122 of file class.ilSurveyPageGUI.php.

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

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

◆ addQuestionToolbarForm()

ilSurveyPageGUI::addQuestionToolbarForm ( )
protected

Add question to survey form (used in toolbar)

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

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

Referenced by addQuestionToolbar().

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

Parameters
int$a_new_id
bool$a_duplicate

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

References $ilDB, and $result.

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

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
+ Here is the caller graph for this function:

◆ callEditor()

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

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

References $_REQUEST.

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

857  {
858  global $ilTabs;
859 
860  $ilTabs->clearSubTabs();
861  $_REQUEST[$a_param] = $a_value;
862 
863  call_user_func(array($this->editor_gui, $a_cmd));
864  }
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
+ Here is the caller graph for this function:

◆ clearClipboard()

ilSurveyPageGUI::clearClipboard ( )
protected

Empty clipboard.

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

References $_SESSION, and $ref_id.

Referenced by paste().

496  {
497  $_SESSION["survey_page_view"][$this->ref_id]["clipboard"] = null;
498  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
+ Here is the caller graph for this function:

◆ confirmRemoveQuestions()

ilSurveyPageGUI::confirmRemoveQuestions ( )
protected

Remove question(s) from survey.

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

References $_POST, and $ilCtrl.

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

◆ copyQuestion()

ilSurveyPageGUI::copyQuestion (   $a_id)
protected

Add question to be copied to clipboard.

Parameters
int$a_idquestion id

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

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

444  {
445  global $lng;
446 
447  ilUtil::sendSuccess($lng->txt("survey_questions_to_clipboard_copy"));
448  $this->suppress_clipboard_msg = true;
449 
450  $_SESSION["survey_page_view"][$this->ref_id]["clipboard"] = array(
451  "source" => $this->current_page,
452  "nodes" => array($a_id),
453  "mode" => "copy");
454  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
+ 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 425 of file class.ilSurveyPageGUI.php.

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

426  {
427  global $lng;
428 
429  ilUtil::sendSuccess($lng->txt("survey_questions_to_clipboard_cut"));
430  $this->suppress_clipboard_msg = true;
431 
432  $_SESSION["survey_page_view"][$this->ref_id]["clipboard"] = array(
433  "source" => $this->current_page,
434  "nodes" => array($a_id),
435  "mode" => "cut");
436  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
+ Here is the call graph for this function:

◆ deleteBlock()

ilSurveyPageGUI::deleteBlock ( )
protected

Confirm removing question block.

Parameters
int$a_id

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

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

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

◆ deleteHeading()

ilSurveyPageGUI::deleteHeading (   $a_id)
protected

Delete question heading.

Parameters
int$a_id

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

References callEditor().

851  {
852  $this->callEditor("removeHeadingObject", "q_id", $a_id);
853  return true;
854  }
callEditor($a_cmd, $a_param, $a_value)
+ 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 727 of file class.ilSurveyPageGUI.php.

References $ilCtrl.

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

◆ determineCurrentPage()

ilSurveyPageGUI::determineCurrentPage ( )

determine current page

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

References $_REQUEST, and $current_page.

Referenced by executeCommand().

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  }
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
+ Here is the caller graph for this function:

◆ dnd()

ilSurveyPageGUI::dnd ( )
protected

Move questions in page.

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

References $_REQUEST, and $target_id.

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

◆ editBlock()

ilSurveyPageGUI::editBlock (   $a_id)
protected

Edit question block.

Parameters
int$a_id

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

References callEditor().

818  {
819  $this->callEditor("editQuestionblockObject", "bl_id", $a_id);
820  return true;
821  }
callEditor($a_cmd, $a_param, $a_value)
+ Here is the call graph for this function:

◆ editHeading()

ilSurveyPageGUI::editHeading (   $a_id)
protected

Edit question heading.

Parameters
int$a_id

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

References callEditor().

840  {
841  $this->callEditor("editHeadingObject", "q_id", $a_id);
842  return true;
843  }
callEditor($a_cmd, $a_param, $a_value)
+ Here is the call graph for this function:

◆ editQuestion()

ilSurveyPageGUI::editQuestion (   $a_id)
protected

Edit question.

Parameters
int$a_id

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

References $data, and $ilCtrl.

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

◆ executeCommand()

ilSurveyPageGUI::executeCommand ( )

Routing.

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

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

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  }
$cmd
Definition: sahs_server.php:35
addQuestion($a_type, $a_use_pool, $a_pos, $a_special_position)
Call add question to survey form.
global $ilCtrl
Definition: ilias.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
insertNewQuestion($a_new_id)
Add new question to survey.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
determineCurrentPage()
determine current page
+ Here is the call graph for this function:

◆ getAutoBlockTitle()

ilSurveyPageGUI::getAutoBlockTitle ( )

Get name for newly created blocks.

Returns
string

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

References $lng.

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

1789  {
1790  global $lng;
1791 
1792  return $lng->txt("survey_auto_block_title");
1793  }
+ 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 1499 of file class.ilSurveyPageGUI.php.

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

Referenced by renderPage().

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

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

Referenced by executeCommand().

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  }
getAutoBlockTitle()
Get name for newly created blocks.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
appendNewQuestionToSurvey($a_new_id, $a_duplicate=true, $a_force_duplicate=false)
Add new question to survey (database part)
global $ilDB
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
_isComplete($question_id)
Checks whether the question is complete or not.
+ 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.

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

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  }
getAutoBlockTitle()
Get name for newly created blocks.
appendNewQuestionToSurvey($a_new_id, $a_duplicate=true, $a_force_duplicate=false)
Add new question to survey (database part)
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
+ 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 921 of file class.ilSurveyPageGUI.php.

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

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

◆ movePage()

ilSurveyPageGUI::movePage ( )
protected

Move current page to new position.

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

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

1197  {
1198  global $lng, $ilCtrl;
1199 
1200  // current_page is already set to new position
1201  $target_page = $this->current_page-1;
1202  $source_page = $_REQUEST["old_pos"]-1;
1203 
1204  $pages = $this->object->getSurveyPages();
1205  foreach($pages[$source_page] as $question)
1206  {
1207  $questions[] = $question["question_id"];
1208  }
1209 
1210  // move to first position
1211  $position = 0;
1212  if($_REQUEST["pgov"] != "fst")
1213  {
1214  $position = 1;
1215  }
1216 
1217  $target = $pages[$target_page];
1218  $target = array_shift($target);
1219  $this->object->moveQuestions($questions, $target["question_id"], $position);
1220 
1221  if($target_page < $source_page && $position)
1222  {
1223  $this->current_page++;
1224  }
1225 
1226  ilUtil::sendSuccess($lng->txt("survey_page_moved"), true);
1227  $ilCtrl->setParameter($this, "pgov", $this->current_page);
1228  $ilCtrl->redirect($this, "renderPage");
1229  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilCtrl
Definition: ilias.php:18
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
+ Here is the call graph for this function:

◆ movePageForm()

ilSurveyPageGUI::movePageForm ( )
protected

Move current page.

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

References $ilCtrl, $lng, $tpl, and ilSelectInputGUI\setOptions().

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

◆ movePrevious()

ilSurveyPageGUI::movePrevious (   $a_id)
protected

Move question to previous page.

Parameters
int$a_id

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

References $target_id, and getAutoBlockTitle().

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

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

480  {
481  global $lng;
482 
483  ilUtil::sendSuccess($lng->txt("survey_questions_to_clipboard_copy"));
484  $this->suppress_clipboard_msg = true;
485 
486  $_SESSION["survey_page_view"][$this->ref_id]["clipboard"] = array(
487  "source" => $this->current_page,
488  "nodes" => $a_id,
489  "mode" => "copy");
490  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
+ 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 461 of file class.ilSurveyPageGUI.php.

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

462  {
463  global $lng;
464 
465  ilUtil::sendSuccess($lng->txt("survey_questions_to_clipboard_cut"));
466  $this->suppress_clipboard_msg = true;
467 
468  $_SESSION["survey_page_view"][$this->ref_id]["clipboard"] = array(
469  "source" => $this->current_page,
470  "nodes" => $a_id,
471  "mode" => "cut");
472  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
+ 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 505 of file class.ilSurveyPageGUI.php.

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

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

◆ renderPage()

ilSurveyPageGUI::renderPage ( )
protected

render questions per page

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

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().

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

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

Referenced by getPageNodes().

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

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

Referenced by renderPage().

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

References getAutoBlockTitle().

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