Diff for /loncom/interface/lonstatistics.pm between versions 1.122 and 1.138

version 1.122, 2005/03/21 19:47:53 version 1.138, 2007/06/06 17:30:40
Line 49  use Apache::Constants qw(:common :http); Line 49  use Apache::Constants qw(:common :http);
 use vars qw(  use vars qw(
     @FullClasslist       @FullClasslist 
     @Students      @Students
     @Sections       @Sections
       @Groups 
     %StudentData      %StudentData
     @StudentDataOrder      @StudentDataOrder
     @SelectedStudentData      @SelectedStudentData
     $enrollment_status);      $enrollment_status);
   
 use Apache::lonnet();  use Apache::lonnet;
 use Apache::lonhomework;  use Apache::lonhomework;
 use Apache::loncommon;  use Apache::loncommon;
 use Apache::loncoursedata;  use Apache::loncoursedata;
 use Apache::lonhtmlcommon;  use Apache::lonhtmlcommon;
 use Apache::lonmysql;  use Apache::lonmysql;
 use Apache::lonlocal;  use Apache::lonlocal;
   use Apache::longroup;
 use Time::HiRes;  use Time::HiRes;
 #  #
 # Statistics Packages  # Statistics Packages
Line 73  use Apache::lonstudentassessment(); Line 75  use Apache::lonstudentassessment();
 use Apache::lonpercentage;  use Apache::lonpercentage;
 use Apache::lonstudentsubmissions();  use Apache::lonstudentsubmissions();
 use Apache::lonsurveyreports();  use Apache::lonsurveyreports();
   use Apache::longradinganalysis();
   use LONCAPA;
   
 #######################################################  #######################################################
 #######################################################  #######################################################
Line 87  use Apache::lonsurveyreports(); Line 91  use Apache::lonsurveyreports();
   
 =item @Sections The sections available in this class  =item @Sections The sections available in this class
   
   =item @Groups The groups available in the class
   
 =item $curr_student The student currently being examined  =item $curr_student The student currently being examined
   
 =item $prev_student The student previous in the classlist  =item $prev_student The student previous in the classlist
Line 123  undef the following package variables: Line 129  undef the following package variables:
   
 =item @Sections  =item @Sections
   
   =item @Groups
   
 =item %StudentData  =item %StudentData
   
 =item @StudentDataOrder  =item @StudentDataOrder
Line 145  sub clear_classlist_variables { Line 153  sub clear_classlist_variables {
     undef(@FullClasslist);      undef(@FullClasslist);
     undef(@Students);      undef(@Students);
     undef(@Sections);      undef(@Sections);
       undef(@Groups);
     undef(%StudentData);      undef(%StudentData);
     undef(@SelectedStudentData);      undef(@SelectedStudentData);
     undef($curr_student);      undef($curr_student);
Line 170  the following package variables: Line 179  the following package variables:
   
 =item @Sections  =item @Sections
   
   =item @Groups 
   
 =item %StudentData  =item %StudentData
   
 =item @SelectedStudentData  =item @SelectedStudentData
Line 194  sub PrepareClasslist { Line 205  sub PrepareClasslist {
     &clear_classlist_variables();      &clear_classlist_variables();
     #      #
     # Retrieve the classlist      # Retrieve the classlist
     my $cid  = $ENV{'request.course.id'};      my $cid  = $env{'request.course.id'};
     my $cdom = $ENV{'course.'.$cid.'.domain'};      my $cdom = $env{'course.'.$cid.'.domain'};
     my $cnum = $ENV{'course.'.$cid.'.num'};      my $cnum = $env{'course.'.$cid.'.num'};
     my ($classlist,$field_names) = &Apache::loncoursedata::get_classlist($cid,      my ($classlist,$field_names) = &Apache::loncoursedata::get_classlist($cdom,
                                                                   $cdom,$cnum);   $cnum);
     my @selected_sections = &get_selected_sections();      my @selected_sections = &get_selected_sections();
       my @selected_groups = &get_selected_groups();
     #      #
     # Deal with instructors with restricted section access      # Deal with instructors with restricted section access
     if ($ENV{'request.course.sec'} !~ /^\s*$/) {      if ($env{'request.course.sec'} !~ /^\s*$/) {
         @selected_sections = ($ENV{'request.course.sec'});          @selected_sections = ($env{'request.course.sec'});
     }      }
     #      #
     # Set up %StudentData      # Set up %StudentData
     @StudentDataOrder = qw/fullname username domain id section status comments/;      @StudentDataOrder = qw/fullname username domain id section status groups comments/;
     foreach my $field (@StudentDataOrder) {      foreach my $field (@StudentDataOrder) {
         $StudentData{$field}->{'title'} = &mt($field);          $StudentData{$field}->{'title'} = &mt($field);
         $StudentData{$field}->{'base_width'} = length(&mt($field));          $StudentData{$field}->{'base_width'} = length(&mt($field));
Line 217  sub PrepareClasslist { Line 229  sub PrepareClasslist {
     #      #
     # get the status requested      # get the status requested
     $enrollment_status = 'Active';      $enrollment_status = 'Active';
     $enrollment_status = $ENV{'form.Status'} if (exists($ENV{'form.Status'}));      $enrollment_status = $env{'form.Status'} if (exists($env{'form.Status'}));
     #      #
       # Get groupmembership
       my ($classgroups,$studentgroups);
       my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
       if (%curr_groups) {
           ($classgroups,$studentgroups) = 
       &Apache::loncoursedata::get_group_memberships($classlist,
                                                             $field_names,
     $cdom,$cnum);
       }
       my $now = time;
   
     # Process the classlist      # Process the classlist
     while (my ($student,$student_data) = each (%$classlist)) {      while (my ($student,$student_data) = each (%$classlist)) {
         my $studenthash = ();          my $studenthash = ();
Line 233  sub PrepareClasslist { Line 256  sub PrepareClasslist {
                 $StudentData{$field}->{'width'} = $length;                   $StudentData{$field}->{'width'} = $length; 
             }              }
         }          }
           my @studentsgroups = &Apache::loncoursedata::get_students_groups
                                                      ($student,$enrollment_status,
                                                       $classgroups);
           if (@studentsgroups) {
               $studenthash->{'groups'} = join(', ',@studentsgroups);
               $studenthash->{'groupref'} = \@studentsgroups;
           } else {
               $studenthash->{'groups'} = 'none';
               $studenthash->{'groupref'} = []; 
           }
         push (@FullClasslist,$studenthash);          push (@FullClasslist,$studenthash);
         #          #
         # Build up a list of sections          # Build up a list of sections
Line 250  sub PrepareClasslist { Line 283  sub PrepareClasslist {
                  (($studenthash->{'status'} eq $enrollment_status) ||                    (($studenthash->{'status'} eq $enrollment_status) || 
                   ($enrollment_status eq 'Any'))                     ($enrollment_status eq 'Any')) 
                  ){                   ){
                 push (@Students,$studenthash);                  my $groupcheck = 0;
                 last;                  if (grep(/^all$/,@selected_groups)) {
                       push(@Students,$studenthash);
                       last;
                   } elsif (grep(/^none$/,@selected_groups)) {
                       if ($studenthash->{'groups'} eq 'none') {
                           push(@Students,$studenthash);
                           last;
                       }     
                   } else {
                       foreach my $group (@selected_groups) {
                           if (grep(/^$group$/,@studentsgroups)) {
                               push(@Students,$studenthash);
                               $groupcheck = 1;
                               last;
                           }
                       }
                       if ($groupcheck) {
                           last;
                       }
                   }
             }              }
         }          }
     }      }
     #      #
     # Put the consolidated section data in the right place      # Put the consolidated section data in the right place
     if ($ENV{'request.course.sec'} !~ /^\s*$/) {      if ($env{'request.course.sec'} !~ /^\s*$/) {
         @Sections = ($ENV{'request.course.sec'});          @Sections = ($env{'request.course.sec'});
     } else {      } else {
         @Sections = sort {$a cmp $b} keys(%Sections);          @Sections = sort {
       if ($a == $a && $b == $b ) { return $a <=> $b; }
       return $a cmp $b;
    } keys(%Sections);
   
         unshift(@Sections,'all'); # Put 'all' at the front of the list          unshift(@Sections,'all'); # Put 'all' at the front of the list
     }      }
       # Sort the groups
       @Groups = sort {$a cmp $b} keys(%{$studentgroups});
       unshift(@Groups,'all'); # Put 'all' at the front of the list
   
     #      #
     # Sort the Students      # Sort the Students
     my $sortby = 'fullname';      my $sortby = 'fullname';
     $sortby = $ENV{'form.sort'} if (exists($ENV{'form.sort'}));      $sortby = $env{'form.sort'} if (exists($env{'form.sort'}));
     my @TmpStudents = sort { $a->{$sortby} cmp $b->{$sortby} ||      my @TmpStudents = sort { lc($a->{$sortby}) cmp lc($b->{$sortby}) ||
                              $a->{'fullname'} cmp $b->{'fullname'} } @Students;                               lc($a->{'fullname'}) cmp lc($b->{'fullname'}) ||
        lc($a->{'username'}) cmp lc($b->{'username'}) } @Students;
     @Students = @TmpStudents;      @Students = @TmpStudents;
     #       # 
     # Now deal with that current student thing....      # Now deal with that current student thing....
     $curr_student = undef;      $curr_student = undef;
     if (exists($ENV{'form.SelectedStudent'})) {      if (exists($env{'form.SelectedStudent'})) {
         my ($current_uname,$current_dom) =           my ($current_uname,$current_dom) = 
             split(':',$ENV{'form.SelectedStudent'});              split(':',$env{'form.SelectedStudent'});
         my $i;          my $i;
         for ($i = 0; $i<=$#Students; $i++) {          for ($i = 0; $i<=$#Students; $i++) {
             next if (($Students[$i]->{'username'} ne $current_uname) ||               next if (($Students[$i]->{'username'} ne $current_uname) || 
Line 297  sub PrepareClasslist { Line 358  sub PrepareClasslist {
         }          }
     }      }
     #      #
     if (exists($ENV{'form.StudentData'})) {      if (exists($env{'form.StudentData'})) {
         if (ref($ENV{'form.StudentData'}) eq 'ARRAY') {   @SelectedStudentData = 
             @SelectedStudentData = @{$ENV{'form.StudentData'}};      &Apache::loncommon::get_env_multiple('form.StudentData');
         } else {  
             @SelectedStudentData = ($ENV{'form.StudentData'});  
         }  
     } else {      } else {
         @SelectedStudentData = ('username');          @SelectedStudentData = ('username');
     }      }
Line 330  Returns an array of the selected section Line 388  Returns an array of the selected section
 #######################################################  #######################################################
 #######################################################  #######################################################
 sub get_selected_sections {  sub get_selected_sections {
     my @selected_sections;      my @selected_sections = 
     if (exists($ENV{'form.Section'})) {   &Apache::loncommon::get_env_multiple('form.Section');
         if (ref($ENV{'form.Section'})) {  
             @selected_sections = @{$ENV{'form.Section'}};  
         } elsif ($ENV{'form.Section'} !~ /^\s*$/) {  
             @selected_sections = ($ENV{'form.Section'});  
         }  
     }  
     @selected_sections = ('all') if (! @selected_sections);      @selected_sections = ('all') if (! @selected_sections);
     foreach (@selected_sections) {      foreach (@selected_sections) {
         if ($_ eq 'all') {          if ($_ eq 'all') {
Line 346  sub get_selected_sections { Line 398  sub get_selected_sections {
     }      }
     #      #
     # Deal with instructors with restricted section access      # Deal with instructors with restricted section access
     if ($ENV{'request.course.sec'} !~ /^\s*$/) {      if ($env{'request.course.sec'} !~ /^\s*$/) {
         @selected_sections = ($ENV{'request.course.sec'});          @selected_sections = ($env{'request.course.sec'});
     }      }
     return @selected_sections;      return @selected_sections;
 }  }
   
 #######################################################  #######################################################
 #######################################################  #######################################################
                                                                                       
   =pod
                                                                                       
   =item get_selected_groups
                                                                                       
   Returns an array of the selected groups
                                                                                       
   =cut
                                                                                       
   #######################################################
   #######################################################
   sub get_selected_groups {
       my @selected_groups =
           &Apache::loncommon::get_env_multiple('form.Group');
       @selected_groups = ('all') if (! @selected_groups);
       foreach my $grp (@selected_groups) {
           if ($grp eq 'all') {
               @selected_groups = ('all');
               last;
           }
       }
       return @selected_groups;
   }
                                                                                       
 =pod  =pod
   
 =item &section_and_enrollment_description  =item &section_and_enrollment_description
   
 Returns a string describing the currenly selected section(s) and   Returns a string describing the currently selected section(s), group(s) and 
 enrollment status.    access status.  
   
 Inputs: mode = 'plaintext' or 'localized'  (defaults to 'localized')  Inputs: mode = 'plaintext' or 'localized'  (defaults to 'localized')
     'plaintext' is used for example in Excel spreadsheets.      'plaintext' is used for example in Excel spreadsheets.
Line 374  sub section_and_enrollment_description { Line 449  sub section_and_enrollment_description {
     my ($mode) = @_;      my ($mode) = @_;
     if (! defined($mode)) { $mode = 'localized'; }      if (! defined($mode)) { $mode = 'localized'; }
     my @sections = &Apache::lonstatistics::get_selected_sections();      my @sections = &Apache::lonstatistics::get_selected_sections();
       my @groups = &Apache::lonstatistics::get_selected_groups();
     my $description;      my $description;
     if ($mode eq 'localized') {      if ($mode eq 'localized') {
         $description = &mt('Unable to determine section and enrollment');          $description = &mt('Unable to determine section, groups and access status');
     } elsif ($mode eq 'plaintext') {      } elsif ($mode eq 'plaintext') {
         $description = 'Unable to determine section and enrollment';          $description = 'Unable to determine section, groups and access status';
     } else {      } else {
         $description = 'Bad parameter passed to lonstatistics::section_and_enrollment_description';          $description = 'Bad parameter passed to lonstatistics::section_and_enrollment_description';
         &Apache::lonnet::logthis($description);          &Apache::lonnet::logthis($description);
     }      }
     if (scalar(@sections) == 1 && $sections[0] ne 'all') {      $description = &section_or_group_text($mode,'section',@sections).
    ' '.&section_or_group_text($mode,'group',@groups);
       if ($mode eq 'localized') {
           $description .= &mt(' [_1] access status.',$env{'form.Status'});
       } elsif ($mode eq 'plaintext') {
           $description .= ' '.$env{'form.Status'}.' access status.';
       }
       return $description;
   }
   
   #######################################################
   #######################################################
   
   sub section_or_group_text {
       my ($mode,$type,@items) = @_;
       my $text;
       my %phrases = ();
       %{$phrases{'section'}} = (
                                 single => 'Section',
                                 all => 'All sections',
                                 plural => 'Sections',
                                );
       %{$phrases{'group'}} = (
                                 single => 'Group',
                                 all => 'All groups',
                                 plural => 'Groups',
                                );
       if (scalar(@items) == 1 && $items[0] ne 'all') {
         if ($mode eq 'localized') {          if ($mode eq 'localized') {
             $description = &mt('Section [_1]. [_2] enrollment status.',              $text = &mt('[_1] [_2].',$phrases{$type}{single},$items[0]);
                                $sections[0],$ENV{'form.Status'});  
         } elsif ($mode eq 'plaintext') {          } elsif ($mode eq 'plaintext') {
             $description = 'Section '.$sections[0].'. '.              $text = $phrases{$type}{single}.' '.$items[0].'.';
                 $ENV{'form.Status'}.' enrollment status.';  
         }          }
     } elsif (scalar(@sections) && $sections[0] eq 'all') {      } elsif (scalar(@items) && $items[0] eq 'all') {
         if ($mode eq 'localized') {          if ($mode eq 'localized') {
             $description = &mt('All sections. [_1] enrollment status.',              $text = &mt('[_1].',$phrases{$type}{all});
                                $ENV{'form.Status'});  
         } elsif ($mode eq 'plaintext') {          } elsif ($mode eq 'plaintext') {
             $description = 'All sections. '.              $text = $phrases{$type}{all}.'.';
                 $ENV{'form.Status'}.' enrollment status.';  
         }          }
     } elsif (scalar(@sections)) {      } elsif (scalar(@items)) {
         my $lastsection = pop(@sections);          my $lastitem = pop(@items);
         if ($mode eq 'localized') {          if ($mode eq 'localized') {
             $description = &mt('Sections [_1] and [_2]. [_3] enrollment status.',              $text = &mt('[_1] [_2] and [_3].',$phrases{$type}{plural},
                                join(', ',@sections),$lastsection,                          join(', ',@items),$lastitem);
                                $ENV{'form.Status'});  
         } elsif ($mode eq 'plaintext') {          } elsif ($mode eq 'plaintext') {
             $description =               $text = $phrases{$type}{plural}.' '.join(', ',@items).' and '.
                 'Sections '.join(', ',@sections).' and '.$lastsection.'. '.                      $lastitem.'.';
                 $ENV{'form.Status'}.' enrollment status.';  
         }          }
     }      }
     return $description;      return $text;
 }  }
   
 #######################################################  
 #######################################################  
   
 =pod  =pod
   
Line 569  Returns: Array of symbs of selected maps Line 665  Returns: Array of symbs of selected maps
 #######################################################  #######################################################
 sub get_selected_maps {  sub get_selected_maps {
     my ($elementname) = @_;      my ($elementname) = @_;
     my @selected_maps;      my @selected_maps = 
     if (exists($ENV{'form.'.$elementname})) {   &Apache::loncommon::get_env_multiple('form.'.$elementname);
         if (ref($ENV{'form.'.$elementname})) {      @selected_maps = ('all') if (! @selected_maps);
             @selected_maps = @{$ENV{'form.'.$elementname}};  
         } else {  
             @selected_maps = ($ENV{'form.'.$elementname});  
         }  
     } else {  
         @selected_maps = ('all');  
     }  
     foreach my $map (@selected_maps) {      foreach my $map (@selected_maps) {
         if ($map eq 'all') {          if ($map eq 'all') {
             @selected_maps = ('all');              @selected_maps = ('all');
Line 772  sub SectionSelect { Line 861  sub SectionSelect {
     return $Str;      return $Str;
 }  }
   
   ##############################################
   ##############################################
                                                                                       
   =pod
                                                                                       
   =item &GroupSelect($elementname,$status,$numvisible)
                                                                                       
   Returns html for a selection box allowing the user to choose one (or more)
   of the groups in the course.
                                                                                       
   Uses the package variables @Groups
   =over 4
                                                                                       
   =item $elementname The name of the HTML form element
                                                                                       
   =item $status 'multiple' or 'single' selection box
                                                                                       
   =item $numvisible The number of options to be visible
                                                                                       
   =back
                                                                                       
   =cut
                                                                                       
   ##############################################
   ##############################################
   sub GroupSelect {
       my ($elementname,$status,$numvisible)=@_;
       if ($numvisible < 1) {
           return;
       }
       #
       # Make sure we have the data we need to continue
       if (! @Groups) {
           &PrepareClasslist();
       }
       #
       # Build the form element
       my $Str = "\n";
       $Str .= '<select name="'.$elementname.'" ';
       if ($status ne 'single') {
           $Str .= 'multiple="true" ';
       }
       $Str .= 'size="'.$numvisible.'" >'."\n";
       #
       # Loop through the groups
       foreach my $s (@Groups) {
           $Str .= '    <option value="'.$s.'" ';
           foreach my $group (&get_selected_groups()) {
               if ($s eq $group) {
                   $Str .= 'selected ';
                   last;
               }
           }
           $Str .= '>'.$s."</option>\n";
       }
       $Str .= "</select>\n";
   }
   
   
 ##################################################  ##################################################
 ##################################################  ##################################################
 sub DisplayClasslist {  sub DisplayClasslist {
Line 781  sub DisplayClasslist { Line 929  sub DisplayClasslist {
     #      #
     # Output some of the standard interface components      # Output some of the standard interface components
     my $Str;      my $Str;
     $Str .= &Apache::lonhtmlcommon::breadcrumbs(undef,'Select One Student');      $Str .= &Apache::lonhtmlcommon::breadcrumbs('Select One Student');
     $Str .= '<p><table cellspacing="5">'."\n";      $Str .= '<p><table cellspacing="5">'."\n";
     $Str .= '<tr>';      $Str .= '<tr>';
     $Str .= '<th align="center"><b>'.&mt('Sections').'</b></th>';      $Str .= '<th align="center"><b>'.&mt('Sections').'</b></th>';
     $Str .= '<th align="center"><b>'.&mt('Enrollment Status').'</b></th>';      $Str .= '<th align="center"><b>'.&mt('Groups').'</b></th>';
       $Str .= '<th align="center"><b>'.&mt('Access Status').'</b></th>';
     $Str .= '</tr>'.$/;      $Str .= '</tr>'.$/;
     $Str .= '<tr>';      $Str .= '<tr>';
     $Str .= '<td>'.      $Str .= '<td>'.
         &Apache::lonstatistics::SectionSelect('Section','multiple',5).          &Apache::lonstatistics::SectionSelect('Section','multiple',5).
         '</td>';          '</td>';
       $Str .=  '<td>'.
           &Apache::lonstatistics::GroupSelect('Group','multiple',5).
           '</td>';
     $Str .= '<td>'.      $Str .= '<td>'.
         &Apache::lonhtmlcommon::StatusOptions(undef,undef,5).          &Apache::lonhtmlcommon::StatusOptions(undef,undef,5).
         '</td>';          '</td>';
Line 802  sub DisplayClasslist { Line 954  sub DisplayClasslist {
     $r->print($Str);      $r->print($Str);
     $r->rflush();      $r->rflush();
     #      #
     my @Fields = ('fullname','username','domain','id','section','status');      my @Fields = ('fullname','username','domain','id','section','status','groups');
     #      #
     $Str = '';      $Str = '';
     my @selected_sections = &get_selected_sections();      my @selected_sections = &get_selected_sections();
     if (! @Students) {      if (! @Students) {
         if ($selected_sections[0] eq 'all') {           if ($selected_sections[0] eq 'all') { 
             if (lc($ENV{'form.Status'}) eq 'any') {              if (lc($env{'form.Status'}) eq 'any') {
                 $Str .= '<h2>'.                  $Str .= '<h2>'.
                     &mt('There are no students in the course.').                      &mt('There are no students in the course.').
                     '</h2>';                      '</h2>';
             } elsif (lc($ENV{'form.Status'}) eq 'active') {              } elsif (lc($env{'form.Status'}) eq 'active') {
                 $Str .= '<h2>'.                  $Str .= '<h2>'.
                 &mt('There are no currently enrolled students in the course.').                  &mt('There are no currently enrolled students in the course.').
                     '</h2>';                      '</h2>';
             } elsif (lc($ENV{'form.Status'}) eq 'expired') {              } elsif (lc($env{'form.Status'}) eq 'expired') {
                 $Str .= '<h2>'.                  $Str .= '<h2>'.
                     &mt('There are no previously enrolled students in the course.').                      &mt('There are no previously enrolled students in the course.').
                         '</h2>';                          '</h2>';
             }              }
         } else {           } else { 
             my $sections;              my $sections;
             if (lc($ENV{'form.Status'}) eq 'any') {              if (lc($env{'form.Status'}) eq 'any') {
                 $Str .= '<h2>'.                  $Str .= '<h2>'.
                     &mt('There are no students in the selected sections.').                      &mt('There are no students in the selected sections.').
                     '</h2>';                      '</h2>';
             } elsif (lc($ENV{'form.Status'}) eq 'active') {              } elsif (lc($env{'form.Status'}) eq 'active') {
                 $Str .= '<h2>'.                  $Str .= '<h2>'.
                     &mt('There are no currently enrolled students in the selected sections.').                      &mt('There are no currently enrolled students in the selected sections.').
                     '</h2>';                      '</h2>';
             } elsif (lc($ENV{'form.Status'}) eq 'expired') {              } elsif (lc($env{'form.Status'}) eq 'expired') {
                 $Str .= '<h2>'.                  $Str .= '<h2>'.
                     &mt('There are no previously enrolled students in the selected sections.').                      &mt('There are no previously enrolled students in the selected sections.').
                     '</h2>';                      '</h2>';
Line 871  sub DisplayClasslist { Line 1023  sub DisplayClasslist {
             $Str .= '<td>';              $Str .= '<td>';
             if ($field eq 'fullname' || $field eq 'username') {              if ($field eq 'fullname' || $field eq 'username') {
                 $Str .= '<a href="/adm/statistics?reportSelected=';                  $Str .= '<a href="/adm/statistics?reportSelected=';
                 $Str .= &Apache::lonnet::escape('student_assessment');                  $Str .= &escape('student_assessment');
                 $Str .= '&sort='.&Apache::lonnet::escape($ENV{'form.sort'});                  $Str .= '&sort='.&escape($env{'form.sort'});
                 $Str .= '&SelectedStudent=';                  $Str .= '&SelectedStudent=';
                 $Str .= &Apache::lonnet::escape($sname).'">';                  $Str .= &escape($sname).'">';
                 $Str .= $student->{$field}.'&nbsp';                  $Str .= $student->{$field}.'&nbsp';
                 $Str .= '</a>';                  $Str .= '</a>';
             } elsif ($field eq 'status') {              } elsif ($field eq 'status') {
Line 929  sub CreateMainMenu { Line 1081  sub CreateMainMenu {
                      short_description =>                        short_description => 
     &mt('Display a histogram of student performance in the course.'),      &mt('Display a histogram of student performance in the course.'),
                  },                   },
   #                   { internal_name => 'grading_analysis',
   #                     name => &mt('Detailed Grading Analysis'),
   #                     short_description => 
   #    &mt('Display statistics about who graded who.'),
   #                 },
 #                   { internal_name => 'student_assessment',  #                   { internal_name => 'student_assessment',
 #                     name => &mt('Problem Status Chart'),  #                     name => &mt('Problem Status Chart'),
 #                     short_description =>   #                     short_description => 
Line 964  sub handler { Line 1121  sub handler {
     if ($loaderror) { return $loaderror; }      if ($loaderror) { return $loaderror; }
     $loaderror=      $loaderror=
        &Apache::lonnet::overloaderror($r,         &Apache::lonnet::overloaderror($r,
          $ENV{'course.'.$ENV{'request.course.id'}.'.home'});           $env{'course.'.$env{'request.course.id'}.'.home'});
     if ($loaderror) { return $loaderror; }      if ($loaderror) { return $loaderror; }
     #      #
     # Check for access      # Check for access
     if (! &Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {      if (! &Apache::lonnet::allowed('vgr',$env{'request.course.id'})) {
         $ENV{'user.error.msg'}=          $env{'user.error.msg'}=
             $r->uri.":vgr:0:0:Cannot view grades for complete course";              $r->uri.":vgr:0:0:Cannot view grades for complete course";
         if (! &Apache::lonnet::allowed('vgr',          if (! &Apache::lonnet::allowed('vgr',
                       $ENV{'request.course.id'}.'/'.$ENV{'request.course.sec'})) {                        $env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
             $ENV{'user.error.msg'}=              $env{'user.error.msg'}=
                 $r->uri.":vgr:0:0:Cannot view grades with given role";                  $r->uri.":vgr:0:0:Cannot view grades with given role";
             return HTTP_NOT_ACCEPTABLE;              return HTTP_NOT_ACCEPTABLE;
         }          }
Line 999  sub handler { Line 1156  sub handler {
     td.essay          { border: 1px solid gray; }      td.essay          { border: 1px solid gray; }
 </style>  </style>
 ENDSTYLE  ENDSTYLE
     my $html=&Apache::lonxml::xmlbegin();        
     $r->print($html.'<head><title>'.      $r->print(&Apache::loncommon::start_page('Course Statistics and Charts',
               &mt('Course Statistics and Charts').       $style));
               '</title>'.$style.  
               "</head>\n".  
               &Apache::loncommon::bodytag('Course Statistics and Charts'));  
     $r->rflush();      $r->rflush();
     #       # 
     # Either print out a menu for them or send them to a report      # Either print out a menu for them or send them to a report
Line 1014  ENDSTYLE Line 1168  ENDSTYLE
                                             text =>'Statistics',                                              text =>'Statistics',
                                             faq=>139,                                              faq=>139,
                                             bug=>'Statistics and Charts'});                                              bug=>'Statistics and Charts'});
     if (! exists($ENV{'form.reportSelected'}) ||       if (! exists($env{'form.reportSelected'}) || 
         $ENV{'form.reportSelected'} eq '') {          $env{'form.reportSelected'} eq '') {
         $r->print(&Apache::lonhtmlcommon::breadcrumbs          $r->print(&Apache::lonhtmlcommon::breadcrumbs('Statistics Main Page').
                   (undef,&mt('Statistics Main Page')).  
                   &CreateMainMenu());                    &CreateMainMenu());
     } else {      } else {
     #      #
Line 1034  ENDSTYLE Line 1187  ENDSTYLE
                           'retrieved until the database is restarted.  '.                            'retrieved until the database is restarted.  '.
                           'Your data is intact but cannot be displayed '.                            'Your data is intact but cannot be displayed '.
                           'at this time.').'</p>');                            'at this time.').'</p>');
             $r->print('</body></html>');              $r->print(&Apache::loncommon::end_page());
             return;              return;
         }          }
         #          #
         # Clean out the caches          # Clean out the caches
         if (exists($ENV{'form.ClearCache'})) {          if (exists($env{'form.ClearCache'})) {
             &Apache::loncoursedata::delete_caches($ENV{'requres.course.id'});              &Apache::loncoursedata::delete_caches($env{'requres.course.id'});
         }          }
         #          #
         # Begin form output          # Begin form output
Line 1048  ENDSTYLE Line 1201  ENDSTYLE
         $r->print('method="post" action="/adm/statistics">');          $r->print('method="post" action="/adm/statistics">');
         $r->rflush();          $r->rflush();
         #          #
         my $GoToPage = $ENV{'form.reportSelected'};          my $GoToPage = $env{'form.reportSelected'};
         #          #
         $r->print('<input type="hidden" name="reportSelected" value="'.          $r->print('<input type="hidden" name="reportSelected" value="'.
                   $GoToPage.'">');                    $GoToPage.'">');
Line 1093  ENDSTYLE Line 1246  ENDSTYLE
                 ({href=>'/adm/statistics?reportselected=student_assessment',                  ({href=>'/adm/statistics?reportselected=student_assessment',
                   text=>'Chart'});                    text=>'Chart'});
             &Apache::lonstudentassessment::BuildStudentAssessmentPage($r,$c);              &Apache::lonstudentassessment::BuildStudentAssessmentPage($r,$c);
         }          } elsif($GoToPage eq 'grading_analysis') {
               &Apache::lonhtmlcommon::add_breadcrumb
                   ({href=>'/adm/statistics?reportselected=grading_anaylsis',
                     text=>'Grading Analysis'});
               &Apache::longradinganalysis::build_grading_analysis_page($r,$c);
    }
         #          #
         $r->print("</form>\n");          $r->print("</form>\n");
     }      }
     $r->print("</body>\n</html>\n");      $r->print(&Apache::loncommon::end_page());
     $r->rflush();      $r->rflush();
     #      #
     return OK;      return OK;

Removed from v.1.122  
changed lines
  Added in v.1.138


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>