Diff for /rat/lonuserstate.pm between versions 1.75 and 1.81

version 1.75, 2004/04/23 19:39:25 version 1.81, 2004/10/26 23:00:11
Line 160  sub loadmap { Line 160  sub loadmap {
                         if ($token->[2]->{'external'} eq 'true') { # external                          if ($token->[2]->{'external'} eq 'true') { # external
                             $turi=~s/^http\:\/\//\/adm\/wrapper\/ext\//;                              $turi=~s/^http\:\/\//\/adm\/wrapper\/ext\//;
                         } elsif ($turi=~/^\/*uploaded\//) { # uploaded                          } elsif ($turi=~/^\/*uploaded\//) { # uploaded
     if (($embstyle eq 'img') || ($embstyle eq 'emb')      if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
                              || ($embstyle eq 'ssi')) {                                  $turi='/adm/wrapper'.$turi;
                                 unless ($turi =~/\.page$/) {      } elsif ($embstyle eq 'ssi') {
                                     $turi='/adm/wrapper'.$turi;   #do nothing with these
                                 }      } elsif ($turi!~/\.(sequence|page)$/) {
                             } elsif ($turi!~/\.(sequence|page)$/) {  
  $turi='/adm/coursedocs/showdoc'.$turi;   $turi='/adm/coursedocs/showdoc'.$turi;
                             }                              }
                         } elsif ($turi=~/\S/) { # normal non-empty internal resource                          } elsif ($turi=~/\S/) { # normal non-empty internal resource
Line 332  sub simplify { Line 331  sub simplify {
 # -------------------------------------------------------- Build condition hash  # -------------------------------------------------------- Build condition hash
   
 sub traceroute {  sub traceroute {
     my ($sofar,$rid,$beenhere)=@_;      my ($sofar,$rid,$beenhere,$encflag,$hdnflag)=@_;
     $sofar=simplify($sofar);      my $newsofar=$sofar=simplify($sofar);
     unless ($beenhere=~/\&$rid\&/) {      unless ($beenhere=~/\&$rid\&/) {
        $beenhere.=$rid.'&';           $beenhere.=$rid.'&';  
          my ($mapid,$resid)=split(/\./,$rid);
          my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$hash{'src_'.$rid});
          my $hidden=&Apache::lonnet::EXT('resource.0.hiddenresource',$symb);
          if ($hdnflag || lc($hidden) eq 'yes') { $hiddenurl{$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 352  sub traceroute { Line 352  sub traceroute {
        } else {         } else {
            $hash{'conditions_'.$rid}=$sofar;             $hash{'conditions_'.$rid}=$sofar;
        }         }
          $newsofar=$hash{'conditions_'.$rid};
        if (defined($hash{'is_map_'.$rid})) {         if (defined($hash{'is_map_'.$rid})) {
            if (defined($hash{'map_start_'.$hash{'src_'.$rid}})) {             if (defined($hash{'map_start_'.$hash{'src_'.$rid}})) {
        &traceroute($sofar,$hash{'map_start_'.$hash{'src_'.$rid}},'&');         $sofar=$newsofar=
                if (defined($hash{'map_finish_'.$hash{'src_'.$rid}})) {     &traceroute($sofar,
    $sofar=         $hash{'map_start_'.$hash{'src_'.$rid}},'&',
                   $hash{'conditions_'.$hash{'map_finish_'.$hash{'src_'.$rid}}};         $encflag || $encurl{$rid},
                }         $hdnflag || $hiddenurl{$rid});
            }             }
        }         }
        if (defined($hash{'to_'.$rid})) {         if (defined($hash{'to_'.$rid})) {
Line 373  sub traceroute { Line 374  sub traceroute {
                                  .$hash{'undercond_'.$_}.'. ';                                   .$hash{'undercond_'.$_}.'. ';
                    }                     }
                 }                  }
                 &traceroute($further,$hash{'goesto_'.$_},$beenhere);                  $newsofar=&traceroute($further,$hash{'goesto_'.$_},$beenhere,
         $encflag,$hdnflag);
           }            }
        }         }
     }      }
       return $newsofar;
 }  }
   
 # ------------------------------ Cascading conditions, quick access, parameters  # ------------------------------ Cascading conditions, quick access, parameters
Line 442  sub accinit { Line 445  sub accinit {
                    /(\&\Q$urifile\E\:[^\&]*)/) {                     /(\&\Q$urifile\E\:[^\&]*)/) {
     my $replace=$1;      my $replace=$1;
                     my $regexp=$replace;                      my $regexp=$replace;
                     $regexp=~s/\|/\\\|/g;                      #$regexp=~s/\|/\\\|/g;
                     $acchash{'acc.res.'.$short.'.'.$uripath}                      $acchash{'acc.res.'.$short.'.'.$uripath}
                      =~s/$regexp/$replace\|$uricond/;                       =~s/\Q$regexp\E/$replace\|$uricond/;
                 } else {                  } else {
    $acchash{'acc.res.'.$short.'.'.$uripath}.=     $acchash{'acc.res.'.$short.'.'.$uripath}.=
                      $urifile.':'.$uricond.'&';                       $urifile.':'.$uricond.'&';
Line 461  sub accinit { Line 464  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 565  sub readmap { Line 565  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 615  sub readmap { Line 618  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.75  
changed lines
  Added in v.1.81


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.