--- loncom/interface/lonprintout.pm 2006/07/31 10:32:00 1.469 +++ loncom/interface/lonprintout.pm 2006/08/08 17:32:02 1.477 @@ -2,7 +2,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.469 2006/07/31 10:32:00 foxr Exp $ +# $Id: lonprintout.pm,v 1.477 2006/08/08 17:32:02 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -827,16 +827,21 @@ sub details_for_menu { return ($name_of_resource,$name_of_sequence,$name_of_map); } +sub copyright_line { + return '\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 } '; +} +my $end_of_student = "\n".'\special{ps:ENDOFSTUDENTSTAMP}'."\n"; sub latex_corrections { my ($number_of_columns,$result,$selectionmade,$answer_mode) = @_; # $result =~ s/\\includegraphics{/\\includegraphics\[width=\\minipagewidth\]{/g; - $result =~ s/\$number_of_columns/$number_of_columns/g; + my $copyright = ©right_line(); if ($selectionmade eq '1' || $answer_mode eq 'only') { - $result =~ s/(\\end{document})/\\strut\\vskip 0 mm\\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{document})/\\strut\\vskip 0 mm $copyright $end_of_student $1/; } else { - $result =~ s/(\\end{document})/\\strut\\vspace\*{-4 mm}\\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{document})/\\strut\\vspace\*{-4 mm}\\newline $copyright $end_of_student $1/; } + $result =~ s/\$number_of_columns/$number_of_columns/g; $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 @@ -893,7 +898,7 @@ sub IndexCreation { sub print_latex_header { my $mode=shift; - my $output='\documentclass[letterpaper,twoside]{article}'; + my $output='\documentclass[letterpaper,twoside]{article}\raggedbottom'; if (($mode eq 'batchmode') || (!$perm{'pav'})) { $output.='\batchmode'; } @@ -1114,7 +1119,9 @@ sub print_construction_sequence { # If necessary, encapsulate answer in minipage: $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); - my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}).'}\vskip 0 mm '; + my $title = &Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}); + $title = &Apache::lonxml::latex_special_symbols($title); + my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; $body.=&path_to_problem($urlp,$LaTeXwidth); $body.='\vskip 1 mm '.$answer.'\end{document}'; $body = &encapsulate_minipage($body); @@ -1309,7 +1316,9 @@ ENDPART } else { $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); if ($helper->{'VARS'}->{'construction'} ne '1') { - $texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}).'}\vskip 0 mm '; + my $title = &Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}); + $title = &Apache::lonxml::latex_special_symbols($title); + $texversion.='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; $texversion.=&path_to_problem($cleanURL,$LaTeXwidth); } else { $texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm '; @@ -1430,7 +1439,9 @@ ENDPART } else { if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) { $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); - my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($master_seq[$i]).'}\vskip 0 mm '; + my $title = &Apache::lonnet::gettitle($master_seq[$i]); + $title = &Apache::lonxml::latex_special_symbols($title); + my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; $body .= &path_to_problem ($urlp,$LaTeXwidth); $body .='\vskip 1 mm '.$answer; $body = &encapsulate_minipage($body); @@ -1754,12 +1765,6 @@ ENDPART $result = &page_format_transformation($papersize,$laystyle,$numberofcolumns,$helper->{'VARS'}->{'PRINT_TYPE'},$result,$helper->{VARS}->{'assignment'},$helper->{'VARS'}->{'TABLE_CONTENTS'},$helper->{'VARS'}->{'TABLE_INDEX'},$selectionmade); $result = &latex_corrections($number_of_columns,$result,$selectionmade, $helper->{'VARS'}->{'ANSWER_TYPE'}); - for (my $i=1;$i<=$#print_array;$i++) { - $print_array[$i] = - &latex_corrections($number_of_columns,$print_array[$i], - $selectionmade, - $helper->{'VARS'}->{'ANSWER_TYPE'}); - } #if ($numberofcolumns == 1) { $result =~ s/\\textwidth\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /; $result =~ s/\\textheight\s*=?\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textheight $helper->{'VARS'}->{'pagesize.height'} $helper->{'VARS'}->{'pagesize.heightunit'} /; @@ -1786,9 +1791,15 @@ ENDPART if ($i==0) { $print_array[$i]=$result; } else { + $print_array[$i].='\end{document}'; + $print_array[$i] = + &latex_corrections($number_of_columns,$print_array[$i], + $selectionmade, + $helper->{'VARS'}->{'ANSWER_TYPE'}); + my $anobegin=index($print_array[$i],'\setcounter{page}',0); substr($print_array[$i],0,$anobegin)=''; - $print_array[$i]=$inc.$print_array[$i].'\end{document}'; + $print_array[$i]=$inc.$print_array[$i]; } my $temp_file; my $newfilename=$filename; @@ -1899,8 +1910,7 @@ sub print_resources { &Apache::lonxml::clear_problem_counter(); my %page_breaks = &get_page_breaks($helper); - my @format_array = split(/\|/,$helper->{'VARS'}->{'FORMAT'}); - my $columns_in_format = $format_array[1]; + my $columns_in_format = (split(/\|/,$helper->{'VARS'}->{'FORMAT'}))[1]; # # end each student with a # Special that allows the post processor to even out the page @@ -1948,8 +1958,10 @@ sub print_resources { my $header =&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); - my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($curresline).'}\vskip 0 mm '; - $body .=&path_to_problem($res_url,$LaTeXwidth); + my $title = &Apache::lonnet::gettitle($curresline); + $title = &Apache::lonxml::latex_special_symbols($title); + my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; + $body .=&path_to_problem($res_url,$LaTeXwidth); $body .='\vskip 1 mm '.$ansrendered; $body = &encapsulate_minipage($body); $rendered = $header.$body; @@ -1990,28 +2002,27 @@ sub print_resources { if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection} my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header'); - my $HeaderLine = $parmhash{'print_header_format'}; - $HeaderLine = format_page_header($HeaderLine, $currentassignment, $courseidinfo, $fullname); - if ($current_output=~/\\documentclass/) { - if ($columns_in_format == 1) { - $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\lhead{$HeaderLine$namepostfix}}\\vskip 5 mm /; - } else { - $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fancyhead[LO]{$HeaderLine$namepostfix}}\\vskip 5 mm /; + my $header_line = + &format_page_header($parmhash{'print_header_format'}, + $currentassignment, $courseidinfo, $fullname); + my $header_start = ($columns_in_format == 1) ? '\lhead' + : '\fancyhead[LO]'; + $header_line = $header_start.'{'.$header_line.'}'; - } + if ($current_output=~/\\documentclass/) { + $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$header_line$namepostfix}\\vskip 5 mm /; } else { - my $blankpages = ''; - for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blankpages.='\clearpage\strut\clearpage';} - if ($columns_in_format == 1) { - $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{'.$HeaderLine.'}'.$namepostfix.'} \vskip 5 mm '.$current_output; - } else { - $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\\fancyhead[LO]{'.$HeaderLine.'}'.$namepostfix.'} \vskip 5 mm '.$current_output; - } + my $blankpages = + '\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'}; + + $current_output = '\strut\vspace*{-6 mm}\\newline'. + ©right_line().' \newpage '.$blankpages.$end_of_student. + '\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent'. + $header_line.$namepostfix.'} \vskip 5 mm '.$current_output; } # # Close the student bracketing. # - $current_output .= "\n\\special{ps:ENDOFSTUDENTSTAMP}\n"; return ($current_output,$fullname, $printed); } @@ -2318,7 +2329,7 @@ ALL_PROBLEMS if ($helper->{VARS}->{'assignment'}) { push @{$printChoices}, [&mt("Selected Problems from folder [_1] for selected students",$sequenceTitle), 'problems_for_students', 'CHOOSE_STUDENTS']; - push @{$printChoices}, [&mt("Selected Problems from folder [_1] for anonymous students",$sequenceTitle), 'problems_for_anon', 'CHOOSE_ANON1']; + push @{$printChoices}, [&mt("Selected Problems from folder [_1] for CODEd assignments",$sequenceTitle), 'problems_for_anon', 'CHOOSE_ANON1']; } # resource_selector will hold a few states that: @@ -2405,7 +2416,7 @@ CHOOSE_STUDENTS } if (%codes_to_print) { $code_selection .=' - Choose single code from list + Choose single CODE from list: @@ -2462,7 +2473,7 @@ CHOOSE_STUDENTS -

Print a Specific Code


+

Print a Specific CODE


Enter a CODE to print: @@ -2476,10 +2487,10 @@ CHOOSE_STUDENTS } -
+
$code_selection
-

Reprint a Set of Saved Codes

+

Reprint a Set of Saved CODEs

Select saved CODEs: @@ -2493,7 +2504,7 @@ CHOOSE_ANON1 if ($helper->{VARS}->{'assignment'}) { push @{$printChoices}, [&mt("Selected Resources from folder [_1] for selected students",$sequenceTitle), 'resources_for_students', 'CHOOSE_STUDENTS1']; - push @{$printChoices}, [&mt("Selected Resources from folder [_1] for anonymous students",$sequenceTitle), 'resources_for_anon', 'CHOOSE_ANON2']; + push @{$printChoices}, [&mt("Selected Resources from folder [_1] for CODEd assignments",$sequenceTitle), 'resources_for_anon', 'CHOOSE_ANON2']; } @@ -2544,9 +2555,12 @@ RESOURCE_SELECTOR CHOOSE_STUDENTS1 &Apache::lonxml::xmlparse($r, 'helper', < + SELECT_RESOURCES -
Number of anonymous assignments to print: +

Fill out one of the forms below

+


+

Generate new CODEd Assignments

+
Number of CODEd assignments to print: if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && @@ -2568,9 +2582,9 @@ CHOOSE_STUDENTS1 $codechoice -

-
- Enter a CODE to print: +
+

Print a Specific CODE


+
Enter a CODE to print: if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} && @@ -2583,15 +2597,16 @@ CHOOSE_STUDENTS1 } -

+
$code_selection - Reprint a set of saved CODEs: +
+

Reprint a Set of Saved CODEs

+ Select saved CODEs: $namechoice
-
$resource_selector CHOOSE_ANON2 @@ -3030,9 +3045,16 @@ sub render { } } - $result .= <How should each column be formatted?

@@ -3074,7 +3096,7 @@ ELEMENTHTML return $result; } -# If the user didn't select 1 column, skip this state. + sub preprocess { my $self = shift; my $helper = Apache::lonhelper::getHelper(); @@ -3107,9 +3129,7 @@ sub preprocess { foreach my $dim ('width', 'height', 'lmargin') { my ($value, $units) = split(/ /, $size{$dim}); - - &Apache::lonnet::logthis("$dim : $value : $units"); - + $helper->{VARS}->{"$var.".$dim} = $value; $helper->{VARS}->{"$var.".$dim.'unit'} = $units; @@ -3149,6 +3169,14 @@ sub postprocess { } if ($lmargin !~ /^-?[0-9]*(\.[0-9]*)?$/) { $error .= "Invalid left margin; please type only a number.
\n"; + } else { + # Adjust for LaTeX 1.0 inch margin: + + if ($env{"form.${var}.lmarginunit"} eq "in") { + $helper->{VARS}->{$var.'.lmargin'} = $lmargin - 1; + } else { + $helper->{VARS}->{$var.'.lmargin'} = $lmargin - 2.54; + } } if (!$error) {