--- loncom/interface/lonquickgrades.pm 2010/11/27 20:51:26 1.50 +++ loncom/interface/lonquickgrades.pm 2010/11/29 22:37:26 1.51 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Quick Student Grades Display # -# $Id: lonquickgrades.pm,v 1.50 2010/11/27 20:51:26 www Exp $ +# $Id: lonquickgrades.pm,v 1.51 2010/11/29 22:37:26 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -72,19 +72,6 @@ sub real_handler { $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 my $title = "Grading and Statistics";#$showPoints ? "Points Display" : "Completed Problems Display"; my $brcrum = [{href=>"/adm/quickgrades",text => "Points Display"}]; @@ -104,8 +91,21 @@ sub real_handler { $r->print('
'.&mt('This may take a few moments to display.').'
'); $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; + +} - # End navmap using boilerplate +sub getData { + + my ($showPoints)=@_; + + # Create the nav map + my $navmap = Apache::lonnavmaps::navmap->new(); + + my $res = $navmap->firstResource(); # temp resource to access constants my $iterator = $navmap->getIterator(undef, undef, undef, 1); my $depth = 1; @@ -220,11 +220,17 @@ sub real_handler { } $curRes = $iterator->next(); } + return ($navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted); +} - $iterator = $navmap->getIterator(undef, undef, undef, 1); - $depth = 1; - $iterator->next(); # ignore first BEGIN_MAP - $curRes = $iterator->next(); +# +# Outputting everything. +# + +sub outputTable { + + my ($r,$showPoints,$notshowTotals, + $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)=@_; my @start = (255, 255, 192); my @end = (0, 192, 0); @@ -235,12 +241,21 @@ sub real_handler { $r->print(&Apache::loncommon::start_data_table() .&Apache::loncommon::start_data_table_header_row() .'