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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 23 Feb 2006 18:17:38 -0000


albertel		Thu Feb 23 13:17:38 2006 EDT

  Modified files:              
    /rat	lonuserstate.pm 
  Log:
  - changing the way conditions are stored, no longer are they a complete
    definiton of all of the individual expresssions but now allow the use
    of _<num>.<num> which point to another condition
  - directcondval now understands the existance of these condition pointers,
    looks them up and recurses into docondval to evaluate them
  
  
  
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.104 rat/lonuserstate.pm:1.105
--- rat/lonuserstate.pm:1.104	Thu Feb 23 13:08:43 2006
+++ rat/lonuserstate.pm	Thu Feb 23 13:17:37 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.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 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 @@
 	} 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 @@
 		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 @@
     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 @@
 			    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}.=