[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 22 Aug 2006 14:43:50 -0000
albertel Tue Aug 22 10:43:50 2006 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
- revert to 1.477
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.480 loncom/interface/lonprintout.pm:1.481
--- loncom/interface/lonprintout.pm:1.480 Mon Aug 21 18:53:19 2006
+++ loncom/interface/lonprintout.pm Tue Aug 22 10:43:49 2006
@@ -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.481 2006/08/22 14:43:49 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1051,20 +1051,16 @@
# 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 +1110,7 @@
$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 +1198,6 @@
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<p>\n$msg\n</p>\n");
# fetch the pagebreaks and store them in the course environment
@@ -1258,7 +1249,6 @@
}
if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') {
-
#-- single document - problem, page, html, xml, ...
my ($currentURL,$cleanURL);
@@ -2158,6 +2148,7 @@
}
}
+
# This will persistently load in the data we want from the
# very first screen.
@@ -2165,7 +2156,7 @@
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'});
}
@@ -2177,6 +2168,7 @@
}
}
+
if ($env{'form.symb'}) {
$helper->{VARS}->{'symb'} = $env{'form.symb'};
}
@@ -2188,6 +2180,7 @@
&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'};
@@ -2195,24 +2188,16 @@
my $subdir;
# 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'}) {
+ } else {
($map, $id, $url) = &Apache::lonnet::decode_symb($symb);
$helper->{VARS}->{'postdata'} =
&Apache::lonenc::check_encrypt(&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,7 +2213,7 @@
my $userCanSeeHidden = Apache::lonnavmaps::advancedUser();
- &Apache::lonhelper::registerHelperTags();
+ Apache::lonhelper::registerHelperTags();
# "Delete everything after the last slash."
$subdir =~ s|/[^/]+$||;
@@ -2280,7 +2265,6 @@
if (($helper->{'VARS'}->{'construction'} ne '1') &&
$helper->{VARS}->{'postdata'} &&
- ($helper->{VARS}->{'postdata'} !~ /^\/res\//) &&
$helper->{VARS}->{'assignment'}) {
# Allow problems from sequence
push @{$printChoices}, [&mt('Selected <b>Problems</b> in folder <b><i>[_1]</i></b>',$sequenceTitle), 'map_problems', 'CHOOSE_PROBLEMS'];
@@ -2317,8 +2301,8 @@
# 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)$/) {
+ ($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) {
+
push @{$printChoices}, ['Selected <b>Problems</b> from <b>entire course</b>', 'all_problems', 'ALL_PROBLEMS'];
push @{$printChoices}, ['Selected <b>Resources</b> from <b>entire course</b>', 'all_resources', 'ALL_RESOURCES'];
&Apache::lonxml::xmlparse($r, 'helper', <<ALL_PROBLEMS);
@@ -2626,11 +2610,10 @@
</state>
$resource_selector
CHOOSE_ANON2
-}
+ }
+
# FIXME: That RE should come from a library somewhere.
- if ((((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and
- ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or
- defined $helper->{'VARS'}->{'construction'}) and $perm{'pav'} and $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/') {
+ if ((((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or defined $helper->{'VARS'}->{'construction'}) and $perm{'pav'} and $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/') {
push @{$printChoices}, [&mt("Selected <b>Problems</b> from current subdirectory <b><i>[_1]</i></b>",$subdir), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
my $f = '$filename';
@@ -2656,7 +2639,7 @@
# Allow the user to select any sequence in the course, feed it to
# another resource selector for that sequence
- if (!$helper->{VARS}->{'construction'} && ($helper->{VARS}->{'postdata'} !~ /^\/res\//)) {
+ if (!$helper->{VARS}->{'construction'}) {
push @$printChoices, ["Selected <b>Resources</b> from <b>selected folder</b> in course",
'select_sequences', 'CHOOSE_SEQUENCE'];
my $escapedSequenceName = $helper->{VARS}->{'SEQUENCE'};
@@ -2687,6 +2670,7 @@
</state>
CHOOSE_FROM_ANY_SEQUENCE
}
+
# Generate the first state, to select which resources get printed.
Apache::lonhelper::state->new("START", "Select Printing Options:");
$paramHash = Apache::lonhelper::getParamHash();