--- loncom/xml/lonxml.pm 2003/02/19 17:48:05 1.238 +++ loncom/xml/lonxml.pm 2003/05/02 19:57:01 1.250 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.238 2003/02/19 17:48:05 albertel Exp $ +# $Id: lonxml.pm,v 1.250 2003/05/02 19:57:01 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -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.=(< +

@@ -257,6 +264,9 @@ sub xmlend { Note: in anonymous discussion, your name is visible only to course faculty
+

+Attachment (128 KB max size): +

ENDDISCUSS $discussion.=&Apache::lonfeedback::generate_preview_button(); @@ -370,8 +380,11 @@ sub printtokenheader { sub fontsettings() { my $headerstring=''; if (($ENV{'browser.os'} eq 'mac') && (!$ENV{'browser.mathml'})) { - $headerstring.= - ''; + $headerstring.= + ''; + } elsif (!$ENV{'browser.mathml'}) { + $headerstring.= + ''; } return $headerstring; } @@ -391,6 +404,7 @@ sub xmlparse { &Apache::inputtags::initialize_inputtags(); &Apache::outputtags::initialize_outputtags(); &Apache::edit::initialize_edit(); + # # do we have a course style file? # @@ -464,7 +478,7 @@ sub latex_special_symbols { $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/(&[^A-Za-z\#])/\\$1/g; $current_token=~s/([^&])\#/$1\\#/g; $current_token=~s/(\$|_|{|})/\\$1/g; $current_token=~s/\\char92 /\\texttt{\\char92}/g; @@ -486,7 +500,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; } @@ -515,10 +530,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); } } @@ -545,9 +560,10 @@ sub inner_xmlparse { } } if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) { - if ($target eq 'tex') { - $result=&latex_special_symbols($result,$stack,$parstack); - } + #Style file definitions should be correct + if ($target eq 'tex' && ($Apache::lonxml::usestyle)) { + $result=&latex_special_symbols($result,$stack,$parstack); + } } # Encode any high ASCII characters @@ -787,6 +803,7 @@ sub init_safespace { my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser(); $rndseed=&Apache::lonnet::rndseed($symb,$courseid,$domain,$name); $safeinit .= ';$external::randomseed='.$rndseed.';'; + &Apache::lonxml::debug("Setting rndseed to $rndseed"); &Apache::run::run($safeinit,$safeeval); } @@ -794,7 +811,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); @@ -886,18 +903,23 @@ sub get_all_text_unbalanced { } sub increment_counter { - $Apache::lonxml::counter++; + my ($increment) = @_; + if (defined($increment) && $increment gt 0) { + $Apache::lonxml::counter+=$increment; + } else { + $Apache::lonxml::counter++; + } $Apache::lonxml::counter_changed=1; } sub init_counter { if (defined($ENV{'form.counter'})) { $Apache::lonxml::counter=$ENV{'form.counter'}; + $Apache::lonxml::counter_changed=0; } else { $Apache::lonxml::counter=1; - &store_counter(); + $Apache::lonxml::counter_changed=1; } - $Apache::lonxml::counter_changed=0; } sub store_counter { @@ -1099,6 +1121,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 +1138,7 @@ BUTTONS
+$xml_help $buttons
@@ -1178,7 +1208,7 @@ sub handler { my %mystyle; my $result = ''; my $filecontents=&Apache::lonnet::getfile($file); - if ($filecontents == -1) { + if ($filecontents eq -1) { $result=(< @@ -1371,7 +1401,7 @@ sub description { # calls to lonnet functions for this setup. # - looks for form.grade_ parameters sub whichuser { - my ($symb,$courseid,$domain,$name); + my ($symb,$courseid,$domain,$name,$publicuser); if (defined($ENV{'form.grade_symb'})) { my $tmp_courseid=$ENV{'form.grade_courseid'}; my $allowed=&Apache::lonnet::allowed('mgr',$tmp_courseid); @@ -1382,12 +1412,18 @@ sub whichuser { $name=$ENV{'form.grade_username'}; } } else { - $symb=&Apache::lonnet::symbread(); - $courseid=$ENV{'request.course.id'}; - $domain=$ENV{'user.domain'}; - $name=$ENV{'user.name'}; + $symb=&Apache::lonnet::symbread(); + $courseid=$ENV{'request.course.id'}; + $domain=$ENV{'user.domain'}; + $name=$ENV{'user.name'}; + if ($name eq 'public' && $domain eq 'public') { + if (!defined($ENV{'form.username'})) { + $ENV{'form.username'}.=time.rand(10000000); + } + $name.=$ENV{'form.username'}; + } } - return ($symb,$courseid,$domain,$name); + return ($symb,$courseid,$domain,$name,$publicuser); } 1;