fixing the function
@@ -2969,14 +2978,15 @@ class MySpace
$course_info,
$sessionId,
$start_date,
- $end_date
+ $end_date,
+ $addUserIp = false
) {
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$user_id = (int) $user_id;
$connections = [];
if (!empty($course_info)) {
$courseId = (int) $course_info['real_id'];
- $end_date = add_day_to($end_date);
+ $end_date = self::add_day_to($end_date);
$start_date = Database::escape_string($start_date);
$end_date = Database::escape_string($end_date);
@@ -2984,7 +2994,8 @@ class MySpace
$sql = "SELECT
login_course_date,
logout_course_date,
- TIMESTAMPDIFF(SECOND, login_course_date, logout_course_date) duration
+ TIMESTAMPDIFF(SECOND, login_course_date, logout_course_date) duration,
+ user_ip
FROM $table
WHERE
user_id = $user_id AND
@@ -2996,47 +3007,50 @@ class MySpace
$rs = Database::query($sql);
while ($row = Database::fetch_array($rs)) {
- $connections[] = [
+ $item = [
'login' => $row['login_course_date'],
'logout' => $row['logout_course_date'],
'duration' => $row['duration'],
];
+ if ($addUserIp) {
+ $item['user_ip'] = $row['user_ip'];
+ }
+ $connections[] = $item;
}
}
return $connections;
}
-}
-/**
- * @param $user_id
- * @param array $course_info
- * @param int $sessionId
- * @param null $start_date
- * @param null $end_date
- *
- * @return array
- */
-function get_stats($user_id, $course_info, $sessionId, $start_date = null, $end_date = null)
-{
- $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
- $result = [];
- if (!empty($course_info)) {
- $stringStartDate = '';
- $stringEndDate = '';
- if ($start_date != null && $end_date != null) {
- $end_date = add_day_to($end_date);
+ /**
+ * @param int $user_id
+ * @param array $course_info
+ * @param int $sessionId
+ * @param null $start_date
+ * @param null $end_date
+ *
+ * @return array
+ */
+ public static function getStats($user_id, $course_info, $sessionId, $start_date = null, $end_date = null)
+ {
+ $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
+ $result = [];
+ if (!empty($course_info)) {
+ $stringStartDate = '';
+ $stringEndDate = '';
+ if ($start_date != null && $end_date != null) {
+ $end_date = self::add_day_to($end_date);
- $start_date = Database::escape_string($start_date);
- $end_date = Database::escape_string($end_date);
+ $start_date = Database::escape_string($start_date);
+ $end_date = Database::escape_string($end_date);
- $stringStartDate = "AND login_course_date BETWEEN '$start_date' AND '$end_date'";
- $stringEndDate = "AND logout_course_date BETWEEN '$start_date' AND '$end_date'";
- }
- $user_id = (int) $user_id;
- $courseId = (int) $course_info['real_id'];
- $sessionCondition = api_get_session_condition($sessionId);
- $sql = "SELECT
+ $stringStartDate = "AND login_course_date BETWEEN '$start_date' AND '$end_date'";
+ $stringEndDate = "AND logout_course_date BETWEEN '$start_date' AND '$end_date'";
+ }
+ $user_id = (int) $user_id;
+ $courseId = (int) $course_info['real_id'];
+ $sessionCondition = api_get_session_condition($sessionId);
+ $sql = "SELECT
SEC_TO_TIME(AVG(time_to_sec(timediff(logout_course_date,login_course_date)))) as avrg,
SEC_TO_TIME(SUM(time_to_sec(timediff(logout_course_date,login_course_date)))) as total,
count(user_id) as times
@@ -3047,284 +3061,253 @@ function get_stats($user_id, $course_info, $sessionId, $start_date = null, $end_
$sessionCondition
ORDER BY login_course_date ASC";
- $rs = Database::query($sql);
- if ($row = Database::fetch_array($rs)) {
- $foo_avg = $row['avrg'];
- $foo_total = $row['total'];
- $foo_times = $row['times'];
- $result = [
- 'avg' => $foo_avg,
- 'total' => $foo_total,
- 'times' => $foo_times,
- ];
+ $rs = Database::query($sql);
+ if ($row = Database::fetch_array($rs)) {
+ $foo_avg = $row['avrg'];
+ $foo_total = $row['total'];
+ $foo_times = $row['times'];
+ $result = [
+ 'avg' => $foo_avg,
+ 'total' => $foo_total,
+ 'times' => $foo_times,
+ ];
+ }
}
- }
-
- return $result;
-}
-
-function add_day_to($end_date)
-{
- $foo_date = strtotime($end_date);
- $foo_date = strtotime(' +1 day', $foo_date);
- $foo_date = date('Y-m-d', $foo_date);
- return $foo_date;
-}
-
-/**
- * Converte an array to a table in html.
- *
- * @param array $result
- *
- * @author Jorge Frisancho Jibaja
- *
- * @version OCT-22- 2010
- *
- * @return string
- */
-function convert_to_string($result)
-{
- $html = '';
- if (!empty($result)) {
- foreach ($result as $key => $data) {
- $html .= '| ';
- $html .= api_get_local_time($data['login']);
- $html .= ' | ';
- $html .= '';
-
- $html .= api_time_to_hms(api_strtotime($data['logout']) - api_strtotime($data['login']));
- $html .= ' |
';
- }
+ return $result;
}
- $html .= '
';
- return $html;
-}
+ public static function add_day_to($end_date)
+ {
+ $foo_date = strtotime($end_date);
+ $foo_date = strtotime(' +1 day', $foo_date);
+ $foo_date = date('Y-m-d', $foo_date);
-/**
- * This function draw the graphic to be displayed on the user view as an image.
- *
- * @param array $sql_result
- * @param string $start_date
- * @param string $end_date
- * @param string $type
- *
- * @author Jorge Frisancho Jibaja
- *
- * @version OCT-22- 2010
- *
- * @return string
- */
-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';
+ return $foo_date;
}
- $main_year = $main_month_year = $main_day = [];
- $period = new DatePeriod(
- new DateTime($start_date),
- new DateInterval('P1D'),
- new DateTime($end_date)
- );
+ /**
+ * This function draw the graphic to be displayed on the user view as an image.
+ *
+ * @param array $sql_result
+ * @param string $start_date
+ * @param string $end_date
+ * @param string $type
+ *
+ * @author Jorge Frisancho Jibaja
+ *
+ * @version OCT-22- 2010
+ *
+ * @return string
+ */
+ public static 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 = [];
- foreach ($period as $date) {
- $main_day[$date->format('d-m-Y')] = 0;
- }
+ $period = new DatePeriod(
+ new DateTime($start_date),
+ new DateInterval('P1D'),
+ new DateTime($end_date)
+ );
- $period = new DatePeriod(
- new DateTime($start_date),
- new DateInterval('P1M'),
- new DateTime($end_date)
- );
+ foreach ($period as $date) {
+ $main_day[$date->format('d-m-Y')] = 0;
+ }
- foreach ($period as $date) {
- $main_month_year[$date->format('m-Y')] = 0;
- }
+ $period = new DatePeriod(
+ new DateTime($start_date),
+ new DateInterval('P1M'),
+ new DateTime($end_date)
+ );
- $i = 0;
- if (is_array($sql_result) && count($sql_result) > 0) {
- foreach ($sql_result as $key => $data) {
- $login = api_strtotime($data['login']);
- $logout = api_strtotime($data['logout']);
- //creating the main array
- if (isset($main_month_year[date('m-Y', $login)])) {
- $main_month_year[date('m-Y', $login)] += float_format(($logout - $login) / 60, 0);
+ 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) {
+ $login = api_strtotime($data['login']);
+ $logout = api_strtotime($data['logout']);
+ //creating the main array
+ if (isset($main_month_year[date('m-Y', $login)])) {
+ $main_month_year[date('m-Y', $login)] += float_format(($logout - $login) / 60, 0);
+ }
+ if (isset($main_day[date('d-m-Y', $login)])) {
+ $main_day[date('d-m-Y', $login)] += float_format(($logout - $login) / 60, 0);
+ }
+ if ($i > 500) {
+ break;
+ }
+ $i++;
}
- if (isset($main_day[date('d-m-Y', $login)])) {
- $main_day[date('d-m-Y', $login)] += float_format(($logout - $login) / 60, 0);
+ switch ($type) {
+ case 'day':
+ $main_date = $main_day;
+ break;
+ case 'month':
+ $main_date = $main_month_year;
+ break;
+ case 'year':
+ $main_date = $main_year;
+ break;
}
- if ($i > 500) {
- break;
+
+ $labels = array_keys($main_date);
+ if (count($main_date) == 1) {
+ $labels = $labels[0];
+ $main_date = $main_date[$labels];
}
- $i++;
- }
- switch ($type) {
- case 'day':
- $main_date = $main_day;
- break;
- case 'month':
- $main_date = $main_month_year;
- break;
- case 'year':
- $main_date = $main_year;
- break;
- }
- $labels = array_keys($main_date);
- if (count($main_date) == 1) {
- $labels = $labels[0];
- $main_date = $main_date[$labels];
- }
+ /* Create and populate the pData object */
+ $myData = new pData();
+ $myData->addPoints($main_date, 'Serie1');
+ if (count($main_date) != 1) {
+ $myData->addPoints($labels, 'Labels');
+ $myData->setSerieDescription('Labels', 'Months');
+ $myData->setAbscissa('Labels');
+ }
+ $myData->setSerieWeight('Serie1', 1);
+ $myData->setSerieDescription('Serie1', get_lang('MyResults'));
+ $myData->setAxisName(0, get_lang('Minutes'));
+ $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
+
+ // Cache definition
+ $cachePath = api_get_path(SYS_ARCHIVE_PATH);
+ $myCache = new pCache(['CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)]);
+ $chartHash = $myCache->getHash($myData);
+
+ if ($myCache->isInCache($chartHash)) {
+ //if we already created the img
+ $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
+ $myCache->saveFromCache($chartHash, $imgPath);
+ $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
+ } else {
+ /* Define width, height and angle */
+ $mainWidth = 760;
+ $mainHeight = 230;
+ $angle = 50;
+
+ /* Create the pChart object */
+ $myPicture = new pImage($mainWidth, $mainHeight, $myData);
+
+ /* Turn of Antialiasing */
+ $myPicture->Antialias = false;
+ /* Draw the background */
+ $settings = ["R" => 255, "G" => 255, "B" => 255];
+ $myPicture->drawFilledRectangle(0, 0, $mainWidth, $mainHeight, $settings);
+
+ /* Add a border to the picture */
+ $myPicture->drawRectangle(
+ 0,
+ 0,
+ $mainWidth - 1,
+ $mainHeight - 1,
+ ["R" => 0, "G" => 0, "B" => 0]
+ );
- /* Create and populate the pData object */
- $myData = new pData();
- $myData->addPoints($main_date, 'Serie1');
- if (count($main_date) != 1) {
- $myData->addPoints($labels, 'Labels');
- $myData->setSerieDescription('Labels', 'Months');
- $myData->setAbscissa('Labels');
- }
- $myData->setSerieWeight('Serie1', 1);
- $myData->setSerieDescription('Serie1', get_lang('MyResults'));
- $myData->setAxisName(0, get_lang('Minutes'));
- $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
+ /* Set the default font */
+ $myPicture->setFontProperties(
+ [
+ "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
+ "FontSize" => 10, ]
+ );
+ /* Write the chart title */
+ $myPicture->drawText(
+ $mainWidth / 2,
+ 30,
+ get_lang('TimeSpentInTheCourse'),
+ [
+ "FontSize" => 12,
+ "Align" => TEXT_ALIGN_BOTTOMMIDDLE,
+ ]
+ );
- // Cache definition
- $cachePath = api_get_path(SYS_ARCHIVE_PATH);
- $myCache = new pCache(['CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)]);
- $chartHash = $myCache->getHash($myData);
+ /* Set the default font */
+ $myPicture->setFontProperties(
+ [
+ "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
+ "FontSize" => 8,
+ ]
+ );
- if ($myCache->isInCache($chartHash)) {
- //if we already created the img
- $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
- $myCache->saveFromCache($chartHash, $imgPath);
- $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
- } else {
- /* Define width, height and angle */
- $mainWidth = 760;
- $mainHeight = 230;
- $angle = 50;
-
- /* Create the pChart object */
- $myPicture = new pImage($mainWidth, $mainHeight, $myData);
-
- /* Turn of Antialiasing */
- $myPicture->Antialias = false;
- /* Draw the background */
- $settings = ["R" => 255, "G" => 255, "B" => 255];
- $myPicture->drawFilledRectangle(0, 0, $mainWidth, $mainHeight, $settings);
-
- /* Add a border to the picture */
- $myPicture->drawRectangle(
- 0,
- 0,
- $mainWidth - 1,
- $mainHeight - 1,
- ["R" => 0, "G" => 0, "B" => 0]
- );
+ /* Define the chart area */
+ $myPicture->setGraphArea(50, 40, $mainWidth - 40, $mainHeight - 80);
+
+ /* Draw the scale */
+ $scaleSettings = [
+ 'XMargin' => 10,
+ 'YMargin' => 10,
+ 'Floating' => true,
+ 'GridR' => 200,
+ 'GridG' => 200,
+ 'GridB' => 200,
+ 'DrawSubTicks' => true,
+ 'CycleBackground' => true,
+ 'LabelRotation' => $angle,
+ 'Mode' => SCALE_MODE_ADDALL_START0,
+ ];
+ $myPicture->drawScale($scaleSettings);
+
+ /* Turn on Antialiasing */
+ $myPicture->Antialias = true;
+
+ /* Enable shadow computing */
+ $myPicture->setShadow(
+ true,
+ [
+ "X" => 1,
+ "Y" => 1,
+ "R" => 0,
+ "G" => 0,
+ "B" => 0,
+ "Alpha" => 10,
+ ]
+ );
- /* Set the default font */
- $myPicture->setFontProperties(
- [
- "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
- "FontSize" => 10, ]
- );
- /* Write the chart title */
- $myPicture->drawText(
- $mainWidth / 2,
- 30,
- get_lang('TimeSpentInTheCourse'),
- [
- "FontSize" => 12,
- "Align" => TEXT_ALIGN_BOTTOMMIDDLE,
- ]
- );
+ /* Draw the line chart */
+ $myPicture->setFontProperties(
+ [
+ "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
+ "FontSize" => 10,
+ ]
+ );
+ $myPicture->drawSplineChart();
+ $myPicture->drawPlotChart(
+ [
+ "DisplayValues" => true,
+ "PlotBorder" => true,
+ "BorderSize" => 1,
+ "Surrounding" => -60,
+ "BorderAlpha" => 80,
+ ]
+ );
- /* Set the default font */
- $myPicture->setFontProperties(
- [
- "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
- "FontSize" => 8,
- ]
- );
+ /* Do NOT Write the chart legend */
- /* Define the chart area */
- $myPicture->setGraphArea(50, 40, $mainWidth - 40, $mainHeight - 80);
-
- /* Draw the scale */
- $scaleSettings = [
- 'XMargin' => 10,
- 'YMargin' => 10,
- 'Floating' => true,
- 'GridR' => 200,
- 'GridG' => 200,
- 'GridB' => 200,
- 'DrawSubTicks' => true,
- 'CycleBackground' => true,
- 'LabelRotation' => $angle,
- 'Mode' => SCALE_MODE_ADDALL_START0,
- ];
- $myPicture->drawScale($scaleSettings);
-
- /* Turn on Antialiasing */
- $myPicture->Antialias = true;
-
- /* Enable shadow computing */
- $myPicture->setShadow(
- true,
- [
- "X" => 1,
- "Y" => 1,
- "R" => 0,
- "G" => 0,
- "B" => 0,
- "Alpha" => 10,
- ]
- );
+ /* Write and save into cache */
+ $myCache->writeToCache($chartHash, $myPicture);
+ $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
+ $myCache->saveFromCache($chartHash, $imgPath);
+ $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
+ }
- /* Draw the line chart */
- $myPicture->setFontProperties(
- [
- "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
- "FontSize" => 10,
- ]
- );
- $myPicture->drawSplineChart();
- $myPicture->drawPlotChart(
- [
- "DisplayValues" => true,
- "PlotBorder" => true,
- "BorderSize" => 1,
- "Surrounding" => -60,
- "BorderAlpha" => 80,
- ]
+ return '
';
+ } else {
+ return api_convert_encoding(
+ ''.get_lang('GraphicNotAvailable').'
',
+ 'UTF-8'
);
-
- /* Do NOT Write the chart legend */
-
- /* Write and save into cache */
- $myCache->writeToCache($chartHash, $myPicture);
- $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
- $myCache->saveFromCache($chartHash, $imgPath);
- $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
}
- $html = '
';
-
- return $html;
- } else {
- $foo_img = api_convert_encoding(
- ''.get_lang('GraphicNotAvailable').'
',
- 'UTF-8'
- );
-
- return $foo_img;
}
+
}
diff --git a/main/inc/lib/pear/HTML/Table.php b/main/inc/lib/pear/HTML/Table.php
index 1ea62097d9..24cf43e7ab 100755
--- a/main/inc/lib/pear/HTML/Table.php
+++ b/main/inc/lib/pear/HTML/Table.php
@@ -923,7 +923,7 @@ class HTML_Table extends HTML_Common
* @access public
* @return string
*/
- function toHtml()
+ public function toHtml()
{
$strHtml = '';
$tabs = $this->_getTabs();
@@ -1024,5 +1024,3 @@ class HTML_Table extends HTML_Common
}
}
-
-?>
diff --git a/main/inc/lib/sortable_table.class.php b/main/inc/lib/sortable_table.class.php
index 0ec74e8d16..c4ac6e6524 100755
--- a/main/inc/lib/sortable_table.class.php
+++ b/main/inc/lib/sortable_table.class.php
@@ -343,6 +343,13 @@ class SortableTable extends HTML_Table
echo $this->return_table();
}
+ public function toArray()
+ {
+ $headers = array_column($this->getHeaders(), 'label');
+
+ return array_merge([$headers], $this->get_table_data());
+ }
+
/**
* Displays the table, complete with navigation buttons to browse through
* the data-pages.
diff --git a/main/inc/lib/statistics.lib.php b/main/inc/lib/statistics.lib.php
index 213b2d9934..0abe29445b 100644
--- a/main/inc/lib/statistics.lib.php
+++ b/main/inc/lib/statistics.lib.php
@@ -230,9 +230,9 @@ class Statistics
if (isset($_GET['keyword'])) {
$keyword = Database::escape_string(trim($_GET['keyword']));
$sql .= " AND (
- user.username LIKE '%".$keyword."%' OR
- default_event_type LIKE '%".$keyword."%' OR
- default_value_type LIKE '%".$keyword."%' OR
+ user.username LIKE '%".$keyword."%' OR
+ default_event_type LIKE '%".$keyword."%' OR
+ default_value_type LIKE '%".$keyword."%' OR
default_value LIKE '%".$keyword."%') ";
}
@@ -403,7 +403,7 @@ class Statistics
public static function getCourseCategories()
{
$categoryTable = Database::get_main_table(TABLE_MAIN_CATEGORY);
- $sql = "SELECT code, name
+ $sql = "SELECT code, name
FROM $categoryTable
ORDER BY tree_pos";
$res = Database::query($sql);
@@ -514,8 +514,8 @@ class Statistics
$period = get_lang('PeriodMonth');
$periodCollection = api_get_months_long();
- $sql = "SELECT
- DATE_FORMAT( login_date, '%Y-%m' ) AS stat_date ,
+ $sql = "SELECT
+ DATE_FORMAT( login_date, '%Y-%m' ) AS stat_date ,
count( login_id ) AS number_of_logins
FROM $table $table_url $where_url
GROUP BY stat_date
@@ -525,32 +525,32 @@ class Statistics
switch ($type) {
case 'hour':
$period = get_lang('PeriodHour');
- $sql = "SELECT
- DATE_FORMAT( login_date, '%H') AS stat_date,
- count( login_id ) AS number_of_logins
- FROM $table $table_url $where_url
- GROUP BY stat_date
+ $sql = "SELECT
+ DATE_FORMAT( login_date, '%H') AS stat_date,
+ count( login_id ) AS number_of_logins
+ FROM $table $table_url $where_url
+ GROUP BY stat_date
ORDER BY stat_date ";
- $sql_last_x = "SELECT
- DATE_FORMAT( login_date, '%H' ) AS stat_date,
- count( login_id ) AS number_of_logins
- FROM $table $table_url $where_url ".sprintf($where_url_last, 'DAY')."
- GROUP BY stat_date
+ $sql_last_x = "SELECT
+ DATE_FORMAT( login_date, '%H' ) AS stat_date,
+ count( login_id ) AS number_of_logins
+ FROM $table $table_url $where_url ".sprintf($where_url_last, 'DAY')."
+ GROUP BY stat_date
ORDER BY stat_date ";
break;
case 'day':
$periodCollection = api_get_week_days_long();
$period = get_lang('PeriodDay');
- $sql = "SELECT DATE_FORMAT( login_date, '%w' ) AS stat_date ,
- count( login_id ) AS number_of_logins
- FROM $table $table_url $where_url
- GROUP BY stat_date
+ $sql = "SELECT DATE_FORMAT( login_date, '%w' ) AS stat_date ,
+ count( login_id ) AS number_of_logins
+ FROM $table $table_url $where_url
+ GROUP BY stat_date
ORDER BY DATE_FORMAT( login_date, '%w' ) ";
- $sql_last_x = "SELECT
- DATE_FORMAT( login_date, '%w' ) AS stat_date,
- count( login_id ) AS number_of_logins
- FROM $table $table_url $where_url ".sprintf($where_url_last, 'WEEK')."
- GROUP BY stat_date
+ $sql_last_x = "SELECT
+ DATE_FORMAT( login_date, '%w' ) AS stat_date,
+ count( login_id ) AS number_of_logins
+ FROM $table $table_url $where_url ".sprintf($where_url_last, 'WEEK')."
+ GROUP BY stat_date
ORDER BY DATE_FORMAT( login_date, '%w' ) ";
break;
}
@@ -631,17 +631,17 @@ class Statistics
$label = get_lang('Today');
}
$label .= "
$localDate - $localEndDate";
- $sql = "SELECT count($field) AS number
- FROM $table $table_url
- WHERE
+ $sql = "SELECT count($field) AS number
+ FROM $table $table_url
+ WHERE
UNIX_TIMESTAMP(logout_date) - UNIX_TIMESTAMP(login_date) > $sessionDuration AND
- login_date BETWEEN '$startDate' AND '$endDate'
+ login_date BETWEEN '$startDate' AND '$endDate'
$where_url";
$sqlList[$label] = $sql;
}
- $sql = "SELECT count($field) AS number
- FROM $table $table_url
+ $sql = "SELECT count($field) AS number
+ FROM $table $table_url
WHERE UNIX_TIMESTAMP(logout_date) - UNIX_TIMESTAMP(login_date) > $sessionDuration $where_url
";
$sqlList[get_lang('Total')] = $sql;
@@ -675,10 +675,10 @@ class Statistics
$sql = "
SELECT count(logins) count FROM (
SELECT count(login_user_id) AS logins
- FROM $table $table_url
- WHERE
- login_date BETWEEN '$startDate' AND '$endDate'
- $where_url
+ FROM $table $table_url
+ WHERE
+ login_date BETWEEN '$startDate' AND '$endDate'
+ $where_url
GROUP BY login_user_id
) as t
";
@@ -727,10 +727,10 @@ class Statistics
$sessionDuration = (int) $sessionDuration;
$sql = "SELECT count($field) AS number, date(login_date) as login_date
- FROM $table $table_url
- WHERE
+ FROM $table $table_url
+ WHERE
UNIX_TIMESTAMP(logout_date) - UNIX_TIMESTAMP(login_date) > $sessionDuration AND
- login_date >= '$newDate' $where_url
+ login_date >= '$newDate' $where_url
GROUP BY date(login_date)";
$res = Database::query($sql);
@@ -1026,16 +1026,16 @@ class Statistics
}
if (api_is_multiple_url_enabled()) {
- $sql = "SELECT lastname, firstname, username, COUNT($field) AS count_message
- FROM $access_url_rel_user_table as url, $message_table m
- LEFT JOIN $user_table u ON m.$field = u.user_id
- WHERE url.user_id = m.$field AND access_url_id='".$urlId."'
- GROUP BY m.$field
+ $sql = "SELECT lastname, firstname, username, COUNT($field) AS count_message
+ FROM $access_url_rel_user_table as url, $message_table m
+ LEFT JOIN $user_table u ON m.$field = u.user_id
+ WHERE url.user_id = m.$field AND access_url_id='".$urlId."'
+ GROUP BY m.$field
ORDER BY count_message DESC ";
} else {
- $sql = "SELECT lastname, firstname, username, COUNT($field) AS count_message
- FROM $message_table m
- LEFT JOIN $user_table u ON m.$field = u.user_id
+ $sql = "SELECT lastname, firstname, username, COUNT($field) AS count_message
+ FROM $message_table m
+ LEFT JOIN $user_table u ON m.$field = u.user_id
GROUP BY m.$field ORDER BY count_message DESC ";
}
$res = Database::query($sql);
@@ -1065,23 +1065,23 @@ class Statistics
$urlId = api_get_current_access_url_id();
if (api_is_multiple_url_enabled()) {
- $sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend
- FROM $access_url_rel_user_table as url, $user_friend_table uf
- LEFT JOIN $user_table u
- ON (uf.user_id = u.user_id)
- WHERE
- uf.relation_type <> '".USER_RELATION_TYPE_RRHH."' AND
- uf.user_id = url.user_id AND
- access_url_id = '".$urlId."'
- GROUP BY uf.user_id
+ $sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend
+ FROM $access_url_rel_user_table as url, $user_friend_table uf
+ LEFT JOIN $user_table u
+ ON (uf.user_id = u.user_id)
+ WHERE
+ uf.relation_type <> '".USER_RELATION_TYPE_RRHH."' AND
+ uf.user_id = url.user_id AND
+ access_url_id = '".$urlId."'
+ GROUP BY uf.user_id
ORDER BY count_friend DESC ";
} else {
- $sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend
- FROM $user_friend_table uf
- LEFT JOIN $user_table u
- ON (uf.user_id = u.user_id)
- WHERE uf.relation_type <> '".USER_RELATION_TYPE_RRHH."'
- GROUP BY uf.user_id
+ $sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend
+ FROM $user_friend_table uf
+ LEFT JOIN $user_table u
+ ON (uf.user_id = u.user_id)
+ WHERE uf.relation_type <> '".USER_RELATION_TYPE_RRHH."'
+ GROUP BY uf.user_id
ORDER BY count_friend DESC ";
}
$res = Database::query($sql);
@@ -1262,7 +1262,7 @@ class Statistics
if (!empty($result)) {
$actions = Display::url(
- Display::return_icon('excel.png', get_lang('ExportToXls'), [], ICON_SIZE_MEDIUM),
+ Display::return_icon('excel.png', get_lang('ExportAsXLS'), [], ICON_SIZE_MEDIUM),
api_get_self().'?'.http_build_query(
[
'report' => 'logins_by_date',
diff --git a/main/mySpace/access_details.php b/main/mySpace/access_details.php
index 1d7e57ea70..960b302619 100755
--- a/main/mySpace/access_details.php
+++ b/main/mySpace/access_details.php
@@ -1,11 +1,10 @@
').
+ attr(\"href\", url+'&export=excel')
+ .attr('class', 'btn btn-default')
+ .attr('target', '_blank')
+ .html('".addslashes(get_lang('ExportAsXLS'))."');
+
+ $('#messages').append(exportLink);
+
$('#cev_cont_stats').html(db.stats);
- $('#graph' ).html(db.graph_result);
+ $('#graph').html(db.graph_result);
} else {
$('#messages').text('".get_lang('NoDataAvailable')."');
$('#messages').addClass('warning-message');
@@ -118,24 +128,16 @@ $(function() {
changeMonth: true,
changeYear: true
});
+
+ $(\"#cev_button\").hide();
});
";
-$htmlHeadXtra[] = '';
-
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('AccessDetails')];
Display::display_header('');
$userInfo = api_get_user_info($user_id);
-$result_to_print = '';
-$sql_result = MySpace::get_connections_to_course($user_id, $courseInfo);
-$result_to_print = convert_to_string($sql_result);
echo Display::page_header(get_lang('DetailsStudentInCourse'));
echo Display::page_subheader(
@@ -156,17 +158,17 @@ $form->display();
- '.get_lang('Total').': '.$rst['total'].'
';
- $foo_stats .= ''.get_lang('Average').': '.$rst['avg'].'
';
- $foo_stats .= ''.get_lang('Quantity').' : '.$rst['times'].'
';
- echo $foo_stats;
+ '.get_lang('Total').': '.$data['total'].'
';
+ $stats .= ''.get_lang('Average').': '.$data['avg'].'
';
+ $stats .= ''.get_lang('Quantity').' : '.$data['times'].'
';
+ echo $stats;
} else {
echo Display::return_message(get_lang('NoDataAvailable'), 'warning');
}
- ?>
+ ?>