--- rat/lonuserstate.pm 2006/02/28 20:56:40 1.106 +++ rat/lonuserstate.pm 2006/05/11 23:56:27 1.107.2.1 @@ -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.106 2006/02/28 20:56:40 albertel Exp $ +# $Id: lonuserstate.pm,v 1.107.2.1 2006/05/11 23:56:27 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -368,7 +368,11 @@ sub traceroute { } else { $hash{'conditions_'.$rid}=$sofar; } - $newsofar='_'.$rid; + + # if the expression is just the 0th condition keep it + # otherwise leave a pointer to this condition expression + $newsofar = ($sofar eq '0') ? $sofar : '_'.$rid; + if (defined($hash{'is_map_'.$rid})) { if (defined($hash{'map_start_'.$hash{'src_'.$rid}})) { $sofar=$newsofar= @@ -409,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})) { @@ -586,8 +592,14 @@ 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)_)(.*)/) { + &Apache::lonnet::logthis($key); + my ($type, $url) = ($1,$2); + my $value = $hash{$key}; + delete($hash{$key}); + $hash{$type.&putinversion($url)}=$value; } } # ---------------------------------------------------------------- Encrypt URLs