--- loncom/interface/lonprintout.pm 2003/05/07 19:00:56 1.156 +++ loncom/interface/lonprintout.pm 2003/05/12 20:29:39 1.163 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.156 2003/05/07 19:00:56 bowersj2 Exp $ +# $Id: lonprintout.pm,v 1.163 2003/05/12 20:29:39 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1363,28 +1363,47 @@ ENDPART if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') { #-- single document - problem, page, html, xml, ... my $currentURL; - if (not defined $helper->{'VARS'}->{'construction'}) { + if ($helper->{'VARS'}->{'construction'} ne '1') { + #prins published resource $currentURL=$helper->{'VARS'}->{'postdata'}; } else { - $currentURL=$helper->{'VARS'}->{'construction'}; + #prins resource from the construction space + $currentURL=$helper->{'VARS'}->{'filename'}; + $currentURL=~s/\/home\//\/~/; + $currentURL=~s/public_html\///; } $selectionmade = 1; 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',$currentURL)) { - $currentURL=~s/http:\/\/[^\/]+//; - } - $moreenv{'request.filename'}=$currentURL; - $moreenv{'form.textwidth'}=$LaTeXwidth; - &Apache::lonnet::appenv(%moreenv); - my $texversion=&Apache::lonnet::ssi($currentURL); - &Apache::lonnet::delenv('form.grade_target','form.textwidth','form.counter'); - $result .= $texversion; - if ($currentURL=~m/\.page\s*$/) { - ($result,$number_of_columns) = &page_cleanup($result); - } - } else { + my %moreenv; + $moreenv{'form.grade_target'}='tex'; + $moreenv{'request.filename'}=$currentURL; + $moreenv{'form.textwidth'}=$LaTeXwidth; + &Apache::lonnet::appenv(%moreenv); + my $texversion=&Apache::lonnet::ssi($currentURL); + &Apache::lonnet::delenv('form.grade_target','form.textwidth','form.counter'); + if($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { + $moreenv{'form.grade_target'}='answer'; + &Apache::lonnet::appenv(%moreenv); + my $answer=&Apache::lonnet::ssi($currentURL); + &Apache::lonnet::delenv('form.grade_target'); + my $start=index($answer,'',$start); + if ($start!=-1 && $finish!=-1) {$answer=substr($answer,$start,$finish-$start+8);} + $answer=~s/<\/td>\s*/ \\\\ \\hline /g; + $answer=~s/]*)>/\\vskip 0 mm \\begin{tabular}{|c|}\\hline /; + $answer=~s/<\/table>/\\end{tabular}\\vskip 0 mm/; + $answer=~s/\s*//; + $answer=~s/<\/td>\s*<\/tr>/\\\\ \\hline /; + $answer=~s/([^\#]*)<\/b>/\\verb|$1|/; + $answer=~s/([^\#]*)<\/i>/\\textit{$1}/; +# $r->print('
'.$answer.'
'); return OK; + $texversion=~s/(\\end{document})/$answer$1/; + } + $result .= $texversion; + if ($currentURL=~m/\.page\s*$/) { + ($result,$number_of_columns) = &page_cleanup($result); + } + } else { # $result='\documentclass[letterpaper]{article}\usepackage{calc}\begin{document}Printout of this type of document is currently not supported: '; # if ($ENV{'form.url'}=~/\/(aboutme|syllabus|bulletinboard|smppg)$/) { # $result.=$1; @@ -1392,9 +1411,7 @@ ENDPART # $result.=$ENV{'form.url'}; # } # $result.=' \end{document}' - } - - + } } 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')) { @@ -1583,10 +1600,11 @@ sub handler { $helper = $result; -# my $key; -# foreach $key (keys %{$helper->{'VARS'}}) { -# $r->print(' '.$key.'->'.$helper->{'VARS'}->{$key}.'
'); -# } + + my $key; + foreach $key (keys %{$helper->{'VARS'}}) { + $r->print(' '.$key.'->'.$helper->{'VARS'}->{$key}.'<-
'); + } # return OK; @@ -1710,6 +1728,7 @@ sub printHelper { if ($ENV{'form.url'}) { $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'}); } + } if ($ENV{'form.symb'}) { $helper->{VARS}->{'symb'} = $ENV{'form.symb'}; @@ -1749,16 +1768,9 @@ sub printHelper { # "Delete everything after the last slash." $subdir =~ s|/[^/]+$||; - if (not defined $helper->{VARS}->{'construction'}) { - $subdir = '/home/httpd/html/res'.$subdir; - } else { - $helper->{VARS}->{'construction'}=~/^([^\/]+)\/\/([^\/]+)(.*)\/[^\/]*$/; - $subdir = $3; - $subdir=~/\/~([^\/]+)\/(.*)$/; - $subdir = '/home/'.$1.'/public_html/'.$2; + if (not $helper->{VARS}->{'construction'}) { + $subdir='/home/httpd/html/res/'.$subdir; } -#### $r->print('Dir: '.$subdir.' '); -#### return OK; # What can be printed is a very dynamic decision based on @@ -1782,7 +1794,7 @@ sub printHelper { $r->print($helper->{VARS}->{'postdata'}); # If we're in a sequence... - if (!defined($helper->{'VARS'}->{'construction'})) { + if ($helper->{'VARS'}->{'construction'} ne '1') { # Allow problems from sequence push @{$printChoices}, ["Problem(s) from $sequenceTitle", 'map_problems', 'CHOOSE_PROBLEMS']; # Allow all resources from sequence @@ -1890,6 +1902,20 @@ CHOOSE_FROM_SUBDIR $helper->declareVar('PRINT_TYPE'); $paramHash->{CHOICES} = $printChoices; Apache::lonhelper::choices->new(); + + if ($ENV{'request.role.adv'}) { + $paramHash = Apache::lonhelper::getParamHash(); + $paramHash->{MESSAGE_TEXT} = "
Next option is available only for advanced users:
"; + Apache::lonhelper::message->new(); + $paramHash = Apache::lonhelper::getParamHash(); + $paramHash->{'variable'} = 'ANSWER_TYPE'; + $helper->declareVar('ANSWER_TYPE'); + $paramHash->{CHOICES} = [ + ['Print without answer', 'yes'], + ['Print with answers', 'no'] ]; + Apache::lonhelper::choices->new(); + } + Apache::lonprintout::page_format_state->new("FORMAT"); # Generate the PAGESIZE state which will offer the user the margin