--- loncom/interface/lonprintout.pm 2004/03/15 20:27:57 1.270.2.2 +++ loncom/interface/lonprintout.pm 2004/01/16 18:36:25 1.271 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.270.2.2 2004/03/15 20:27:57 albertel Exp $ +# $Id: lonprintout.pm,v 1.271 2004/01/16 18:36:25 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -647,20 +647,6 @@ 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; @@ -710,7 +696,16 @@ ENDPART } my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle,$numberofcolumns); my $assignment = $ENV{'form.assignment'}; - my $LaTeXwidth=&recalcto_mm($textwidth); + 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'; + if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') { #-- single document - problem, page, html, xml, ... my $currentURL; @@ -737,12 +732,7 @@ ENDPART } 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'}=$LaTeXwidth; $form{'problem_split'}=$parmhash{'problem_stream_switch'}; $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; if ($helper->{'VARS'}->{'curseed'}) { @@ -752,7 +742,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'); } @@ -807,12 +797,7 @@ ENDPART 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'}=$LaTeXwidth; $form{'problem_split'}=$parmhash{'problem_stream_switch'}; $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; $form{'rndseed'}=$rndseed; @@ -858,12 +843,7 @@ ENDPART } 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'}=$LaTeXwidth; $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; my $texversion=&Apache::lonnet::ssi($currentURL,%form); $result .= $texversion; @@ -885,12 +865,7 @@ ENDPART #-- 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'}=$LaTeXwidth; $form{'problem_split'}=$parmhash{'problem_stream_switch'}; $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; my $flag_latex_header_remove = 'NO'; @@ -983,18 +958,13 @@ ENDPART #loop over students my $flag_latex_header_remove = 'NO'; my %moreenv; - if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && - $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { - $moreenv{'form.textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'}); - } else { - $moreenv{'form.textwidth'}=$LaTeXwidth; - } + $moreenv{'form.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) { my $current_output = ''; -# my ($usersection,$username,$userdomain) = split /:/,$person; - my ($username,$userdomain) = split /:/,$person; + my ($username,$userdomain,$usersection) = split /:/,$person; +# my ($username,$userdomain) = split /:/,$person; my $fullname = &get_name($username,$userdomain); if ($parmhash{'anonymous_quiz'}=~/yes/) {$fullname=' ';} #put here something reasonable for anonymous exams or quiz @@ -1041,6 +1011,7 @@ ENDPART } my $courseidinfo = &get_course(); if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } + if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection} my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header'); if ($current_output=~/\\documentclass/) { $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\lhead{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$currentassignment}}\\vskip 3 mm /; @@ -1074,12 +1045,7 @@ ENDPART 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'}=$LaTeXwidth; $form{'rndseed'}=$rndseed; if ($urlp =~ m|/home/([^/]+)/public_html|) { $urlp =~ s|/home/([^/]*)/public_html|/~$1|;