ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilLPListOfSettingsGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once './Services/Tracking/classes/class.ilLearningProgressBaseGUI.php';
6include_once './Services/Tracking/classes/class.ilLPObjSettings.php';
7
21{
22 protected $obj_settings;
23 protected $obj_lp;
24
25 function __construct($a_mode,$a_ref_id)
26 {
27 parent::__construct($a_mode,$a_ref_id);
28
29 $this->obj_settings = new ilLPObjSettings($this->getObjId());
30
31 include_once './Services/Object/classes/class.ilObjectLP.php';
32 $this->obj_lp = ilObjectLP::getInstance($this->getObjId());
33 }
34
38 function &executeCommand()
39 {
40 switch($this->ctrl->getNextClass())
41 {
42 default:
43 $cmd = $this->__getDefaultCommand();
44 $this->$cmd();
45
46 }
47 return true;
48 }
49
53 protected function show()
54 {
55 global $ilHelp;
56
57 $ilHelp->setSubScreenId("trac_settings");
58
59 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.lp_obj_settings.html','Services/Tracking');
60
61 $form = $this->initFormSettings();
62 $this->tpl->setVariable('PROP_FORM',$form->getHTML());
63 $this->tpl->setVariable('COLLECTION_TABLE',$this->getTableByMode());
64 }
65
66
72 protected function initFormSettings()
73 {
74 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
75 $form = new ilPropertyFormGUI();
76 $form->setTitle($this->lng->txt('tracking_settings'));
77 $form->setFormAction($this->ctrl->getFormAction($this));
78
79 // Mode
80 $mod = new ilRadioGroupInputGUI($this->lng->txt('trac_mode'), 'modus');
81 $mod->setRequired(true);
82 $mod->setValue($this->obj_lp->getCurrentMode());
83 $form->addItem($mod);
84
85 foreach($this->obj_lp->getValidModes() as $mode_key)
86 {
87 $opt = new ilRadioOption(
88 $this->obj_lp->getModeText($mode_key),
89 $mode_key,
90 $this->obj_lp->getModeInfoText($mode_key)
91 );
92 $opt->setValue($mode_key);
93 $mod->addOption($opt);
94
95 // :TODO: Subitem for visits ?!
96 if($mode_key == ilLPObjSettings::LP_MODE_VISITS)
97 {
98 $vis = new ilNumberInputGUI($this->lng->txt('trac_visits'), 'visits');
99 $vis->setSize(3);
100 $vis->setMaxLength(4);
101 $vis->setInfo(sprintf($this->lng->txt('trac_visits_info'),
103 $vis->setRequired(true);
104 $vis->setValue($this->obj_settings->getVisits());
105 $opt->addSubItem($vis);
106 }
107 }
108
109 $form->addCommandButton('saveSettings', $this->lng->txt('save'));
110
111 return $form;
112 }
113
118 protected function saveSettings()
119 {
120 $form = $this->initFormSettings();
121 if($form->checkInput())
122 {
123 // anything changed?
124
125 // mode
126 $new_mode = (int)$form->getInput('modus');
127 $old_mode = $this->obj_lp->getCurrentMode();
128 $mode_changed = ($old_mode != $new_mode);
129
130 // visits
131 $new_visits = null;
132 $visits_changed = null;
133 if($new_mode == ilLPObjSettings::LP_MODE_VISITS)
134 {
135 $new_visits = (int)$form->getInput('visits');
136 $old_visits = $this->obj_settings->getVisits();
137 $visits_changed = ($old_visits != $new_visits);
138 }
139
140 if($mode_changed)
141 {
142 // delete existing collection
143 $collection = $this->obj_lp->getCollectionInstance();
144 if($collection)
145 {
146 $collection->delete();
147 }
148 }
149
150 $refresh_lp = ($mode_changed || $visits_changed);
151
152 // has to be done before LP refresh!
153 $this->obj_lp->resetCaches();
154
155 $this->obj_settings->setMode($new_mode);
156 $this->obj_settings->setVisits($new_visits);
157 $this->obj_settings->update($refresh_lp);
158
159 if($mode_changed &&
160 $this->obj_lp->getCollectionInstance() &&
161 $new_mode != ilLPObjSettings::LP_MODE_MANUAL_BY_TUTOR) // #14819
162 {
163 ilUtil::sendInfo($this->lng->txt('trac_edit_collection'), true);
164 }
165 ilUtil::sendSuccess($this->lng->txt('trac_settings_saved'), true);
166 $this->ctrl->redirect($this, 'show');
167 }
168
169 $form->setValuesByPost();
170 ilUtil::sendFailure($this->lng->txt('err_check_input'));
171
172 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.lp_obj_settings.html','Services/Tracking');
173 $this->tpl->setVariable('PROP_FORM',$form->getHTML());
174 $this->tpl->setVariable('COLLECTION_TABLE',$this->getTableByMode());
175 }
176
180 protected function getTableByMode()
181 {
182 $collection = $this->obj_lp->getCollectionInstance();
183 if($collection && $collection->hasSelectableItems())
184 {
185 include_once "Services/Tracking/classes/repository_statistics/class.ilLPCollectionSettingsTableGUI.php";
186 $table = new ilLPCollectionSettingsTableGUI($this, 'show', $this->getRefId(), $this->obj_lp->getCurrentMode());
187 $table->parse($collection);
188 return $table->getHTML();
189 }
190 }
191
196 protected function assign()
197 {
198 if(!$_POST['item_ids'])
199 {
200 ilUtil::sendFailure($this->lng->txt('select_one'),true);
201 $this->ctrl->redirect($this,'show');
202 }
203 if(count($_POST['item_ids']))
204 {
205 $collection = $this->obj_lp->getCollectionInstance();
206 if($collection && $collection->hasSelectableItems())
207 {
208 $collection->activateEntries($_POST['item_ids']);
209 }
210
211 // #15045 - has to be done before LP refresh!
212 $this->obj_lp->resetCaches();
213
214 // refresh learning progress
215 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
217 }
218 ilUtil::sendSuccess($this->lng->txt('trac_settings_saved'),true);
219 $this->ctrl->redirect($this,'show');
220 }
221
226 protected function deassign()
227 {
228 if(!$_POST['item_ids'])
229 {
230 ilUtil::sendFailure($this->lng->txt('select_one'),true);
231 $this->ctrl->redirect($this,'show');
232 return false;
233 }
234 if(count($_POST['item_ids']))
235 {
236 $collection = $this->obj_lp->getCollectionInstance();
237 if($collection && $collection->hasSelectableItems())
238 {
239 $collection->deactivateEntries($_POST['item_ids']);
240 }
241
242 // #15045 - has to be done before LP refresh!
243 $this->obj_lp->resetCaches();
244
245 // refresh learning progress
246 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
248 }
249 ilUtil::sendSuccess($this->lng->txt('trac_settings_saved'),true);
250 $this->ctrl->redirect($this,'show');
251 }
252
256 protected function groupMaterials()
257 {
258 if(!count((array) $_POST['item_ids']))
259 {
260 ilUtil::sendFailure($this->lng->txt('select_one'),true);
261 $this->ctrl->redirect($this,'show');
262 }
263
264 $collection = $this->obj_lp->getCollectionInstance();
265 if($collection && $collection->hasSelectableItems())
266 {
267 // Assign new grouping id
268 $collection->createNewGrouping((array)$_POST['item_ids']);
269
270 // refresh learning progress
271 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
273 }
274
275 ilUtil::sendSuccess($this->lng->txt('trac_settings_saved'),true);
276 $this->ctrl->redirect($this,'show');
277 }
278
282 protected function releaseMaterials()
283 {
284 if(!count((array) $_POST['item_ids']))
285 {
286 ilUtil::sendFailure($this->lng->txt('select_one'),true);
287 $this->ctrl->redirect($this,'show');
288 }
289
290 $collection = $this->obj_lp->getCollectionInstance();
291 if($collection && $collection->hasSelectableItems())
292 {
293 $collection->releaseGrouping((array)$_POST['item_ids']);
294
295 // refresh learning progress
296 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
298 }
299
300 ilUtil::sendSuccess($this->lng->txt('trac_settings_saved'),true);
301 $this->ctrl->redirect($this,'show');
302 }
303
307 protected function saveObligatoryMaterials()
308 {
309 if(!is_array((array) $_POST['grp']))
310 {
311 ilUtil::sendFailure($this->lng->txt('select_one'),true);
312 $this->ctrl->redirect($this,'show');
313 }
314
315 try {
316
317 $collection = $this->obj_lp->getCollectionInstance();
318 if($collection && $collection->hasSelectableItems())
319 {
320 $collection->saveObligatoryMaterials((array)$_POST['grp']);
321
322 // refresh learning progress
323 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
325 }
326
327 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
328 $this->ctrl->redirect($this,'show');
329 }
330 catch(UnexpectedValueException $e) {
331 ilUtil::sendFailure($this->lng->txt('trac_grouped_material_obligatory_err'), true);
332 ilUtil::sendInfo($this->lng->txt('err_check_input'),true);
333 $this->ctrl->redirect($this,'show');
334 }
335 }
336
337 protected function updateTLT()
338 {
339 include_once "Services/MetaData/classes/class.ilMD.php";
340 foreach($_POST['tlt'] as $item_id => $item)
341 {
342 $md_obj = new ilMD($this->getObjId(),$item_id,'st');
343 if(!is_object($md_section = $md_obj->getEducational()))
344 {
345 $md_section = $md_obj->addEducational();
346 $md_section->save();
347 }
348 $md_section->setPhysicalTypicalLearningTime((int)$item['mo'],
349 (int)$item['d'],(int)$item['h'],(int)$item['m'],0);
350 $md_section->update();
351 }
352
353 // refresh learning progress
354 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
356
357 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
358 $this->ctrl->redirect($this,'show');
359 }
360}
361?>
Class ilLPListOfSettingsGUI.
initFormSettings()
Init property form.
assign()
Save material assignment.
saveObligatoryMaterials()
Save obligatory state per grouped materials.
saveSettings()
Save learning progress settings.
deassign()
save mterial assignment
_refreshStatus($a_obj_id, $a_users=null)
Set dirty.
This class represents a number property in a property form.
static getInstance($a_obj_id)
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$_POST['username']
Definition: cron.php:12
$cmd
Definition: sahs_server.php:35