ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilExcCriteriaGUI Class Reference

Class ilExcCriteriaGUI. More...

+ Collaboration diagram for ilExcCriteriaGUI:

Public Member Functions

 __construct (int $a_cat_id)
 
 executeCommand ()
 

Protected Member Functions

 view ()
 
 saveOrder ()
 
 confirmDeletion ()
 
 delete ()
 
 initForm (ilExcCriteria $a_crit_obj)
 
 add (?ilPropertyFormGUI $a_form=null)
 
 exportForm (ilExcCriteria $a_crit_obj, ilPropertyFormGUI $a_form)
 
 importForm (ilExcCriteria $a_crit_obj)
 
 create ()
 
 getCurrentCritera ()
 
 edit (?ilPropertyFormGUI $a_form=null)
 
 update ()
 

Protected Attributes

ILIAS Exercise InternalGUIService $gui
 
ilCtrl $ctrl
 
ilToolbarGUI $toolbar
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
int $cat_id
 
GUIRequest $request
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilExcCriteriaGUI::__construct ( int  $a_cat_id)

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

References $DIC, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

39  {
40  global $DIC;
41 
42  $this->ctrl = $DIC->ctrl();
43  $this->toolbar = $DIC->toolbar();
44  $this->lng = $DIC->language();
45  $this->tpl = $DIC["tpl"];
46  $this->cat_id = $a_cat_id;
47  $this->request = $DIC->exercise()->internal()->gui()->request();
48  $this->gui = $DIC->exercise()->internal()->gui();
49  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ add()

ilExcCriteriaGUI::add ( ?ilPropertyFormGUI  $a_form = null)
protected

Definition at line 205 of file class.ilExcCriteriaGUI.php.

References $ctrl, $tpl, ilExcCriteria\getInstanceByType(), initForm(), ilCtrl\redirect(), and ILIAS\UICore\GlobalTemplate\setContent().

205  : void
206  {
207  $tpl = $this->tpl;
208  $ilCtrl = $this->ctrl;
209 
210  $new_type = $this->request->getCriteriaType();
211  if (!$new_type) {
212  $ilCtrl->redirect($this, "view");
213  }
214 
215  $ilCtrl->setParameter($this, "type", $new_type);
216 
217  if (!$a_form) {
218  $crit_obj = ilExcCriteria::getInstanceByType($new_type);
219  $a_form = $this->initForm($crit_obj);
220  }
221 
222  $tpl->setContent($a_form->getHTML());
223  }
setContent(string $a_html)
Sets content for standard template.
static getInstanceByType(string $a_type)
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
initForm(ilExcCriteria $a_crit_obj)
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:

◆ confirmDeletion()

ilExcCriteriaGUI::confirmDeletion ( )
protected

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

References $ctrl, $lng, $tpl, ilExcCriteria\getInstancesByParentId(), ILIAS\UICore\GlobalTemplate\setContent(), ILIAS\UICore\GlobalTemplate\setOnScreenMessage(), and ilLanguage\txt().

114  : void
115  {
116  $ilCtrl = $this->ctrl;
117  $lng = $this->lng;
118  $tpl = $this->tpl;
119 
120  $ids = $this->request->getCriteriaIds();
121  if (count($ids) == 0) {
122  $this->tpl->setOnScreenMessage('info', $lng->txt("select_one"), true);
123  $ilCtrl->redirect($this, "view");
124  }
125 
126  $confirmation_gui = new ilConfirmationGUI();
127  $confirmation_gui->setFormAction($ilCtrl->getFormAction($this, "delete"));
128  $confirmation_gui->setHeaderText($lng->txt("exc_criteria_deletion_confirmation"));
129  $confirmation_gui->setCancel($lng->txt("cancel"), "view");
130  $confirmation_gui->setConfirm($lng->txt("delete"), "delete");
131 
132  foreach (ilExcCriteria::getInstancesByParentId($this->cat_id) as $item) {
133  if (in_array($item->getId(), $ids)) {
134  $confirmation_gui->addItem("id[]", $item->getId(), $item->getTitle());
135  }
136  }
137 
138  $tpl->setContent($confirmation_gui->getHTML());
139  }
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
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 getInstancesByParentId(int $a_parent_id)
setContent(string $a_html)
Sets content for standard template.
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:

◆ create()

ilExcCriteriaGUI::create ( )
protected

Definition at line 267 of file class.ilExcCriteriaGUI.php.

References $ctrl, ilExcCriteria\getInstanceByType(), importForm(), and ilCtrl\redirect().

267  : void
268  {
269  $ilCtrl = $this->ctrl;
270 
271  $new_type = $this->request->getCriteriaType();
272  if (!$new_type) {
273  $ilCtrl->redirect($this, "view");
274  }
275 
276  $crit_obj = ilExcCriteria::getInstanceByType($new_type);
277  $this->importForm($crit_obj);
278  }
static getInstanceByType(string $a_type)
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
importForm(ilExcCriteria $a_crit_obj)
+ Here is the call graph for this function:

◆ delete()

ilExcCriteriaGUI::delete ( )
protected

Definition at line 141 of file class.ilExcCriteriaGUI.php.

References $ctrl, $lng, ilExcCriteria\getInstancesByParentId(), and ilLanguage\txt().

141  : void
142  {
143  $ilCtrl = $this->ctrl;
144  $lng = $this->lng;
145 
146  $ids = $this->request->getCriteriaIds();
147  if (count($ids) == 0) {
148  $ilCtrl->redirect($this, "view");
149  }
150 
151  foreach (ilExcCriteria::getInstancesByParentId($this->cat_id) as $item) {
152  if (in_array($item->getId(), $ids)) {
153  $item->delete();
154  }
155  }
156 
157  $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
158  $ilCtrl->redirect($this, "view");
159  }
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 getInstancesByParentId(int $a_parent_id)
+ Here is the call graph for this function:

◆ edit()

ilExcCriteriaGUI::edit ( ?ilPropertyFormGUI  $a_form = null)
protected

Definition at line 298 of file class.ilExcCriteriaGUI.php.

References $tpl, exportForm(), getCurrentCritera(), initForm(), and ILIAS\UICore\GlobalTemplate\setContent().

298  : void
299  {
300  $tpl = $this->tpl;
301 
302  $crit_obj = $this->getCurrentCritera();
303 
304  if (!$a_form) {
305  $a_form = $this->initForm($crit_obj);
306  $this->exportForm($crit_obj, $a_form);
307  }
308 
309  $tpl->setContent($a_form->getHTML());
310  }
setContent(string $a_html)
Sets content for standard template.
exportForm(ilExcCriteria $a_crit_obj, ilPropertyFormGUI $a_form)
initForm(ilExcCriteria $a_crit_obj)
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:

◆ executeCommand()

ilExcCriteriaGUI::executeCommand ( )

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

References $ctrl, and ilCtrl\getNextClass().

51  : void
52  {
53  $ilCtrl = $this->ctrl;
54 
55  $next_class = $ilCtrl->getNextClass($this);
56  $cmd = $ilCtrl->getCmd("view");
57 
58  switch ($next_class) {
59  default:
60  $this->$cmd();
61  break;
62  }
63  }
getNextClass($a_gui_class=null)
+ Here is the call graph for this function:

◆ exportForm()

ilExcCriteriaGUI::exportForm ( ilExcCriteria  $a_crit_obj,
ilPropertyFormGUI  $a_form 
)
protected

Definition at line 225 of file class.ilExcCriteriaGUI.php.

References ilExcCriteria\exportCustomForm(), ilExcCriteria\getDescription(), ilPropertyFormGUI\getItemByPostVar(), ilExcCriteria\getTitle(), and ilExcCriteria\isRequired().

Referenced by edit().

228  : void {
229  $a_form->getItemByPostVar("title")->setValue($a_crit_obj->getTitle());
230  $a_form->getItemByPostVar("desc")->setValue($a_crit_obj->getDescription());
231  $a_form->getItemByPostVar("req")->setChecked($a_crit_obj->isRequired());
232 
233  $a_crit_obj->exportCustomForm($a_form);
234  }
getItemByPostVar(string $a_post_var)
exportCustomForm(ilPropertyFormGUI $a_form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentCritera()

ilExcCriteriaGUI::getCurrentCritera ( )
protected

Definition at line 280 of file class.ilExcCriteriaGUI.php.

References $cat_id, $ctrl, $id, ilExcCriteria\getInstanceById(), and null.

Referenced by edit(), and update().

280  : ?ilExcCriteria
281  {
282  $ilCtrl = $this->ctrl;
283 
284  $id = $this->request->getCritId();
285  if ($id) {
286  $crit_obj = ilExcCriteria::getInstanceById($id);
287  if ($crit_obj->getParent() == $this->cat_id) {
288  $ilCtrl->setParameter($this, "crit_id", $id);
289  return $crit_obj;
290  }
291  }
292 
293  $ilCtrl->redirect($this, "view");
294 
295  return null;
296  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static getInstanceById(int $a_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importForm()

ilExcCriteriaGUI::importForm ( ilExcCriteria  $a_crit_obj)
protected

Definition at line 236 of file class.ilExcCriteriaGUI.php.

References $ctrl, $lng, ilExcCriteria\getId(), ilExcCriteria\importCustomForm(), initForm(), ilExcCriteria\save(), ilExcCriteria\setDescription(), ilExcCriteria\setParent(), ilExcCriteria\setRequired(), ilExcCriteria\setTitle(), ilLanguage\txt(), and ilExcCriteria\update().

Referenced by create(), and update().

238  : void {
239  $ilCtrl = $this->ctrl;
240  $lng = $this->lng;
241 
242  $is_edit = (bool) $a_crit_obj->getId();
243  $ilCtrl->setParameter($this, "type", $this->request->getCriteriaType());
244  $form = $this->initForm($a_crit_obj);
245  if ($form->checkInput()) {
246  $a_crit_obj->setTitle($form->getInput("title"));
247  $a_crit_obj->setDescription($form->getInput("desc"));
248  $a_crit_obj->setRequired($form->getInput("req"));
249 
250  $a_crit_obj->importCustomForm($form);
251 
252  if (!$is_edit) {
253  $a_crit_obj->setParent($this->cat_id);
254  $a_crit_obj->save();
255  } else {
256  $a_crit_obj->update();
257  }
258 
259  $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
260  $ilCtrl->redirect($this, "view");
261  }
262 
263  $form->setValuesByPost();
264  $this->{$is_edit ? "edit" : "add"}($form);
265  }
setDescription(?string $a_value)
setRequired(bool $a_value)
importCustomForm(ilPropertyFormGUI $a_form)
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...
setTitle(?string $a_value)
initForm(ilExcCriteria $a_crit_obj)
setParent(?int $a_value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilExcCriteriaGUI::initForm ( ilExcCriteria  $a_crit_obj)
protected

Definition at line 166 of file class.ilExcCriteriaGUI.php.

References $ctrl, $lng, XapiProxy\$req, ilExcCriteria\getId(), ilExcCriteria\getTranslatedType(), ilExcCriteria\initCustomForm(), and ilLanguage\txt().

Referenced by add(), edit(), and importForm().

167  {
168  $ilCtrl = $this->ctrl;
169  $lng = $this->lng;
170 
171  $form = new ilPropertyFormGUI();
172 
173  $is_edit = (bool) $a_crit_obj->getId();
174  if (!$is_edit) {
175  $form->setFormAction($ilCtrl->getFormAction($this, "create"));
176  $form->setTitle($lng->txt("exc_criteria_create_form"));
177  $form->addCommandButton("create", $lng->txt("create"));
178  } else {
179  $form->setFormAction($ilCtrl->getFormAction($this, "update"));
180  $form->setTitle($lng->txt("exc_criteria_update_form"));
181  $form->addCommandButton("update", $lng->txt("save"));
182  }
183 
184  $form->addCommandButton("view", $lng->txt("cancel"));
185 
186  $type = new ilNonEditableValueGUI($lng->txt("type"));
187  $type->setValue($a_crit_obj->getTranslatedType());
188  $form->addItem($type);
189 
190  $title = new ilTextInputGUI($lng->txt("title"), "title");
191  $title->setRequired(true);
192  $form->addItem($title);
193 
194  $desc = new ilTextAreaInputGUI($lng->txt("description"), "desc");
195  $form->addItem($desc);
196 
197  $req = new ilCheckboxInputGUI($lng->txt("required_field"), "req");
198  $form->addItem($req);
199 
200  $a_crit_obj->initCustomForm($form);
201 
202  return $form;
203  }
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...
catch(\Exception $e) $req
Definition: xapiproxy.php:91
This class represents a text area property in a property form.
initCustomForm(ilPropertyFormGUI $a_form)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveOrder()

ilExcCriteriaGUI::saveOrder ( )
protected

Definition at line 92 of file class.ilExcCriteriaGUI.php.

References $ctrl, $id, $lng, ilExcCriteria\getInstancesByParentId(), and ilLanguage\txt().

92  : void
93  {
94  $ilCtrl = $this->ctrl;
95  $lng = $this->lng;
96 
97  $all_cat = ilExcCriteria::getInstancesByParentId($this->cat_id);
98 
99  $pos = 0;
100  $req_positions = $this->request->getPositions();
101  asort($req_positions);
102  foreach (array_keys($req_positions) as $id) {
103  if (array_key_exists($id, $all_cat)) {
104  $pos += 10;
105  $all_cat[$id]->setPosition($pos);
106  $all_cat[$id]->update();
107  }
108  }
109 
110  $this->tpl->setOnScreenMessage('success', $lng->txt("settings_saved"), true);
111  $ilCtrl->redirect($this, "view");
112  }
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 getInstancesByParentId(int $a_parent_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ update()

ilExcCriteriaGUI::update ( )
protected

Definition at line 312 of file class.ilExcCriteriaGUI.php.

References getCurrentCritera(), and importForm().

312  : void
313  {
314  $crit_obj = $this->getCurrentCritera();
315  $this->importForm($crit_obj);
316  }
importForm(ilExcCriteria $a_crit_obj)
+ Here is the call graph for this function:

◆ view()

ilExcCriteriaGUI::view ( )
protected

Definition at line 70 of file class.ilExcCriteriaGUI.php.

References $ctrl, $lng, $toolbar, $tpl, ilExcCriteria\getTypesMap(), ILIAS\UICore\GlobalTemplate\setContent(), ilSelectInputGUI\setOptions(), and ilLanguage\txt().

70  : void
71  {
72  $ilToolbar = $this->toolbar;
73  $ilCtrl = $this->ctrl;
74  $lng = $this->lng;
75  $tpl = $this->tpl;
76 
77  $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "add"));
78 
79  $types = new ilSelectInputGUI($lng->txt("type"), "type");
81  $ilToolbar->addStickyItem($types);
82 
83  $this->gui->button(
84  $lng->txt("exc_add_criteria"),
85  "add"
86  )->submit()->toToolbar(true);
87 
88  $tbl = new ilExcCriteriaTableGUI($this, "view", $this->cat_id);
89  $tpl->setContent($tbl->getHTML());
90  }
This class represents a selection list property in a property form.
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...
setContent(string $a_html)
Sets content for standard template.
setOptions(array $a_options)
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

Field Documentation

◆ $cat_id

int ilExcCriteriaGUI::$cat_id
protected

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

Referenced by getCurrentCritera().

◆ $ctrl

ilCtrl ilExcCriteriaGUI::$ctrl
protected

◆ $gui

ILIAS Exercise InternalGUIService ilExcCriteriaGUI::$gui
protected

Definition at line 30 of file class.ilExcCriteriaGUI.php.

◆ $lng

ilLanguage ilExcCriteriaGUI::$lng
protected

◆ $request

GUIRequest ilExcCriteriaGUI::$request
protected

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

◆ $toolbar

ilToolbarGUI ilExcCriteriaGUI::$toolbar
protected

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

Referenced by view().

◆ $tpl

ilGlobalTemplateInterface ilExcCriteriaGUI::$tpl
protected

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

Referenced by add(), confirmDeletion(), edit(), and view().


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