ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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 InternalDomainService $domain
 
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
 
ilHtmlPurifierInterface $purifier
 

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 30 of file class.SurveyQuestionGUI.php.

Constructor & Destructor Documentation

◆ __construct()

SurveyQuestionGUI::__construct (   $a_id = -1)

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

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

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

+ Here is the call graph for this function:

Member Function Documentation

◆ _getClassNameForQType()

static SurveyQuestionGUI::_getClassNameForQType ( string  $q_type)
static

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

139 : string
140 {
141 return $q_type;
142 }

Referenced by _getGUIClassNameForId().

+ Here is the caller graph for this function:

◆ _getGUIClassNameForId()

static SurveyQuestionGUI::_getGUIClassNameForId ( int  $a_q_id)
static

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

132 : string
133 {
134 $q_type = SurveyQuestion::_getQuestionType($a_q_id);
135 $class_name = SurveyQuestionGUI::_getClassNameForQType($q_type);
136 return $class_name;
137 }
static _getClassNameForQType(string $q_type)
static _getQuestionType(int $question_id)
Returns the question type of a question with a given id.

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

Referenced by ilSurveyQuestionsTableGUI\fillRow().

+ 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 119 of file class.SurveyQuestionGUI.php.

123 if ((!$questiontype) and ($question_id > 0)) {
124 $questiontype = SurveyQuestion::_getQuestionType($question_id);
125 }
126 SurveyQuestion::_includeClass($questiontype, 1);
127 $question_type_gui = $questiontype . "GUI";
128 $question = new $question_type_gui($question_id);
129 return $question;
130 }
Basic class for all survey question types The SurveyQuestionGUI class defines and encapsulates basic ...
static _includeClass(string $question_type, int $gui=0)
Include the php class file for a given question type.

References SurveyQuestion\_getQuestionType().

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

+ 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 296 of file class.SurveyQuestionGUI.php.

296 : void
297 {
298 $a_form->addCommandButton("saveReturn", $this->lng->txt("save_return"));
299 $a_form->addCommandButton("save", $this->lng->txt("save"));
300
301 // pool question?
302 if (ilObject::_lookupType($this->object->getObjId()) === "spl" && $this->object->hasCopies()) {
303 $a_form->addCommandButton("saveSync", $this->lng->txt("svy_save_sync"));
304 }
305 }
static _lookupType(int $id, bool $reference=false)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")

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

+ Here is the call graph for this function:

◆ addFieldsToEditForm()

SurveyQuestionGUI::addFieldsToEditForm ( ilPropertyFormGUI  $a_form)
abstractprotected

◆ cancel()

SurveyQuestionGUI::cancel ( )
protected

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

539 : void
540 {
541 if ($this->parent_url) {
542 ilUtil::redirect($this->parent_url);
543 } else {
544 $this->ctrl->redirectByClass("ilobjsurveyquestionpoolgui", "questions");
545 }
546 }
static redirect(string $a_script)

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

+ Here is the call graph for this function:

◆ cancelSync()

SurveyQuestionGUI::cancelSync ( )
protected

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

491 : void
492 {
493 $this->tpl->setOnScreenMessage('info', $this->lng->txt("question_changed_in_survey_only"), true);
494 $this->redirectAfterSaving($this->request->getReturn());
495 }
redirectAfterSaving(bool $a_return=false)
Redirect to calling survey or to edit form.

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ copySyncForm()

SurveyQuestionGUI::copySyncForm ( )
protected

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

405 : void
406 {
407 $ilTabs = $this->tabs;
408
409 $ilTabs->activateTab("edit_properties");
410
411 $tbl = new ilSurveySyncTableGUI($this, "copySyncForm", $this->object);
412
413 $this->tpl->setContent($tbl->getHTML());
414 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
activateTab(string $a_id)

◆ editQuestion()

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

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

307 : void
308 {
309 $ilTabs = $this->tabs;
310
311 $ilTabs->activateTab("edit_properties");
312
313 if (!$a_form) {
314 $a_form = $this->initEditForm();
315 }
316 $this->tpl->setContent($a_form->getHTML());
317 }

◆ executeCommand()

SurveyQuestionGUI::executeCommand ( )

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

103 : string
104 {
105 $cmd = $this->ctrl->getCmd();
106 $next_class = $this->ctrl->getNextClass($this);
107 switch ($next_class) {
108 default:
109 $ret = $this->$cmd();
110 break;
111 }
112 return (string) $ret;
113 }

References ILIAS\Repository\ctrl().

+ 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

◆ getPrintViewQuestionTitle()

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

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

566 : string {
567 $title = "";
568 switch ($question_title) {
570 $title = ilLegacyFormElementsUtil::prepareFormOutput($this->object->getTitle());
571 break;
572
573 #19448 get rid of showing only the label without title
574 //case 2:
575 // $title = ilUtil::prepareFormOutput($this->object->getLabel());
576 // break;
577
579 $title = ilLegacyFormElementsUtil::prepareFormOutput($this->object->getTitle());
580 if (trim($this->object->getLabel())) {
581 $title .= ' <span class="questionLabel">(' . ilLegacyFormElementsUtil::prepareFormOutput(
582 $this->object->getLabel()
583 ) . ')</span>';
584 }
585 break;
586 }
587 return $title;
588 }
static prepareFormOutput($a_str, bool $a_strip=false)

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

+ Here is the call graph for this function:

◆ getQuestionTitle()

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

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

592 : string {
593 $title = "";
594 switch ($question_title_mode) {
596 $title = $this->object->getTitle();
597 break;
598
600 $title = $this->object->getTitle();
601 if (trim($this->object->getLabel())) {
602 $title .= ' <span class="questionLabel">(' .
603 $this->object->getLabel()
604 . ')</span>';
605 }
606 break;
607 }
608 return $title;
609 }

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

+ Here is the call graph for this function:

◆ getQuestionType()

SurveyQuestionGUI::getQuestionType ( )

Returns the question type string.

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

147 : string
148 {
149 return $this->object->getQuestionType();
150 }

◆ 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

◆ importEditFormValues()

SurveyQuestionGUI::importEditFormValues ( ilPropertyFormGUI  $a_form)
abstractprotected

◆ initEditForm()

SurveyQuestionGUI::initEditForm ( )
protected

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

229 {
230 $form = new ilPropertyFormGUI();
231 $form->setFormAction($this->ctrl->getFormAction($this, "save"));
232 $form->setTitle($this->lng->txt($this->getQuestionType()));
233 $form->setMultipart(false);
234 $form->setTableWidth("100%");
235 // $form->setId("essay");
236
237 // title
238 $title = new ilTextInputGUI($this->lng->txt("title"), "title");
239 $title->setMaxLength(200);
240 $title->setRequired(true);
241 $form->addItem($title);
242
243 // label
244 $label = new ilTextInputGUI($this->lng->txt("label"), "label");
245 $label->setInfo($this->lng->txt("label_info"));
246 $title->setMaxLength(255);
247 $label->setRequired(false);
248 $form->addItem($label);
249
250 // author
251 $author = new ilTextInputGUI($this->lng->txt("author"), "author");
252 $author->setRequired(true);
253 $title->setMaxLength(100);
254 $form->addItem($author);
255
256 // description
257 $description = new ilTextInputGUI($this->lng->txt("description"), "description");
258 $description->setRequired(false);
259 $title->setMaxLength(200);
260 $form->addItem($description);
261
262 // questiontext
263 $question = new ilTextAreaInputGUI($this->lng->txt("question"), "question");
264 $question->setRequired(true);
265 $question->setRows(10);
266 $question->setCols(80);
267 if ((new \ilRTESettings($this->lng, $this->user))->getRichTextEditor() === "tinymce") {
268 $question->setUseRte(true);
269 $question->setRteTagSet("mini");
270 }
271 $question->usePurifier(true);
272 $question->setPurifier($this->purifier);
273 $form->addItem($question);
274
275 // obligatory
276 $shuffle = new ilCheckboxInputGUI($this->lng->txt("obligatory"), "obligatory");
277 $shuffle->setValue("1");
278 $shuffle->setRequired(false);
279 $form->addItem($shuffle);
280
281 $this->addFieldsToEditForm($form);
282
283 $this->addCommandButtons($form);
284
285 // values
286 $title->setValue($this->object->getTitle());
287 $label->setValue($this->object->label);
288 $author->setValue($this->object->getAuthor());
289 $description->setValue($this->object->getDescription());
290 $question->setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
291 $shuffle->setChecked($this->object->getObligatory());
292
293 return $form;
294 }
addFieldsToEditForm(ilPropertyFormGUI $a_form)
addCommandButtons(ilPropertyFormGUI $a_form)
This class represents a checkbox property in a property form.
This class represents a property form user interface.
This class represents a text area property in a property form.
This class represents a text property in a property form.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ initObject()

SurveyQuestionGUI::initObject ( )
abstractprotected

◆ originalSyncForm()

SurveyQuestionGUI::originalSyncForm ( )
protected

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

462 : void
463 {
464 $ilTabs = $this->tabs;
465
466 $ilTabs->activateTab("edit_properties");
467
468 $this->ctrl->saveParameter($this, "rtrn");
469
470 $cgui = new ilConfirmationGUI();
471 $cgui->setHeaderText($this->lng->txt("confirm_sync_questions"));
472
473 $cgui->setFormAction($this->ctrl->getFormAction($this, "confirmRemoveQuestions"));
474 $cgui->setCancel($this->lng->txt("no"), "cancelSync");
475 $cgui->setConfirm($this->lng->txt("yes"), "sync");
476
477 $this->tpl->setContent($cgui->getHTML());
478 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

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

+ Here is the call graph for this function:

◆ outQuestionText()

SurveyQuestionGUI::outQuestionText ( ilTemplate  $template)
protected

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

152 : void
153 {
154 $questiontext = $this->object->getQuestiontext();
155 if (preg_match("/^<.[\\>]?>(.*?)<\\/.[\\>]*?>$/", $questiontext, $matches)) {
156 $questiontext = $matches[1];
157 }
158 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, true));
159 if ($this->object->getObligatory()) {
160 $template->setVariable("OBLIGATORY_TEXT", ' *');
161 }
162 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544

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

+ Here is the call graph for this function:

◆ preview()

SurveyQuestionGUI::preview ( )

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

611 : void
612 {
613 $ilTabs = $this->tabs;
614
615 $ilTabs->activateTab("preview");
616
617 $tpl = new ilTemplate("tpl.il_svy_qpl_preview.html", true, true, "components/ILIAS/SurveyQuestionPool");
618
619 if ($this->object->getObligatory()) {
620 $tpl->setCurrentBlock("required");
621 $tpl->setVariable("TEXT_REQUIRED", $this->lng->txt("required_field"));
623 }
624
625 $tpl->setVariable("QUESTION_OUTPUT", $this->getWorkingForm());
626
627 $f = $this->gui->ui()->factory();
628 $r = $this->gui->ui()->renderer();
629 $p = $f->panel()->standard(
630 "",
631 $f->legacy()->content($tpl->get())
632 );
633
634 $this->tpl->setContent($r->render($p));
635 }
getWorkingForm(?array $working_data=null, int $question_title=1, bool $show_questiontext=true, string $error_message="", ?int $survey_id=null, bool $compress_view=false)
special template class to simplify handling of ITX/PEAR
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.

References Vendor\Package\$f, ILIAS\News\Common\Table\$tpl, ILIAS\UICore\GlobalTemplate\get(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), and ILIAS\UICore\GlobalTemplate\setVariable().

+ 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 500 of file class.SurveyQuestionGUI.php.

502 : void {
503 // return?
504 if ($a_return) {
505 // to calling survey
506 if ($this->parent_url) {
507 $addurl = "";
508 if ($this->request->getNewForSurvey() > 0) {
509 $addurl = "&new_id=" . $this->request->getQuestionId();
510 }
511 ilUtil::redirect(str_replace("&amp;", "&", $this->parent_url) . $addurl);
512 }
513 // to pool
514 else {
515 $this->ctrl->redirectByClass("ilObjSurveyQuestionPoolGUI", "questions");
516 }
517 }
518 // stay in form
519 else {
520 $this->ctrl->setParameterByClass(
521 $this->ctrl->getCmdClass(),
522 "q_id",
523 $this->object->getId()
524 );
525 $this->ctrl->setParameterByClass(
526 $this->ctrl->getCmdClass(),
527 "sel_question_types",
528 $this->request->getSelectedQuestionTypes()
529 );
530 $this->ctrl->setParameterByClass(
531 $this->ctrl->getCmdClass(),
532 "new_for_survey",
533 $this->request->getNewForSurvey()
534 );
535 $this->ctrl->redirectByClass($this->ctrl->getCmdClass(), "editQuestion");
536 }
537 }

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

+ Here is the call graph for this function:

◆ renderStatisticsDetailsTable()

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

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

656 : string {
657 $html = array();
658 $html[] = '<div class="ilTableOuter table-responsive">';
659 $html[] = '<table class="table table-striped">';
660
661 $html[] = "<thead>";
662 $html[] = "<tr>";
663 foreach ($a_head as $col) {
664 $col = trim($col);
665 $html[] = "<th>";
666 $html[] = ($col != "") ? $col : "&nbsp;";
667 $html[] = "</th>";
668 }
669 $html[] = "</tr>";
670 $html[] = "</thead>";
671
672 $html[] = "<tbody>";
673 foreach ($a_rows as $row) {
674 $html[] = "<tr>";
675 foreach ($row as $col) {
676 $col = trim($col);
677 $html[] = "<td>";
678 $html[] = ($col != "") ? $col : "&nbsp;";
679 $html[] = "</td>";
680 }
681 $html[] = "</tr>";
682 }
683 $html[] = "</tbody>";
684
685 if ($a_foot) {
686 $html[] = "<tfoot>";
687 $html[] = "<tr>";
688 foreach ($a_foot as $col) {
689 $col = trim($col);
690 $html[] = "<td>";
691 $html[] = ($col != "") ? $col : "&nbsp;";
692 $html[] = "</td>";
693 }
694 $html[] = "</tr>";
695 $html[] = "</tfoot>";
696 }
697
698 $html[] = "</table>";
699 $html[] = "</div>";
700 return implode("\n", $html);
701 }

◆ save()

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

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

360 : void {
361 $ilUser = $this->user;
362
363 if ($this->saveForm()) {
364 // #13784
365 if ($a_return &&
366 !SurveyQuestion::_isComplete($this->object->getId())) {
367 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("survey_error_insert_incomplete_question"));
368 $this->editQuestion();
369 return;
370 }
371
372 $ilUser->setPref("svy_lastquestiontype", $this->object->getQuestionType());
373 $ilUser->writePref("svy_lastquestiontype", $this->object->getQuestionType());
374
375 $originalexists = SurveyQuestion::_questionExists((int) $this->object->original_id);
376 $this->ctrl->setParameter($this, "q_id", $this->object->getId());
377
378 // pool question?
379 if ($a_sync) {
380 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
381 $this->ctrl->redirect($this, 'copySyncForm');
382 } elseif ($originalexists &&
383 SurveyQuestion::_isWriteable($this->object->original_id, $ilUser->getId())) {
384 // form: update original pool question, too?
385 if ($a_return) {
386 $this->ctrl->setParameter($this, 'rtrn', 1);
387 }
388 $this->ctrl->redirect($this, 'originalSyncForm');
389 }
390
391 // if we got a survey, already save in survey
392 if ($this->request->getNewForSurvey() > 0) {
393 $survey = new ilObjSurvey($this->request->getNewForSurvey());
394 $this->domain->sequence(
395 $survey->getSurveyId(),
396 $survey
397 )->appendQuestion($this->object->getId()); // will check if question is already in survey
398 }
399
400 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
401 $this->redirectAfterSaving($a_return);
402 }
403 }
editQuestion(?ilPropertyFormGUI $a_form=null)
static _isWriteable(int $question_id, int $user_id)
is question writeable by a certain user
static _questionExists(int $question_id)
static _isComplete(int $question_id)
Checks whether the question is complete or not.

References SurveyQuestion\_isComplete(), SurveyQuestion\_isWriteable(), SurveyQuestion\_questionExists(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ saveForm()

SurveyQuestionGUI::saveForm ( )
protected

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

329 : bool
330 {
331 $form = $this->initEditForm();
332 if ($form->checkInput() && $this->validateEditForm($form)) {
333 $this->object->setTitle($form->getInput("title"));
334 $this->object->label = ($form->getInput("label"));
335 $this->object->setAuthor($form->getInput("author"));
336 $this->object->setDescription($form->getInput("description"));
337
338 $this->object->setQuestiontext(
339 $this->purifier->purify($form->getInput("question"))
340 );
341
342 $this->object->setObligatory((bool) $form->getInput("obligatory"));
343
344 $this->importEditFormValues($form);
345
346 // will save both core and extended data
347 $this->object->saveToDb();
348
349 return true;
350 }
351
352 $form->setValuesByPost();
353 $this->editQuestion($form);
354 return false;
355 }
importEditFormValues(ilPropertyFormGUI $a_form)

◆ saveReturn()

SurveyQuestionGUI::saveReturn ( )
protected

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

324 : void
325 {
326 $this->save(true);
327 }
save(bool $a_return=false, bool $a_sync=false)

◆ saveSync()

SurveyQuestionGUI::saveSync ( )
protected

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

319 : void
320 {
321 $this->save($this->request->getReturn(), true);
322 }

◆ setBackUrl()

SurveyQuestionGUI::setBackUrl ( string  $a_url)

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

164 : void
165 {
166 $this->parent_url = $a_url;
167 }

◆ setQuestionTabs()

◆ setQuestionTabsForClass()

SurveyQuestionGUI::setQuestionTabsForClass ( string  $guiclass)

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

169 : void
170 {
172 $ilTabs = $this->tabs;
173
174 $this->ctrl->setParameterByClass($guiclass, "sel_question_types", $this->getQuestionType());
175 $this->ctrl->setParameterByClass(
176 $guiclass,
177 "q_id",
178 $this->request->getQuestionId()
179 );
180
181 if ($this->parent_url) {
182 $addurl = "";
183 if ($this->request->getNewForSurvey() > 0) {
184 $addurl = "&new_id=" . $this->request->getQuestionId();
185 }
186 $ilTabs->setBackTarget($this->lng->txt("menubacktosurvey"), $this->parent_url . $addurl);
187 } else {
188 $ilTabs->setBackTarget($this->lng->txt("spl"), $this->ctrl->getLinkTargetByClass("ilObjSurveyQuestionPoolGUI", "questions"));
189 }
190 if ($this->request->getQuestionId()) {
191 $ilTabs->addNonTabbedLink(
192 "preview",
193 $this->lng->txt("preview"),
194 $this->ctrl->getLinkTargetByClass($guiclass, "preview")
195 );
196 }
197
198 if ($rbacsystem->checkAccess('edit', $this->request->getRefId())) {
199 $ilTabs->addTab(
200 "edit_properties",
201 $this->lng->txt("properties"),
202 $this->ctrl->getLinkTargetByClass($guiclass, "editQuestion")
203 );
204
205 if (stripos($guiclass, "matrix") !== false) {
206 $ilTabs->addTab(
207 "layout",
208 $this->lng->txt("layout"),
209 $this->ctrl->getLinkTargetByClass($guiclass, "layout")
210 );
211 }
212 }
213
214 if ($this->object->getId() > 0) {
215 $title = $this->lng->txt("edit") . " &quot;" . $this->object->getTitle() . "&quot";
216 } else {
217 $title = $this->lng->txt("create_new") . " " . $this->lng->txt($this->getQuestionType());
218 }
219
220 $this->tpl->setVariable("HEADER", $title);
221 }
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 ...

References ilRbacSystem\checkAccess(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

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

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

◆ sync()

SurveyQuestionGUI::sync ( )
protected

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

480 : void
481 {
482 $original_id = $this->object->original_id;
483 if ($original_id) {
484 $this->object->syncWithOriginal();
485 }
486
487 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
488 $this->redirectAfterSaving($this->request->getReturn());
489 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ syncCopies()

SurveyQuestionGUI::syncCopies ( )
protected

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

416 : void
417 {
419 $ilAccess = $this->access;
420
421 $qids = $this->request->getQuestionIds();
422 if (count($qids) === 0) {
423 $this->tpl->setOnScreenMessage('failure', $lng->txt("select_one"));
424 $this->copySyncForm();
425 return;
426 }
427
428 foreach ($this->object->getCopyIds(true) as $survey_id => $questions) {
429 // check permissions for "parent" survey
430 $can_write = false;
431 $ref_ids = ilObject::_getAllReferences($survey_id);
432 foreach ($ref_ids as $ref_id) {
433 if ($ilAccess->checkAccess("edit", "", $ref_id)) {
434 $can_write = true;
435 break;
436 }
437 }
438
439 if ($can_write) {
440 foreach ($questions as $qid) {
441 if (in_array($qid, $qids)) {
442 $id = $this->object->getId();
443
444 $this->object->setId($qid);
445 $this->object->setOriginalId($id);
446 $this->object->saveToDb();
447
448 $this->object->setId($id);
449 $this->object->setOriginalId(null);
450
451 // see: SurveyQuestion::syncWithOriginal()
452 // what about material?
453 }
454 }
455 }
456 }
457
458 $this->tpl->setOnScreenMessage('success', $lng->txt("survey_sync_success"), true);
459 $this->redirectAfterSaving($this->request->getReturn());
460 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
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

References $id, $lng, ilObject\_getAllReferences(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ validateEditForm()

SurveyQuestionGUI::validateEditForm ( ilPropertyFormGUI  $a_form)
protected

Reimplemented in SurveyMultipleChoiceQuestionGUI.

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

548 : bool
549 {
550 return true;
551 }

Field Documentation

◆ $access

ilAccessHandler SurveyQuestionGUI::$access
protected

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

◆ $ctrl

ilCtrl SurveyQuestionGUI::$ctrl
protected

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

◆ $cumulated

array SurveyQuestionGUI::$cumulated = []
protected

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

◆ $domain

ILIAS Survey InternalDomainService SurveyQuestionGUI::$domain
protected

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

◆ $edit_manager

EditManager SurveyQuestionGUI::$edit_manager
protected

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

◆ $gui

ILIAS Survey InternalGUIService SurveyQuestionGUI::$gui
protected

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

◆ $lng

ilLanguage SurveyQuestionGUI::$lng
protected

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

Referenced by __construct().

◆ $log

ilLogger SurveyQuestionGUI::$log
protected

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

◆ $object

SurveyQuestion SurveyQuestionGUI::$object = null

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

◆ $parent_url

string SurveyQuestionGUI::$parent_url = ""
protected

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

◆ $purifier

ilHtmlPurifierInterface SurveyQuestionGUI::$purifier
protected

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

◆ $rbacsystem

ilRbacSystem SurveyQuestionGUI::$rbacsystem
protected

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

◆ $request

EditingGUIRequest SurveyQuestionGUI::$request
protected

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

◆ $tabs

ilTabsGUI SurveyQuestionGUI::$tabs
protected

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

◆ $toolbar

ilToolbarGUI SurveyQuestionGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface SurveyQuestionGUI::$tpl
protected

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

Referenced by __construct().

◆ $tree

ilTree SurveyQuestionGUI::$tree
protected

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

◆ $user

ilObjUser SurveyQuestionGUI::$user
protected

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


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