[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 23 Mar 2004 16:17:49 -0000
albertel Tue Mar 23 11:17:49 2004 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
- refactoring textwidht computation
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.284 loncom/interface/lonprintout.pm:1.285
--- loncom/interface/lonprintout.pm:1.284 Mon Mar 22 20:34:17 2004
+++ loncom/interface/lonprintout.pm Tue Mar 23 11:17:48 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.284 2004/03/23 01:34:17 albertel Exp $
+# $Id: lonprintout.pm,v 1.285 2004/03/23 16:17:48 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -661,6 +661,16 @@
return $LaTeXwidth;
}
+sub get_textwidth {
+ my ($helper,$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;
+ }
+}
+
sub output_data {
my ($r,$helper,$rparmhash) = @_;
my %parmhash = %$rparmhash;
@@ -740,12 +750,7 @@
}
my %form;
$form{'grade_target'}='tex';
- 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{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
$form{'problem_split'}=$parmhash{'problem_stream_switch'};
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
if ($helper->{'VARS'}->{'curseed'}) {
@@ -810,12 +815,7 @@
if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') {
my %form;
$form{'grade_target'}='tex';
- 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{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
$form{'problem_split'}=$parmhash{'problem_stream_switch'};
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
$form{'rndseed'}=$rndseed;
@@ -861,12 +861,7 @@
} elsif ($currentURL=~/\/smppg$/) {
my %form;
$form{'grade_target'}='tex';
- 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{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
my $texversion=&Apache::lonnet::ssi($currentURL,%form);
$result .= $texversion;
@@ -888,12 +883,7 @@
#-- produce an output string
my %form=();
$form{'grade_target'}='tex';
- 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{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
$form{'problem_split'}=$parmhash{'problem_stream_switch'};
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
my $flag_latex_header_remove = 'NO';
@@ -994,12 +984,7 @@
#loop over students
my $flag_latex_header_remove = 'NO';
my %moreenv;
- 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;
- }
+ $moreenv{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1);
my $student_counter=-1;
foreach my $person (@students) {
@@ -1034,12 +1019,7 @@
if ($urlp=~/\//) {
my %form;
$form{'grade_target'}='tex';
- 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{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
$form{'rndseed'}=$rndseed;
if ($urlp =~ m|/home/([^/]+)/public_html|) {
$urlp =~ s|/home/([^/]*)/public_html|/~$1|;