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

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


stredwic		Thu May 30 09:09:13 2002 EDT

  Modified files:              
    /loncom/interface	lonstatistics.pm 
  Log:
  See bug 480.  Forgot to add the error checking for the lonnet::dump function.
  
  
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.22 loncom/interface/lonstatistics.pm:1.23
--- loncom/interface/lonstatistics.pm:1.22	Wed May 29 13:58:45 2002
+++ loncom/interface/lonstatistics.pm	Thu May 30 09:09:13 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: lonstatistics.pm,v 1.22 2002/05/29 17:58:45 stredwic Exp $
+# $Id: lonstatistics.pm,v 1.23 2002/05/30 13:09:13 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -523,7 +523,7 @@
 	      "\n".'<th> Tries </th>'.
 	      "\n".'</tr>';
     my ($temp)=keys(%result);
-    unless ($temp=~/^error\:/) {
+    unless ($temp=~/^(con_lost|error|no_such_host)/i) {
         foreach my $CurCol (@cols) {
 	    if (!$CurCol){
 		my $Set=&Apache::lonnet::declutter($hash{'map_id_'.$1});
@@ -751,6 +751,10 @@
     $courseid=~s/^(\w)/\/$1/;
 
     my %result=&Apache::lonnet::dump('roles',$udom,$unam);
+    my ($checkForResult)=keys(%result);
+    if ($checkForResult=~/^(con_lost|error|no_such_host)/i) {
+	return -1;
+    }
     foreach my $key (keys (%result)) {
 	my $value=$result{$key};
         if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) {
@@ -803,7 +807,7 @@
     my $SecLimit;
     my $MapLimit;
     my ($temp)=keys(%result);
-    unless ($temp=~/^error\:/) {
+    unless ($temp=~/^(con_lost|error|no_such_host)/i) {
         foreach my $CurCol(@cols) {
 	    ($PrOrd,$ResId)=split(/\:/,$CurCol);
 	    if ( !$CurCol ) { next; }
@@ -1416,34 +1420,40 @@
 #	    foreach my $KeyPoint(sort keys(%students)) {
 
 
-	my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum);
-
 	my $StudNo = 0;
 	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);
-		my $ssec=&usection($sdom,$sname,$cid,$Status);
-		if ($ssec==-1 || $ssec eq 'adm' ) {next;}
-		$ssec=($ssec) ? $ssec : '(none)';
-		#$ssec=(int($ssec)) ? int($ssec) : $ssec;
-		$section{$ssec}=$ssec;
-		if ($CurSec eq 'All Sections' || $ssec eq $CurSec) {
-		    $students[$StudNo]=$name;
-		    $StuBox{$sname}=$sdom;
+
+	my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum);
+
+	my ($checkForError)=keys(%result);
+	if($checkForError=~/^(con_lost|error|no_such_host)/i) {
+	    $r->print('<h1>Could not access course data</h1>');
+	} else {
+	    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);
+		    my $ssec=&usection($sdom,$sname,$cid,$Status);
+		    if ($ssec==-1 || $ssec eq 'adm' ) {next;}
+		    $ssec=($ssec) ? $ssec : '(none)';
+		    #$ssec=(int($ssec)) ? int($ssec) : $ssec;
+		    $section{$ssec}=$ssec;
+		    if ($CurSec eq 'All Sections' || $ssec eq $CurSec) {
+			$students[$StudNo]=$name;
+			$StuBox{$sname}=$sdom;
+		    }
+		    $StudNo++;
 		}
-		$StudNo++;
 	    }
 	}