--- loncom/interface/lonstatistics.pm 2003/04/21 15:12:37 1.67 +++ loncom/interface/lonstatistics.pm 2003/05/13 14:25:37 1.69 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstatistics.pm,v 1.67 2003/04/21 15:12:37 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 @@ sub PrepareClasslist { } } # + # 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,10 @@ sub PrepareClasslist { $StudentData{$field}->{'width'} = $StudentData{$field}->{'base_width'}; } - + # + # get the status requested + my $requested_status = 'Active'; + $requested_status = $ENV{'form.Status'} if (exists($ENV{'form.Status'})); # # Process the classlist while (my ($student,$student_data) = each (%$classlist)) { @@ -266,7 +274,11 @@ sub PrepareClasslist { # # Only put in the list those students we are interested in foreach my $sect (@SelectedSections) { - if (($sect eq 'all') || ($section eq $sect)) { + if ( (($sect eq 'all') || + ($section eq $sect)) && + (($studenthash->{'status'} eq $requested_status) || + ($requested_status eq 'Any')) + ){ push (@Students,$studenthash); last; } @@ -274,8 +286,12 @@ sub PrepareClasslist { } # # 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'; @@ -834,7 +850,6 @@ sub CreateMainMenu { $Str .= ''."\n"; $Str .= ''."\n"; $Str .= 'Select a Report'."\n"; - $Str .= 'Student Status'."\n"; $Str .= ''."\n"; # $Str .= ''. @@ -855,10 +870,6 @@ sub CreateMainMenu { } $Str .= ''."\n"; # - $Str .= ''; - $Str .= &Apache::lonhtmlcommon::StatusOptions($status, 'Statistics'); - $Str .= ''."\n"; - # $Str .= ''."\n"; $Str .= '
'."\n"; # @@ -880,10 +891,15 @@ sub handler { 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