--- loncom/xml/lonxml.pm 2003/11/21 18:54:10 1.294 +++ loncom/xml/lonxml.pm 2004/01/30 17:27:34 1.299 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.294 2003/11/21 18:54:10 albertel Exp $ +# $Id: lonxml.pm,v 1.299 2004/01/30 17:27:34 sakharuk 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 { @@ -402,7 +405,7 @@ sub latex_special_symbols { $string =~ s/_/ /g; } else { $string=~s/\\ /\\char92 /g; - $string=~s/\^/\\\^ /g; + $string=~s/\^/\\\^\\strut /g; $string=~s/\~/\\char126 /g; #fixup & if it doesn't look like # { or α @@ -625,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; @@ -994,7 +998,6 @@ sub parstring { my $val=$token->[2]->{$_}; $val =~ s/([\%\@\\\"\'])/\\$1/g; #if ($val =~ m/^[\%\@]/) { $val="\\".$val; } - if ($val !~ m/^\s*\$[a-z_]/i) { $val =~ s/\$/\\\$/g; } $temp .= "my \$$_=\"$val\";"; } } @@ -1291,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 @@ -1324,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 { @@ -1338,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) { @@ -1361,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)) {