[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Sat, 20 Jan 2007 22:04:57 -0000


raeburn		Sat Jan 20 17:04:57 2007 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
  Log:
  Fix &blockcheck() so it sends $startblock and $endblock from aggregation of blocks for all active courses for $uname:$udom.
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.501 loncom/interface/loncommon.pm:1.502
--- loncom/interface/loncommon.pm:1.501	Mon Jan 15 15:48:34 2007
+++ loncom/interface/loncommon.pm	Sat Jan 20 17:04:57 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.501 2007/01/15 20:48:34 banghart Exp $
+# $Id: loncommon.pm,v 1.502 2007/01/20 22:04:57 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2903,16 +2903,16 @@
         $uname = $env{'user.name'};
     }
 
-    my ($startblock,$endblock);
-
     # If uname and udom are for a course, check for blocks in the course.
 
     if (&Apache::lonnet::is_course($udom,$uname)) {
         my %records = &Apache::lonnet::dump('comm_block',$udom,$uname);
-        ($startblock,$endblock)=&get_blocks($setters,$activity,$udom,$uname);
+        my ($startblock,$endblock)=&get_blocks($setters,$activity,$udom,$uname);
         return ($startblock,$endblock);
     }
 
+    my $startblock = 0;
+    my $endblock = 0;
     my %live_courses = &findallcourses(undef,$uname,$udom);
 
     # If uname is for a user, and activity is course-specific, i.e.,
@@ -2973,8 +2973,6 @@
             if ($sec ne 'none') {
                 $checkrole .= '/'.$sec;
             }
-            # Resource belongs to user other than current user.
-            # Assemble privs for that user, and check for 'evb' priv.  
             if ($otheruser) {
                 # Resource belongs to user other than current user.
                 # Assemble privs for that user, and check for 'evb' priv.
@@ -3024,8 +3022,16 @@
 
         # Retrieve blocking times and identity of blocker for course
         # of specified user, unless user has 'evb' privilege.
-
-        ($startblock,$endblock)=&get_blocks($setters,$activity,$cdom,$cnum);
+        
+        my ($start,$end)=&get_blocks($setters,$activity,$cdom,$cnum);
+        if (($start != 0) && 
+            (($startblock == 0) || ($startblock > $start))) {
+            $startblock = $start;
+        }
+        if (($end != 0)  &&
+            (($endblock == 0) || ($endblock < $end))) {
+            $endblock = $end;
+        }
     }
     return ($startblock,$endblock);
 }