[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm

foxr lon-capa-cvs@mail.lon-capa.org
Wed, 23 Feb 2005 11:51:41 -0000


foxr		Wed Feb 23 06:51:41 2005 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  Added some context to help the saved pagebreaks not get reset too
  spuriously.   The context is the type of print selected.  I think 
  this will work in most but not all cases.  Context is complicated
  by the interaction between the helper and the printout that is managing
  the context.  The helper knows which resources are available to be printed,
  that's the best context to use to know when to reload the saved pagebreaks,
  however, that information is presented in the same page of the helper in 
  which we want to select the page breaks.  The only other alternative
  is to select page breaks on a separate page of the helper...
  
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.365 loncom/interface/lonprintout.pm:1.366
--- loncom/interface/lonprintout.pm:1.365	Tue Feb 22 18:32:48 2005
+++ loncom/interface/lonprintout.pm	Wed Feb 23 06:51:40 2005
@@ -1,7 +1,7 @@
 #  The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.365 2005/02/22 23:32:48 foxr Exp $
+# $Id: lonprintout.pm,v 1.366 2005/02/23 11:51:40 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -845,9 +845,11 @@
     # 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.pagebreaks'}  = $helper->{'VARS'}->{'FINISHPAGE'};
+    $ENV{'form.lastprinttype'} = $helper->{'VARS'}->{'PRINT_TYPE'}; 
     &Apache::loncommon::store_course_settings('print',
-					      {'pagebreaks' => 'scalar'});
+					      {'pagebreaks'    => 'scalar',
+					       'lastprinttype' => 'scalar'});
 
     my %page_breaks  = &get_page_breaks($helper);
 
@@ -1637,13 +1639,26 @@
     $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'});
+						{'pagebreaks'  => 'scalar',
+					         'lastprinttype' => 'scalar'});
 
-    $helper->{VARS}->{FINISHPAGE} = $ENV{'form.pagebreaks'};
+    
+    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.
@@ -1751,8 +1766,8 @@
     $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') &&
@@ -2030,7 +2045,6 @@
     Apache::lonhelper::message->new();
     $paramHash = Apache::lonhelper::getParamHash();
     $paramHash->{'variable'} = 'PRINT_TYPE';
-    $helper->declareVar('PRINT_TYPE');
     $paramHash->{CHOICES} = $printChoices;
     Apache::lonhelper::choices->new();