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