--- rat/lonratsrv.pm 2002/06/27 16:43:57 1.19 +++ rat/lonratsrv.pm 2002/08/19 21:15:08 1.21 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Server for RAT Maps # -# $Id: lonratsrv.pm,v 1.19 2002/06/27 16:43:57 albertel Exp $ +# $Id: lonratsrv.pm,v 1.21 2002/08/19 21:15:08 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -69,15 +69,20 @@ sub qtunescape { sub loadmap { my ($fn,$errtext)=@_; my $outstr=''; - my @content=(); my @obj=(); my @links=(); - if (-e $fn) { + my $instr=''; + if ($fn=~/^\/*uploaded\//) { + $instr=&Apache::lonnet::getfile($fn); + } elsif (-e $fn) { + my @content=(); { my $fh=Apache::File->new($fn); @content=<$fh>; } - my $instr=join('',@content); + $instr=join('',@content); + } + if ($instr) { my $parser = HTML::TokeParser->new(\$instr); my $token; my $graphmode=0; @@ -197,7 +202,7 @@ sub loadmap { # ----------------------------------------------------------- Saves map to disk sub savemap { - my ($fn,$errtext,$r)=@_; + my ($fn,$errtext)=@_; my %alltypes; my %allvalues; if (($fn=~/\.sequence$/) || @@ -262,17 +267,19 @@ sub savemap { } elsif ($parts[0] eq 'objparms') { undef %alltypes; undef %allvalues; - map { + foreach (split(/:/,$parts[$#parts])) { my ($type,$name,$value)=split(/\_\_\_/,$_); $alltypes{$name}=$type; $allvalues{$name}=$value; - } split(/:/,$parts[$#parts]); - map { + } + foreach (keys %allvalues) { + if ($allvalues{$_} ne '') { $outstr.='' ."\n"; - } keys %allvalues; + } + } } elsif (($parts[0] ne '') && ($graphdef)) { # ------------------------------------------------------------- Graphical input $outstr.='<'.$parts[0]; @@ -284,7 +291,14 @@ sub savemap { } } @tags; $outstr.="\n"; - { + if ($fn=~/^\/*uploaded\//) { + $ENV{'form.output'}=$outstr; + &Apache::lonnet::finishuserfileupload( + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.home'}, + 'output',(split(/\//,$fn))[-1]); + } else { my $fh; if ($fh=Apache::File->new(">$fn")) { print $fh $outstr; @@ -295,7 +309,7 @@ sub savemap { } } else { # -------------------------------------------- Cannot write to that file, error - $errtext.='Map not saved: The specified '.$fn.' path does not exist. '.$r->uri(); + $errtext.='Map not saved: The specified path does not exist. '; } return $errtext; } @@ -327,7 +341,7 @@ sub handler { my $outtext=''; if ($mode ne 'loadonly') { - $errtext=&savemap($fn,$errtext,$r); + $errtext=&savemap($fn,$errtext); } ($outtext,$errtext)=&loadmap($fn,$errtext);