Browse Source

Fixing query due bad table reference + some minor fixes

Julio Montoya 13 years ago
parent
commit
f55183768f

+ 2 - 3
main/inc/ajax/course_home.ajax.php

@@ -146,9 +146,8 @@ switch ($action) {
                 if ($course_id != $item['id']) {
                     continue;
                 }
-            }
-        
-            $list               = new LearnpathList(api_get_user_id(),$item['code'], $session_id);
+            }        
+            $list               = new LearnpathList(api_get_user_id(), $item['code'], $session_id);
             $flat_list          = $list->get_flat_list(); 
             $lps[$item['code']] = $flat_list;
             $course_url         = api_get_path(WEB_COURSE_PATH).$item['directory'].'/?id_session='.$session_id;

+ 3 - 2
main/newscorm/learnpathList.class.php

@@ -35,9 +35,11 @@ class learnpathList {
         if (!empty($course_code)){
             $course_info = api_get_course_info($course_code);
             $lp_table = Database::get_course_table(TABLE_LP_MAIN, $course_info['db_name']);
+            $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST, $course_info['db_name']);
         } else {
             $course_code = api_get_course_id();
             $lp_table = Database::get_course_table(TABLE_LP_MAIN);
+            $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
         }
         $this->course_code = $course_code;
         $this->user_id = $user_id;
@@ -58,8 +60,7 @@ class learnpathList {
         $names = array();
         while ($row = Database::fetch_array($res,'ASSOC')) {
             // Check if published.
-            $pub = '';
-            $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
+            $pub = '';            
             // Use domesticate here instead of Database::escape_string because
             // it prevents ' to be slashed and the input (done by learnpath.class.php::toggle_visibility())
             // is done using domesticate()

+ 6 - 2
main/session/index.php

@@ -150,8 +150,12 @@ foreach($final_array as $session_data) {
         if (!empty($course_data['exercises'])) {
             //Exercises            
             foreach ($course_data['exercises'] as $my_exercise_id => $exercise_data) {
-                $best_score_data = get_best_attempt_in_course($my_exercise_id, $my_course_code, $session_id);     
-                $best_score      = show_score($best_score_data['exe_result'], $best_score_data['exe_weighting']);
+                $best_score_data = get_best_attempt_in_course($my_exercise_id, $my_course_code, $session_id);
+                
+                $best_score = '';
+                if (!empty($best_score_data)) {     
+                	$best_score      = show_score($best_score_data['exe_result'], $best_score_data['exe_weighting']);
+                }
                 //Exercise results                              
                 $counter = 1;