--- loncom/interface/lonprintout.pm 2006/01/17 18:39:50 1.415 +++ loncom/interface/lonprintout.pm 2006/01/26 23:15:54 1.416 @@ -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 @@ sub page_format_transformation { 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 @@ sub recently_generated { # 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 @@ ENDPART &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 @@ ENDPART 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 @@ sub print_resources { 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 @@ sub handler { &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}.'<-
'); -# } -# foreach $key (keys %env) { -# $r->print(' '.$key.'->'.$env{$key}.'<-
'); -# } -# return OK; my %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'}); -# my $key; -# foreach $key (keys %parmhash) { -# $r->print(' '.$key.'->'.$parmhash{$key}.'<-
'); -# } -# + # If a figure conversion queue file exists for this user.domain @@ -1879,7 +1885,7 @@ sub addMessage { Apache::lonhelper::message->new(); } -use Data::Dumper; + sub init_perm { undef(%perm); @@ -1941,7 +1947,7 @@ sub printHelper { # 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 @@ sub printHelper { } } - + # This will persistently load in the data we want from the # very first screen. @@ -1978,6 +1984,7 @@ sub printHelper { if ($env{'form.url'}) { $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'}); } + } if ($env{'form.symb'}) { @@ -2064,9 +2071,7 @@ sub printHelper { $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 @@ RNDSEED $helper->process(); + # MANUAL BAILOUT CONDITION: # If we're in the "final" state, bailout and return to handler if ($helper->{STATE} eq 'FINAL') {