Browse Source

Minor - fix PHP warning, format code, avoid double id_session param

jmontoyaa 7 years ago
parent
commit
45a330d8f9
2 changed files with 20 additions and 20 deletions
  1. 1 1
      main/exercise/exercise.class.php
  2. 19 19
      main/inc/lib/exercise.lib.php

+ 1 - 1
main/exercise/exercise.class.php

@@ -5779,7 +5779,7 @@ class Exercise
         }
 
         $user_info = api_get_user_info(api_get_user_id());
-        $url = api_get_path(WEB_CODE_PATH).'exercise/exercise_show.php?'.api_get_cidreq().'&id_session='.$sessionId.'&id='.$exe_id.'&action=qualify';
+        $url = api_get_path(WEB_CODE_PATH).'exercise/exercise_show.php?'.api_get_cidreq().'&id='.$exe_id.'&action=qualify';
 
         if (!empty($sessionId)) {
             $addGeneralCoach = true;

+ 19 - 19
main/inc/lib/exercise.lib.php

@@ -1344,35 +1344,35 @@ HOTSPOT;
     }
 
     /**
-     * @param int $exe_id
+     * @param int $exeId
      *
      * @return array
      */
-    public static function get_exercise_track_exercise_info($exe_id)
+    public static function get_exercise_track_exercise_info($exeId)
     {
-        $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
-        $TBL_TRACK_EXERCICES = Database::get_main_table(
-            TABLE_STATISTIC_TRACK_E_EXERCISES
-        );
-        $TBL_COURSE = Database::get_main_table(TABLE_MAIN_COURSE);
-        $exe_id = intval($exe_id);
+        $quizTable = Database::get_course_table(TABLE_QUIZ_TEST);
+        $trackExerciseTable = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
+        $courseTable = Database::get_main_table(TABLE_MAIN_COURSE);
+        $exeId = (int) $exeId;
         $result = [];
-        if (!empty($exe_id)) {
+        if (!empty($exeId)) {
             $sql = " SELECT q.*, tee.*
-                FROM $TBL_EXERCICES as q
-                INNER JOIN $TBL_TRACK_EXERCICES as tee
+                FROM $quizTable as q
+                INNER JOIN $trackExerciseTable as tee
                 ON q.id = tee.exe_exo_id
-                INNER JOIN $TBL_COURSE c
+                INNER JOIN $courseTable c
                 ON c.id = tee.c_id
-                WHERE tee.exe_id = $exe_id
+                WHERE tee.exe_id = $exeId
                 AND q.c_id = c.id";
 
-            $res_fb_type = Database::query($sql);
-            $result = Database::fetch_array($res_fb_type, 'ASSOC');
-            $result['duration_formatted'] = '';
-            if (!empty($result['exe_duration'])) {
-                $time = api_format_time($result['exe_duration'], 'js');
-                $result['duration_formatted'] = $time;
+            $sqlResult = Database::query($sql);
+            if (Database::num_rows($sqlResult)) {
+                $result = Database::fetch_array($sqlResult, 'ASSOC');
+                $result['duration_formatted'] = '';
+                if (!empty($result['exe_duration'])) {
+                    $time = api_format_time($result['exe_duration'], 'js');
+                    $result['duration_formatted'] = $time;
+                }
             }
         }