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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 14 Sep 2006 17:04:43 -0000


albertel		Thu Sep 14 13:04:43 2006 EDT

  Modified files:              
    /loncom/interface	printout.pl 
  Log:
  - BUG#5017, extra page at end of printing when priting multiple users
  
  
Index: loncom/interface/printout.pl
diff -u loncom/interface/printout.pl:1.109 loncom/interface/printout.pl:1.110
--- loncom/interface/printout.pl:1.109	Mon Aug 14 06:52:30 2006
+++ loncom/interface/printout.pl	Thu Sep 14 13:04:42 2006
@@ -747,12 +747,11 @@
     my $line;
     my $total_pages;		# Total pages in document.
     my $seen_pages        = 0;	# There are several %%Pages only the first is useful
-    my $student_number    = 0;	# Index of student we're working on.
     my @pages_in_student;	# For each student his/her initial page count.
     my $max_pages = 0;		# Pages in 'longest' student.
     my $page_number = 0;
     &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state, 
-					  "Counting pages for student: ".$student_number+1);
+					  &mt("Counting pages for student: [_1]",1));
 
     while ($line = <PSFILE>) {
 	
@@ -774,26 +773,32 @@
 	    my @pageinfo = split(/ /, $line);
 	    if ($page_number < $pageinfo[1]) {
 		$page_number = $pageinfo[1];
+	    } elsif ($pageinfo[2] ne 1) {
+		#  current page count reset, and it's not because of a 
+		#    minipage 
+		# - save the page_number, reset and, if necessary
+		#    update max_pages.
+		push(@pages_in_student, $page_number);
+		&Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state, 
+						      &mt("Counting pages for student: [_1]", scalar(@pages_in_student)));
+		if ($page_number > $max_pages) {
+		    $max_pages = $page_number;
+		}
+		$page_number = $pageinfo[1];
 	    }
 	}
-	#  ENDOFSTUDENTSTAMP - save the page_number, reset and, if necessary
-	#                      udpate max_pages.
-	#
-	if ($line =~ /ENDOFSTUDENTSTAMP/) {
-	    $pages_in_student[$student_number] = $page_number;
-	    $student_number++;
-	    &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state, 
-						  "Counting pages for student: ".$student_number+1);
-	    
-	    if ($page_number > $max_pages) {
-		$max_pages = $page_number;
-	    }
-	    $page_number = 0;
-	 
-	}
 
 	
     }
+    # file ended so one more student
+    push(@pages_in_student, $page_number);
+    &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state, 
+					  &mt("Counting pages for student: [_1]",scalar(@pages_in_student)));
+    if ($page_number > $max_pages) {
+	$max_pages = $page_number;
+    }
+    $page_number = 0;
+    
     close(PSFILE);
 
     #  If 2 columns, max_pages must go to an even number of columns:
@@ -814,7 +819,7 @@
     open(LATEXOUT, ">$outfilename");
 
 
-    $student_number = 0;	# first student...
+    my $student_number    = 0;	# Index of student we're working on.
     &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state, 
 					  "Repaginating student ".$student_number+1);