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

foxr lon-capa-cvs@mail.lon-capa.org
Tue, 22 Feb 2005 11:43:06 -0000


foxr		Tue Feb 22 06:43:06 2005 EDT

  Modified files:              
    /loncom/interface	lonhelper.pm lonprintout.pm 
  Log:
  BZ 3173:
    Save the pagebreak positions as course paramters to that they can be
  reproduced.  Note that at present, what is saved is the set of symbnames
  in front of which a pagebreak should occur.  No printing context is
  saved.  This means that if you later print multiple resources which overlap
  with a prior multiple resource print, you will have some pagebreaks pre-set.
  This may not be wholly bad, but is probably not wholly good either.
  
  
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.97 loncom/interface/lonhelper.pm:1.98
--- loncom/interface/lonhelper.pm:1.97	Thu Feb 17 18:19:44 2005
+++ loncom/interface/lonhelper.pm	Tue Feb 22 06:43:05 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.97 2005/02/17 23:19:44 albertel Exp $
+# $Id: lonhelper.pm,v 1.98 2005/02/22 11:43:05 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1977,6 +1977,7 @@
 	$mapUrl = $self->{MAP_URL};
     }
 
+
     # Create the composite function that renders the column on the nav map
     # have to admit any language that lets me do this can't be all bad
     #  - Jeremy (Pythonista) ;-)
@@ -2005,14 +2006,19 @@
             return $result;
         } else {
 	    my $col = "";
+	    my $raw_name = &$valueFunc($resource);
 	    my $resource_name =   
-                   HTML::Entities::encode(&$valueFunc($resource),"<>&\"'");
+                   HTML::Entities::encode($raw_name,"<>&\"'");
 	    if($option_vars) {
 		foreach my $option_var (@$option_vars) {
+		    my $checked ="";
+		    if($helper->{VARS}->{$option_var} =~ /$raw_name/) {
+			$checked = "checked";
+		    }
 		    $col .= 
                         "<td align='center'><input type='checkbox' name ='$option_var".
 			".forminput' value='".
-			$resource_name . "' /> </td>";
+			$resource_name . "' $checked /> </td>";
 		}
 	    }
 
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.362 loncom/interface/lonprintout.pm:1.363
--- loncom/interface/lonprintout.pm:1.362	Thu Feb 17 18:19:44 2005
+++ loncom/interface/lonprintout.pm	Tue Feb 22 06:43:05 2005
@@ -1,7 +1,7 @@
 #  The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.362 2005/02/17 23:19:44 albertel Exp $
+# $Id: lonprintout.pm,v 1.363 2005/02/22 11:43:05 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -781,6 +781,29 @@
 }
 
 
+#
+#   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 +842,20 @@
 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'};
+    &Apache::loncommon::store_course_settings('print',
+					      {'pagebreaks' => 'scalar'});
+
+    my $page_hashref = &get_page_breaks($helper);
+    my %page_breaks  = %$page_hashref;
+
+
+
     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 +1049,6 @@
 	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 +1460,15 @@
 	$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_hashref = &get_page_breaks($helper);
+    my %page_breaks  = %$page_hashref;
+
     foreach my $curresline (@{$master_seq})  {
 	if (defined $page_breaks{$curresline}) {
 	    if($i != 0) {
@@ -1609,6 +1642,14 @@
     $helper->declareVar('assignment');
     $helper->declareVar('style_file');
     $helper->declareVar('student_sort');
+    $helper->declareVar('FINISHPAGE');
+
+    #  The page breaks can get loaded initially from the course environment:
+    
+    &Apache::loncommon::restore_course_settings('print',
+						{'pagebreaks' => 'scalar'});
+
+    $helper->{VARS}->{FINISHPAGE} = $ENV{'form.pagebreaks'};
     
     # This will persistently load in the data we want from the
     # very first screen.