ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLPObjectStatisticsGUI.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 
20 {
21  function ilLPObjectStatisticsGUI($a_mode,$a_ref_id = 0)
22  {
23  parent::ilLearningProgressBaseGUI($a_mode,$a_ref_id);
24 
25  if(!$this->ref_id)
26  {
27  $this->ref_id = (int)$_REQUEST["ref_id"];
28  }
29  }
30 
31  protected function setTabs()
32  {
33  global $ilAccess;
34 
35  $this->tabs_gui->addSubTab('trac_object_stat_access',
36  $this->lng->txt('trac_object_stat_access'),
37  $this->ctrl->getLinkTarget($this, 'accessFilter'));
38  $this->tabs_gui->addSubTab('trac_object_stat_daily',
39  $this->lng->txt('trac_object_stat_daily'),
40  $this->ctrl->getLinkTarget($this, 'dailyFilter'));
41  $this->tabs_gui->addSubTab('trac_object_stat_lp',
42  $this->lng->txt('trac_object_stat_lp'),
43  $this->ctrl->getLinkTarget($this, 'learningProgressFilter'));
44  $this->tabs_gui->addSubTab('trac_object_stat_types',
45  $this->lng->txt('trac_object_stat_types'),
46  $this->ctrl->getLinkTarget($this, 'typesFilter'));
47 
48  if($ilAccess->checkAccess("write", "", $this->ref_id))
49  {
50  $this->tabs_gui->addSubTab('trac_object_stat_admin',
51  $this->lng->txt('trac_object_stat_admin'),
52  $this->ctrl->getLinkTarget($this, 'admin'));
53  }
54  }
55 
59  function executeCommand()
60  {
61  $this->ctrl->setReturn($this, "");
62 
63  $this->setTabs();
64 
65  switch($this->ctrl->getNextClass())
66  {
67  default:
68  $cmd = $this->__getDefaultCommand();
69  $this->$cmd();
70  }
71 
72  return true;
73  }
74 
75  function applyAccessFilter()
76  {
77  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsTableGUI.php");
78  $lp_table = new ilLPObjectStatisticsTableGUI($this, "access", null, false);
79  $lp_table->resetOffset();
80  $lp_table->writeFilterToSession();
81  $this->access();
82  }
83 
84  function resetAccessFilter()
85  {
86  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsTableGUI.php");
87  $lp_table = new ilLPObjectStatisticsTableGUI($this, "access", null, false);
88  $lp_table->resetOffset();
89  $lp_table->resetFilter();
90  $this->access();
91  }
92 
93  function accessFilter()
94  {
95  $this->access(false);
96  }
97 
98  function access($a_load_data = true)
99  {
100  global $tpl;
101 
102  $this->tabs_gui->activateSubTab('trac_object_stat_access');
103 
104  $this->showAggregationInfo();
105 
106  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsTableGUI.php");
107  $lp_table = new ilLPObjectStatisticsTableGUI($this, "access", null, $a_load_data);
108 
109  if(!$a_load_data)
110  {
111  $lp_table->disable("content");
112  $lp_table->disable("header");
113  }
114 
115  $tpl->setContent($lp_table->getHTML());
116  }
117 
118  function showAccessGraph()
119  {
120  global $lng, $tpl;
121 
122  if(!$_POST["item_id"])
123  {
124  ilUtil::sendFailure($lng->txt("no_checkbox"));
125  return $this->access();
126  }
127 
128  $this->tabs_gui->activateSubTab('trac_object_stat_access');
129 
130  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsTableGUI.php");
131  $lp_table = new ilLPObjectStatisticsTableGUI($this, "access", $_POST["item_id"]);
132 
133  $tpl->setContent($lp_table->getGraph($_POST["item_id"]).$lp_table->getHTML());
134  }
135 
136  function applyTypesFilter()
137  {
138  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsTypesTableGUI.php");
139  $lp_table = new ilLPObjectStatisticsTypesTableGUI($this, "types", null, false);
140  $lp_table->resetOffset();
141  $lp_table->writeFilterToSession();
142  $this->types();
143  }
144 
145  function resetTypesFilter()
146  {
147  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsTypesTableGUI.php");
148  $lp_table = new ilLPObjectStatisticsTypesTableGUI($this, "types", null, false);
149  $lp_table->resetOffset();
150  $lp_table->resetFilter();
151  $this->types();
152  }
153 
154  function typesFilter()
155  {
156  $this->types(false);
157  }
158 
159  function types($a_load_data = true)
160  {
161  global $tpl;
162 
163  $this->tabs_gui->activateSubTab('trac_object_stat_types');
164 
165  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsTypesTableGUI.php");
166  $lp_table = new ilLPObjectStatisticsTypesTableGUI($this, "types", null, $a_load_data);
167 
168  if(!$a_load_data)
169  {
170  $lp_table->disable("content");
171  $lp_table->disable("header");
172  }
173 
174  $tpl->setContent($lp_table->getHTML());
175  }
176 
177  function showTypesGraph()
178  {
179  global $lng, $tpl;
180 
181  if(!$_POST["item_id"])
182  {
183  ilUtil::sendFailure($lng->txt("no_checkbox"));
184  return $this->types();
185  }
186 
187  $this->tabs_gui->activateSubTab('trac_object_stat_types');
188 
189  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsTypesTableGUI.php");
190  $lp_table = new ilLPObjectStatisticsTypesTableGUI($this, "types", $_POST["item_id"]);
191 
192  $tpl->setContent($lp_table->getGraph($_POST["item_id"]).$lp_table->getHTML());
193  }
194 
195  function applyDailyFilter()
196  {
197  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsDailyTableGUI.php");
198  $lp_table = new ilLPObjectStatisticsDailyTableGUI($this, "daily", null, false);
199  $lp_table->resetOffset();
200  $lp_table->writeFilterToSession();
201  $this->daily();
202  }
203 
204  function resetDailyFilter()
205  {
206  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsDailyTableGUI.php");
207  $lp_table = new ilLPObjectStatisticsDailyTableGUI($this, "daily", null, false);
208  $lp_table->resetOffset();
209  $lp_table->resetFilter();
210  $this->daily();
211  }
212 
213  function dailyFilter()
214  {
215  $this->daily(false);
216  }
217 
218  function daily($a_load_data = true)
219  {
220  global $tpl;
221 
222  $this->tabs_gui->activateSubTab('trac_object_stat_daily');
223 
224  $this->showAggregationInfo();
225 
226  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsDailyTableGUI.php");
227  $lp_table = new ilLPObjectStatisticsDailyTableGUI($this, "daily", null, $a_load_data);
228 
229  if(!$a_load_data)
230  {
231  $lp_table->disable("content");
232  $lp_table->disable("header");
233  }
234 
235  $tpl->setContent($lp_table->getHTML());
236  }
237 
238  function showDailyGraph()
239  {
240  global $lng, $tpl;
241 
242  if(!$_POST["item_id"])
243  {
244  ilUtil::sendFailure($lng->txt("no_checkbox"));
245  return $this->daily();
246  }
247 
248  $this->tabs_gui->activateSubTab('trac_object_stat_daily');
249 
250  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsDailyTableGUI.php");
251  $lp_table = new ilLPObjectStatisticsDailyTableGUI($this, "daily", $_POST["item_id"]);
252 
253  $tpl->setContent($lp_table->getGraph($_POST["item_id"]).$lp_table->getHTML());
254  }
255 
256  function admin()
257  {
258  global $tpl, $ilToolbar, $lng, $ilCtrl, $ilAccess;
259 
260  $this->tabs_gui->activateSubTab('trac_object_stat_admin');
261 
262  $this->showAggregationInfo(false);
263 
264  $ilToolbar->addButton($lng->txt("trac_sync_obj_stats"),
265  $ilCtrl->getLinkTarget($this, "adminSync"));
266 
267  if($ilAccess->checkAccess("delete", "", $this->ref_id))
268  {
269  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsAdminTableGUI.php");
270  $lp_table = new ilLPObjectStatisticsAdminTableGUI($this, "admin");
271 
272  $tpl->setContent($lp_table->getHTML());
273  }
274  }
275 
276  function adminSync()
277  {
278  global $ilCtrl, $lng;
279 
280  include_once "Services/Tracking/classes/class.ilChangeEvent.php";
282 
283  ilUtil::sendSuccess($lng->txt("trac_sync_obj_stats_success"), true);
284  $ilCtrl->redirect($this, "admin");
285  }
286 
287  function confirmDeleteData()
288  {
289  global $lng, $tpl, $ilTabs, $ilCtrl;
290 
291  if(!$_POST["item_id"])
292  {
293  ilUtil::sendFailure($lng->txt("no_checkbox"));
294  return $this->admin();
295  }
296 
297  $ilTabs->setBackTarget($lng->txt("back"),
298  $ilCtrl->getLinkTarget($this, "admin"));
299 
300  // display confirmation message
301  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
302  $cgui = new ilConfirmationGUI();
303  $cgui->setFormAction($ilCtrl->getFormAction($this));
304  $cgui->setHeaderText($lng->txt("trac_sure_delete_data"));
305  $cgui->setCancel($lng->txt("cancel"), "admin");
306  $cgui->setConfirm($lng->txt("delete"), "deleteData");
307 
308  // list objects that should be deleted
309  foreach ($_POST["item_id"] as $i)
310  {
311  $caption = $lng->txt("month_".str_pad(substr($i, 5), 2, "0", STR_PAD_LEFT)."_long").
312  " ".substr($i, 0, 4);
313 
314  $cgui->addItem("item_id[]", $i, $caption);
315  }
316 
317  $tpl->setContent($cgui->getHTML());
318  }
319 
320  function deleteData()
321  {
322  global $lng;
323 
324  if(!$_POST["item_id"])
325  {
326  ilUtil::sendFailure($lng->txt("no_checkbox"));
327  return $this->admin();
328  }
329 
330  include_once "Services/Tracking/classes/class.ilTrQuery.php";
332  ilUtil::sendSuccess($lng->txt("trac_data_deleted"));
333  $this->admin();
334  }
335 
337  {
338  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsLPTableGUI.php");
339  $lp_table = new ilLPObjectStatisticsLPTableGUI($this, "learningProgress", null, false);
340  $lp_table->resetOffset();
341  $lp_table->writeFilterToSession();
342  $this->learningProgress();
343  }
344 
346  {
347  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsLPTableGUI.php");
348  $lp_table = new ilLPObjectStatisticsLPTableGUI($this, "learningProgress", null, false);
349  $lp_table->resetOffset();
350  $lp_table->resetFilter();
351  $this->learningProgress();
352  }
353 
355  {
356  $this->learningProgress(false);
357  }
358 
359  function learningProgress($a_load_data = true)
360  {
361  global $tpl;
362 
363  $this->tabs_gui->activateSubTab('trac_object_stat_lp');
364 
365  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsLPTableGUI.php");
366  $lp_table = new ilLPObjectStatisticsLPTableGUI($this, "learningProgress", null, $a_load_data);
367 
368  if(!$a_load_data)
369  {
370  $lp_table->disable("content");
371  $lp_table->disable("header");
372  }
373 
374  $tpl->setContent($lp_table->getHTML());
375  }
376 
378  {
379  global $lng, $tpl;
380 
381  if(!$_POST["item_id"])
382  {
383  ilUtil::sendFailure($lng->txt("no_checkbox"));
384  return $this->learningProgress();
385  }
386 
387  $this->tabs_gui->activateSubTab('trac_object_stat_lp');
388 
389  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsLPTableGUI.php");
390  $lp_table = new ilLPObjectStatisticsLPTableGUI($this, "learningProgress", $_POST["item_id"], true, true);
391 
392  $tpl->setContent($lp_table->getGraph($_POST["item_id"]).$lp_table->getHTML());
393  }
394 
396  {
397  include_once("./Services/Tracking/classes/class.ilLPObjectStatisticsLPTableGUI.php");
398  $lp_table = new ilLPObjectStatisticsLPTableGUI($this, "showLearningProgressDetails", array($_GET["item_id"]), true, false, true);
399 
400  $a_tpl = new ilTemplate("tpl.lp_object_statistics_lp_details.html", true, true, "Services/Tracking");
401  $a_tpl->setVariable("CONTENT", $lp_table->getHTML());
402  $a_tpl->setVariable('CLOSE_IMG_SRC', ilUtil::getImagePath('icon_close2_s.png'));
403  $a_tpl->setVariable('CLOSE_IMG_TXT', $this->lng->txt('close'));
404  echo $a_tpl->get();
405  exit();
406  }
407 
408  protected function showAggregationInfo($a_show_link = true)
409  {
410  global $ilAccess, $lng, $ilCtrl;
411 
412  include_once "Services/Tracking/classes/class.ilTrQuery.php";
414  $info_date = ilDatePresentation::formatDate(new ilDateTime($info["tstamp"], IL_CAL_UNIX));
415 
416  $link = "";
417  if($a_show_link && $ilAccess->checkAccess("write", "", $this->ref_id))
418  {
419  $link = " <a href=\"".$ilCtrl->getLinkTarget($this, "admin")."\">&raquo;".
420  $lng->txt("trac_log_info_link")."</a>";
421  }
422 
423  ilUtil::sendInfo(sprintf($lng->txt("trac_log_info"), $info_date, $info["counter"]).$link);
424 
425  }
426 }
427 
428 ?>