Browse Source

Hiding LP for students if the time limit is not correct #1618

Julio Montoya 14 years ago
parent
commit
1e938ab086
2 changed files with 38 additions and 4 deletions
  1. 4 4
      main/newscorm/learnpathList.class.php
  2. 34 0
      main/newscorm/lp_list.php

+ 4 - 4
main/newscorm/learnpathList.class.php

@@ -75,24 +75,24 @@ class learnpathList {
             $vis = api_get_item_visibility(api_get_course_info($course_code), 'learnpath', $row['id'], $session_id);
             
             if (!empty($row['created_on']) && $row['created_on'] != '0000-00-00 00:00:00') {
-            	$row['created_on'] = api_get_local_time($row['created_on']);
+            	$row['created_on'] = $row['created_on'];
             } else {
             	$row['created_on'] = '';
             }
             if (!empty($row['modified_on']) && $row['modified_on'] != '0000-00-00 00:00:00') {
-                $row['modified_on'] = api_get_local_time($row['modified_on']);
+                $row['modified_on'] = $row['modified_on'];
             } else {
                 $row['modified_on'] = '';
             }
             
             if (!empty($row['publicated_on']) && $row['publicated_on'] != '0000-00-00 00:00:00') {
-                $row['publicated_on'] = api_get_local_time($row['publicated_on']);
+                $row['publicated_on'] = $row['publicated_on'];
             } else {
                 $row['publicated_on'] = '';
             }
             
             if (!empty($row['expired_on']) && $row['expired_on'] != '0000-00-00 00:00:00') {
-                $row['expired_on'] = api_get_local_time($row['expired_on']);
+                $row['expired_on'] = $row['expired_on'];
             } else {
                 $row['expired_on'] = '';
             }

+ 34 - 0
main/newscorm/lp_list.php

@@ -165,6 +165,7 @@ if (is_array($flat_list)) {
     $current        = 0;
     $autolunch_exists = false;
     foreach ($flat_list as $id => $details) {
+        
         // Validacion when belongs to a session
         $session_img = api_get_session_image($details['lp_session'], $_user['status']);
 
@@ -176,7 +177,37 @@ if (is_array($flat_list)) {
         // Check if the learnpath is visible for student.
         if (!$is_allowed_to_edit && !learnpath::is_lp_visible_for_student($id, api_get_user_id())) {
             continue;
+        }        
+        
+        if (!$is_allowed_to_edit) {
+            $time_limits = false;                  
+            if ($details['expired_on'] != '' && $details['expired_on'] != '0000-00-00 00:00:00') {
+                $time_limits = true;  
+            }            
+            
+            if (empty($details['created_on'])  && empty($details['modified_on'])   ) {
+                //This is an old LP (from a migration) so we do nothing
+                $time_limits = false;
+            }
+     
+            if ($time_limits) {
+                // check if start time
+                $start_time = api_strtotime($details['publicated_on'],'UTC');                
+                $end_time   = api_strtotime($details['expired_on'],'UTC');                                      
+                $now        = time();          
+                $is_actived_time = false;                
+                                    
+                if ($now > $start_time && $end_time > $now ) {
+                    $is_actived_time = true;
+                }
+                                
+                if (!$is_actived_time) {
+                	continue;
+                }                
+            }
+            
         }
+        
 
         $counter++;
         if (($counter % 2) == 0) { $oddclass = 'row_odd'; } else { $oddclass = 'row_even'; }
@@ -222,6 +253,9 @@ if (is_array($flat_list)) {
         } else {
             $dsp_progress = '<td width="140px" style="padding-top:1em;">'.learnpath::get_db_progress($id, api_get_user_id(), 'both','',false, api_get_session_id()).'</td>';
         }
+        
+        //
+  
 
         if ($is_allowed_to_edit) {