--- loncom/xml/lonxml.pm 2003/03/25 22:51:48 1.241
+++ loncom/xml/lonxml.pm 2011/12/09 21:21:43 1.527
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.241 2003/03/25 22:51:48 albertel Exp $
+# $Id: lonxml.pm,v 1.527 2011/12/09 21:21:43 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,31 +36,32 @@
# The C source of the Code may not be distributed by the Licensee
# to any other parties under any circumstances.
#
-# last modified 06/26/00 by Alexander Sakharuk
-# 11/6 Gerd Kortemeyer
-# 6/1/1 Gerd Kortemeyer
-# 2/21,3/13 Guy
-# 3/29,5/4 Gerd Kortemeyer
-# 5/26 Gerd Kortemeyer
-# 5/27 H. K. Ng
-# 6/2,6/3,6/8,6/9 Gerd Kortemeyer
-# 6/12,6/13 H. K. Ng
-# 6/16 Gerd Kortemeyer
-# 7/27 H. K. Ng
-# 8/7,8/9,8/10,8/11,8/15,8/16,8/17,8/18,8/20,8/23,8/24 Gerd Kortemeyer
-# Guy Albertelli
-# 9/26 Gerd Kortemeyer
-# Dec Guy Albertelli
-# YEAR=2002
-# 1/1 Gerd Kortemeyer
-# 1/2 Matthew Hall
-# 1/3 Gerd Kortemeyer
-#
+
+=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 $prevent_entity_encode $errorcount $warningcount);
+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();
@@ -69,6 +70,9 @@ use Safe::Hole();
use Math::Cephes();
use Math::Random();
use Opcode();
+use POSIX qw(strftime);
+use Time::HiRes qw( gettimeofday tv_interval );
+use Symbol();
sub register {
my ($space,@taglist) = @_;
@@ -94,16 +98,26 @@ use Apache::style();
use Apache::run();
use Apache::londefdef();
use Apache::scripttag();
+use Apache::languagetags();
use Apache::edit();
-use Apache::lonnet();
+use Apache::inputtags();
+use Apache::outputtags();
+use Apache::lonnet;
use Apache::File();
use Apache::loncommon();
use Apache::lonfeedback();
use Apache::lonmsg();
use Apache::loncacc();
+use Apache::lonmaxima();
+use Apache::lonr();
+use Apache::lonlocal;
+use Apache::lonhtmlcommon();
+use Apache::functionplotresponse();
+
+#==================================== 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
@@ -135,11 +149,8 @@ $evaluate = 1;
# stores the list of active tag namespaces
@namespace=();
-# if 0 all high ASCII characters will be encoded into HTML Entities
-$prevent_entity_encode=0;
-
-# 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='';
@@ -148,232 +159,68 @@ $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;
-sub xmlbegin {
- my $output='';
- if ($ENV{'browser.mathml'}) {
- $output=''
- .''
- .']>'
- .'';
- } else {
- $output='';
- }
- return $output;
-}
+#locations used to store the parameter string for style substitutions
+$Apache::lonxml::style_values='';
+$Apache::lonxml::style_end_values='';
-sub xmlend {
- my ($discussiononly,$symb)=@_;
- my $discussion='';
- if ($ENV{'request.course.id'}) {
- my $crs='/'.$ENV{'request.course.id'};
- if ($ENV{'request.course.sec'}) {
- $crs.='_'.$ENV{'request.course.sec'};
- }
- $crs=~s/\_/\//g;
- my $seeid=&Apache::lonnet::allowed('rin',$crs);
- unless ($symb) {
- $symb=&Apache::lonnet::symbread();
- }
- if ($symb) {
- my %contrib=&Apache::lonnet::restore($symb,$ENV{'request.course.id'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
- if ($contrib{'version'}) {
- unless ($discussiononly) {
- $discussion.=
- '
';
- }
- my $idx;
- for ($idx=1;$idx<=$contrib{'version'};$idx++) {
- my $hidden=($contrib{'hidden'}=~/\.$idx\./);
- my $deleted=($contrib{'deleted'}=~/\.$idx\./);
- unless ((($hidden) && (!$seeid)) || ($deleted)) {
- my $message=$contrib{$idx.':message'};
- $message=~s/\n/\ /g;
- $message=&Apache::lontexconvert::msgtexconverted($message);
- if ($message) {
- if ($hidden) {
- $message=''.$message.'';
- }
- my $screenname=&Apache::loncommon::screenname(
- $contrib{$idx.':sendername'},
- $contrib{$idx.':senderdomain'});
- my $plainname=&Apache::loncommon::nickname(
- $contrib{$idx.':sendername'},
- $contrib{$idx.':senderdomain'});
-
- my $sender='Anonymous';
- if ((!$contrib{$idx.':anonymous'}) || ($seeid)) {
- $sender=&Apache::loncommon::aboutmewrapper(
- $plainname,
- $contrib{$idx.':sendername'},
- $contrib{$idx.':senderdomain'}).' ('.
- $contrib{$idx.':sendername'}.' at '.
- $contrib{$idx.':senderdomain'}.')';
- if ($contrib{$idx.':anonymous'}) {
- $sender.=' [anonymous] '.
- $screenname;
- }
- if ($seeid) {
- if ($hidden) {
- $sender.=' Make Visible';
- } else {
- $sender.=' Hide';
- }
- $sender.=' Delete';
- }
- } else {
- if ($screenname) {
- $sender=''.$screenname.'';
- }
- }
- $discussion.='