Browse Source

Fix session visibility out of date - refs BT#12412

Angel Fernando Quiroz Campos 8 years ago
parent
commit
7c8b711b67
1 changed files with 13 additions and 11 deletions
  1. 13 11
      main/inc/lib/api.lib.php

+ 13 - 11
main/inc/lib/api.lib.php

@@ -2277,17 +2277,6 @@ function api_get_session_visibility(
             $isCoach = api_is_coach($session_id, $courseId);
 
             if ($isCoach) {
-                // Test end date.
-                if (!empty($row['coach_access_end_date'])) {
-                    $endDateCoach = api_strtotime($row['coach_access_end_date'], 'UTC');
-
-                    if ($endDateCoach >= $now) {
-                        $visibility = SESSION_AVAILABLE;
-                    } else {
-                        $visibility = SESSION_INVISIBLE;
-                    }
-                }
-
                 // Test start date.
                 if (!empty($row['coach_access_start_date'])) {
                     $start = api_strtotime($row['coach_access_start_date'], 'UTC');
@@ -2297,6 +2286,19 @@ function api_get_session_visibility(
                         $visibility = SESSION_INVISIBLE;
                     }
                 }
+
+                // Test end date.
+                if (!empty($row['coach_access_end_date'])) {
+                    if ($visibility = SESSION_AVAILABLE) {
+                        $endDateCoach = api_strtotime($row['coach_access_end_date'], 'UTC');
+
+                        if ($endDateCoach >= $now) {
+                            $visibility = SESSION_AVAILABLE;
+                        } else {
+                            $visibility = $row['visibility'];
+                        }
+                    }
+                }
             }
         } else {
             $visibility = SESSION_INVISIBLE;