--- loncom/xml/lonxml.pm 2002/01/01 16:37:20 1.143 +++ loncom/xml/lonxml.pm 2002/01/08 21:11:13 1.147 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.143 2002/01/01 16:37:20 www Exp $ +# $Id: lonxml.pm,v 1.147 2002/01/08 21:11:13 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -54,6 +54,8 @@ # Dec Guy Albertelli # YEAR=2002 # 1/1 Gerd Kortemeyer +# 1/2 Matthew Hall +# 1/3 Gerd Kortemeyer # package Apache::lonxml; @@ -288,11 +290,14 @@ sub printtokenheader { $reply{'generation'}; if ($target eq 'web') { + my %idhash=&Apache::lonnet::idrget($tudom,($tuname)); return ''. 'Checked out for '.$plainname. '
User: '.$tuname.' at '.$tudom. + '
ID: '.$idhash{$tuname}. '
CourseID: '.$tcrsid. + '
Course: '.$ENV{'course.'.$tcrsid.'.description'}. '
DocID: '.$token. '
Time: '.localtime().'
'; } else { @@ -1006,6 +1011,8 @@ sub storefile { if (my $fh=Apache::File->new('>'.$file)) { print $fh $contents; $fh->close(); + } else { + &warning("Unable to save file $file"); } } @@ -1027,23 +1034,38 @@ sub inserteditinfo { SIMPLECONTENT } - my $editheader='Edit below
'; + + $filecontents =~ s::</textarea>:g; +# my $editheader='Edit below
'; my $editfooter=(<

+ +
ENDFOOTER - $result=~s/(\]*\>)/$1$editheader/is; +# $result=~s/(\]*\>)/$1$editheader/is; $result=~s/(\<\/body\>)/$editfooter/is; return $result; } +sub editbutton { + my ($result) = @_; + my $button=(< + + +EDITBUTTON + $result=~s/(\<\/body\>)/$button/is; + return $result; +} + sub handler { my $request=shift; @@ -1072,7 +1094,7 @@ sub handler { } } my %mystyle; - my $result = ''; + my $result = ''; my $filecontents=&Apache::lonnet::getfile($file); if ($filecontents == -1) { $result=(<uri); $request->print($result); return OK; } - + sub debug { if ($Apache::lonxml::debug eq 1) { - print("DEBUG:".$_[0]."
\n"); + $|=1; + print("DEBUG:".join('
',@_)."
\n"); } } sub error { if (($Apache::lonxml::debug eq 1) || ($ENV{'request.state'} eq 'construct') ) { - print "ERROR:".$_[0]."
\n"; + print "ERROR:".join('
',@_)."
\n"; } else { print "An Error occured while processing this resource. The instructor has been notified.
"; #notify author - &Apache::lonmsg::author_res_msg($ENV{'request.filename'},$_[0]); + &Apache::lonmsg::author_res_msg($ENV{'request.filename'},join('
',@_)); #notify course if ( $ENV{'request.course.id'} ) { my $users=$ENV{'course.'.$ENV{'request.course.id'}.'.comment.email'}; @@ -1129,19 +1159,19 @@ sub error { foreach my $user (split /\,/, $users) { ($user,my $domain) = split /:/, $user; &Apache::lonmsg::user_normal_msg($user,$domain, - "Error [$declutter]",$_[0]); + "Error [$declutter]",join('
',@_)); } } #FIXME probably shouldn't have me get everything forever. - &Apache::lonmsg::user_normal_msg('albertel','msu',"Error in $ENV{'request.filename'}",$_[0]); + &Apache::lonmsg::user_normal_msg('albertel','msu',"Error in $ENV{'request.filename'}",join('
',@_)); #&Apache::lonmsg::user_normal_msg('albertel','103',"Error in $ENV{'request.filename'}",$_[0]); } } sub warning { if ($ENV{'request.state'} eq 'construct') { - print "WARNING:".$_[0]."
\n"; + print "WARNING:".join('
',@_)."
\n"; } } @@ -1198,7 +1228,7 @@ sub register_insert { my $line = $data[$i]; my ($mnemonic,@which) = split(/ +/,$line); my $tag = $insertlist{"$tagnum.tag"}; - for (my $j=0;$j <$#which;$j++) { + for (my $j=0;$j <=$#which;$j++) { if ( $which[$j] eq 'Y' ) { if ($insertlist{"$j.show"} ne 'no') { push(@{ $insertlist{"$tag.which"} },$j);