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

stredwic lon-capa-cvs@mail.lon-capa.org
Thu, 30 May 2002 13:08:34 -0000


stredwic		Thu May 30 09:08:34 2002 EDT

  Modified files:              
    /loncom/interface	lonchart.pm 
  Log:
  See bug 480.  Forgot the error checking with the new lonnet::dump function.
  
  
Index: loncom/interface/lonchart.pm
diff -u loncom/interface/lonchart.pm:1.39 loncom/interface/lonchart.pm:1.40
--- loncom/interface/lonchart.pm:1.39	Wed May 29 13:57:52 2002
+++ loncom/interface/lonchart.pm	Thu May 30 09:08:34 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: lonchart.pm,v 1.39 2002/05/29 17:57:52 stredwic Exp $
+# $Id: lonchart.pm,v 1.40 2002/05/30 13:08:34 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -85,6 +85,14 @@
             substr($rowlabels[$index].
             '                                                        ',0,45).' ! ';
 
+    my($checkForError)=keys (%result);
+    if($checkForError =~ /^(con_lost|error|no_such_host)/i) {
+	my $PrTot = sprintf( "%5d", $ProbTotal );
+	my $PrSvd = sprintf( "%5d", $ProbSolved );
+	$Str .= ' '.'<font color="#000088">'.$PrSvd.'  /'.$PrTot.'</font> ';
+	return $Str;
+    }
+
     $ProbNo = 0;
     $ProbTotal = 0;
     $ProbSolved = 0;
@@ -229,6 +237,12 @@
     $courseid=~s/^(\w)/\/$1/;
 
     my %result=&Apache::lonnet::dump('roles',$udom,$unam);
+
+    my($checkForError)=keys (%result);
+    if($checkForError =~ /^(con_lost|error|no_such_host)/i) {
+	return -1;
+    }
+
     foreach my $key (keys (%result)) {
 	my $value = $result{$key};
         if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) {
@@ -267,44 +281,52 @@
         my ($cdom,$cnum)=split(/\_/,$cid);
 # ---------------------------------------------- Read class list and row labels
 	my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum);
-	my $now=time;
-	foreach my $name (keys (%classlist)) {
-	    my $value=$classlist{$name};
-	    my ($end,$start)=split(/\:/,$value);
-	    my $active=1;
-	    my $Status=$ENV{'form.status'};
-	    $Status = ($Status) ? $Status : 'Active';
-	    if ( ( ($end) && $now > $end ) && 
-		 ( ($Status eq 'Active') ) ) { $active=0; }
-	    if ( ($Status eq 'Expired') && 
-		 ($end == 0 || $now < $end) ) { $active=0; }
-	    if ($active) {
-		my $thisindex=$#students+1;
-		$students[$thisindex]=$name;
-		my ($sname,$sdom)=split(/\:/,$name);
-		$PreCol[$thisindex]=$sname.':';
-		my $ssec=&usection($sdom,$sname,$cid,$Status);
-		if ($ssec==-1) {
-		    $rowlabels[$thisindex]=
-			'Data not available: '.$name;
-		} else {
-		    my %reply=&Apache::lonnet::idrget($sdom,$sname);
-		    my $reply=&Apache::lonnet::get('environment',
-			['lastname','generation','firstname','middlename'],
-			$sdom,$sname);
-		    #$ssec=(int($ssec)) ? int($ssec) : $ssec;
-		    my $sec=sprintf('%3s',$ssec);
-		    $rowlabels[$thisindex]=$sec.' '.$reply{$sname}.' ';
-		    $PreCol[$thisindex] .= $reply.':'.$sec;
-		    my $i=0;
-		    foreach (split(/\&/,$reply)) {
-			$i++;
-			if ( $_ ne '') {
-			    $rowlabels[$thisindex].=&Apache::lonnet::unescape($_).' ';
-			}
-			if ($i == 2) {
-			    chop($rowlabels[$thisindex]);
-			    $rowlabels[$thisindex].=', ';
+
+	my($checkForError)=keys (%classlist);
+	if($checkForError =~ /^(con_lost|error|no_such_host)/i) {
+	    $r->print('<h1>Could not access course data</h1>');
+	} else {
+	    my $now=time;
+	    foreach my $name (keys (%classlist)) {
+		my $value=$classlist{$name};
+		my ($end,$start)=split(/\:/,$value);
+		my $active=1;
+		my $Status=$ENV{'form.status'};
+		$Status = ($Status) ? $Status : 'Active';
+		if ( ( ($end) && $now > $end ) && 
+		     ( ($Status eq 'Active') ) ) { $active=0; }
+		if ( ($Status eq 'Expired') && 
+		     ($end == 0 || $now < $end) ) { $active=0; }
+		if ($active) {
+		    my $thisindex=$#students+1;
+		    $students[$thisindex]=$name;
+		    my ($sname,$sdom)=split(/\:/,$name);
+		    $PreCol[$thisindex]=$sname.':';
+		    my $ssec=&usection($sdom,$sname,$cid,$Status);
+		    if ($ssec==-1) {
+			$rowlabels[$thisindex]=
+			    'Data not available: '.$name;
+		    } else {
+			my %reply=&Apache::lonnet::idrget($sdom,$sname);
+			my $reply=&Apache::lonnet::get('environment',
+						       ['lastname','generation'
+						       ,'firstname'
+						       ,'middlename'],
+						       $sdom,$sname);
+			#$ssec=(int($ssec)) ? int($ssec) : $ssec;
+			my $sec=sprintf('%3s',$ssec);
+			$rowlabels[$thisindex]=$sec.' '.$reply{$sname}.' ';
+			$PreCol[$thisindex] .= $reply.':'.$sec;
+			my $i=0;
+			foreach (split(/\&/,$reply)) {
+			    $i++;
+			    if ( $_ ne '') {
+				$rowlabels[$thisindex].=&Apache::lonnet::unescape($_).' ';
+			    }
+			    if ($i == 2) {
+				chop($rowlabels[$thisindex]);
+				$rowlabels[$thisindex].=', ';
+			    }
 			}
 		    }
 		}