--- loncom/interface/lonprintout.pm 2007/04/20 20:13:58 1.498 +++ loncom/interface/lonprintout.pm 2007/08/29 00:55:37 1.507 @@ -2,7 +2,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.498 2007/04/20 20:13:58 foxr Exp $ +# $Id: lonprintout.pm,v 1.507 2007/08/29 00:55:37 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -60,19 +60,13 @@ sub fetch_raw_resource { my ($url) = @_; my $filename = &Apache::lonnet::filelocation("", $url); - # - # fetch if needed: - # - if (! -e $filename) { - my $repcopy_result = &Apache::lonnet::repcopy($filename); + my $contents = &Apache::lonnet::getfile($filename); - if ($repcopy_result ne 'ok') { - return "File open failed for $filename"; # This will bomb the print. - } + if ($contents == -1) { + return "File open failed for $filename"; # This will bomb the print. } - my $contents = &Apache::lonnet::readfile($filename); - return $contents; + } @@ -873,7 +867,11 @@ sub page_format_transformation { my ($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin); if ($selectionmade eq '4') { - $assignment='Problems from the Whole Course'; + if ($choice eq 'all_problems') { + $assignment='Problems from the Whole Course'; + } else { + $assignment='Resources from the Whole Course'; + } } else { $assignment=&Apache::lonxml::latex_special_symbols($assignment,'header'); } @@ -1293,6 +1291,7 @@ sub output_data { my ($r,$helper,$rparmhash) = @_; my %parmhash = %$rparmhash; $resources_printed = ''; + my $do_postprocessing = 1; my $js = < var editbrowser; @@ -1372,6 +1371,14 @@ ENDPART if ($helper->{'VARS'}->{'showallfoils'} eq "1") { $form{'showallfoils'} = $helper->{'VARS'}->{'showallfoils'}; } + + if ($helper->{'VARS'}->{'style_file'}=~/\w/) { + &Apache::lonnet::appenv('construct.style' => + $helper->{'VARS'}->{'style_file'}); + } elsif ($env{'construct.style'}) { + &Apache::lonnet::delenv('construct\\.style'); + } + if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') { #-- single document - problem, page, html, xml, ... @@ -1395,12 +1402,6 @@ ENDPART if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') { my %moreenv; $moreenv{'request.filename'}=$cleanURL; - if ($helper->{'VARS'}->{'style_file'}=~/\w/) { - $moreenv{'construct.style'}=$helper->{'VARS'}->{'style_file'}; - my $dom = $env{'user.domain'}; - my $user = $env{'user.name'}; - my $put_result = &Apache::lonnet::put('environment',{'construct.style'=>$helper->{'VARS'}->{'style_file'}},$dom,$user); - } if ($helper->{'VARS'}->{'probstatus'} eq 'exam') {$form{'problemtype'}='exam';} $form{'problem_split'}=$parmhash{'problem_stream_switch'}; $form{'suppress_tries'}=$parmhash{'suppress_tries'}; @@ -1449,7 +1450,7 @@ ENDPART $texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm '; my $URLpath=$cleanURL; $URLpath=~s/~([^\/]+)/public_html\/$1\/$1/; - $texversion.=&path_to_problem ($URLpath,$LaTeXwidth); + $texversion.=&path_to_problem($URLpath,$LaTeXwidth); } $texversion.='\vskip 1 mm '.$answer.'\end{document}'; } @@ -1489,6 +1490,7 @@ ENDPART # $result = &fetch_raw_resource($currentURL); + $do_postprocessing = 0; # Don't massage the result. } else { $result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'}, @@ -1894,15 +1896,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; @@ -2215,6 +2222,28 @@ sub init_perm { } } +sub get_randomly_ordered_warning { + my ($helper,$map) = @_; + + my $message; + + my $postdata = $env{'form.postdata'} || $helper->{VARS}{'postdata'}; + my $navmap = Apache::lonnavmaps::navmap->new(); + my $res = $navmap->getResourceByUrl($map); + if ($res) { + my $func = + sub { return ($_[0]->is_map() && $_[0]->randomorder); }; + my @matches = $navmap->retrieveResources($res, $func,1,1,1); + if (@matches) { + $message = "Some folders are set to be randomly ordered. When printing the contents of these folders will be printed in the original order for all students."; + } + } + if ($message) { + return ''.$message.''; + } + return; +} + sub printHelper { my $r = shift; @@ -2470,6 +2499,9 @@ ALL_PROBLEMS push @{$printChoices}, [&mt("Selected Problems from folder [_1] for CODEd assignments",$sequenceTitle), 'problems_for_anon', 'CHOOSE_ANON1']; } + my $randomly_ordered_warning = + &get_randomly_ordered_warning($helper,$map); + # resource_selector will hold a few states that: # - Allow resources to be selected for printing. # - Determine pagination between assignments. @@ -2481,6 +2513,8 @@ ALL_PROBLEMS # my $resource_selector=< + $randomly_ordered_warning + PRINT_FORMATTING
Select resources for the assignment
- Names to store the CODEs under for later: + Names to save the CODEs under for later: @@ -2648,6 +2682,8 @@ CHOOSE_ANON1 $resource_selector=< + $randomly_ordered_warning + PRINT_FORMATTING
Select resources for the assignment
- Names to store the CODEs under for later: + Names to save the CODEs under for later: @@ -2878,7 +2914,7 @@ CHOOSE_FROM_ANY_SEQUENCE Apache::lonhelper::dropdown->new(); addMessage("". - ''. + ': "); $paramHash = Apache::lonhelper::getParamHash(); @@ -2927,9 +2963,10 @@ CHOOSE_FROM_ANY_SEQUENCE } if ($helper->{'VARS'}->{'construction'}) { - my $stylevalue=$env{'construct.style'}; + my $stylevalue='$Apache::lonnet::env{"construct.style"}'; my $randseedtext=&mt("Use random seed"); my $stylefiletext=&mt("Use style file"); + my $selectfiletext=&mt("Select style file"); my $xmlfrag .= <<"RNDSEED"; @@ -2941,17 +2978,19 @@ CHOOSE_FROM_ANY_SEQUENCE - : + : -   Select style file + + + return $stylevalue; + +   $selectfiletext - Show all foils? + Show all foils RNDSEED &Apache::lonxml::xmlparse($r, 'helper', $xmlfrag); - $helper->{'VARS'}->{'style_file'}=$env{'form.style_file_value'}; - } } @@ -3056,6 +3095,8 @@ sub render { my $PageLayout=&mt('Page layout'); my $NumberOfColumns=&mt('Number of columns'); my $PaperType=&mt('Paper type'); + my $landscape=&mt('Landscape'); + my $portrait=&mt('Portrait'); $result .= < @@ -3067,8 +3108,8 @@ sub render { -
- +
+