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

sakharuk lon-capa-cvs@mail.lon-capa.org
Mon, 09 Feb 2004 20:41:36 -0000


sakharuk		Mon Feb  9 15:41:36 2004 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  Bug 2708 (one column printing does not respect width settings) is fixed. But I have found a few more general issues which can influence the output + I need to make some small fixing (only capital E in 1E+4 for example). Continue work with this.
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.274 loncom/interface/lonprintout.pm:1.275
--- loncom/interface/lonprintout.pm:1.274	Thu Feb  5 13:35:58 2004
+++ loncom/interface/lonprintout.pm	Mon Feb  9 15:41:36 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.274 2004/02/05 18:35:58 sakharuk Exp $
+# $Id: lonprintout.pm,v 1.275 2004/02/09 20:41:36 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -647,6 +647,20 @@
     return '{\small\noindent\verb|'.$newurlp.'|\vskip 0 mm}';
 }
 
+sub recalcto_mm {
+    my $textwidth=shift;
+    my $LaTeXwidth;
+    if ($textwidth=~/(\d+\.?\d*)\s*cm/) {
+	$LaTeXwidth = $1*10;
+    } elsif ($textwidth=~/(\d+\.?\d*)\s*mm/) {
+	$LaTeXwidth = $1;
+    } elsif ($textwidth=~/(\d+\.?\d*)\s*in/) {
+	$LaTeXwidth = $1*25.4;
+    }
+    $LaTeXwidth.=' mm';
+    return $LaTeXwidth;
+}
+
 sub output_data {
     my ($r,$helper,$rparmhash) = @_;
     my %parmhash = %$rparmhash;
@@ -696,15 +710,7 @@
     }
     my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle,$numberofcolumns);
     my $assignment =  $ENV{'form.assignment'};
-    my $LaTeXwidth; 
-    if ($textwidth=~/(\d+\.?\d*)\s*cm/) {
-	$LaTeXwidth = $1*10;
-    } elsif ($textwidth=~/(\d+\.?\d*)\s*mm/) {
-	$LaTeXwidth = $1;
-    } elsif ($textwidth=~/(\d+\.?\d*)\s*in/) {
-	$LaTeXwidth = $1*25.4;
-    }
-    $LaTeXwidth.=' mm';
+    my $LaTeXwidth=&recalcto_mm($textwidth); 
     my @print_array=();
     my @student_names=();
     
@@ -734,7 +740,12 @@
 		}
 		my %form;
 		$form{'grade_target'}='tex';
-		$form{'textwidth'}=$LaTeXwidth;	
+		if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&
+                    $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {
+		    $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});
+		} else {
+		    $form{'textwidth'}=$LaTeXwidth;
+		}
 		$form{'problem_split'}=$parmhash{'problem_stream_switch'};
 		$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
 		if ($helper->{'VARS'}->{'curseed'}) {
@@ -744,7 +755,7 @@
 		&Apache::lonnet::appenv(%moreenv);
 		&Apache::lonnet::delenv('form.counter');
 		&Apache::lonxml::init_counter();
-		$texversion=&Apache::lonnet::ssi($currentURL,%form);
+		$texversion.=&Apache::lonnet::ssi($currentURL,%form);
 		&Apache::lonnet::delenv('form.counter');
 		&Apache::lonnet::delenv('request.filename');
 	    }
@@ -799,7 +810,12 @@
 		    if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') {
 			my %form;
 			$form{'grade_target'}='tex';
-			$form{'textwidth'}=$LaTeXwidth;
+			if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&
+			    $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {
+			    $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});
+			} else {
+			    $form{'textwidth'}=$LaTeXwidth;
+			}
 			$form{'problem_split'}=$parmhash{'problem_stream_switch'};
 			$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
 			$form{'rndseed'}=$rndseed;
@@ -845,7 +861,12 @@
 	} elsif ($currentURL=~/\/smppg$/) { 
 		my %form;
 		$form{'grade_target'}='tex';
-		$form{'textwidth'}=$LaTeXwidth;	
+		if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&
+                    $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {
+		    $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});
+		} else {
+		    $form{'textwidth'}=$LaTeXwidth;
+		}	
 		$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
 		my $texversion=&Apache::lonnet::ssi($currentURL,%form);
 		$result .= $texversion;
@@ -867,7 +888,12 @@
         #-- produce an output string
 	my %form=();	   
 	$form{'grade_target'}='tex';
-	$form{'textwidth'}=$LaTeXwidth;
+	if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&
+	    $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {
+	    $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});
+	} else {
+	    $form{'textwidth'}=$LaTeXwidth;
+	}
 	$form{'problem_split'}=$parmhash{'problem_stream_switch'};
 	$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
 	my $flag_latex_header_remove = 'NO';
@@ -961,7 +987,12 @@
 	 #loop over students
 	 my $flag_latex_header_remove = 'NO'; 
 	 my %moreenv;
-	 $moreenv{'form.textwidth'}=$LaTeXwidth;
+	 if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&
+	     $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {
+	     $moreenv{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});
+	 } else {
+	     $moreenv{'textwidth'}=$LaTeXwidth;
+	 }
 	 &Apache::lonnet::appenv(%moreenv);
 	 my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1);
 	 my $student_counter=-1;
@@ -1050,7 +1081,12 @@
 	    if ($urlp=~/\//) {
 		my %form;
 		$form{'grade_target'}='tex';
-		$form{'textwidth'}=$LaTeXwidth;
+		if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&
+                    $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {
+		    $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});
+		} else {
+		    $form{'textwidth'}=$LaTeXwidth;
+		}
 		$form{'rndseed'}=$rndseed;
 		if ($urlp =~ m|/home/([^/]+)/public_html|) {
 		    $urlp =~ s|/home/([^/]*)/public_html|/~$1|;