ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjQuestionPoolSettingsGeneralGUI Class Reference
+ Collaboration diagram for ilObjQuestionPoolSettingsGeneralGUI:

Public Member Functions

 __construct (ilCtrl $ctrl, ilAccessHandler $access, ilLanguage $lng, ilGlobalTemplateInterface $tpl, ilTabsGUI $tabs, ilObjQuestionPoolGUI $poolGUI)
 Constructor. More...
 
 executeCommand ()
 Command Execution. More...
 

Data Fields

const CMD_SHOW_FORM = 'showForm'
 command constants More...
 
const CMD_SAVE_FORM = 'saveForm'
 

Protected Member Functions

 formPropertyExists (ilPropertyFormGUI $form, $propertyId)
 

Protected Attributes

 $ctrl = null
 
 $access = null
 
 $lng = null
 
 $tpl = null
 
 $tabs = null
 
 $poolGUI = null
 
 $poolOBJ = null
 

Private Member Functions

 showFormCmd (ilPropertyFormGUI $form=null)
 
 saveFormCmd ()
 
 performSaveForm (ilPropertyFormGUI $form)
 
 buildForm ()
 
 getTaxonomySelectInputOptions ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjQuestionPoolSettingsGeneralGUI::__construct ( ilCtrl  $ctrl,
ilAccessHandler  $access,
ilLanguage  $lng,
ilGlobalTemplateInterface  $tpl,
ilTabsGUI  $tabs,
ilObjQuestionPoolGUI  $poolGUI 
)

Member Function Documentation

◆ buildForm()

ilObjQuestionPoolSettingsGeneralGUI::buildForm ( )
private

Definition at line 212 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

References $DIC, ILIAS\Repository\ctrl(), ilMD\getGeneral(), getTaxonomySelectInputOptions(), ilObjQuestionPool\isSkillManagementGloballyActivated(), ILIAS\Repository\lng(), ilCheckboxInputGUI\setChecked(), ilTextAreaInputGUI\setCols(), and ilFormPropertyGUI\setInfo().

Referenced by saveFormCmd(), and showFormCmd().

213  {
214  global $DIC; /* @var \ILIAS\DI\Container $DIC */
215 
216  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
217  $form = new ilPropertyFormGUI();
218 
219  $form->setFormAction($this->ctrl->getFormAction($this));
220  $form->addCommandButton(self::CMD_SAVE_FORM, $this->lng->txt('save'));
221 
222  $form->setTitle($this->lng->txt('qpl_form_general_settings'));
223  $form->setId('properties');
224 
225  include_once 'Services/MetaData/classes/class.ilMD.php';
226  $md_obj = new ilMD($this->poolOBJ->getId(), 0, "qpl");
227  $md_section = $md_obj->getGeneral();
228 
229  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
230  $title->setRequired(true);
231  $title->setMaxLength(255);
232  $title->setValue($md_section->getTitle());
233  $form->addItem($title);
234 
235  $ids = $md_section->getDescriptionIds();
236  if ($ids) {
237  $desc_obj = $md_section->getDescription(array_pop($ids));
238 
239  $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "description");
240  $desc->setCols(50);
241  $desc->setRows(4);
242  $desc->setValue($desc_obj->getDescription());
243  $form->addItem($desc);
244  }
245 
246  // online
247 
248  $online = new ilCheckboxInputGUI($this->lng->txt('qpl_settings_general_form_property_online'), 'online');
249  $online->setInfo($this->lng->txt('qpl_settings_general_form_property_online_description'));
250  $online->setChecked($this->poolOBJ->getOnline());
251  $form->addItem($online);
252 
253  // show taxonomies
254 
255  $showTax = new ilCheckboxInputGUI($this->lng->txt('qpl_settings_general_form_property_show_taxonomies'), 'show_taxonomies');
256  $showTax->setInfo($this->lng->txt('qpl_settings_general_form_prop_show_tax_desc'));
257  $showTax->setChecked($this->poolOBJ->getShowTaxonomies());
258  $form->addItem($showTax);
259 
260  $taxSelectOptions = $this->getTaxonomySelectInputOptions();
261 
262  // pool navigation taxonomy
263 
264  $navTax = new ilSelectInputGUI($this->lng->txt('qpl_settings_general_form_property_nav_taxonomy'), 'nav_taxonomy');
265  $navTax->setInfo($this->lng->txt('qpl_settings_general_form_property_nav_taxonomy_description'));
266  $navTax->setValue($this->poolOBJ->getNavTaxonomyId());
267  $navTax->setOptions($taxSelectOptions);
268  $showTax->addSubItem($navTax);
269 
270  $section = new ilFormSectionHeaderGUI();
271  $section->setTitle($this->lng->txt('tst_presentation_settings_section'));
272  $form->addItem($section);
273 
274  $DIC->object()->commonSettings()->legacyForm($form, $this->poolOBJ)->addTileImage();
275 
276  // skill service activation
277 
279  $otherHead = new ilFormSectionHeaderGUI();
280  $otherHead->setTitle($this->lng->txt('obj_features'));
281  $form->addItem($otherHead);
282 
283  $skillService = new ilCheckboxInputGUI($this->lng->txt('tst_activate_skill_service'), 'skill_service');
284  $skillService->setChecked($this->poolOBJ->isSkillServiceEnabled());
285  $form->addItem($skillService);
286  }
287 
288  return $form;
289  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a checkbox property in a property form.
global $DIC
Definition: feed.php:28
This class represents a text area property in a property form.
getGeneral()
Definition: class.ilMD.php:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilObjQuestionPoolSettingsGeneralGUI::executeCommand ( )

Command Execution.

Definition at line 105 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

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

105  : void
106  {
107  // allow only write access
108 
109  if (!$this->access->checkAccess('write', '', $this->poolGUI->getRefId())) {
110  $this->tpl->setOnScreenMessage('info', $this->lng->txt('cannot_edit_question_pool'), true);
111  $this->ctrl->redirectByClass('ilObjQuestionPoolGUI', 'infoScreen');
112  }
113 
114  // activate corresponding tab (auto activation does not work in ilObjTestGUI-Tabs-Salad)
115 
116  $this->tabs->activateTab('settings');
117  $this->tabs->activateSubTab('qpl_settings_subtab_general');
118 
119  // process command
120 
121  $nextClass = $this->ctrl->getNextClass();
122 
123  switch ($nextClass) {
124  default:
125  $cmd = $this->ctrl->getCmd(self::CMD_SHOW_FORM) . 'Cmd';
126  $this->$cmd();
127  }
128  }
+ Here is the call graph for this function:

◆ formPropertyExists()

ilObjQuestionPoolSettingsGeneralGUI::formPropertyExists ( ilPropertyFormGUI  $form,
  $propertyId 
)
protected

Definition at line 304 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

References ilPropertyFormGUI\getItemByPostVar().

Referenced by performSaveForm().

304  : bool
305  {
306  return $form->getItemByPostVar($propertyId) instanceof ilFormPropertyGUI;
307  }
getItemByPostVar(string $a_post_var)
This class represents a property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTaxonomySelectInputOptions()

ilObjQuestionPoolSettingsGeneralGUI::getTaxonomySelectInputOptions ( )
private

Definition at line 291 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

References ilObject\_lookupTitle(), and ILIAS\Repository\lng().

Referenced by buildForm().

291  : array
292  {
293  $taxSelectOptions = array(
294  '0' => $this->lng->txt('qpl_settings_general_form_property_opt_notax_selected')
295  );
296 
297  foreach ($this->poolOBJ->getTaxonomyIds() as $taxId) {
298  $taxSelectOptions[$taxId] = ilObject::_lookupTitle($taxId);
299  }
300 
301  return $taxSelectOptions;
302  }
static _lookupTitle(int $obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performSaveForm()

ilObjQuestionPoolSettingsGeneralGUI::performSaveForm ( ilPropertyFormGUI  $form)
private

Definition at line 165 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

References $DIC, formPropertyExists(), ilMD\getGeneral(), ilPropertyFormGUI\getItemByPostVar(), ilMDBase\save(), and ilMDBase\update().

Referenced by saveFormCmd().

165  : void
166  {
167  global $DIC; /* @var \ILIAS\DI\Container $DIC */
168 
169  include_once 'Services/MetaData/classes/class.ilMD.php';
170  $md_obj = new ilMD($this->poolOBJ->getId(), 0, "qpl");
171  $md_section = $md_obj->getGeneral();
172 
173  // title
174  $md_section->setTitle($form->getItemByPostVar('title')->getValue());
175  $md_section->update();
176 
177  // Description
178  $md_desc_ids = $md_section->getDescriptionIds();
179  if ($md_desc_ids) {
180  $md_desc = $md_section->getDescription(array_pop($md_desc_ids));
181  $md_desc->setDescription($form->getItemByPostVar('description')->getValue());
182  $md_desc->update();
183  } else {
184  $md_desc = $md_section->addDescription();
185  $md_desc->setDescription($form->getItemByPostVar('description')->getValue());
186  $md_desc->save();
187  }
188 
189  $this->poolOBJ->setTitle($form->getItemByPostVar('title')->getValue());
190  $this->poolOBJ->setDescription($form->getItemByPostVar('description')->getValue());
191  $this->poolOBJ->update();
192 
193  $online = $form->getItemByPostVar('online');
194  $this->poolOBJ->setOnline($online->getChecked());
195 
196  $showTax = $form->getItemByPostVar('show_taxonomies');
197  $this->poolOBJ->setShowTaxonomies($showTax->getChecked());
198 
199  $navTax = $form->getItemByPostVar('nav_taxonomy');
200  $this->poolOBJ->setNavTaxonomyId($navTax->getValue());
201 
202  $DIC->object()->commonSettings()->legacyForm($form, $this->poolOBJ)->saveTileImage();
203 
204  if ($this->formPropertyExists($form, 'skill_service')) {
205  $skillService = $form->getItemByPostVar('skill_service');
206  $this->poolOBJ->setSkillServiceEnabled($skillService->getChecked());
207  }
208 
209  $this->poolOBJ->saveToDb();
210  }
getItemByPostVar(string $a_post_var)
global $DIC
Definition: feed.php:28
getGeneral()
Definition: class.ilMD.php:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveFormCmd()

ilObjQuestionPoolSettingsGeneralGUI::saveFormCmd ( )
private

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

References $errors, buildForm(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), performSaveForm(), and showFormCmd().

139  : void
140  {
141  $form = $this->buildForm();
142 
143  // form validation and initialisation
144 
145  $errors = !$form->checkInput(); // ALWAYS CALL BEFORE setValuesByPost()
146  $form->setValuesByPost(); // NEVER CALL THIS BEFORE checkInput()
147 
148  // return to form when any form validation errors exist
149 
150  if ($errors) {
151  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_input_not_valid'));
152  $this->showFormCmd($form);
153  }
154 
155  // perform saving the form data
156 
157  $this->performSaveForm($form);
158 
159  // redirect to form output
160 
161  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
162  $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
163  }
$errors
Definition: imgupload.php:65
+ Here is the call graph for this function:

◆ showFormCmd()

ilObjQuestionPoolSettingsGeneralGUI::showFormCmd ( ilPropertyFormGUI  $form = null)
private

Definition at line 130 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

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

Referenced by saveFormCmd().

130  : void
131  {
132  if ($form === null) {
133  $form = $this->buildForm();
134  }
135 
136  $this->tpl->setContent($this->ctrl->getHTML($form));
137  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilObjQuestionPoolSettingsGeneralGUI::$access = null
protected

Definition at line 50 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

Referenced by __construct().

◆ $ctrl

ilObjQuestionPoolSettingsGeneralGUI::$ctrl = null
protected

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

Referenced by __construct().

◆ $lng

ilObjQuestionPoolSettingsGeneralGUI::$lng = null
protected

Definition at line 57 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

Referenced by __construct().

◆ $poolGUI

ilObjQuestionPoolSettingsGeneralGUI::$poolGUI = null
protected

Definition at line 78 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

Referenced by __construct().

◆ $poolOBJ

ilObjQuestionPoolSettingsGeneralGUI::$poolOBJ = null
protected

◆ $tabs

ilObjQuestionPoolSettingsGeneralGUI::$tabs = null
protected

Definition at line 71 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

Referenced by __construct().

◆ $tpl

ilObjQuestionPoolSettingsGeneralGUI::$tpl = null
protected

Definition at line 64 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

Referenced by __construct().

◆ CMD_SAVE_FORM

const ilObjQuestionPoolSettingsGeneralGUI::CMD_SAVE_FORM = 'saveForm'

◆ CMD_SHOW_FORM

const ilObjQuestionPoolSettingsGeneralGUI::CMD_SHOW_FORM = 'showForm'

command constants

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


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