[LON-CAPA-cvs] cvs: loncom(version_2_9_X) /interface lonprintout.pm
raeburn
raeburn@source.lon-capa.org
Fri, 30 Jul 2010 22:47:03 -0000
raeburn Fri Jul 30 22:47:03 2010 EDT
Modified files: (Branch: version_2_9_X)
/loncom/interface lonprintout.pm
Log:
- Backport 1.582.
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.568.2.7 loncom/interface/lonprintout.pm:1.568.2.8
--- loncom/interface/lonprintout.pm:1.568.2.7 Mon May 24 22:10:42 2010
+++ loncom/interface/lonprintout.pm Fri Jul 30 22:47:02 2010
@@ -2,7 +2,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.568.2.7 2010/05/24 22:10:42 raeburn Exp $
+# $Id: lonprintout.pm,v 1.568.2.8 2010/07/30 22:47:02 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1525,7 +1525,9 @@
my $title=&Apache::lonnet::gettitle($symb);
$title = &Apache::lonxml::latex_special_symbols($title);
} else {
- $result.=$currentURL;
+ my $esc_currentURL= $currentURL;
+ $esc_currentURL =~ s/_/\\_/g;
+ $result.=$esc_currentURL;
}
$result .= '\\\\';
@@ -1555,7 +1557,7 @@
}
# these resources go through the XML transformer:
- elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
+ elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) {
my $urlp = &Apache::lonnet::clutter($resource_src);
my %form;
my %moreenv;
@@ -2211,7 +2213,14 @@
&Apache::lonxml::remember_problem_counter();
if ($flag_latex_header_remove eq 'NO') {
$texversion.=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); # RF
- $flag_latex_header_remove = 'YES';
+ unless (($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only') ||
+ (($i==0) &&
+ (($urlp=~/\.page$/) ||
+ ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_in_page') ||
+ ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_resources_in_page')))) {
+
+ $flag_latex_header_remove = 'YES';
+ }
}
$texversion.=&ssi_with_retries($urlp, $ssi_retry_count, %form);
if ($urlp=~/\.page$/) {
@@ -2232,12 +2241,22 @@
&Apache::lonxml::restore_problem_counter();
my $answer=&ssi_with_retries($urlp, $ssi_retry_count, %answerform);
+ if ($urlp =~ /\.page$/) {
+ $answer =~ s/\\end{document}(\d*)$//;
+ }
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
- $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
+ if ($urlp =~ /\.page$/) {
+ my @probs = split(/\\keephidden{ENDOFPROBLEM}/,$texversion);
+ my $lastprob = pop(@probs);
+ $texversion = join('\keephidden{ENDOFPROBLEM}',@probs).
+ $answer.'\keephidden{ENDOFPROBLEM}'.$lastprob;
+ } else {
+ $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
+ }
} else {
- if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {
+ if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page)$/) {
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
- $texversion =~ s/\\begin{document}//;
+# $texversion =~ s/\\begin{document}//;
my $title = &Apache::lonnet::gettitle($master_seq[$i]);
$title = &Apache::lonxml::latex_special_symbols($title);
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
@@ -2805,7 +2824,7 @@
$i++;
if ( !($type eq 'problems' &&
- ($curresline!~ m/\.(problem|exam|quiz|assess|survey|form|library)$/)) ) {
+ ($curresline!~ m/\.(problem|exam|quiz|assess|survey|form|library|page)$/)) ) {
my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline);
if (&Apache::lonnet::allowed('bre',$res_url)) {
if ($res_url!~m|^ext/|
@@ -2814,6 +2833,18 @@
&Apache::lonxml::remember_problem_counter();
my $rendered = &get_student_view_with_retries($curresline,$ssi_retry_count,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);
+ if ($res_url =~ /\.page$/) {
+ if ($remove_latex_header eq 'NO') {
+ if (!($rendered =~ /\\begin\{document\}/)) {
+ $rendered = &print_latex_header().$rendered;
+ }
+ }
+ if ($remove_latex_header eq 'YES') {
+ $rendered = &latex_header_footer_remove($rendered);
+ } else {
+ $rendered =~ s/\\end{document}\d*//;
+ }
+ }
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
# Use a copy of the hash so we don't pervert it on future loop passes.
@@ -2831,7 +2862,9 @@
my $header =&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
- $header =~ s/\\begin{document}//; #<<<<<
+ unless ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only') {
+ $header =~ s/\\begin{document}//; #<<<<<
+ }
my $title = &Apache::lonnet::gettitle($curresline);
$title = &Apache::lonxml::latex_special_symbols($title);
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';