--- loncom/interface/lonprintout.pm 2003/05/01 20:37:32 1.140 +++ loncom/interface/lonprintout.pm 2003/05/02 15:48:26 1.143 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.140 2003/05/01 20:37:32 sakharuk Exp $ +# $Id: lonprintout.pm,v 1.143 2003/05/02 15:48:26 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1389,21 +1389,27 @@ ENDPART if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') { - #-- single document - problem, page, html, xml, ... + #-- single document - problem, page, html, xml, ... + my $currentURL; + if (defined $helper->{'VARS'}->{'url'}) { + $currentURL=$helper->{'VARS'}->{'url'}; + } else { + $currentURL=$helper->{'VARS'}->{'postdata'}; + } $selectionmade = 1; - if ($helper->{'VARS'}->{'url'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { + if ($currentURL=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { my %moreenv; $moreenv{'form.grade_target'}='tex'; - if (&Apache::lonnet::allowed('bre',$helper->{'VARS'}->{'url'})) { - $helper->{'VARS'}->{'url'}=~s/http:\/\/[^\/]+//; - } - $moreenv{'request.filename'}=$helper->{'VARS'}->{'url'}; + if (&Apache::lonnet::allowed('bre',$currentURL)) { + $currentURL=~s/http:\/\/[^\/]+//; + } + $moreenv{'request.filename'}=$currentURL; $moreenv{'form.textwidth'}=$LaTeXwidth; &Apache::lonnet::appenv(%moreenv); - my $texversion=&Apache::lonnet::ssi($helper->{'VARS'}->{'url'}); + my $texversion=&Apache::lonnet::ssi($currentURL); &Apache::lonnet::delenv('form.grade_target','form.textwidth','form.counter'); $result .= $texversion; - if ($helper->{'VARS'}->{'url'}=~m/\.page\s*$/) { + if ($currentURL=~m/\.page\s*$/) { ($result,$number_of_columns) = &page_cleanup($result); } } else { @@ -1417,50 +1423,53 @@ ENDPART } -# } elsif ($choice eq 'Standard LaTeX output for the primary sequence' or -# $choice eq 'Standard LaTeX output for whole primary sequence') { -# #-- minimal sequence to which the current document belongs -# #-- where is the primary sequence containing file? -# my @master_seq = (); -# for (my $i=0; $i<$ENV{'form.numberoffiles'};$i++) { -# if ($ENV{'form.whatfile'.$i}=~/\S/) { -# push @master_seq,$ENV{'form.whatfile'.$i}; -# } -# } -# #-- produce an output string -# my $flag_latex_header_remove = 'NO'; -# my $flag_page_in_sequence = 'NO'; -# for (my $i=0;$i<=$#master_seq;$i++) { -# my ($urlp,$symb) = split /&&/, $master_seq[$i]; -# if ($choice eq 'Standard LaTeX output for the primary sequence') { -# $selectionmade = 2; -# } elsif ($choice eq 'Standard LaTeX output for whole primary sequence') { -# $selectionmade = 3; -# } -# my %moreenv; -# $moreenv{'form.grade_target'}='tex'; -# $moreenv{'form.textwidth'}=$LaTeXwidth; -# &Apache::lonnet::appenv(%moreenv); -# #&Apache::lonnet::logthis("Trying to get $urlp with symb $symb"); -# my $texversion=&Apache::lonnet::ssi($urlp,('symb'=>$symb)); -# &Apache::lonnet::delenv('form.grade_target','form.textwidth'); -# if ($urlp =~ m/\.page/) { -# ($texversion,my $number_of_columns_page) = &page_cleanup($texversion); -# if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;} -# $texversion =~ s/\\end{document}\d*/\\end{document}/; -# $flag_page_in_sequence = 'YES'; -# } -# if ($flag_latex_header_remove ne 'NO') { -# $texversion = &latex_header_footer_remove($texversion); -# } else { -# $texversion =~ s/\\end{document}//; -# } -# $result .= $texversion; -# $flag_latex_header_remove = 'YES'; + } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') or + ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or + ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems')) { + #-- produce an output string + my $flag_latex_header_remove = 'NO'; + my $flag_page_in_sequence = 'NO'; + my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; + +# foreach my $key (@master_seq) { +# $r->print(' '.$key.'
'); # } -# &Apache::lonnet::delenv('form.counter'); -# if ($flag_page_in_sequence eq 'YES') {$result =~ s/\\usepackage{calc}/\\usepackage{calc}\\usepackage{longtable}/;} -# $result .= '\end{document}'; +# return OK; + + for (my $i=0;$i<=$#master_seq;$i++) { + $master_seq[$i]=~/___\d+___(.*)$/; + my $urlp='/res/'.$1; + if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') { + $selectionmade = 2; + } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') { + $selectionmade = 3; + } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') { + $selectionmade = 4; + } + my %moreenv; + $moreenv{'form.grade_target'}='tex'; + $moreenv{'form.textwidth'}=$LaTeXwidth; + &Apache::lonnet::appenv(%moreenv); + #&Apache::lonnet::logthis("Trying to get $urlp with symb $master_seq[$i]"); + my $texversion=&Apache::lonnet::ssi($urlp,('symb'=>$master_seq[$i])); + &Apache::lonnet::delenv('form.grade_target','form.textwidth'); + if ($urlp=~/\.page$/) { + ($texversion,my $number_of_columns_page) = &page_cleanup($texversion); + if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;} + $texversion =~ s/\\end{document}\d*/\\end{document}/; + $flag_page_in_sequence = 'YES'; + } + if ($flag_latex_header_remove ne 'NO') { + $texversion = &latex_header_footer_remove($texversion); + } else { + $texversion =~ s/\\end{document}//; + } + $result .= $texversion; + $flag_latex_header_remove = 'YES'; + } + &Apache::lonnet::delenv('form.counter'); + if ($flag_page_in_sequence eq 'YES') {$result =~ s/\\usepackage{calc}/\\usepackage{calc}\\usepackage{longtable}/;} + $result .= '\end{document}'; # } elsif ($choice eq 'Standard LaTeX output for the top level sequence') { # # where is the main sequence of the course? # $selectionmade = 4; @@ -1636,7 +1645,7 @@ ENDPART } print $temp_file $result; - +# $r->print(< @@ -1664,8 +1673,9 @@ sub handler { # foreach $key (keys %{$helper->{'VARS'}}) { # $r->print(' '.$key.'->'.$helper->{'VARS'}->{$key}.'
'); # } +# return OK; + - &output_data_new($r,$helper);