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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 15 Dec 2005 21:10:31 -0000


albertel		Thu Dec 15 16:10:31 2005 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  - BUG#4499 - endline was overpriinting the answers
  - prining resources for selected students was not working
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.407 loncom/interface/lonprintout.pm:1.408
--- loncom/interface/lonprintout.pm:1.407	Thu Dec 15 14:08:14 2005
+++ loncom/interface/lonprintout.pm	Thu Dec 15 16:10:30 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.407 2005/12/15 19:08:14 albertel Exp $
+# $Id: lonprintout.pm,v 1.408 2005/12/15 21:10:30 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -750,15 +750,14 @@
 
 
 sub latex_corrections {
-
-    my ($number_of_columns,$result,$selectionmade) = @_;
+    my ($number_of_columns,$result,$selectionmade,$answer_mode) = @_;
 
 #    $result =~ s/\\includegraphics{/\\includegraphics\[width=\\minipagewidth\]{/g;
     $result =~ s/\$number_of_columns/$number_of_columns/g;
-    if ($selectionmade ne '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  $1/;
+    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/;
     } else {
-	$result =~ s/(\\end{document})/\\strut\\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  $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;
@@ -1402,7 +1401,8 @@
 						     $person,$type,
 						     \%moreenv,\@master_seq,
 						     $flag_latex_header_remove,
-						     $LaTeXwidth);
+						     $LaTeXwidth,
+						     $number_of_columns);
 	     $resources_printed .= ":";
 	     $print_array[$i].=$output;
 	     $student_names[$i].=$person.':'.$fullname.'_END_';
@@ -1578,8 +1578,14 @@
     }
 #-------------------------------------------------------- corrections for the different page formats
     $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);
-    for (my $i=1;$i<=$#print_array;$i++) {$print_array[$i] = &latex_corrections($number_of_columns,$print_array[$i],$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'});
+    }
     #changes page's parameters for the one column output 
     if ($numberofcolumns == 1) {
 	$result =~ s/\\textwidth\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /;
@@ -1701,7 +1707,7 @@
 
 sub print_resources {
     my ($r,$helper,$person,$type,$moreenv,$master_seq,$remove_latex_header,
-	$LaTeXwidth)=@_;
+	$LaTeXwidth,$number_of_columns)=@_;
     my $current_output = ''; 
     my $printed = '';
     my ($username,$userdomain,$usersection) = split /:/,$person;
@@ -1767,7 +1773,7 @@
 		    $printed .= $curresline.':';
 		    my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);
 		    my ($envfile) = 
-			( $env{'user.environment'} = ~m|/([^/]+)\.id$| );
+			( $env{'user.environment'} =~ m|/([^/]+)\.id$| );
 		    &Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'),
 							     $envfile);
 		    my $current_counter=$env{'form.counter'};
@@ -1776,7 +1782,7 @@
 		    } else {
 			$rendered =~ s/\\end{document}//;
 		    }
-		    $current_output .= $rendered.'\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\strut \vskip 0 mm \strut ';
+		    $current_output .= $rendered.'\vskip 0.5mm\noindent\makebox[\textwidth/'.$number_of_columns.'][b]{\hrulefill}\strut \vskip 0 mm \strut ';
 		} else {
 		    my $rendered = &unsupported($res_url,$helper->{'VARS'}->{'LATEX_TYPE'});
 		    if ($remove_latex_header ne 'NO') {