diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index 11fb9ee6c3..e49bf5861f 100644 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -141,7 +141,7 @@ class Tracking { //If the last connection is > than 7 days, the text is red //345600 = 7 days in seconds if ($currentTimestamp - $timestamp > 604800) { - return '' . format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($last_login_date)) . ' '; + return '' . format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($last_login_date)) . ' '; } else { return format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($last_login_date)); } @@ -657,6 +657,31 @@ class Tracking { } return $a_courses; } + + function get_inactives_students_in_course($course_code, $since, $session_id=0) + { + $tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); + $tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER); + $inner = ''; + if($session_id!=0) + { + $inner = ' INNER JOIN '.$tbl_session_course_user.' session_course_user + ON stats_login.course_code = session_course_user.course_code + AND session_course_user.id_session = '.intval($session_id).' + AND session_course_user.id_user = stats_login.user_id '; + } + $sql = 'SELECT user_id, MAX(login_course_date) max_date FROM'.$tbl_track_login.' stats_login'.$inner.' + GROUP BY user_id + HAVING DATE_ADD(max_date, INTERVAL '.$since.' DAY) < NOW() '; + + $rs = api_sql_query($sql,__FILE__,__LINE__); + $inactive_users = array(); + while($user = Database::fetch_array($rs)) + { + $inactive_users[] = $user['user_id']; + } + return $inactive_users; + } } ?> \ No newline at end of file diff --git a/main/tracking/courseLog.php b/main/tracking/courseLog.php index cb5a0a2fb5..aa6b27733b 100644 --- a/main/tracking/courseLog.php +++ b/main/tracking/courseLog.php @@ -66,6 +66,7 @@ require_once(api_get_path(LIBRARY_PATH).'tracking.lib.php'); require_once(api_get_path(LIBRARY_PATH).'course.lib.php'); require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php'); require_once (api_get_path(LIBRARY_PATH).'export.lib.inc.php'); +require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); @@ -180,8 +181,8 @@ else '.get_lang('CourseTracking').'  '; } -echo '
-  '.get_lang('Print').''; +echo '
'; +echo '  '.get_lang('Print').''; if($_GET['studentlist'] == 'false'){ echo ' '.get_lang('ExportAsCSV').'
'; } @@ -470,6 +471,33 @@ if($_GET['studentlist'] == 'false') // else display student list with all the informations else { + // BEGIN : form to remind inactives susers + $form = new FormValidator('reminder_form','get',api_get_path(REL_CLARO_PATH).'announcements/announcements.php'); + + $renderer = $form->defaultRenderer(); + $renderer->setElementTemplate('{label} {element}  '2 '.get_lang('Days'), + 3 => '3 '.get_lang('Days'), + 4 => '4 '.get_lang('Days'), + 5 => '5 '.get_lang('Days'), + 6 => '6 '.get_lang('Days'), + 7 => '7 '.get_lang('Days'), + 15 => '15 '.get_lang('Days'), + 30 => '30 '.get_lang('Days') + ); + + $el = $form -> addElement('select','since',''.get_lang('RemindInactivesLearnersSince'),$options); + $el -> setSelected(7); + + $form -> addElement('hidden','action','add'); + $form -> addElement('hidden','remindallinactives','true'); + + $form -> display(); + // END : form to remind inactives susers + + $tracking_column = isset($_GET['tracking_column']) ? $_GET['tracking_column'] : 0; $tracking_direction = isset($_GET['tracking_direction']) ? $_GET['tracking_direction'] : DESC;