Browse Source

[svn r17456] logic changes - Added in the reporting the last conexions of an user in the chat see FS#1099

Cristian Fasanando 16 years ago
parent
commit
c01993429d
3 changed files with 54 additions and 2 deletions
  1. 1 0
      documentation/changelog.html
  2. 33 0
      main/inc/lib/tracking.lib.php
  3. 20 2
      main/mySpace/myStudents.php

+ 1 - 0
documentation/changelog.html

@@ -62,6 +62,7 @@
   <li>Option to hide/show e-mail addresses to all users (SVN#16965, SVN#16968)</li>
   <li>Added an introduction section for each group area (SVN#17424)</li>
   <li>New notebook tool</li>
+  <li>Added in the reporting the last conexions of a user in the chat  </li>
 </ul>
 <br />
 <h3>Debugging</h3>

+ 33 - 0
main/inc/lib/tracking.lib.php

@@ -787,6 +787,39 @@ class Tracking {
 			return null;
 		}
 	}
+	
+	function last_three_connection_chat($student_id,$course_code) {
+		require_once (api_get_path(LIBRARY_PATH) . 'course.lib.php');
+		
+		//protect datas
+		$student_id = intval($student_id);
+		$course_code = addslashes($course_code);
+		
+		// get the informations of the course 
+		$a_course = CourseManager :: get_course_information($course_code);		
+		
+		if (!empty($a_course['db_name'])) {
+			// table definition
+			$tbl_stats_access = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS, $a_course['db_name']);
+			$sql = "SELECT access_date FROM $tbl_stats_access 
+					 WHERE access_tool='".TOOL_CHAT."' AND access_user_id='$student_id' AND access_cours_code = '$course_code' limit 3";
+					 	
+			$rs = api_sql_query($sql, __LINE__, __FILE__);
+			$last_connnections = array();
+			while ($row = Database::fetch_array($rs)) {
+				$last_connection = $row['access_date'];
+				if (isset($last_connection)) {				
+					$date_format_long = format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($last_connection));			 
+					$time = explode(' ',$last_connection);	
+					$date_time = $date_format_long.' '.$time[1];	
+					$last_connnections[] = $date_time;										
+				}
+			}
+			return $last_connnections; 
+		} else {
+				return null;
+		}										
+	}
 
 	function count_student_visited_links($student_id, $course_code) {
 		// protect datas

+ 20 - 2
main/mySpace/myStudents.php

@@ -1,4 +1,4 @@
-<?php //$Id: myStudents.php 17362 2008-12-17 23:21:17Z cfasanando $
+<?php //$Id: myStudents.php 17456 2008-12-24 20:34:06Z cfasanando $
 /* For licensing terms, see /dokeos_license.txt */
 /**
  * Implements the tracking of students in the Reporting pages
@@ -860,11 +860,13 @@ if(!empty($_GET['student']))
 			$messages = Tracking :: count_student_messages($a_infosUser['user_id'], $a_infosCours['code']);
 			$links = Tracking :: count_student_visited_links($a_infosUser['user_id'], $a_infosCours['code']);
 			$documents = Tracking :: count_student_downloaded_documents($a_infosUser['user_id'], $a_infosCours['code']);
-			
+			$last_three_connections_chat = Tracking::last_three_connection_chat($a_infosUser['user_id'], $a_infosCours['code']);
+	
 			$csv_content[] = array(get_lang('Student_publication'), $nb_assignments);
 			$csv_content[] = array(get_lang('Messages'), $messages);
 			$csv_content[] = array(get_lang('LinksDetails'), $links);
 			$csv_content[] = array(get_lang('DocumentsDetails'), $documents);
+			
 			?>
 				<tr>
 					<th colspan="2">
@@ -903,6 +905,22 @@ if(!empty($_GET['student']))
 						<?php echo $documents ?>
 					</td>
 				</tr>
+				<tr><!-- Chats -->
+					<td>
+						<?php echo get_lang('LastConnectionsInChat') ?>
+					</td>
+					<td>
+						<?php 
+						$last_connections_chat ='';						
+						for($i=0;$i<count($last_three_connections_chat);$i++){
+							echo $last_three_connections_chat[$i].'<br/>';
+							
+							$last_connections_chat .= str_replace(',', ' ', $last_three_connections_chat[$i]).' ';							
+						}
+						$csv_content[] = array(get_lang('LastConnectionsInChat'), $last_connections_chat);
+						?>
+					</td>
+				</tr>
 			</table>
 			</td>
 		</tr>