--- loncom/interface/lonprintout.pm 2007/01/22 10:38:32 1.496 +++ loncom/interface/lonprintout.pm 2007/04/26 09:32:23 1.500 @@ -2,7 +2,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.496 2007/01/22 10:38:32 foxr Exp $ +# $Id: lonprintout.pm,v 1.500 2007/04/26 09:32:23 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -48,6 +48,28 @@ my %perm; my %parmhash; my $resources_printed; +# Fetch the contents of a resource, uninterpreted. +# This is used here to fetch a latex file to be included +# verbatim into the printout< +# NOTE: Ask Guy if there is a lonnet function similar to this? +# +# Parameters: +# URL of the file +# +sub fetch_raw_resource { + my ($url) = @_; + + my $filename = &Apache::lonnet::filelocation("", $url); + my $contents = &Apache::lonnet::getfile($filename); + + if ($contents == -1) { + return "File open failed for $filename"; # This will bomb the print. + } + return $contents; + + +} + # # printf_style_subst item format_string repl # @@ -1265,6 +1287,7 @@ sub output_data { my ($r,$helper,$rparmhash) = @_; my %parmhash = %$rparmhash; $resources_printed = ''; + my $do_postprocessing = 1; my $js = < var editbrowser; @@ -1455,6 +1478,14 @@ ENDPART $resources_printed .= $currentURL.':'; my $texversion=&Apache::lonnet::ssi($currentURL,%form); $result .= $texversion; + } elsif ($cleanURL =~/.tex$/) { + # For this sort of print of a single LaTeX file, + # We can just print the LaTeX file as it is uninterpreted in any way: + # + + $result = &fetch_raw_resource($currentURL); + $do_postprocessing = 0; # Don't massage the result. + } else { $result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'}, $helper->{'VARS'}->{'symb'}); @@ -1859,15 +1890,20 @@ ENDPART $result .= '\end{document}'; } #-------------------------------------------------------- corrections for the different page formats - $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'}); - #if ($numberofcolumns == 1) { + + # Only post process if that has not been turned off e.g. by a raw latex resource. + + if ($do_postprocessing) { + $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'}); + #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'} /; $result =~ s/\\evensidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\evensidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /; $result =~ s/\\oddsidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\oddsidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /; - #} + #} + } #-- writing .tex file in prtspool my $temp_file; @@ -2798,7 +2834,10 @@ CHOOSE_FROM_ANY_SEQUENCE if (($perm{'pav'} and &Apache::lonnet::allowed('vgr',$env{'request.course.id'})) or ($helper->{VARS}->{'construction'} eq '1')) { - addMessage("
Print: "); + addMessage("
". + ': "); $paramHash = Apache::lonhelper::getParamHash(); $paramHash->{'variable'} = 'ANSWER_TYPE'; $helper->declareVar('ANSWER_TYPE'); @@ -2814,10 +2853,16 @@ CHOOSE_FROM_ANY_SEQUENCE if ($perm{'pav'}) { if (!$startedTable) { - addMessage("
LaTeX mode: "); + addMessage("
"); if (not $helper->{VARS}->{'construction'}) { - addMessage(""); - addMessage("
". + ': "); $startedTable = 1; } else { - addMessage("
LaTeX mode: "); + addMessage("
". + ': "); } $paramHash = Apache::lonhelper::getParamHash(); $paramHash->{'variable'} = 'LATEX_TYPE'; @@ -2833,7 +2878,10 @@ CHOOSE_FROM_ANY_SEQUENCE } Apache::lonhelper::dropdown->new(); - addMessage("
Print Table of Contents: "); + addMessage("
". + ''. + &mt('Print Table of Contents'). + ": "); $paramHash = Apache::lonhelper::getParamHash(); $paramHash->{'variable'} = 'TABLE_CONTENTS'; $helper->declareVar('TABLE_CONTENTS'); @@ -2844,7 +2892,10 @@ CHOOSE_FROM_ANY_SEQUENCE addMessage("
Print Index: "); + addMessage("
". + ': "); $paramHash = Apache::lonhelper::getParamHash(); $paramHash->{'variable'} = 'TABLE_INDEX'; $helper->declareVar('TABLE_INDEX'); @@ -2853,7 +2904,10 @@ CHOOSE_FROM_ANY_SEQUENCE ['Yes', 'yes'] ]; Apache::lonhelper::dropdown->new(); addMessage("
Print Discussions: "); + addMessage("
". + ': "); $paramHash = Apache::lonhelper::getParamHash(); $paramHash->{'variable'} = 'PRINT_DISCUSSIONS'; $helper->declareVar('PRINT_DISCUSSIONS'); @@ -2875,14 +2929,21 @@ CHOOSE_FROM_ANY_SEQUENCE if ($helper->{'VARS'}->{'construction'}) { my $stylevalue=$env{'construct.style'}; + my $randseedtext=&mt("Use random seed"); + my $stylefiletext=&mt("Use style file"); + my $xmlfrag .= <<"RNDSEED"; -
Use random seed: +
+ : + return $helper->{VARS}->{'curseed'}; -
Use style file: +
+ : +   Select style file
Show all foils?