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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 26 Oct 2004 15:15:23 -0000


albertel		Tue Oct 26 11:15:23 2004 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
    /rat	lonuserstate.pm 
  Log:
  - map conditions work
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.552 loncom/lonnet/perl/lonnet.pm:1.553
--- loncom/lonnet/perl/lonnet.pm:1.552	Tue Oct 26 11:03:08 2004
+++ loncom/lonnet/perl/lonnet.pm	Tue Oct 26 11:15:18 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.552 2004/10/26 15:03:08 albertel Exp $
+# $Id: lonnet.pm,v 1.553 2004/10/26 15:15:18 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1873,6 +1873,7 @@
         # - the student level sheet of this user in course's homespace
         # - the assessment level sheet for this resource 
         #   for this user in user's homespace
+	# - current conditional state info
 	my $key=$uname.':'.$udom.':';
         my $status=
 	    &del('nohist_calculatedsheets',
@@ -1887,6 +1888,7 @@
                     $uname.' at '.$udom.' for '.
 		    $symb.': '.$status);
         }
+	&delenv('user.state.'.$cid);
     }
 }
 
@@ -3056,6 +3058,9 @@
             return ''; 
          }
       }
+      if (!defined($ENV{'user.state.'.$ENV{'request.course.id'}})) {
+	  &Apache::lonuserstate::evalstate();
+      }
       if (&condval($statecond)) {
 	 return '2';
       } else {
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.79 rat/lonuserstate.pm:1.80
--- rat/lonuserstate.pm:1.79	Tue Oct 26 11:10:42 2004
+++ rat/lonuserstate.pm	Tue Oct 26 11:15:20 2004
@@ -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.79 2004/10/26 15:10:42 albertel Exp $
+# $Id: lonuserstate.pm,v 1.80 2004/10/26 15:15:20 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -617,39 +617,37 @@
 # ------------------------------------------------------- Evaluate state string
 
 sub evalstate {
-
     my $fn=$ENV{'request.course.fn'}.'.state';
-    my $state='2';
+    my $state='';
     if (-e $fn) {
-       my @conditions=();
-       {
-        my $fh=Apache::File->new($fn);
-        @conditions=<$fh>;
-       }  
-       my $safeeval = new Safe;
-       my $safehole = new Safe::Hole;
-       $safeeval->permit("entereval");
-       $safeeval->permit(":base_math");
-       $safeeval->deny(":base_io");
-       $safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT');
-       foreach (@conditions) {
-	   my $line=$_;
-           chomp($line);
-	   my ($condition,$weight)=split(/\:/,$_);
-           if ($safeeval->reval($condition)) {
-	       if ($weight eq 'force') {
-		   $state.='3';
-               } else {
-                   $state.='2';
-               }
-           } else {
-               if ($weight eq 'stop') {
-		   $state.='0';
-               } else {
-                   $state.='1';
-               }
-           }
-       }
+	my @conditions=();
+	{
+	    my $fh=Apache::File->new($fn);
+	    @conditions=<$fh>;
+	}  
+	my $safeeval = new Safe;
+	my $safehole = new Safe::Hole;
+	$safeeval->permit("entereval");
+	$safeeval->permit(":base_math");
+	$safeeval->deny(":base_io");
+	$safehole->wrap(\&Apache::lonnet::EXT,$safeeval,'&EXT');
+	foreach my $line (@conditions) {
+	    chomp($line);
+	    my ($condition,$weight)=split(/\:/,$line);
+	    if ($safeeval->reval($condition)) {
+		if ($weight eq 'force') {
+		    $state.='3';
+		} else {
+		    $state.='2';
+		}
+	    } else {
+		if ($weight eq 'stop') {
+		    $state.='0';
+		} else {
+		    $state.='1';
+		}
+	    }
+	}
     }
     &Apache::lonnet::appenv('user.state.'.$ENV{'request.course.id'} => $state);
     return $state;