ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjQuestionPoolSettingsGeneralGUI Class Reference
+ Collaboration diagram for ilObjQuestionPoolSettingsGeneralGUI:

Public Member Functions

 __construct (ilCtrl $ctrl, ilAccessHandler $access, ilLanguage $lng, ilTemplate $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,
ilTemplate  $tpl,
ilTabsGUI  $tabs,
ilObjQuestionPoolGUI  $poolGUI 
)

Member Function Documentation

◆ buildForm()

ilObjQuestionPoolSettingsGeneralGUI::buildForm ( )
private

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

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

Referenced by saveFormCmd(), and showFormCmd().

193  {
194  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
195  $form = new ilPropertyFormGUI();
196 
197  $form->setFormAction($this->ctrl->getFormAction($this));
198  $form->addCommandButton(self::CMD_SAVE_FORM, $this->lng->txt('save'));
199 
200  $form->setTitle($this->lng->txt('qpl_form_general_settings'));
201  $form->setId('properties');
202 
203  include_once 'Services/MetaData/classes/class.ilMD.php';
204  $md_obj = new ilMD($this->poolOBJ->getId(), 0, "qpl");
205  $md_section = $md_obj->getGeneral();
206 
207  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
208  $title->setRequired(true);
209  $title->setValue($md_section->getTitle());
210  $form->addItem($title);
211 
212  $ids = $md_section->getDescriptionIds();
213  if ($ids) {
214  $desc_obj = $md_section->getDescription(array_pop($ids));
215 
216  $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "description");
217  $desc->setCols(50);
218  $desc->setRows(4);
219  $desc->setValue($desc_obj->getDescription());
220  $form->addItem($desc);
221  }
222 
223  // online
224 
225  $online = new ilCheckboxInputGUI($this->lng->txt('qpl_settings_general_form_property_online'), 'online');
226  $online->setInfo($this->lng->txt('qpl_settings_general_form_property_online_description'));
227  $online->setChecked($this->poolOBJ->getOnline());
228  $form->addItem($online);
229 
230  // show taxonomies
231 
232  $showTax = new ilCheckboxInputGUI($this->lng->txt('qpl_settings_general_form_property_show_taxonomies'), 'show_taxonomies');
233  $showTax->setInfo($this->lng->txt('qpl_settings_general_form_prop_show_tax_desc'));
234  $showTax->setChecked($this->poolOBJ->getShowTaxonomies());
235  $form->addItem($showTax);
236 
237  $taxSelectOptions = $this->getTaxonomySelectInputOptions();
238 
239  // pool navigation taxonomy
240 
241  $navTax = new ilSelectInputGUI($this->lng->txt('qpl_settings_general_form_property_nav_taxonomy'), 'nav_taxonomy');
242  $navTax->setInfo($this->lng->txt('qpl_settings_general_form_property_nav_taxonomy_description'));
243  $navTax->setValue($this->poolOBJ->getNavTaxonomyId());
244  $navTax->setOptions($taxSelectOptions);
245  $showTax->addSubItem($navTax);
246 
247  // skill service activation
248 
250  $skillService = new ilCheckboxInputGUI($this->lng->txt('tst_activate_skill_service'), 'skill_service');
251  $skillService->setChecked($this->poolOBJ->isSkillServiceEnabled());
252  $form->addItem($skillService);
253  }
254 
255  return $form;
256  }
This class represents a selection list property in a property form.
This class represents a property form user interface.
This class represents a checkbox property in a property form.
setInfo($a_info)
Set Information Text.
setChecked($a_checked)
Set Checked.
if(isset($_POST['submit'])) $form
This class represents a text property in a property form.
& 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 271 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

References ilPropertyFormGUI\getItemByPostVar().

Referenced by performSaveForm().

272  {
273  return $form->getItemByPostVar($propertyId) instanceof ilFormPropertyGUI;
274  }
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 258 of file class.ilObjQuestionPoolSettingsGeneralGUI.php.

References ilObject\_lookupTitle(), and array.

Referenced by buildForm().

259  {
260  $taxSelectOptions = array(
261  '0' => $this->lng->txt('qpl_settings_general_form_property_opt_notax_selected')
262  );
263 
264  foreach ($this->poolOBJ->getTaxonomyIds() as $taxId) {
265  $taxSelectOptions[$taxId] = ilObject::_lookupTitle($taxId);
266  }
267 
268  return $taxSelectOptions;
269  }
static _lookupTitle($a_id)
lookup object title
Create styles array
The data for the language used.
+ 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 formPropertyExists(), ilMD\getGeneral(), ilPropertyFormGUI\getItemByPostVar(), ilMDBase\save(), and ilMDBase\update().

Referenced by saveFormCmd().

150  {
151  include_once 'Services/MetaData/classes/class.ilMD.php';
152  $md_obj = new ilMD($this->poolOBJ->getId(), 0, "qpl");
153  $md_section = $md_obj->getGeneral();
154 
155  // title
156  $md_section->setTitle($form->getItemByPostVar('title')->getValue());
157  $md_section->update();
158 
159  // Description
160  $md_desc_ids = $md_section->getDescriptionIds();
161  if ($md_desc_ids) {
162  $md_desc = $md_section->getDescription(array_pop($md_desc_ids));
163  $md_desc->setDescription($form->getItemByPostVar('description')->getValue());
164  $md_desc->update();
165  } else {
166  $md_desc = $md_section->addDescription();
167  $md_desc->setDescription($form->getItemByPostVar('description')->getValue());
168  $md_desc->save();
169  }
170 
171  $this->poolOBJ->setTitle($form->getItemByPostVar('title')->getValue());
172  $this->poolOBJ->setDescription($form->getItemByPostVar('description')->getValue());
173  $this->poolOBJ->update();
174 
175  $online = $form->getItemByPostVar('online');
176  $this->poolOBJ->setOnline($online->getChecked());
177 
178  $showTax = $form->getItemByPostVar('show_taxonomies');
179  $this->poolOBJ->setShowTaxonomies($showTax->getChecked());
180 
181  $navTax = $form->getItemByPostVar('nav_taxonomy');
182  $this->poolOBJ->setNavTaxonomyId($navTax->getValue());
183 
184  if ($this->formPropertyExists($form, 'skill_service')) {
185  $skillService = $form->getItemByPostVar('skill_service');
186  $this->poolOBJ->setSkillServiceEnabled($skillService->getChecked());
187  }
188 
189  $this->poolOBJ->saveToDb();
190  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
& 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, $form, buildForm(), performSaveForm(), ilUtil\sendFailure(), ilUtil\sendSuccess(), 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  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
if(isset($_POST['submit'])) $form
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$errors
Definition: index.php:6
+ 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 $form, and 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: