version 1.43, 2008/10/16 16:35:53
|
version 1.51, 2010/11/29 22:37:26
|
Line 25
|
Line 25
|
# |
# |
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
# Created Nov. 14, 2002 by Jeremy Bowers |
|
|
|
package Apache::lonquickgrades; |
package Apache::lonquickgrades; |
|
|
Line 65 sub real_handler {
|
Line 64 sub real_handler {
|
my $showPoints = |
my $showPoints = |
$env{'course.'.$env{'request.course.id'}.'.grading'} eq 'standard'; |
$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 'external') |
|
|| ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals')); |
|
my $notshowTotals= |
|
$env{'course.'.$env{'request.course.id'}.'.grading'} eq 'externalnototals'; |
|
my $showCategories= |
|
$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 = $showPoints ? "Points Display" : "Completed Problems Display"; |
my $title = "Grading and Statistics";#$showPoints ? "Points Display" : "Completed Problems Display"; |
$r->print(&Apache::loncommon::start_page($title)); |
my $brcrum = [{href=>"/adm/quickgrades",text => "Points Display"}]; |
|
$r->print(&Apache::loncommon::start_page($title,undef, |
|
{'bread_crumbs' => $brcrum}) |
|
); |
|
|
if (!$showPoints && !$notshowSPRSlink ) { |
if (!$showPoints && !$notshowSPRSlink ) { |
$r->print('<p>' |
$r->print('<p>' |
Line 96 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 { |
|
|
# End navmap using boilerplate |
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 $iterator = $navmap->getIterator(undef, undef, undef, 1); |
my $depth = 1; |
my $depth = 1; |
Line 212 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 227 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 / ".&mt('Total').'</td>' |
$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 247 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 256 sub real_handler {
|
Line 279 sub real_handler {
|
|
|
$r->print("$thisIndent$title</td>"); |
$r->print("$thisIndent$title</td>"); |
if ($totalAttempted) { |
if ($totalAttempted) { |
$r->print("<td valign='top'>$thisIndent<nobr>$correct / $attempted / $total</nobr></td>" |
$r->print('<td valign="top">' |
.&Apache::loncommon::end_data_table_row()); |
.$thisIndent |
|
.'<span class="LC_nobreak">' |
|
.$correct.' / '.$attempted.($notshowTotals?'':' / '.$total) |
|
.'</span></td>' |
|
.&Apache::loncommon::end_data_table_row() |
|
); |
} else { |
} else { |
$r->print("<td valign='top'>$thisIndent<nobr>$correct / $total</nobr></td>" |
$r->print('<td valign="top">' |
|
.$thisIndent |
|
.'<span class="LC_nobreak">' |
|
.$correct.($notshowTotals?'':' / '.$total) |
|
.'</span></td>' |
.&Apache::loncommon::end_data_table_row()); |
.&Apache::loncommon::end_data_table_row()); |
} |
} |
} |
} |
Line 279 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; |