--- loncom/interface/lonprintout.pm 2009/08/17 10:48:28 1.560.2.1 +++ 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.1 2009/08/17 10:48:28 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 # @@ -26,7 +36,6 @@ # # package Apache::lonprintout; - use strict; use Apache::Constants qw(:common :http); use Apache::lonxml; @@ -74,6 +83,105 @@ my $ssi_retry_count = 5; # Some arbitrar my $font_size = 'normalsize'; # Default is normalsize... +#---------------------------- Helper helpers. ------------------------- + +# Returns the text needd for a student chooser. +# that text must still be parsed by the helper xml parser. +# Parameters: +# this_state - State name of the chooser. +# sort_choice - variable to hold the sorting choice. +# variable - Name of variable to hold students. +# next_state - State after chooser. + + +sub generate_student_chooser { + my ($this_state, + $sort_choice, + $variable, + $next_state) = @_; + + my $result = < + Select sorting order of printout + + + Sort by section then student + Sort by students across sections. + + +


+ + + +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; +} + + +#----------------------------------------------------------------------- + # Fetch the contents of a resource, uninterpreted. # This is used here to fetch a latex file to be included @@ -1343,7 +1451,7 @@ sub print_page_in_course { if ($mode ne '') {$mode='\\'.$mode} - my $result.= &print_latex_header($mode); + my $result = &print_latex_header($mode); if ($currentURL=~m|^(/adm/wrapper/)?ext/|) { $currentURL=~s|^(/adm/wrapper/)?ext/|http://|; my $title=&Apache::lonnet::gettitle($symb); @@ -1413,9 +1521,6 @@ sub print_page_in_course { my $texversion = &ssi_with_retries($urlp, $ssi_retry_count, %form); - # There seems to be an extraneous \vskip 1mm \\\\ : - - $texversion =~ s/^\\vskip 1mm \\\\\\\\//; # current document with answers.. no need to encap in minipage # since there's only one answer. @@ -1438,7 +1543,7 @@ sub print_page_in_course { if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; } else { - $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); + $texversion= &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); if ($helper->{'VARS'}->{'construction'} ne '1') { my $title = &Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}); $title = &Apache::lonxml::latex_special_symbols($title); @@ -1473,6 +1578,14 @@ sub print_page_in_course { $texversion=~s/(\\addcontentsline\{toc\}\{subsection\}\{[^\}]*\})/$1 URL: \\verb|$currentURL| \\strut\\\\\\strut /; } + $texversion = &latex_header_footer_remove($texversion); + + # the first remaining line is a comment from londefdef the second + # line seems to be an extraneous \vskip 1mm \\\\ : + # (imperfect removal from header_footer_remove? + + $texversion =~ s/\\vskip 1mm \\\\\\\\//; + $result .= $texversion; if ($currentURL=~m/\.page\s*$/) { ($result,$numberofcolumns) = &page_cleanup($result); @@ -1560,7 +1673,7 @@ sub recently_generated { # A reference to a page break hash. # # -#use Data::Dumper; +use Data::Dumper; #sub dump_helper_vars { # my ($helper) = @_; # my $helpervars = Dumper($helper->{'VARS'}); @@ -2018,7 +2131,7 @@ ENDPART $result.="\\newpage\n"; } } - my ($sequence,$middle_thingy,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]); + my ($sequence,$middle_thingy,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]); $urlp=&Apache::lonnet::clutter($urlp); $form{'symb'}=$master_seq[$i]; @@ -2033,6 +2146,10 @@ ENDPART &Apache::lonnet::logthis("Problem"); $resources_printed .= $urlp.':'; &Apache::lonxml::remember_problem_counter(); + &Apache::lonnet::logthis("Fetching tex for $urlp"); + my $debug = Dumper(%form); + &Apache::lonnet::logthis("Form: $debug"); + $texversion.=&ssi_with_retries($urlp, $ssi_retry_count, %form); &Apache::lonnet::logthis("texversion so far: $texversion"); if ($urlp=~/\.page$/) { @@ -3007,61 +3124,60 @@ sub printHelper { "