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

bowersj2 lon-capa-cvs@mail.lon-capa.org
Tue, 03 Sep 2002 20:46:30 -0000


bowersj2		Tue Sep  3 16:46:30 2002 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm 
  Log:
  Backed out previous yucky fix to 176, and this should ACTUALLY fix it.
  
  If a network error occurs when grabbing the problem status for the 
  nav map, then make it a neutral gray color and say "status unavailable".
  Also posts an error on the top of the screen saying the network is experiencing
  problems and data may not be available.
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.46 loncom/interface/lonnavmaps.pm:1.47
--- loncom/interface/lonnavmaps.pm:1.46	Mon Sep  2 15:35:31 2002
+++ loncom/interface/lonnavmaps.pm	Tue Sep  3 16:46:30 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.46 2002/09/02 19:35:31 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.47 2002/09/03 20:46:30 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -67,6 +67,10 @@
 my %useropt;
 my %parmhash;
 
+# This parameter keeps track of whether obtaining the user's information
+# failed, which the colorizer in astatus can use
+my $networkFailedFlag = 0;
+
 # ------------------------------------------------------------------ Euclid gcd
 
 sub euclid {
@@ -458,7 +462,7 @@
 	my ($cdom,$cnum)=split(/\_/,$cid);
 
 	my $userprefix=$uname.'_'.$udom.'_';
-
+	
 	unless ($uhome eq 'no_host') { 
 # -------------------------------------------------------------- Get coursedata
 	    unless ((time-$courserdatas{$cid.'.last_cache'})<240) {
@@ -468,6 +472,10 @@
 		    $courserdatas{$cid}=$reply;
 		    $courserdatas{$cid.'.last_cache'}=time;
 		}
+		else
+		{
+		    $networkFailedFlag = 1;
+		}
 	    }
 	    foreach (split(/\&/,$courserdatas{$cid})) {
 		my ($name,$value)=split(/\=/,$_);
@@ -584,6 +592,15 @@
 		($currenturl!~/^\/res\/adm/)) {
 		$r->print('<a href="#curloc">Current Location</a><p>');
 	    }
+
+	    # Handle a network error
+
+	    if ($networkFailedFlag)
+	    {
+		$r->print('<H2>LON-CAPA network failure.</H2>'."\n");
+		$r->print("<p>LON-CAPA's network is having difficulties, some problem" .
+			  " information, such as due dates, will not be available.");
+	    }
 # ----------------------------------------------------- The little content list
 	    for ($i=0;$i<=$#rows;$i++) {
 		if ($rows[$i]) {
@@ -642,19 +659,36 @@
 			    my $tcode=$2;
 			    my $ctext=$3;
 			    $rid=$4;
-			    if ($tcode eq '1') {
+			    
+			    # will open later
+			    if ($tcode eq '1') { 
 				$add='<td bgcolor="#AAAAAA">';
 			    }
+
+			    # solved/correct
 			    if ($code eq '3') {
 				$add='<td bgcolor="#AAFFAA">';
-			    } elsif ($code eq '4') {
+			    } elsif ($code eq '4') { # partially correct
 				$add='<td bgcolor="#E0FFAA">';
 			    } else {
-				$add='<td bgcolor="#CCCCFF">';
-				if ($tcode eq '2') {
+				# not attempted
+				
+				# we end up here on network failure, so pick a neutral
+				# color if the network failed instead of bright red.
+				if ( $networkFailedFlag )
+				{
+				    $add = '<td bgcolor="#AAAAAA">';
+				}
+				else
+				{
+				    $add='<td bgcolor="#FFAAAA">';
+				}
+
+				if ($tcode eq '2') { # open, not past due
 				    $add='<td bgcolor="#FFFFAA">';
 				}
-				if ($tcode eq '4') {
+
+				if ($tcode eq '4') { # due in next 24 hours
 				    $add='<td bgcolor="#FFFF33">';
 				    $adde='</td>';
 				}
@@ -671,6 +705,10 @@
 			    if ($code eq '3') {
 				$hwk='<font color="#229922"><b>';
 				$hwke='</b> ('.$ctext.')</font>';
+			    }
+			    if ($networkFailedFlag) 
+			    {
+				$hwke='</b> (status unavailable)</font>';
 			    }
 			}
 			if ($rid && $hash{'src_'.$rid} eq $currenturl) {