--- rat/lonuserstate.pm 2006/05/12 15:28:50 1.107.2.3
+++ rat/lonuserstate.pm 2006/05/30 19:11:37 1.115
@@ -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.2.3 2006/05/12 15:28:50 matthew Exp $
+# $Id: lonuserstate.pm,v 1.115 2006/05/30 19:11:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,6 +33,7 @@ package Apache::lonuserstate;
use strict;
use HTML::TokeParser;
use Apache::lonnet;
+use Apache::lonlocal;
use Apache::loncommon();
use GDBM_File;
use Apache::lonmsg;
@@ -41,6 +42,9 @@ use Safe::Hole;
use Opcode;
use Apache::lonenc;
use Fcntl qw(:flock);
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
+
# ---------------------------------------------------- Globals for this package
@@ -103,8 +107,10 @@ sub processversionfile {
sub loadmap {
my $uri=shift;
- if ($hash{'map_pc_'.$uri}) { return; }
-
+ if ($hash{'map_pc_'.$uri}) {
+ $errtext.=&mt('
Multiple use of sequence/page [_1]! The course will not function properly.',$uri);
+ return;
+ }
$pc++;
my $lpc=$pc;
$hash{'map_pc_'.$uri}=$lpc;
@@ -117,7 +123,7 @@ sub loadmap {
unless (($fn=~/\.sequence$/) ||
($fn=~/\.page$/)) {
- $errtext.="Invalid map: $fn\n";
+ $errtext.=&mt("
Invalid map: [_1]",$fn);
return;
}
@@ -277,9 +283,9 @@ sub loadmap {
}
$name=~s/^.*_([^_]*)$/$1/;
my $newparam=
- &Apache::lonnet::escape($token->[2]->{'type'}).':'.
- &Apache::lonnet::escape($part.'.'.$name).'='.
- &Apache::lonnet::escape($token->[2]->{'value'});
+ &escape($token->[2]->{'type'}).':'.
+ &escape($part.'.'.$name).'='.
+ &escape($token->[2]->{'value'});
if (defined($hash{'param_'.$referid})) {
$hash{'param_'.$referid}.='&'.$newparam;
} else {
@@ -310,7 +316,7 @@ sub loadmap {
}
} else {
- $errtext.='Map not loaded: The file ('.$fn.') does not exist. ';
+ $errtext.=&mt('
Map not loaded: The file [_1] does not exist.',$fn);
}
}
@@ -390,8 +396,7 @@ sub traceroute {
$further=simplify('('.'_'.$rid.')&('.
$hash{'condid_'.$hash{'undercond_'.$id}}.')');
} else {
- $errtext.='Undefined condition ID: '
- .$hash{'undercond_'.$id}.'. ';
+ $errtext.=&mt('
Undefined condition ID: [_1]',$hash{'undercond_'.$id});
}
}
$newsofar=&traceroute($further,$hash{'goesto_'.$id},$beenhere,
@@ -438,10 +443,10 @@ sub accinit {
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);
- $parmhash{$prefix.'.'.&Apache::lonnet::unescape($name).'.type'}=
- &Apache::lonnet::unescape($type);
+ $parmhash{$prefix.'.'.&unescape($name)}=
+ &unescape($value);
+ $parmhash{$prefix.'.'.&unescape($name).'.type'}=
+ &unescape($type);
}
}
}
@@ -545,14 +550,14 @@ sub hiddenurls {
sub readmap {
my $short=shift;
$short=~s/^\///;
- my %cenv=&Apache::lonnet::coursedescription($short);
+ my %cenv=&Apache::lonnet::coursedescription($short,{'freshen_cache'=>1});
my $fn=$cenv{'fn'};
my $uri;
$short=~s/\//\_/g;
unless ($uri=$cenv{'url'}) {
&Apache::lonnet::logthis("WARNING: ".
"Could not load course $short.");
- return 'No course data available.';
+ return ('',&mt('No course data available.'));;
}
@cond=('true:normal');
@@ -681,8 +686,9 @@ sub evalstate {
if (-e $fn) {
my @conditions=();
{
- my $fh=Apache::File->new($fn);
+ open(my $fh,"<$fn");
@conditions=<$fh>;
+ close($fh);
}
my $safeeval = new Safe;
my $safehole = new Safe::Hole;