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

raeburn raeburn at source.lon-capa.org
Thu Sep 15 12:33:57 EDT 2011


raeburn		Thu Sep 15 16:33:57 2011 EDT

  Modified files:              (Branch: version_2_10_X)
    /loncom/interface	lonprintout.pm 
  Log:
  - Backport 1.586, 1.587, 1.597, 1.598.
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.583.2.4 loncom/interface/lonprintout.pm:1.583.2.5
--- loncom/interface/lonprintout.pm:1.583.2.4	Tue Nov  9 19:19:25 2010
+++ loncom/interface/lonprintout.pm	Thu Sep 15 16:33:57 2011
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.583.2.4 2010/11/09 19:19:25 raeburn Exp $
+# $Id: lonprintout.pm,v 1.583.2.5 2011/09/15 16:33:57 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -256,6 +256,46 @@
    return $result;
 }
 
+#  Returns the XML for choosing how assignments are to be formatted
+#  that text must still be parsed by the helper xml parser.
+# Parameters: 3 (required)
+
+#   helper       - The helper; $helper->{'VARS'}->{'PRINT_TYPE'} used
+#                  to check if splitting PDFs by section can be offered.
+#   title        - Title for the current state.
+#   this_state   - State name of the chooser.
+
+sub generate_format_selector {
+    my ($helper,$title,$this_state) = @_;
+    my $secpdfoption;
+    unless (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon')     ||
+            ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon_page') ||
+            ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon')  ) {
+        $secpdfoption =  '<choice computer="sections">Each PDF contains exactly one section</choice>';
+    }
+    return <<RESOURCE_SELECTOR;
+    <state name="$this_state" title="$title">
+    <message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>
+    <choices variable="EMPTY_PAGES">
+      <choice computer='0'>Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)</choice>
+      <choice computer='1'>Add one empty page/column after each student\'s assignment</choice>
+      <choice computer='2'>Add two empty pages/column after each student\'s assignment</choice>
+      <choice computer='3'>Add three empty pages/column after each student\'s assignment</choice>
+    </choices>
+    <nextstate>PAGESIZE</nextstate>
+    <message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message>
+    <choices variable="SPLIT_PDFS">
+       <choice computer="all">All assignments in a single PDF file</choice>
+       $secpdfoption
+       <choice computer="oneper">Each PDF contains exactly one assignment</choice>
+       <choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT">
+            Specify the number of assignments per PDF:</choice>
+    </choices>
+    </state>
+RESOURCE_SELECTOR
+}
+
+
 #-----------------------------------------------------------------------
 
 
@@ -2653,7 +2693,8 @@
 	 my ($type) = split(/_/,$helper->{'VARS'}->{'PRINT_TYPE'});
 	 &adjust_number_to_print($helper);
 	 my $number_per_page=$helper->{'VARS'}->{'NUMBER_TO_PRINT'};
-	 if ($number_per_page eq '0' || $number_per_page eq 'all') {
+	 if ($number_per_page eq '0' || $number_per_page eq 'all'
+             || $number_per_page eq 'section') {
 	     $number_per_page=$num_todo;
 	 }
 	 my $flag_latex_header_remove = 'NO'; 
@@ -3559,27 +3600,10 @@
 							  $map,
 							  $isProblem, '', $symbFilter,
 							  $start_new_option);
-	$resource_selector .=  <<RESOURCE_SELECTOR;
-    <state name="PRINT_FORMATTING" title="How should results be printed?">
-    <message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>
-    <choices variable="EMPTY_PAGES">
-      <choice computer='0'>Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)</choice>
-      <choice computer='1'>Add one empty page/column after each student\'s assignment</choice>
-      <choice computer='2'>Add two empty pages/column after each student\'s assignment</choice>
-      <choice computer='3'>Add three empty pages/column after each student\'s assignment</choice>
-    </choices>
-    <nextstate>PAGESIZE</nextstate>
-    <message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message>
-    <choices variable="SPLIT_PDFS">
-       <choice computer="all">All assignments in a single PDF file</choice>
-       <choice computer="sections">Each PDF contains exactly one section</choice>
-       <choice computer="oneper">Each PDF contains exactly one assignment</choice>
-       <choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT">
-            Specify the number of assignments per PDF:</choice>
-    </choices>
-    </state>
-RESOURCE_SELECTOR
-        $resource_selector .= &generate_resource_chooser('CHOOSE_STUDENTS_PAGE',
+        $resource_selector .=  &generate_format_selector($helper,
+                                                         'How should results be printed?',
+                                                         'PRINT_FORMATTING').
+                               &generate_resource_chooser('CHOOSE_STUDENTS_PAGE',
 							'Select Problem(s) to print',
 							"multichoice='1' addstatus='1' closeallpages ='1'",
 							'RESOURCES',
@@ -3707,28 +3731,11 @@
       $start_new_option
       </resource>
     </state>
-
-    <state name="PRINT_FORMATTING" title="Format of the print job">
-    <nextstate>NUMBER_PER_PDF</nextstate>
-    <message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>
-    <choices variable="EMPTY_PAGES">
-      <choice computer='0'>Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)</choice>
-      <choice computer='1'>Add one empty page/column after each student\'s assignment</choice>
-      <choice computer='2'>Add two empty pages/column after each student\'s assignment</choice>
-      <choice computer='3'>Add three empty pages/column after each student\'s assignment</choice>
-    </choices>
-    <nextstate>PAGESIZE</nextstate>
-    <message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message>
-    <choices variable="SPLIT_PDFS">
-       <choice computer="all">All assignments in a single PDF file</choice>
-       <choice computer="sections">Each PDF contains exactly one section</choice>
-       <choice computer="oneper">Each PDF contains exactly one assignment</choice>
-       <choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT">
-           Specify the number of assignments per PDF:</choice>
-    </choices>
-    </state>
 RESOURCE_SELECTOR
 
+        $resource_selector .= &generate_format_selector($helper,
+                                                        'Format of the print job',
+                                                        'PRINT_FORMATTING');
 	&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS1);
   <state name="CHOOSE_STUDENTS1" title="Select Students and Resources">
     <choices variable='student_sort'>




More information about the LON-CAPA-cvs mailing list