--- loncom/xml/lonxml.pm 2005/05/03 06:44:56 1.373
+++ loncom/xml/lonxml.pm 2010/02/08 00:35:06 1.505
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.373 2005/05/03 06:44:56 albertel Exp $
+# $Id: lonxml.pm,v 1.505 2010/02/08 00:35:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -37,11 +37,31 @@
# to any other parties under any circumstances.
#
+=pod
+
+=head1 NAME
+
+Apache::lonxml
+
+=head1 SYNOPSIS
+
+XML Parsing Module
+
+This is part of the LearningOnline Network with CAPA project
+described at http://www.lon-capa.org.
+
+
+=head1 SUBROUTINES
+
+=cut
+
+
package Apache::lonxml;
use vars
-qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace $errorcount $warningcount @htmlareafields);
+qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace $errorcount $warningcount);
use strict;
+use LONCAPA;
use HTML::LCParser();
use HTML::TreeBuilder();
use HTML::Entities();
@@ -52,6 +72,7 @@ use Math::Random();
use Opcode();
use POSIX qw(strftime);
use Time::HiRes qw( gettimeofday tv_interval );
+use Symbol();
sub register {
my ($space,@taglist) = @_;
@@ -87,10 +108,15 @@ use Apache::loncommon();
use Apache::lonfeedback();
use Apache::lonmsg();
use Apache::loncacc();
+use Apache::lonmaxima();
+use Apache::lonr();
use Apache::lonlocal;
+use Apache::lonhtmlcommon();
+
+#==================================== Main subroutine: xmlparse
-#================================================== Main subroutine: xmlparse
#debugging control, to turn on debugging modify the correct handler
+
$Apache::lonxml::debug=0;
# keeps count of the number of warnings and errors generated in a parse
@@ -122,8 +148,8 @@ $evaluate = 1;
# stores the list of active tag namespaces
@namespace=();
-# has the dynamic menu been updated to know about this resource
-$Apache::lonxml::registered=0;
+# stores all Scrit Vars displays for later showing
+my @script_var_displays=();
# a pointer the the Apache request object
$Apache::lonxml::request='';
@@ -132,6 +158,16 @@ $Apache::lonxml::request='';
$Apache::lonxml::counter=1;
$Apache::lonxml::counter_changed=0;
+# Part counter hash. In analysis mode, the
+# problems can use this to record which parts increment the counter
+# by how much. The counter subs will maintain this hash via
+# their optional part parameters. Note that the assumption is that
+# analysis is done in one request and therefore it is not necessary to
+# save this information request-to-request.
+
+
+%Apache::lonxml::counters_per_part = ();
+
#internal check on whether to look at style defs
$Apache::lonxml::usestyle=1;
@@ -148,26 +184,17 @@ $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 ($style)=@_;
- my $output='';
- @htmlareafields=();
- if ($env{'browser.mathml'}) {
- $output=''
- #.''."\n"
-# .'] >'
- .''
- .'';
- } else {
- $output='';
- }
- if ($style eq 'encode') {
- $output=&HTML::Entities::encode($output,'<>&"');
- }
- return $output;
+# Control whether or not LaTeX symbols should be substituted for their
+# \ style equivalents...this may be turned off e.g. in an verbatim
+# environment.
+
+$Apache::lonxml::substitute_LaTeX_symbols = 1; # Starts out on.
+
+sub enable_LaTeX_substitutions {
+ $Apache::lonxml::substitute_LaTeX_symbols = 1;
+}
+sub disable_LaTeX_substitutions {
+ $Apache::lonxml::substitute_LaTeX_symbols = 0;
}
sub xmlend {
@@ -180,8 +207,8 @@ sub xmlend {
$status=$Apache::inputtags::status[-1];
}
my $discussion;
- &Apache::loncommon::get_unprocessed_cgi
- ($env{'query_string'},['LONCAPA_INTERNAL_no_discussion']);
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['LONCAPA_INTERNAL_no_discussion']);
if (! exists($env{'form.LONCAPA_INTERNAL_no_discussion'}) ||
$env{'form.LONCAPA_INTERNAL_no_discussion'} ne 'true') {
$discussion=&Apache::lonfeedback::list_discussion($mode,$status);
@@ -190,9 +217,9 @@ sub xmlend {
$discussion.='