--- loncom/interface/lonprintout.pm 2002/11/14 20:02:00 1.88 +++ loncom/interface/lonprintout.pm 2002/11/19 15:45:25 1.92 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.88 2002/11/14 20:02:00 sakharuk Exp $ +# $Id: lonprintout.pm,v 1.92 2002/11/19 15:45:25 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -107,7 +107,7 @@ ENDMENUOUT6 } my $subdirtoprint = &Apache::lonnet::filelocation("",$ENV{'form.url'}); $subdirtoprint =~ s/\/[^\/]+$//; - if (&Apache::lonnet::allowed('bre',$subdirtoprint) eq 'F') { + if ((&Apache::lonnet::allowed('bre',$subdirtoprint) eq 'F') and ($ENV{'form.postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/)) { $r->print(< Problems from current subdirectory $subdir_to_print
ENDMENUOUT4 @@ -357,7 +357,12 @@ ENDDISHEADER } } $r->print(< +
Number of blank pages to add: +
@@ -389,6 +394,7 @@ sub additional_print_menu { + Define one column layout parameters:
Width:
Height:
@@ -420,14 +426,14 @@ ENDPART my $laystyle = 'book'; my $assignment = $ENV{'form.assignment'}; if ($choice eq 'Subdirectory print') { - $layout = 'CAPA'; - $papersize = 'Letter [8 1/2x11 in]'; - $numberofcolumns = 2; + if ($ENV{'form.layout'} eq '') {$layout = 'CAPA';} + if ($ENV{'form.papersize'} eq '') {$papersize = 'Letter [8 1/2x11 in]';} + if ($ENV{'form.numberofcolumns'} eq '') {$numberofcolumns = 2;} } if (($choice eq 'Standard LaTeX output for current document') && ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./)) { - $layout = 'CAPA'; - $papersize = 'Letter [8 1/2x11 in]'; - $numberofcolumns = 1; + if ($ENV{'form.layout'} eq '') {$layout = 'CAPA';} + if ($ENV{'form.papersize'} eq '') {$papersize = 'Letter [8 1/2x11 in]';} + if ($ENV{'form.numberofcolumns'} eq '') {$numberofcolumns = 2;} } my $result = ''; my $number_of_columns = 1; #used only for pages to determine the width of the cell @@ -443,19 +449,23 @@ ENDPART if ($choice eq 'Standard LaTeX output for current document') { #-- single document - problem, page, html, xml $selectionmade = 1; - my %moreenv; - $moreenv{'form.grade_target'}='tex'; - if (&Apache::lonnet::allowed('bre',$ENV{'form.url'})) { + if ($ENV{'form.url'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { + my %moreenv; + $moreenv{'form.grade_target'}='tex'; + if (&Apache::lonnet::allowed('bre',$ENV{'form.url'})) { $ENV{'form.url'}=~s/http:\/\/[^\/]+//; - } - $moreenv{'request.filename'}=$ENV{'form.url'}; - $moreenv{'form.textwidth'}=$LaTeXwidth; - &Apache::lonnet::appenv(%moreenv); - my $texversion=&Apache::lonnet::ssi($ENV{'form.url'}); - &Apache::lonnet::delenv('form.grade_target','form.textwidth','form.counter'); - $result .= $texversion; - if ($ENV{'form.url'}=~m/\.page\s*$/) { + } + $moreenv{'request.filename'}=$ENV{'form.url'}; + $moreenv{'form.textwidth'}=$LaTeXwidth; + &Apache::lonnet::appenv(%moreenv); + my $texversion=&Apache::lonnet::ssi($ENV{'form.url'}); + &Apache::lonnet::delenv('form.grade_target','form.textwidth','form.counter'); + $result .= $texversion; + if ($ENV{'form.url'}=~m/\.page\s*$/) { ($result,$number_of_columns) = &page_cleanup($result); + } + } else{ + $result='\documentclass[letterpaper]{article}\usepackage{calc}\begin{document}You are trying to print eather sequence or something simular. Currently this option is not supported. Sorry for the inconvenience. Bye.\end{document}' } } elsif ($choice eq 'Standard LaTeX output for the primary sequence' or $choice eq 'Standard LaTeX output for whole primary sequence') { @@ -571,9 +581,11 @@ ENDPART } if ($current_output=~/\\documentclass/) { my $courseidinfo = $ENV{'course.'.$ENV{'request.course.id'}.'.description'}; - $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm}\\setlength{\\headheight}{1cm}\\setlength{\\headsep}{0.5cm}\\pagestyle{myheadings}\\markboth{}{{\\textbf{$fullname} $courseidinfo - $assignment}}\\begin{document} /; + $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm}\\setlength{\\headheight}{1cm}\\setlength{\\headsep}{0.5cm}\\pagestyle{myheadings}\\markboth{}{{$courseidinfo - $assignment}}\\begin{document}\\noindent\\textit{\\textbf{$fullname}}\\vskip 3 mm /; } else { - $current_output = '\\vskip 3mm\noindent\parbox{\minipagewidth}{\noindent\fbox{\textbf{'.$fullname.'}}\hskip 1.4in } \vskip 5 mm '.$current_output; + my $blanspages = ''; + for (my $j=0;$j<$ENV{'form.addedpages'};$j++) {$blanspages.='\clearpage\strut\clearpage';} + $current_output = '\strut\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License } \\vskip 3mm'.$blanspages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\textit{\textbf{'.$fullname.'}}\hskip 1.4in } \vskip 5 mm '.$current_output; } $result .= $current_output; &Apache::lonnet::delenv('form.counter'); @@ -1215,9 +1227,9 @@ sub latex_corrections { $result =~ s/\\includegraphics{/\\includegraphics\[width=\\minipagewidth\]{/g; $result =~ s/\$number_of_columns/$number_of_columns/g; - $result =~ s/(\\end{document})/\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License $1/; - $result =~ s/(\\end{longtable}\s*)(\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill})/$2$1/g; - $result =~ s/(\\end{longtable}\s*)\\newline/$1/g; + $result =~ s/(\\end{document})/\\strut\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License $1/; + $result =~ s/(\\end{longtable}\s*)(\\strut\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill})/$2$1/g; + $result =~ s/(\\end{longtable}\s*)\\strut\\newline/$1/g; #-- LaTeX corrections my $first_comment = index($result,'