List users time in platform - refs BT#9087

1.10.x
Angel Fernando Quiroz Campos 11 years ago
parent 6d76ad0003
commit f5c9867957
  1. 16
      main/admin/teacher_time_report.php
  2. 17
      main/inc/lib/sessionmanager.lib.php

@ -53,10 +53,6 @@ $sessionsList = SessionManager::get_sessions_list(array(), array('name'));
$teacherList = SessionManager::getAllCourseCoaches();
foreach ($courseCoaches as &$coach) {
$coach['totalTime'] = SessionManager::getTotalUserTimeInPlatform($coach['id']);
}
$htmlHeadXtra[] = '
<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/daterange/moment.min.js"></script>
<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/daterange/daterangepicker-bs2.css">
@ -189,6 +185,18 @@ if (!empty($selectedTeacher)) {
}
}
if (empty($selectedCourse) && empty($selectedSession) && empty($selectedTeacher)) {
foreach ($teacherList as &$teacher) {
$rows[] = array(
'coach' => array(
'username' => $teacher['username'],
'completeName' => $teacher['completeName'],
),
'totalTime' => SessionManager::getTotalUserTimeInPlatform($teacher['id'], $selectedFrom, $selectedUntil)
);
}
}
// view
//hack for daterangepicker
$startDate->modify('+1 day');

@ -5336,21 +5336,30 @@ class SessionManager
/**
* Calculate the total user time in the platform
* @param int $userId The user id
* @param string $from Optional. From date
* @param string $until Optional. Until date
* @return string The time (hh:mm:ss)
*/
public static function getTotalUserTimeInPlatform($userId)
public static function getTotalUserTimeInPlatform($userId, $from = '', $until = '')
{
$userId = intval($userId);
$trackLoginTable = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$whereConditions = array(
'login_user_id = ?' => $userId
);
if (!empty($from) && !empty($until)) {
$whereConditions["AND (login_date >= '?' "] = $from;
$whereConditions["AND logout_date <= '?') "] = $until;
}
$trackResult = Database::select(
'SEC_TO_TIME(SUM(UNIX_TIMESTAMP(logout_date) - UNIX_TIMESTAMP(login_date))) as total_time',
$trackLoginTable,
array(
'where' => array(
'login_user_id = ?' => $userId
)
'where' => $whereConditions
), 'first'
);

Loading…
Cancel
Save