--- loncom/interface/lonprintout.pm 2006/09/06 21:56:30 1.477.2.1
+++ 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.477.2.1 2006/09/06 21:56:30 albertel Exp $
+# $Id: lonprintout.pm,v 1.484 2006/09/05 15:41:09 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -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);
@@ -2124,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.
@@ -2135,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"})) {
@@ -2149,9 +2154,7 @@ 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";
@@ -2159,6 +2162,9 @@ sub printHelper {
} 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'};
@@ -2186,6 +2192,7 @@ sub printHelper {
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'}) {
@@ -2194,9 +2201,15 @@ sub printHelper {
$subdir = substr($helper->{VARS}->{'filename'},
0, rindex($helper->{VARS}->{'filename'}, '/') + 1);
} else {
- ($map, $id, $url) = &Apache::lonnet::decode_symb($symb);
- $helper->{VARS}->{'postdata'} =
- &Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url));
+ 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'};
@@ -2217,11 +2230,6 @@ sub printHelper {
# "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.
@@ -2262,7 +2270,7 @@ sub printHelper {
"' variable='FINISHPAGE' />";
}
- if (($helper->{'VARS'}->{'construction'} ne '1') &&
+ if (($helper->{'VARS'}->{'construction'} ne '1' ) &&
$helper->{VARS}->{'postdata'} &&
$helper->{VARS}->{'assignment'}) {
@@ -2300,7 +2308,7 @@ 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'} &&
+ 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'];
@@ -2328,7 +2336,7 @@ HELPERFRAGMENT
ALL_PROBLEMS
if ($helper->{VARS}->{'assignment'}) {
- push @{$printChoices}, [&mt("Selected Problems from folder [_1] for selected students",$sequenceTitle), 'problems_for_students', 'CHOOSE_STUDENTS'];
+ push @{$printChoices}, [&mt("Selected Problems from folder [_1] for selected people",$sequenceTitle), 'problems_for_students', 'CHOOSE_STUDENTS'];
push @{$printChoices}, [&mt("Selected Problems from folder [_1] for CODEd assignments",$sequenceTitle), 'problems_for_anon', 'CHOOSE_ANON1'];
}
@@ -2503,7 +2511,7 @@ CHOOSE_ANON1
if ($helper->{VARS}->{'assignment'}) {
- push @{$printChoices}, [&mt("Selected Resources from folder [_1] for selected students",$sequenceTitle), 'resources_for_students', 'CHOOSE_STUDENTS1'];
+ push @{$printChoices}, [&mt("Selected Resources from folder [_1] for selected people",$sequenceTitle), 'resources_for_students', 'CHOOSE_STUDENTS1'];
push @{$printChoices}, [&mt("Selected Resources from folder [_1] for CODEd assignments",$sequenceTitle), 'resources_for_anon', 'CHOOSE_ANON2'];
}
@@ -2613,12 +2621,21 @@ 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/') {
- push @{$printChoices}, [&mt("Selected Problems from current subdirectory [_1]",$subdir), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
+ if (($perm{'pav'}
+ && $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'
+ && (defined($helper->{'VARS'}->{'construction'})
+ ||
+ (&Apache::lonnet::allowed('bre',$subdir) eq 'F'
+ &&
+ $helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)
+ ))
+ && $helper->{VARS}->{'assignment'} eq ""
+ ) {
- my $f = '$filename';
+ my $pretty_dir = &Apache::lonnet::hreflocation($subdir);
+ push @{$printChoices}, [&mt("Selected Problems from current subdirectory [_1]",$pretty_dir), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
my $xmlfrag = <
+
PAGESIZE
@@ -2639,7 +2656,7 @@ CHOOSE_FROM_SUBDIR
# Allow the user to select any sequence in the course, feed it to
# another resource selector for that sequence
- if (!$helper->{VARS}->{'construction'}) {
+ if (!$helper->{VARS}->{'construction'} && !$is_published) {
push @$printChoices, ["Selected Resources from selected folder in course",
'select_sequences', 'CHOOSE_SEQUENCE'];
my $escapedSequenceName = $helper->{VARS}->{'SEQUENCE'};