--- loncom/interface/lonquickgrades.pm 2003/09/22 21:05:15 1.27 +++ loncom/interface/lonquickgrades.pm 2005/01/03 14:46:41 1.35 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Quick Student Grades Display # -# $Id: lonquickgrades.pm,v 1.27 2003/09/22 21:05:15 bowersj2 Exp $ +# $Id: lonquickgrades.pm,v 1.35 2005/01/03 14:46:41 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -67,6 +67,8 @@ sub real_handler { my $showPoints = $ENV{'course.'.$ENV{'request.course.id'}.'.grading'} eq 'standard'; + my $notshowSPRSlink = + $ENV{'course.'.$ENV{'request.course.id'}.'.grading'} eq 'external'; # Create the nav map my $navmap = Apache::lonnavmaps::navmap->new(); @@ -82,10 +84,10 @@ sub real_handler { my $res = $navmap->firstResource(); # temp resource to access constants # Header - my $title = $showPoints ? "Quick Points Display" : "Quick Completed Problems Display"; + my $title = $showPoints ? "Points Display" : "Completed Problems Display"; $r->print(&Apache::loncommon::bodytag($title, '', '')); - if (!$showPoints) { + if (!$showPoints && !$notshowSPRSlink ) { $r->print(<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 a detailed @@ -117,8 +119,9 @@ HEADER # equally for both cases. my $totalParts = 0; my $totalPossible = 0; my $totalRight = 0; + my $totalAttempted = 0; my $now = time(); - my $topLevelParts = 0; my $topLevelRight = 0; + my $topLevelParts = 0; my $topLevelRight = 0; my $topLevelAttempted = 0; # Pre-run: Count parts correct while ( $depth > 0 ) { @@ -131,14 +134,30 @@ HEADER my $parts = $curRes->parts(); my $partsRight = 0; my $partsCount = 0; + my $partsAttempted = 0; my $stack = $iterator->getStack(); for my $part (@{$parts}) { - if ($curRes->getCompletionStatus($part) == $curRes->EXCUSED()) { + my $completionStatus = $curRes->getCompletionStatus($part); + my $dateStatus = $curRes->getDateStatus($part); + + if ($completionStatus == $curRes->EXCUSED()) { next; } if ($showPoints) { - my $score = $curRes->weight($part) * $curRes->awarded($part); + my $score = 0; + # If we're not telling status and the answer date isn't passed yet, + # it's an "attempted" point + if ($curRes->problemstatus($part) eq 'no' && + ($dateStatus != $curRes->ANSWER_OPEN)) { + my $status = $curRes->simpleStatus($part); + if ($status == $curRes->ATTEMPTED) { + $partsAttempted += $curRes->weight($part); + $totalAttempted += $partsAttempted; + } + } else { + $score = $curRes->weight($part) * $curRes->awarded($part); + } $partsRight += $score; $totalRight += $score; $partsCount += $curRes->weight($part); @@ -151,13 +170,16 @@ HEADER my $status = $curRes->simpleStatus($part); my $thisright = 0; $partsCount++; - if ($status == $curRes->CORRECT || - $status == $curRes->INCORRECT || - $status == $curRes->ATTEMPTED) { + if ($status == $curRes->CORRECT ) { $partsRight++; $totalRight++; $thisright = 1; } + + if ($status == $curRes->ATTEMPTED) { + $partsAttempted++; + $totalAttempted++; + } my $dateStatus = $curRes->getDateStatus($part); $totalParts++; @@ -170,6 +192,7 @@ HEADER if ($depth == 1) { # in top-level only $topLevelParts += $partsCount; $topLevelRight += $partsRight; + $topLevelAttempted += $partsAttempted; } # Crawl down stack and record parts correct and total @@ -178,10 +201,12 @@ HEADER if (!defined($res->{DATA}->{CHILD_PARTS})) { $res->{DATA}->{CHILD_PARTS} = 0; $res->{DATA}->{CHILD_CORRECT} = 0; + $res->{DATA}->{CHILD_ATTEMPTED} = 0; } $res->{DATA}->{CHILD_PARTS} += $partsCount; $res->{DATA}->{CHILD_CORRECT} += $partsRight; + $res->{DATA}->{CHILD_ATTEMPTED} += $partsAttempted; } } } @@ -199,9 +224,14 @@ HEADER my $indentString = '     '; # Second pass: Print the maps. - $r->print(''); - $title =&mt($showPoints ? "Points Scored" : "Done"); - $r->print("" . "\n\n"); + $r->print('
Folder$title / Total
'); + $title = &mt($showPoints ? "Points Scored" : "Done"); + if ($totalAttempted) { + $title .= " / " . &mt("Attempted"); + } + $r->print("\n\n"); while ($depth > 0) { if ($curRes == $iterator->BEGIN_MAP()) {$depth++;} if ($curRes == $iterator->END_MAP()) { $depth--; } @@ -211,6 +241,7 @@ HEADER my $correct = $curRes->{DATA}->{CHILD_CORRECT}; my $total = $curRes->{DATA}->{CHILD_PARTS}; + my $attempted = $curRes->{DATA}->{CHILD_ATTEMPTED}; if ($total > 0) { my $ratio; @@ -222,7 +253,11 @@ HEADER for (my $i = 1; $i < $depth; $i++) { $thisIndent .= $indentString; } $r->print("$thisIndent$title"); - $r->print("\n"); + if ($totalAttempted) { + $r->print("\n"); + } else { + $r->print("\n"); + } } } @@ -238,20 +273,19 @@ HEADER $r->print("$topLevelRight / $topLevelParts"); } - my $maxHelpLink = Apache::loncommon::help_open_topic("Quick_Grades_Possibly_Correct"); - - $title = $showPoints ? "Points" : "Parts Done"; - - $r->print("\n\n"); + if ($showPoints) { + my $maxHelpLink = Apache::loncommon::help_open_topic("Quick_Grades_Possibly_Correct"); + $title = $showPoints ? "Points" : "Parts Done"; + + $r->print("\n\n"); + } $r->print("
' . + &mt('Folder') . '$title / " + . &mt('Total') . "
$thisIndent$correct / $total
$thisIndent$correct / $attempted / $total
$thisIndent$correct / $total
Total $title: $totalRight
"); - $r->print(&mt("Max Possible To Date")." $maxHelpLink: $totalPossible
"); - $title = $showPoints ? "Points" : "Parts"; - $r->print(&mt("Total $title In Course").": $totalParts
Total $title: $totalRight
"); + $r->print(&mt("Max Possible To Date")." $maxHelpLink: $totalPossible
"); + $title = $showPoints ? "Points" : "Parts"; + $r->print(&mt("Total $title In Course").": $totalParts
"); - $navmap->untieHashes(); - return OK; }