--- loncom/interface/lonprintout.pm 2005/02/17 08:29:43 1.361
+++ loncom/interface/lonprintout.pm 2005/02/23 11:51:40 1.366
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.361 2005/02/17 08:29:43 albertel Exp $
+# $Id: lonprintout.pm,v 1.366 2005/02/23 11:51:40 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -781,6 +781,27 @@ sub unsupported {
}
+#
+# Retrieve the hash of page breaks.
+#
+# Inputs:
+# helper - reference to helper object.
+# Outputs
+# A reference to a page break hash.
+#
+#
+
+sub get_page_breaks {
+ my ($helper) = @_;
+ my %page_breaks;
+
+ foreach my $break (split /\|\|\|/, $helper->{'VARS'}->{'FINISHPAGE'}) {
+ $page_breaks{$break} = 1;
+ }
+
+ return %page_breaks;
+}
+
sub output_data {
my ($r,$helper,$rparmhash) = @_;
my %parmhash = %$rparmhash;
@@ -819,6 +840,19 @@ $bodytag
Please stand by while processing your print request, this may take some time ...
ENDPART
+
+ # fetch the pagebreaks and store them in the course environment
+ # The page breaks will be pulled into the hash %page_breaks which is
+ # indexed by symb and contains 1's for each break.
+
+ $ENV{'form.pagebreaks'} = $helper->{'VARS'}->{'FINISHPAGE'};
+ $ENV{'form.lastprinttype'} = $helper->{'VARS'}->{'PRINT_TYPE'};
+ &Apache::loncommon::store_course_settings('print',
+ {'pagebreaks' => 'scalar',
+ 'lastprinttype' => 'scalar'});
+
+ my %page_breaks = &get_page_breaks($helper);
+
my $format_from_helper = $helper->{'VARS'}->{'FORMAT'};
my ($result,$selectionmade) = ('','');
my $number_of_columns = 1; #used only for pages to determine the width of the cell
@@ -1012,10 +1046,6 @@ ENDPART
my $flag_latex_header_remove = 'NO';
my $flag_page_in_sequence = 'NO';
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
- my %page_breaks;
- foreach my $break (split /\|\|\|/, $helper->{'VARS'}->{'FINISHPAGE'}) {
- $page_breaks{$break} = 1;
- }
my $prevassignment='';
&Apache::lonnet::delenv('form.counter');
&Apache::lonxml::init_counter();
@@ -1427,15 +1457,14 @@ sub print_resources {
$namepostfix="\\\\Name: ";
$fullname = "CODE - ".$moreenv->{'CODE'};
}
- my %page_breaks;
- foreach my $break (split /\|\|\|/,$helper->{'VARS'}->{'FINISHPAGE'}) {
- $page_breaks{$break} = 1;
- }
my $i = 0;
#goes through all resources, checks if they are available for
#current student, and produces output
&Apache::lonnet::delenv('form.counter');
&Apache::lonxml::init_counter();
+
+ my %page_breaks = &get_page_breaks($helper);
+
foreach my $curresline (@{$master_seq}) {
if (defined $page_breaks{$curresline}) {
if($i != 0) {
@@ -1609,6 +1638,27 @@ sub printHelper {
$helper->declareVar('assignment');
$helper->declareVar('style_file');
$helper->declareVar('student_sort');
+ $helper->declareVar('FINISHPAGE');
+ $helper->declareVar('PRINT_TYPE');
+
+ # The page breaks can get loaded initially from the course environment:
+
+ if((!defined($ENV{"form.CURRENT_STATE"})) ||
+ ($ENV{'form.CURRENT_STATE'} == "START")) {
+ $helper->{VARS}->{FINISHPAGE} = ""; # In case they did a back e.g.
+ }
+
+
+
+ &Apache::loncommon::restore_course_settings('print',
+ {'pagebreaks' => 'scalar',
+ 'lastprinttype' => 'scalar'});
+
+
+ if("$helper->{VARS}->{PRINT_TYPE}" eq "$ENV{'form.lastprinttype'}") {
+ $helper->{VARS}->{FINISHPAGE} = $ENV{'form.pagebreaks'};
+ }
+
# This will persistently load in the data we want from the
# very first screen.
@@ -1716,8 +1766,8 @@ sub printHelper {
$helper->declareVar('SEQUENCE');
# Useful for debugging: Dump the help vars
- #$r->print(Dumper($helper->{VARS}));
- #$r->print($map);
+# $r->print(Dumper($helper->{VARS}));
+# $r->print($map);
# If we're in a sequence...
if (($helper->{'VARS'}->{'construction'} ne '1') &&
@@ -1783,7 +1833,6 @@ HELPERFRAGMENT
suppressEmptySequences='0' addstatus='1' closeallpages='1'>
PAGESIZEreturn $isNotMap;
- $map
return $symbFilter;
@@ -1837,10 +1886,22 @@ CHOOSE_STUDENTS
&Apache::lonxml::xmlparse($r, 'helper', <PAGESIZE
- Number of anonymous assignments to print?
-
- Names to store the CODEs under for later:
+
+
Number of anonymous assignments to print?
+
+
+ if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) &&
+ !\$helper->{'VARS'}{'REUSE_OLD_CODES'}) {
+ return "You need to specify the number of assignments to print";
+ }
+ return undef;
+
+
+
+ Names to store the CODEs under for later:
+
+
Reprint a set of saved CODEs:
@@ -1893,10 +1954,21 @@ CHOOSE_STUDENTS1
&Apache::lonxml::xmlparse($r, 'helper', <PAGESIZE
- Number of anonymous assignments to print?
-
- Names to store the CODEs under for later:
+
Number of anonymous assignments to print?
+
+
+ if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) &&
+ !\$helper->{'VARS'}{'REUSE_OLD_CODES'}) {
+ return "You need to specify the number of assignments to print";
+ }
+ return undef;
+
+
+
+ Names to store the CODEs under for later:
+
+
Reprint a set of saved CODEs:
@@ -1973,7 +2045,6 @@ CHOOSE_FROM_ANY_SEQUENCE
Apache::lonhelper::message->new();
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{'variable'} = 'PRINT_TYPE';
- $helper->declareVar('PRINT_TYPE');
$paramHash->{CHOICES} = $printChoices;
Apache::lonhelper::choices->new();