--- loncom/interface/lonprintout.pm 2002/11/18 14:35:25 1.89 +++ loncom/interface/lonprintout.pm 2003/01/13 21:20:51 1.104 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.89 2002/11/18 14:35:25 sakharuk Exp $ +# $Id: lonprintout.pm,v 1.104 2003/01/13 21:20:51 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -66,11 +66,12 @@ sub headerform {
ENDHEADER - if ($ENV{'request.role'}=~m/^cc\./ or $ENV{'request.role'}=~m/^in\./ or $ENV{'request.role'}=~m/^ta\./) { - $r->print(<print(<Path to current document: $ENV{'form.postdata'}

ENDHEADER1 -} + } } @@ -81,9 +82,10 @@ sub menu_for_output { if ($title_for_single_resource ne '') {$title_for_single_resource = '"'.$title_for_single_resource.'"';} if ($title_for_sequence ne '') {$title_for_sequence = '"'.$title_for_sequence.'"';} if ($title_for_main_map ne '') {$title_for_main_map = '"'.$title_for_main_map.'"';} + $ENV{'form.postdata'} =~ s|http://[^/]+||; my $subdir_to_print = $ENV{'form.postdata'}; $subdir_to_print =~ m/\/([^\/]+)$/; - $subdir_to_print =~ s/$1//; + $subdir_to_print =~ s/\Q$1\E//; $r->print(<What do you want to print? Make a choice.
@@ -107,7 +109,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 @@ -151,11 +153,14 @@ ENDMENUOUT5 sub sequence_content_menu { my ($key_to,$r) = @_; + my $primary_sequence; my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'}); my @sequence = split('___',$symbolic); - my $primary_sequence = '/res/'.$sequence[0]; + if ($sequence[0]=~/^uploaded/) {$primary_sequence = '/'.$sequence[0];} + else {$primary_sequence = '/res/'.$sequence[0];} my @master_seq = &coming_from_hash($primary_sequence,$sequence[0]); - my @master_seq_view = @master_seq; + my @master_seq_view = sort @master_seq; + @master_seq = sort @master_seq; for (my $i=0;$i<=$#master_seq_view;$i++) { $master_seq_view[$i]=~/\/([^\/]+)$/; $master_seq_view[$i]=$1; @@ -165,6 +170,7 @@ sub sequence_content_menu { +

Mark item(s) which you want to print

  - +  

@@ -357,7 +362,12 @@ ENDDISHEADER } } $r->print(< +
Number of blank pages to add: +
@@ -389,6 +399,7 @@ sub additional_print_menu { + Define one column layout parameters:
Width:
Height:
@@ -424,7 +435,8 @@ ENDPART 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\./)) { + if (($choice eq 'Standard LaTeX output for current document') && + ($ENV{'form.url'}=~m|^/~|)) { 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;} @@ -433,8 +445,11 @@ ENDPART my $number_of_columns = 1; #used only for pages to determine the width of the cell my $selectionmade = ''; my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$layout,$numberofcolumns); - my $LaTeXwidth; - + if ($numberofcolumns == 1) { + $textwidth=$ENV{'form.width'}; + $textheight=$ENV{'form.height'}; + } + my $LaTeXwidth; if ($textwidth=~/(\d+\s*cm)/) { $LaTeXwidth = $1*10; } elsif ($textwidth=~/(\d+\s*mm)/) { @@ -443,19 +458,29 @@ 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}Printout of this type of document is currently not supported: '; + if ($ENV{'form.url'}=~/\/(aboutme|syllabus|bulletinboard|smppg)$/) { + $result.=$1; + } else { + $result.=$ENV{'form.url'}; + } + $result.=' \end{document}' } } elsif ($choice eq 'Standard LaTeX output for the primary sequence' or $choice eq 'Standard LaTeX output for whole primary sequence') { @@ -481,7 +506,7 @@ ENDPART $moreenv{'form.grade_target'}='tex'; $moreenv{'form.textwidth'}=$LaTeXwidth; &Apache::lonnet::appenv(%moreenv); - &Apache::lonnet::logthis("Trying to get $urlp with symb $symb"); + #&Apache::lonnet::logthis("Trying to get $urlp with symb $symb"); my $texversion=&Apache::lonnet::ssi($urlp,('symb'=>$symb)); &Apache::lonnet::delenv('form.grade_target','form.textwidth'); if ($urlp =~ m/\.page/) { @@ -573,7 +598,9 @@ ENDPART 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{}{{$courseidinfo - $assignment}}\\begin{document}\\noindent\\textit{\\textbf{$fullname}}\\vskip 3 mm /; } else { - $current_output = '\\vskip 3mm\\clearpage\\strut\\clearpage\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\textit{\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'); @@ -597,8 +624,8 @@ ENDPART $moreenv{'form.grade_target'}='tex'; $moreenv{'form.textwidth'}=$LaTeXwidth; &Apache::lonnet::appenv(%moreenv); - if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) { - $urlp =~ s/\/home\/([^\/]*)\/public_html/\/~$1/; + if ($urlp =~ m|/home/([^/]+)/public_html|) { + $urlp =~ s|/home/([^/]*)/public_html|/~$1|; } my $texversion=&Apache::lonnet::ssi($urlp); &Apache::lonnet::delenv('form.grade_target','form.textwidth'); @@ -706,7 +733,13 @@ sub coming_from_hash { my $mapid = $hash{'map_pc_'.$mainsequence}; my $mapstart = $hash{'map_start_'.$mainsequence}; my $mapfinish = $hash{'map_finish_'.$mainsequence}; - my ($presymb) = split(/___/,$symb); + my ($presymb); + if ($symb) { + ($presymb)=split(/___/,$symb); + } else { + $presymb=$mainsequence; + $presymb=~s|^/res/||; + } $presymb = $presymb.'___'; my $current_resource = $mapstart; while ($current_resource ne $mapfinish) { @@ -1159,16 +1192,22 @@ sub character_chart { sub page_format_transformation { - my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment) = @_; - my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$layout,$numberofcolumns); - my $courseidinfo = $ENV{'course.'.$ENV{'request.course.id'}.'.description'}; + my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment) = @_; + my ($textwidth,$textheight,$oddoffset,$evenoffset); + $assignment=~s/_/ /g; + if ($numberofcolumns != 1) { + ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$layout,$numberofcolumns); + } else { + ($textwidth,$textheight,$oddoffset,$evenoffset) = ($ENV{'form.width'},$ENV{'form.height'},$ENV{'form.leftmargin'},$ENV{'form.leftmargin'}); + } + my $courseidinfo = $ENV{'course.'.$ENV{'request.course.id'}.'.description'}; if ($layout eq 'CBI') { $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}\\setlength{\\topmargin}{200pt}\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\parindent}{20pt}\\setlength{\\marginparwidth}{90pt}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm} \\begin{document}\\setcounter{page}{1}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fbox{\\textbf{$ENV{'environment.firstname'} $ENV{'environment.lastname'}}} \\hfill $courseidinfo} \\vskip 5 mm /; } elsif ($layout eq 'CAPA') { 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\}\\setlength{\\topmargin}{1cm}\\setlength{\\headheight}{1cm}\\setlength{\\headsep}{0.5cm}\\markboth{}{\\textbf{$ENV{'environment.firstname'} $ENV{'environment.lastname'}} $courseidinfo - $assignment}\\pagestyle{myheadings}\\begin{document}\\voffset=-1\.8cm\\setcounter{page}{1}/; + $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\}\\setlength{\\topmargin}{1cm}\\setlength{\\headheight}{1cm}\\setlength{\\headsep}{0.5cm}\\markboth{}{\\textbf{$ENV{'environment.firstname'} $ENV{'environment.lastname'}} $courseidinfo - $assignment}\\pagestyle{myheadings}\\begin{document}\\voffset=-1\.8cm\\setcounter{page}{1}/; } else { - $text =~ s/\\begin{document}/\\setlength{\\textheight}{$textheight}\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}\\setlength{\\textwidth}{$textwidth}\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\begin{document}\\voffset=-1\.8cm\\setcounter{page}{1} \\vskip 5 mm /; + $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\}\\begin{document}\\voffset=-1\.8cm\\setcounter{page}{1} \\vskip 5 mm /; } } return $text; @@ -1194,9 +1233,14 @@ sub details_for_menu { my $name_of_resourse = $hash{'title_'.$hash{'ids_'.$ENV{'form.postdata'}}}; my $symbolic = &Apache::lonnet::symbread($ENV{'form.postdata'}); my ($map,$id,$resource)=split(/___/,$symbolic); - my $name_of_sequence = $hash{'title_'.$hash{'ids_/res/'.$map}}; + my $name_of_sequence; + if ($map=~/^uploaded/) { + $name_of_sequence = $hash{'title_'.$hash{'ids_/'.$map}}; + } else { + $name_of_sequence = $hash{'title_'.$hash{'ids_/res/'.$map}}; + } if ($name_of_sequence =~ /^\s*$/) { - $map =~ m|([^/]+)$|; + $map =~ m|([^/]+)$|; $name_of_sequence = $1; } my $name_of_map = $hash{'title_'.$hash{'ids_/res/'.$ENV{'request.course.uri'}}}; @@ -1215,9 +1259,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,'