--- rat/lonuserstate.pm 2002/07/15 12:22:32 1.34 +++ rat/lonuserstate.pm 2002/09/10 20:53:37 1.43 @@ -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.34 2002/07/15 12:22:32 www Exp $ +# $Id: lonuserstate.pm,v 1.43 2002/09/10 20:53:37 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -79,7 +79,10 @@ sub loadmap { $hash{'map_pc_'.$uri}=$lpc; $hash{'map_id_'.$lpc}=$uri; - my $fn='/home/httpd/html'.$uri; +# Determine and check filename + my $fn=&Apache::lonnet::filelocation('',$uri); + + my $ispage=($fn=~/\.page$/); unless (($fn=~/\.sequence$/) || ($fn=~/\.page$/)) { @@ -87,32 +90,12 @@ sub loadmap { return OK; } - my $ispage=($fn=~/\.page$/); + my $instr=&Apache::lonnet::getfile($fn); - unless (-e $fn) { - my $returned=Apache::lonnet::repcopy($fn); - unless ($returned eq OK) { - $errtext.="Could not import: $fn - "; - if ($returned eq HTTP_SERVICE_UNAVAILABLE) { - $errtext.="Server unavailable\n"; - } - if ($returned eq HTTP_NOT_FOUND) { - $errtext.="File not found\n"; - } - if ($returned eq FORBIDDEN) { - $errtext.="Access forbidden\n"; - } - return OK; - } - } + unless ($instr == -1) { + +# Successfully got file, parse it - if (-e $fn) { - my @content; - { - my $fh=Apache::File->new($fn); - @content=<$fh>; - } - my $instr=join('',@content); my $parser = HTML::TokeParser->new(\$instr); my $token; @@ -135,11 +118,18 @@ sub loadmap { unless ($ispage) { $turi=~/\.(\w+)$/; my $embstyle=&Apache::loncommon::fileembstyle($1); - if ($token->[2]->{'external'} eq 'true') { + if ($token->[2]->{'external'} eq 'true') { # external $turi=~s/^http\:\/\//\/adm\/wrapper\/ext\//; - } else { - my $embstyle=&Apache::loncommon::fileembstyle($1); - if (($embstyle eq 'img') || ($embstyle eq 'emb')) { + } elsif ($turi=~/^\/*uploaded\//) { # uploaded + if (($embstyle eq 'img') || ($embstyle eq 'emb') + || ($embstyle eq 'ssi')) { + $turi='/adm/wrapper'.$turi; + } elsif ($turi!~/\.(sequence|page)$/) { + $turi='/adm/coursedocs/showdoc'.$turi; + } + } else { # normal internal resource + if (($embstyle eq 'img') || ($embstyle eq 'emb') + || ($turi=~/\/(syllabus|aboutme|navmaps|smppg|bulletinboard)$/)) { $turi='/adm/wrapper'.$turi; } } @@ -279,7 +269,8 @@ sub traceroute { $beenhere.=$rid.'&'; if (($retfurl eq '') && ($hash{'src_'.$rid})) { my ($mapid,$resid)=split(/\./,$rid); - $retfurl=$hash{'src_'.$rid}.'?symb='. + $retfurl=$hash{'src_'.$rid}. + (($hash{'src_'.$rid}=~/\?/)?'&':'?').'symb='. &Apache::lonnet::symbclean( &Apache::lonnet::declutter($hash{'map_id_'.$mapid}). '___'.$resid.'___'. @@ -472,13 +463,13 @@ sub readmap { unlink($fn.'parms.db'); undef %randompick; $retfurl=''; - if ((tie(%hash,'GDBM_File',"$fn.db",&GDBM_WRCREAT,0640)) && - (tie(%parmhash,'GDBM_File',$fn.'_parms.db',&GDBM_WRCREAT,0640))) { + if ((tie(%hash,'GDBM_File',"$fn.db",&GDBM_WRCREAT(),0640)) && + (tie(%parmhash,'GDBM_File',$fn.'_parms.db',&GDBM_WRCREAT(),0640))) { %hash=(); %parmhash=(); $errtext=''; $pc=0; - my $furi='/res/'.&Apache::lonnet::declutter($uri); + my $furi=&Apache::lonnet::clutter($uri); $hash{'src_0.0'}=$furi; $hash{'title_0.0'}=&Apache::lonnet::metadata($uri,'title'); $hash{'ids_'.$furi}='0.0';