[LON-CAPA-cvs] cvs: loncom(bz2851) /interface lonprintout.pm
foxr
foxr@source.lon-capa.org
Tue, 08 Sep 2009 10:53:15 -0000
This is a MIME encoded message
--foxr1252407195
Content-Type: text/plain
foxr Tue Sep 8 10:53:15 2009 EDT
Modified files: (Branch: bz2851)
/loncom/interface lonprintout.pm
Log:
- Remove logging from lonnavmaps.pm (don't need it anymore)
- Progress so far on page printing.
- Document issues to go in comments at top of the file.
--foxr1252407195
Content-Type: text/plain
Content-Disposition: attachment; filename="foxr-20090908105315.txt"
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.560.2.2 loncom/interface/lonprintout.pm:1.560.2.3
--- loncom/interface/lonprintout.pm:1.560.2.2 Tue Aug 25 10:57:18 2009
+++ loncom/interface/lonprintout.pm Tue Sep 8 10:53:15 2009
@@ -1,7 +1,17 @@
+#
+# Issues:
+# - Need to get the state flow for selected problems/resources for students
+# correct
+# - Need to do the CODEd stuff.
+# - Need to regularize and figure out for each case who puts on the latex
+# front matter and make sure it gets done.
+#
+#
+
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.560.2.2 2009/08/25 10:57:18 foxr Exp $
+# $Id: lonprintout.pm,v 1.560.2.3 2009/09/08 10:53:15 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -111,6 +121,65 @@
return $result;
}
+# Generate the text needed for a resource chooser given the top level of
+# the sequence/page
+#
+# Parameters:
+# this_state - State name of the chooser.
+# prompt_text - Text to use to prompt user.
+# resource_options - Resource tag options e.g.
+# "multichoice='1', toponly='1', addstatus='1'"
+# that control the selection and appearance of the
+# resource selector.
+# variable - Name of the variable to hold the choice
+# next_state - Name of the next state the helper should transition
+# to
+# top_url - Top level URL within which to make the selector.
+# If empty the top level sequence is shown.
+# filter - How to filter the resources.
+# value_func - <valuefunc> function.
+# choice_func - If not empty generates a <choicefunc> with this function.
+# start_new_option
+# - Fragment appended after valuefunc.
+#
+#
+sub generate_resource_chooser {
+ my ($this_state,
+ $prompt_text,
+ $resource_options,
+ $variable,
+ $next_state,
+ $top_url,
+ $filter,
+ $choice_func,
+ $value_func,
+ $start_new_option) = @_;
+
+
+ my $result = <<CHOOSE_RESOURCES;
+<state name="$this_state" title="$prompt_text">
+ <resource variable="$variable" $resource_options
+ closeallpages="1">
+ <nextstate>$next_state</nextstate>
+ <filterfunc>return $filter;</filterfunc>
+CHOOSE_RESOURCES
+ if ($value_func ne '') {
+ $result .= "<choicefunc>return $choice_func;</choicefunc>";
+ }
+ if ($top_url ne '') {
+ $result .= "<mapurl>$top_url</mapurl>";
+ }
+ $result .= <<CHOOSE_RESOURCES;
+ <valuefunc>return $value_func;</valuefunc>
+ $start_new_option
+ </resource>
+ </state>
+CHOOSE_RESOURCES
+
+ return $result;
+}
+
+
#-----------------------------------------------------------------------
@@ -3080,36 +3149,35 @@
'map_resources_in_page',
'CHOOSE_RESOURCES_PAGE'];
}
- my $helperFragment = <<HELPERFRAGMENT;
- <state name="CHOOSE_PROBLEMS_PAGE" title="Select Problem(s) to print">
- <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
- closeallpages="1">
- <nextstate>PAGESIZE</nextstate>
- <filterfunc>return $isProblem;</filterfunc>
- <mapurl>$url</mapurl>
- <valuefunc>return $symbFilter;</valuefunc>
- $start_new_option
- </resource>
- </state>
+ my $helperFragment = &generate_resource_chooser('CHOOSE_PROBLEMS_PAGE',
+ 'Select Problem(s) to print',
+ "multichoice='1' toponly='1', addstatus='1' closeallpages='1'",
+ 'RESOURCES',
+ 'PAGESIZE',
+ $url,
+ $isProblem, '', $symbFilter,
+ $start_new_option);
+
+
+ $helperFragment .= &generate_resource_chooser('CHOOSE_RESOURCES_PAGE',
+ 'Select Resource(s) to print',
+ 'multichoice="1" toponly="1" addstatus="1" closeallpages="1"',
+ 'RESOURCES',
+ 'PAGESIZE',
+ $url,
+ $isNotMap, '', $symbFilter,
+ $start_new_option);
+
+
+
- <state name="CHOOSE_RESOURCES_PAGE" title="Select Resource(s) to print">
- <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
- closeallpages="1">
- <nextstate>PAGESIZE</nextstate>
- <filterfunc>return $isNotMap;</filterfunc>
- <mapurl>$url</mapurl>
- <valuefunc>return $symbFilter;</valuefunc>
- $start_new_option
- </resource>
- </state>
-HELPERFRAGMENT
&Apache::lonxml::xmlparse($r, 'helper', $helperFragment);
}
}
- if (($helper->{'VARS'}->{'construction'} ne '1' ) &&
+ if (($helper->{'VAR'}->{'construction'} ne '1' ) &&
$helper->{VARS}->{'postdata'} &&
$helper->{VARS}->{'assignment'}) {
# Allow problems from sequence
@@ -3122,29 +3190,24 @@
'map_problems_pages',
'CHOOSE_PROBLEMS_HTML'];
&Apache::lonnet::logthis("Map url : $map");
- my $helperFragment = <<HELPERFRAGMENT;
- <state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print">
- <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
- closeallpages="1">
- <nextstate>PAGESIZE</nextstate>
- <filterfunc>return $isProblem;</filterfunc>
- <mapurl>$map</mapurl>
- <valuefunc>return $symbFilter;</valuefunc>
- $start_new_option
- </resource>
- </state>
-
- <state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print">
- <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
- closeallpages="1">
- <nextstate>PAGESIZE</nextstate>
- <filterfunc>return $isNotMap;</filterfunc>
- <mapurl>$map</mapurl>
- <valuefunc>return $symbFilter;</valuefunc>
- $start_new_option
- </resource>
- </state>
-HELPERFRAGMENT
+ my $helperFragment = &generate_resource_chooser('CHOOSE_PROBLEMS',
+ 'Select Problem(s) to print',
+ 'multichoice="1" toponly="1" addstatus="1" closeallpages="1"',
+ 'RESOURCES',
+ 'PAGESIZE',
+ $map,
+ $isProblem, '',
+ $symbFilter,
+ $start_new_option);
+ $helperFragment .= &generate_resource_chooser('CHOOSE_PROBLEMS_HTML',
+ 'Select Resource(s) to print',
+ 'multichoice="1" toponly="1" addstatus="1" closeallpages="1"',
+ 'RESOURCES',
+ 'PAGESIZE',
+ $map,
+ $isNotMap, '',
+ $symbFilter,
+ $start_new_option);
&Apache::lonxml::xmlparse($r, 'helper', $helperFragment);
}
@@ -3158,36 +3221,7 @@
push @{$printChoices}, [&mtn('Selected <b>Problems</b> from <b>entire course</b>'), 'all_problems', 'ALL_PROBLEMS'];
push @{$printChoices}, [&mtn('Selected <b>Resources</b> from <b>entire course</b>'), 'all_resources', 'ALL_RESOURCES'];
push @{$printChoices}, [&mtn('Selected <b>Problems</b> from <b>entire course</b> for <b>selected people</b>'), 'all_problems_students', 'ALL_PROBLEMS_STUDENTS'];
- &Apache::lonxml::xmlparse($r, 'helper', <<ALL_PROBLEMS);
- <state name="ALL_PROBLEMS" title="Select Problem(s) to print">
- <resource variable="RESOURCES" toponly='0' multichoice="1"
- suppressEmptySequences='0' addstatus="1" closeallpages="1">
- <nextstate>PAGESIZE</nextstate>
- <filterfunc>return $isProblemOrMap;</filterfunc>
- <choicefunc>return $isNotMap;</choicefunc>
- <valuefunc>return $symbFilter;</valuefunc>
- $start_new_option
- </resource>
- </state>
- <state name="ALL_RESOURCES" title="Select Resource(s) to print">
- <resource variable="RESOURCES" toponly='0' multichoice='1'
- suppressEmptySequences='0' addstatus='1' closeallpages='1'>
- <nextstate>PAGESIZE</nextstate>
- <filterfunc>return $isNotMap; </filterfunc>
- <valuefunc>return $symbFilter;</valuefunc>
- $start_new_option
- </resource>
- </state>
- <state name="ALL_PROBLEMS_STUDENTS" title="Select Problem(s) to print">
- <resource variable="RESOURCES" toponly='0' multichoice="1"
- suppressEmptySequences='0' addstatus="1" closeallpages="1">
- <nextstate>STUDENTS1</nextstate>
- <filterfunc>return $isProblemOrMap;</filterfunc>
- <choicefunc>return $isNotMap;</choicefunc>
- <valuefunc>return $symbFilter;</valuefunc>
- $start_new_option
- </resource>
- </state>
+my $suffixXml = <<ALL_PROBLEMS;
<state name="STUDENTS1" title="Select People">
<message><b>Select sorting order of printout</b> </message>
<choices variable='student_sort'>
@@ -3197,8 +3231,35 @@
<message><br /><hr /><br /> </message>
<student multichoice='1' variable="STUDENTS" nextstate="PRINT_FORMATTING" coursepersonnel="1"/>
</state>
-
ALL_PROBLEMS
+ &Apache::lonxml::xmlparse($r, 'helper',
+ &generate_resource_chooser('ALL_PROBLEMS',
+ 'SelectProblem(s) to print',
+ 'multichoice="1" suppressEmptySequences="0" addstatus="1" closeallpages="1"',
+ 'RESOURCES',
+ 'PAGESIZE',
+ '',
+ $isProblemOrMap, $isNotMap,
+ $symbFilter,
+ $start_new_option) .
+ &generate_resource_chooser('ALL_RESOURCES',
+ 'Select Resource(s) to print',
+ " toponly='0' multichoice='1' suppressEmptySequences='0' addstatus='1' closeallpages='1'",
+ 'RESOURCES',
+ 'PAGESIZE',
+ '',
+ $isNotMap,,$symbFilter,
+ $start_new_option) .
+ &generate_resource_chooser('ALL_PROBLEMS_STUDENTS',
+ 'Select Problem(s) to print',
+ 'toponly="0" multichoice="1" suppressEmptySequences="0" addstatus="1" closeallpages="1"',
+ 'RESOURCES',
+ 'STUDENTS1',
+ '',
+ $isProblemOrMap, , $symbFilter,
+ $start_new_option) .
+ $suffixXml
+ );
if ($helper->{VARS}->{'assignment'}) {
@@ -3233,20 +3294,15 @@
# with one state, and use REGEXPs at inclusion time to set state names
# and next states for better mix and match capability
#
- my $resource_selector=<<RESOURCE_SELECTOR;
- <state name="SELECT_PROBLEMS" title="Select resources to print">
- $randomly_ordered_warning
-
- <nextstate>PRINT_FORMATTING</nextstate>
- <message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message>
- <resource variable="RESOURCES" multichoice="1" addstatus="1"
- closeallpages="1">
- <filterfunc>return $isProblem;</filterfunc>
- <mapurl>$map</mapurl>
- <valuefunc>return $symbFilter;</valuefunc>
- $start_new_option
- </resource>
- </state>
+ my $resource_selector= &generate_resource_chooser('SELECT_PROBLEMS',
+ 'Select resources to print',
+ 'multichoice="1" addstatus="1" closeallpages="1"',
+ 'RESOURCES',
+ 'PRINT_FORMATTING',
+ '',
+ $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">
@@ -3271,26 +3327,13 @@
-# &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS);
-# <state name="CHOOSE_STUDENTS" title="Select Students and Resources">
-# <message><b>Select sorting order of printout</b> </message>
-# <choices variable='student_sort'>
-#
-#
-# <choice computer='0'>Sort by section then student</choice>
-# <choice computer='1'>Sort by students across sections.</choice>
-# </choices>
-# <message><br /><hr /><br /> </message>
-# <student multichoice='1' variable="STUDENTS" nextstate="SELECT_PROBLEMS" coursepersonnel="1"/>
-# </state>
+
&Apache::lonxml::xmlparse($r, 'helper',
&generate_student_chooser('CHOOSE_STUDENTS',
'student_sort',
'STUDENTS',
'SELECT_PROBLEMS'));
&Apache::lonxml::xmlparse($r, 'helper', $resource_selector);
-# $resource_selector
-# CHOOSE_STUDENTS
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
@@ -3416,7 +3459,6 @@
$resource_selector=<<RESOURCE_SELECTOR;
<state name="SELECT_RESOURCES" title="Select Resources">
$randomly_ordered_warning
-
<nextstate>PRINT_FORMATTING</nextstate>
<message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message>
<resource variable="RESOURCES" multichoice="1" addstatus="1"
@@ -3427,6 +3469,7 @@
$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>
--foxr1252407195--