Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/main/inc/ajax/statistics.ajax.php

50 lines
1.7 KiB

<?php
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls
*/
require_once __DIR__.'/../global.inc.php';
api_protect_admin_script();
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
switch ($action) {
case 'recentlogins':
header('Content-type: application/json');
$list = [];
$all = Statistics::getRecentLoginStats();
foreach ($all as $tick => $tock) {
$list['labels'][] = $tick;
}
$list['datasets'][0]['label'] = get_lang('Logins');
$list['datasets'][0]['fillColor'] = "rgba(151,187,205,0.2)";
$list['datasets'][0]['strokeColor'] = "rgba(151,187,205,1)";
$list['datasets'][0]['pointColor'] = "rgba(151,187,205,1)";
$list['datasets'][0]['pointStrokeColor'] = "#fff";
$list['datasets'][0]['pointHighlightFill'] = "#fff";
$list['datasets'][0]['pointHighlightStroke'] = "rgba(151,187,205,1)";
foreach ($all as $tick => $tock) {
$list['datasets'][0]['data'][] = $tock;
}
$list['datasets'][1]['label'] = get_lang('DistinctUsersLogins');
$list['datasets'][1]['fillColor'] = "rgba(0,204,0,0.2)";
$list['datasets'][1]['strokeColor'] = "rgba(0,204,0,1)";
$list['datasets'][1]['pointColor'] = "rgba(0,204,0,1)";
$list['datasets'][1]['pointStrokeColor'] = "#fff";
$list['datasets'][1]['pointHighlightFill'] = "#fff";
$list['datasets'][1]['pointHighlightStroke'] = "rgba(0,204,0,1)";
$distinct = Statistics::getRecentLoginStats(true);
foreach ($distinct as $tick => $tock) {
$list['datasets'][1]['data'][] = $tock;
}
echo json_encode($list);
break;
}