From 145b7c6c478bbd8ac6dd0c4644b797338571f36d Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 18 Aug 2016 12:23:40 -0500 Subject: [PATCH 1/8] Fix student detail time tracking data collection - refs CT#8405 --- main/inc/ajax/myspace.ajax.php | 4 +- main/inc/lib/myspace.lib.php | 91 +++++++++++++++++----------------- 2 files changed, 47 insertions(+), 48 deletions(-) diff --git a/main/inc/ajax/myspace.ajax.php b/main/inc/ajax/myspace.ajax.php index 6538278c59..a85794c36f 100755 --- a/main/inc/ajax/myspace.ajax.php +++ b/main/inc/ajax/myspace.ajax.php @@ -20,7 +20,7 @@ switch ($action) { 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, @@ -47,7 +47,7 @@ switch ($action) { $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, diff --git a/main/inc/lib/myspace.lib.php b/main/inc/lib/myspace.lib.php index 6f0f95b3a9..1bc64c22d3 100644 --- a/main/inc/lib/myspace.lib.php +++ b/main/inc/lib/myspace.lib.php @@ -2967,6 +2967,51 @@ class MySpace 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 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; + } } /** @@ -3021,52 +3066,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 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; -} - /** * * From a0ee00b727a1f88ba9e777c6ff1577a408702f86 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 18 Aug 2016 13:55:49 -0500 Subject: [PATCH 2/8] Fix #1364 extended profile field values not visible in profile edition --- main/inc/lib/api.lib.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 12d345c591..8191b8f30a 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -1447,6 +1447,12 @@ function _api_format_user($user, $add_password = false) 'expiration_date', 'last_login' ); + if (api_get_setting('extended_profile') === 'true') { + $attributes[] = 'competences'; + $attributes[] = 'diplomas'; + $attributes[] = 'teach'; + $attributes[] = 'openarea'; + } foreach ($attributes as $attribute) { $result[$attribute] = isset($user[$attribute]) ? $user[$attribute] : null; From 9b821ab6ee1abe11df2a0dc303fcf795f28d1642 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 18 Aug 2016 14:07:52 -0500 Subject: [PATCH 3/8] Fix #1369 preventing teachers from seeing page 2 of teachers list in users tool --- main/user/user.php | 1 + 1 file changed, 1 insertion(+) diff --git a/main/user/user.php b/main/user/user.php index ce784f9240..5bfb0f8f96 100755 --- a/main/user/user.php +++ b/main/user/user.php @@ -856,6 +856,7 @@ $parameters['keyword'] = isset($_GET['keyword']) ? Security::remove_XSS($_GET['k $parameters['sec_token'] = Security::get_token(); $parameters['cidReq'] = api_get_cidreq(); $parameters['id_session'] = api_get_session_id(); +$parameters['type'] = $type; $table->set_additional_parameters($parameters); $header_nr = 0; From 019cd4bca5724f683e7611f4dc83e3350e7b6e2c Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Fri, 19 Aug 2016 10:40:10 +0200 Subject: [PATCH 4/8] Fix js error adding addslashes --- main/inc/lib/formvalidator/FormValidator.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main/inc/lib/formvalidator/FormValidator.class.php b/main/inc/lib/formvalidator/FormValidator.class.php index b91883951f..9823b19c3f 100755 --- a/main/inc/lib/formvalidator/FormValidator.class.php +++ b/main/inc/lib/formvalidator/FormValidator.class.php @@ -1337,14 +1337,14 @@ EOT; var uploadButton = $('