--- rat/lonuserstate.pm 2003/10/22 16:10:56 1.61 +++ rat/lonuserstate.pm 2003/10/22 16:52:14 1.62 @@ -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 @@ sub versiontrack { 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 @@ sub putinversion { 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 @@ sub processversionfile { $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 @@ sub loadmap { $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 @@ sub loadmap { $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 @@ sub readmap { %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 @@ sub readmap { &accinit($uri,$short,$fn); &pickrandom(); } -# ------------------------------------------------------------ Version tracking - &processversionfile(%cenv); +# ------------------------------------------------------- Put versions into src foreach (keys %hash) { if ($_=~/^src\_/) { $hash{$_}=&putinversion($hash{$_});