From 4346f5be4344d1d8835d3f3295ede0f711e04c4a Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 10 Apr 2008 00:33:57 +0200 Subject: [PATCH] [svn r14818] Show link to learnpath results as soon as there is one item of tracking, even if the score and progress are 0. Minor - changed mysql_ calls to Database:: calls --- main/mySpace/myStudents.php | 65 +++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index d46dcd7040..6daf4cec51 100644 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -1,4 +1,4 @@ -0) + if(Database::num_rows($resultLearnpath)>0) { $i = 0; - while($a_learnpath = mysql_fetch_array($resultLearnpath)) + while($a_learnpath = Database::fetch_array($resultLearnpath)) { - - $progress = learnpath :: get_db_progress($a_learnpath['id'],$student_id, '%',$a_infosCours['db_name']); - + $any_result = false; + $progress = learnpath :: get_db_progress($a_learnpath['id'],$student_id, '%',$a_infosCours['db_name'],true); + if($progress === null) + { + $progress = '0%'; + } + else + { + $any_result = true; + } // calculates time $sql = 'SELECT SUM(total_time) @@ -566,9 +573,13 @@ if(!empty($_GET['student'])) AND view.lp_id = '.$a_learnpath['id'].' AND view.user_id = '.intval($_GET['student']); $rs = api_sql_query($sql, __FILE__, __LINE__); - $total_time = mysql_result($rs, 0, 0); - - + $total_time = 0; + if(Database::num_rows($rs)>0) + { + $total_time = Database::result($rs, 0, 0); + if($total_time>0) $any_result = true; + } + // calculates last connection time $sql = 'SELECT MAX(start_time) FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view_item.' AS item_view @@ -577,8 +588,12 @@ if(!empty($_GET['student'])) AND view.lp_id = '.$a_learnpath['id'].' AND view.user_id = '.intval($_GET['student']); $rs = api_sql_query($sql, __FILE__, __LINE__); - $start_time = mysql_result($rs, 0, 0); - + $start_time = null; + if(Database::num_rows($rs)>0) + { + $start_time = Database::result($rs, 0, 0); + if($start_time > 0) $any_result = true; + } //QUIZZ IN LP $sql = 'SELECT id as item_id, max_score @@ -591,7 +606,12 @@ if(!empty($_GET['student'])) //We get the last view id of this LP $sql='SELECT max(id) as id FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view.' WHERE lp_id='.$a_learnpath['id'].' AND user_id="'.intval($_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'); + $lp_view_id = 0; + if(Database::num_rows($rs_last_lp_view_id)>0) + { + $lp_view_id = Database::result($rs_last_lp_view_id,0,'id'); + if($lp_view_id > 0) $any_result = true; + } $total_score = $total_weighting = 0; while($item = Database :: fetch_array($rsItems, 'ASSOC')) @@ -605,6 +625,7 @@ if(!empty($_GET['student'])) $rsScores = api_sql_query($sql, __FILE__, __LINE__); $total_score += mysql_result($rsScores, 0, 0); $total_weighting += $item['max_score']; + $any_result = true; } $sql = 'SELECT id, max_score @@ -614,21 +635,25 @@ if(!empty($_GET['student'])) $rs_lp_item_id_scorm = api_sql_query($sql, __FILE__, __LINE__); - if(mysql_num_rows($rs_lp_item_id_scorm)>0){ - $lp_item_id = mysql_result($rs_lp_item_id_scorm,0,'id'); - $lp_item__max_score = mysql_result($rs_lp_item_id_scorm,0,'max_score'); + if(Database::num_rows($rs_lp_item_id_scorm)>0){ + $lp_item_id = Database::result($rs_lp_item_id_scorm,0,'id'); + $lp_item__max_score = Database::result($rs_lp_item_id_scorm,0,'max_score'); $total_weighting+=$lp_item__max_score; //We get the last view id of this LP $sql='SELECT max(id) as id FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view.' WHERE lp_id='.$a_learnpath['id'].' AND user_id="'.intval($_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'); + $lp_view_id = Database::result($rs_last_lp_view_id,0,'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'); - - $total_score+=$lp_scorm_score; + if(Database::num_rows($rs_score)>0) + { + $lp_scorm_score = Database::result($rs_score,0,'score'); + + $total_score+=$lp_scorm_score; + $any_result = true; + } } $score = 0; @@ -667,7 +692,7 @@ if(!empty($_GET['student'])) 0 || $score > 0) + if($any_result === true) { ?>