--- loncom/interface/lonprintout.pm 2010/01/12 10:40:01 1.569 +++ loncom/interface/lonprintout.pm 2010/06/10 16:14:34 1.581 @@ -2,7 +2,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.569 2010/01/12 10:40:01 foxr Exp $ +# $Id: lonprintout.pm,v 1.581 2010/06/10 16:14:34 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -196,14 +196,19 @@ sub generate_code_selector {


Generate new CODEd Assignments

Number of CODEd assignments to print: - + if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && !\$helper->{'VARS'}{'REUSE_OLD_CODES'} && !\$helper->{'VARS'}{'SINGLE_CODE'} && - !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { + !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'} ) { + return "You need to specify the number of assignments to print"; } + if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) >= 1) && + (\$helper->{'VARS'}{'SINGLE_CODE'} ne '') ) { + return 'Specifying number of codes to print and a specific code is not compatible'; + } return undef; @@ -228,6 +233,8 @@ sub generate_code_selector { !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'}, \$helper->{'VARS'}{'CODE_OPTION'}); + } elsif (\$helper->{'VARS'}{'SINGLE_CODE'} ne ''){ + return 'Specifying a code name is incompatible with specifying number of codes.'; } else { return undef; # Other forces control us. } @@ -306,7 +313,14 @@ sub set_font_size { my ($text) = @_; - $text =~ s/\\begin{document}/\\begin{document}{\\$font_size/; + # There appear to be cases where the font directive is empty.. in which + # case the first substituion would insert a spurious \ oh happy day. + # as this has been the cause of much mystery and hair pulling _sigh_ + + if ($font_size ne '') { + + $text =~ s/\\begin{document}/\\begin{document}{\\$font_size/; + } $text =~ s/\\end{document}/}\\end{document}/; return $text; @@ -1309,7 +1323,13 @@ sub page_format_transformation { $text =~ s/\\pagestyle{fancy}\\rhead{}\\chead{}\s*\\begin{document}/\\textheight = $textheight\\oddsidemargin = $evenoffset\n\\evensidemargin = $evenoffset $topmargintoinsert\\textwidth= $textwidth\\newlength{\\minipagewidth}\n\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\usepackage{booktabs}\\begin{document}\\voffset=-0\.8cm\n\\setcounter{page}{1} \\vskip 5 mm\n /; } if ($papersize eq 'a4') { - $text =~ s/(\\begin{document})/$1\\special{papersize=210mm,297mm}/; + my $papersize_text; + if ($perm{'pav'}) { + $papersize_text = '\\special{papersize=210mm,297mm}'; + } else { + $papersize_text = '\special{papersize=210mm,297mm}'; + } + $text =~ s/(\\begin{document})/$1$papersize_text/; } } if ($tableofcontents eq 'yes') {$text=~s/(\\setcounter\{page\}\{1\})/$1 \\tableofcontents\\newpage /;} @@ -1570,7 +1590,7 @@ sub print_page_in_course { } # these resources go through the XML transformer: - elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm\xhtml|xhtm)$/) { + elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { my $urlp = &Apache::lonnet::clutter($resource_src); my %form; my %moreenv; @@ -1581,7 +1601,7 @@ sub print_page_in_course { $form{'grade_target'} = 'tex'; $form{'textwidth'} = &get_textwidth($helper, $LaTeXwidth); - $form{'pdfFormFiels'} = $pdfFormFields; # + $form{'pdfFormFields'} = $pdfFormFields; # $form{'showallfoils'} = $helper->{'VARS'}->{'showallfoils'}; $form{'problem_split'}=$parmhash{'problem_stream_switch'}; @@ -1781,6 +1801,8 @@ sub get_page_breaks { # This is done as follows: # POSSIBLE_RESOURCES has the list of possible resources. # EXTRASPACE has the list of extra space values. +# EXTRASPACE_UNITS is the set of resources for which the units are +# mm. All others are 'in'. # # The resource is found in the POSSIBLE_RESOURCES to get the index # of the EXTRASPACE value. @@ -1792,6 +1814,7 @@ sub get_page_breaks { my %possible_resources; +my %extraspace_mm; my @extraspace; my $skips_loaded = 0; @@ -1811,6 +1834,9 @@ sub load_skips { $possible_resources{$resource} = $i; $i++; } + foreach my $mm_resource (split(/\|\|\|/, $helper->{'VARS'}->{'EXTRASPACE_UNITS'})) { + $extraspace_mm{$mm_resource} = 1; + } $skips_loaded = 1; } } @@ -1829,8 +1855,14 @@ sub get_extra_vspaces { my $result = ''; if ($skip ne '') { - $result = '\vskip '.$skip.' mm'; + my $units = 'in'; + if (defined($extraspace_mm{$resource})) { + $units = 'mm'; + } + $result = '\vskip '.$skip.' '.$units; } + + return $result; @@ -1848,10 +1880,12 @@ sub get_extra_vspaces { # Implicit input: # $helper->{'VARS'}->{'EXTRASPACE'} - the spaces helper var has the text field # value. +# $helper->{'VARS'}->{'EXTRASPACE_UNITS'} - units for the skips (checkboxes). # $helper->{'VARS'}->{'POSSIBLE_RESOURCES'} - has the list of resources. ||| # separated of course. # Implicit outputs: -# $env{'form.extrapsace'} +# $env{'form.extraspace'} +# $env{'form.extraspace_units'} # sub set_form_extraspace { my ($helper) = @_; @@ -1870,6 +1904,7 @@ sub set_form_extraspace { } $env{'form.extraspace'} = $result; + $env{'form.extraspace_units'} = $helper->{'VARS'}->{'EXTRASPACE_UNITS'}; return $result; } @@ -2049,6 +2084,7 @@ ENDPART &Apache::loncommon::store_course_settings('print', {'pagebreaks' => 'scalar', 'extraspace' => 'scalar', + 'extraspace_units' => 'scalar', 'lastprinttype' => 'scalar'}); my %page_breaks = &get_page_breaks($helper); @@ -2421,7 +2457,11 @@ ENDPART if ($i > 0) { $result .= '\cleardoublepage'; } - $result .= &include_pdf($urlp); + my $texfrompdf = &include_pdf($urlp); + if ($flag_latex_header_remove ne 'NO') { + $texfrompdf = &latex_header_footer_remove($texfrompdf); + } + $result .= $texfrompdf; if ($i != $#master_seq) { if ($numberofcolumns eq '1') { $result .= '\newpage'; @@ -2545,7 +2585,8 @@ ENDPART $resources_printed .= ":"; $print_array[$i].=$output; $student_names[$i].=$person.':'.$fullname.'_END_'; - &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,&mt('last student').' '.$fullname); +# &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,&mt('last student').' '.$fullname); + &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last student'); $flag_latex_header_remove = 'YES'; if (&Apache::loncommon::connection_aborted($r)) { last; } } @@ -3177,6 +3218,7 @@ sub printHelper { &Apache::loncommon::restore_course_settings('print', {'pagebreaks' => 'scalar', 'extraspace' => 'scalar', + 'extraspace_units' => 'scalar', 'lastprinttype' => 'scalar'}); # This will persistently load in the data we want from the @@ -3187,11 +3229,14 @@ sub printHelper { $helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'}; $helper->{VARS}->{EXTRASPACE} = $env{'form.extraspace'}; + $helper->{VARS}->{EXTRASPACE_UNITS} = $env{'form.extraspace_units'}; } else { my $state = $env{"form.CURRENT_STATE"}; if ($state eq "START") { $helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'}; $helper->{VARS}->{EXTRASPACE} = $env{'form.extraspace'}; + $helper->{VARS}->{EXTRASPACE_UNITS} = $env{'form.extraspace_units'}; + } } @@ -3311,10 +3356,14 @@ sub printHelper { $start_new_option = "