--- loncom/xml/lonxml.pm 2003/10/24 21:31:05 1.287 +++ loncom/xml/lonxml.pm 2004/01/28 16:10:26 1.298 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.287 2003/10/24 21:31:05 albertel Exp $ +# $Id: lonxml.pm,v 1.298 2004/01/28 16:10:26 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -167,6 +167,9 @@ $Apache::lonxml::style_end_values=''; #should we do the postag variable interpolation $Apache::lonxml::post_evaluate=1; +#a header message to emit in the case of any generated warning or errors +$Apache::lonxml::warnings_error_header=''; + sub xmlbegin { my $output=''; if ($ENV{'browser.mathml'}) { @@ -189,7 +192,7 @@ sub xmlend { $mode='problem'; $status=$Apache::inputtags::status[-1]; } - return &Apache::lonfeedback::list_discussion().''; + return &Apache::lonfeedback::list_discussion($mode,$status).''; } sub tokeninputfield { @@ -337,6 +340,13 @@ sub xmlparse { &Apache::style::styleparser($target,$styletext)); } } + } elsif ($ENV{'construct.style'} && ($ENV{'request.state'} eq 'construct')) { + my $location=&Apache::lonnet::filelocation('',$ENV{'construct.style'}); + my $styletext=&Apache::lonnet::getfile($location); + if ($styletext ne '-1') { + %style_for_target = (%style_for_target, + &Apache::style::styleparser($target,$styletext)); + } } #&printalltags(); my @pars = (); @@ -395,9 +405,11 @@ sub latex_special_symbols { $string =~ s/_/ /g; } else { $string=~s/\\ /\\char92 /g; - $string=~s/\^/\\char94 /g; + $string=~s/\^/\\\^ /g; $string=~s/\~/\\char126 /g; - $string=~s/(&[^A-Za-z\#])/\\$1/g; + #fixup & if it doesn't look like + # { or α + $string=~s/(&(?!((\#[0-9]+)|([a-z]+));))/\\$1/gi; $string=~s/([^&])\#/$1\\#/g; $string=~s/(\$|_|{|})/\\$1/g; $string=~s/\\char92 /\\texttt{\\char92}/g; @@ -616,6 +628,7 @@ sub setup_globals { @Apache::lonxml::extlinks=(); @Apache::lonxml::ssi_info=(); $Apache::lonxml::post_evaluate=1; + $Apache::lonxml::warnings_error_header=''; if ($target eq 'meta') { $Apache::lonxml::redirection = 0; $Apache::lonxml::metamode = 1; @@ -1060,6 +1073,7 @@ ENDSCRIPT sub storefile { my ($file,$contents)=@_; + &Apache::lonnet::correct_line_ends(\$contents); if (my $fh=Apache::File->new('>'.$file)) { print $fh $contents; $fh->close(); @@ -1280,17 +1294,19 @@ sub display_title { } sub debug { - if ($Apache::lonxml::debug eq 1) { - $|=1; - print('DEBUG:'.&HTML::Entities::encode($_[0])."\n"); - } + if ($Apache::lonxml::debug eq "1") { + $|=1; + Apache->request->print('DEBUG:'.&HTML::Entities::encode($_[0])."\n"); + } } sub error { $errorcount++; if (($Apache::lonxml::debug eq 1) || ($ENV{'request.state'} eq 'construct') ) { # If printing in construction space, put the error inside

-    print "ERROR:".join("\n",@_)."\n";
+      print $Apache::lonxml::warnings_error_header.
+	  "ERROR:".join("\n",@_)."\n";
+      $Apache::lonxml::warnings_error_header='';
   } else {
     print "An Error occured while processing this resource. The instructor has been notified. 
"; #notify author @@ -1313,13 +1329,15 @@ sub error { } sub warning { - $warningcount++; + $warningcount++; - if ($ENV{'form.grade_target'} ne 'tex') { - if ($ENV{'request.state'} eq 'construct' || $Apache::lonxml::debug) { - print "WARNING:".join('
',@_)."
\n"; - } - } + if ($ENV{'form.grade_target'} ne 'tex') { + if ($ENV{'request.state'} eq 'construct' || $Apache::lonxml::debug) { + print $Apache::lonxml::warnings_error_header. + "WARNING:".join('
',@_)."
\n"; + $Apache::lonxml::warnings_error_header=''; + } + } } sub get_param { @@ -1327,6 +1345,9 @@ sub get_param { if ( ! $context ) { $context = -1; } my $args =''; if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; } + if ( ! $Apache::lonxml::usestyle ) { + $args=$Apache::lonxml::style_values.$args; + } if ( ! $args ) { return undef; } if ( $case_insensitive ) { if ($args =~ s/(my \$)(\Q$param\E)(=\")/$1.lc($2).$3/ei) { @@ -1350,6 +1371,9 @@ sub get_param_var { if ( ! $context ) { $context = -1; } my $args =''; if ( $#$parstack > (-2-$context) ) { $args=$$parstack[$context]; } + if ( ! $Apache::lonxml::usestyle ) { + $args=$Apache::lonxml::style_values.$args; + } &Apache::lonxml::debug("Args are $args param is $param"); if ($case_insensitive) { if (! ($args=~s/(my \$)(\Q$param\E)(=\")/$1.lc($2).$3/ei)) {