Diff for /rat/lonuserstate.pm between versions 1.60 and 1.61

version 1.60, 2003/09/19 18:20:35 version 1.61, 2003/10/22 16:10:56
Line 68  my $errtext; # variable with all errors Line 68  my $errtext; # variable with all errors
 my $retfurl; # variable with the very first URL in the course  my $retfurl; # variable with the very first URL in the course
 my %randompick; # randomly picked resources  my %randompick; # randomly picked resources
 my %randompickseed; # optional seed for randomly picking resources  my %randompickseed; # optional seed for randomly picking resources
 my %actualversion; # version of resource as loaded now  
 my %setversion; # forced version of resource  # ----------------------------------- Remove version from URL and store in hash
 my %lastversion; # version when CC came in last  
 my $versionmode; # how versioning is handled in this course  sub versiontrack {
       my $uri=shift;
       if ($uri=~/\.(\d+)\.\w+$/) {
    my $version=$1;
    $uri=~s/\.\d+\.(\w+)$/\.$1/;
           $hash{'version_'.$uri}=$version;
       }
       return $uri;
   }
   
   # -------------------------------------------------------------- Put in version
   
   sub putinversion {
       my $uri=shift;
       if ($hash{'version_'.$uri}) {
    my $version=$hash{'version_'.$uri};
    $uri=~s/\.(\w+)$/\.$version\.$1/;
       }
       return $uri;
   }
   
   # ----------------------------------------- Processing versions file for course
   
   sub processversionfile {
       my %cenv=shift;
       my %versions=&Apache::lonnet::dump('resourceversions',
          $cenv{'domain'},
          $cenv{'num'});
       foreach (keys %versions) {
    if ($_=~/^error\:/) { return; }
    if ($versions{$_} eq 'current') {
       delete $hash{'version_'.$_};
    } else {
       $hash{'version_'.$_}=$versions{$_};
    }
       }
   }
   
 # --------------------------------------------------------- Loads map from disk  # --------------------------------------------------------- Loads map from disk
   
Line 119  sub loadmap { Line 155  sub loadmap {
   
                     $hash{'kind_'.$rid}='res';                      $hash{'kind_'.$rid}='res';
                     $hash{'title_'.$rid}=$token->[2]->{'title'};                      $hash{'title_'.$rid}=$token->[2]->{'title'};
                     my $turi=$token->[2]->{'src'};  # 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;
       }
     &Apache::lonnet::do_cache(\%Apache::lonnet::titlecache,      &Apache::lonnet::do_cache(\%Apache::lonnet::titlecache,
        &Apache::lonnet::symbclean(         &Apache::lonnet::symbclean(
                         &Apache::lonnet::declutter($uri).'___'.                          &Apache::lonnet::declutter($uri).'___'.
Line 494  sub readmap { Line 535  sub readmap {
     $errtext='';      $errtext='';
     $pc=0;      $pc=0;
     my $furi=&Apache::lonnet::clutter($uri);      my $furi=&Apache::lonnet::clutter($uri);
     $hash{'src_0.0'}=$furi;      $hash{'src_0.0'}=&versiontrack($furi);
     $hash{'title_0.0'}=&Apache::lonnet::metadata($uri,'title');      $hash{'title_0.0'}=&Apache::lonnet::metadata($uri,'title');
     $hash{'ids_'.$furi}='0.0';      $hash{'ids_'.$furi}='0.0';
     $hash{'is_map_0.0'}=1;      $hash{'is_map_0.0'}=1;
Line 505  sub readmap { Line 546  sub readmap {
         &pickrandom();          &pickrandom();
     }      }
 # ------------------------------------------------------------ Version tracking  # ------------------------------------------------------------ Version tracking
 #    if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {      &processversionfile(%cenv);
 # &Apache::lonnet::logthis('Will be version tracking');      foreach (keys %hash) {
 #    }   if ($_=~/^src\_/) {
       $hash{$_}=&putinversion($hash{$_});
    }
       }
     unless ((untie(%hash)) && (untie(%parmhash))) {      unless ((untie(%hash)) && (untie(%parmhash))) {
       &Apache::lonnet::logthis("<font color=blue>WARNING: ".        &Apache::lonnet::logthis("<font color=blue>WARNING: ".
                        "Could not untie coursemap $fn for $uri.</font>");                          "Could not untie coursemap $fn for $uri.</font>"); 

Removed from v.1.60  
changed lines
  Added in v.1.61


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>