ILIAS  release_4-4 Revision
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...
 
 editJS ()
 Edit content (ajax, js) More...
 
 saveJS ()
 Save content (ajax, js) 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 1816 of file class.ilSurveyPageGUI.php.

References $cmd, $ilCtrl, and $ilUser.

1817  {
1818  global $ilCtrl, $ilUser;
1819 
1820  if($node == "page_end")
1821  {
1822  $pos = $this->object->getSurveyPages();
1823  $pos = array_pop($pos[$this->current_page-1]);
1824  $pos = $pos["question_id"]."a";
1825  }
1826  else
1827  {
1828  $pos = $pos."b";
1829  }
1830 
1831  $ilCtrl->setParameter($this->editor_gui, "pgov", $this->current_page);
1832  $ilCtrl->setParameter($this->editor_gui, "pgov_pos", $pos);
1833 
1834  $cmd = ($ilUser->getPref('svy_insert_type') == 1 || strlen($ilUser->getPref('svy_insert_type')) == 0) ? 'browseForQuestions' : 'browseForQuestionblocks';
1835  $ilCtrl->redirect($this->editor_gui, $cmd);
1836  }
$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 $ilCtrl
Definition: ilias.php:18
This class represents a hidden form property in a property form.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
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 $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
+ 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"] != "page_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:

◆ editJS()

ilSurveyPageGUI::editJS ( )

Edit content (ajax, js)

Returns
string

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

References $_POST, exit, and ilObjSurvey\getTextblock().

1768  {
1769  $node = $_POST["ajaxform_node"];
1770  if($node)
1771  {
1772  $node = explode("_", $node);
1773  if($node[0] == "heading")
1774  {
1775  $id = (int)$node[1];
1776 
1777  include_once "Modules/Survey/classes/class.ilObjSurvey.php";
1778  echo ilObjSurvey::getTextblock($id);
1779  exit();
1780  }
1781  }
1782  }
exit
Definition: login.php:54
$_POST['username']
Definition: cron.php:12
getTextblock($question_id)
+ 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
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data

◆ 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 1809 of file class.ilSurveyPageGUI.php.

References $lng.

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

1810  {
1811  global $lng;
1812 
1813  return $lng->txt("survey_auto_block_title");
1814  }
+ 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 1504 of file class.ilSurveyPageGUI.php.

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

Referenced by renderPage().

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

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

Referenced by addQuestionToolbar().

1345  {
1346  global $ilCtrl, $lng, $tpl, $rbacsystem;
1347 
1348  $pages = $this->object->getSurveyPages();
1349  $this->has_next_page = ($this->current_page < sizeof($pages));
1350  $this->has_previous_page = ($this->current_page > 1);
1351  $this->has_datasets = $this->object->_hasDatasets($this->object->getSurveyId());
1352 
1353  if($this->has_datasets)
1354  {
1355  $link = $ilCtrl->getLinkTargetByClass(array("ilobjsurveygui", "ilsurveyparticipantsgui"), "maintenance");
1356  $link = "<a href=\"".$link."\">".$lng->txt("survey_has_datasets_warning_page_view_link")."</a>";
1357  ilUtil::sendInfo($lng->txt("survey_has_datasets_warning_page_view")." ".$link);
1358  }
1359 
1360  $ilCtrl->setParameter($this, "pg", $this->current_page);
1361  $ilCtrl->setParameter($this, "pgov", "");
1362 
1363  $this->renderToolbar($pages);
1364 
1365  if($pages)
1366  {
1367  $ttpl = new ilTemplate("tpl.il_svy_svy_page_view.html", true, true, "Modules/Survey");
1368  $ttpl->setVariable("FORM_ACTION", $ilCtrl->getFormAction($this));
1369  $ttpl->setVariable("WYSIWYG_ACTION", $ilCtrl->getFormAction($this));
1370  $lng->loadLanguageModule("form");
1371 
1372  $read_only = ($this->has_datasets || !$rbacsystem->checkAccess("write", $this->ref_id));
1373 
1374  $commands = $multi_commands = array();
1375 
1376  if(!$read_only)
1377  {
1378  // clipboard is empty
1379  if(!$_SESSION["survey_page_view"][$this->ref_id]["clipboard"])
1380  {
1381  $multi_commands[] = array("cmd"=>"multiDelete", "text"=>$lng->txt("delete"));
1382  $multi_commands[] = array("cmd"=>"multiCut", "text"=>$lng->txt("cut"));
1383  $multi_commands[] = array("cmd"=>"multiCopy", "text"=>$lng->txt("copy"));
1384  $multi_commands[] = array("cmd"=>"selectAll", "text"=>$lng->txt("select_all"));
1385  }
1386  else
1387  {
1388  if(!$this->suppress_clipboard_msg)
1389  {
1390  ilUtil::sendInfo($lng->txt("survey_clipboard_notice"));
1391  }
1392  $multi_commands[] = array("cmd"=>"clearClipboard", "text"=>$lng->txt("survey_dnd_clear_clipboard"));
1393  }
1394 
1395  // help
1396  $ttpl->setCurrentBlock("help_img");
1397  $ttpl->setVariable("IMG_HELP", ilUtil::getImagePath("streaked_area.png"));
1398  $ttpl->parseCurrentBlock();
1399  $ttpl->setCurrentBlock("help_section");
1400  $ttpl->setVariable("TXT_HELP", $lng->txt("form_hierarchy_add_elements"));
1401  $ttpl->parseCurrentBlock();
1402 
1403  $ttpl->setCurrentBlock("help_img");
1404  $ttpl->setVariable("IMG_HELP", ilUtil::getImagePath("icon_cont_el_s.png"));
1405  $ttpl->parseCurrentBlock();
1406  $ttpl->setVariable("IMG_HELP", ilUtil::getImagePath("drop_streaked_area.png"));
1407  $ttpl->parseCurrentBlock();
1408  $ttpl->setCurrentBlock("help_section");
1409  $ttpl->setVariable("TXT_HELP", $lng->txt("form_hierarchy_drag_drop_help"));
1410  $ttpl->parseCurrentBlock();
1411 
1412  $ttpl->setCurrentBlock("help_img");
1413  $ttpl->setVariable("IMG_HELP", ilUtil::getImagePath("icon_cont_el_s.png"));
1414  $ttpl->parseCurrentBlock();
1415  $ttpl->setCurrentBlock("help_section");
1416  $ttpl->setVariable("TXT_HELP", $lng->txt("survey_dnd_double_click_to_delete"));
1417  $ttpl->parseCurrentBlock();
1418 
1419  $ttpl->setVariable("DND_INIT_JS", "initDragElements();");
1420 
1421 
1422  // tiny mce
1423 
1424  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1425  $tags = ilObjAdvancedEditing::_getUsedHTMLTags("survey");
1426 
1427  include_once "./Services/RTE/classes/class.ilTinyMCE.php";
1428  $tiny = new ilTinyMCE();
1429  $ttpl->setVariable("WYSIWYG_BLOCKFORMATS", $tiny->_buildAdvancedBlockformatsFromHTMLTags($tags));
1430  $ttpl->setVariable("WYSIWYG_VALID_ELEMENTS", $tiny->_getValidElementsFromHTMLTags($tags));
1431 
1432  $buttons_1 = $tiny->_buildAdvancedButtonsFromHTMLTags(1, $tags);
1433  $buttons_2 = $tiny->_buildAdvancedButtonsFromHTMLTags(2, $tags).','.
1434  $tiny->_buildAdvancedTableButtonsFromHTMLTags($tags).
1435  ($tiny->getStyleSelect() ? ',styleselect' : '');
1436  $buttons_3 = $tiny->_buildAdvancedButtonsFromHTMLTags(3, $tags);
1437  $ttpl->setVariable('WYSIWYG_BUTTONS_1', $tiny->_removeRedundantSeparators($buttons_1));
1438  $ttpl->setVariable('WYSIWYG_BUTTONS_2', $tiny->_removeRedundantSeparators($buttons_2));
1439  $ttpl->setVariable('WYSIWYG_BUTTONS_3', $tiny->_removeRedundantSeparators($buttons_3));
1440  }
1441 
1442  // commands
1443  if (count($multi_commands) > 0 || count($commands) > 0)
1444  {
1445  $single = false;
1446  foreach($commands as $cmd)
1447  {
1448  $ttpl->setCurrentBlock("cmd");
1449  $ttpl->setVariable("ORG_CMD", "renderPage");
1450  $ttpl->setVariable("CMD", $cmd["cmd"]);
1451  $ttpl->setVariable("CMD_TXT", $cmd["text"]);
1452  $ttpl->parseCurrentBlock();
1453  $single = true;
1454  }
1455 
1456  $multi = false;
1457  foreach($multi_commands as $cmd)
1458  {
1459  $ttpl->setCurrentBlock("multi_cmd");
1460  $ttpl->setVariable("ORG_CMD_MULTI", "renderPage");
1461  $ttpl->setVariable("MULTI_CMD", $cmd["cmd"]);
1462  $ttpl->setVariable("MULTI_CMD_TXT", $cmd["text"]);
1463  $ttpl->parseCurrentBlock();
1464  $multi = true;
1465  }
1466  if ($multi)
1467  {
1468  $ttpl->setCurrentBlock("multi_cmds");
1469  $ttpl->setVariable("MCMD_ALT", $lng->txt("commands"));
1470  $ttpl->setVariable("MCMD_IMG", ilUtil::getImagePath("arrow_downright.png"));
1471  $ttpl->parseCurrentBlock();
1472  }
1473 
1474  if ($single || $multi)
1475  {
1476  $ttpl->setCurrentBlock("commands");
1477  $ttpl->parseCurrentBlock();
1478  }
1479  }
1480 
1481  // nodes
1482  $ttpl->setVariable("NODES", $this->getPageNodes($pages[$this->current_page-1],
1483  $this->has_previous_page, $this->has_next_page, $read_only));
1484 
1485  $tpl->setContent($ttpl->get());
1486 
1487  // add js to template
1488  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1490  $tpl->addJavascript("./Modules/Survey/js/SurveyPageView.js");
1491  $tpl->addJavascript("./Services/RTE/tiny_mce_3_5_11/tiny_mce_src.js");
1492  }
1493  }
< 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
getPageNodes(array $a_questions, $a_has_previous_page=false, $a_has_next_page=false, $a_readonly=false)
Get Form HTML.
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
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
& _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 1677 of file class.ilSurveyPageGUI.php.

References $ilCtrl, $lng, ilUtil\getImagePath(), ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

Referenced by getPageNodes().

1678  {
1679  global $ilCtrl, $lng;
1680 
1681  $node_id = $a_type."_".$a_id;
1682 
1683  if($a_content !== null)
1684  {
1685  $drag = "";
1686  $double = false;
1687  switch($a_type)
1688  {
1689  case "block":
1690  $caption = $lng->txt("questionblock");
1691  break;
1692 
1693  case "question":
1694  if($a_heading)
1695  {
1696  $a_content = "<div class=\"questionheading\">".$a_heading."</div>".
1697  $a_content;
1698  }
1699  $caption = $lng->txt("question").": ".$a_subtitle;
1700  $drag = "_drag";
1701  $double = true;
1702  break;
1703 
1704  case "heading":
1705  $caption = $lng->txt("heading");
1706  break;
1707 
1708  default:
1709  return;
1710  }
1711 
1712  if($a_status)
1713  {
1714  $caption .= " (".$a_status.")";
1715  }
1716 
1717  $a_tpl->setCurrentBlock("list_item");
1718  $a_tpl->setVariable("NODE_ID", $node_id);
1719  $a_tpl->setVariable("NODE_DRAG", $drag);
1720  $a_tpl->setVariable("TXT_NODE_TYPE", $caption);
1721  $a_tpl->setVariable("TXT_NODE_CONTENT", $a_content);
1722  if($double)
1723  {
1724  $a_tpl->setVariable("VAL_DBLCLICK", " onDblClick=\"doMouseDblClick(event,this.id);\"");
1725  }
1726  $a_tpl->parseCurrentBlock();
1727  }
1728 
1729  // drop area menu
1730  if($a_menu)
1731  {
1732  foreach($a_menu as $mcnt => $menu_item)
1733  {
1734  $a_tpl->setCurrentBlock("menu_cmd");
1735  $a_tpl->setVariable("TXT_MENU_CMD", $menu_item["text"]);
1736  $a_tpl->setVariable("MENU_CMD", "renderPage");
1737 
1738  $a_tpl->setVariable("FC", $menu_item["cmd"]);
1739  $a_tpl->setVariable("MCNT", $mcnt);
1740 
1741  $a_tpl->setVariable("CMD_NODE", $node_id);
1742  $a_tpl->parseCurrentBlock();
1743  }
1744 
1745  $a_tpl->setCurrentBlock("drop_area_menu");
1746  $a_tpl->setVariable("MNODE_ID", $node_id);
1747  $a_tpl->parseCurrentBlock();
1748  }
1749 
1750  if($a_spacer)
1751  {
1752  $a_tpl->setCurrentBlock("drop_area");
1753  $a_tpl->setVariable("DNODE_ID", $node_id);
1754  $a_tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("spacer.png"));
1755  $a_tpl->parseCurrentBlock();
1756  }
1757 
1758  $a_tpl->setCurrentBlock("element");
1759  $a_tpl->parseCurrentBlock();
1760  }
global $ilCtrl
Definition: ilias.php:18
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:626
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
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, $has_next_page, $has_previous_page, $ilCtrl, $ilUser, $lng, and $si.

Referenced by renderPage().

1237  {
1238  global $ilToolbar, $ilCtrl, $lng, $ilUser;
1239 
1240  if(!$this->has_datasets)
1241  {
1242  $ilToolbar->addButton($lng->txt("survey_add_new_question"), $ilCtrl->getLinkTarget($this, "addQuestionToolbarForm"));
1243 
1244  if($this->object->isPoolActive())
1245  {
1246  $ilToolbar->addSeparator();
1247 
1248  $last_on_page = 0;
1249  if($a_pages &&
1250  is_array($a_pages[$this->current_page-1]))
1251  {
1252  $last_on_page = $a_pages[$this->current_page-1];
1253  $last_on_page = array_pop($last_on_page);
1254  $last_on_page = $last_on_page["question_id"];
1255  }
1256 
1257  $ilCtrl->setParameter($this->editor_gui, "pgov", $this->current_page);
1258  $ilCtrl->setParameter($this->editor_gui, "pgov_pos", $last_on_page."c");
1259 
1260  $cmd = ($ilUser->getPref('svy_insert_type') == 1 || strlen($ilUser->getPref('svy_insert_type')) == 0) ? 'browseForQuestions' : 'browseForQuestionblocks';
1261  $ilToolbar->addButton($lng->txt("browse_for_questions"),
1262  $ilCtrl->getLinkTarget($this->editor_gui, $cmd));
1263 
1264  $ilCtrl->setParameter($this->editor_gui, "pgov", "");
1265  $ilCtrl->setParameter($this->editor_gui, "pgov_pos", "");
1266  }
1267 
1268  if($a_pages)
1269  {
1270  $ilToolbar->addSeparator();
1271  }
1272  }
1273 
1274  // parse data for pages drop-down
1275  if($a_pages)
1276  {
1277  // previous/next
1278  $ilCtrl->setParameter($this, "pg", $this->current_page-1);
1279  $ilToolbar->addLink($lng->txt("survey_prev_question"),
1280  $ilCtrl->getLinkTarget($this, "renderPage"), !$this->has_previous_page);
1281  $ilCtrl->setParameter($this, "pg", $this->current_page+1);
1282  $ilToolbar->addLink($lng->txt("survey_next_question"),
1283  $ilCtrl->getLinkTarget($this, "renderPage"), !$this->has_next_page);
1284  $ilCtrl->setParameter($this, "pg", $this->current_page);
1285 
1286  foreach($a_pages as $idx => $questions)
1287  {
1288  $page = $questions;
1289  $page = array_shift($page);
1290  if($page["questionblock_id"])
1291  {
1292  $pages_drop[$idx+1] = $page["questionblock_title"];
1293 
1294  if(sizeof($questions) > 1)
1295  {
1296  foreach($questions as $question)
1297  {
1298  $pages_drop[($idx+1)."__".$question["question_id"]] = "- ".$question["title"];
1299  }
1300  }
1301  }
1302  else
1303  {
1304  $pages_drop[$idx+1] = strip_tags($page["title"]);
1305  }
1306  }
1307  }
1308 
1309  // jump to page
1310  if(sizeof($pages_drop) > 1)
1311  {
1312  $ilToolbar->addSeparator();
1313 
1314  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1315 
1316  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1317  $si = new ilSelectInputGUI($lng->txt("survey_jump_to"), "jump");
1318  $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
1319  $si->setOptions($pages_drop);
1320  $si->setValue($this->current_page);
1321  $ilToolbar->addInputItem($si, true);
1322 
1323  // we need this to have to right cmd
1324  $cmd = new ilHiddenInputGUI("cmd[renderPage]");
1325  $cmd->setValue("1");
1326  $ilToolbar->addInputItem($cmd);
1327 
1328  if(!$this->has_datasets)
1329  {
1330  $ilToolbar->addSeparator();
1331  $ilCtrl->setParameter($this, "csum", md5(print_r($a_pages[$this->current_page-1], true)));
1332  $ilToolbar->addButton($lng->txt("survey_delete_page"), $ilCtrl->getLinkTarget($this, "deleteBlock"));
1333  $ilCtrl->setParameter($this, "csum", "");
1334 
1335  $ilToolbar->addSeparator();
1336  $ilToolbar->addButton($lng->txt("survey_move_page"), $ilCtrl->getLinkTarget($this, "movePageForm"));
1337  }
1338  }
1339  }
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 caller graph for this function:

◆ saveJS()

ilSurveyPageGUI::saveJS ( )

Save content (ajax, js)

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

References $_POST, and exit.

1788  {
1789  $node = $_POST["ajaxform_node"];
1790  if($node)
1791  {
1792  $node = explode("_", $node);
1793  if($node[0] == "heading")
1794  {
1795  $id = (int)$node[1];
1796  $content = trim($_POST["ajaxform_content"]);
1797 
1798  $this->object->saveHeading($content, $id);
1799  exit();
1800  }
1801  }
1802  }
exit
Definition: login.php:54
$_POST['username']
Definition: cron.php:12

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

Referenced by renderToolbar().

◆ $has_previous_page

ilSurveyPageGUI::$has_previous_page
protected

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

Referenced by renderToolbar().

◆ $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: