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