ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilSessionStatisticsGUI Class Reference
+ Collaboration diagram for ilSessionStatisticsGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 

Protected Member Functions

 setSubTabs ()
 
 current (bool $a_export=false)
 
 currentExport ()
 
 importDate (string $a_incoming, ?int $a_default=null)
 
 short (bool $a_export=false)
 
 shortExport ()
 
 long ($a_export=false)
 
 longExport ()
 
 periodic ($a_export=false)
 
 periodicExport ()
 
 renderCurrentBasics ()
 
 buildData (int $a_time_from, int $a_time_to, string $a_title)
 
 render (array $a_data, int $a_scale, ?string $a_measure=null)
 
 getChart (array $a_data, string $a_title, int $a_scale=self::SCALE_DAY, ?string $a_measure=null)
 Build chart for active sessions. More...
 
 adaptDataToScale (int $a_scale, array $a_data)
 
 adminSync ()
 
 exportCSV (array $a_data, $a_scale)
 

Private Attributes

const MODE_TODAY = 1
 
const MODE_LAST_DAY = 2
 
const MODE_LAST_WEEK = 3
 
const MODE_LAST_MONTH = 4
 
const MODE_DAY = 5
 
const MODE_WEEK = 6
 
const MODE_MONTH = 7
 
const MODE_YEAR = 8
 
const SCALE_DAY = 1
 
const SCALE_WEEK = 2
 
const SCALE_MONTH = 3
 
const SCALE_YEAR = 4
 
const SCALE_PERIODIC_WEEK = 5
 
const REQUEST_SMD = "smd"
 
const REQUEST_SMM = "smm"
 
const REQUEST_SST = "sst"
 
const REQUEST_STO = "sto"
 
const REQUEST_REF = "ref_id"
 
ilCtrl $ilCtrl
 
ilTabsGUI $ilTabs
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilToolbarGUI $toolbar
 
ilSetting $settings
 
ilAccess $access
 
ilIniFile $clientIniFile
 
ilObjUser $user
 
ilLogger $logger
 
int $ref_id = -1
 
int $smd = null
 
string $smm = null
 
string $sst = null
 
string $sto = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilSessionStatisticsGUI::__construct ( )

Definition at line 64 of file class.ilSessionStatisticsGUI.php.

References $DIC, $http, ILIAS\Repository\access(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), ILIAS\Repository\settings(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

65  {
66  global $DIC;
67 
68  $this->ilCtrl = $DIC->ctrl();
69  $this->ilTabs = $DIC->tabs();
70  $this->lng = $DIC->language();
71  $this->tpl = $DIC->ui()->mainTemplate();
72  $this->toolbar = $DIC->toolbar();
73  $this->settings = $DIC->settings();
74  $this->access = $DIC->access();
75  $this->clientIniFile = $DIC->clientIni();
76  $this->user = $DIC->user();
77  $this->logger = $DIC->logger()->auth();
78 
79  $http = $DIC->http();
80  $kindlyTo = $DIC->refinery()->kindlyTo();
81  if ($http->request()->getMethod() === "POST") {
82  if ($http->wrapper()->post()->has(self::REQUEST_SMD)) {
83  $this->smd = $http->wrapper()->post()->retrieve(self::REQUEST_SMD, $kindlyTo->int());
84  }
85  if ($http->wrapper()->post()->has(self::REQUEST_SMM)) {
86  $this->smm = $http->wrapper()->post()->retrieve(self::REQUEST_SMM, $kindlyTo->string());
87  }
88  if ($http->wrapper()->post()->has(self::REQUEST_STO)) {
89  $this->sto = $http->wrapper()->post()->retrieve(self::REQUEST_STO, $kindlyTo->string());
90  }
91  if ($http->wrapper()->post()->has(self::REQUEST_SST)) {
92  $this->sst = $http->wrapper()->post()->retrieve(self::REQUEST_SST, $kindlyTo->string());
93  }
94  } else {
95  if ($http->wrapper()->query()->has(self::REQUEST_SMD)) {
96  $this->smd = $http->wrapper()->query()->retrieve(self::REQUEST_SMD, $kindlyTo->int());
97  }
98  if ($http->wrapper()->query()->has(self::REQUEST_SMM)) {
99  $this->smm = $http->wrapper()->query()->retrieve(self::REQUEST_SMM, $kindlyTo->string());
100  }
101  if ($http->wrapper()->query()->has(self::REQUEST_STO)) {
102  $this->sto = $http->wrapper()->query()->retrieve(self::REQUEST_STO, $kindlyTo->string());
103  }
104  if ($http->wrapper()->query()->has(self::REQUEST_SST)) {
105  $this->sst = $http->wrapper()->query()->retrieve(self::REQUEST_SST, $kindlyTo->string());
106  }
107  }
108  if ($http->wrapper()->query()->has(self::REQUEST_REF)) {
109  $this->ref_id = $http->wrapper()->query()->retrieve(self::REQUEST_REF, $kindlyTo->int());
110  }
111  }
$http
Definition: deliver.php:30
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ adaptDataToScale()

ilSessionStatisticsGUI::adaptDataToScale ( int  $a_scale,
array  $a_data 
)
protected

Definition at line 662 of file class.ilSessionStatisticsGUI.php.

References $id, and ILIAS\Repository\int().

Referenced by exportCSV(), and getChart().

662  : array
663  {
664  // can we use original data?
665  switch ($a_scale) {
666  case self::SCALE_DAY:
667  // 96 values => ok
668  // fallthrough
669 
670  case self::SCALE_WEEK:
671  // 672 values => ok
672  return $a_data;
673  }
674 
675  $tmp = [];
676  foreach ($a_data as $item) {
677  $date_parts = getdate($item["slot_begin"]);
678 
679  // aggregate slots for scale
680  switch ($a_scale) {
681  default:
682  case self::SCALE_MONTH:
683  // aggregate to hours => 720 values
684  $slot = mktime($date_parts["hours"], 0, 0, $date_parts["mon"], $date_parts["mday"], $date_parts["year"]);
685  break;
686 
687  case self::SCALE_YEAR:
688  // aggregate to days => 365 values
689  $slot = mktime(0, 0, 1, $date_parts["mon"], $date_parts["mday"], $date_parts["year"]);
690  break;
691 
692  case self::SCALE_PERIODIC_WEEK:
693  // aggregate to weekdays => 672 values
694  $day = $date_parts["wday"];
695  if (!$day) {
696  $day = 7;
697  }
698  $slot = $day . date("His", $item["slot_begin"]);
699  break;
700  }
701 
702  // process minx/max, prepare avg
703  foreach ($item as $id => $value) {
704  switch (substr((string) $id, -3)) {
705  case "min":
706  if (!isset($tmp[$slot][$id]) || $value < $tmp[$slot][$id]) {
707  $tmp[$slot][$id] = $value;
708  }
709  break;
710 
711  case "max":
712  if (!isset($tmp[$slot][$id]) || $value > $tmp[$slot][$id]) {
713  $tmp[$slot][$id] = $value;
714  }
715  break;
716 
717  case "avg":
718  $tmp[$slot][$id][] = $value;
719  break;
720  }
721  }
722  }
723 
724  foreach ($tmp as $slot => $attr) {
725  $tmp[$slot]["active_avg"] = (int) round(array_sum($attr["active_avg"]) / count($attr["active_avg"]));
726  $tmp[$slot]["slot_begin"] = $slot;
727  }
728  ksort($tmp);
729  return array_values($tmp);
730  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adminSync()

ilSessionStatisticsGUI::adminSync ( )
protected

Definition at line 732 of file class.ilSessionStatisticsGUI.php.

References ilSession\_destroyExpiredSessions(), ilSessionStatistics\aggretateRaw(), and ILIAS\Repository\lng().

732  : void
733  {
734  // see ilSession::_writeData()
735  $now = time();
738 
739  $this->tpl->setOnScreenMessage('success', $this->lng->txt("trac_sync_session_stats_success"), true);
740  $this->ilCtrl->redirect($this);
741  }
static _destroyExpiredSessions()
Destroy expired sessions.
static aggretateRaw(int $a_now)
Aggregate raw session data (older than given time)
+ Here is the call graph for this function:

◆ buildData()

ilSessionStatisticsGUI::buildData ( int  $a_time_from,
int  $a_time_to,
string  $a_title 
)
protected

Definition at line 495 of file class.ilSessionStatisticsGUI.php.

References $data, ilDatePresentation\formatPeriod(), ilSessionStatistics\getNumberOfSessionsByType(), IL_CAL_UNIX, ILIAS\Repository\int(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), and ilDatePresentation\setUseRelativeDates().

Referenced by current(), long(), periodic(), and short().

495  : array
496  {
497  // basic data - time related
498 
499  $counters = ilSessionStatistics::getNumberOfSessionsByType($a_time_from, $a_time_to);
500  $opened = (int) $counters["opened"];
501  unset($counters["opened"]);
502 
503 
504  // build center column
505 
506  $data = array();
507 
509  $data["title"] = $a_title . " (" .
511  new ilDateTime($a_time_from, IL_CAL_UNIX),
512  new ilDateTime($a_time_to, IL_CAL_UNIX)
513  ) . ")";
514 
515  $data["opened"] = array($this->lng->txt("trac_sessions_opened"), $opened);
516  $data["closed"] = array($this->lng->txt("trac_sessions_closed"), array_sum($counters));
517  foreach ($counters as $type => $counter) {
518  $data["closed_details"][] = array($this->lng->txt("trac_" . $type), (int) $counter);
519  }
520 
521  $data["active"] = ilSessionStatistics::getActiveSessions($a_time_from, $a_time_to);
522  $this->logger->debug("Data to plot: " . var_export($data, true));
523  return $data;
524  }
static array static setUseRelativeDates(bool $a_status)
set use relative dates
static getNumberOfSessionsByType(int $a_from, int $a_to)
Get session counters by type (opened, closed)
const IL_CAL_UNIX
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ?ilObjUser $user=null)
Format a period of two dates Shows: 14.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ current()

ilSessionStatisticsGUI::current ( bool  $a_export = false)
protected

Definition at line 150 of file class.ilSessionStatisticsGUI.php.

References $data, $smd, $smm, buildData(), exportCSV(), ILIAS\Repository\lng(), render(), renderCurrentBasics(), ilSelectInputGUI\setOptions(), and ILIAS\Repository\toolbar().

Referenced by currentExport().

150  : void
151  {
152  $this->ilTabs->activateSubTab("current");
153 
154  // current mode
155  if (!$this->smd) {
156  $mode = self::MODE_TODAY;
157  } else {
158  $mode = $this->smd;
159  }
160 
161  // current measure
162  if (!$this->smm) {
163  $measure = "avg";
164  } else {
165  $measure = $this->smm;
166  }
167 
168  switch ($mode) {
169  default:
170  case self::MODE_TODAY:
171  $time_from = strtotime("today");
172  $time_to = strtotime("tomorrow") - 1;
173  $scale = self::SCALE_DAY;
174  break;
175 
176  case self::MODE_LAST_DAY:
177  $time_to = time();
178  $time_from = $time_to - 60 * 60 * 24;
179  $scale = self::SCALE_DAY;
180  break;
181 
182  case self::MODE_LAST_WEEK:
183  $time_to = time();
184  $time_from = $time_to - 60 * 60 * 24 * 7;
185  $scale = self::SCALE_WEEK;
186  break;
187 
188  case self::MODE_LAST_MONTH:
189  $time_to = time();
190  $time_from = $time_to - 60 * 60 * 24 * 30;
191  $scale = self::SCALE_MONTH;
192  break;
193  }
194 
195  $mode_options = array(
196  self::MODE_TODAY => $this->lng->txt("trac_session_statistics_mode_today"),
197  self::MODE_LAST_DAY => $this->lng->txt("trac_session_statistics_mode_last_day"),
198  self::MODE_LAST_WEEK => $this->lng->txt("trac_session_statistics_mode_last_week"),
199  self::MODE_LAST_MONTH => $this->lng->txt("trac_session_statistics_mode_last_month"));
200 
201  $title = $this->lng->txt("trac_current_system_load") . " - " . $mode_options[$mode];
202  $data = $this->buildData($time_from, $time_to, $title);
203 
204  if (!$a_export) {
205  // toolbar
206  $this->toolbar->setFormAction($this->ilCtrl->getFormAction($this, "current"));
207 
208  $mode_selector = new ilSelectInputGUI("&nbsp;" . $this->lng->txt("trac_scale"), "smd");
209  $mode_selector->setOptions($mode_options);
210  $mode_selector->setValue($mode);
211  $this->toolbar->addInputItem($mode_selector, true);
212 
213  $measure_options = array(
214  "avg" => $this->lng->txt("trac_session_active_avg"),
215  "min" => $this->lng->txt("trac_session_active_min"),
216  "max" => $this->lng->txt("trac_session_active_max"));
217 
218  $measure_selector = new ilSelectInputGUI("&nbsp;" . $this->lng->txt("trac_measure"), "smm");
219  $measure_selector->setOptions($measure_options);
220  $measure_selector->setValue($measure);
221  $this->toolbar->addInputItem($measure_selector, true);
222 
223  $this->toolbar->addFormButton($this->lng->txt("ok"), "current");
224 
225  if (count($data["active"])) {
226  $this->toolbar->addSeparator();
227  $this->toolbar->addFormButton($this->lng->txt("export"), "currentExport");
228  }
229 
230  $this->tpl->setContent($this->render($data, $scale, $measure));
231 
232  $this->tpl->setLeftContent($this->renderCurrentBasics());
233  } else {
234  $this->exportCSV($data, $scale);
235  }
236  }
exportCSV(array $a_data, $a_scale)
This class represents a selection list property in a property form.
setOptions(array $a_options)
render(array $a_data, int $a_scale, ?string $a_measure=null)
buildData(int $a_time_from, int $a_time_to, string $a_title)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ currentExport()

ilSessionStatisticsGUI::currentExport ( )
protected

Definition at line 238 of file class.ilSessionStatisticsGUI.php.

References current().

238  : void
239  {
240  $this->current(true);
241  }
+ Here is the call graph for this function:

◆ executeCommand()

ilSessionStatisticsGUI::executeCommand ( )

Definition at line 113 of file class.ilSessionStatisticsGUI.php.

References setSubTabs().

113  : bool
114  {
115  $this->setSubTabs();
116 
117  switch ($this->ilCtrl->getNextClass()) {
118  default:
119  $cmd = $this->ilCtrl->getCmd("current");
120  $this->$cmd();
121  }
122 
123  return true;
124  }
+ Here is the call graph for this function:

◆ exportCSV()

ilSessionStatisticsGUI::exportCSV ( array  $a_data,
  $a_scale 
)
protected

Definition at line 743 of file class.ilSessionStatisticsGUI.php.

References $filename, ilCalendarUtil\_numericDayToString(), adaptDataToScale(), exit, ilDatePresentation\formatDate(), ILIAS\UI\examples\Symbol\Glyph\Header\header(), IL_CAL_UNIX, ILIAS\Repository\lng(), ilDatePresentation\setUseRelativeDates(), and ILIAS\Repository\user().

Referenced by current(), long(), periodic(), and short().

743  : void
744  {
746 
747  $csv = new ilCSVWriter();
748  $csv->setSeparator(";");
749 
750  $now = time();
751 
752  // meta
753  $meta = array(
754  $this->lng->txt("trac_name_of_installation") => $this->clientIniFile->readVariable('client', 'name'),
755  $this->lng->txt("trac_report_date") => ilDatePresentation::formatDate(new ilDateTime($now, IL_CAL_UNIX)),
756  $this->lng->txt("trac_report_owner") => $this->user->getFullName(),
757  );
758  foreach ($a_data as $idx => $item) {
759  switch ($idx) {
760  case "title":
761  $meta[$this->lng->txt("title")] = $item;
762  break;
763 
764  case "active":
765  // nothing to do
766  break;
767 
768  case "closed_details":
769  foreach ($item as $detail) {
770  $meta[$a_data["closed"][0] . " - " . $detail[0]] = $detail[1];
771  }
772  break;
773 
774  default:
775  $meta[$item[0]] = $item[1];
776  break;
777  }
778  }
779  foreach ($meta as $caption => $value) {
780  $csv->addColumn(strip_tags((string) $caption));
781  $csv->addColumn(strip_tags((string) $value));
782  $csv->addRow();
783  }
784  $csv->addRow();
785 
786  // aggregate data
787  $aggr_data = $this->adaptDataToScale($a_scale, $a_data["active"]);
788 
789  // header
790  $first = $aggr_data;
791  $first = array_keys(array_shift($first));
792  foreach ($first as $column) {
793  // split weekday and time slot again
794  if ($a_scale === self::SCALE_PERIODIC_WEEK && $column === "slot_begin") {
795  $csv->addColumn("weekday");
796  $csv->addColumn("time");
797  } else {
798  $csv->addColumn(strip_tags((string) $column));
799  }
800  }
801  $csv->addRow();
802 
803  // data
804  foreach ($aggr_data as $row) {
805  foreach ($row as $column => $value) {
806  if (is_array($value)) {
807  $value = implode(', ', $value);
808  }
809  switch ($column) {
810  case "slot_begin":
811  // split weekday and time slot again
812  if ($a_scale === self::SCALE_PERIODIC_WEEK) {
813  $csv->addColumn(ilCalendarUtil::_numericDayToString((int) substr((string) $value, 0, 1)));
814  $value = substr((string) $value, 1, 2) . ":" . substr((string) $value, 3, 2);
815  break;
816  }
817  // fallthrough
818 
819  // no break
820  case "slot_end":
821  $value = date("d.m.Y H:i", $value);
822  break;
823  }
824  $csv->addColumn(strip_tags((string) $value));
825  }
826  $csv->addRow();
827  }
828 
829  // send
830  $filename = "session_statistics_" . date("Ymd", $now) . ".csv";
831  header("Content-type: text/comma-separated-values");
832  header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
833  header("Expires: 0");
834  header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
835  header("Pragma: public");
836  echo $csv->getCSVString();
837  exit();
838  }
static array static setUseRelativeDates(bool $a_status)
set use relative dates
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_CAL_UNIX
adaptDataToScale(int $a_scale, array $a_data)
static _numericDayToString(int $a_day, bool $a_long=true, ?ilLanguage $lng=null)
$filename
Definition: buildRTE.php:78
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
header()
expected output: > ILIAS shows the rendered Component.
Definition: header.php:29
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getChart()

ilSessionStatisticsGUI::getChart ( array  $a_data,
string  $a_title,
int  $a_scale = self::SCALE_DAY,
?string  $a_measure = null 
)
protected

Build chart for active sessions.

Definition at line 566 of file class.ilSessionStatisticsGUI.php.

References ilCalendarUtil\_numericDayToString(), adaptDataToScale(), ilChartGrid\DATA_LINES, ilChart\getInstanceByType(), ILIAS\Repository\int(), ILIAS\Repository\lng(), null, and ilChart\TYPE_GRID.

Referenced by render().

571  : string {
572  $chart = ilChart::getInstanceByType(ilChart::TYPE_GRID, "objstacc");
573  $chart->setSize("700", "500");
574  $chart->setYAxisToInteger(true);
575 
576  $legend = new ilChartLegend();
577  $chart->setLegend($legend);
578 
579  if (!$a_measure) {
580  $measures = ["min", "avg", "max"];
581  } else {
582  $measures = [$a_measure];
583  }
584 
585  $colors_map = array("min" => "#00cc00",
586  "avg" => "#0000cc",
587  "max" => "#cc00cc");
588 
589  $colors = $act_line = array();
590  foreach ($measures as $measure) {
591  $act_line[$measure] = $chart->getDataInstance(ilChartGrid::DATA_LINES);
592  $act_line[$measure]->setLineSteps(true);
593  $act_line[$measure]->setLabel($this->lng->txt("trac_session_active_" . $measure));
594  $colors[] = $colors_map[$measure];
595  }
596 
597  $chart->setColors($colors);
598 
599  $chart_data = $this->adaptDataToScale($a_scale, $a_data);
600 
601  $scale = ceil(count($chart_data) / 5);
602  $labels = array();
603  foreach ($chart_data as $idx => $item) {
604  $date = $item["slot_begin"];
605 
606  if ($a_scale === self::SCALE_PERIODIC_WEEK || !($idx % ceil($scale))) {
607  switch ($a_scale) {
608  case self::SCALE_DAY:
609  $labels[$date] = date("H:i", $date);
610  break;
611 
612  case self::SCALE_WEEK:
613  $labels[$date] = date("d.m. H", $date) . "h";
614  break;
615 
616  case self::SCALE_MONTH:
617  $labels[$date] = date("d.m.", $date);
618  break;
619 
620  case self::SCALE_YEAR:
621  $labels[$date] = date("Y-m", $date);
622  break;
623 
624  case self::SCALE_PERIODIC_WEEK:
625  $day = substr((string) $date, 0, 1);
626  $hour = substr((string) $date, 1, 2);
627  $min = substr((string) $date, 3, 2);
628 
629  // build ascending scale from day values
630  $day_value = ($day - 1) * 60 * 60 * 24;
631  $date = $day_value + $hour * 60 * 60 + $min * 60;
632 
633  // 6-hour interval labels
634  if ((!isset($old_hour) || $hour != $old_hour) && $hour && $hour % 6 == 0) {
635  $labels[$date] = $hour;
636  $old_hour = $hour;
637  }
638  // day label
639  if (!isset($old_day) || $day != $old_day) {
640  $labels[$date] = ilCalendarUtil::_numericDayToString((int) $day, false);
641  $old_day = $day;
642  }
643  break;
644  }
645  }
646 
647  foreach ($measures as $measure) {
648  $value = (int) $item["active_" . $measure];
649  $act_line[$measure]->addPoint($date, $value);
650  }
651  }
652 
653  foreach ($act_line as $line) {
654  $chart->addData($line);
655  }
656 
657  $chart->setTicks($labels, null, true);
658 
659  return $chart->getHTML();
660  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
adaptDataToScale(int $a_scale, array $a_data)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _numericDayToString(int $a_day, bool $a_long=true, ?ilLanguage $lng=null)
const TYPE_GRID
static getInstanceByType(int $a_type, string $a_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importDate()

ilSessionStatisticsGUI::importDate ( string  $a_incoming,
?int  $a_default = null 
)
protected
Returns
array|int|string|null

Definition at line 246 of file class.ilSessionStatisticsGUI.php.

References IL_CAL_UNIX, and ilCalendarUtil\parseIncomingDate().

Referenced by long(), periodic(), and short().

247  {
248  if (!$a_default) {
249  $a_default = time();
250  }
251 
252  $parsed = ilCalendarUtil::parseIncomingDate($a_incoming);
253  return $parsed
254  ? $parsed->get(IL_CAL_UNIX)
255  : $a_default;
256  }
static parseIncomingDate($value, bool $add_time=false)
Try to parse incoming value to date object.
const IL_CAL_UNIX
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ long()

ilSessionStatisticsGUI::long (   $a_export = false)
protected

Definition at line 342 of file class.ilSessionStatisticsGUI.php.

References $data, $smd, buildData(), exportCSV(), IL_CAL_UNIX, importDate(), ILIAS\Repository\lng(), render(), ilDateTimeInputGUI\setDate(), ilSelectInputGUI\setOptions(), and ILIAS\Repository\toolbar().

Referenced by longExport().

342  : void
343  {
344  $this->ilTabs->activateSubTab("long");
345 
346  // current start
347  //TODO validate input
348  $time_to = $this->importDate((string) $this->sst);
349 
350  // current mode
351  if (!$this->smd) {
352  $mode = self::MODE_WEEK;
353  } else {
354  $mode = $this->smd;
355  }
356 
357  switch ($mode) {
358  default:
359  case self::MODE_WEEK:
360  $time_from = $time_to - 60 * 60 * 24 * 7;
361  $scale = self::SCALE_WEEK;
362  break;
363 
364  case self::MODE_MONTH:
365  $time_from = $time_to - 60 * 60 * 24 * 30;
366  $scale = self::SCALE_MONTH;
367  break;
368 
369  case self::MODE_YEAR:
370  $time_from = $time_to - 60 * 60 * 24 * 365;
371  $scale = self::SCALE_YEAR;
372  break;
373  }
374 
375  $mode_options = array(
376  self::MODE_WEEK => $this->lng->txt("trac_session_statistics_mode_week"),
377  self::MODE_MONTH => $this->lng->txt("trac_session_statistics_mode_month"),
378  self::MODE_YEAR => $this->lng->txt("trac_session_statistics_mode_year")
379  );
380 
381  $title = $this->lng->txt("trac_long_system_load") . " - " . $mode_options[$mode];
382  $data = $this->buildData($time_from, $time_to, $title);
383 
384  if (!$a_export) {
385  // toolbar
386  $this->toolbar->setFormAction($this->ilCtrl->getFormAction($this, "long"));
387 
388  $start_selector = new ilDateTimeInputGUI($this->lng->txt("trac_end_at"), "sst");
389  $start_selector->setDate(new ilDate($time_to, IL_CAL_UNIX));
390  $this->toolbar->addInputItem($start_selector, true);
391 
392  $mode_selector = new ilSelectInputGUI("&nbsp;" . $this->lng->txt("trac_scale"), "smd");
393  $mode_selector->setOptions($mode_options);
394  $mode_selector->setValue($mode);
395  $this->toolbar->addInputItem($mode_selector, true);
396 
397  $this->toolbar->addFormButton($this->lng->txt("ok"), "long");
398 
399  if (count($data["active"])) {
400  $this->toolbar->addSeparator();
401  $this->toolbar->addFormButton($this->lng->txt("export"), "longExport");
402  }
403 
404  $this->tpl->setContent($this->render($data, $scale));
405  } else {
406  $this->exportCSV($data, $scale);
407  }
408  }
exportCSV(array $a_data, $a_scale)
This class represents a selection list property in a property form.
setOptions(array $a_options)
const IL_CAL_UNIX
This class represents a date/time property in a property form.
importDate(string $a_incoming, ?int $a_default=null)
setDate(?ilDateTime $a_date=null)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
render(array $a_data, int $a_scale, ?string $a_measure=null)
buildData(int $a_time_from, int $a_time_to, string $a_title)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ longExport()

ilSessionStatisticsGUI::longExport ( )
protected

Definition at line 410 of file class.ilSessionStatisticsGUI.php.

References long().

410  : void
411  {
412  $this->long(true);
413  }
+ Here is the call graph for this function:

◆ periodic()

ilSessionStatisticsGUI::periodic (   $a_export = false)
protected

Definition at line 415 of file class.ilSessionStatisticsGUI.php.

References $data, buildData(), exportCSV(), IL_CAL_UNIX, importDate(), ILIAS\Repository\lng(), render(), ilDateTimeInputGUI\setDate(), and ILIAS\Repository\toolbar().

Referenced by periodicExport().

415  : void
416  {
417  $this->ilTabs->activateSubTab("periodic");
418 
419  //TODO validate input
420  // current start
421  $time_to = $this->importDate((string) $this->sst);
422 
423  // current end
424  $time_from = $this->importDate((string) $this->sto, strtotime("-7 days"));
425 
426  // mixed up dates?
427  if ($time_to < $time_from) {
428  $tmp = $time_to;
429  $time_to = $time_from;
430  $time_from = $tmp;
431  }
432 
433  $title = $this->lng->txt("trac_periodic_system_load");
434  $data = $this->buildData($time_from, $time_to, $title);
435 
436  if (!$a_export) {
437  // toolbar
438  $this->toolbar->setFormAction($this->ilCtrl->getFormAction($this, "periodic"));
439 
440  $end_selector = new ilDateTimeInputGUI($this->lng->txt("trac_begin_at"), "sto");
441  $end_selector->setDate(new ilDate($time_from, IL_CAL_UNIX));
442  $this->toolbar->addInputItem($end_selector, true);
443 
444  $start_selector = new ilDateTimeInputGUI($this->lng->txt("trac_end_at"), "sst");
445  $start_selector->setDate(new ilDate($time_to, IL_CAL_UNIX));
446  $this->toolbar->addInputItem($start_selector, true);
447 
448  $this->toolbar->addFormButton($this->lng->txt("ok"), "periodic");
449 
450  if (count($data["active"])) {
451  $this->toolbar->addSeparator();
452  $this->toolbar->addFormButton($this->lng->txt("export"), "periodicExport");
453  }
454 
455  $this->tpl->setContent($this->render($data, self::SCALE_PERIODIC_WEEK));
456  } else {
457  $this->exportCSV($data, self::SCALE_PERIODIC_WEEK);
458  }
459  }
exportCSV(array $a_data, $a_scale)
const IL_CAL_UNIX
This class represents a date/time property in a property form.
importDate(string $a_incoming, ?int $a_default=null)
setDate(?ilDateTime $a_date=null)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
render(array $a_data, int $a_scale, ?string $a_measure=null)
buildData(int $a_time_from, int $a_time_to, string $a_title)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ periodicExport()

ilSessionStatisticsGUI::periodicExport ( )
protected

Definition at line 461 of file class.ilSessionStatisticsGUI.php.

References periodic().

461  : void
462  {
463  $this->periodic(true);
464  }
+ Here is the call graph for this function:

◆ render()

ilSessionStatisticsGUI::render ( array  $a_data,
int  $a_scale,
?string  $a_measure = null 
)
protected

Definition at line 526 of file class.ilSessionStatisticsGUI.php.

References getChart(), and ILIAS\Repository\lng().

Referenced by current(), long(), periodic(), and short().

526  : string
527  {
528  $center = new ilTemplate("tpl.session_statistics_center.html", true, true, "components/ILIAS/Authentication");
529 
530  foreach ($a_data as $idx => $item) {
531  switch ($idx) {
532  case "active":
533  case "title":
534  // nothing to do
535  break;
536 
537  case "closed_details":
538  $center->setCurrentBlock("closed_details");
539  foreach ($item as $detail) {
540  $center->setVariable("CAPTION_CLOSED_DETAILS", $detail[0]);
541  $center->setVariable("VALUE_CLOSED_DETAILS", $detail[1]);
542  $center->parseCurrentBlock();
543  }
544  break;
545 
546  default:
547  $tpl_var = strtoupper($idx);
548  $center->setVariable("CAPTION_" . $tpl_var, $item[0]);
549  $center->setVariable("VALUE_" . $tpl_var, $item[1]);
550  break;
551  }
552  }
553 
554  if ($a_data["active"]) {
555  $center->setVariable("CHART", $this->getChart($a_data["active"], $a_data["title"], $a_scale, $a_measure));
556  } else {
557  $this->tpl->setOnScreenMessage('info', $this->lng->txt("trac_session_statistics_no_data"));
558  }
559 
560  return $center->get();
561  }
getChart(array $a_data, string $a_title, int $a_scale=self::SCALE_DAY, ?string $a_measure=null)
Build chart for active sessions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderCurrentBasics()

ilSessionStatisticsGUI::renderCurrentBasics ( )
protected

Definition at line 466 of file class.ilSessionStatisticsGUI.php.

References ilSessionControl\$session_types_controlled, ILIAS\Repository\access(), ilDatePresentation\formatDate(), ilSessionControl\getExistingSessionCount(), ilSessionStatistics\getLastAggregation(), IL_CAL_UNIX, and ILIAS\Repository\lng().

Referenced by current().

466  : string
467  {
468  // basic data - not time related
469 
471 
473 
474 
475  // build left column
476 
477  $left = new ilTemplate("tpl.session_statistics_left.html", true, true, "components/ILIAS/Authentication");
478 
479  $left->setVariable("CAPTION_CURRENT", $this->lng->txt("users_online"));
480  $left->setVariable("VALUE_CURRENT", $active);
481 
482  $left->setVariable("CAPTION_LAST_AGGR", $this->lng->txt("trac_last_aggregation"));
483  $left->setVariable("VALUE_LAST_AGGR", ilDatePresentation::formatDate($last_aggr));
484 
485  // sync button
486  if ($this->access->checkAccess("write", "", $this->ref_id)) {
487  $left->setVariable("URL_SYNC", $this->ilCtrl->getFormAction($this, "adminSync"));
488  $left->setVariable("CMD_SYNC", "adminSync");
489  $left->setVariable("TXT_SYNC", $this->lng->txt("trac_sync_session_stats"));
490  }
491 
492  return $left->get();
493  }
const IL_CAL_UNIX
static getLastAggregation()
Get timestamp of last aggregation.
static getExistingSessionCount(array $a_types)
returns number of valid sessions relating to given session types
static array $session_types_controlled
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSubTabs()

ilSessionStatisticsGUI::setSubTabs ( )
protected

Definition at line 126 of file class.ilSessionStatisticsGUI.php.

References ILIAS\Repository\lng().

Referenced by executeCommand().

126  : void
127  {
128  $this->ilTabs->addSubTab(
129  "current",
130  $this->lng->txt("trac_current_system_load"),
131  $this->ilCtrl->getLinkTarget($this, "current")
132  );
133  $this->ilTabs->addSubTab(
134  "short",
135  $this->lng->txt("trac_short_system_load"),
136  $this->ilCtrl->getLinkTarget($this, "short")
137  );
138  $this->ilTabs->addSubTab(
139  "long",
140  $this->lng->txt("trac_long_system_load"),
141  $this->ilCtrl->getLinkTarget($this, "long")
142  );
143  $this->ilTabs->addSubTab(
144  "periodic",
145  $this->lng->txt("trac_periodic_system_load"),
146  $this->ilCtrl->getLinkTarget($this, "periodic")
147  );
148  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ short()

ilSessionStatisticsGUI::short ( bool  $a_export = false)
protected

Definition at line 258 of file class.ilSessionStatisticsGUI.php.

References $data, $smd, $smm, buildData(), exportCSV(), IL_CAL_UNIX, importDate(), ILIAS\Repository\lng(), render(), ilDateTimeInputGUI\setDate(), ilSelectInputGUI\setOptions(), and ILIAS\Repository\toolbar().

Referenced by shortExport().

258  : void
259  {
260  $this->ilTabs->activateSubTab("short");
261 
262  //TODO validate input
263  // current start
264  $time_to = $this->importDate((string) $this->sst);
265 
266  // current mode
267  if (!$this->smd) {
268  $mode = self::MODE_DAY;
269  } else {
270  $mode = $this->smd;
271  }
272 
273  // current measure
274  if (!$this->smm) {
275  $measure = "avg";
276  } else {
277  $measure = $this->smm;
278  }
279 
280  switch ($mode) {
281  default:
282  case self::MODE_DAY:
283  $time_from = $time_to - 60 * 60 * 24;
284  $scale = self::SCALE_DAY;
285  break;
286 
287  case self::MODE_WEEK:
288  $time_from = $time_to - 60 * 60 * 24 * 7;
289  $scale = self::SCALE_WEEK;
290  break;
291  }
292 
293  $mode_options = array(
294  self::MODE_DAY => $this->lng->txt("trac_session_statistics_mode_day"),
295  self::MODE_WEEK => $this->lng->txt("trac_session_statistics_mode_week")
296  );
297 
298  $title = $this->lng->txt("trac_short_system_load") . " - " . $mode_options[$mode];
299  $data = $this->buildData($time_from, $time_to, $title);
300 
301  if (!$a_export) {
302  // toolbar
303  $this->toolbar->setFormAction($this->ilCtrl->getFormAction($this, "short"));
304 
305  $start_selector = new ilDateTimeInputGUI($this->lng->txt("trac_end_at"), "sst");
306  $start_selector->setDate(new ilDate($time_to, IL_CAL_UNIX));
307  $this->toolbar->addInputItem($start_selector, true);
308 
309  $mode_selector = new ilSelectInputGUI("&nbsp;" . $this->lng->txt("trac_scale"), "smd");
310  $mode_selector->setOptions($mode_options);
311  $mode_selector->setValue($mode);
312  $this->toolbar->addInputItem($mode_selector, true);
313 
314  $measure_options = array(
315  "avg" => $this->lng->txt("trac_session_active_avg"),
316  "min" => $this->lng->txt("trac_session_active_min"),
317  "max" => $this->lng->txt("trac_session_active_max"));
318 
319  $measure_selector = new ilSelectInputGUI("&nbsp;" . $this->lng->txt("trac_measure"), "smm");
320  $measure_selector->setOptions($measure_options);
321  $measure_selector->setValue($measure);
322  $this->toolbar->addInputItem($measure_selector, true);
323 
324  $this->toolbar->addFormButton($this->lng->txt("ok"), "short");
325 
326  if (count($data["active"])) {
327  $this->toolbar->addSeparator();
328  $this->toolbar->addFormButton($this->lng->txt("export"), "shortExport");
329  }
330 
331  $this->tpl->setContent($this->render($data, $scale, $measure));
332  } else {
333  $this->exportCSV($data, $scale);
334  }
335  }
exportCSV(array $a_data, $a_scale)
This class represents a selection list property in a property form.
setOptions(array $a_options)
const IL_CAL_UNIX
This class represents a date/time property in a property form.
importDate(string $a_incoming, ?int $a_default=null)
setDate(?ilDateTime $a_date=null)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
render(array $a_data, int $a_scale, ?string $a_measure=null)
buildData(int $a_time_from, int $a_time_to, string $a_title)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shortExport()

ilSessionStatisticsGUI::shortExport ( )
protected

Definition at line 337 of file class.ilSessionStatisticsGUI.php.

References short().

337  : void
338  {
339  $this->short(true);
340  }
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccess ilSessionStatisticsGUI::$access
private

Definition at line 53 of file class.ilSessionStatisticsGUI.php.

◆ $clientIniFile

ilIniFile ilSessionStatisticsGUI::$clientIniFile
private

Definition at line 54 of file class.ilSessionStatisticsGUI.php.

◆ $ilCtrl

ilCtrl ilSessionStatisticsGUI::$ilCtrl
private

Definition at line 47 of file class.ilSessionStatisticsGUI.php.

◆ $ilTabs

ilTabsGUI ilSessionStatisticsGUI::$ilTabs
private

Definition at line 48 of file class.ilSessionStatisticsGUI.php.

◆ $lng

ilLanguage ilSessionStatisticsGUI::$lng
private

Definition at line 49 of file class.ilSessionStatisticsGUI.php.

◆ $logger

ilLogger ilSessionStatisticsGUI::$logger
private

Definition at line 56 of file class.ilSessionStatisticsGUI.php.

◆ $ref_id

int ilSessionStatisticsGUI::$ref_id = -1
private

Definition at line 58 of file class.ilSessionStatisticsGUI.php.

◆ $settings

ilSetting ilSessionStatisticsGUI::$settings
private

Definition at line 52 of file class.ilSessionStatisticsGUI.php.

◆ $smd

int ilSessionStatisticsGUI::$smd = null
private

Definition at line 59 of file class.ilSessionStatisticsGUI.php.

Referenced by current(), long(), and short().

◆ $smm

string ilSessionStatisticsGUI::$smm = null
private

Definition at line 60 of file class.ilSessionStatisticsGUI.php.

Referenced by current(), and short().

◆ $sst

string ilSessionStatisticsGUI::$sst = null
private

Definition at line 61 of file class.ilSessionStatisticsGUI.php.

◆ $sto

string ilSessionStatisticsGUI::$sto = null
private

Definition at line 62 of file class.ilSessionStatisticsGUI.php.

◆ $toolbar

ilToolbarGUI ilSessionStatisticsGUI::$toolbar
private

Definition at line 51 of file class.ilSessionStatisticsGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilSessionStatisticsGUI::$tpl
private

Definition at line 50 of file class.ilSessionStatisticsGUI.php.

◆ $user

ilObjUser ilSessionStatisticsGUI::$user
private

Definition at line 55 of file class.ilSessionStatisticsGUI.php.

◆ MODE_DAY

const ilSessionStatisticsGUI::MODE_DAY = 5
private

Definition at line 30 of file class.ilSessionStatisticsGUI.php.

◆ MODE_LAST_DAY

const ilSessionStatisticsGUI::MODE_LAST_DAY = 2
private

Definition at line 27 of file class.ilSessionStatisticsGUI.php.

◆ MODE_LAST_MONTH

const ilSessionStatisticsGUI::MODE_LAST_MONTH = 4
private

Definition at line 29 of file class.ilSessionStatisticsGUI.php.

◆ MODE_LAST_WEEK

const ilSessionStatisticsGUI::MODE_LAST_WEEK = 3
private

Definition at line 28 of file class.ilSessionStatisticsGUI.php.

◆ MODE_MONTH

const ilSessionStatisticsGUI::MODE_MONTH = 7
private

Definition at line 32 of file class.ilSessionStatisticsGUI.php.

◆ MODE_TODAY

const ilSessionStatisticsGUI::MODE_TODAY = 1
private

Definition at line 26 of file class.ilSessionStatisticsGUI.php.

◆ MODE_WEEK

const ilSessionStatisticsGUI::MODE_WEEK = 6
private

Definition at line 31 of file class.ilSessionStatisticsGUI.php.

◆ MODE_YEAR

const ilSessionStatisticsGUI::MODE_YEAR = 8
private

Definition at line 33 of file class.ilSessionStatisticsGUI.php.

◆ REQUEST_REF

const ilSessionStatisticsGUI::REQUEST_REF = "ref_id"
private

Definition at line 45 of file class.ilSessionStatisticsGUI.php.

◆ REQUEST_SMD

const ilSessionStatisticsGUI::REQUEST_SMD = "smd"
private

Definition at line 41 of file class.ilSessionStatisticsGUI.php.

◆ REQUEST_SMM

const ilSessionStatisticsGUI::REQUEST_SMM = "smm"
private

Definition at line 42 of file class.ilSessionStatisticsGUI.php.

◆ REQUEST_SST

const ilSessionStatisticsGUI::REQUEST_SST = "sst"
private

Definition at line 43 of file class.ilSessionStatisticsGUI.php.

◆ REQUEST_STO

const ilSessionStatisticsGUI::REQUEST_STO = "sto"
private

Definition at line 44 of file class.ilSessionStatisticsGUI.php.

◆ SCALE_DAY

const ilSessionStatisticsGUI::SCALE_DAY = 1
private

Definition at line 35 of file class.ilSessionStatisticsGUI.php.

◆ SCALE_MONTH

const ilSessionStatisticsGUI::SCALE_MONTH = 3
private

Definition at line 37 of file class.ilSessionStatisticsGUI.php.

◆ SCALE_PERIODIC_WEEK

const ilSessionStatisticsGUI::SCALE_PERIODIC_WEEK = 5
private

Definition at line 39 of file class.ilSessionStatisticsGUI.php.

◆ SCALE_WEEK

const ilSessionStatisticsGUI::SCALE_WEEK = 2
private

Definition at line 36 of file class.ilSessionStatisticsGUI.php.

◆ SCALE_YEAR

const ilSessionStatisticsGUI::SCALE_YEAR = 4
private

Definition at line 38 of file class.ilSessionStatisticsGUI.php.


The documentation for this class was generated from the following file: