|
|
|
@ -164,6 +164,39 @@ class Statistics |
|
|
|
|
return $obj->number; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param string $startDate |
|
|
|
|
* @param string $endDate |
|
|
|
|
* |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
public static function getCoursesWithActivity($startDate, $endDate) |
|
|
|
|
{ |
|
|
|
|
$access_url_rel_course_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
|
|
|
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS); |
|
|
|
|
$startDate = Database::escape_string($startDate); |
|
|
|
|
$endDate = Database::escape_string($endDate); |
|
|
|
|
|
|
|
|
|
$urlId = api_get_current_access_url_id(); |
|
|
|
|
|
|
|
|
|
if (api_is_multiple_url_enabled()) { |
|
|
|
|
$sql = "SELECT DISTINCT(t.c_id) FROM $table t , $access_url_rel_course_table a |
|
|
|
|
WHERE |
|
|
|
|
t.c_id = a.c_id AND |
|
|
|
|
access_url_id='".$urlId."' AND |
|
|
|
|
access_date BETWEEN '$startDate' AND '$endDate' |
|
|
|
|
"; |
|
|
|
|
} else { |
|
|
|
|
$sql = "SELECT DISTINCT(t.c_id) FROM $table t |
|
|
|
|
access_date BETWEEN '$startDate' AND '$endDate' "; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
|
|
|
|
|
return Database::store_result($result); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Count activities from track_e_default_table. |
|
|
|
|
* |
|
|
|
@ -626,6 +659,41 @@ class Statistics |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function getLoginCount($startDate, $endDate) |
|
|
|
|
{ |
|
|
|
|
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
|
|
|
|
$access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
|
|
|
$urlId = api_get_current_access_url_id(); |
|
|
|
|
$table_url = ''; |
|
|
|
|
$where_url = ''; |
|
|
|
|
if (api_is_multiple_url_enabled()) { |
|
|
|
|
$table_url = ", $access_url_rel_user_table"; |
|
|
|
|
$where_url = " AND login_user_id=user_id AND access_url_id='".$urlId."'"; |
|
|
|
|
} |
|
|
|
|
$startDate = Database::escape_string($startDate); |
|
|
|
|
$endDate = Database::escape_string($endDate); |
|
|
|
|
|
|
|
|
|
$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 |
|
|
|
|
GROUP BY login_user_id |
|
|
|
|
) as t |
|
|
|
|
"; |
|
|
|
|
|
|
|
|
|
$res = Database::query($sql); |
|
|
|
|
$totalLogin = 0; |
|
|
|
|
$row = Database::fetch_array($res, 'ASSOC'); |
|
|
|
|
if ($row) { |
|
|
|
|
$totalLogin = $row['count']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $totalLogin; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* get the number of recent logins. |
|
|
|
|
* |
|
|
|
|