[LON-CAPA-cvs] cvs: rat(version_2_1_X) / lonuserstate.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 11 May 2006 23:56:27 -0000


albertel		Thu May 11 19:56:27 2006 EDT

  Modified files:              (Branch: version_2_1_X)
    /rat	lonuserstate.pm 
  Log:
  - backport 1.109 1.110
  
  
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.107 rat/lonuserstate.pm:1.107.2.1
--- rat/lonuserstate.pm:1.107	Fri Mar  3 17:32:49 2006
+++ rat/lonuserstate.pm	Thu May 11 19:56:27 2006
@@ -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.1 2006/05/11 23:56:27 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -413,16 +413,18 @@
     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,14 @@
 	}
 # ------------------------------------------------------- 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