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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 19 Feb 2004 19:35:07 -0000


albertel		Thu Feb 19 14:35:07 2004 EDT

  Modified files:              (Branch: version_1_1_X)
    /loncom/interface	lonprintout.pm 
  Log:
  - backport 1.275
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.270 loncom/interface/lonprintout.pm:1.270.2.1
--- loncom/interface/lonprintout.pm:1.270	Thu Jan 15 16:23:22 2004
+++ loncom/interface/lonprintout.pm	Thu Feb 19 14:35:06 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.270 2004/01/15 21:23:22 sakharuk Exp $
+# $Id: lonprintout.pm,v 1.270.2.1 2004/02/19 19:35:06 albertel 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,16 +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);
     if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') {
       #-- single document - problem, page, html, xml, ...
 	my $currentURL;
@@ -732,7 +737,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'}) {
@@ -742,7 +752,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');
 	    }
@@ -797,7 +807,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;
@@ -843,7 +858,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;
@@ -865,7 +885,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';
@@ -958,7 +983,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);
 	 foreach my $person (@students) {
@@ -1044,7 +1074,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|;