--- loncom/interface/lonprintout.pm 2004/09/24 21:01:50 1.316.2.3 +++ loncom/interface/lonprintout.pm 2004/08/13 17:40:55 1.323 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.316.2.3 2004/09/24 21:01:50 albertel Exp $ +# $Id: lonprintout.pm,v 1.323 2004/08/13 17:40:55 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -415,21 +415,108 @@ sub page_format { $topmargin = '3.5 in'; } } -# } elsif($papersize eq '1') { -# } elsif($papersize eq '2') { -# } elsif($papersize eq '3'/) { +<<<<<<< lonprintout.pm + } 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 = '7 in'; + $textheight = '9 in'; + $oddoffset = '-0.57 in'; + $evenoffset = '-0.57 in'; + $topmargin = '-0.5 in'; + } elsif ($numberofcolumns == 2) { + $textwidth = '3.5 in'; + $textheight = '9 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 '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') { @@ -483,15 +570,19 @@ 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.'}';} 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} /; } 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}\\rhead{}\\chead{}\\lhead{\\textbf{$name} $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}\\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 +720,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; @@ -1007,7 +1101,6 @@ ENDPART $result .= $texversion; $flag_latex_header_remove = 'YES'; } - if (&Apache::loncommon::connection_aborted($r)) { last; } } &Apache::lonnet::delenv('form.counter'); if ($flag_page_in_sequence eq 'YES') {$result =~ s/\\usepackage{calc}/\\usepackage{calc}\\usepackage{longtable}/;} @@ -1032,11 +1125,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"; @@ -1051,7 +1143,6 @@ ENDPART $student_names[$i].=$person.':'.$fullname.'_END_'; &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,&mt('last student').' '.$fullname); $flag_latex_header_remove = 'YES'; - if (&Apache::loncommon::connection_aborted($r)) { last; } } &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); $result .= $print_array[0].' \end{document}'; @@ -1101,7 +1192,6 @@ ENDPART &mt('last assignment').' '.$fullname); $flag_latex_header_remove = 'YES'; $count++; - if (&Apache::loncommon::connection_aborted($r)) { last; } } &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); $result .= $print_array[0].' \end{document}'; @@ -1264,7 +1354,9 @@ ENDPART 'cgi.'.$identifier.'backref' => $URLback,); $r->print(< +Continue FINALEND @@ -1297,7 +1389,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 @@ -1365,18 +1459,17 @@ sub print_resources { } $remove_latex_header = 'YES'; } - if (&Apache::loncommon::connection_aborted($r)) { last; } } 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 /; + $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);