[LON-CAPA-cvs] cvs: loncom(PRINT_INCOMPLETE) /interface lonprintout.pm
foxr
foxr@source.lon-capa.org
Tue, 11 May 2010 11:10:19 -0000
foxr Tue May 11 11:10:19 2010 EDT
Modified files: (Branch: PRINT_INCOMPLETE)
/loncom/interface lonprintout.pm
Log:
Building the helper states modularly.
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.575.2.1 loncom/interface/lonprintout.pm:1.575.2.2
--- loncom/interface/lonprintout.pm:1.575.2.1 Mon May 10 10:21:24 2010
+++ loncom/interface/lonprintout.pm Tue May 11 11:10:19 2010
@@ -2,7 +2,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.575.2.1 2010/05/10 10:21:24 foxr Exp $
+# $Id: lonprintout.pm,v 1.575.2.2 2010/05/11 11:10:19 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -74,8 +74,23 @@
my $font_size = 'normalsize'; # Default is normalsize...
+#
+# Useful filters that will be filled in by printHelper.
+# These are put here to support modularizing helpers into
+# less of a helper soup than it was originally:
+# These can't be filled in here as there's some conditionalization
+# involved.
+#
+
+my $isProblem;
+my $isProblemOrMap;
+my $isNotMap;
+my $isMap;
+my $symbFilter;
+
#---------------------------- Helper helpers. -------------------------
+
# Returns the text needd for a student chooser.
# that text must still be parsed by the helper xml parser.
# Parameters:
@@ -239,6 +254,42 @@
return $result;
}
+# Returns the XML for the states associated with choosing incomplete problems
+# for selected students:
+# Paramterss:
+# helper - reference to the helper.
+# map - Map within which to generate the selector.
+# base_state - The first/base state of the helper subsegment.
+#
+#
+#
+# States we will use:
+# $base_state - Selects resources.
+# $base_state.WHO - Selects the people to display.
+# $base_state.FORMAT - Selects the final print format etc.
+#
+
+sub generate_incomplete_states {
+ my ($helper, $map, $base_state) = @_;
+ my $result = '';
+
+ $result .= &generate_resource_chooser(
+ $base_state,
+ 'Select Problem(s) to print.',
+ "multichoice='1' addstatus='1'",
+ 'RESOURCES',
+ $base_state.'WHO',
+ '',
+ '$res->is_incomplete()'
+ );
+ $result .= &generate_student_chooser(
+ $base_state.'WHO',
+ 'student_sort',
+ 'STUDENTS',
+ $base_state.'FORMAT');
+ return $result;
+}
+
#-----------------------------------------------------------------------
# Fetch the contents of a resource, uninterpreted.
@@ -3642,7 +3693,11 @@
}
- # Detect whether we're coming from construction space
+ # Detect whether we're coming from construction space. If so,
+ # $helper->{VARS}->{'construction'} will be defined and true.
+ # Otherwise, if this is a post, load the helper 'postdata' var with
+ # the posted form data.
+
if (
$env{'form.postdata'} =~ /^(?:http:\/\/[^\/]+\/|\/|)\~([^\/]+)\/(.*)$/ )
{
@@ -3755,15 +3810,16 @@
}
# Useful filter strings
- my $isProblem =
+ $isProblem =
'($res->is_problem()||$res->contains_problem||$res->is_practice()) ';
$isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;
- my $isProblemOrMap =
+ $isProblemOrMap =
'$res->is_problem() || $res->contains_problem() || $res->is_sequence() || $res->is_practice()';
- my $isNotMap = '!$res->is_sequence()';
+ $isNotMap = '!$res->is_sequence()';
$isNotMap .= ' && !$res->randomout()' if !$userCanSeeHidden;
- my $isMap = '$res->is_map()';
- my $symbFilter = '$res->shown_symb()';
+ $isMap = '$res->is_map()';
+ $symbFilter = '$res->shown_symb()';
+
my $urlValue = '$res->link()';
$helper->declareVar('SEQUENCE');
@@ -3949,9 +4005,22 @@
<student multichoice='1' variable="STUDENTS" nextstate="PRINT_FORMATTING" coursepersonnel="1"/>
</state>
ALL_PROBLEMS
+ #
+ # Support printing incompleteproblems.:
+ #
+ push @{$printChoices},
+ [
+ &mtn('Incomplete <b>Problems</b> from <b>entire course</b> for <b>selected people</b>'),
+ 'incomplete_problems_students',
+ 'INCOMPLETE_PROBLEMS_STUDENTS'
+ ];
+
&Apache::lonxml::xmlparse(
$r, 'helper',
- &generate_resource_chooser(
+ &generate_incomplete_states($helper, $map,
+ 'INCOMPLETE_PROBLEMS_STUDENTS')
+
+ .&generate_resource_chooser(
'ALL_PROBLEMS',
'SelectProblem(s) to print',
'multichoice="1" suppressEmptySequences="0" addstatus="1" closeallpages="1"',