ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
5 include_once './Services/Tracking/classes/class.ilLearningProgressBaseGUI.php';
6 include_once './Services/Tracking/classes/class.ilLPObjSettings.php';
7 
21 {
22  function ilLPListOfSettingsGUI($a_mode,$a_ref_id)
23  {
24  parent::ilLearningProgressBaseGUI($a_mode,$a_ref_id);
25 
26  $this->obj_settings = new ilLPObjSettings($this->getObjId());
27  }
28 
32  function &executeCommand()
33  {
34  switch($this->ctrl->getNextClass())
35  {
36  default:
37  $cmd = $this->__getDefaultCommand();
38  $this->$cmd();
39 
40  }
41  return true;
42  }
43 
44  function show()
45  {
46  // Sub Tabs
47 
48  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.lp_obj_settings.html','Services/Tracking');
49 
50  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormaction($this));
51  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_trac.gif'));
52  $this->tpl->setVariable("ALT_IMG",$this->lng->txt('tracking_settings'));
53  $this->tpl->setVariable("TXT_TRACKING_SETTINGS", $this->lng->txt("tracking_settings"));
54 
55  $this->tpl->setVariable("TXT_ACTIVATE_TRACKING", $this->lng->txt("trac_activated"));
56  $this->tpl->setVariable("ACTIVATED_IMG_OK",$activated = ilObjUserTracking::_enabledLearningProgress()
57  ? ilUtil::getImagePath('icon_ok.gif')
58  : ilUtil::getImagePath('icon_not_ok.gif'));
59  $this->tpl->setVariable("ACTIVATED_STATUS",$activated ? $this->lng->txt('yes') : $this->lng->txt('no'));
60 
61  $this->tpl->setVariable("TXT_USER_RELATED_DATA", $this->lng->txt("trac_anonymized"));
62  $this->tpl->setVariable("ANONYMIZED_IMG_OK",$anonymized = !ilObjUserTracking::_enabledUserRelatedData()
63  ? ilUtil::getImagePath('icon_ok.gif')
64  : ilUtil::getImagePath('icon_not_ok.gif'));
65  $this->tpl->setVariable("ANONYMIZED_STATUS",$anonymized ? $this->lng->txt('no') : $this->lng->txt('yes'));
66 
67  $this->tpl->setVariable("TXT_VALID_REQUEST",$this->lng->txt('trac_valid_request'));
68  $this->tpl->setVariable("INFO_VALID_REQUEST",$this->lng->txt('info_valid_request'));
69  $this->tpl->setVariable("SECONDS",$this->lng->txt('seconds'));
70  $this->tpl->setVariable("VAL_SECONDS",ilObjUserTracking::_getValidTimeSpan());
71 
72  $this->showModeSelection();
73 
74  if($this->obj_settings->getMode() == LP_MODE_VISITS)
75  {
76  $this->tpl->setCurrentBlock("visits");
77  $this->tpl->setVariable("TXT_VISITS",$this->lng->txt('trac_num_visits'));
78  $this->tpl->setVariable("NUM_VISITS",$this->obj_settings->getVisits());
79  $this->tpl->setVariable("INFO_VISITS",$this->lng->txt('trac_visits_info'));
80  $this->tpl->parseCurrentBlock();
81  }
82 
83  $this->tpl->setVariable("TXT_SAVE",$this->lng->txt('save'));
84 
85  // Show additional tables (e.g collection table)
86  $this->__showTablesByMode();
87  }
88 
89  function saveSettings()
90  {
91  $this->__addInfo();
92  $this->obj_settings->setMode($_POST['modus']);
93  if((int) $_POST['visits'])
94  {
95  $this->obj_settings->setVisits((int) $_POST['visits']);
96  }
97  $this->obj_settings->update();
98  $this->show();
99  }
100 
101  function assign()
102  {
103  if(!$_POST['item_ids'] and !$_POST['event_ids'])
104  {
105  ilUtil::sendFailure($this->lng->txt('select_one'));
106  $this->show();
107  return false;
108  }
109  if(count($_POST['item_ids']))
110  {
111  include_once 'Services/Tracking/classes/class.ilLPCollections.php';
112  $lp_collections = new ilLPCollections($this->getObjId());
113  foreach($_POST['item_ids'] as $ref_id)
114  {
115  $lp_collections->add($ref_id);
116  }
117 
118  // refresh learning progress
119  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
121  }
122  ilUtil::sendSuccess($this->lng->txt('trac_settings_saved'));
123  $this->show();
124  }
125 
126  function deassign()
127  {
128  if(!$_POST['item_ids'] and !$_POST['event_ids'])
129  {
130  ilUtil::sendFailure($this->lng->txt('select_one'));
131  $this->show();
132  return false;
133  }
134  if(count($_POST['item_ids']))
135  {
136  include_once 'Services/Tracking/classes/class.ilLPCollections.php';
137  $lp_collections = new ilLPCollections($this->getObjId());
138  foreach($_POST['item_ids'] as $ref_id)
139  {
140  $lp_collections->delete($ref_id);
141  }
142 
143  // refresh learning progress
144  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
146  }
147  ilUtil::sendSuccess($this->lng->txt('trac_settings_saved'));
148  $this->show();
149  }
150 
152  {
153  switch($this->obj_settings->getMode())
154  {
156  case LP_MODE_COLLECTION:
157 
158  $this->__showCollectionTable();
159  break;
160 
161  case LP_MODE_SCORM:
162 
163  $this->__showSCOTable();
164  break;
165 
166  }
167  return true;
168  }
169 
170  function __showSCOTable()
171  {
172  global $ilObjDataCache,$tree;
173 
174  include_once 'Services/Tracking/classes/class.ilLPCollections.php';
175  include_once './Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php';
176 
177 
178  if(!$items = ilLPCollections::_getPossibleSAHSItems($this->getObjId()))
179  {
180  ilUtil::sendFailure($this->lng->txt('trac_no_sahs_items_found'));
181  return false;
182  }
183 
184  $lp_collections = new ilLPCollections($this->getObjId());
185  $tpl =& new ilTemplate('tpl.trac_collections.html',true,true,'Services/Tracking');
186 
187  //$tpl->setVariable("COLL_TITLE_IMG_ALT",$this->lng->txt('trac_assignments'));
188  $tpl->setVariable("COLL_TITLE_IMG_ALT",$this->lng->txt('trac_lp_determination'));
189  $tpl->setVariable("COLL_TITLE_IMG",ilUtil::getImagePath('icon_trac.gif'));
190  //$tpl->setVariable("TABLE_TITLE", $this->lng->txt('trac_assignments'));
191  $tpl->setVariable("TABLE_TITLE", $this->lng->txt('trac_lp_determination'));
192  $tpl->setVariable("TABLE_INFO", $this->lng->txt('trac_lp_determination_info_sco'));
193  //$tpl->setVariable("ITEM_DESC",$this->lng->txt('description'));
194  //$tpl->setVariable("ITEM_ASSIGNED",$this->lng->txt('trac_assigned'));
195 
196  $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
197  $tpl->setVariable("BTN_ASSIGN",$this->lng->txt('trac_collection_assign'));
198  $tpl->setVariable("BTN_DEASSIGN",$this->lng->txt('trac_collection_deassign'));
199 
200 
201  $counter = 0;
202 
203  $tpl->addBlockFile('MATERIALS','materials','tpl.trac_collections_sco_row.html','Services/Tracking');
204  $counter = 0;
205  foreach($items as $obj_id => $data)
206  {
207  $tpl->setCurrentBlock("materials");
208  $tpl->setVariable("COLL_TITLE",$data['title']);
209  $tpl->setVariable("ROW_CLASS",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
210  $tpl->setVariable("CHECK_TRAC",ilUtil::formCheckbox(0,'item_ids[]',$obj_id));
211 
212  // Assigned
213  $tpl->setVariable("ASSIGNED_IMG_OK",$lp_collections->isAssigned($obj_id)
214  ? ilUtil::getImagePath('icon_ok.gif')
215  : ilUtil::getImagePath('icon_not_ok.gif'));
216  $tpl->setVariable("ASSIGNED_STATUS",$lp_collections->isAssigned($obj_id)
217  ? $this->lng->txt('trac_assigned')
218  : $this->lng->txt('trac_not_assigned'));
219 
220 
221  $tpl->parseCurrentBlock();
222  }
223  $tpl->setVariable("SELECT_ROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
224  $tpl->setVariable("SELECT_ALL",$this->lng->txt('select_all'));
225  $this->tpl->setVariable("COLLECTION_TABLE",$tpl->get());
226  }
227 
228 
229 
230 
232  {
233  global $ilObjDataCache,$tree;
234 
235  include_once 'Services/Tracking/classes/class.ilLPCollections.php';
236  include_once 'classes/class.ilLink.php';
237  include_once 'classes/class.ilFrameTargetInfo.php';
238 
239 
240  $lp_collections = new ilLPCollections($this->getObjId());
241 
242  $tpl =& new ilTemplate('tpl.trac_collections.html',true,true,'Services/Tracking');
243 
244  $tpl->setVariable("COLL_TITLE_IMG_ALT",$this->lng->txt('trac_lp_determination'));
245  $tpl->setVariable("COLL_TITLE_IMG",ilUtil::getImagePath('icon_trac.gif'));
246  //$tpl->setVariable("TABLE_TITLE",$this->lng->txt('trac_crs_assignments'));
247 
250  {
251  $tpl->setVariable("TABLE_TITLE",$this->lng->txt('trac_lp_determination'));
252  $tpl->setVariable("TABLE_INFO",$this->lng->txt('trac_lp_determination_info_crs'));
253  }
254  else
255  {
256  $tpl->setVariable("TABLE_TITLE",$this->lng->txt('trac_lp_determination_tutor'));
257  $tpl->setVariable("TABLE_INFO",$this->lng->txt('trac_lp_determination_info_crs_tutor'));
258  }
259 
260  $tpl->setVariable("ITEM_DESC",$this->lng->txt('trac_crs_items'));
261  $tpl->setVariable("ITEM_ASSIGNED",$this->lng->txt('trac_assigned'));
262 
263  $tpl->setVariable("IMG_ARROW",ilUtil::getImagePath('arrow_downright.gif'));
264  $tpl->setVariable("BTN_ASSIGN",$this->lng->txt('trac_collection_assign'));
265  $tpl->setVariable("BTN_DEASSIGN",$this->lng->txt('trac_collection_deassign'));
266 
267 
268  if(!ilLPCollections::_getCountPossibleItems($this->getRefId()) and !count($events))
269  {
270  $tpl->setCurrentBlock("no_items");
271  $tpl->setVariable("NO_ITEM_MESSAGE",$this->lng->txt('trac_no_items'));
272  $tpl->parseCurrentBlock();
273  }
274 
275  // Show header
276  $tpl->addBlockFile('MATERIALS','materials','tpl.trac_collections_row.html','Services/Tracking');
277  $counter = 0;
278  // Show materials
280  {
281  $obj_id = $ilObjDataCache->lookupObjId($ref_id);
282  $type = $ilObjDataCache->lookupType($obj_id);
283 
284  $anonymized = $this->__checkItemAnonymized($obj_id,$type);
285 
286  $tpl->setCurrentBlock("materials");
287 
288  $tpl->setVariable('TYPE_IMG',ilUtil::getImagePath('icon_'.$type.'_s.gif'));
289  $tpl->setVariable('ALT_IMG',$this->lng->txt('obj_'.$type));
290 
293  {
294  $tpl->setVariable("COLL_MODE",
295  $this->lng->txt('trac_mode').": ".
297  }
298  else
299  {
300  $tpl->setVariable("COLL_MODE",
301  $this->lng->txt('trac_mode').":");
302  $tpl->setVariable("COLL_MODE_DEACTIVATED",
304  }
305  if($anonymized)
306  {
307  $tpl->setVariable("ANONYMIZED",$this->lng->txt('trac_anonymized_info_short'));
308  }
309 
310  // Link to settings
311  $tpl->setVariable("COLL_LINK",ilLink::_getLink($ref_id,$ilObjDataCache->lookupType($obj_id)));
312  $tpl->setVariable("COLL_FRAME",ilFrameTargetInfo::_getFrame('MainContent',$ilObjDataCache->lookupType($obj_id)));
313  $tpl->setVariable("COLL_DESC",$ilObjDataCache->lookupDescription($obj_id));
314  $tpl->setVariable("COLL_TITLE",$ilObjDataCache->lookupTitle($obj_id));
315  $tpl->setVariable("ROW_CLASS",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
316 
317  if(!$anonymized)
318  {
319  $tpl->setVariable("CHECK_TRAC",ilUtil::formCheckbox(0,'item_ids[]',$ref_id));
320  }
321 
322  $path = $this->__formatPath($tree->getPathFull($ref_id),$ref_id);
323  $tpl->setVariable("COLL_PATH",$this->lng->txt('path').": ".$path);
324 
325  // Assigned
326  $tpl->setVariable("ASSIGNED_IMG_OK",$lp_collections->isAssigned($ref_id)
327  ? ilUtil::getImagePath('icon_ok.gif')
328  : ilUtil::getImagePath('icon_not_ok.gif'));
329  $tpl->setVariable("ASSIGNED_STATUS",$lp_collections->isAssigned($ref_id)
330  ? $this->lng->txt('trac_assigned')
331  : $this->lng->txt('trac_not_assigned'));
332 
333 
334  $tpl->parseCurrentBlock();
335  }
336 
337  $tpl->setVariable("SELECT_ROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
338  $tpl->setVariable("SELECT_ALL",$this->lng->txt('select_all'));
339 
340  $this->tpl->setVariable("COLLECTION_TABLE",$tpl->get());
341  }
342  function __addInfo()
343  {
344  $message = $this->lng->txt('trac_settings_saved');
345 
346  if($this->obj_settings->getMode() == $_POST['modus'])
347  {
348  ilUtil::sendSuccess($message);
349  return true;
350  }
351 
352  ilUtil::sendSuccess($message);
353 
354  switch($_POST['modus'])
355  {
356  case LP_MODE_COLLECTION:
357  $message = $this->lng->txt('trac_edit_collection');
358  ilUtil::sendInfo($message);
359  break;
360 
361  case LP_MODE_VISITS:
362  $message = $this->lng->txt('trac_edit_visits');
363  ilUtil::sendInfo($message);
364  break;
365 
366 
367  default:
368  ;
369  }
370  return true;
371  }
372 
373  function __formatPath($a_path_arr,$a_ref_id)
374  {
375  global $tree;
376  #$path = $this->__formatPath($tree->getPathFull($ref_id));
377  #$tpl->setVariable("COLL_PATH",$this->lng->txt('path').": ".$path);
378  $counter = 0;
379  foreach($a_path_arr as $data)
380  {
381  if(!$tree->isGrandChild($this->getRefId(),$data['ref_id']))
382  {
383  continue;
384  }
385  if($a_ref_id == $data['ref_id'])
386  {
387  break;
388  }
389  if($counter++)
390  {
391  $path .= " -> ";
392  }
393  $path .= $data['title'];
394  }
395 
396  return $path;
397  }
398 
399  function __checkItemAnonymized($a_obj_id,$a_type)
400  {
401  switch($a_type)
402  {
403  case 'tst':
404  include_once './Modules/Test/classes/class.ilObjTest.php';
405 
406  if(ilObjTest::_lookupAnonymity($a_obj_id))
407  {
408  return true;
409  }
410  return false;
411 
412  default:
413  return false;
414  }
415  }
416 
423  private function showModeSelection()
424  {
425  $this->tpl->setVariable('TXT_MODE',$this->lng->txt('trac_mode'));
426 
427  foreach($this->obj_settings->getValidModes() as $mode_key => $mode_name)
428  {
429  $this->tpl->setCurrentBlock('mode_check');
430  $this->tpl->setVariable('RADIO_ID',$mode_key);
431  $this->tpl->setVariable('RADIO_CHECKED',$mode_key == $this->obj_settings->getMode() ? ' checked="checked"' : '');
432  $this->tpl->setVariable('RADIO_VALUE',$mode_key);
433  $this->tpl->setVariable('MODE_NAME',$mode_name);
434  $this->tpl->setVariable('MODE_INFO',ilLPObjSettings::_mode2InfoText($mode_key));
435  $this->tpl->parseCurrentBlock();
436  }
437  }
438 }
439 ?>