Просмотр исходного кода

[svn r13580] now we are able to remind all users inactive since x days

Eric Marguin 17 лет назад
Родитель
Сommit
15a2bfc10f
2 измененных файлов с 56 добавлено и 3 удалено
  1. 26 1
      main/inc/lib/tracking.lib.php
  2. 30 2
      main/tracking/courseLog.php

+ 26 - 1
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 '<span style="color: #F00;">' . format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($last_login_date)) . ' <a href="'.api_get_path(REL_CLARO_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'" title="'.get_lang('RemindInactiveUser').'"><img align="middle" src="'.api_get_path(WEB_IMG_PATH).'linphone.gif" /></a></span>';
+				return '<span style="color: #F00;">' . format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($last_login_date)) . ' <a href="'.api_get_path(REL_CLARO_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'" title="'.get_lang('RemindInactiveUser').'"><img align="middle" src="'.api_get_path(WEB_IMG_PATH).'messagebox_warning.gif" /></a></span>';
 			} 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;
+	}
 
 }
 ?>

+ 30 - 2
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
 			<a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a>&nbsp;
 		  </div>';
 }
-echo '<div style="float:right; clear:right">
-		<a href="#" onclick="window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>';
+echo '<div style="float:right; clear:right">';
+echo '&nbsp;<a href="#" onclick="window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>';
 if($_GET['studentlist'] == 'false'){	
 	echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=csv&studentlist=false"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a></div>';
 }
@@ -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('<span>{label} {element}</span>&nbsp;<input type="submit" value="'.get_lang('Ok').'"','since');
+	
+	$options = array(
+				2 => '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','<img width="22" align="middle" src="'.api_get_path(WEB_IMG_PATH).'messagebox_warning.gif" border="0" />'.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;