ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
SurveyQuestionGUI Class Reference

Basic class for all survey question types The SurveyQuestionGUI class defines and encapsulates basic methods and attributes for survey question types to be used for all parent classes. More...

+ Inheritance diagram for SurveyQuestionGUI:
+ Collaboration diagram for SurveyQuestionGUI:

Public Member Functions

 __construct ($a_id=-1)
 
 setQuestionTabs ()
 
 executeCommand ()
 
 getQuestionType ()
 Returns the question type string. More...
 
 setBackUrl (string $a_url)
 
 setQuestionTabsForClass (string $guiclass)
 
 getPrintView (int $question_title=1, bool $show_questiontext=true, ?int $survey_id=null, ?array $working_data=null)
 
 preview ()
 
 getWorkingForm (array $working_data=null, int $question_title=1, bool $show_questiontext=true, string $error_message="", int $survey_id=null, bool $compress_view=false)
 

Static Public Member Functions

static _getQuestionGUI (?string $questiontype, int $question_id=-1)
 Creates a question gui representation. More...
 
static _getGUIClassNameForId (int $a_q_id)
 
static _getClassNameForQType (string $q_type)
 

Data Fields

SurveyQuestion $object = null
 

Protected Member Functions

 initObject ()
 
 outQuestionText (ilTemplate $template)
 
 initEditForm ()
 
 addCommandButtons (ilPropertyFormGUI $a_form)
 
 editQuestion (ilPropertyFormGUI $a_form=null)
 
 saveSync ()
 
 saveReturn ()
 
 saveForm ()
 
 save (bool $a_return=false, bool $a_sync=false)
 
 copySyncForm ()
 
 syncCopies ()
 
 originalSyncForm ()
 
 sync ()
 
 cancelSync ()
 
 redirectAfterSaving (bool $a_return=false)
 Redirect to calling survey or to edit form. More...
 
 cancel ()
 
 validateEditForm (ilPropertyFormGUI $a_form)
 
 addFieldsToEditForm (ilPropertyFormGUI $a_form)
 
 importEditFormValues (ilPropertyFormGUI $a_form)
 
 getPrintViewQuestionTitle (int $question_title=1)
 
 getQuestionTitle (int $question_title_mode=1)
 
 renderStatisticsDetailsTable (array $a_head, array $a_rows, array $a_foot=null)
 

Protected Attributes

ILIAS Survey InternalGUIService $gui
 
EditingGUIRequest $request
 
EditManager $edit_manager
 
ilRbacSystem $rbacsystem
 
ilObjUser $user
 
ilAccessHandler $access
 
ilTree $tree
 
ilToolbarGUI $toolbar
 
ilTabsGUI $tabs
 
ilGlobalTemplateInterface $tpl
 
ilLanguage $lng
 
ilCtrl $ctrl
 
array $cumulated = []
 
string $parent_url = ""
 
ilLogger $log
 

Detailed Description

Basic class for all survey question types The SurveyQuestionGUI class defines and encapsulates basic methods and attributes for survey question types to be used for all parent classes.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m

Definition at line 28 of file class.SurveyQuestionGUI.php.

Constructor & Destructor Documentation

◆ __construct()

SurveyQuestionGUI::__construct (   $a_id = -1)

Definition at line 47 of file class.SurveyQuestionGUI.php.

References $DIC, $lng, $tpl, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilLoggerFactory\getLogger(), initObject(), ILIAS\Repository\lng(), setQuestionTabs(), ILIAS\Repository\tabs(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

48  {
49  global $DIC;
50 
51  $this->rbacsystem = $DIC->rbac()->system();
52  $this->user = $DIC->user();
53  $this->access = $DIC->access();
54  $this->tree = $DIC->repositoryTree();
55  $this->toolbar = $DIC->toolbar();
56  $lng = $DIC->language();
57  $tpl = $DIC["tpl"];
58  $ilCtrl = $DIC->ctrl();
59 
60 
61  $this->request = $DIC->surveyQuestionPool()
62  ->internal()
63  ->gui()
64  ->editing()
65  ->request();
66 
67  $this->lng = $lng;
68  $this->tpl = $tpl;
69  $this->ctrl = $ilCtrl;
70  $this->ctrl->saveParameter($this, "q_id");
71  $this->ctrl->setParameterByClass(
72  $this->ctrl->getCmdClass(),
73  "sel_question_types",
74  $this->request->getSelectedQuestionTypes()
75  );
76  $this->cumulated = array();
77  $this->tabs = $DIC->tabs();
78 
79  $this->initObject();
80 
81  if ($a_id > 0) {
82  $this->object->loadFromDb($a_id);
83  }
84  $this->log = ilLoggerFactory::getLogger('svy');
85 
86  $this->edit_manager = $DIC->surveyQuestionPool()
87  ->internal()
88  ->domain()
89  ->editing();
90  $this->gui = $DIC->survey()->internal()->gui();
91  }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: feed.php:28
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:

Member Function Documentation

◆ _getClassNameForQType()

static SurveyQuestionGUI::_getClassNameForQType ( string  $q_type)
static

Definition at line 133 of file class.SurveyQuestionGUI.php.

Referenced by _getGUIClassNameForId().

133  : string
134  {
135  return $q_type;
136  }
+ Here is the caller graph for this function:

◆ _getGUIClassNameForId()

static SurveyQuestionGUI::_getGUIClassNameForId ( int  $a_q_id)
static

Definition at line 126 of file class.SurveyQuestionGUI.php.

References _getClassNameForQType(), and SurveyQuestion\_getQuestionType().

Referenced by ilSurveyQuestionsTableGUI\fillRow().

126  : string
127  {
128  $q_type = SurveyQuestion::_getQuestionType($a_q_id);
129  $class_name = SurveyQuestionGUI::_getClassNameForQType($q_type);
130  return $class_name;
131  }
static _getQuestionType(int $question_id)
Returns the question type of a question with a given id.
static _getClassNameForQType(string $q_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getQuestionGUI()

static SurveyQuestionGUI::_getQuestionGUI ( ?string  $questiontype,
int  $question_id = -1 
)
static

Creates a question gui representation.

Todo:
move to factory

Definition at line 113 of file class.SurveyQuestionGUI.php.

References SurveyQuestion\_getQuestionType(), and SurveyQuestion\_includeClass().

Referenced by ilObjSurveyQuestionPoolGUI\createQuestionObject(), ilObjSurveyQuestionPoolGUI\executeCommand(), ilSurveyEditorGUI\executeCommand(), ilSurveyEditorGUI\executeCreateQuestionObject(), ilObjSurvey\getQuestionGUI(), and ilObjSurveyQuestionPoolGUI\previewObject().

117  if ((!$questiontype) and ($question_id > 0)) {
118  $questiontype = SurveyQuestion::_getQuestionType($question_id);
119  }
120  SurveyQuestion::_includeClass($questiontype, 1);
121  $question_type_gui = $questiontype . "GUI";
122  $question = new $question_type_gui($question_id);
123  return $question;
124  }
static _getQuestionType(int $question_id)
Returns the question type of a question with a given id.
static _includeClass(string $question_type, int $gui=0)
Include the php class file for a given question type.
Basic class for all survey question types The SurveyQuestionGUI class defines and encapsulates basic ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addCommandButtons()

SurveyQuestionGUI::addCommandButtons ( ilPropertyFormGUI  $a_form)
protected

Definition at line 292 of file class.SurveyQuestionGUI.php.

References ilObject\_lookupType(), ilPropertyFormGUI\addCommandButton(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

Referenced by initEditForm().

292  : void
293  {
294  $a_form->addCommandButton("saveReturn", $this->lng->txt("save_return"));
295  $a_form->addCommandButton("save", $this->lng->txt("save"));
296 
297  // pool question?
298  if (ilObject::_lookupType($this->object->getObjId()) === "spl" && $this->object->hasCopies()) {
299  $a_form->addCommandButton("saveSync", $this->lng->txt("svy_save_sync"));
300  }
301  }
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addFieldsToEditForm()

SurveyQuestionGUI::addFieldsToEditForm ( ilPropertyFormGUI  $a_form)
abstractprotected

Referenced by initEditForm(), and validateEditForm().

+ Here is the caller graph for this function:

◆ cancel()

SurveyQuestionGUI::cancel ( )
protected

Definition at line 522 of file class.SurveyQuestionGUI.php.

References ILIAS\Repository\ctrl(), and ilUtil\redirect().

522  : void
523  {
524  if ($this->parent_url) {
525  ilUtil::redirect($this->parent_url);
526  } else {
527  $this->ctrl->redirectByClass("ilobjsurveyquestionpoolgui", "questions");
528  }
529  }
static redirect(string $a_script)
+ Here is the call graph for this function:

◆ cancelSync()

SurveyQuestionGUI::cancelSync ( )
protected

Definition at line 474 of file class.SurveyQuestionGUI.php.

References ILIAS\Repository\lng(), and redirectAfterSaving().

474  : void
475  {
476  $this->tpl->setOnScreenMessage('info', $this->lng->txt("question_changed_in_survey_only"), true);
477  $this->redirectAfterSaving($this->request->getReturn());
478  }
redirectAfterSaving(bool $a_return=false)
Redirect to calling survey or to edit form.
+ Here is the call graph for this function:

◆ copySyncForm()

SurveyQuestionGUI::copySyncForm ( )
protected

Definition at line 388 of file class.SurveyQuestionGUI.php.

References $tabs, and ilTabsGUI\activateTab().

Referenced by syncCopies().

388  : void
389  {
390  $ilTabs = $this->tabs;
391 
392  $ilTabs->activateTab("edit_properties");
393 
394  $tbl = new ilSurveySyncTableGUI($this, "copySyncForm", $this->object);
395 
396  $this->tpl->setContent($tbl->getHTML());
397  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
activateTab(string $a_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editQuestion()

SurveyQuestionGUI::editQuestion ( ilPropertyFormGUI  $a_form = null)
protected

Definition at line 303 of file class.SurveyQuestionGUI.php.

References $tabs, ilTabsGUI\activateTab(), and initEditForm().

Referenced by save(), and saveForm().

303  : void
304  {
305  $ilTabs = $this->tabs;
306 
307  $ilTabs->activateTab("edit_properties");
308 
309  if (!$a_form) {
310  $a_form = $this->initEditForm();
311  }
312  $this->tpl->setContent($a_form->getHTML());
313  }
activateTab(string $a_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

SurveyQuestionGUI::executeCommand ( )

Definition at line 97 of file class.SurveyQuestionGUI.php.

References ILIAS\Repository\ctrl().

97  : string
98  {
99  $cmd = $this->ctrl->getCmd();
100  $next_class = $this->ctrl->getNextClass($this);
101  switch ($next_class) {
102  default:
103  $ret = $this->$cmd();
104  break;
105  }
106  return (string) $ret;
107  }
+ Here is the call graph for this function:

◆ getPrintView()

SurveyQuestionGUI::getPrintView ( int  $question_title = 1,
bool  $show_questiontext = true,
?int  $survey_id = null,
?array  $working_data = null 
)
abstract

Referenced by validateEditForm().

+ Here is the caller graph for this function:

◆ getPrintViewQuestionTitle()

SurveyQuestionGUI::getPrintViewQuestionTitle ( int  $question_title = 1)
protected

Definition at line 547 of file class.SurveyQuestionGUI.php.

References ILIAS\Repository\object(), ilLegacyFormElementsUtil\prepareFormOutput(), ilObjSurvey\PRINT_HIDE_LABELS, and ilObjSurvey\PRINT_SHOW_LABELS.

Referenced by SurveyTextQuestionGUI\getPrintView(), SurveySingleChoiceQuestionGUI\getPrintView(), SurveyMetricQuestionGUI\getPrintView(), SurveyMultipleChoiceQuestionGUI\getPrintView(), and SurveyMatrixQuestionGUI\getPrintView().

549  : string {
550  $title = "";
551  switch ($question_title) {
553  $title = ilLegacyFormElementsUtil::prepareFormOutput($this->object->getTitle());
554  break;
555 
556  #19448 get rid of showing only the label without title
557  //case 2:
558  // $title = ilUtil::prepareFormOutput($this->object->getLabel());
559  // break;
560 
562  $title = ilLegacyFormElementsUtil::prepareFormOutput($this->object->getTitle());
563  if (trim($this->object->getLabel())) {
564  $title .= ' <span class="questionLabel">(' . ilLegacyFormElementsUtil::prepareFormOutput(
565  $this->object->getLabel()
566  ) . ')</span>';
567  }
568  break;
569  }
570  return $title;
571  }
static prepareFormOutput($a_str, bool $a_strip=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionTitle()

SurveyQuestionGUI::getQuestionTitle ( int  $question_title_mode = 1)
protected

Definition at line 573 of file class.SurveyQuestionGUI.php.

References ILIAS\Repository\object(), ilObjSurvey\PRINT_HIDE_LABELS, and ilObjSurvey\PRINT_SHOW_LABELS.

Referenced by SurveyTextQuestionGUI\getWorkingForm(), SurveyMetricQuestionGUI\getWorkingForm(), SurveySingleChoiceQuestionGUI\getWorkingForm(), SurveyMultipleChoiceQuestionGUI\getWorkingForm(), and SurveyMatrixQuestionGUI\getWorkingForm().

575  : string {
576  $title = "";
577  switch ($question_title_mode) {
579  $title = $this->object->getTitle();
580  break;
581 
583  $title = $this->object->getTitle();
584  if (trim($this->object->getLabel())) {
585  $title .= ' <span class="questionLabel">(' .
586  $this->object->getLabel()
587  . ')</span>';
588  }
589  break;
590  }
591  return $title;
592  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionType()

SurveyQuestionGUI::getQuestionType ( )

Returns the question type string.

Definition at line 141 of file class.SurveyQuestionGUI.php.

Referenced by setQuestionTabsForClass().

141  : string
142  {
143  return $this->object->getQuestionType();
144  }
+ Here is the caller graph for this function:

◆ getWorkingForm()

SurveyQuestionGUI::getWorkingForm ( array  $working_data = null,
int  $question_title = 1,
bool  $show_questiontext = true,
string  $error_message = "",
int  $survey_id = null,
bool  $compress_view = false 
)
abstract

Referenced by preview().

+ Here is the caller graph for this function:

◆ importEditFormValues()

SurveyQuestionGUI::importEditFormValues ( ilPropertyFormGUI  $a_form)
abstractprotected

Referenced by saveForm(), and validateEditForm().

+ Here is the caller graph for this function:

◆ initEditForm()

SurveyQuestionGUI::initEditForm ( )
protected

Definition at line 222 of file class.SurveyQuestionGUI.php.

References ilObjAdvancedEditing\_getRichTextEditor(), ilObjAdvancedEditing\_getUsedHTMLTags(), addCommandButtons(), addFieldsToEditForm(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilFormPropertyGUI\setRequired().

Referenced by editQuestion(), and saveForm().

223  {
224  $form = new ilPropertyFormGUI();
225  $form->setFormAction($this->ctrl->getFormAction($this, "save"));
226  $form->setTitle($this->lng->txt($this->getQuestionType()));
227  $form->setMultipart(false);
228  $form->setTableWidth("100%");
229  // $form->setId("essay");
230 
231  // title
232  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
233  $title->setMaxLength(200);
234  $title->setRequired(true);
235  $form->addItem($title);
236 
237  // label
238  $label = new ilTextInputGUI($this->lng->txt("label"), "label");
239  $label->setInfo($this->lng->txt("label_info"));
240  $title->setMaxLength(255);
241  $label->setRequired(false);
242  $form->addItem($label);
243 
244  // author
245  $author = new ilTextInputGUI($this->lng->txt("author"), "author");
246  $author->setRequired(true);
247  $title->setMaxLength(100);
248  $form->addItem($author);
249 
250  // description
251  $description = new ilTextInputGUI($this->lng->txt("description"), "description");
252  $description->setRequired(false);
253  $title->setMaxLength(200);
254  $form->addItem($description);
255 
256  // questiontext
257  $question = new ilTextAreaInputGUI($this->lng->txt("question"), "question");
258  $question->setRequired(true);
259  $question->setRows(10);
260  $question->setCols(80);
261  if (ilObjAdvancedEditing::_getRichTextEditor() === "tinymce") {
262  $question->setUseRte(true);
263  $question->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
264  $question->addPlugin("latex");
265  $question->addButton("latex");
266  $question->addButton("pastelatex");
267  $question->setRTESupport($this->object->getId(), "spl", "survey");
268  }
269  $form->addItem($question);
270 
271  // obligatory
272  $shuffle = new ilCheckboxInputGUI($this->lng->txt("obligatory"), "obligatory");
273  $shuffle->setValue(1);
274  $shuffle->setRequired(false);
275  $form->addItem($shuffle);
276 
277  $this->addFieldsToEditForm($form);
278 
279  $this->addCommandButtons($form);
280 
281  // values
282  $title->setValue($this->object->getTitle());
283  $label->setValue($this->object->label);
284  $author->setValue($this->object->getAuthor());
285  $description->setValue($this->object->getDescription());
286  $question->setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
287  $shuffle->setChecked($this->object->getObligatory());
288 
289  return $form;
290  }
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
addFieldsToEditForm(ilPropertyFormGUI $a_form)
setRequired(bool $a_required)
addCommandButtons(ilPropertyFormGUI $a_form)
This class represents a text area property in a property form.
static _getUsedHTMLTags(string $a_module="")
Returns an array of all allowed HTML tags for text editing.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initObject()

SurveyQuestionGUI::initObject ( )
abstractprotected

Referenced by __construct().

+ Here is the caller graph for this function:

◆ originalSyncForm()

SurveyQuestionGUI::originalSyncForm ( )
protected

Definition at line 445 of file class.SurveyQuestionGUI.php.

References $tabs, ilTabsGUI\activateTab(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

445  : void
446  {
447  $ilTabs = $this->tabs;
448 
449  $ilTabs->activateTab("edit_properties");
450 
451  $this->ctrl->saveParameter($this, "rtrn");
452 
453  $cgui = new ilConfirmationGUI();
454  $cgui->setHeaderText($this->lng->txt("confirm_sync_questions"));
455 
456  $cgui->setFormAction($this->ctrl->getFormAction($this, "confirmRemoveQuestions"));
457  $cgui->setCancel($this->lng->txt("no"), "cancelSync");
458  $cgui->setConfirm($this->lng->txt("yes"), "sync");
459 
460  $this->tpl->setContent($cgui->getHTML());
461  }
activateTab(string $a_id)
+ Here is the call graph for this function:

◆ outQuestionText()

SurveyQuestionGUI::outQuestionText ( ilTemplate  $template)
protected

Definition at line 146 of file class.SurveyQuestionGUI.php.

References ILIAS\Repository\object(), and HTML_Template_IT\setVariable().

Referenced by SurveyTextQuestionGUI\getPrintView(), SurveySingleChoiceQuestionGUI\getPrintView(), SurveyMetricQuestionGUI\getPrintView(), SurveyMultipleChoiceQuestionGUI\getPrintView(), SurveyMatrixQuestionGUI\getPrintView(), SurveyTextQuestionGUI\getWorkingForm(), SurveyMetricQuestionGUI\getWorkingForm(), SurveySingleChoiceQuestionGUI\getWorkingForm(), SurveyMultipleChoiceQuestionGUI\getWorkingForm(), and SurveyMatrixQuestionGUI\getWorkingForm().

146  : void
147  {
148  $questiontext = $this->object->getQuestiontext();
149  if (preg_match("/^<.[\\>]?>(.*?)<\\/.[\\>]*?>$/", $questiontext, $matches)) {
150  $questiontext = $matches[1];
151  }
152  $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
153  if ($this->object->getObligatory()) {
154  $template->setVariable("OBLIGATORY_TEXT", ' *');
155  }
156  }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:546
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ preview()

SurveyQuestionGUI::preview ( )

Definition at line 594 of file class.SurveyQuestionGUI.php.

References Vendor\Package\$f, $r, $tabs, ilTabsGUI\activateTab(), ilGlobalTemplateInterface\get(), getWorkingForm(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilGlobalTemplateInterface\parseCurrentBlock(), ilGlobalTemplateInterface\setCurrentBlock(), and ilGlobalTemplateInterface\setVariable().

594  : void
595  {
596  $ilTabs = $this->tabs;
597 
598  $ilTabs->activateTab("preview");
599 
600  $tpl = new ilTemplate("tpl.il_svy_qpl_preview.html", true, true, "Modules/SurveyQuestionPool");
601 
602  if ($this->object->getObligatory()) {
603  $tpl->setCurrentBlock("required");
604  $tpl->setVariable("TEXT_REQUIRED", $this->lng->txt("required_field"));
606  }
607 
608  $tpl->setVariable("QUESTION_OUTPUT", $this->getWorkingForm());
609 
610  $f = $this->gui->ui()->factory();
611  $r = $this->gui->ui()->renderer();
612  $p = $f->panel()->standard(
613  "",
614  $f->legacy($tpl->get())
615  );
616 
617  $this->tpl->setContent($r->render($p));
618  }
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
ilGlobalTemplateInterface $tpl
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
activateTab(string $a_id)
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
getWorkingForm(array $working_data=null, int $question_title=1, bool $show_questiontext=true, string $error_message="", int $survey_id=null, bool $compress_view=false)
$r
+ Here is the call graph for this function:

◆ redirectAfterSaving()

SurveyQuestionGUI::redirectAfterSaving ( bool  $a_return = false)
protected

Redirect to calling survey or to edit form.

Definition at line 483 of file class.SurveyQuestionGUI.php.

References ILIAS\Repository\ctrl(), and ilUtil\redirect().

Referenced by cancelSync(), save(), sync(), and syncCopies().

485  : void {
486  // return?
487  if ($a_return) {
488  // to calling survey
489  if ($this->parent_url) {
490  $addurl = "";
491  if ($this->request->getNewForSurvey() > 0) {
492  $addurl = "&new_id=" . $this->request->getQuestionId();
493  }
494  ilUtil::redirect(str_replace("&amp;", "&", $this->parent_url) . $addurl);
495  }
496  // to pool
497  else {
498  $this->ctrl->redirectByClass("ilObjSurveyQuestionPoolGUI", "questions");
499  }
500  }
501  // stay in form
502  else {
503  $this->ctrl->setParameterByClass(
504  $this->ctrl->getCmdClass(),
505  "q_id",
506  $this->object->getId()
507  );
508  $this->ctrl->setParameterByClass(
509  $this->ctrl->getCmdClass(),
510  "sel_question_types",
511  $this->request->getSelectedQuestionTypes()
512  );
513  $this->ctrl->setParameterByClass(
514  $this->ctrl->getCmdClass(),
515  "new_for_survey",
516  $this->request->getNewForSurvey()
517  );
518  $this->ctrl->redirectByClass($this->ctrl->getCmdClass(), "editQuestion");
519  }
520  }
static redirect(string $a_script)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderStatisticsDetailsTable()

SurveyQuestionGUI::renderStatisticsDetailsTable ( array  $a_head,
array  $a_rows,
array  $a_foot = null 
)
protected

Definition at line 635 of file class.SurveyQuestionGUI.php.

639  : string {
640  $html = array();
641  $html[] = '<div class="ilTableOuter table-responsive">';
642  $html[] = '<table class="table table-striped">';
643 
644  $html[] = "<thead>";
645  $html[] = "<tr>";
646  foreach ($a_head as $col) {
647  $col = trim($col);
648  $html[] = "<th>";
649  $html[] = ($col != "") ? $col : "&nbsp;";
650  $html[] = "</th>";
651  }
652  $html[] = "</tr>";
653  $html[] = "</thead>";
654 
655  $html[] = "<tbody>";
656  foreach ($a_rows as $row) {
657  $html[] = "<tr>";
658  foreach ($row as $col) {
659  $col = trim($col);
660  $html[] = "<td>";
661  $html[] = ($col != "") ? $col : "&nbsp;";
662  $html[] = "</td>";
663  }
664  $html[] = "</tr>";
665  }
666  $html[] = "</tbody>";
667 
668  if ($a_foot) {
669  $html[] = "<tfoot>";
670  $html[] = "<tr>";
671  foreach ($a_foot as $col) {
672  $col = trim($col);
673  $html[] = "<td>";
674  $html[] = ($col != "") ? $col : "&nbsp;";
675  $html[] = "</td>";
676  }
677  $html[] = "</tr>";
678  $html[] = "</tfoot>";
679  }
680 
681  $html[] = "</table>";
682  $html[] = "</div>";
683  return implode("\n", $html);
684  }

◆ save()

SurveyQuestionGUI::save ( bool  $a_return = false,
bool  $a_sync = false 
)
protected

Definition at line 349 of file class.SurveyQuestionGUI.php.

References $user, SurveyQuestion\_isComplete(), SurveyQuestion\_isWriteable(), SurveyQuestion\_questionExists(), ILIAS\Repository\ctrl(), editQuestion(), ILIAS\Repository\lng(), ILIAS\Repository\object(), redirectAfterSaving(), and saveForm().

Referenced by saveReturn(), and saveSync().

352  : void {
353  $ilUser = $this->user;
354 
355  if ($this->saveForm()) {
356  // #13784
357  if ($a_return &&
358  !SurveyQuestion::_isComplete($this->object->getId())) {
359  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("survey_error_insert_incomplete_question"));
360  $this->editQuestion();
361  return;
362  }
363 
364  $ilUser->setPref("svy_lastquestiontype", $this->object->getQuestionType());
365  $ilUser->writePref("svy_lastquestiontype", $this->object->getQuestionType());
366 
367  $originalexists = SurveyQuestion::_questionExists((int) $this->object->original_id);
368  $this->ctrl->setParameter($this, "q_id", $this->object->getId());
369 
370  // pool question?
371  if ($a_sync) {
372  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
373  $this->ctrl->redirect($this, 'copySyncForm');
374  } elseif ($originalexists &&
375  SurveyQuestion::_isWriteable($this->object->original_id, $ilUser->getId())) {
376  // form: update original pool question, too?
377  if ($a_return) {
378  $this->ctrl->setParameter($this, 'rtrn', 1);
379  }
380  $this->ctrl->redirect($this, 'originalSyncForm');
381  }
382 
383  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
384  $this->redirectAfterSaving($a_return);
385  }
386  }
static _isWriteable(int $question_id, int $user_id)
is question writeable by a certain user
static _isComplete(int $question_id)
Checks whether the question is complete or not.
redirectAfterSaving(bool $a_return=false)
Redirect to calling survey or to edit form.
editQuestion(ilPropertyFormGUI $a_form=null)
static _questionExists(int $question_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveForm()

SurveyQuestionGUI::saveForm ( )
protected

Definition at line 325 of file class.SurveyQuestionGUI.php.

References editQuestion(), importEditFormValues(), initEditForm(), and validateEditForm().

Referenced by save().

325  : bool
326  {
327  $form = $this->initEditForm();
328  if ($form->checkInput() && $this->validateEditForm($form)) {
329  $this->object->setTitle($form->getInput("title"));
330  $this->object->label = ($form->getInput("label"));
331  $this->object->setAuthor($form->getInput("author"));
332  $this->object->setDescription($form->getInput("description"));
333  $this->object->setQuestiontext($form->getInput("question"));
334  $this->object->setObligatory($form->getInput("obligatory"));
335 
336  $this->importEditFormValues($form);
337 
338  // will save both core and extended data
339  $this->object->saveToDb();
340 
341  return true;
342  }
343 
344  $form->setValuesByPost();
345  $this->editQuestion($form);
346  return false;
347  }
validateEditForm(ilPropertyFormGUI $a_form)
importEditFormValues(ilPropertyFormGUI $a_form)
editQuestion(ilPropertyFormGUI $a_form=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveReturn()

SurveyQuestionGUI::saveReturn ( )
protected

Definition at line 320 of file class.SurveyQuestionGUI.php.

References save().

320  : void
321  {
322  $this->save(true);
323  }
save(bool $a_return=false, bool $a_sync=false)
+ Here is the call graph for this function:

◆ saveSync()

SurveyQuestionGUI::saveSync ( )
protected

Definition at line 315 of file class.SurveyQuestionGUI.php.

References save().

315  : void
316  {
317  $this->save($this->request->getReturn(), true);
318  }
save(bool $a_return=false, bool $a_sync=false)
+ Here is the call graph for this function:

◆ setBackUrl()

SurveyQuestionGUI::setBackUrl ( string  $a_url)

Definition at line 158 of file class.SurveyQuestionGUI.php.

158  : void
159  {
160  $this->parent_url = $a_url;
161  }

◆ setQuestionTabs()

SurveyQuestionGUI::setQuestionTabs ( )
abstract

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setQuestionTabsForClass()

SurveyQuestionGUI::setQuestionTabsForClass ( string  $guiclass)

Definition at line 163 of file class.SurveyQuestionGUI.php.

References $rbacsystem, $tabs, ilRbacSystem\checkAccess(), ILIAS\Repository\ctrl(), getQuestionType(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

Referenced by SurveyMatrixQuestionGUI\setQuestionTabs(), SurveyMultipleChoiceQuestionGUI\setQuestionTabs(), SurveyMetricQuestionGUI\setQuestionTabs(), SurveyTextQuestionGUI\setQuestionTabs(), and SurveySingleChoiceQuestionGUI\setQuestionTabs().

163  : void
164  {
166  $ilTabs = $this->tabs;
167 
168  $this->ctrl->setParameterByClass($guiclass, "sel_question_types", $this->getQuestionType());
169  $this->ctrl->setParameterByClass(
170  $guiclass,
171  "q_id",
172  $this->request->getQuestionId()
173  );
174 
175  if ($this->parent_url) {
176  $addurl = "";
177  if ($this->request->getNewForSurvey() > 0) {
178  $addurl = "&new_id=" . $this->request->getQuestionId();
179  }
180  $ilTabs->setBackTarget($this->lng->txt("menubacktosurvey"), $this->parent_url . $addurl);
181  } else {
182  $ilTabs->setBackTarget($this->lng->txt("spl"), $this->ctrl->getLinkTargetByClass("ilObjSurveyQuestionPoolGUI", "questions"));
183  }
184  if ($this->request->getQuestionId()) {
185  $ilTabs->addNonTabbedLink(
186  "preview",
187  $this->lng->txt("preview"),
188  $this->ctrl->getLinkTargetByClass($guiclass, "preview")
189  );
190  }
191 
192  if ($rbacsystem->checkAccess('edit', $this->request->getRefId())) {
193  $ilTabs->addTab(
194  "edit_properties",
195  $this->lng->txt("properties"),
196  $this->ctrl->getLinkTargetByClass($guiclass, "editQuestion")
197  );
198 
199  if (stripos($guiclass, "matrix") !== false) {
200  $ilTabs->addTab(
201  "layout",
202  $this->lng->txt("layout"),
203  $this->ctrl->getLinkTargetByClass($guiclass, "layout")
204  );
205  }
206  }
207 
208  if ($this->object->getId() > 0) {
209  $title = $this->lng->txt("edit") . " &quot;" . $this->object->getTitle() . "&quot";
210  } else {
211  $title = $this->lng->txt("create_new") . " " . $this->lng->txt($this->getQuestionType());
212  }
213 
214  $this->tpl->setVariable("HEADER", $title);
215  }
getQuestionType()
Returns the question type string.
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sync()

SurveyQuestionGUI::sync ( )
protected

Definition at line 463 of file class.SurveyQuestionGUI.php.

References ILIAS\Repository\lng(), and redirectAfterSaving().

463  : void
464  {
465  $original_id = $this->object->original_id;
466  if ($original_id) {
467  $this->object->syncWithOriginal();
468  }
469 
470  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
471  $this->redirectAfterSaving($this->request->getReturn());
472  }
redirectAfterSaving(bool $a_return=false)
Redirect to calling survey or to edit form.
+ Here is the call graph for this function:

◆ syncCopies()

SurveyQuestionGUI::syncCopies ( )
protected

Definition at line 399 of file class.SurveyQuestionGUI.php.

References $access, $id, $lng, $ref_id, ilObject\_getAllReferences(), copySyncForm(), ILIAS\Repository\object(), redirectAfterSaving(), and ilLanguage\txt().

399  : void
400  {
401  $lng = $this->lng;
402  $ilAccess = $this->access;
403 
404  $qids = $this->request->getQuestionIds();
405  if (count($qids) === 0) {
406  $this->tpl->setOnScreenMessage('failure', $lng->txt("select_one"));
407  $this->copySyncForm();
408  return;
409  }
410 
411  foreach ($this->object->getCopyIds(true) as $survey_id => $questions) {
412  // check permissions for "parent" survey
413  $can_write = false;
414  $ref_ids = ilObject::_getAllReferences($survey_id);
415  foreach ($ref_ids as $ref_id) {
416  if ($ilAccess->checkAccess("edit", "", $ref_id)) {
417  $can_write = true;
418  break;
419  }
420  }
421 
422  if ($can_write) {
423  foreach ($questions as $qid) {
424  if (in_array($qid, $qids)) {
425  $id = $this->object->getId();
426 
427  $this->object->setId($qid);
428  $this->object->setOriginalId($id);
429  $this->object->saveToDb();
430 
431  $this->object->setId($id);
432  $this->object->setOriginalId(null);
433 
434  // see: SurveyQuestion::syncWithOriginal()
435  // what about material?
436  }
437  }
438  }
439  }
440 
441  $this->tpl->setOnScreenMessage('success', $lng->txt("survey_sync_success"), true);
442  $this->redirectAfterSaving($this->request->getReturn());
443  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:67
redirectAfterSaving(bool $a_return=false)
Redirect to calling survey or to edit form.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ validateEditForm()

SurveyQuestionGUI::validateEditForm ( ilPropertyFormGUI  $a_form)
protected

Definition at line 531 of file class.SurveyQuestionGUI.php.

References addFieldsToEditForm(), getPrintView(), and importEditFormValues().

Referenced by saveForm().

531  : bool
532  {
533  return true;
534  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler SurveyQuestionGUI::$access
protected

Definition at line 35 of file class.SurveyQuestionGUI.php.

Referenced by syncCopies().

◆ $ctrl

ilCtrl SurveyQuestionGUI::$ctrl
protected

Definition at line 41 of file class.SurveyQuestionGUI.php.

◆ $cumulated

array SurveyQuestionGUI::$cumulated = []
protected

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

◆ $edit_manager

EditManager SurveyQuestionGUI::$edit_manager
protected

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

◆ $gui

ILIAS Survey InternalGUIService SurveyQuestionGUI::$gui
protected

Definition at line 30 of file class.SurveyQuestionGUI.php.

◆ $lng

ilLanguage SurveyQuestionGUI::$lng
protected

Definition at line 40 of file class.SurveyQuestionGUI.php.

Referenced by __construct(), and syncCopies().

◆ $log

ilLogger SurveyQuestionGUI::$log
protected

Definition at line 44 of file class.SurveyQuestionGUI.php.

◆ $object

SurveyQuestion SurveyQuestionGUI::$object = null

Definition at line 45 of file class.SurveyQuestionGUI.php.

◆ $parent_url

string SurveyQuestionGUI::$parent_url = ""
protected

Definition at line 43 of file class.SurveyQuestionGUI.php.

◆ $rbacsystem

ilRbacSystem SurveyQuestionGUI::$rbacsystem
protected

Definition at line 33 of file class.SurveyQuestionGUI.php.

Referenced by setQuestionTabsForClass().

◆ $request

EditingGUIRequest SurveyQuestionGUI::$request
protected

Definition at line 31 of file class.SurveyQuestionGUI.php.

◆ $tabs

◆ $toolbar

ilToolbarGUI SurveyQuestionGUI::$toolbar
protected

Definition at line 37 of file class.SurveyQuestionGUI.php.

◆ $tpl

ilGlobalTemplateInterface SurveyQuestionGUI::$tpl
protected

Definition at line 39 of file class.SurveyQuestionGUI.php.

Referenced by __construct().

◆ $tree

ilTree SurveyQuestionGUI::$tree
protected

Definition at line 36 of file class.SurveyQuestionGUI.php.

◆ $user

ilObjUser SurveyQuestionGUI::$user
protected

Definition at line 34 of file class.SurveyQuestionGUI.php.

Referenced by save().


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