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

www lon-capa-cvs@mail.lon-capa.org
Wed, 22 Oct 2003 16:52:14 -0000


www		Wed Oct 22 12:52:14 2003 EDT

  Modified files:              
    /rat	lonuserstate.pm 
  Log:
  At least a few loose ends regarding versioning, unfortunately much more to
  come.
  
  
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.61 rat/lonuserstate.pm:1.62
--- rat/lonuserstate.pm:1.61	Wed Oct 22 12:10:56 2003
+++ rat/lonuserstate.pm	Wed Oct 22 12:52:14 2003
@@ -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.61 2003/10/22 16:10:56 www Exp $
+# $Id: lonuserstate.pm,v 1.62 2003/10/22 16:52:14 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -76,7 +76,9 @@
     if ($uri=~/\.(\d+)\.\w+$/) {
 	my $version=$1;
 	$uri=~s/\.\d+\.(\w+)$/\.$1/;
-        $hash{'version_'.$uri}=$version;
+        unless ($hash{'version_'.$uri}) {
+	    $hash{'version_'.$uri}=$version;
+	}
     }
     return $uri;
 }
@@ -87,6 +89,7 @@
     my $uri=shift;
     if ($hash{'version_'.$uri}) {
 	my $version=$hash{'version_'.$uri};
+	if ($version eq 'current') { return $uri; }
 	$uri=~s/\.(\w+)$/\.$version\.$1/;
     }
     return $uri;
@@ -101,11 +104,7 @@
 				       $cenv{'num'});
     foreach (keys %versions) {
 	if ($_=~/^error\:/) { return; }
-	if ($versions{$_} eq 'current') {
-	    delete $hash{'version_'.$_};
-	} else {
-	    $hash{'version_'.$_}=$versions{$_};
-	}
+	$hash{'version_'.$_}=$versions{$_};
     }
 }
 
@@ -121,7 +120,7 @@
     $hash{'map_id_'.$lpc}=$uri;
 
 # Determine and check filename
-    my $fn=&Apache::lonnet::filelocation('',$uri);
+    my $fn=&Apache::lonnet::filelocation('',&putinversion($uri));
 
     my $ispage=($fn=~/\.page$/);
 
@@ -155,11 +154,11 @@
 
                     $hash{'kind_'.$rid}='res';
                     $hash{'title_'.$rid}=$token->[2]->{'title'};
-# Rip out the version and store it separately
                     my $turi=&versiontrack($token->[2]->{'src'});
-# If there is an explicit version parameter, use that one
                     if ($token->[2]->{'version'}) {
-			$hash{'version_'.$turi}=$1;
+			unless ($hash{'version_'.$turi}) {
+			    $hash{'version_'.$turi}=$1;
+			}
 		    }
 		    &Apache::lonnet::do_cache(\%Apache::lonnet::titlecache,
 		       &Apache::lonnet::symbclean(
@@ -534,6 +533,7 @@
     %parmhash=();
     $errtext='';
     $pc=0;
+    &processversionfile(%cenv);
     my $furi=&Apache::lonnet::clutter($uri);
     $hash{'src_0.0'}=&versiontrack($furi);
     $hash{'title_0.0'}=&Apache::lonnet::metadata($uri,'title');
@@ -545,8 +545,7 @@
         &accinit($uri,$short,$fn);
         &pickrandom();
     }
-# ------------------------------------------------------------ Version tracking
-    &processversionfile(%cenv);
+# ------------------------------------------------------- Put versions into src
     foreach (keys %hash) {
 	if ($_=~/^src\_/) {
 	    $hash{$_}=&putinversion($hash{$_});