ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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: shib_login.php:22
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 288 of file class.SurveyQuestionGUI.php.

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

Referenced by initEditForm().

288  : void
289  {
290  $a_form->addCommandButton("saveReturn", $this->lng->txt("save_return"));
291  $a_form->addCommandButton("save", $this->lng->txt("save"));
292 
293  // pool question?
294  if (ilObject::_lookupType($this->object->getObjId()) === "spl" && $this->object->hasCopies()) {
295  $a_form->addCommandButton("saveSync", $this->lng->txt("svy_save_sync"));
296  }
297  }
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 518 of file class.SurveyQuestionGUI.php.

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

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

◆ cancelSync()

SurveyQuestionGUI::cancelSync ( )
protected

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

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

470  : void
471  {
472  $this->tpl->setOnScreenMessage('info', $this->lng->txt("question_changed_in_survey_only"), true);
473  $this->redirectAfterSaving($this->request->getReturn());
474  }
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 384 of file class.SurveyQuestionGUI.php.

References $tabs, and ilTabsGUI\activateTab().

Referenced by syncCopies().

384  : void
385  {
386  $ilTabs = $this->tabs;
387 
388  $ilTabs->activateTab("edit_properties");
389 
390  $tbl = new ilSurveySyncTableGUI($this, "copySyncForm", $this->object);
391 
392  $this->tpl->setContent($tbl->getHTML());
393  }
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 299 of file class.SurveyQuestionGUI.php.

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

Referenced by save(), and saveForm().

299  : void
300  {
301  $ilTabs = $this->tabs;
302 
303  $ilTabs->activateTab("edit_properties");
304 
305  if (!$a_form) {
306  $a_form = $this->initEditForm();
307  }
308  $this->tpl->setContent($a_form->getHTML());
309  }
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 543 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().

545  : string {
546  $title = "";
547  switch ($question_title) {
549  $title = ilLegacyFormElementsUtil::prepareFormOutput($this->object->getTitle());
550  break;
551 
552  #19448 get rid of showing only the label without title
553  //case 2:
554  // $title = ilUtil::prepareFormOutput($this->object->getLabel());
555  // break;
556 
558  $title = ilLegacyFormElementsUtil::prepareFormOutput($this->object->getTitle());
559  if (trim($this->object->getLabel())) {
560  $title .= ' <span class="questionLabel">(' . ilLegacyFormElementsUtil::prepareFormOutput(
561  $this->object->getLabel()
562  ) . ')</span>';
563  }
564  break;
565  }
566  return $title;
567  }
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 569 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().

571  : string {
572  $title = "";
573  switch ($question_title_mode) {
575  $title = $this->object->getTitle();
576  break;
577 
579  $title = $this->object->getTitle();
580  if (trim($this->object->getLabel())) {
581  $title .= ' <span class="questionLabel">(' .
582  $this->object->getLabel()
583  . ')</span>';
584  }
585  break;
586  }
587  return $title;
588  }
+ 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(), 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->setRteTagSet("mini");
264  }
265  $form->addItem($question);
266 
267  // obligatory
268  $shuffle = new ilCheckboxInputGUI($this->lng->txt("obligatory"), "obligatory");
269  $shuffle->setValue(1);
270  $shuffle->setRequired(false);
271  $form->addItem($shuffle);
272 
273  $this->addFieldsToEditForm($form);
274 
275  $this->addCommandButtons($form);
276 
277  // values
278  $title->setValue($this->object->getTitle());
279  $label->setValue($this->object->label);
280  $author->setValue($this->object->getAuthor());
281  $description->setValue($this->object->getDescription());
282  $question->setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
283  $shuffle->setChecked($this->object->getObligatory());
284 
285  return $form;
286  }
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.
+ 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 441 of file class.SurveyQuestionGUI.php.

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

441  : void
442  {
443  $ilTabs = $this->tabs;
444 
445  $ilTabs->activateTab("edit_properties");
446 
447  $this->ctrl->saveParameter($this, "rtrn");
448 
449  $cgui = new ilConfirmationGUI();
450  $cgui->setHeaderText($this->lng->txt("confirm_sync_questions"));
451 
452  $cgui->setFormAction($this->ctrl->getFormAction($this, "confirmRemoveQuestions"));
453  $cgui->setCancel($this->lng->txt("no"), "cancelSync");
454  $cgui->setConfirm($this->lng->txt("yes"), "sync");
455 
456  $this->tpl->setContent($cgui->getHTML());
457  }
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:544
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ preview()

SurveyQuestionGUI::preview ( )

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

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

590  : void
591  {
592  $ilTabs = $this->tabs;
593 
594  $ilTabs->activateTab("preview");
595 
596  $tpl = new ilTemplate("tpl.il_svy_qpl_preview.html", true, true, "components/ILIAS/SurveyQuestionPool");
597 
598  if ($this->object->getObligatory()) {
599  $tpl->setCurrentBlock("required");
600  $tpl->setVariable("TEXT_REQUIRED", $this->lng->txt("required_field"));
602  }
603 
604  $tpl->setVariable("QUESTION_OUTPUT", $this->getWorkingForm());
605 
606  $f = $this->gui->ui()->factory();
607  $r = $this->gui->ui()->renderer();
608  $p = $f->panel()->standard(
609  "",
610  $f->legacy()->content($tpl->get())
611  );
612 
613  $this->tpl->setContent($r->render($p));
614  }
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
ilGlobalTemplateInterface $tpl
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
activateTab(string $a_id)
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 479 of file class.SurveyQuestionGUI.php.

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

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

481  : void {
482  // return?
483  if ($a_return) {
484  // to calling survey
485  if ($this->parent_url) {
486  $addurl = "";
487  if ($this->request->getNewForSurvey() > 0) {
488  $addurl = "&new_id=" . $this->request->getQuestionId();
489  }
490  ilUtil::redirect(str_replace("&amp;", "&", $this->parent_url) . $addurl);
491  }
492  // to pool
493  else {
494  $this->ctrl->redirectByClass("ilObjSurveyQuestionPoolGUI", "questions");
495  }
496  }
497  // stay in form
498  else {
499  $this->ctrl->setParameterByClass(
500  $this->ctrl->getCmdClass(),
501  "q_id",
502  $this->object->getId()
503  );
504  $this->ctrl->setParameterByClass(
505  $this->ctrl->getCmdClass(),
506  "sel_question_types",
507  $this->request->getSelectedQuestionTypes()
508  );
509  $this->ctrl->setParameterByClass(
510  $this->ctrl->getCmdClass(),
511  "new_for_survey",
512  $this->request->getNewForSurvey()
513  );
514  $this->ctrl->redirectByClass($this->ctrl->getCmdClass(), "editQuestion");
515  }
516  }
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 631 of file class.SurveyQuestionGUI.php.

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

◆ save()

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

Definition at line 345 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().

348  : void {
349  $ilUser = $this->user;
350 
351  if ($this->saveForm()) {
352  // #13784
353  if ($a_return &&
354  !SurveyQuestion::_isComplete($this->object->getId())) {
355  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("survey_error_insert_incomplete_question"));
356  $this->editQuestion();
357  return;
358  }
359 
360  $ilUser->setPref("svy_lastquestiontype", $this->object->getQuestionType());
361  $ilUser->writePref("svy_lastquestiontype", $this->object->getQuestionType());
362 
363  $originalexists = SurveyQuestion::_questionExists((int) $this->object->original_id);
364  $this->ctrl->setParameter($this, "q_id", $this->object->getId());
365 
366  // pool question?
367  if ($a_sync) {
368  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
369  $this->ctrl->redirect($this, 'copySyncForm');
370  } elseif ($originalexists &&
371  SurveyQuestion::_isWriteable($this->object->original_id, $ilUser->getId())) {
372  // form: update original pool question, too?
373  if ($a_return) {
374  $this->ctrl->setParameter($this, 'rtrn', 1);
375  }
376  $this->ctrl->redirect($this, 'originalSyncForm');
377  }
378 
379  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
380  $this->redirectAfterSaving($a_return);
381  }
382  }
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 321 of file class.SurveyQuestionGUI.php.

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

Referenced by save().

321  : bool
322  {
323  $form = $this->initEditForm();
324  if ($form->checkInput() && $this->validateEditForm($form)) {
325  $this->object->setTitle($form->getInput("title"));
326  $this->object->label = ($form->getInput("label"));
327  $this->object->setAuthor($form->getInput("author"));
328  $this->object->setDescription($form->getInput("description"));
329  $this->object->setQuestiontext($form->getInput("question"));
330  $this->object->setObligatory($form->getInput("obligatory"));
331 
332  $this->importEditFormValues($form);
333 
334  // will save both core and extended data
335  $this->object->saveToDb();
336 
337  return true;
338  }
339 
340  $form->setValuesByPost();
341  $this->editQuestion($form);
342  return false;
343  }
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 316 of file class.SurveyQuestionGUI.php.

References save().

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

◆ saveSync()

SurveyQuestionGUI::saveSync ( )
protected

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

References save().

311  : void
312  {
313  $this->save($this->request->getReturn(), true);
314  }
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 459 of file class.SurveyQuestionGUI.php.

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

459  : void
460  {
461  $original_id = $this->object->original_id;
462  if ($original_id) {
463  $this->object->syncWithOriginal();
464  }
465 
466  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
467  $this->redirectAfterSaving($this->request->getReturn());
468  }
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 395 of file class.SurveyQuestionGUI.php.

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

395  : void
396  {
397  $lng = $this->lng;
398  $ilAccess = $this->access;
399 
400  $qids = $this->request->getQuestionIds();
401  if (count($qids) === 0) {
402  $this->tpl->setOnScreenMessage('failure', $lng->txt("select_one"));
403  $this->copySyncForm();
404  return;
405  }
406 
407  foreach ($this->object->getCopyIds(true) as $survey_id => $questions) {
408  // check permissions for "parent" survey
409  $can_write = false;
410  $ref_ids = ilObject::_getAllReferences($survey_id);
411  foreach ($ref_ids as $ref_id) {
412  if ($ilAccess->checkAccess("edit", "", $ref_id)) {
413  $can_write = true;
414  break;
415  }
416  }
417 
418  if ($can_write) {
419  foreach ($questions as $qid) {
420  if (in_array($qid, $qids)) {
421  $id = $this->object->getId();
422 
423  $this->object->setId($qid);
424  $this->object->setOriginalId($id);
425  $this->object->saveToDb();
426 
427  $this->object->setId($id);
428  $this->object->setOriginalId(null);
429 
430  // see: SurveyQuestion::syncWithOriginal()
431  // what about material?
432  }
433  }
434  }
435  }
436 
437  $this->tpl->setOnScreenMessage('success', $lng->txt("survey_sync_success"), true);
438  $this->redirectAfterSaving($this->request->getReturn());
439  }
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
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$ref_id
Definition: ltiauth.php:65
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 527 of file class.SurveyQuestionGUI.php.

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

Referenced by saveForm().

527  : bool
528  {
529  return true;
530  }
+ 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: