[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm printout.pl

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 03 Aug 2006 00:26:42 -0000


albertel		Wed Aug  2 20:26:42 2006 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm printout.pl 
  Log:
  - BUG#4950 the ENDOFSTUDENTSTAMP was being placed not at the actual
    end of a student but at the begining of the next student this could cause
    oddities when  you had exactly the right number of columns sepicified
  - additionaly the final student was getting blank columns inserted
  - switch to using \clearpage\strut\clearpage to cause the blank columns
    like lonprintout.pm does
  
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.474 loncom/interface/lonprintout.pm:1.475
--- loncom/interface/lonprintout.pm:1.474	Wed Aug  2 16:49:55 2006
+++ loncom/interface/lonprintout.pm	Wed Aug  2 20:26:39 2006
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.474 2006/08/02 20:49:55 www Exp $
+# $Id: lonprintout.pm,v 1.475 2006/08/03 00:26:39 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -833,9 +833,9 @@
 #    $result =~ s/\\includegraphics{/\\includegraphics\[width=\\minipagewidth\]{/g;
     $result =~ s/\$number_of_columns/$number_of_columns/g;
     if ($selectionmade eq '1' || $answer_mode eq 'only') {
-	$result =~ s/(\\end{document})/\\strut\\vskip 0 mm\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License  $1/;
+	$result =~ s/(\\end{document})/\\strut\\vskip 0 mm\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License \newpage \n\\special{ps:ENDOFSTUDENTSTAMP}\n $1/;
     } else {
-	$result =~ s/(\\end{document})/\\strut\\vspace\*{-4 mm}\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License  $1/;
+	$result =~ s/(\\end{document})/\\strut\\vspace\*{-4 mm}\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License \newpage \n\\special{ps:ENDOFSTUDENTSTAMP}\n $1/;
     }
     $result =~ s/(\\end{longtable}\s*)(\\strut\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill})/$2$1/g;
     $result =~ s/(\\end{longtable}\s*)\\strut\\newline/$1/g;
@@ -1754,12 +1754,6 @@
     $result = &page_format_transformation($papersize,$laystyle,$numberofcolumns,$helper->{'VARS'}->{'PRINT_TYPE'},$result,$helper->{VARS}->{'assignment'},$helper->{'VARS'}->{'TABLE_CONTENTS'},$helper->{'VARS'}->{'TABLE_INDEX'},$selectionmade);
     $result = &latex_corrections($number_of_columns,$result,$selectionmade,
 				 $helper->{'VARS'}->{'ANSWER_TYPE'});
-    for (my $i=1;$i<=$#print_array;$i++) {
-	$print_array[$i] = 
-	    &latex_corrections($number_of_columns,$print_array[$i],
-			       $selectionmade, 
-			       $helper->{'VARS'}->{'ANSWER_TYPE'});
-    }
     #if ($numberofcolumns == 1) {
 	$result =~ s/\\textwidth\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /;
 	$result =~ s/\\textheight\s*=?\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textheight $helper->{'VARS'}->{'pagesize.height'} $helper->{'VARS'}->{'pagesize.heightunit'} /;
@@ -1786,9 +1780,15 @@
 	    if ($i==0) {
 		$print_array[$i]=$result;
 	    } else {
+		$print_array[$i].='\end{document}';
+		$print_array[$i] = 
+		    &latex_corrections($number_of_columns,$print_array[$i],
+				       $selectionmade, 
+				       $helper->{'VARS'}->{'ANSWER_TYPE'});
+
 		my $anobegin=index($print_array[$i],'\setcounter{page}',0);
 		substr($print_array[$i],0,$anobegin)='';
-		$print_array[$i]=$inc.$print_array[$i].'\end{document}';
+		$print_array[$i]=$inc.$print_array[$i];
 	    }
 	    my $temp_file;
 	    my $newfilename=$filename;
@@ -2003,15 +2003,14 @@
 	my $blankpages = '';
 	for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blankpages.='\clearpage\strut\clearpage';}
 	if ($columns_in_format == 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{'.$HeaderLine.'}'.$namepostfix.'} \vskip 5 mm '.$current_output;
+	    $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."\n\\special{ps:ENDOFSTUDENTSTAMP}\n".'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{'.$HeaderLine.'}'.$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]{'.$HeaderLine.'}'.$namepostfix.'} \vskip 5 mm '.$current_output;
+	   $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."\n\\special{ps:ENDOFSTUDENTSTAMP}\n".'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{'.$HeaderLine.'}'.$namepostfix.'} \vskip 5 mm '.$current_output;
 	}
     }
     #
     #  Close the student bracketing.
     #
-    $current_output .= "\n\\special{ps:ENDOFSTUDENTSTAMP}\n";
     return ($current_output,$fullname, $printed);
 
 }
Index: loncom/interface/printout.pl
diff -u loncom/interface/printout.pl:1.107 loncom/interface/printout.pl:1.108
--- loncom/interface/printout.pl:1.107	Thu Jun 29 21:24:41 2006
+++ loncom/interface/printout.pl	Wed Aug  2 20:26:39 2006
@@ -830,7 +830,7 @@
 	    my $addlines = $max_pages - $pages_in_student[$student_number];
 	    &Apache::lonnet::logthis("student: $pages_in_student[$student_number] add: $addlines");
 	    while($addlines)  {
-		print LATEXOUT '\linebreak \strut \pagebreak';
+		print LATEXOUT '\clearpage \strut \clearpage';
 
 		$addlines--;
 	    }
@@ -846,7 +846,7 @@
 
     close(LATEXIN);
     close(LATEXOUT);
-   rename($outfilename, $latex_filename);
+    rename($outfilename, $latex_filename);
 
 }