[LON-CAPA-cvs] cvs: rat / lonuserstate.pm

www lon-capa-cvs@mail.lon-capa.org
Sat, 17 Aug 2002 17:40:06 -0000


www		Sat Aug 17 13:40:06 2002 EDT

  Modified files:              
    /rat	lonuserstate.pm 
  Log:
  Use lonnet standard routine to determine map filenames and read them
  
  
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.36 rat/lonuserstate.pm:1.37
--- rat/lonuserstate.pm:1.36	Tue Jul 30 16:01:40 2002
+++ rat/lonuserstate.pm	Sat Aug 17 13:40:06 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construct and maintain state and binary representation of course for user
 #
-# $Id: lonuserstate.pm,v 1.36 2002/07/30 20:01:40 albertel Exp $
+# $Id: lonuserstate.pm,v 1.37 2002/08/17 17:40:06 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -79,7 +79,10 @@
     $hash{'map_pc_'.$uri}=$lpc;
     $hash{'map_id_'.$lpc}=$uri;
 
-    my $fn='/home/httpd/html'.$uri;
+# Determine and check filename
+    my $fn=&Apache::lonnet::filelocation('',$uri);
+
+    my $ispage=($fn=~/\.page$/);
 
     unless (($fn=~/\.sequence$/) ||
             ($fn=~/\.page$/)) { 
@@ -87,32 +90,12 @@
        return OK; 
     }
 
-    my $ispage=($fn=~/\.page$/);
+    my $instr=&Apache::lonnet::getfile($fn);
 
-    unless (-e $fn) {
-	my $returned=Apache::lonnet::repcopy($fn);
-        unless ($returned eq OK) {
-           $errtext.="Could not import: $fn - ";
-           if ($returned eq HTTP_SERVICE_UNAVAILABLE) {
-	      $errtext.="Server unavailable\n";
-           }
-           if ($returned eq HTTP_NOT_FOUND) {
-	      $errtext.="File not found\n";
-           }
-           if ($returned eq FORBIDDEN) {
-	      $errtext.="Access forbidden\n";
-           }
-           return OK;
-       }
-    }
+    unless ($instr == -1) {
+
+# Successfully got file, parse it
 
-    if (-e $fn) {
-        my @content;
-        {
-	    my $fh=Apache::File->new($fn);
-            @content=<$fh>;
-        }
-        my $instr=join('',@content);
         my $parser = HTML::TokeParser->new(\$instr);
         my $token;