Diff for /rat/lonuserstate.pm between versions 1.4 and 1.7

version 1.4, 2000/08/22 15:26:28 version 1.7, 2000/09/04 11:28:04
Line 10 Line 10
 # 7/1 Gerd Kortemeyer)  # 7/1 Gerd Kortemeyer)
 # 7/1,7/3,7/4,7/7,7/8,7/10 Gerd Kortemeyer)  # 7/1,7/3,7/4,7/7,7/8,7/10 Gerd Kortemeyer)
 #  #
 # 7/15,7/17,7/18,8/1,8/2,8/4,8/5,8/21,8/22 Gerd Kortemeyer  # 7/15,7/17,7/18,8/1,8/2,8/4,8/5,8/21,8/22,8/23,8/30,9/2,9/4 Gerd Kortemeyer
   
 package Apache::lonuserstate;  package Apache::lonuserstate;
   
Line 179  sub loadmap { Line 179  sub loadmap {
   
 sub simplify {  sub simplify {
    my $expression=shift;     my $expression=shift;
 # "True and" is nothing   
    $expression=~s/0\&//g;  
 # (8)=8  # (8)=8
    $expression=~s/\((\d+)\)/$1/g;     $expression=~s/\((\d+)\)/$1/g;
 # 8&8=8  # 8&8=8
    $expression=~s/(\d+)\&\1/$1/g;     $expression=~s/(\D)(\d+)\&\2(\D)/$1$2$3/g;
 # 8|8=8  # 8|8=8
    $expression=~s/(\d+)\|\1/$1/g;     $expression=~s/(\D)(\d+)\|\2(\D)/$1$2$3/g;
 # (5&3)&4=5&3&4  # (5&3)&4=5&3&4
    $expression=~s/\((\d+)\&(\d+)\)\&(\d+)/$1\&$2\&$3/g;     $expression=~s/\((\d+)((?:\&\d+)+)\)\&(\d+\D)/$1$2\&$3/g;
 # (((5&3)|(4&6)))=((5&3)|(4&6))  # (((5&3)|(4&6)))=((5&3)|(4&6))
    $expression=~     $expression=~
        s/\((\(\(\d+(?:\&\d+)*\)(?:\|\(\d+(?:\&\d+)*\))+\))\)/$1/g;         s/\((\(\(\d+(?:\&\d+)*\)(?:\|\(\d+(?:\&\d+)*\))+\))\)/$1/g;
Line 245  sub accinit { Line 243  sub accinit {
     my %acchash=();      my %acchash=();
     my %captured=();      my %captured=();
     my $condcounter=0;      my $condcounter=0;
     $acchash{'acc.cond.0'}='0';      $acchash{'acc.cond.'.$short.'.0'}=0;
     map {      map {
        if ($_=~/^conditions/) {         if ($_=~/^conditions/) {
   my $expr=$hash{$_};    my $expr=$hash{$_};
           map {            map {
              my $sub=$_;               my $sub=$_;
              my $orig=$_;               my $orig=$_;
              $sub=~/\(\((\d+(:?\&\d+)*)(?:\&\d+)+\)(?:\|\(\1(?:\&\d+)+\))+\)/;               $sub=~/\(\((\d+\&(:?\d+\&)*)(?:\d+\&*)+\)(?:\|\(\1(?:\d+\&*)+\))+\)/;
              my $factor=$1;               my $factor=$1;
              $sub=~s/$factor\&//g;               $sub=~s/$factor//g;
              $sub=~s/^\(/\($factor\&\(/;               $sub=~s/^\(/\($factor\(/;
      $sub.=')';       $sub.=')';
              $sub=simplify($sub);               $sub=simplify($sub);
              $orig=~s/(\W)/\\$1/g;               $orig=~s/(\W)/\\$1/g;
      $expr=~s/$orig/$sub/;        $expr=~s/$orig/$sub/;
   } ($expr=~m/(\(\(\d+(?:\&\d+)+\)(?:\|\(\d+(?:\&\d+)+\))+\))/g);    } ($expr=~m/(\(\(\d+(?:\&\d+)+\)(?:\|\(\d+(?:\&\d+)+\))+\))/g);
           $hash{$_}=$expr;            $hash{$_}=$expr;
           unless (defined($captured{$expr})) {            unless (defined($captured{$expr})) {
       $condcounter++;        $condcounter++;
               $captured{$expr}=$condcounter;                $captured{$expr}=$condcounter;
               $acchash{'acc.cond.'.$condcounter}=$expr;                $acchash{'acc.cond.'.$short.'.'.$condcounter}=$expr;
           }             } 
         }          }
     } keys %hash;      } keys %hash;
Line 282  sub accinit { Line 280  sub accinit {
             } else {              } else {
                 $urifile.=':0';                  $urifile.=':0';
             }              }
             if (defined($acchash{'acc.res.'.$uripath})) {              if (defined($acchash{'acc.res.'.$short.'.'.$uripath})) {
  $acchash{'acc.res.'.$uripath}.=$urifile.'&';   $acchash{'acc.res.'.$short.'.'.$uripath}.=$urifile.'&';
             } else {              } else {
                 $acchash{'acc.res.'.$uripath}='&'.$urifile.'&';                  $acchash{'acc.res.'.$short.'.'.$uripath}='&'.$urifile.'&';
             }              }
         }          }
     } keys %hash;      } keys %hash;
Line 322  sub readmap { Line 320  sub readmap {
      if ($cfh=Apache::File->new(">$fn.state")) {       if ($cfh=Apache::File->new(">$fn.state")) {
         print $cfh join("\n",@cond);          print $cfh join("\n",@cond);
      } else {       } else {
       &Apache::lonnet::logthis("<font color=blie>WARNING: ".        &Apache::lonnet::logthis("<font color=blue>WARNING: ".
                        "Could not write statemap $fn for $uri.</font>");                          "Could not write statemap $fn for $uri.</font>"); 
      }       }
     }        }  
    } else {     } else {
       &Apache::lonnet::logthis("<font color=blie>WARNING: ".        &Apache::lonnet::logthis("<font color=blue>WARNING: ".
                        "Could not tie coursemap $fn for $uri.</font>");                          "Could not tie coursemap $fn for $uri.</font>"); 
    }     }
    return $errtext;     return $errtext;

Removed from v.1.4  
changed lines
  Added in v.1.7


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