Diff for /loncom/interface/lonquickgrades.pm between versions 1.50 and 1.51

version 1.50, 2010/11/27 20:51:26 version 1.51, 2010/11/29 22:37:26
Line 72  sub real_handler { Line 72  sub real_handler {
         $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories';          $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories';
   
   
     # Create the nav map  
     my $navmap = Apache::lonnavmaps::navmap->new();  
   
     if (!defined($navmap)) {  
         my $requrl = $r->uri;  
         $env{'user.error.msg'} = "$requrl:bre:0:0:Navamp initialization failed.";  
         return HTTP_NOT_ACCEPTABLE;  
     }  
   
     # Keep this hash in sync with %statusIconMap in lonnavmaps; they  
     # should match color/icon  
     my $res = $navmap->firstResource(); # temp resource to access constants  
    
     # Header      # Header
     my $title = "Grading and Statistics";#$showPoints ? "Points Display" : "Completed Problems Display";      my $title = "Grading and Statistics";#$showPoints ? "Points Display" : "Completed Problems Display";
     my $brcrum = [{href=>"/adm/quickgrades",text => "Points Display"}];      my $brcrum = [{href=>"/adm/quickgrades",text => "Points Display"}];
Line 104  sub real_handler { Line 91  sub real_handler {
     $r->print('<p class="LC_info">'.&mt('This may take a few moments to display.').'</p>');      $r->print('<p class="LC_info">'.&mt('This may take a few moments to display.').'</p>');
   
     $r->rflush();      $r->rflush();
       my ($navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)=&getData($showPoints);
       &outputTable($r,$showPoints,$notshowTotals,
                    $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted);
       return OK;
   
   }
   
   sub getData {
   
       my ($showPoints)=@_;
   
       # Create the nav map
       my $navmap = Apache::lonnavmaps::navmap->new();
   
     # End navmap using boilerplate      my $res = $navmap->firstResource(); # temp resource to access constants
   
     my $iterator = $navmap->getIterator(undef, undef, undef, 1);      my $iterator = $navmap->getIterator(undef, undef, undef, 1);
     my $depth = 1;      my $depth = 1;
Line 220  sub real_handler { Line 220  sub real_handler {
         }          }
         $curRes = $iterator->next();          $curRes = $iterator->next();
     }      }
       return ($navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted);
   }
   
     $iterator = $navmap->getIterator(undef, undef, undef, 1);  #
     $depth = 1;  # Outputting everything.
     $iterator->next(); # ignore first BEGIN_MAP  #
     $curRes = $iterator->next();  
   sub outputTable {
   
       my ($r,$showPoints,$notshowTotals,
              $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)=@_;
   
     my @start = (255, 255, 192);      my @start = (255, 255, 192);
     my @end   = (0, 192, 0);      my @end   = (0, 192, 0);
Line 235  sub real_handler { Line 241  sub real_handler {
     $r->print(&Apache::loncommon::start_data_table()      $r->print(&Apache::loncommon::start_data_table()
              .&Apache::loncommon::start_data_table_header_row()               .&Apache::loncommon::start_data_table_header_row()
              .'<th>'.&mt('Folder').'</th>');               .'<th>'.&mt('Folder').'</th>');
     $title = &mt($showPoints ? "Points Scored" : "Done");      my $title = &mt($showPoints ? "Points Scored" : "Done");
     if ($totalAttempted) {      if ($totalAttempted) {
  $title .= " / " . &mt("Attempted");          $title .= " / " . &mt("Attempted");
     }      }
     $r->print("<th>$title".($notshowTotals?'':" / ".&mt('Total')).'</th>'      $r->print("<th>$title".($notshowTotals?'':" / ".&mt('Total')).'</th>'
              .&Apache::loncommon::end_data_table_header_row());               .&Apache::loncommon::end_data_table_header_row());
   #
   # Output of folder scores
   #
   
       my $iterator = $navmap->getIterator(undef, undef, undef, 1);
       my $depth = 1;
       $iterator->next(); # ignore first BEGIN_MAP
       my $curRes = $iterator->next();
   
     while ($depth > 0) {      while ($depth > 0) {
         if ($curRes == $iterator->BEGIN_MAP()) {$depth++;}          if ($curRes == $iterator->BEGIN_MAP()) {$depth++;}
         if ($curRes == $iterator->END_MAP()) { $depth--; }          if ($curRes == $iterator->END_MAP()) { $depth--; }
Line 255  sub real_handler { Line 270  sub real_handler {
             if ($total > 0) {              if ($total > 0) {
                 my $ratio;                  my $ratio;
                 $ratio = $correct / $total;                  $ratio = $correct / $total;
                 my $color = mixColors(\@start, \@end, $ratio);                  my $color = &mixColors(\@start, \@end, $ratio);
                 $r->print(&Apache::loncommon::start_data_table_row()                  $r->print(&Apache::loncommon::start_data_table_row()
                          .'<td style="background-color:'.$color.';">');                           .'<td style="background-color:'.$color.';">');
                                   
Line 296  sub real_handler { Line 311  sub real_handler {
                  .&Apache::loncommon::end_data_table_row());                   .&Apache::loncommon::end_data_table_row());
     }      }
   
   #
   # show totals (if applicable), close table
   #
     if ($showPoints) {      if ($showPoints) {
  my $maxHelpLink = Apache::loncommon::help_open_topic("Quick_Grades_Possibly_Correct");          my $maxHelpLink = Apache::loncommon::help_open_topic("Quick_Grades_Possibly_Correct");
   
  $title = $showPoints ? "Points" : "Parts Done";          $title = $showPoints ? "Points" : "Parts Done";
  my $totaltitle = $showPoints ? &mt("Awarded Total Points") : &mt("Total Parts Done");          my $totaltitle = $showPoints ? &mt("Awarded Total Points") : &mt("Total Parts Done");
  $r->print(&Apache::loncommon::start_data_table_row()          $r->print(&Apache::loncommon::start_data_table_row()
                  .'<td colspan="2" align="right">'.$totaltitle.': <b>'.$totalRight.'</b><br />');                   .'<td colspan="2" align="right">'.$totaltitle.': <b>'.$totalRight.'</b><br />');
  $r->print(&mt('Max Possible To Date')." $maxHelpLink: <b>$totalPossible</b><br />");          $r->print(&mt('Max Possible To Date')." $maxHelpLink: <b>$totalPossible</b><br />");
  $title = $showPoints ? "Points" : "Parts";          $title = $showPoints ? "Points" : "Parts";
  $r->print(&mt("Total $title In Course").': <b>'.$totalParts.'</b></td>'          $r->print(&mt("Total $title In Course").': <b>'.$totalParts.'</b></td>'
                  .&Apache::loncommon::end_data_table_row());                   .&Apache::loncommon::end_data_table_row());
     }      }
   
     $r->print(&Apache::loncommon::end_data_table()      $r->print(&Apache::loncommon::end_data_table()
              .&Apache::loncommon::end_page());               .&Apache::loncommon::end_page());
   
     return OK;  
 }  }
   
 # Pass this two refs to arrays for the start and end color, and a number  # Pass this two refs to arrays for the start and end color, and a number
 # from 0 to 1 for how much of the latter you want to mix in. It will  # from 0 to 1 for how much of the latter you want to mix in. It will
 # return a string ready to show ("#FFC309");  # return a string ready to show ("#FFC309");
   
 sub mixColors {  sub mixColors {
     my $start = shift;      my $start = shift;
     my $end = shift;      my $end = shift;

Removed from v.1.50  
changed lines
  Added in v.1.51


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