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