--- loncom/interface/lonprintout.pm 2009/08/25 10:57:18 1.560.2.2 +++ loncom/interface/lonprintout.pm 2009/09/08 10:53:15 1.560.2.3 @@ -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 @@ CHOOSE_STUDENTS 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 - function. +# choice_func - If not empty generates a 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 = < + + $next_state + return $filter; +CHOOSE_RESOURCES + if ($value_func ne '') { + $result .= "return $choice_func;"; + } + if ($top_url ne '') { + $result .= "$top_url"; + } + $result .= <return $value_func; + $start_new_option + + +CHOOSE_RESOURCES + + return $result; +} + + #----------------------------------------------------------------------- @@ -3080,36 +3149,35 @@ sub printHelper { 'map_resources_in_page', 'CHOOSE_RESOURCES_PAGE']; } - my $helperFragment = < - - PAGESIZE - return $isProblem; - $url - return $symbFilter; - $start_new_option - - + 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); + + + - - - PAGESIZE - return $isNotMap; - $url - return $symbFilter; - $start_new_option - - -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 @@ HELPERFRAGMENT 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML']; &Apache::lonnet::logthis("Map url : $map"); - my $helperFragment = < - - PAGESIZE - return $isProblem; - $map - return $symbFilter; - $start_new_option - - - - - - PAGESIZE - return $isNotMap; - $map - return $symbFilter; - $start_new_option - - -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 @@ HELPERFRAGMENT push @{$printChoices}, [&mtn('Selected Problems from entire course'), 'all_problems', 'ALL_PROBLEMS']; push @{$printChoices}, [&mtn('Selected Resources from entire course'), 'all_resources', 'ALL_RESOURCES']; push @{$printChoices}, [&mtn('Selected Problems from entire course for selected people'), 'all_problems_students', 'ALL_PROBLEMS_STUDENTS']; - &Apache::lonxml::xmlparse($r, 'helper', < - - PAGESIZE - return $isProblemOrMap; - return $isNotMap; - return $symbFilter; - $start_new_option - - - - - PAGESIZE - return $isNotMap; - return $symbFilter; - $start_new_option - - - - - STUDENTS1 - return $isProblemOrMap; - return $isNotMap; - return $symbFilter; - $start_new_option - - +my $suffixXml = < Select sorting order of printout @@ -3197,8 +3231,35 @@ HELPERFRAGMENT


- 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 @@ ALL_PROBLEMS # 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=< - $randomly_ordered_warning - - PRINT_FORMATTING -
Select resources for the assignment
- - return $isProblem; - $map - return $symbFilter; - $start_new_option - - + 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 .= <
How should the results be printed?
@@ -3271,26 +3327,13 @@ RESOURCE_SELECTOR -# &Apache::lonxml::xmlparse($r, 'helper', < -# Select sorting order of printout -# -# -# -# Sort by section then student -# Sort by students across sections. -# -#


-# -# + &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 @@ CHOOSE_ANON1 $resource_selector=< $randomly_ordered_warning - PRINT_FORMATTING
Select resources for the assignment
+ NUMBER_PER_PDF
How should the results be printed?