Diff for /rat/lonuserstate.pm between versions 1.78 and 1.80

version 1.78, 2004/05/11 06:28:23 version 1.80, 2004/10/26 15:15:20
Line 335  sub traceroute { Line 335  sub traceroute {
     $sofar=simplify($sofar);      $sofar=simplify($sofar);
     unless ($beenhere=~/\&$rid\&/) {      unless ($beenhere=~/\&$rid\&/) {
        $beenhere.=$rid.'&';           $beenhere.=$rid.'&';  
        if ($hdnflag) {         my ($mapid,$resid)=split(/\./,$rid);
    $hiddenurl{$rid}=1;         my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$hash{'src_'.$rid});
        }         my $encrypt=&Apache::lonnet::EXT('resource.0.hiddenresource',$symb);
        if ($encflag) {         if ($hdnflag || lc($encrypt) eq 'yes') { $hiddenurl{$rid}=1; }
    $encurl{$rid}=1;         my $encrypt=&Apache::lonnet::EXT('resource.0.encrypturl',$symb);
        }         if ($encflag || lc($encrypt) eq 'yes') { $encurl{$rid}=1; }
        if (($retfurl eq '') && ($hash{'src_'.$rid})         if (($retfurl eq '') && ($hash{'src_'.$rid})
         && ($hash{'src_'.$rid}!~/\.sequence$/)) {     && ($hash{'src_'.$rid}!~/\.sequence$/)) {
            my ($mapid,$resid)=split(/\./,$rid);             $retfurl=$hash{'src_'.$rid}.(($hash{'src_'.$rid}=~/\?/)?'&':'?').
            $retfurl=$hash{'src_'.$rid}.         'symb='.$symb;
            (($hash{'src_'.$rid}=~/\?/)?'&':'?').'symb='.  
            &Apache::lonnet::symbclean(  
                            &Apache::lonnet::declutter($hash{'map_id_'.$mapid}).  
                            '___'.$resid.'___'.  
                            &Apache::lonnet::declutter($hash{'src_'.$rid}));  
        }         }
        if (defined($hash{'conditions_'.$rid})) {         if (defined($hash{'conditions_'.$rid})) {
    $hash{'conditions_'.$rid}=simplify(     $hash{'conditions_'.$rid}=simplify(
Line 468  sub accinit { Line 463  sub accinit {
     my $courseuri=$uri;      my $courseuri=$uri;
     $courseuri=~s/^\/res\///;      $courseuri=~s/^\/res\///;
     &Apache::lonnet::delenv('(acc\.|httpref\.)');      &Apache::lonnet::delenv('(acc\.|httpref\.)');
     &Apache::lonnet::appenv(%acchash,      &Apache::lonnet::appenv(%acchash);
                             "request.course.id"  => $short,  
                             "request.course.fn"  => $fn,  
                             "request.course.uri" => $courseuri);   
 }  }
   
 # ---------------- Selectively delete from randompick maps and hidden url parms  # ---------------- Selectively delete from randompick maps and hidden url parms
Line 572  sub readmap { Line 564  sub readmap {
     $hash{'is_map_0.0'}=1;      $hash{'is_map_0.0'}=1;
     loadmap($uri);      loadmap($uri);
     if (defined($hash{'map_start_'.$uri})) {      if (defined($hash{'map_start_'.$uri})) {
    &Apache::lonnet::appenv("request.course.id"  => $short,
    "request.course.fn"  => $fn,
    "request.course.uri" => $uri);
         &traceroute('0',$hash{'map_start_'.$uri},'&');          &traceroute('0',$hash{'map_start_'.$uri},'&');
         &accinit($uri,$short,$fn);          &accinit($uri,$short,$fn);
         &hiddenurls();          &hiddenurls();
Line 622  sub readmap { Line 617  sub readmap {
 # ------------------------------------------------------- Evaluate state string  # ------------------------------------------------------- Evaluate state string
   
 sub evalstate {  sub evalstate {
   
     my $fn=$ENV{'request.course.fn'}.'.state';      my $fn=$ENV{'request.course.fn'}.'.state';
     my $state='2';      my $state='';
     if (-e $fn) {      if (-e $fn) {
        my @conditions=();   my @conditions=();
        {   {
         my $fh=Apache::File->new($fn);      my $fh=Apache::File->new($fn);
         @conditions=<$fh>;      @conditions=<$fh>;
        }     }  
        my $safeeval = new Safe;   my $safeeval = new Safe;
        my $safehole = new Safe::Hole;   my $safehole = new Safe::Hole;
        $safeeval->permit("entereval");   $safeeval->permit("entereval");
        $safeeval->permit(":base_math");   $safeeval->permit(":base_math");
        $safeeval->deny(":base_io");   $safeeval->deny(":base_io");
        $safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT');   $safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT');
        foreach (@conditions) {   foreach my $line (@conditions) {
    my $line=$_;      chomp($line);
            chomp($line);      my ($condition,$weight)=split(/\:/,$line);
    my ($condition,$weight)=split(/\:/,$_);      if ($safeeval->reval($condition)) {
            if ($safeeval->reval($condition)) {   if ($weight eq 'force') {
        if ($weight eq 'force') {      $state.='3';
    $state.='3';   } else {
                } else {      $state.='2';
                    $state.='2';   }
                }      } else {
            } else {   if ($weight eq 'stop') {
                if ($weight eq 'stop') {      $state.='0';
    $state.='0';   } else {
                } else {      $state.='1';
                    $state.='1';   }
                }      }
            }   }
        }  
     }      }
     &Apache::lonnet::appenv('user.state.'.$ENV{'request.course.id'} => $state);      &Apache::lonnet::appenv('user.state.'.$ENV{'request.course.id'} => $state);
     return $state;      return $state;

Removed from v.1.78  
changed lines
  Added in v.1.80


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