--- rat/lonuserstate.pm 2006/02/23 18:08:43 1.104 +++ rat/lonuserstate.pm 2006/02/23 18:17:37 1.105 @@ -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.104 2006/02/23 18:08:43 albertel Exp $ +# $Id: lonuserstate.pm,v 1.105 2006/02/23 18:17:37 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -319,21 +319,21 @@ sub loadmap { sub simplify { my $expression=shift; # (0&1) = 1 - $expression=~s/\(0\&(\d+)\)/$1/g; + $expression=~s/\(0\&([_\.\d]+)\)/$1/g; # (8)=8 - $expression=~s/\((\d+)\)/$1/g; + $expression=~s/\(([_\.\d]+)\)/$1/g; # 8&8=8 - $expression=~s/(\D)(\d+)\&\2(\D)/$1$2$3/g; + $expression=~s/([^_\.\d])([_\.\d]+)\&\2([^_\.\d])/$1$2$3/g; # 8|8=8 - $expression=~s/(\D)(\d+)\|\2(\D)/$1$2$3/g; + $expression=~s/([^_\.\d])([_\.\d]+)\|\2([^_\.\d])/$1$2$3/g; # (5&3)&4=5&3&4 - $expression=~s/\((\d+)((?:\&\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)) -# $expression=~ -# s/\((\(\(\d+(?:\&\d+)*\)(?:\|\(\d+(?:\&\d+)*\))+\))\)/$1/g; + $expression=~ + s/\((\(\([_\.\d]+(?:\&[_\.\d]+)*\)(?:\|\([_\.\d]+(?:\&[_\.\d]+)*\))+\))\)/$1/g; # ((5&3)|(4&6))|(1&2)=(5&3)|(4&6)|(1&2) $expression=~ - s/\((\(\d+(?:\&\d+)*\))((?:\|\(\d+(?:\&\d+)*\))+)\)\|(\(\d+(?:\&\d+)*\))/\($1$2\|$3\)/g; + s/\((\([_\.\d]+(?:\&[_\.\d]+)*\))((?:\|\([_\.\d]+(?:\&[_\.\d]+)*\))+)\)\|(\([_\.\d]+(?:\&[_\.\d]+)*\))/\($1$2\|$3\)/g; return $expression; } @@ -368,7 +368,7 @@ sub traceroute { } else { $hash{'conditions_'.$rid}=$sofar; } - $newsofar=$hash{'conditions_'.$rid}; + $newsofar='_'.$rid; if (defined($hash{'is_map_'.$rid})) { if (defined($hash{'map_start_'.$hash{'src_'.$rid}})) { $sofar=$newsofar= @@ -383,7 +383,7 @@ sub traceroute { my $further=$sofar; if ($hash{'undercond_'.$_}) { if (defined($hash{'condid_'.$hash{'undercond_'.$_}})) { - $further=simplify('('.$further.')&('. + $further=simplify('('.'_'.$rid.')&('. $hash{'condid_'.$hash{'undercond_'.$_}}.')'); } else { $errtext.='Undefined condition ID: ' @@ -409,9 +409,9 @@ sub accinit { foreach my $key (keys(%hash)) { if ($key=~/^conditions/) { my $expr=$hash{$key}; - foreach my $sub ($expr=~m/(\(\(\d+(?:\&\d+)+\)(?:\|\(\d+(?:\&\d+)+\))+\))/g) { + foreach my $sub ($expr=~m/(\(\([_\.\d]+(?:\&[_\.\d]+)+\)(?:\|\([_\.\d]+(?:\&[_\.\d]+)+\))+\))/g) { my $orig=$sub; - $sub=~/\(\((\d+\&(:?\d+\&)*)(?:\d+\&*)+\)(?:\|\(\1(?:\d+\&*)+\))+\)/; + $sub=~/\(\(([_\.\d]+\&(:?[_\.\d]+\&)*)(?:[_\.\d]+\&*)+\)(?:\|\(\1(?:[_\.\d]+\&*)+\))+\)/; my $factor=$1; $sub=~s/$factor//g; $sub=~s/^\(/\($factor\(/; @@ -456,7 +456,7 @@ sub accinit { my $replace=$1; my $regexp=$replace; #$regexp=~s/\|/\\\|/g; - $acchash{'acc.res.'.$short.'.'.$uripath}=~ + $acchash{'acc.res.'.$short.'.'.$uripath} =~ s/\Q$regexp\E/$replace\|$uricond/; } else { $acchash{'acc.res.'.$short.'.'.$uripath}.=