Work: Count considered_working_time as total time connected to the platform - refs BT#16104

pull/3035/head^2
Yannick Warnier 6 years ago
parent 36b5e50a53
commit c0a1e2d5c0
  1. 28
      main/inc/lib/events.lib.php
  2. 2
      main/mySpace/myStudents.php
  3. 1
      main/work/work.lib.php

@ -2260,6 +2260,17 @@ class Event
$courseTrackingTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
Database::insert($courseTrackingTable, $params);
// Time should also be added to the track_e_login table so as to
// affect total time on the platform
$params = [
'login_user_id' => $userId,
'login_date' => $loginDate,
'user_ip' => api_get_real_ip(),
'logout_date' => $logoutDate
];
$platformTrackingTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
Database::insert($platformTrackingTable, $params);
return true;
}
@ -2292,6 +2303,7 @@ class Event
return false;
}
$courseTrackingTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$platformTrackingTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$courseId = (int) $courseId;
$userId = (int) $userId;
$sessionId = (int) $sessionId;
@ -2326,8 +2338,22 @@ class Event
$courseAccessId = $row[0];
$sql = "DELETE FROM $courseTrackingTable
WHERE course_access_id = $courseAccessId";
Database::query($sql);
}
$sql = "SELECT login_id
FROM $platformTrackingTable
WHERE
login_user_id = $userId AND
(UNIX_TIMESTAMP(logout_date) - UNIX_TIMESTAMP(login_date)) = '$virtualTime'
ORDER BY login_date DESC LIMIT 0,1";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
// Found the latest connection
$row = Database::fetch_row($result);
$loginAccessId = $row[0];
$sql = "DELETE FROM $platformTrackingTable
WHERE login_id = $loginAccessId";
$result = Database::query($sql);
return $result;
}

@ -1855,7 +1855,7 @@ if (empty($details)) {
echo '<td class="text-center"><a href="'.$url.'">('.$documentNumber.')</a></td>';
$qualification = !empty($results['qualification']) ? $results['qualification'] : '-';
echo '<td class="text-center">'.$qualification.'</td>';
echo '<td class="text-center">'.$results['formatted_date'].'</td>';
echo '<td class="text-center">'.api_convert_and_format_date($results['sent_date_from_db']).' '.$results['expiry_note'].'</td>';
$assignment = get_work_assignment_by_id($work->id, $courseInfo['real_id']);
echo '<td class="text-center">';

@ -2069,6 +2069,7 @@ function get_work_user_list(
$work_date = api_get_local_time($work['sent_date']);
$date = date_to_str_ago($work['sent_date']).' '.$work_date;
$work['formatted_date'] = $work_date.' '.$add_string;
$work['expiry_note'] = $add_string;
$work['sent_date_from_db'] = $work['sent_date'];
$work['sent_date'] = '<div class="work-date" title="'.$date.'">'.
$add_string.' '.Display::dateToStringAgoAndLongDate($work['sent_date']).'</div>';

Loading…
Cancel
Save