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

stredwic lon-capa-cvs@mail.lon-capa.org
Wed, 29 May 2002 17:58:45 -0000


stredwic		Wed May 29 13:58:45 2002 EDT

  Modified files:              
    /loncom/interface	lonstatistics.pm 
  Log:
  See bug 480.  Updated code to use lonnet::dump and lonnet::get instead of using lonnet::reply to get the information.
  
  
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.21 loncom/interface/lonstatistics.pm:1.22
--- loncom/interface/lonstatistics.pm:1.21	Sun May 26 20:24:05 2002
+++ loncom/interface/lonstatistics.pm	Wed May 29 13:58:45 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: lonstatistics.pm,v 1.21 2002/05/27 00:24:05 minaeibi Exp $
+# $Id: lonstatistics.pm,v 1.22 2002/05/29 17:58:45 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -749,15 +749,14 @@
     my ($udom,$unam,$courseid,$ActiveFlag)=@_;
     $courseid=~s/\_/\//g;
     $courseid=~s/^(\w)/\/$1/;
-    foreach (split(/\&/,&Apache::lonnet::reply('dump:'.
-             $udom.':'.$unam.':roles',
-             &Apache::lonnet::homeserver($unam,$udom)))){
-        my ($key,$value)=split(/\=/,$_);
-        $key=&Apache::lonnet::unescape($key);
+
+    my %result=&Apache::lonnet::dump('roles',$udom,$unam);
+    foreach my $key (keys (%result)) {
+	my $value=$result{$key};
         if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) {
             my $section=$1;
             if ($key eq $courseid.'_st') { $section=''; }
-	    my ($dummy,$end,$start)=split(/\_/,&Apache::lonnet::unescape($value));
+	    my ($dummy,$end,$start)=split(/\_/,$value);
 	    if ( $ActiveFlag ne 'Any' ) {
 		my $now=time;
 		my $notactive=0;
@@ -1401,7 +1400,6 @@
     &GetStatus();
 
     $cid=$ENV{'request.course.id'};
-    my $chome=$ENV{'course.'.$cid.'.home'};
     my ($cdom,$cnum)=split(/\_/,$cid);
 # ----------------------- Get first and last resource, see if there is anything
     $firstres=$hash{'map_start_/res/'.$ENV{'request.course.uri'}};
@@ -1418,44 +1416,37 @@
 #	    foreach my $KeyPoint(sort keys(%students)) {
 
 
-	my $classlst=&Apache::lonnet::reply('dump:'.$cdom.':'.$cnum.':classlist',$chome);
+	my %classlist=&Apache::lonnet::dump('classlist',$cdom,$cnum);
 
 	my $StudNo = 0;
 	my $now=time;
-	unless ($classlst=~/^error\:/) {
-	    foreach my $KeyPoint(sort split(/\&/,$classlst)) {
-		my ($name,$value)=split(/\=/,$KeyPoint);
-		my ($end,$start)=split(/\:/,&Apache::lonnet::unescape($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;
-		    $name=&Apache::lonnet::unescape($name);
-		    $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++;
-	        }
+	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++;
 	    }
 	}
-	else {
-	    $r->print('<h1>Could not access course data</h1>');
-	} 
+
         $r->print("Total number of students : ".($#students+1));
         $r->rflush();
 # --------------- Find all assessments and put them into some linear-like order