[LON-CAPA-cvs] cvs: loncom /interface lonquickgrades.pm

bowersj2 lon-capa-cvs@mail.lon-capa.org
Wed, 18 Jun 2003 19:31:38 -0000


bowersj2		Wed Jun 18 15:31:38 2003 EDT

  Modified files:              
    /loncom/interface	lonquickgrades.pm 
  Log:
  Correct adds up problems not in the top-level folder (previously only 
  worked as long as the course had no sequences inside of sequences), and 
  changes the formatting such that the student now at least has a *chance* 
  to understand that the upper level courses include the lower level 
  ones...
  
  
Index: loncom/interface/lonquickgrades.pm
diff -u loncom/interface/lonquickgrades.pm:1.14 loncom/interface/lonquickgrades.pm:1.15
--- loncom/interface/lonquickgrades.pm:1.14	Fri Jun 13 15:11:56 2003
+++ loncom/interface/lonquickgrades.pm	Wed Jun 18 15:31:38 2003
@@ -108,6 +108,7 @@
 
     my $totalParts = 0; my $totalPossible = 0; my $totalRight = 0;
     my $now = time();
+    my $topLevelParts = 0; my $topLevelRight = 0;
 
     # Pre-run: Count parts correct
     while ( $depth > 0 ) {
@@ -137,7 +138,13 @@
                     $totalPossible++;
                 }
             }
-            
+
+            if ($depth == 1) { # in top-level only
+		$topLevelParts += scalar(@{$parts});
+		$topLevelRight += $partsRight;
+		$r->print($curRes->compTitle() . '<br>');
+	    }
+
             # Crawl down stack and record parts correct and total
             for my $res (@{$stack}) {
                 if (ref($res) && $res->is_map()) {
@@ -164,9 +171,6 @@
 
     my $indentString = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
 
-    my $unaccountedTotal = $totalParts;
-    my $unaccountedCorrect = $totalRight;
-
     # Second pass: Print the maps.
     $r->print('<table cellspacing="3" border="2"><tr><td align="center"><b>Sequence</b></td>');
     $r->print('<td align="center">Done / Total</td><tr>' . "\n\n");
@@ -180,19 +184,17 @@
             my $correct = $curRes->{DATA}->{CHILD_CORRECT};
             my $total = $curRes->{DATA}->{CHILD_PARTS};
 
-            $unaccountedTotal -= $total;
-            $unaccountedCorrect -= $correct;
-
             if ($total > 0) {
                 my $ratio;
                 $ratio = $correct / $total;
                 my $color = mixColors(\@start, \@end, $ratio);
                 $r->print("<tr><td bgcolor='$color'>");
                 
-                for (my $i = 1; $i < $depth; $i++) { $r->print($indentString); }
+		my $thisIndent = '';
+                for (my $i = 1; $i < $depth; $i++) { $thisIndent .= $indentString; }
                 
-                $r->print("$title</td>");
-                $r->print("<td align='center'>$correct / $total</td></tr>\n");
+                $r->print("$thisIndent$title</td>");
+                $r->print("<td valign='top'>$thisIndent<nobr>$correct / $total</nobr></td></tr>\n");
             }
         }
 
@@ -200,12 +202,12 @@
     }
 
     # If there were any problems at the top level, print an extra "catchall"
-    if ($unaccountedTotal > 0) {
-        my $ratio = $unaccountedCorrect / $unaccountedTotal;
+    if ($topLevelParts > 0) {
+        my $ratio = $topLevelRight / $topLevelParts;
         my $color = mixColors(\@start, \@end, $ratio);
         $r->print("<tr><td bgcolor='$color'>");
-        $r->print("Problems Not Contained In A Folder</td><td align='center'>");
-        $r->print("$unaccountedCorrect / $unaccountedTotal</td></tr>");
+        $r->print("Problems Not Contained In A Folder</td><td>");
+        $r->print("$topLevelRight / $topLevelParts</td></tr>");
     }
 
     my $maxHelpLink = Apache::loncommon::help_open_topic("Quick_Grades_Possibly_Correct");