From 9a270341020a8c1b6170953f56c28efb37129e7c Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 8 Mar 2017 12:19:09 +0100 Subject: [PATCH] Minor - format code, update docs --- main/inc/lib/events.lib.php | 44 +++++++++++++++++++++---------------- main/work/work.lib.php | 2 +- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/main/inc/lib/events.lib.php b/main/inc/lib/events.lib.php index 4352c809eb..bec2b7bd59 100644 --- a/main/inc/lib/events.lib.php +++ b/main/inc/lib/events.lib.php @@ -1769,13 +1769,19 @@ class Event * end at the same second as the user connected to the course. * @param int $courseId The course in which to add the time * @param int $userId The user for whom to add the time - * @param $sessionId The session in which to add the time (if any) + * @param int $sessionId The session in which to add the time (if any) * @param string $virtualTime The amount of time to be added, in a hh:mm:ss format. If int, we consider it is expressed in hours. * @param string $ip IP address to go on record for this time record + * * @return True on successful insertion, false otherwise */ - public static function eventAddVirtualCourseTime($courseId, $userId, $sessionId, $virtualTime = '', $ip = '') - { + public static function eventAddVirtualCourseTime( + $courseId, + $userId, + $sessionId, + $virtualTime = '', + $ip = '' + ) { $courseTrackingTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); $time = $loginDate = $logoutDate = api_get_utc_datetime(); @@ -1787,13 +1793,13 @@ class Event // Get the current latest course connection register. We need that // record to re-use the data and create a new record. $sql = "SELECT * - FROM $courseTrackingTable - WHERE - user_id = ".$userId." AND - c_id = ".$courseId." AND - session_id = ".$sessionId." AND - login_course_date > '$time' - INTERVAL 3600 SECOND - ORDER BY login_course_date DESC LIMIT 0,1"; + FROM $courseTrackingTable + WHERE + user_id = ".$userId." AND + c_id = ".$courseId." AND + session_id = ".$sessionId." AND + login_course_date > '$time' - INTERVAL 3600 SECOND + ORDER BY login_course_date DESC LIMIT 0,1"; $result = Database::query($sql); // Ignore if we didn't find any course connection record in the last @@ -1833,16 +1839,16 @@ class Event ); // We update the course tracking table $sql = "UPDATE $courseTrackingTable - SET - login_course_date = '$loginDate', - logout_course_date = '$courseAccessLoginDate', - counter = 0 - WHERE - course_access_id = ".intval($courseAccessId)." AND - session_id = ".$sessionId; - $result = Database::query($sql); + SET + login_course_date = '$loginDate', + logout_course_date = '$courseAccessLoginDate', + counter = 0 + WHERE + course_access_id = ".intval($courseAccessId)." AND + session_id = ".$sessionId; + Database::query($sql); - return $result; + return true; } return false; diff --git a/main/work/work.lib.php b/main/work/work.lib.php index 001b509fb7..83e3f6841e 100755 --- a/main/work/work.lib.php +++ b/main/work/work.lib.php @@ -3823,7 +3823,6 @@ function processWorkForm( ); $workingTime = null; - foreach ($resultExtra as $field) { $field = $field['value']; @@ -3834,6 +3833,7 @@ function processWorkForm( // If no time was defined, or a time of "0" was set, do nothing if (!empty($workingTime)) { + // If some time is set, get the list of docs handed in by // this student (to make sure we count the time only once) $userWorks = get_work_user_list(