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

bowersj2 lon-capa-cvs@mail.lon-capa.org
Mon, 08 Sep 2003 19:53:09 -0000


bowersj2		Mon Sep  8 15:53:09 2003 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm 
  Log:
  Go ahead and teach the Navmap system about my "simple status" concept, 
  which I was already using for the icons in the navmap. Now other things 
  can use it too.
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.223 loncom/interface/lonnavmaps.pm:1.224
--- loncom/interface/lonnavmaps.pm:1.223	Wed Sep  3 16:27:08 2003
+++ loncom/interface/lonnavmaps.pm	Mon Sep  8 15:53:09 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.223 2003/09/03 20:27:08 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.224 2003/09/08 19:53:09 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -61,19 +61,14 @@
 # Keep these mappings in sync with lonquickgrades, which uses the colors
 # instead of the icons.
 my %statusIconMap = 
-    ( $resObj->NETWORK_FAILURE    => '',
-      $resObj->NOTHING_SET        => '',
-      $resObj->CORRECT            => 'navmap.correct.gif',
-      $resObj->EXCUSED            => 'navmap.correct.gif',
-      $resObj->PAST_DUE_NO_ANSWER => 'navmap.wrong.gif',
-      $resObj->PAST_DUE_ANSWER_LATER => 'navmap.wrong.gif',
-      $resObj->ANSWER_OPEN        => 'navmap.wrong.gif',
-      $resObj->OPEN_LATER         => '',
-      $resObj->TRIES_LEFT         => 'navmap.open.gif',
-      $resObj->INCORRECT          => 'navmap.wrong.gif',
-      $resObj->OPEN               => 'navmap.open.gif',
-      $resObj->ATTEMPTED          => 'navmap.ellipsis.gif',
-      $resObj->ANSWER_SUBMITTED   => 'navmap.ellipsis.gif' );
+    (
+     $resObj->CLOSED       => '',
+     $resObj->OPEN         => 'navmap.open.gif',
+     $resObj->CORRECT      => 'navmap.correct.gif',
+     $resObj->INCORRECT    => 'navmap.wrong.gif',
+     $resObj->ATTEMPTED    => 'navmap.ellipsis.gif',
+     $resObj->ERROR        => ''
+     );
 
 my %iconAltTags = 
     ( 'navmap.correct.gif' => 'Correct',
@@ -1036,7 +1031,8 @@
 
     if ($resource->is_problem() &&
         !$firstDisplayed) {
-        my $icon = $statusIconMap{$resource->status($part)};
+	
+        my $icon = $statusIconMap{$resource->simpleStatus($part)};
         my $alt = $iconAltTags{$icon};
         if ($icon) {
             $result .= "<td width='30' valign='center' width='50' align='right'>$linkopen<img width='25' height='25' src='/adm/lonIcons/$icon' border='0' alt='$alt' />$linkclose</td>\n";
@@ -3925,6 +3921,64 @@
 
     # Otherwise, it's untried and open
     return OPEN; 
+}
+
+sub CLOSED { return 23; }
+sub ERROR { return 24; }
+
+=pod
+
+B<Simple Status>
+
+Convenience method B<simpleStatus> provides a "simple status" for the resource.
+"Simple status" corresponds to "which icon is shown on the
+Navmaps". There are six "simple" statuses:
+
+=over 4
+
+=item * B<CLOSED>: The problem is currently closed. (No icon shown.)
+
+=item * B<OPEN>: The problem is open and unattempted.
+
+=item * B<CORRECT>: The problem is correct for any reason.
+
+=item * B<INCORRECT>: The problem is incorrect and can still be
+completed successfully.
+
+=item * B<ATTEMPTED>: The problem has been attempted, but the student
+does not know if they are correct. (The ellipsis icon.)
+
+=item * B<ERROR>: There is an error retrieving information about this
+problem.
+
+=back
+
+=cut
+
+# This hash maps the composite status to this simple status, and
+# can be used directly, if you like
+my %compositeToSimple = 
+    (
+      NETWORK_FAILURE()       => ERROR,
+      NOTHING_SET()           => CLOSED,
+      CORRECT()               => CORRECT,
+      EXCUSED()               => CORRECT,
+      PAST_DUE_NO_ANSWER()    => INCORRECT,
+      PAST_DUE_ANSWER_LATER() => INCORRECT,
+      ANSWER_OPEN()           => INCORRECT,
+      OPEN_LATER()            => CLOSED,
+      TRIES_LEFT()            => OPEN,
+      INCORRECT()             => INCORRECT,
+      OPEN()                  => OPEN,
+      ATTEMPTED()             => ATTEMPTED,
+      ANSWER_SUBMITTED()      => ATTEMPTED
+     );
+
+sub simpleStatus {
+    my $self = shift;
+    my $part = shift;
+    my $status = $self->status($part);
+    return $compositeToSimple{$status};
 }
 
 =pod