--- loncom/xml/lonxml.pm 2002/10/11 20:52:13 1.201
+++ loncom/xml/lonxml.pm 2002/10/17 17:13:44 1.204
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.201 2002/10/11 20:52:13 www Exp $
+# $Id: lonxml.pm,v 1.204 2002/10/17 17:13:44 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -140,6 +140,10 @@ $Apache::lonxml::registered=0;
# a pointer the the Apache request object
$Apache::lonxml::request='';
+# a problem number counter, and check on hether it is used
+$Apache::lonxml::counter=0;
+$Apache::lonxml::counter_changed=0;
+
sub xmlbegin {
my $output='';
if ($ENV{'browser.mathml'}) {
@@ -555,6 +559,7 @@ sub xmlparse {
if ($ENV{'request.uri'}) {
&writeallows($ENV{'request.uri'});
}
+ if ($Apache::lonxml::counter_changed) { &store_counter() }
return $finaloutput;
}
@@ -585,11 +590,7 @@ sub latex_special_symbols {
$current_token=~s/\^/\\char94 /g;
$current_token=~s/\~/\\char126 /g;
$current_token=~s/(&[^a-z\#])/\\$1/g;
- if ($current_token=~/ \#\w/) {
- $current_token=~s/ \#(\w)/ \\#$1/;
- } else {
- $current_token=~s/([^&])(\#)/$1\\$2/g;
- }
+ $current_token=~s/([^&])\#/$1\\#/g;
$current_token=~s/(\$|_|{|})/\\$1/g;
$current_token=~s/\\char92 /\\texttt{\\char92}/g;
$current_token=~s/>/\$>\$/g; #more
@@ -851,6 +852,7 @@ sub setup_globals {
my ($request,$target)=@_;
$Apache::lonxml::request=$request;
$Apache::lonxml::registered = 0;
+ &init_counter();
@Apache::lonxml::pwd=();
@Apache::lonxml::extlinks=();
if ($target eq 'meta') {
@@ -1034,6 +1036,26 @@ sub get_all_text_unbalanced {
return $result
}
+sub increment_counter {
+ $Apache::lonxml::counter++;
+ $Apache::lonxml::counter_changed=1;
+}
+
+sub init_counter {
+ if (defined($ENV{'form.counter'})) {
+ $Apache::lonxml::counter=$ENV{'form.counter'};
+ } elsif (not defined($Apache::lonxml::counter)) {
+ $Apache::lonxml::counter=1;
+ &store_counter();
+ }
+ $Apache::lonxml::counter_changed=0;
+}
+
+sub store_counter {
+ &Apache::lonnet::appenv(('form.counter' => $Apache::lonxml::counter));
+ return '';
+}
+
sub get_all_text {
my($tag,$pars)= @_;
my $depth=0;
@@ -1325,7 +1347,7 @@ ENDNOTFOUND
sub debug {
if ($Apache::lonxml::debug eq 1) {
$|=1;
- print("DEBUG:".&HTML::Entities::encode($_[0])."
\n");
+ print('DEBUG:'.&HTML::Entities::encode($_[0])."\n");
}
}