--- loncom/xml/lonxml.pm 2003/02/14 19:35:55 1.234
+++ loncom/xml/lonxml.pm 2003/04/03 22:34:26 1.246
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.234 2003/02/14 19:35:55 www Exp $
+# $Id: lonxml.pm,v 1.246 2003/04/03 22:34:26 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -145,7 +145,7 @@ $Apache::lonxml::registered=0;
$Apache::lonxml::request='';
# a problem number counter, and check on ether it is used
-$Apache::lonxml::counter=4;
+$Apache::lonxml::counter=1;
$Apache::lonxml::counter_changed=0;
#internal check on whether to look at style defs
@@ -196,6 +196,13 @@ sub xmlend {
my $message=$contrib{$idx.':message'};
$message=~s/\n/\
/g;
$message=&Apache::lontexconvert::msgtexconverted($message);
+ if ($contrib{$idx.':attachmenturl'}) {
+ my ($fname,$ft)
+ =($contrib{$idx.':attachmenturl'}=~/\/(\w+)\.(\w+)$/);
+ $message.='
Attachment: '.$fname.'.'.$ft.'';
+ }
if ($message) {
if ($hidden) {
$message=''.$message.'';
@@ -248,7 +255,7 @@ sub xmlend {
}
if ($discussiononly) {
$discussion.=(<
+
ENDDISCUSS
$discussion.=&Apache::lonfeedback::generate_preview_button();
@@ -391,6 +401,7 @@ sub xmlparse {
&Apache::inputtags::initialize_inputtags();
&Apache::outputtags::initialize_outputtags();
&Apache::edit::initialize_edit();
+
#
# do we have a course style file?
#
@@ -457,22 +468,20 @@ sub htmlclean {
sub latex_special_symbols {
my ($current_token,$stack,$parstack,$where)=@_;
- if ($where=='header') {
- $current_token =~ s/_/ /g;
- $current_token =~ s/\^/ /g;
- $current_token =~ s/&/\\&/g;
+ if ($where eq 'header') {
+ $current_token =~ s/(\\|_|\^)/ /g;
+ $current_token =~ s/(\$|%|\#|&|\{|\})/\\$1/g;
} else {
- $current_token=~s/\\ /\\char92 /g;
- $current_token=~s/\^/\\char94 /g;
- $current_token=~s/\~/\\char126 /g;
- $current_token=~s/(&[^a-z\#])/\\$1/g;
- $current_token=~s/([^&])\#/$1\\#/g;
- $current_token=~s/(\$|_|{|})/\\$1/g;
- $current_token=~s/\\char92 /\\texttt{\\char92}/g;
- $current_token=~s/>/\$>\$/g; #more
- $current_token=~s/\$<\$/g; #less
- if ($current_token=~m/\d%/) {$current_token =~ s/(\d)%/$1\\%/g;} #percent after digit
- if ($current_token=~m/\s%/) {$current_token =~ s/(\s)%/$1\\%/g;} #persent after space
+ $current_token=~s/\\ /\\char92 /g;
+ $current_token=~s/\^/\\char94 /g;
+ $current_token=~s/\~/\\char126 /g;
+ $current_token=~s/(&[^A-Za-z\#])/\\$1/g;
+ $current_token=~s/([^&])\#/$1\\#/g;
+ $current_token=~s/(\$|_|{|})/\\$1/g;
+ $current_token=~s/\\char92 /\\texttt{\\char92}/g;
+ $current_token=~s/(>|<)/\$$1\$/g; #more or less
+ if ($current_token=~m/\d%/) {$current_token =~ s/(\d)%/$1\\%/g;} #percent after digit
+ if ($current_token=~m/\s%/) {$current_token =~ s/(\s)%/$1\\%/g;} #persent after space
}
return $current_token;
}
@@ -488,7 +497,8 @@ sub inner_xmlparse {
if ($metamode<1) {
my $text=$token->[1];
if ($token->[0] eq 'C' && $target eq 'tex') {
- $text = '%'.$text."\n";
+ $text = '';
+# $text = '%'.$text."\n";
}
$result.=$text;
}
@@ -517,10 +527,10 @@ sub inner_xmlparse {
while ($token->[1] ne $$stack['-1'] && ($#$stack > -1)) {
my $lasttag=$$stack[-1];
if ($token->[1] =~ /^$lasttag$/i) {
- &Apache::lonxml::warning('Using tag </'.$token->[1].'> as end tag to <'.$$stack[-1].'>');
+ &Apache::lonxml::warning('Using tag </'.$token->[1].'> on line '.$token->[3].' as end tag to <'.$$stack[-1].'>');
last;
} else {
- &Apache::lonxml::warning('Found tag </'.$token->[1].'> when looking for </'.$$stack[-1].'> in file');
+ &Apache::lonxml::warning('Found tag </'.$token->[1].'> on line '.$token->[3].' when looking for </'.$$stack[-1].'> in file');
&end_tag($stack,$parstack,$token);
}
}
@@ -592,6 +602,8 @@ sub callsub {
my $sub1;
no strict 'refs';
my $tag=$token->[1];
+# get utterly rid of extended html tags
+ if ($tag=~/^x\-/i) { return ''; }
my $space=$Apache::lonxml::alltags{$tag}[-1];
if (!$space) {
$tag=~tr/A-Z/a-z/;
@@ -794,7 +806,7 @@ sub default_homework_load {
my ($safeeval)=@_;
&Apache::lonxml::debug('Loading default_homework');
my $default=&Apache::lonnet::getfile('/home/httpd/html/res/adm/includes/default_homework.lcpm');
- if ($default == -1) {
+ if ($default eq -1) {
&Apache::lonxml::error("Unable to find default_homework.lcpm");
} else {
&Apache::run::run($default,$safeeval);
@@ -893,7 +905,7 @@ sub increment_counter {
sub init_counter {
if (defined($ENV{'form.counter'})) {
$Apache::lonxml::counter=$ENV{'form.counter'};
- } elsif (not defined($Apache::lonxml::counter)) {
+ } else {
$Apache::lonxml::counter=1;
&store_counter();
}
@@ -1099,6 +1111,13 @@ sub inserteditinfo {
my ($result,$filecontents)=@_;
$filecontents = &HTML::Entities::encode($filecontents);
# my $editheader='Edit below
';
+ my $xml_help = ''.
+ &Apache::loncommon::help_open_topic("Greek_Symbols",'Greek Symbols',
+ undef,undef,600)
+ .' | '.
+ &Apache::loncommon::help_open_topic("Other_Symbols",'Other Symbols',
+ undef,undef,600)
+ .' |
';
my $buttons=(<
@@ -1109,6 +1128,7 @@ BUTTONS