--- rat/lonuserstate.pm 2004/10/26 15:10:42 1.79 +++ rat/lonuserstate.pm 2004/10/26 15:15:20 1.80 @@ -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 @@ sub readmap { # ------------------------------------------------------- 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;