--- loncom/interface/lonquickgrades.pm 2010/11/29 22:37:26 1.51 +++ loncom/interface/lonquickgrades.pm 2010/12/03 21:33:52 1.55 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Quick Student Grades Display # -# $Id: lonquickgrades.pm,v 1.51 2010/11/29 22:37:26 www Exp $ +# $Id: lonquickgrades.pm,v 1.55 2010/12/03 21:33:52 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -61,9 +61,9 @@ sub real_handler { &Apache::loncommon::no_cache($r); $r->send_http_header; - my $showPoints = + my $showPoints = $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'standard'; - my $notshowSPRSlink = + my $notshowSPRSlink = (($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'external') || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals')); my $notshowTotals= @@ -72,38 +72,90 @@ sub real_handler { $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories'; - # Header my $title = "Grading and Statistics";#$showPoints ? "Points Display" : "Completed Problems Display"; my $brcrum = [{href=>"/adm/quickgrades",text => "Points Display"}]; $r->print(&Apache::loncommon::start_page($title,undef, {'bread_crumbs' => $brcrum}) ); - if (!$showPoints && !$notshowSPRSlink ) { - $r->print('

' - .&mt('This screen shows how many problems (or problem parts) you have completed' - .', and how many you have not yet done.' - .' You can also look at [_1]a detailed score sheet[_2].' - ,'','') - .'

'); - } - - $r->print('

'.&mt('This may take a few moments to display.').'

'); + &startGradeScreen($r,'quick'); $r->rflush(); - my ($navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)=&getData($showPoints); - &outputTable($r,$showPoints,$notshowTotals, + +# my $uname='korte'; +# my $udom='gerd'; + + my $uname; + my $udom; + + my ($navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)= + &getData($showPoints,$uname,$udom); + + if ($showCategories) { + &outputCategories($r,$showPoints,$notshowTotals, + $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted); + } else { + &outputTable($r,$showPoints,$notshowTotals, $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted); + } + &endGradeScreen($r); return OK; } +sub startGradeScreen { + my ($r,$mode)=@_; + + my $showPoints = + $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'standard'; + my $notshowSPRSlink = + (($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'external') + || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals') + || ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories')); + my $notshowTotals= + $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals'; + my $showCategories= + $env{'course.'.$env{'request.course.id'}.'.grading'} eq 'categories'; + + my $allowed_to_view = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}); + my $allowed_to_edit = &Apache::lonnet::allowed('mgr',$env{'request.course.id'}); + + if ($allowed_to_view) { + $r->print(''); + if ($notshowTotals) { $r->print (''); } + if ($notshowSPRSlink){ $r->print (''); } + if ($showPoints) { $r->print (''); } + if ($showCategories) { $r->print (''); } + $r->print('
'.&mt('Students do not see total points.').''.&mt('Students do not see link to spreadsheet.').''.&mt('Students will see points based on problem weights.').''.&mt('Students will see points based on categories.').''.&Apache::lonhtmlcommon::coursepreflink(&mt('Grade display settings'),'grading').'
'); + } + + + $r->print(''); + $r->print('
'); +} + +sub endGradeScreen { + my ($r)=@_; + $r->print('
'); +} + + sub getData { - my ($showPoints)=@_; + my ($showPoints,$uname,$udom)=@_; + + &Apache::lonnet::logthis("About to call with $uname $udom"); # Create the nav map - my $navmap = Apache::lonnavmaps::navmap->new(); + my $navmap = Apache::lonnavmaps::navmap->new($uname,$udom); my $res = $navmap->firstResource(); # temp resource to access constants @@ -332,6 +384,16 @@ sub outputTable { } +# +# Outputting category-based grades. +# + +sub outputCategories { + + my ($r,$showPoints,$notshowTotals, + $navmap,$totalParts,$totalPossible,$totalRight,$totalAttempted,$topLevelParts,$topLevelRight,$topLevelAttempted)=@_; +} + # 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 # return a string ready to show ("#FFC309");