[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
foxr
lon-capa-cvs@mail.lon-capa.org
Thu, 26 Jan 2006 23:15:58 -0000
foxr Thu Jan 26 18:15:58 2006 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
defect 4467: Fixed wiping out of FINISHPAGE variable which prevented the
page breaks to go at the right place in 1 col mode due to the extra state
in the print helper.
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.415 loncom/interface/lonprintout.pm:1.416
--- loncom/interface/lonprintout.pm:1.415 Tue Jan 17 13:39:50 2006
+++ loncom/interface/lonprintout.pm Thu Jan 26 18:15:54 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.415 2006/01/17 18:39:50 albertel Exp $
+# $Id: lonprintout.pm,v 1.416 2006/01/26 23:15:54 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -687,6 +687,7 @@
my $topmargintoinsert = '';
if ($topmargin ne '0') {$topmargintoinsert='\setlength{\topmargin}{'.$topmargin.'}';}
my $fancypagestatement='';
+# &Apache::lonnet::logthis("1: columns = $numberofcolumns");
if ($numberofcolumns eq '2') {
$fancypagestatement="\\fancyhead{}\\fancyhead[LO]{\\textbf{$name} $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}";
} else {
@@ -963,15 +964,20 @@
# A reference to a page break hash.
#
#
+#use Data::Dumper;
+#sub dump_helper_vars {
+# my ($helper) = @_;
+# my $helpervars = Dumper($helper->{'VARS'});
+# &Apache::lonnet::logthis("Dump of helper vars:\n $helpervars");
+#}
sub get_page_breaks {
my ($helper) = @_;
my %page_breaks;
-
+
foreach my $break (split /\|\|\|/, $helper->{'VARS'}->{'FINISHPAGE'}) {
$page_breaks{$break} = 1;
}
-
return %page_breaks;
}
@@ -1253,6 +1259,7 @@
&Apache::lonnet::delenv('form.counter');
&Apache::lonxml::init_counter();
&Apache::lonxml::store_counter();
+ my $pbreakresources = keys %page_breaks;
for (my $i=0;$i<=$#master_seq;$i++) {
# Note due to document structure, not allowed to put \newpage
@@ -1322,7 +1329,12 @@
my $courseidinfo = &get_course();
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
$prevassignment=$assignment;
- $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip 5 mm ';
+# &Apache::lonnet::logthis("2: Number of columns: $number_of_columns");
+ if ($number_of_columns eq '1') {
+ $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip 5 mm ';
+ } else {
+ $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip 5 mm ';
+ }
}
$result .= $texversion;
$flag_latex_header_remove = 'YES';
@@ -1812,11 +1824,22 @@
if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection}
my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header');
if ($current_output=~/\\documentclass/) {
- $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\lhead{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$currentassignment}$namepostfix}}\\vskip 5 mm /;
+# &Apache::lonnet::logthis("3: Number of columns = $number_of_columns");
+ if ($number_of_columns == 1) {
+ $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\lhead{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$currentassignment}$namepostfix}}\\vskip 5 mm /;
+ } else {
+ $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fancyhead[LO]{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$currentassignment}$namepostfix}}\\vskip 5 mm /;
+
+ }
} else {
my $blankpages = '';
for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blankpages.='\clearpage\strut\clearpage';}
- $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}'.$namepostfix.'}} \vskip 5 mm '.$current_output;
+# &Apache::lonnet::logthis("4: Number of columns = $number_of_columns");
+ if ($number_of_columns == 1) {
+ $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}'.$namepostfix.'}} \vskip 5 mm '.$current_output;
+ } else {
+ $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}'.$namepostfix.'}} \vskip 5 mm '.$current_output;
+ }
}
return ($current_output,$fullname, $printed);
@@ -1828,34 +1851,17 @@
&init_perm();
-# my $loaderror=&Apache::lonnet::overloaderror($r);
-# if ($loaderror) { return $loaderror; }
-# $loaderror=
-# &Apache::lonnet::overloaderror($r,
-# $env{'course.'.$env{'request.course.id'}.'.home'});
-# if ($loaderror) { return $loaderror; }
+
my $helper = printHelper($r);
if (!ref($helper)) {
return $helper;
}
-# my $key;
-# foreach $key (keys %{$helper->{'VARS'}}) {
-# $r->print(' '.$key.'->'.$helper->{'VARS'}->{$key}.'<-<br />');
-# }
-# foreach $key (keys %env) {
-# $r->print(' '.$key.'->'.$env{$key}.'<-<br />');
-# }
-# return OK;
my %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'});
-# my $key;
-# foreach $key (keys %parmhash) {
-# $r->print(' '.$key.'->'.$parmhash{$key}.'<-<br />');
-# }
-#
+
# If a figure conversion queue file exists for this user.domain
@@ -1879,7 +1885,7 @@
Apache::lonhelper::message->new();
}
-use Data::Dumper;
+
sub init_perm {
undef(%perm);
@@ -1941,7 +1947,7 @@
# But we only do this in the initial state so that they are allowed to change.
#
- $helper->{VARS}->{FINISHPAGE} = '';
+ # $helper->{VARS}->{FINISHPAGE} = '';
&Apache::loncommon::restore_course_settings('print',
{'pagebreaks' => 'scalar',
@@ -1960,7 +1966,7 @@
}
}
-
+
# This will persistently load in the data we want from the
# very first screen.
@@ -1978,6 +1984,7 @@
if ($env{'form.url'}) {
$helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
}
+
}
if ($env{'form.symb'}) {
@@ -2064,9 +2071,7 @@
$helper->declareVar('SEQUENCE');
- # Useful for debugging: Dump the help vars
-# $r->print(Dumper($helper->{VARS}));
-# $r->print($map);
+
# If we're in a sequence...
if (($helper->{'VARS'}->{'construction'} ne '1') &&
@@ -2547,6 +2552,7 @@
$helper->process();
+
# MANUAL BAILOUT CONDITION:
# If we're in the "final" state, bailout and return to handler
if ($helper->{STATE} eq 'FINAL') {