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

matthew lon-capa-cvs@mail.lon-capa.org
Tue, 13 May 2003 14:25:37 -0000


matthew		Tue May 13 10:25:37 2003 EDT

  Modified files:              
    /loncom/interface	lonstatistics.pm 
  Log:
  Bug 1319: restricting a role to viewing only a given section of the course
  now works. $ENV{'request.course.sec'} is assumed to be empty when the user
  has full access and nonempty when they are restricted.
  
  
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.68 loncom/interface/lonstatistics.pm:1.69
--- loncom/interface/lonstatistics.pm:1.68	Mon May 12 18:07:17 2003
+++ loncom/interface/lonstatistics.pm	Tue May 13 10:25:37 2003
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstatistics.pm,v 1.68 2003/05/12 22:07:17 matthew Exp $
+# $Id: lonstatistics.pm,v 1.69 2003/05/13 14:25:37 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -230,6 +230,11 @@
         }
     }
     #
+    # Deal with instructors with restricted section access
+    if ($ENV{'request.course.sec'} ne '') {
+        @SelectedSections = ($ENV{'request.course.sec'});
+    }
+    #
     # Set up %StudentData
     @StudentDataOrder = qw/fullname username domain id section status/;
     foreach my $field (@StudentDataOrder) {
@@ -238,7 +243,6 @@
         $StudentData{$field}->{'width'} = 
                                $StudentData{$field}->{'base_width'};
     }
-
     #
     # get the status requested
     my $requested_status = 'Active';
@@ -282,8 +286,12 @@
     }
     #
     # Put the consolidated section data in the right place
-    @Sections = sort {$a cmp $b} keys(%Sections);
-    unshift(@Sections,'all'); # Put 'all' at the front of the list
+    if ($ENV{'request.course.sec'} ne '') {
+        @Sections = ($ENV{'request.course.sec'});
+    } else {
+        @Sections = sort {$a cmp $b} keys(%Sections);
+        unshift(@Sections,'all'); # Put 'all' at the front of the list
+    }
     #
     # Sort the Students
     my $sortby = 'fullname';
@@ -883,10 +891,15 @@
     if ($loaderror) { return $loaderror; }
     #
     # Check for access
-    unless(&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {
+    if (! &Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {
         $ENV{'user.error.msg'}=
-        $r->uri.":vgr:0:0:Cannot view grades for complete course";
-        return HTTP_NOT_ACCEPTABLE;
+            $r->uri.":vgr:0:0:Cannot view grades for complete course";
+        if (! &Apache::lonnet::allowed('vgr',
+                      $ENV{'request.course.id'}.'/'.$ENV{'request.course.sec'})) {
+            $ENV{'user.error.msg'}=
+                $r->uri.":vgr:0:0:Cannot view grades with given role";
+            return HTTP_NOT_ACCEPTABLE;
+        }
     }
     #
     # Set document type for header only