Julio Montoya 14 years ago
parent
commit
d5448736f2
4 changed files with 63 additions and 53 deletions
  1. 45 38
      main/auth/my_progress.php
  2. 3 4
      main/inc/lib/events.lib.inc.php
  3. 4 2
      main/inc/lib/tracking.lib.php
  4. 11 9
      main/inc/local.inc.php

+ 45 - 38
main/auth/my_progress.php

@@ -38,7 +38,6 @@ $tbl_course_quiz 			= Database :: get_course_table(TABLE_QUIZ_TEST);
 $tbl_access_rel_session     = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
 $tbl_access_rel_course      = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
 
-
 // get course list
 if ($_configuration['multiple_access_urls']) {    
     $sql = 'SELECT cu.course_code FROM '.$tbl_course_user.' cu INNER JOIN '.$tbl_access_rel_course.' a  ON(a.course_code = cu.course_code) WHERE user_id='.intval($_user['user_id']).' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH.' AND access_url_id = '.api_get_current_access_url_id().'';
@@ -53,9 +52,7 @@ while($row = Database :: fetch_array($rs)) {
 	$courses[$row['course_code']] = CourseManager::get_course_information($row['course_code']);
 }
 
-// get the list of sessions where the user is subscribed as student
-
-
+// Get the list of sessions where the user is subscribed as student
 if ($_configuration['multiple_access_urls']) {
     $sql = 'SELECT DISTINCT cu.course_code, id_session as session_id FROM '.$tbl_session_course_user.' cu INNER JOIN '.$tbl_access_rel_session.' a  ON(a.session_id = cu.id_session) WHERE id_user='.$_user['user_id'].' AND access_url_id = '.api_get_current_access_url_id().'';
 } else {
@@ -66,20 +63,20 @@ $rs = Database::query($sql);
 while($row = Database :: fetch_array($rs)) {
 	$course_in_session[$row['session_id']][$row['course_code']] = CourseManager::get_course_information($row['course_code']);
 }
-echo '<div class="actions-title" >';
+/*echo '<div class="actions-title" >';
 echo $nameTools;
-echo '</div>';
+echo '</div>';*/
 
 if (!empty($courses)) {
 ?>
 <table class="data_table" width="100%">
 <tr class="tableName">
 	<td colspan="6">
-		<strong><?php echo get_lang('MyCourses'); ?></strong>
+		<h1><?php echo get_lang('MyCourses'); ?></h1>
 	</td>
 </tr>
 <tr>
-  <th><?php echo get_lang('Course'); ?></th>
+  <th width="300px"><?php echo get_lang('Course'); ?></th>
   <th><?php echo get_lang('Time'); ?></th>
   <th><?php echo get_lang('Progress'); ?></th>
   <th><?php echo get_lang('Score'); Display :: display_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')); ?></th>
@@ -87,17 +84,23 @@ if (!empty($courses)) {
   <th><?php echo get_lang('Details'); ?></th>
 </tr>
 <?php
-
     $i = 0;
     foreach ($courses as $enreg) {
     	$weighting = 0;
+        
+        $total_time_login      = Tracking :: get_time_spent_on_the_course($_user['user_id'], $enreg['code']);
+        $time                  = api_time_to_hms($total_time_login);
+        $progress              = Tracking :: get_avg_student_progress($_user['user_id'], $enreg['code']);
+        $percentage_score      = Tracking :: get_avg_student_score($_user['user_id'], $enreg['code'], array());
     	$last_connection       = Tracking :: get_last_connection_date_on_the_course($_user['user_id'], $enreg['code']);
-    	$progress              = Tracking :: get_avg_student_progress($_user['user_id'], $enreg['code']);
-    	$total_time_login      = Tracking :: get_time_spent_on_the_course($_user['user_id'], $enreg['code']);
-    	$time                  = api_time_to_hms($total_time_login);
-    	$percentage_score      = Tracking :: get_average_test_scorm_and_lp ($_user['user_id'], $enreg['code']);
+    	
     
-        echo '<tr class='.($i?'row_odd':'row_even').'>';
+        if ($enreg['code'] == $_GET['course'] && empty($_GET['session_id'])) {
+            echo '<tr class="row_odd" style="background-color:#FBF09D">';
+        } else {
+            echo '<tr class="row_even">';
+        }
+        
       	echo '<td>'.$enreg['title'].'</td>';
         
       	echo '<td align="center">'.$time.'</td>';
@@ -130,26 +133,22 @@ if (!empty($course_in_session)) {
 ?>
 
 <br />
-<table class="data_table" width="100%">
-<tr class="tableName">
-    <td colspan="7">
-        <strong><?php echo get_lang('Sessions'); ?></strong>
-    </td>
-</tr>
-<tr>
-  <th><?php echo get_lang('Session'); ?></th>
-  <th><?php echo get_lang('Course'); ?></th>
-  <th><?php echo get_lang('Time'); ?></th>
-  <th><?php echo get_lang('Progress'); ?></th>
-  <th><?php echo get_lang('Score'); Display :: display_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')); ?></th>
-  <th><?php echo get_lang('LastConnexion'); ?></th>
-  <th><?php echo get_lang('Details'); ?></th>
-</tr>
-<?php
-    
-    foreach ($course_in_session as $key=>$session) {    
-        echo '<tr  class='.($i?'row_odd':'row_even').'>';    
-        echo '<td rowspan="'.count($session).'" > '.api_get_session_name($key).' </td>';    
+ <h1><?php echo get_lang('Sessions'); ?></h1>
+<?php    
+    foreach ($course_in_session as $key=>$session) {
+        echo '<h2>'.api_get_session_name($key).' </h2>';
+        ?>        
+        <table class="data_table" width="100%">
+        <tr>
+          <th width="300px"><?php echo get_lang('Course'); ?></th>
+          <th><?php echo get_lang('Time'); ?></th>
+          <th><?php echo get_lang('Progress'); ?></th>
+          <th><?php echo get_lang('Score'); Display :: display_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), array ('align' => 'absmiddle', 'hspace' => '3px')); ?></th>
+          <th><?php echo get_lang('LastConnexion'); ?></th>
+          <th><?php echo get_lang('Details'); ?></th>
+        </tr>
+        <?php           
+          
         foreach ($session as $enreg) {               
             $weighting = 0;
             $last_connection       = Tracking :: get_last_connection_date_on_the_course($_user['user_id'], $enreg['code'], $key);
@@ -157,7 +156,14 @@ if (!empty($course_in_session)) {
             
             $total_time_login      = Tracking :: get_time_spent_on_the_course($_user['user_id'], $enreg['code'], $key);
             $time                  = api_time_to_hms($total_time_login);
-            $percentage_score      = Tracking :: get_avg_student_score ($_user['user_id'], $enreg['code'], array(), $key);
+            $percentage_score      = Tracking :: get_avg_student_score($_user['user_id'], $enreg['code'], array(), $key);
+            
+            if ($enreg['code'] == $_GET['course'] && $_GET['session_id'] == $key) {
+                echo '<tr  class="row_odd" style="background-color:#FBF09D" >';
+            } else {
+                echo '<tr  class="row_even">';
+            }
+            
             
             echo '<td>'.$enreg['title'].' </td>';        
             echo '<td align="center">'.$time.'</td>';
@@ -189,9 +195,10 @@ if (!empty($course_in_session)) {
             echo '</td>';
             $i = $i ? 0 : 1;
             echo '</tr>';
-        }  
+        }
+        echo '</table>';  
     }
-    echo '</table>';
+    
 }
 ?>
 <br /><br />
@@ -311,7 +318,7 @@ if (!empty($course_in_session)) {
                         if (is_numeric($progress)) {
                             $progress = $progress.'%';
                         }
-						echo		$progress;
+						echo $progress;
 						echo "	</td>
 								<td align='center' width=180px >";
 						                        

+ 3 - 4
main/inc/lib/events.lib.inc.php

@@ -379,7 +379,6 @@ function update_event_exercice($exeid, $exo_id, $score, $weighting,$session_id,$
 				   status 			= '',
 				   start_date       = '".api_get_utc_datetime($start_date)."'
 				 WHERE exe_id = '".Database::escape_string($exeid)."'";
-        
 		$res = @Database::query($sql);
         
         //Deleting control time session track		
@@ -438,8 +437,8 @@ function create_event_exercice($exo_id) {
     	$expired_date = '0000-00-00 00:00:00';
     }
 
-	$sql = "INSERT INTO $TABLETRACK_EXERCICES ( exe_user_id, exe_cours_id, expired_time_control, exe_exo_id)
-			VALUES (  ".$user_id.",  '".api_get_course_id()."' ,'".$expired_date."','".$exo_id."')";
+	$sql = "INSERT INTO $TABLETRACK_EXERCICES ( exe_user_id, exe_cours_id, expired_time_control, exe_exo_id, session_id)
+			VALUES (  ".$user_id.",  '".api_get_course_id()."' ,'".$expired_date."','".$exo_id."','".api_get_session_id()."')";
 	$res = Database::query($sql);
 	$id= Database::insert_id();
 	return $id;
@@ -696,7 +695,7 @@ function get_all_exercise_event($exercise_id, $course_code, $session_id = 0) {
 	$exercise_id = intval($exercise_id);
 	$session_id = intval($session_id);
 	
-	$sql = "SELECT * FROM $TABLETRACK_EXERCICES WHERE status = ''  AND exe_cours_id = '$course_code' AND exe_exo_id = '$exercise_id' AND session_id = $session_id ORDER BY exe_id";
+	$sql = "SELECT * FROM $TABLETRACK_EXERCICES WHERE status = ''  AND exe_cours_id = '$course_code' AND exe_exo_id = '$exercise_id' AND session_id = $session_id  AND orig_lp_id =0 AND orig_lp_item_id = 0 ORDER BY exe_id";
 	
 	$res = api_sql_query($sql,__FILE__,__LINE__);
 	$list = array();	

+ 4 - 2
main/inc/lib/tracking.lib.php

@@ -759,8 +759,9 @@ class Tracking {
 
 			// Compose a filter based on optional session id
 			$condition_session = "";
-			if (isset($session_id)) {
-				$session_id = intval($session_id);
+            $session_id = intval($session_id);
+            
+			if (isset($session_id)) {				
 				if (count($lp_ids) > 0) {
 					$condition_session = " AND session_id = $session_id ";
 				} else {
@@ -1643,6 +1644,7 @@ class Tracking {
 	 * @param 	string 	Course id
 	 * @return	float	average of test
 	 * @author 	isaac flores paz <florespaz@bidsoftperu.com>
+     * @deprecated get_avg_student_score should be use
 	 */
 	public static function get_average_test_scorm_and_lp ($user_id,$course_id) {
 

+ 11 - 9
main/inc/local.inc.php

@@ -842,7 +842,8 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or
 	            $course_tracking_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
 				$time = api_get_datetime();
 		        $sql="INSERT INTO $course_tracking_table(course_code, user_id, login_course_date, logout_course_date, counter, session_id)" .
-					 "VALUES('".$_course['sysCode']."', '".$_user['user_id']."', '$time', '$time', '1', ".api_get_session_id().")";
+					 "VALUES('".$_course['sysCode']."', '".$_user['user_id']."', '$time', '$time', '1', '".api_get_session_id()."')";
+                //error_log($sql);
 				Database::query($sql);
 			}
         } else {
@@ -853,6 +854,11 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or
         api_session_unregister('_cid');
         api_session_unregister('_real_cid');
         api_session_unregister('_course');
+        
+        //Deleting session id 
+        if (api_get_session_id()) {                
+            api_session_unregister('id_session');
+        }   
     }
 } else { // continue with the previous values
 	if (empty($_SESSION['_course']) OR empty($_SESSION['_cid'])) { //no previous values...
@@ -863,7 +869,7 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or
    		$_course    = $_SESSION['_course'];
 
    		// these lines are usefull for tracking. Indeed we can have lost the id_session and not the cid.
-   		// Moreover, if we want to track a course with another session it can be usefull
+   		// Moreover, if we want to track a course with another session it can be usefull        
 		if (!empty($_GET['id_session'])) {
 			$tbl_session 				= Database::get_main_table(TABLE_MAIN_SESSION);
 			$_SESSION['id_session']		= intval($_GET['id_session']);
@@ -893,17 +899,19 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or
 						AND login_course_date > now() - INTERVAL $session_lifetime SECOND
 						ORDER BY login_course_date DESC LIMIT 0,1";
 				$result=Database::query($sql);
-
+                //error_log($sql);
 			if (Database::num_rows($result)>0) {
 
 				$i_course_access_id = Database::result($result,0,0);
 				//We update the course tracking table
 				$sql="UPDATE $course_tracking_table  SET logout_course_date = '$time', counter = counter+1 ".
 					 "WHERE course_access_id=".intval($i_course_access_id)." AND session_id = ".api_get_session_id();
+                //error_log($sql);
 				Database::query($sql);
 			} else {
 				$sql="INSERT INTO $course_tracking_table (course_code, user_id, login_course_date, logout_course_date, counter, session_id)" .
 					 "VALUES('".$course_code."', '".$_user['user_id']."', '$time', '$time', '1','".api_get_session_id()."')";
+                //error_log($sql);
 				Database::query($sql);
 			}
    	 	}
@@ -1177,9 +1185,3 @@ if (isset($_cid)) {
 	Database::query($sql);
 }
 
-//Deleting session id 
-if (isset($cidReset) && $cidReset) {
-    if (api_get_session_id()) {
-        api_session_unregister('id_session');
-    }
-}