ILIAS  release_7 Revision v7.30-3-g800a261c036
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()

Member Function Documentation

◆ buildForm()

ilObjQuestionPoolSettingsGeneralGUI::buildForm ( )
private

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

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

Referenced by saveFormCmd(), and showFormCmd().

197  {
198  global $DIC; /* @var \ILIAS\DI\Container $DIC */
199 
200  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
201  $form = new ilPropertyFormGUI();
202 
203  $form->setFormAction($this->ctrl->getFormAction($this));
204  $form->addCommandButton(self::CMD_SAVE_FORM, $this->lng->txt('save'));
205 
206  $form->setTitle($this->lng->txt('qpl_form_general_settings'));
207  $form->setId('properties');
208 
209  include_once 'Services/MetaData/classes/class.ilMD.php';
210  $md_obj = new ilMD($this->poolOBJ->getId(), 0, "qpl");
211  $md_section = $md_obj->getGeneral();
212 
213  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
214  $title->setRequired(true);
215  $title->setValue($md_section->getTitle());
216  $form->addItem($title);
217 
218  $ids = $md_section->getDescriptionIds();
219  if ($ids) {
220  $desc_obj = $md_section->getDescription(array_pop($ids));
221 
222  $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "description");
223  $desc->setCols(50);
224  $desc->setRows(4);
225  $desc->setValue($desc_obj->getDescription());
226  $form->addItem($desc);
227  }
228 
229  // online
230 
231  $online = new ilCheckboxInputGUI($this->lng->txt('qpl_settings_general_form_property_online'), 'online');
232  $online->setInfo($this->lng->txt('qpl_settings_general_form_property_online_description'));
233  $online->setChecked($this->poolOBJ->getOnline());
234  $form->addItem($online);
235 
236  // show taxonomies
237 
238  $showTax = new ilCheckboxInputGUI($this->lng->txt('qpl_settings_general_form_property_show_taxonomies'), 'show_taxonomies');
239  $showTax->setInfo($this->lng->txt('qpl_settings_general_form_prop_show_tax_desc'));
240  $showTax->setChecked($this->poolOBJ->getShowTaxonomies());
241  $form->addItem($showTax);
242 
243  $taxSelectOptions = $this->getTaxonomySelectInputOptions();
244 
245  // pool navigation taxonomy
246 
247  $navTax = new ilSelectInputGUI($this->lng->txt('qpl_settings_general_form_property_nav_taxonomy'), 'nav_taxonomy');
248  $navTax->setInfo($this->lng->txt('qpl_settings_general_form_property_nav_taxonomy_description'));
249  $navTax->setValue($this->poolOBJ->getNavTaxonomyId());
250  $navTax->setOptions($taxSelectOptions);
251  $showTax->addSubItem($navTax);
252 
254  $section->setTitle($this->lng->txt('tst_presentation_settings_section'));
255  $form->addItem($section);
256 
257  $DIC->object()->commonSettings()->legacyForm($form, $this->poolOBJ)->addTileImage();
258 
259  // skill service activation
260 
262  $otherHead = new ilFormSectionHeaderGUI();
263  $otherHead->setTitle($this->lng->txt('obj_features'));
264  $form->addItem($otherHead);
265 
266  $skillService = new ilCheckboxInputGUI($this->lng->txt('tst_activate_skill_service'), 'skill_service');
267  $skillService->setChecked($this->poolOBJ->isSkillServiceEnabled());
268  $form->addItem($skillService);
269  }
270 
271  return $form;
272  }
This class represents a property form user interface.
This class represents a section header in a property form.
This class represents a checkbox property in a property form.
setInfo($a_info)
Set Information Text.
$section
Definition: Utf8Test.php:83
setChecked($a_checked)
Set Checked.
global $DIC
Definition: goto.php:24
& getGeneral()
Definition: class.ilMD.php:40
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:

◆ executeCommand()

ilObjQuestionPoolSettingsGeneralGUI::executeCommand ( )

Command Execution.

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

References ilUtil\sendInfo().

91  {
92  // allow only write access
93 
94  if (!$this->access->checkAccess('write', '', $this->poolGUI->ref_id)) {
95  ilUtil::sendInfo($this->lng->txt('cannot_edit_question_pool'), true);
96  $this->ctrl->redirectByClass('ilObjQuestionPoolGUI', 'infoScreen');
97  }
98 
99  // activate corresponding tab (auto activation does not work in ilObjTestGUI-Tabs-Salad)
100 
101  $this->tabs->activateTab('settings');
102 
103  // process command
104 
105  $nextClass = $this->ctrl->getNextClass();
106 
107  switch ($nextClass) {
108  default:
109  $cmd = $this->ctrl->getCmd(self::CMD_SHOW_FORM) . 'Cmd';
110  $this->$cmd();
111  }
112  }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
+ Here is the call graph for this function:

◆ formPropertyExists()

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

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

References ilPropertyFormGUI\getItemByPostVar().

Referenced by performSaveForm().

288  {
289  return $form->getItemByPostVar($propertyId) instanceof ilFormPropertyGUI;
290  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
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 274 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

References ilObject\_lookupTitle().

Referenced by buildForm().

275  {
276  $taxSelectOptions = array(
277  '0' => $this->lng->txt('qpl_settings_general_form_property_opt_notax_selected')
278  );
279 
280  foreach ($this->poolOBJ->getTaxonomyIds() as $taxId) {
281  $taxSelectOptions[$taxId] = ilObject::_lookupTitle($taxId);
282  }
283 
284  return $taxSelectOptions;
285  }
static _lookupTitle($a_id)
lookup object title
+ 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 149 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

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

Referenced by saveFormCmd().

150  {
151  global $DIC; /* @var \ILIAS\DI\Container $DIC */
152 
153  include_once 'Services/MetaData/classes/class.ilMD.php';
154  $md_obj = new ilMD($this->poolOBJ->getId(), 0, "qpl");
155  $md_section = $md_obj->getGeneral();
156 
157  // title
158  $md_section->setTitle($form->getItemByPostVar('title')->getValue());
159  $md_section->update();
160 
161  // Description
162  $md_desc_ids = $md_section->getDescriptionIds();
163  if ($md_desc_ids) {
164  $md_desc = $md_section->getDescription(array_pop($md_desc_ids));
165  $md_desc->setDescription($form->getItemByPostVar('description')->getValue());
166  $md_desc->update();
167  } else {
168  $md_desc = $md_section->addDescription();
169  $md_desc->setDescription($form->getItemByPostVar('description')->getValue());
170  $md_desc->save();
171  }
172 
173  $this->poolOBJ->setTitle($form->getItemByPostVar('title')->getValue());
174  $this->poolOBJ->setDescription($form->getItemByPostVar('description')->getValue());
175  $this->poolOBJ->update();
176 
177  $online = $form->getItemByPostVar('online');
178  $this->poolOBJ->setOnline($online->getChecked());
179 
180  $showTax = $form->getItemByPostVar('show_taxonomies');
181  $this->poolOBJ->setShowTaxonomies($showTax->getChecked());
182 
183  $navTax = $form->getItemByPostVar('nav_taxonomy');
184  $this->poolOBJ->setNavTaxonomyId($navTax->getValue());
185 
186  $DIC->object()->commonSettings()->legacyForm($form, $this->poolOBJ)->saveTileImage();
187 
188  if ($this->formPropertyExists($form, 'skill_service')) {
189  $skillService = $form->getItemByPostVar('skill_service');
190  $this->poolOBJ->setSkillServiceEnabled($skillService->getChecked());
191  }
192 
193  $this->poolOBJ->saveToDb();
194  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
global $DIC
Definition: goto.php:24
& getGeneral()
Definition: class.ilMD.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveFormCmd()

ilObjQuestionPoolSettingsGeneralGUI::saveFormCmd ( )
private

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

References $errors, buildForm(), performSaveForm(), ilUtil\sendFailure(), and showFormCmd().

124  {
125  $form = $this->buildForm();
126 
127  // form validation and initialisation
128 
129  $errors = !$form->checkInput(); // ALWAYS CALL BEFORE setValuesByPost()
130  $form->setValuesByPost(); // NEVER CALL THIS BEFORE checkInput()
131 
132  // return to form when any form validation errors exist
133 
134  if ($errors) {
135  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
136  return $this->showFormCmd($form);
137  }
138 
139  // perform saving the form data
140 
141  $this->performSaveForm($form);
142 
143  // redirect to form output
144 
145  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
146  $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
147  }
$errors
Definition: imgupload.php:49
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ showFormCmd()

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

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

References buildForm().

Referenced by saveFormCmd().

115  {
116  if ($form === null) {
117  $form = $this->buildForm();
118  }
119 
120  $this->tpl->setContent($this->ctrl->getHTML($form));
121  }
+ 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 35 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

Referenced by __construct().

◆ $ctrl

ilObjQuestionPoolSettingsGeneralGUI::$ctrl = null
protected

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

Referenced by __construct().

◆ $lng

ilObjQuestionPoolSettingsGeneralGUI::$lng = null
protected

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

Referenced by __construct().

◆ $poolGUI

ilObjQuestionPoolSettingsGeneralGUI::$poolGUI = null
protected

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

Referenced by __construct().

◆ $poolOBJ

ilObjQuestionPoolSettingsGeneralGUI::$poolOBJ = null
protected

◆ $tabs

ilObjQuestionPoolSettingsGeneralGUI::$tabs = null
protected

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

Referenced by __construct().

◆ $tpl

ilObjQuestionPoolSettingsGeneralGUI::$tpl = null
protected

Definition at line 49 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 20 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.


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