Reworked Access details by date chart - Refs BT#12212

remotes/angel/1.11.x
José Loguercio 8 years ago
parent 5d3ca2bde0
commit ecbd86e83c
  1. 1
      main/inc/ajax/myspace.ajax.php
  2. 35
      main/inc/lib/myspace.lib.php
  3. 52
      main/mySpace/access_details.php

@ -7,6 +7,7 @@ require_once __DIR__.'/../global.inc.php';
$action = $_GET['a'];
switch ($action) {
// At this date : 23/02/2017, a minor review can't determine where is used this case 'access_detail'
case 'access_detail':
$user_id = intval($_REQUEST['student']);
$course_code = Security::remove_XSS($_REQUEST['course']);

@ -2814,23 +2814,38 @@ function grapher($sql_result, $start_date, $end_date, $type = "")
if (empty($start_date)) { $start_date =""; }
if (empty($end_date)) { $end_date =""; }
if ($type == ""){ $type = 'day'; }
$main_year = $main_month_year = $main_day = array();
// get last 8 days/months
$last_days = 5;
$last_months = 3;
for ($i = $last_days; $i >= 0; $i--) {
$main_day[date ('d-m-Y', time () - $i * 3600 * 24)] = 0;
$main_year = $main_month_year = $main_day = [];
$period = new DatePeriod(
new DateTime($start_date),
new DateInterval('P1D'),
new DateTime($end_date)
);
foreach ($period as $date) {
$main_day[$date->format('d-m-Y')] = 0;
}
for ($i = $last_months; $i >= 0; $i--) {
$main_month_year[date ('m-Y', time () - $i * 30 * 3600 * 24)] = 0;
$period = new DatePeriod(
new DateTime($start_date),
new DateInterval('P1M'),
new DateTime($end_date)
);
foreach ($period as $date) {
$main_month_year[$date->format('m-Y')] = 0;
}
$i = 0;
if (is_array($sql_result) && count($sql_result) > 0) {
foreach ($sql_result as $key => $data) {
//creating the main array
$main_month_year[date('m-Y', $data['login'])] += float_format(($data['logout'] - $data['login']) / 60, 0);
$main_day[date('d-m-Y', $data['login'])] += float_format(($data['logout'] - $data['login']) / 60, 0);
if (isset($main_month_year[date('m-Y', $data['login'])])) {
$main_month_year[date('m-Y', $data['login'])] += float_format(($data['logout'] - $data['login']) / 60, 0);
}
if (isset($main_day[date('d-m-Y', $data['login'])])) {
$main_day[date('d-m-Y', $data['login'])] += float_format(($data['logout'] - $data['login']) / 60, 0);
}
if ($i > 500) {
break;
}

@ -132,28 +132,38 @@ echo Display::page_subheader(
$form->setDefaults(array('from' => $from, 'to' => $to));
$form->display();
?>
<div id="cev_results" class="ui-tabs ui-widget ui-widget-content ui-corner-all">
<div class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
<?php echo get_lang('Statistics'); ?>
</div><br />
<div id="cev_cont_stats">
<?php
if ($result_to_print != "") {
$rst = get_stats($user_id, $courseId);
$foo_stats = '<strong>'.get_lang('Total').': </strong>'.$rst['total'].'<br />';
$foo_stats .= '<strong>'.get_lang('Average').': </strong>'.$rst['avg'].'<br />';
$foo_stats .= '<strong>'.get_lang('Quantity').' : </strong>'.$rst['times'].'<br />';
echo $foo_stats;
} else {
echo Display::display_warning_message(get_lang('NoDataAvailable'));
}
?>
<br />
<br />
<div class="text-center" id="graph"></div>
<br />
<br />
<div class="row">
<div id="cev_results" class="ui-tabs ui-widget ui-widget-content ui-corner-all col-md-6">
<div class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
<?php echo get_lang('Statistics'); ?>
</div><br />
<div id="cev_cont_stats">
<?php
if ($result_to_print != "") {
$rst = get_stats($user_id, $courseId);
$foo_stats = '<strong>'.get_lang('Total').': </strong>'.$rst['total'].'<br />';
$foo_stats .= '<strong>'.get_lang('Average').': </strong>'.$rst['avg'].'<br />';
$foo_stats .= '<strong>'.get_lang('Quantity').' : </strong>'.$rst['times'].'<br />';
echo $foo_stats;
} else {
echo Display::display_warning_message(get_lang('NoDataAvailable'));
}
?>
</div>
<br />
</div>
<br />
</div><br />
<div id="messages"></div>
<div id="graph"></div>
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all col-md-6 col-md-6">
<div class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
<?php echo get_lang('Details'); ?>
</div><br />
<div id="messages"></div>
</div>
</div>
<?php
Display:: display_footer();

Loading…
Cancel
Save