--- loncom/interface/lonprintout.pm 2004/09/22 20:49:45 1.316.2.2 +++ loncom/interface/lonprintout.pm 2004/08/16 17:11:10 1.325 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.316.2.2 2004/09/22 20:49:45 albertel Exp $ +# $Id: lonprintout.pm,v 1.325 2004/08/16 17:11:10 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -415,21 +415,107 @@ sub page_format { $topmargin = '3.5 in'; } } -# } elsif($papersize eq '1') { -# } elsif($papersize eq '2') { -# } elsif($papersize eq '3'/) { + } elsif($papersize eq '1') { + if ($layout eq 'book') { + if ($numberofcolumns == 1) { + $textwidth = '7.1 in'; + $textheight = '13 in'; + $oddoffset = '-0.57 in'; + $evenoffset = '-0.57 in'; + $topmargin = '-0.5 in'; + } elsif ($numberofcolumns == 2) { + $textwidth = '3.66 in'; + $textheight = '13 in'; + $oddoffset = '-0.57 in'; + $evenoffset = '-0.57 in'; + $topmargin = '-0.5 in'; + } + } elsif ($layout eq 'album') { + if ($numberofcolumns eq '1') { +# $textwidth = '8.8 in'; +# $textheight = '6.8 in'; +# $oddoffset = '-40 pt'; +# $evenoffset = '-60 pt'; + } elsif ($numberofcolumns == 2) { +# $textwidth = '4.4 in'; +# $textheight = '6.8 in'; +# $oddoffset = '-0.5 in'; +# $evenoffset = '-1.5 in'; +# $topmargin = '3.5 in'; + } + } + } elsif($papersize eq '2') { + if ($layout eq 'book') { + if ($numberofcolumns == 1) { + $textwidth = '9.8 in'; + $textheight = '16 in'; + $oddoffset = '-0.57 in'; + $evenoffset = '-0.57 in'; + $topmargin = '-0.5 in'; + } elsif ($numberofcolumns == 2) { + $textwidth = '4.9 in'; + $textheight = '16 in'; + $oddoffset = '-0.57 in'; + $evenoffset = '-0.57 in'; + $topmargin = '-0.5 in'; + } + } elsif ($layout eq 'album') { + if ($numberofcolumns eq '1') { +# $textwidth = '8.8 in'; +# $textheight = '6.8 in'; +# $oddoffset = '-40 pt'; +# $evenoffset = '-60 pt'; + } elsif ($numberofcolumns == 2) { +# $textwidth = '4.4 in'; +# $textheight = '6.8 in'; +# $oddoffset = '-0.5 in'; +# $evenoffset = '-1.5 in'; +# $topmargin = '3.5 in'; + } + } + } elsif($papersize eq '3') { + if ($layout eq 'book') { + if ($numberofcolumns == 1) { + $textwidth = '6.8 in'; + $textheight = '9 in'; + $oddoffset = '-0.57 in'; + $evenoffset = '-0.57 in'; + $topmargin = '1.2 in'; + } elsif ($numberofcolumns == 2) { + $textwidth = '3.1 in'; + $textheight = '9 in'; + $oddoffset = '-0.57 in'; + $evenoffset = '-0.57 in'; + $topmargin = '1.2 in'; + } + } elsif ($layout eq 'album') { + if ($numberofcolumns eq '1') { +# $textwidth = '8.8 in'; +# $textheight = '6.8 in'; +# $oddoffset = '-40 pt'; +# $evenoffset = '-60 pt'; + } elsif ($numberofcolumns == 2) { +# $textwidth = '4.4 in'; +# $textheight = '6.8 in'; +# $oddoffset = '-0.5 in'; +# $evenoffset = '-1.5 in'; +# $topmargin = '3.5 in'; + } + } } elsif($papersize eq '6') { if ($layout eq 'book') { if ($numberofcolumns == 1) { $textwidth = '176 mm'; - $textheight = '254 mm'; + $textheight = '272 mm'; $oddoffset = '-0.57 in'; $evenoffset = '-0.57 in'; + $topmargin = '-0.5 in'; } elsif ($numberofcolumns == 2) { $textwidth = '91 mm'; - $textheight = '254 mm'; + $textheight = '272 mm'; $oddoffset = '-0.57 in'; $evenoffset = '-0.57 in'; + $topmargin = '-0.5 in'; } } elsif ($layout eq 'album') { if ($numberofcolumns eq '1') { @@ -444,8 +530,8 @@ sub page_format { $evenoffset = '-60 pt'; } } -# } elsif($papersize eq '5') { # } elsif($papersize eq '4') { +# } elsif($papersize eq '5') { # } elsif($papersize eq '7') { # } elsif($papersize eq '8') { } @@ -483,15 +569,24 @@ sub page_format_transformation { my $name = &get_name(); my $courseidinfo = &get_course(); if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } + my $topmargintoinsert = ''; + if ($topmargin ne '0') {$topmargintoinsert='\setlength{\topmargin}{'.$topmargin.'}';} + my $fancypagestatement=''; + if ($numberofcolumns eq '2') { + $fancypagestatement="\\fancyhead{}\\fancyhead[LO]{\\textbf{$name} $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}"; + } else { + $fancypagestatement="\\rhead{}\\chead{}\\lhead{\\textbf{$name} $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}"; + } if ($layout eq 'album') { - my $topmargintoinsert = ''; - if ($topmargin ne '0') {$topmargintoinsert='\setlength{\topmargin}{'.$topmargin.'}';} - $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}$topmargintoinsert\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\usepackage{fancyhdr}\\pagestyle{fancy}\\rhead{}\\chead{}\\lhead{\\textbf{$name} $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}} \\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1} /; + $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}$topmargintoinsert\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\usepackage{fancyhdr}\\pagestyle{fancy}$fancypagestatement\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1} /; } elsif ($layout eq 'book') { if ($choice ne 'All class print') { - $text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\usepackage{fancyhdr}\\pagestyle{fancy}\\rhead{}\\chead{}\\lhead{\\textbf{$name} $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}/; + $text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset $topmargintoinsert\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\usepackage{fancyhdr}\\pagestyle{fancy}$fancypagestatement\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}/; } else { - $text =~ s/\\pagestyle{fancy}\\rhead{}\\chead{}\s*\\begin{document}/\\textheight = $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\begin{document}\\voffset=-0\.8cm\\setcounter{page}{1} \\vskip 5 mm /; + $text =~ s/\\pagestyle{fancy}\\rhead{}\\chead{}\s*\\begin{document}/\\textheight = $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset $topmargintoinsert\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\begin{document}\\voffset=-0\.8cm\\setcounter{page}{1} \\vskip 5 mm /; + } + if ($papersize eq '6') { + $text =~ s/(\\begin{document})/$1\\special{papersize=210mm,297mm}/; } } if ($tableofcontents eq 'yes') {$text=~s/(\\setcounter\{page\}\{1\})/$1 \\tableofcontents\\newpage /;} @@ -629,21 +724,24 @@ sub print_latex_header { } sub path_to_problem { - my ($urlp,$colwidth)=@_; + my ($urlp,$LaTeXwidth)=@_; my $newurlp = ''; - $colwidth=~s/\s*mm\s*$//; -#characters average about 2 mm in width - if (length($urlp)*2 > $LaTeXwidth) { - my @elements = split '/',$urlp; - my $curlength=0; - foreach my $element (@elements) { - if ($curlength+(length($element)*2) > $colwidth) { - $newurlp .= '|\vskip -1 mm \noindent \verb|'; - $curlength=0; - } else { - $curlength+=length($element)*2; + $LaTeXwidth=~s/\s*mm\s*$//; + my $HowMany = length($urlp)*2; + if ($HowMany > $LaTeXwidth) { + my @temporrary = split '/',$urlp; + my $HowManyNew = 0; + for (my $ii=0;$ii<=$#temporrary;$ii++) { + if ($temporrary[$ii] ne '') { + $HowManyNew += length($temporrary[$ii])*2; + if ($HowManyNew < $LaTeXwidth ) { + $newurlp .= '/'.$temporrary[$ii]; + } else { + $HowManyNew = 0; + $newurlp .= '|\vskip -1 mm \noindent \verb|'; + $ii--; + } } - $newurlp.='/'.$element; } } else { $newurlp=$urlp; @@ -1031,11 +1129,10 @@ ENDPART #loop over students my $flag_latex_header_remove = 'NO'; my %moreenv; - $moreenv{'instructor_comments'}='hide'; $moreenv{'textwidth'}=&get_textwidth($helper,$LaTeXwidth); $moreenv{'print_discussions'}=$helper->{'VARS'}->{'PRINT_DISCUSSIONS'}; if ($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') {$moreenv{'problem_split'}='yes';} - my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1); + my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1,'inline','75'); my $student_counter=-1; foreach my $person (@students) { my $duefile="/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.due"; @@ -1261,7 +1358,9 @@ ENDPART 'cgi.'.$identifier.'backref' => $URLback,); $r->print(< +Continue FINALEND @@ -1294,7 +1393,9 @@ sub print_resources { my $current_output = ''; my ($username,$userdomain,$usersection) = split /:/,$person; my $fullname = &get_name($username,$userdomain); + my $namepostfix; if ($person =~ 'anon') { + $namepostfix="\\\\Name: "; $fullname = "CODE - ".$moreenv->{'CODE'}; } #goes through all resources, checks if they are available for @@ -1368,11 +1469,11 @@ sub print_resources { 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 /; + $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\lhead{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$currentassignment}$namepostfix}\\vskip 3 mm /; } else { my $blankpages = ''; for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blankpages.='\clearpage\strut\clearpage';} - $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}}} \vskip -5 mm '.$current_output; + $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}'.$namepostfix.'}} \vskip -5 mm '.$current_output; } return ($current_output,$fullname);