--- rat/lonuserstate.pm 2006/02/22 23:44:55 1.103 +++ rat/lonuserstate.pm 2006/02/23 18:08:43 1.104 @@ -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.103 2006/02/22 23:44:55 albertel Exp $ +# $Id: lonuserstate.pm,v 1.104 2006/02/23 18:08:43 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -406,12 +406,11 @@ sub accinit { my %captured=(); my $condcounter=0; $acchash{'acc.cond.'.$short.'.0'}=0; - foreach (keys %hash) { - if ($_=~/^conditions/) { - my $expr=$hash{$_}; - foreach ($expr=~m/(\(\(\d+(?:\&\d+)+\)(?:\|\(\d+(?:\&\d+)+\))+\))/g) { - my $sub=$_; - my $orig=$_; + foreach my $key (keys(%hash)) { + if ($key=~/^conditions/) { + my $expr=$hash{$key}; + 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; @@ -421,17 +420,17 @@ sub accinit { $orig=~s/(\W)/\\$1/g; $expr=~s/$orig/$sub/; } - $hash{$_}=$expr; + $hash{$key}=$expr; unless (defined($captured{$expr})) { $condcounter++; $captured{$expr}=$condcounter; $acchash{'acc.cond.'.$short.'.'.$condcounter}=$expr; } - } elsif ($_=~/^param_(\d+)\.(\d+)/) { + } elsif ($key=~/^param_(\d+)\.(\d+)/) { my $prefix=&Apache::lonnet::encode_symb($hash{'map_id_'.$1},$2, $hash{'src_'.$1.'.'.$2}); - foreach (split(/\&/,$hash{$_})) { - my ($typename,$value)=split(/\=/,$_); + foreach my $param (split(/\&/,$hash{$key})) { + my ($typename,$value)=split(/\=/,$param); my ($type,$name)=split(/\:/,$typename); $parmhash{$prefix.'.'.&Apache::lonnet::unescape($name)}= &Apache::lonnet::unescape($value); @@ -440,10 +439,9 @@ sub accinit { } } } - foreach (keys %hash) { - if ($_=~/^ids/) { - foreach (split(/\,/,$hash{$_})) { - my $resid=$_; + foreach my $key (keys(%hash)) { + if ($key=~/^ids/) { + foreach my $resid (split(/\,/,$hash{$key})) { my $uri=$hash{'src_'.$resid}; my ($uripath,$urifile) = &Apache::lonnet::split_uri_for_cond($uri); @@ -458,8 +456,8 @@ sub accinit { my $replace=$1; my $regexp=$replace; #$regexp=~s/\|/\\\|/g; - $acchash{'acc.res.'.$short.'.'.$uripath} - =~s/\Q$regexp\E/$replace\|$uricond/; + $acchash{'acc.res.'.$short.'.'.$uripath}=~ + s/\Q$regexp\E/$replace\|$uricond/; } else { $acchash{'acc.res.'.$short.'.'.$uripath}.= $urifile.':'.$uricond.'&';