Skip to content

Commit

Permalink
Fix student detail time tracking data collection - refs CT#8405
Browse files Browse the repository at this point in the history
  • Loading branch information
ywarnier committed Aug 18, 2016
1 parent 5880234 commit 608a869
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 48 deletions.
4 changes: 2 additions & 2 deletions main/inc/ajax/myspace.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
if ($range == 1) {
$start_date = Security::remove_XSS($_REQUEST['sd']);
$end_date = Security::remove_XSS($_REQUEST['ed']);
$sql_result = get_connections_to_course_by_date(
$sql_result = MySpace::get_connections_to_course_by_date(
$user_id,
$courseId,
$start_date,
Expand All @@ -47,7 +47,7 @@
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];

$sql_result = get_connections_to_course_by_date(
$sql_result = MySpace::get_connections_to_course_by_date(
$user_id,
$courseId,
$start_date,
Expand Down
91 changes: 45 additions & 46 deletions main/inc/lib/myspace.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2998,6 +2998,51 @@ public static function getUserDataAccessTrackingOverview($from, $numberItems, $c

return $return;
}

/**
* Gets the connections to a course as an array of login and logout time
*
* @param int $user_id
* @param int $courseId
* @author Jorge Frisancho Jibaja
* @author Julio Montoya <gugli100@gmail.com> fixing the function
* @version OCT-22- 2010
* @return array
*/
public static function get_connections_to_course_by_date($user_id, $courseId, $start_date, $end_date)
{
// Database table definitions
$tbl_track_course = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$course_info = api_get_course_info_by_id($courseId);
$user_id = intval($user_id);
$courseId = intval($courseId);
$connections = array();

if (!empty($course_info)) {
$end_date = add_day_to($end_date);
$sql = "SELECT login_course_date, logout_course_date
FROM $tbl_track_course
WHERE
user_id = $user_id AND
c_id = $courseId AND
login_course_date BETWEEN '$start_date' AND '$end_date' AND
logout_course_date BETWEEN '$start_date' AND '$end_date'
ORDER BY login_course_date ASC";
$rs = Database::query($sql);

while ($row = Database::fetch_array($rs)) {
$login_date = $row['login_course_date'];
$logout_date = $row['logout_course_date'];
$timestamp_login_date = strtotime($login_date);
$timestamp_logout_date = strtotime($logout_date);
$connections[] = array(
'login' => $timestamp_login_date,
'logout' => $timestamp_logout_date
);
}
}
return $connections;
}
}

/**
Expand Down Expand Up @@ -3052,52 +3097,6 @@ function add_day_to($end_date) {
return $foo_date;
}


/**
* Gets the connections to a course as an array of login and logout time
*
* @param int $user_id
* @param int $courseId
* @author Jorge Frisancho Jibaja
* @author Julio Montoya <gugli100@gmail.com> fixing the function
* @version OCT-22- 2010
* @return array
*/
function get_connections_to_course_by_date($user_id, $courseId, $start_date, $end_date)
{
// Database table definitions
$tbl_track_course = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$course_info = api_get_course_info_by_id($courseId);
$user_id = intval($user_id);
$courseId = intval($courseId);
$connections = array();

if (!empty($course_info)) {
$end_date = add_day_to($end_date);
$sql = "SELECT login_course_date, logout_course_date
FROM $tbl_track_course
WHERE
user_id = $user_id AND
c_id = $courseId AND
login_course_date BETWEEN '$start_date' AND '$end_date' AND
logout_course_date BETWEEN '$start_date' AND '$end_date'
ORDER BY login_course_date ASC";
$rs = Database::query($sql);

while ($row = Database::fetch_array($rs)) {
$login_date = $row['login_course_date'];
$logout_date = $row['logout_course_date'];
$timestamp_login_date = strtotime($login_date);
$timestamp_logout_date = strtotime($logout_date);
$connections[] = array(
'login' => $timestamp_login_date,
'logout' => $timestamp_logout_date
);
}
}
return $connections;
}

/**
*
*
Expand Down

0 comments on commit 608a869

Please sign in to comment.