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

bowersj2 lon-capa-cvs@mail.lon-capa.org
Tue, 19 Nov 2002 21:11:25 -0000


bowersj2		Tue Nov 19 16:11:25 2002 EDT

  Modified files:              
    /loncom/interface	lonquickgrades.pm 
  Log:
  Now with Extra Color, and not in a table, either. It's still not quite right
  though, but we can work on it.
  
  
Index: loncom/interface/lonquickgrades.pm
diff -u loncom/interface/lonquickgrades.pm:1.3 loncom/interface/lonquickgrades.pm:1.4
--- loncom/interface/lonquickgrades.pm:1.3	Fri Nov 15 15:08:18 2002
+++ loncom/interface/lonquickgrades.pm	Tue Nov 19 16:11:25 2002
@@ -62,6 +62,29 @@
                         $ENV{"request.course.fn"}.".db",
                         $ENV{"request.course.fn"}."_parms.db", 1, 0);
 
+    # Keep this hash in sync with %statusIconMap in lonnavmaps; they
+    # should match color/icon
+    my $res = $navmap->firstResource(); # temp resource to access constants
+
+    my $green = "#AAFFAA";
+    my $red = "#FFAAAA";
+    my $yellow = "#FFFFAA";
+    my $orange = "#FFBB88";
+    my $neutral = "";
+    my %statusColorMap = 
+        ( $res->NETWORK_FAILURE    => $neutral,
+          $res->NOTHING_SET        => $neutral,
+          $res->CORRECT            => $green,
+          $res->EXCUSED            => $green,
+          $res->PAST_DUE_NO_ANSWER => $orange,
+          $res->PAST_DUE_ANSWER_LATER => $orange,
+          $res->ANSWER_OPEN        => $orange,
+          $res->OPEN_LATER         => $neutral,
+          $res->TRIES_LEFT         => $neutral,
+          $res->INCORRECT          => $orange,
+          $res->OPEN               => $yellow,
+          $res->ATTEMPTED          => $yellow );
+    
     if (!defined($navmap)) {
         my $requrl = $r->uri;
         $ENV{'user.error.msg'} = "$requrl:bre:0:0:Course not initialized";
@@ -76,21 +99,15 @@
 
     # End navmap using boilerplate
 
-    # Col labels
-    $r->print(<<TABLETOP);
-<table border="1" cellpadding="3" cellspacing="0">
-  <tr>
-    <td align="center"><b>Problem</b></td>
-    <td align="center"><b>Score</b></td>
-  </tr>
-TABLETOP
-
     my $iterator = $navmap->getIterator(undef, undef, undef, 1);
     my $depth = 1;
     $iterator->next(); # ignore first BEGIN_MAP
     my $curRes = $iterator->next();
-    my $totalAvailable = 0;
-    my $total = 0;
+    my $totalParts = 0;
+    my $totalRight = 0;
+    my $totalCurrentlyPossible = 0;
+    
+    $r->print("<div width=\"50%\">\n"); # use this to format the col
    
     while ( $depth > 0 ) {
         if ($curRes == $iterator->BEGIN_MAP()) {$depth++;}
@@ -98,7 +115,6 @@
 
         if (ref($curRes) && $curRes->is_problem()) {
             my $title = $curRes->compTitle();
-            $r->print('    <tr>');
             my $stack = $iterator->getStack();
             my $src = Apache::lonnavmaps::getLinkForResource($stack);
             my $srcHasQuestion = $src =~ /\?/;
@@ -106,29 +122,39 @@
                 ($srcHasQuestion?'&':'?') .
                 'symb='.&Apache::lonnet::escape($curRes->symb()).
                 '"';
-            $r->print("<td><a href=\"$link\">$title</td>");
-            
-            my $avail = 0;
-            my $score = 0;
             my $parts = $curRes->parts();
+            my $multipart = scalar(@{$parts}) > 1;
+
             for my $part (@{$parts}) {
-                my $partAvail = $curRes->weight($part);
-                my $partScore = $curRes->awarded($part) * $partAvail;
-                $avail += $partAvail;
-                $score += $partScore;
+                if ($multipart && $part eq '0') { next; }
+                $totalParts++;
+
+                my $status = $curRes->status($part);
+                my $color = $statusColorMap{$status};
+                if ($color eq $green) { # I'm being bad here... ;-)
+                    $totalRight++; $totalCurrentlyPossible++;
+                }
+                if ($color eq $yellow || $color eq $orange) {
+                    $totalCurrentlyPossible++;
+                }
+
+                $r->print("<div style=\"background-color: $color\" width=\"100%\">" .
+                          "<nobr><a href=\"$link\">$title" . 
+                          ($multipart ? ', ' . $part : '') . '</a></nobr></div>'
+                          ."\n");
+
+                if (!($totalParts % 20)) { $r->rflush(); }
             }
-            
-            $r->print("<td align=\"right\">$score / $avail</td></tr>\n");
-            $totalAvailable += $avail;
-            $total += $score;
         }
 
         $curRes = $iterator->next();
     }
 
-    $r->print("<td colspan=\"2\" align=\"right\">Total Points Scored: <b>$total</b>");
-    $r->print("<br />Total Points Available: <b>$totalAvailable</b>");
-    $r->print("</td></tr></table>\n\n");
+    $r->print("<br><hr>\n");
+    $r->print("<div width=\"100%\" align=\"right\">");
+    $r->print("Total Parts Correct: <b>$totalRight</b><br>");
+    $r->print("Number Of Parts Possibly Correct: <b>$totalCurrentlyPossible</b><br>");
+    $r->print("Total Parts In Course: <b>$totalParts</b></div></div>\n\n");
 
     $r->print("</body></html>");