[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
foxr
lon-capa-cvs@mail.lon-capa.org
Fri, 24 Feb 2006 22:37:47 -0000
foxr Fri Feb 24 17:37:47 2006 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
Defect 4500 - Encapsulated answers in a minipage if needed when answer only.
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.422 loncom/interface/lonprintout.pm:1.423
--- loncom/interface/lonprintout.pm:1.422 Tue Feb 14 15:34:34 2006
+++ loncom/interface/lonprintout.pm Fri Feb 24 17:37:45 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.422 2006/02/14 20:34:34 albertel Exp $
+# $Id: lonprintout.pm,v 1.423 2006/02/24 22:37:45 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -226,6 +226,18 @@
$text =~ s/\\documentclass([^&]*)\\begin{document}//;
return $text;
}
+#
+# If necessary, encapsulate text inside
+# a minipage env.
+# necessity is determined by the problem_split param.
+#
+sub encapsulate_minipage {
+ my ($text) = @_;
+ if (!(env{'form.problem.split'} =~ /yes/i)) {
+ $text = '\begin{minipage}{\textwidth}'.$text.'\end{minipage}';
+ }
+ return $text;
+}
sub character_chart {
@@ -1116,6 +1128,9 @@
&Apache::lonnet::delenv('form.counter');
&Apache::lonnet::delenv('request.filename');
}
+ # current document with answers.. no need to encap in minipage
+ # since there's only one answer.
+
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
$form{'problem_split'}=$parmhash{'problem_stream_switch'};
@@ -1192,10 +1207,14 @@
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
} else {
+ # If necessary, encapsulate answer in minipage:
+
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
- $texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}).'}\vskip 0 mm ';
- $texversion.=&path_to_problem($urlp,$LaTeXwidth);
- $texversion.='\vskip 1 mm '.$answer.'\end{document}';
+ my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}).'}\vskip 0 mm ';
+ $body.=&path_to_problem($urlp,$LaTeXwidth);
+ $body.='\vskip 1 mm '.$answer.'\end{document}';
+ $body = &encapsulate_minipage($body);
+ $texversion.=$body;
}
}
if ($flag_latex_header_remove ne 'NO') {
@@ -1305,9 +1324,11 @@
} else {
if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
- $texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($master_seq[$i]).'}\vskip 0 mm ';
- $texversion.=&path_to_problem ($urlp,$LaTeXwidth);
- $texversion.='\vskip 1 mm '.$answer;
+ my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($master_seq[$i]).'}\vskip 0 mm ';
+ $body .= &path_to_problem ($urlp,$LaTeXwidth);
+ $body .='\vskip 1 mm '.$answer;
+ $body = &encapsulate_minipage($body);
+ $texversion .= $body;
} else {
$texversion='';
}
@@ -1777,10 +1798,14 @@
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
$rendered=~s/(\\keephidden{ENDOFPROBLEM})/$ansrendered$1/;
} else {
- $rendered=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
- $rendered.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($curresline).'}\vskip 0 mm ';
- $rendered.=&path_to_problem($res_url,$LaTeXwidth);
- $rendered.='\vskip 1 mm '.$ansrendered;
+
+
+ my $header =&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
+ my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($curresline).'}\vskip 0 mm ';
+ $body .=&path_to_problem($res_url,$LaTeXwidth);
+ $body .='\vskip 1 mm '.$ansrendered;
+ $body = &encapsulate_minipage($body);
+ $rendered = $header.$body;
}
}
if ($remove_latex_header eq 'YES') {