--- rat/lonuserstate.pm 2006/03/03 22:32:49 1.107 +++ rat/lonuserstate.pm 2006/05/12 15:28:50 1.107.2.3 @@ -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.107 2006/03/03 22:32:49 albertel Exp $ +# $Id: lonuserstate.pm,v 1.107.2.3 2006/05/12 15:28:50 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -413,16 +413,18 @@ sub accinit { foreach my $key (keys(%hash)) { if ($key=~/^conditions/) { my $expr=$hash{$key}; + # try to find and factor out common sub-expressions foreach my $sub ($expr=~m/(\(\([_\.\d]+(?:\&[_\.\d]+)+\)(?:\|\([_\.\d]+(?:\&[_\.\d]+)+\))+\))/g) { my $orig=$sub; - $sub=~/\(\(([_\.\d]+\&(:?[_\.\d]+\&)*)(?:[_\.\d]+\&*)+\)(?:\|\(\1(?:[_\.\d]+\&*)+\))+\)/; - my $factor=$1; - $sub=~s/$factor//g; + + my ($factor) = ($sub=~/\(\(([_\.\d]+\&(:?[_\.\d]+\&)*)(?:[_\.\d]+\&*)+\)(?:\|\(\1(?:[_\.\d]+\&*)+\))+\)/); + next if (!defined($factor)); + + $sub=~s/\Q$factor\E//g; $sub=~s/^\(/\($factor\(/; $sub.=')'; $sub=simplify($sub); - $orig=~s/(\W)/\\$1/g; - $expr=~s/$orig/$sub/; + $expr=~s/\Q$orig\E/$sub/; } $hash{$key}=$expr; unless (defined($captured{$expr})) { @@ -590,8 +592,12 @@ sub readmap { } # ------------------------------------------------------- Put versions into src foreach my $key (keys(%hash)) { - if ($key=~/^src\_/) { + if ($key=~/^src_/) { $hash{$key}=&putinversion($hash{$key}); + } elsif ($key =~ /^(map_(?:start|finish|pc)_)(.*)/) { + my ($type, $url) = ($1,$2); + my $value = $hash{$key}; + $hash{$type.&putinversion($url)}=$value; } } # ---------------------------------------------------------------- Encrypt URLs