--- loncom/interface/lonprintout.pm 2006/08/21 22:53:19 1.480 +++ loncom/interface/lonprintout.pm 2006/09/05 15:41:09 1.484 @@ -2,7 +2,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.480 2006/08/21 22:53:19 foxr Exp $ +# $Id: lonprintout.pm,v 1.484 2006/09/05 15:41:09 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -628,8 +628,8 @@ my %page_formats= '2' => ['3.66 in','9.8 in', '-0.57 in','-0.57 in','0.7 cm'] }, 'album' => { - '1' => [ '8.8 in', '6.8 in','-0.55 in', '-0.83 in','1 cm'], - '2' => [ '4.4 in', '6.8 in','-0.5 in', '-1.5 in','3.5 in'] + '1' => [ '8.8 in', '6.8 in','-0.55 in', '-0.55 in','1 cm'], + '2' => [ '4.8 in', '6.8 in','-0.5 in', '-1.0 in','3.5 in'] }, }, 'legal' => { @@ -812,6 +812,8 @@ sub details_for_menu { if (!$postdata) { $postdata=$helper->{VARS}{'postdata'}; } my $name_of_resource = &Apache::lonnet::gettitle($postdata); my $symbolic = &Apache::lonnet::symbread($postdata); + return if ( $symbolic eq ''); + my ($map,$id,$resource)=&Apache::lonnet::decode_symb($symbolic); $map=&Apache::lonnet::clutter($map); my $name_of_sequence = &Apache::lonnet::gettitle($map); @@ -1051,20 +1053,16 @@ sub recently_generated { # my $helpervars = Dumper($helper->{'VARS'}); # &Apache::lonnet::logthis("Dump of helper vars:\n $helpervars"); #} -#sub dump_env { -# my $envvars = Dumper(\%env); -# &Apache::lonnet::logthis("Dump of env: \n $envvars"); -#} -#sub get_page_breaks { -# my ($helper) = @_; -# my %page_breaks; -# -# foreach my $break (split /\|\|\|/, $helper->{'VARS'}->{'FINISHPAGE'}) { -# $page_breaks{$break} = 1; -# } -# return %page_breaks; -#} +sub get_page_breaks { + my ($helper) = @_; + my %page_breaks; + + foreach my $break (split /\|\|\|/, $helper->{'VARS'}->{'FINISHPAGE'}) { + $page_breaks{$break} = 1; + } + return %page_breaks; +} # Output a sequence (recursively if neeed) # from construction space. @@ -1114,10 +1112,7 @@ sub print_construction_sequence { $answerform{'answer_output_mode'}='tex'; $answerform{'rndseed'}=$rndseed; $answerform{'problem_split'}=$parmhash{'problem_stream_switch'}; - if ($urlp=~/\/res\//) { - $env{'request.state'}='published'; - } - + if ($urlp=~/\/res\//) {$env{'request.state'}='published';} $resources_printed .= $urlp.':'; my $answer=&Apache::lonnet::ssi($urlp,%answerform); if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { @@ -1205,8 +1200,6 @@ ENDPART my $start_page = &Apache::loncommon::start_page('Preparing Printout',$js); my $msg = &mt('Please stand by while processing your print request, this may take some time ...'); - - $r->print($start_page."\n
\n$msg\n
\n"); # fetch the pagebreaks and store them in the course environment @@ -1258,7 +1251,6 @@ ENDPART } if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') { - #-- single document - problem, page, html, xml, ... my ($currentURL,$cleanURL); @@ -2134,6 +2126,7 @@ sub printHelper { $helper->declareVar('FINISHPAGE'); $helper->declareVar('PRINT_TYPE'); $helper->declareVar("showallfoils"); + $helper->declareVar("STUDENTS"); # The page breaks can get loaded initially from the course environment: # But we only do this in the initial state so that they are allowed to change. @@ -2145,6 +2138,8 @@ sub printHelper { {'pagebreaks' => 'scalar', 'lastprinttype' => 'scalar'}); + # This will persistently load in the data we want from the + # very first screen. if($helper->{VARS}->{PRINT_TYPE} eq $env{'form.lastprinttype'}) { if (!defined ($env{"form.CURRENT_STATE"})) { @@ -2158,16 +2153,18 @@ sub printHelper { } } - - # This will persistently load in the data we want from the - # very first screen. + + # Detect whether we're coming from construction space if ($env{'form.postdata'}=~/^(?:http:\/\/[^\/]+\/|\/|)\~([^\/]+)\/(.*)$/) { $helper->{VARS}->{'filename'} = "~$1/$2"; $helper->{VARS}->{'construction'} = 1; - } elsif ($env{'form.postdata'}) { + } else { if ($env{'form.postdata'}) { $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($env{'form.postdata'}); + if ( $helper->{VARS}->{'symb'} eq '') { + $helper->{VARS}->{'postdata'} = $env{'form.postdata'}; + } } if ($env{'form.symb'}) { $helper->{VARS}->{'symb'} = $env{'form.symb'}; @@ -2177,6 +2174,7 @@ sub printHelper { } } + if ($env{'form.symb'}) { $helper->{VARS}->{'symb'} = $env{'form.symb'}; } @@ -2188,31 +2186,31 @@ sub printHelper { &Apache::lonenc::check_encrypt($helper->{VARS}->{'symb'}); my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu($helper); if ($sequenceTitle ne '') {$helper->{VARS}->{'assignment'}=$sequenceTitle;} + # Extract map my $symb = $helper->{VARS}->{'symb'}; my ($map, $id, $url); my $subdir; + my $is_published=0; # True when printing from resource space. # Get the resource name from construction space - - if ($helper->{VARS}->{'construction'}) { $resourceTitle = substr($helper->{VARS}->{'filename'}, rindex($helper->{VARS}->{'filename'}, '/')+1); $subdir = substr($helper->{VARS}->{'filename'}, 0, rindex($helper->{VARS}->{'filename'}, '/') + 1); - } elsif ($env{'form.postdata'} =~ /^\/res\// ) { - $subdir = substr($env{'form.postdata'}, - 0, rindex($env{'form.postdata'}, '/') + 1); - } elsif ((defined $helper->{VARS}->{'postdata'}) && - ($helper->{VARS}->{'postdata'} =~ /^\/res\//)){ - $subdir = substr($helper->{VARS}->{'postdata'}, - 0, rindex($helper->{VARS}->{'postdata'}, '/') + 1); - } else { # (!$helper->{VARS}->{'postdata'}) { - ($map, $id, $url) = &Apache::lonnet::decode_symb($symb); - $helper->{VARS}->{'postdata'} = - &Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url)); + } else { + if ($symb ne '') { + ($map, $id, $url) = &Apache::lonnet::decode_symb($symb); + $helper->{VARS}->{'postdata'} = + &Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url)); + } else { + $url = $helper->{VARS}->{'postdata'}; + $is_published=1; # From resource space. + } + $url = &Apache::lonnet::clutter($url); + if (!$resourceTitle) { # if the resource doesn't have a title, use the filename my $postdata = $helper->{VARS}->{'postdata'}; $resourceTitle = substr($postdata, rindex($postdata, '/') + 1); @@ -2228,15 +2226,10 @@ sub printHelper { my $userCanSeeHidden = Apache::lonnavmaps::advancedUser(); - &Apache::lonhelper::registerHelperTags(); + Apache::lonhelper::registerHelperTags(); # "Delete everything after the last slash." $subdir =~ s|/[^/]+$||; - if (not $helper->{VARS}->{'construction'}) { - $subdir=$Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'.$subdir; - } - # "Remove all duplicate slashes." - $subdir =~ s|/+|/|g; # What can be printed is a very dynamic decision based on # lots of factors. So we need to dynamically build this list. @@ -2277,10 +2270,9 @@ sub printHelper { "' variable='FINISHPAGE' />"; } - if (($helper->{'VARS'}->{'construction'} ne '1') && + if (($helper->{'VARS'}->{'construction'} ne '1' ) && $helper->{VARS}->{'postdata'} && - ($helper->{VARS}->{'postdata'} !~ /^\/res\//) && $helper->{VARS}->{'assignment'}) { # Allow problems from sequence push @{$printChoices}, [&mt('Selected Problems in folder [_1]',$sequenceTitle), 'map_problems', 'CHOOSE_PROBLEMS']; @@ -2316,9 +2308,9 @@ HELPERFRAGMENT # If the user has pfo (print for otheres) allow them to print all # problems and resources in the entier course, optionally for selected students - if ($perm{'pfo'} && - $helper->{VARS}->{'postdata'} !~/^\/res\// && - $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/) { + if ($perm{'pfo'} && !$is_published && + ($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) { + push @{$printChoices}, ['Selected Problems from entire course', 'all_problems', 'ALL_PROBLEMS']; push @{$printChoices}, ['Selected Resources from entire course', 'all_resources', 'ALL_RESOURCES']; &Apache::lonxml::xmlparse($r, 'helper', <