--- loncom/interface/lonprintout.pm 2004/01/15 21:23:22 1.270 +++ loncom/interface/lonprintout.pm 2004/02/19 19:35:06 1.270.2.1 @@ -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 @@ sub path_to_problem { 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 @@ ENDPART } 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 @@ ENDPART } 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 @@ ENDPART &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 @@ ENDPART 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 @@ ENDPART } 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 @@ ENDPART #-- 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 @@ ENDPART #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 @@ ENDPART 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|;