瀏覽代碼

Fixing Exercise results when dealing with LPs + sessions + Improving the lp reset feature see BT#1401 + some Minor UI changes

Julio Montoya 14 年之前
父節點
當前提交
07e3ac9215

+ 1 - 1
main/auth/my_progress.php

@@ -247,7 +247,7 @@ foreach ($courses as $enreg) {
 
 						$last_connection_in_lp = Tracking::get_last_connection_time_in_lp($_user['user_id'], $course, $learnpath['id']);
 						if (!empty($last_connection_in_lp)) {
-							echo date('Y-m-d h:i:s', $last_connection_in_lp);
+							echo api_get_utc_datetime($last_connection_in_lp);
 						} else {
 							echo '-';
 						}

+ 48 - 2
main/inc/lib/events.lib.inc.php

@@ -615,8 +615,7 @@ function get_last_attempt_date_of_exercise($exe_id) {
 	$track_exercises 		= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
 	
 	$sql_track_attempt 		= 'SELECT max(tms) as last_attempt_date FROM '.$track_attempts.' WHERE exe_id='.$exe_id;
-	error_log('$sql_track_attempt: '.$sql_track_attempt);
-	 	       
+		 	       
 	$rs_last_attempt 		= Database::query($sql_track_attempt);	
 	$row_last_attempt 		= Database::fetch_array($rs_last_attempt);	
 	$last_attempt_date 		= $row_last_attempt['last_attempt_date'];//Get the date of last attempt
@@ -645,3 +644,50 @@ function get_attempt_count($user_id, $exerciseId, $lp_id, $lp_item_id) {
 }
 
 
+function delete_student_lp_events($user_id, $lp_id, $course, $session_id) {
+        
+	$lp_view_table         = Database::get_course_table(TABLE_LP_VIEW, $course['dbName']);
+    $lp_item_view_table    = Database::get_course_table(TABLE_LP_ITEM_VIEW, $course['dbName']);
+    
+    $track_e_exercises     = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+    $track_attempts        = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
+    $TBL_RECORDING         = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING);
+    
+    $user_id    = intval($user_id);
+    $lp_id      = intval($lp_id);
+    $session_id = intval($session_id);
+    
+    //make sure we have the exact lp_view_id
+    $sqlview       = "SELECT id FROM $lp_view_table WHERE user_id = $user_id AND lp_id = $lp_id AND session_id = $session_id ";                    
+    $resultview    = Database::query($sqlview);
+    $view          = Database::fetch_array($resultview, 'ASSOC');
+    $lp_view_id    = $view['id'];                  
+    
+    $sql_delete = "DELETE FROM $lp_item_view_table  WHERE lp_view_id = $view_id ";
+    $result = Database::query($sql_delete);
+        
+    $sql_delete = "DELETE FROM $lp_view_table  WHERE user_id = $user_id AND lp_id= $lp_id AND session_id= $session_id ";
+    $result = Database::query($sql_delete);
+    
+    $select_all_attempts = "SELECT exe_id FROM $track_e_exercises WHERE exe_user_id = $user_id AND session_id= $session_id  AND exe_cours_id = '{$course['id']}' AND orig_lp_id = $lp_id";    
+    $result    = Database::query($select_all_attempts);
+    $exe_list = array();
+    while ($row = Database::fetch_array($result, 'ASSOC')) {
+    	$exe_list[] = $row['exe_id'];
+    }    
+    
+    if (!empty($exe_list) && is_array($exe_list) && count($exe_list) > 1) {        
+        $sql_delete = "DELETE FROM $track_e_exercises  WHERE exe_id IN (".implode(',',$exe_list).")";
+        $result = Database::query($sql_delete);
+        
+        $sql_delete = "DELETE FROM $track_attempts  WHERE exe_id IN (".implode(',',$exe_list).")";
+        $result = Database::query($sql_delete);
+        
+        $sql_delete = "DELETE FROM $TBL_RECORDING  WHERE exe_id IN (".implode(',',$exe_list).")";
+        $result = Database::query($sql_delete);        
+    }
+    
+
+}
+
+

+ 51 - 62
main/inc/lib/tracking.lib.php

@@ -109,12 +109,11 @@ class Tracking {
 	public static function get_first_connection_date($student_id) {
 		$tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
 		$sql = 'SELECT login_date FROM ' . $tbl_track_login . '
-						WHERE login_user_id = ' . intval($student_id) . '
-						ORDER BY login_date ASC LIMIT 0,1';
+				WHERE login_user_id = ' . intval($student_id) . '
+				ORDER BY login_date ASC LIMIT 0,1';
 
 		$rs = Database::query($sql);
-		if(Database::num_rows($rs)>0)
-		{
+		if(Database::num_rows($rs)>0) {
 			if ($first_login_date = Database::result($rs, 0, 0)) {
 				return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
 			}
@@ -137,24 +136,16 @@ class Tracking {
 						ORDER BY login_date DESC LIMIT 0,1';
 
 		$rs = Database::query($sql);
-		if(Database::num_rows($rs)>0)
-		{
-			if ($last_login_date = Database::result($rs, 0, 0))
-			{
-				$last_login_date = api_get_local_time($last_login_date, null, date_default_timezone_get());
-				if ($return_timestamp)
-				{
-					return api_strtotime($last_login_date);
-				}
-				else
-				{
-					if (!$warning_message)
-					{
+		if(Database::num_rows($rs)>0) {
+			if ($last_login_date = Database::result($rs, 0, 0)) {                         
+				$last_login_date = api_get_local_time($last_login_date);
+				if ($return_timestamp) {
+					return api_strtotime($last_login_date,'UTC');
+				} else {
+					if (!$warning_message) {
 						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
-					}
-					else
-					{
-						$timestamp = api_strtotime($last_login_date);
+					} else {
+						$timestamp = api_strtotime($last_login_date,'UTC');
 						$currentTimestamp = time();
 
 						//If the last connection is > than 7 days, the text is red
@@ -445,22 +436,24 @@ class Tracking {
 
 			// Compose a filter based on optional session id
 			$condition_session = "";
-			if (isset($session_id)) {
-				$session_id = intval($session_id);
-				if (count($lp_ids) > 0) {
-					$condition_session = " AND session_id = $session_id ";
-				} else {
-					$condition_session = " WHERE session_id = $session_id ";
-				}
+			
+			$session_id = intval($session_id);
+			if (count($lp_ids) > 0) {
+				$condition_session = " AND session_id = $session_id ";
+			} else {
+				$condition_session = " WHERE session_id = $session_id ";
 			}
-
-			$res_count_lp = Database::query("SELECT id FROM $tbl_course_lp lp $condition_lp $condition_session");
+		
+            
+            //$sql = "SELECT id FROM $tbl_course_lp lp $condition_lp $condition_session";
+            $sql = "SELECT id FROM $tbl_course_lp lp $condition_lp";            
+			$res_count_lp = Database::query($sql);
 			// count the number of learning paths
 			$count_lp = Database::num_rows($res_count_lp);
 			$lp_id = array();
 			while ($row_lp = Database::fetch_array($res_count_lp)) {
 				$lp_id[] = $row_lp[0];
-			}
+			}            
 			$avg_progress = 0;
 			//if there is at least one learning path and one student
 			if ($count_lp>0 && !empty($student_id)) {
@@ -476,9 +469,10 @@ class Tracking {
                 // Also filter on LPs of this session
                 $sql_maxes = "SELECT MAX(view_count), progress ".
                         "FROM $tbl_course_lp_view lp_view ".
-                        "WHERE $condition_user ".
+                        "WHERE $condition_user session_id = $session_id AND ".
                         "lp_view.lp_id IN (".implode(',',$lp_id).") ".
                         "GROUP BY lp_id, user_id";
+                
                 $res_maxes = Database::query($sql_maxes);
                 $sum = $number_items = 0;
                 while ($row_maxes = Database::fetch_array($res_maxes)) {
@@ -535,8 +529,6 @@ class Tracking {
 			$lp_view_table 		= Database :: get_course_table(TABLE_LP_VIEW,$course['db_name']);
 			$lp_item_view_table = Database :: get_course_table(TABLE_LP_ITEM_VIEW,$course['db_name']);
 
-
-
 			// Compose a filter based on optional learning paths list given
 
 			$condition_lp = "";
@@ -557,7 +549,8 @@ class Tracking {
 
             // Check the real number of LPs corresponding to the filter in the
             // database (and if no list was given, get them all)
-			$res_row_lp = Database::query("SELECT DISTINCT(id) FROM $lp_table $condition_lp $condition_session");
+			//$res_row_lp = Database::query("SELECT DISTINCT(id) FROM $lp_table $condition_lp $condition_session");
+            $res_row_lp = Database::query("SELECT DISTINCT(id) FROM $lp_table $condition_lp");
 			$count_row_lp = Database::num_rows($res_row_lp);
 			$lp_list = array();
 			while ($row_lp = Database::fetch_array($res_row_lp)) {
@@ -584,7 +577,8 @@ class Tracking {
 			if ($count_row_lp>0 && !empty($student_id)) {
 
 				// Getting the total count of LP
-				$sql = "SELECT count(id) as count FROM $lp_table WHERE session_id = ".api_get_session_id();
+				//$sql = "SELECT count(id) as count FROM $lp_table WHERE session_id = ".$session_id;
+                $sql = "SELECT count(id) as count FROM $lp_table ";
 				$my_res = Database::query($sql);
 				$my_row = Database::fetch_array($my_res);
 				$count_views = $my_row['count'];
@@ -595,8 +589,8 @@ class Tracking {
 				$sql = "SELECT MAX(view_count) as vc, id, progress, lp_id, user_id ".
 				        "FROM $lp_view_table ".
 				        "WHERE lp_id IN (".implode(',',$lp_list).") ".
-				        "$condition_user1 GROUP BY lp_id,user_id";
-
+				        "$condition_user1 AND session_id= $session_id GROUP BY lp_id,user_id";
+                 
 				$rs_last_lp_view_id = Database::query($sql);
 
 				$global_count_item = 0;
@@ -630,8 +624,6 @@ class Tracking {
 
 						// Go through each scorable element of this view
 						$count_items = 0;
-						//4 -2 ------ 4 - 1
-						//echo '<br>';
 						$lp_partial_total = 0;
 						$score_of_scorm_calculate = 0;
 
@@ -712,7 +704,7 @@ class Tracking {
 
 				$lp_with_quiz = 0;
 				$total_lp = 0;
-
+                //var_dump($lp_list);
 				foreach($lp_list as $lp_id) {
 					//check if LP have a score
 					$sql = "SELECT count(id) as count FROM $lp_item_table
@@ -729,14 +721,12 @@ class Tracking {
 				}
 				//var_dump($lp_with_quiz);
 				if ($lp_with_quiz != 0 ) {
-
 					if (!$return_array) {
 						$score_of_scorm_calculate = round(($global_result/$lp_with_quiz),2);
 						return $score_of_scorm_calculate;
 					} else {
 						return array($global_result, $lp_with_quiz);
 					}
-
 				} else {
 					return '-';
 				}
@@ -786,7 +776,8 @@ class Tracking {
 
 	        // Check the real number of LPs corresponding to the filter in the
 	        // database (and if no list was given, get them all)
-			$res_row_lp = Database::query("SELECT DISTINCT(id) FROM $lp_table $condition_lp $condition_session");
+			//$res_row_lp = Database::query("SELECT DISTINCT(id) FROM $lp_table $condition_lp $condition_session");
+            $res_row_lp = Database::query("SELECT DISTINCT(id) FROM $lp_table $condition_lp");
 			$count_row_lp = Database::num_rows($res_row_lp);
 
 			// calculates time
@@ -794,11 +785,12 @@ class Tracking {
 				while ($row_lp = Database::fetch_array($res_row_lp)) {
 					$lp_id = intval($row_lp['id']);
 					$sql = 'SELECT SUM(total_time)
-									FROM '.$t_lpiv.' AS item_view
-									INNER JOIN '.$t_lpv.' AS view
-										ON item_view.lp_view_id = view.id
-										AND view.lp_id = '.$lp_id.'
-										AND view.user_id = '.$student_id;
+							FROM '.$t_lpiv.' AS item_view
+							INNER JOIN '.$t_lpv.' AS view
+								ON item_view.lp_view_id = view.id
+								AND view.lp_id = '.$lp_id.'
+								AND view.user_id = '.$student_id.' AND session_id = '.$session_id;
+                        
 						$rs = Database::query($sql);
 						if (Database :: num_rows($rs) > 0) {
 							$total_time += Database :: result($rs, 0, 0);
@@ -822,12 +814,13 @@ class Tracking {
 		$student_id = intval($student_id);
 		$lp_id = intval($lp_id);
 		$last_time = 0;
+        $session_id = intval($session_id);
 
 		if (!empty($course['db_name'])) {
 
-			$lp_table   = Database :: get_course_table(TABLE_LP_MAIN, $course['db_name']);
-			$t_lpv = Database :: get_course_table(TABLE_LP_VIEW, $course['db_name']);
-			$t_lpiv = Database :: get_course_table(TABLE_LP_ITEM_VIEW, $course['db_name']);
+			$lp_table    = Database :: get_course_table(TABLE_LP_MAIN, $course['db_name']);
+			$t_lpv       = Database :: get_course_table(TABLE_LP_VIEW, $course['db_name']);
+			$t_lpiv      = Database :: get_course_table(TABLE_LP_ITEM_VIEW, $course['db_name']);
 
 	        // Check the real number of LPs corresponding to the filter in the
 	        // database (and if no list was given, get them all)
@@ -837,12 +830,12 @@ class Tracking {
 			// calculates last connection time
 			if ($count_row_lp > 0) {
 				$sql = 'SELECT MAX(start_time)
-											FROM ' . $t_lpiv . ' AS item_view
-											INNER JOIN ' . $t_lpv . ' AS view
-												ON item_view.lp_view_id = view.id
-												AND view.lp_id = '.$lp_id.'
-												AND view.user_id = '.$student_id.' 
-												AND view.session_id = '.$session_id;
+						FROM ' . $t_lpiv . ' AS item_view
+						INNER JOIN ' . $t_lpv . ' AS view
+							ON item_view.lp_view_id = view.id
+							AND view.lp_id = '.$lp_id.'
+							AND view.user_id = '.$student_id.' 
+							AND view.session_id = '.$session_id;
 				$rs = Database::query($sql);
 				if (Database :: num_rows($rs) > 0) {
 					$last_time = Database :: result($rs, 0, 0);
@@ -867,9 +860,7 @@ class Tracking {
 
 		$a_students = array ();
 
-		//////////////////////////////////////////////////////////////
 		// At first, courses where $coach_id is coach of the course //
-		//////////////////////////////////////////////////////////////
 		$sql = 'SELECT id_session, course_code FROM ' . $tbl_session_course_user . ' WHERE id_user=' . $coach_id.' AND status=2';
 
 		global $_configuration;
@@ -902,9 +893,7 @@ class Tracking {
 			}
 		}
 
-		//////////////////////////////////////////////////////////////
 		// Then, courses where $coach_id is coach of the session    //
-		//////////////////////////////////////////////////////////////
 
 		$sql = 'SELECT session_course_user.id_user
 						FROM ' . $tbl_session_course_user . ' as session_course_user

+ 2 - 2
main/mySpace/index.php

@@ -235,7 +235,7 @@ if ($nb_teacher_courses > 0 ) {
 }
 
 
-echo '<h4>'.$title.'</h4>';
+echo '<h2>'.$title.'</h2>';
 
 if (($is_drh && $view == 'drh') || $_GET['display'] == 'yourstudents') {
 	// get data for human resources manager
@@ -540,7 +540,7 @@ if (api_is_allowed_to_create_course() && $view == 'teacher') {
 
 	// display sessions
 	if ($nb_sessions > 0 && !isset($_GET['session_id'])) {
-		echo '<h4>'.get_lang('Sessions').'</h4>';
+		echo '<h2>'.get_lang('Sessions').'</h2>';
 		$table = new SortableTable('tracking_sessions', 'count_sessions_coached');
 		$table->set_header(0, get_lang('Title'));
 		$table->set_header(1, get_lang('Date'));

+ 123 - 142
main/mySpace/myStudents.php

@@ -201,51 +201,45 @@ $student_id = intval($_GET['student']);
 
 // Action behaviour
 $check= Security::check_token('get');
-
-	if ($check) {
-		switch ($_GET['action']) {
-			case 'reset_lp' :
-			
-				$origin		= isset($_GET['origin'])	?Security::remove_XSS($_GET['origin']):"";
-				$details	= isset($_GET['details'])	?Security::remove_XSS($_GET['details']):"";  
-				$course		= isset($_GET['course'])	?$_GET['course']:"";
-				$lp_id		= isset($_GET['lp_id'])		?intval($_GET['lp_id']):"";				
-				$session_id	= isset($_GET['session_id'])?intval($_GET['session_id']):0;
-				$lp_reset = 0;
-				
-				if (api_is_course_admin() && !empty($course) && !empty($lp_id) && !empty($student_id)) {
-					   
-					$course_info 	= api_get_course_info($course);
-					$lp_view_table 	= Database::get_course_table(TABLE_LP_VIEW, $course_info['db_name']);
-					$lp_item_view_table 	= Database::get_course_table(TABLE_LP_ITEM_VIEW, $course_info['db_name']);
-					//make sure we have the exact lp_view_id
-					$sqlview = "SELECT id FROM $lp_view_table WHERE user_id = $student_id AND lp_id = $lp_id AND session_id= $session_id";					
-					$resultview = Database::query($sqlview);
-					$view = Database::fetch_array($resultview, 'ASSOC');
-					$lp_view_id =  $view['id'] ;
-					
-					
-					$sql_delete = "DELETE FROM $lp_item_view_table  WHERE lp_view_id = $view_id ";
-					$result = Database::query($sql_delete);
+if ($check) {
+	switch ($_GET['action']) {
+		case 'reset_lp' :		
+			$origin		= isset($_GET['origin'])	?Security::remove_XSS($_GET['origin']):"";
+			$details	= isset($_GET['details'])	?Security::remove_XSS($_GET['details']):"";  
+			$course		= isset($_GET['course'])	?$_GET['course']:"";
+			$lp_id		= isset($_GET['lp_id'])		?intval($_GET['lp_id']):"";
 						
-					$sql_delete = "DELETE FROM $lp_view_table  WHERE user_id = $student_id AND lp_id= $lp_id AND session_id= $session_id ";
-					$result = Database::query($sql_delete);
+			if (api_is_course_admin() && !empty($course) && !empty($lp_id) && !empty($student_id)) {					   
+				$course_info 	= api_get_course_info($course);                    
+                delete_student_lp_events($student_id, $lp_id, $course_info, $session_id);
+                
+                /*
+				$lp_view_table 	= Database::get_course_table(TABLE_LP_VIEW, $course_info['db_name']);
+				$lp_item_view_table 	= Database::get_course_table(TABLE_LP_ITEM_VIEW, $course_info['db_name']);
+                
+				//make sure we have the exact lp_view_id
+				$sqlview       = "SELECT id FROM $lp_view_table WHERE user_id = $student_id AND lp_id = $lp_id AND session_id= $session_id";					
+				$resultview    = Database::query($sqlview);
+				$view          = Database::fetch_array($resultview, 'ASSOC');
+				$lp_view_id    = $view['id'] ;					
+				
+				$sql_delete = "DELETE FROM $lp_item_view_table  WHERE lp_view_id = $view_id ";
+				$result = Database::query($sql_delete);
 					
-					//@todo delete the stats.track_e_exercices records. First implement this http://support.chamilo.org/issues/1334					
-					Display::display_confirmation_message('LPWasReset');
-				}				
+				$sql_delete = "DELETE FROM $lp_view_table  WHERE user_id = $student_id AND lp_id= $lp_id AND session_id= $session_id ";
+				$result = Database::query($sql_delete);
+                */
+				
+				//@todo delete the stats.track_e_exercices records. First implement this http://support.chamilo.org/issues/1334					
+				Display::display_confirmation_message(get_lang('LPWasReset'));
+			}				
+		  break;			
+		default:
 			break;
-			
-			default:
-				break;
-			
-		}
-		Security::clear_token();	
-	}	
-
-	
-	
-	
+		
+	}
+	Security::clear_token();	
+}		
 	
 if (!empty ($_GET['student'])) {
 
@@ -347,6 +341,38 @@ if (!empty ($_GET['student'])) {
 		$avg_student_progress . '%',
 		$avg_student_score
 	);
+
+    
+    //Show title
+    $course_code = $_GET['course'];
+    $info_course = CourseManager :: get_course_information($course_code);       
+    $coachs_name  = '';
+    $session_name = '';     
+    $nb_login = Tracking :: count_login_per_student($info_user['user_id'], $_GET['course']);
+    //get coach and session_name if there is one and if session_mode is activated
+    if (api_get_setting('use_session_mode') == 'true' && $session_id > 0) {
+        
+        $session_info  = api_get_session_info($session_id);         
+        $course_coachs = api_get_coachs_from_course($session_id,$course_code);
+        $nb_login = '';         
+        if (!empty($course_coachs)) {
+            $info_tutor_name = array();
+            foreach ($course_coachs as $course_coach) {
+                $info_tutor_name[] = api_get_person_name($course_coach['firstname'], $course_coach['lastname']);
+            }
+            $info_course['tutor_name'] = implode(",",$info_tutor_name);
+        } elseif ($session_coach_id != 0) {                 
+            $session_coach_id = intval($session_info['id_coach']);      
+            $coach_info = UserManager::get_user_info_by_id($session_coach_id);
+            $info_course['tutor_name'] = api_get_person_name($coach_info['firstname'], $coach_info['lastname']);
+        }
+        $coachs_name  = $info_course['tutor_name'];
+        $session_name = $session_info['name'];
+    } // end if(api_get_setting('use_session_mode')=='true')
+
+    $table_title = ($session_name? get_lang('Session').' : '.ucfirst($session_name).' | ':'').get_lang('Course').' : '.$info_course['title'].($coachs_name?'&nbsp;|&nbsp;'.get_lang('Tutor').' : '.stripslashes($coachs_name):'');
+    echo '<h2>'.$table_title.'</h2>';
+
 ?>
 	<a name="infosStudent"></a>
 				<table width="100%" border="0" >
@@ -489,7 +515,17 @@ if ($timezone !== null) {
 						</td>
 						<td align="left"><?php if (is_numeric($avg_student_score)) { echo $avg_student_score.'%';} else { echo $avg_student_score ;}  ?></td>
 					</tr>
-					<?php } ?>
+                    <?php
+                        if (!empty($nb_login)) {
+                        	echo '<tr><td align="right">';
+                            echo get_lang('CountToolAccess');
+                            echo '</td>';
+                            echo '<td align="left">';
+                            echo $nb_login;
+                            echo '</td>';
+                            echo '</tr>';
+                        }
+					} ?>
 				</table>
 			</td>
 		</tr>
@@ -497,51 +533,11 @@ if ($timezone !== null) {
 	
 <?php
 
-	if (!empty ($_GET['details'])) { ?>
-
-		<table class="data_table">
-		<tr>
-			<td colspan="5" style="border-width: 0px;">&nbsp;</td>
-		</tr>
-		
-		<?php
-		$course_code = $_GET['course'];
-		$info_course = CourseManager :: get_course_information($course_code);		
-		$coachs_name  = '';
-		$session_name = '';		
-		$nb_login = Tracking :: count_login_per_student($info_user['user_id'], $_GET['course']);
-		//get coach and session_name if there is one and if session_mode is activated
-		if (api_get_setting('use_session_mode') == 'true' && $session_id > 0) {
-			
-			$session_info  = api_get_session_info($session_id);			
-			$course_coachs = api_get_coachs_from_course($session_id,$course_code);
-			$nb_login = '';			
-			if (!empty($course_coachs)) {
-				$info_tutor_name = array();
-				foreach ($course_coachs as $course_coach) {
-					$info_tutor_name[] = api_get_person_name($course_coach['firstname'], $course_coach['lastname']);
-				}
-				$info_course['tutor_name'] = implode(",",$info_tutor_name);
-			} elseif ($session_coach_id != 0) {					
-				$session_coach_id = intval($session_info['id_coach']);		
-				$coach_info = UserManager::get_user_info_by_id($session_coach_id);
-				$info_course['tutor_name'] = api_get_person_name($coach_info['firstname'], $coach_info['lastname']);
-			}
-			$coachs_name  = $info_course['tutor_name'];
-			$session_name = $session_info['name'];
-		} // end if(api_get_setting('use_session_mode')=='true')
-
-		$table_title = $info_course['title'].($nb_login?'&nbsp;|&nbsp;'.get_lang('CountToolAccess').' : '.$nb_login:'').($session_name?'&nbsp;|&nbsp;'.get_lang('Session').' : '.ucfirst($session_name):'').($coachs_name?'&nbsp;|&nbsp;'.get_lang('Tutor').' : '.stripslashes($coachs_name):'');
-
-		$csv_content[] = array ();
-		$csv_content[] = array (str_replace('&nbsp;', '', $table_title));
-?>
-		<tr>
-			<td colspan="6">
-					<strong><?php echo $table_title; ?></strong>
-			</td>
-		</tr>
-	</table>
+	if (!empty ($_GET['details'])) {         
+        $csv_content[] = array ();
+        $csv_content[] = array (str_replace('&nbsp;', '', $table_title));        
+        ?>
+<br />
 
 	<!-- line about learnpaths -->
 				<table class="data_table">
@@ -550,54 +546,25 @@ if ($timezone !== null) {
 							<?php echo get_lang('Learnpaths');?>
 						</th>
 						<th>
-							<?php
-
-		echo get_lang('Time');
-		Display :: display_icon('info3.gif', get_lang('TotalTimeByCourse'), array (
-			'align' => 'absmiddle',
-			'hspace' => '3px'
-		));
-?>
+							<?php echo get_lang('Time'); Display :: display_icon('info3.gif', get_lang('TotalTimeByCourse'), array ('align' => 'absmiddle', 'hspace' => '3px')); ?>
 						</th>
 						<th>
-							<?php
-
-		echo get_lang('Score');
-		Display :: display_icon('info3.gif', get_lang('LPTestScore'), array (
-			'align' => 'absmiddle',
-			'hspace' => '3px'
-		));
-?>
+							<?php echo get_lang('Score'); Display :: display_icon('info3.gif', get_lang('LPTestScore'), array ( 'align' => 'absmiddle', 'hspace' => '3px')); ?>
 						</th>
 						<th>
-							<?php
-
-		echo get_lang('Progress');
-		Display :: display_icon('info3.gif', get_lang('LPProgressScore'), array (
-			'align' => 'absmiddle',
-			'hspace' => '3px'
-		));
-?>
+							<?php echo get_lang('Progress'); Display :: display_icon('info3.gif', get_lang('LPProgressScore'), array ('align' => 'absmiddle','hspace' => '3px')); ?>
 						</th>
 						<th>
-							<?php
-
-		echo get_lang('LastConnexion');
-		Display :: display_icon('info3.gif', get_lang('LastTimeTheCourseWasUsed'), array (
-			'align' => 'absmiddle',
-			'hspace' => '3px'
-		));
-?>
+							<?php echo get_lang('LastConnexion'); Display :: display_icon('info3.gif', get_lang('LastTimeTheCourseWasUsed'), array ('align' => 'absmiddle','hspace' => '3px')); ?>
 						</th>
-				<?php		
-					echo '<th>'.get_lang('Details').'</th>'; 
-					if (api_is_course_admin()) {
-						echo '<th>'.get_lang('ResetLP').'</th>';
-					}
-				?>						
-		</tr>
+        				<?php		
+        					echo '<th>'.get_lang('Details').'</th>'; 
+        					if (api_is_course_admin()) {
+        						echo '<th>'.get_lang('ResetLP').'</th>';
+        					}
+        				?>						
+		          </tr>
 <?php
-
 		$headerLearnpath = array (
 			get_lang('Learnpath'),
 			get_lang('Time'),
@@ -618,10 +585,12 @@ if ($timezone !== null) {
 			get_lang('Progress', ''),
 			get_lang('LastConnexion', '')
 		);
-
-		$sql_lp = "	SELECT lp.name, lp.id FROM $t_lp lp WHERE lp.session_id = $session_id ORDER BY lp.display_order";
+        
+        // 
+		//$sql_lp = "	SELECT lp.name, lp.id FROM $t_lp lp WHERE lp.session_id = $session_id ORDER BY lp.display_order";
+        $sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp ORDER BY lp.display_order";
 		$rs_lp = Database::query($sql_lp);
-		$token = Security::get_token();
+		$token = Security::get_token();        
 		
 		if (Database :: num_rows($rs_lp) > 0) {
 			$i = 0;
@@ -632,7 +601,7 @@ if ($timezone !== null) {
 				$any_result = false;
 				
 				// Get progress in lp				
-				$progress = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id),$session_id);
+				$progress = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
 				
 				if ($progress === null) { 
 					$progress = '0%';
@@ -645,11 +614,19 @@ if ($timezone !== null) {
 				if (!empty($total_time)) $any_result = true;
 				
 				// Get last connection time in lp
-				$start_time = Tracking::get_last_connection_time_in_lp($student_id, $course_code, $lp_id,$session_id);
+				$start_time = Tracking::get_last_connection_time_in_lp($student_id, $course_code, $lp_id, $session_id);
+                
+                if (!empty($start_time)) {
+                    $start_time = api_get_utc_datetime($start_time );
+                } else {
+                    $start_time =  '-';
+                }
+                
 				if (!empty($total_time)) $any_result = true;
 			
-				// Quizz in lp
+				// Quizz in lp                
 				$score = Tracking :: get_avg_student_score($student_id, $course_code, array($lp_id),$session_id);
+                
 
 				if ($i % 2 == 0) $css_class = "row_odd";
 				else $css_class = "row_even";
@@ -662,7 +639,7 @@ if ($timezone !== null) {
 					api_time_to_hms($total_time),
 					$score . '%',
 					$progress.'%',
-					date('Y-m-d h:i:s', $start_time)
+					$start_time
 				);
 ?>
 					<tr class="<?php echo $css_class;?>">
@@ -676,7 +653,12 @@ if ($timezone !== null) {
 							<?php
 
 				if (!is_null($score)) {
-					if (is_numeric($score)) { echo $score.'%';} else { echo $score ;}
+					if (is_numeric($score)) { 
+                        echo $score.'%';
+                    } else { 
+                        // if result == '-' means that the LP does not have exercises if result is 0 means the LP have an exercise
+                        echo $score ;
+                    }
 				}
 				 
 				if (is_numeric($progress)) {						
@@ -691,13 +673,11 @@ if ($timezone !== null) {
 						</td>
 						<td align="center">
 							<?php
-				if ($start_time != '' && $start_time > 0) {
+				
 					//Do not change with api_convert_and_format_date, because this value came from the lp_item_view table 
-					//which implies several other changes not a priority right now								
-					echo date('Y-m-d h:i:s', $start_time); 
-				} else {
-					echo '-';
-				}
+					//which implies several other changes not a priority right now	
+                    echo $start_time;							
+				
 ?>
 						</td>
 						<td align="center">
@@ -995,6 +975,7 @@ if ($timezone !== null) {
 				  </tr>';
 
 			if (!empty($courses)) {
+                
 				foreach ($courses as $course_code) {
 					if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
 						$course_info = CourseManager :: get_course_information($course_code);

+ 2 - 1
main/tracking/courseLog.php

@@ -448,7 +448,8 @@ if ($_GET['studentlist'] == 'false') {
 
     $form -> addElement('hidden', 'action', 'add');
     $form -> addElement('hidden', 'remindallinactives', 'true');
-
+    $course_info = api_get_course_info(api_get_course_id());
+    echo '<h2>'.get_lang('Course').' '.$course_info['name'].'</h2>'; 
     $form -> display();
     // END : form to remind inactives susers