Prechádzať zdrojové kódy

[svn r12607] Fix a bug in the reporting : http://projects.dokeos.com/?do=details&id=1517

Julian Prud'homme 18 rokov pred
rodič
commit
4590a216ae
2 zmenil súbory, kde vykonal 9 pridanie a 28 odobranie
  1. 4 25
      main/inc/lib/tracking.lib.php
  2. 5 3
      main/mySpace/myStudents.php

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

@@ -211,29 +211,6 @@ class Tracking {
 	}
 
 	function get_avg_student_score($student_id, $course_code) {
-
-		// protect datas
-		$student_id = intval($student_id);
-		$course_code = addslashes($course_code);
-
-		$sqlScore = "	SELECT  exe_result, exe_weighting
-				 				FROM " . Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES) . "
-								WHERE exe_user_id = " . $student_id . "
-				 				AND exe_cours_id = '" . $course_code . "'
-							";
-		$resultScore = api_sql_query($sqlScore);
-		$i = 0;
-		$score = 0;
-		while ($a_score = mysql_fetch_array($resultScore)) {
-			$score = $score + $a_score['exe_result'];
-			$weighting = $weighting + $a_score['exe_weighting'];
-			$i++;
-		}
-
-		$totalScore = $totalScore + $score;
-		$totalWeighting += $weighting;
-		
-		$pourcentageTests = ($totalScore / $weighting) *100;
 		
 		$course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
 		$course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
@@ -269,7 +246,8 @@ class Tracking {
 					$rs_last_lp_view_id = api_sql_query($sql, __FILE__, __LINE__);
 					$lp_view_id = mysql_result($rs_last_lp_view_id,0,'id');
 					
-					$sql='SELECT SUM(score) as score FROM '.$lp_item_view_table.' WHERE lp_view_id="'.$lp_view_id.'" GROUP BY lp_view_id';
+					$sql='SELECT SUM(score)/count(lp_item_id) as score FROM '.$lp_item_view_table.' WHERE lp_view_id="'.$lp_view_id.'" GROUP BY lp_view_id';
+
 					$rs_score = api_sql_query($sql, __FILE__, __LINE__);
 					$lp_scorm_score = mysql_result($rs_score,0,'score');
 					
@@ -302,6 +280,7 @@ class Tracking {
 					$sql = 'SELECT score as student_score 
 							FROM '.$lp_item_view_table.' as lp_view_item
 							WHERE lp_view_item.lp_item_id = '.$item['item_id'].'
+							AND lp_view_id = "'.$lp_view_id.'"
 							';
 
 					$rsScores = api_sql_query($sql, __FILE__, __LINE__);
@@ -316,7 +295,7 @@ class Tracking {
 			}
 		}
 
-		$totalScore = $lp_scorm_score_total + $pourcentageTests;
+		$totalScore = $lp_scorm_score_total;
 		$totalWeighting = $lp_scorm_weighting_total + 100;
 
 		$pourcentageScore = round(($totalScore * 100) / $totalWeighting);

+ 5 - 3
main/mySpace/myStudents.php

@@ -223,6 +223,7 @@ if(!empty($_GET['student']))
 			$nb_courses++;
 			$avg_student_progress += Tracking :: get_avg_student_progress($a_infosUser['user_id'],$course_code);
 			$avg_student_score += Tracking :: get_avg_student_score($a_infosUser['user_id'],$course_code);
+			echo $course_code.' : '.$avg_student_score.'<br>';
 		}
 	}
 	$avg_student_progress = round($avg_student_progress / $nb_courses,2);
@@ -502,7 +503,7 @@ if(!empty($_GET['student']))
 					$start_time = mysql_result($rs, 0, 0);
 					
 					
-					
+					//QUIZZ IN LP
 					$sql = 'SELECT id as item_id, max_score 
 							FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_item.' AS lp_item
 							WHERE lp_id='.$a_learnpath['id'].'
@@ -521,8 +522,9 @@ if(!empty($_GET['student']))
 						$sql = 'SELECT score as student_score 
 								FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view_item.' as lp_view_item
 								WHERE lp_view_item.lp_item_id = '.$item['item_id'].'
+								AND lp_view_id = "'.$lp_view_id.'"
 								';
-
+								
 						$rsScores = api_sql_query($sql, __FILE__, __LINE__);
 						$total_score += mysql_result($rsScores, 0, 0);
 						$total_weighting += $item['max_score'];
@@ -545,7 +547,7 @@ if(!empty($_GET['student']))
 						$rs_last_lp_view_id = api_sql_query($sql, __FILE__, __LINE__);
 						$lp_view_id = mysql_result($rs_last_lp_view_id,0,'id');
 						
-						$sql='SELECT SUM(score) as score FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view_item.' WHERE lp_view_id="'.$lp_view_id.'" GROUP BY lp_view_id';
+						$sql='SELECT SUM(score)/count(lp_item_id) as score FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view_item.' WHERE lp_view_id="'.$lp_view_id.'" GROUP BY lp_view_id';
 						$rs_score = api_sql_query($sql, __FILE__, __LINE__);
 						$lp_scorm_score = mysql_result($rs_score,0,'score');