version 1.560.2.6, 2009/10/13 11:01:16
|
version 1.572, 2010/02/28 22:38:45
|
Line 1
|
Line 1
|
# |
# |
|
|
|
|
# The LearningOnline Network |
# The LearningOnline Network |
# Printout |
# Printout |
# |
# |
Line 92 sub generate_student_chooser {
|
Line 90 sub generate_student_chooser {
|
$sort_choice, |
$sort_choice, |
$variable, |
$variable, |
$next_state) = @_; |
$next_state) = @_; |
&Apache::lonnet::logthis("Student chooser next state: $next_state, this state: $this_state"); |
|
my $result = <<CHOOSE_STUDENTS; |
my $result = <<CHOOSE_STUDENTS; |
<state name="$this_state" title="Select Students and Resources"> |
<state name="$this_state" title="Select Students and Resources"> |
<message><b>Select sorting order of printout</b> </message> |
<message><b>Select sorting order of printout</b> </message> |
Line 148 sub generate_resource_chooser {
|
Line 145 sub generate_resource_chooser {
|
$value_func, |
$value_func, |
$start_new_option) = @_; |
$start_new_option) = @_; |
|
|
&Apache::lonnet::logthis("Top URL = $top_url"); |
|
my $result = <<CHOOSE_RESOURCES; |
my $result = <<CHOOSE_RESOURCES; |
<state name="$this_state" title="$prompt_text"> |
<state name="$this_state" title="$prompt_text"> |
<resource variable="$variable" $resource_options |
<resource variable="$variable" $resource_options |
Line 503 sub printf_style_subst {
|
Line 499 sub printf_style_subst {
|
sub format_page_header { |
sub format_page_header { |
my ($width, $format, $assignment, $course, $student, $section) = @_; |
my ($width, $format, $assignment, $course, $student, $section) = @_; |
|
|
|
|
|
|
$width = &recalcto_mm($width); # Get width in mm. |
$width = &recalcto_mm($width); # Get width in mm. |
|
my $chars_per_line = int($width/1.6); # Character/textline. |
|
|
# Default format? |
# Default format? |
|
|
if ($format eq '') { |
if ($format eq '') { |
Line 518 sub format_page_header {
|
Line 517 sub format_page_header {
|
# but only truncate the course. |
# but only truncate the course. |
# - Allow the assignment to be 2 lines (wrapped). |
# - Allow the assignment to be 2 lines (wrapped). |
# |
# |
my $chars_per_line = $width/2; # Character/textline. |
|
|
|
|
|
|
|
|
|
my $name_length = int($chars_per_line *3 /4); |
my $name_length = int($chars_per_line *3 /4); |
my $sec_length = int($chars_per_line / 5); |
my $sec_length = int($chars_per_line / 5); |
Line 556 sub format_page_header {
|
Line 554 sub format_page_header {
|
my $testPrintout = '\\\\'.&mt('Construction Space').' \\\\'.&mt('Test-Printout '); |
my $testPrintout = '\\\\'.&mt('Construction Space').' \\\\'.&mt('Test-Printout '); |
$format =~ s/\\\\\s\\\\\s/$testPrintout/; |
$format =~ s/\\\\\s\\\\\s/$testPrintout/; |
} |
} |
|
# |
|
# We're going to trust LaTeX to break lines appropriately, but |
|
# we'll truncate anything that's more than 3 lines worth of |
|
# text. This is also assuming (which will probably end badly) |
|
# nobody's going to embed LaTeX control sequences in the title |
|
# header or rather that those control sequences won't get broken |
|
# by the stuff below. |
|
# |
|
my $total_length = 3*$chars_per_line; |
|
if (length($format) > $total_length) { |
|
$format = substr($format, 0, $total_length); |
|
} |
|
|
|
|
return $format; |
return $format; |
|
|
Line 1267 sub page_format_transformation {
|
Line 1277 sub page_format_transformation {
|
|
|
if ($selectionmade eq '4') { |
if ($selectionmade eq '4') { |
if ($choice eq 'all_problems') { |
if ($choice eq 'all_problems') { |
$assignment='Problems from the Whole Course'; |
$assignment=&mt('Problems from the Whole Course'); |
} else { |
} else { |
$assignment='Resources from the Whole Course'; |
$assignment=&mt('Resources from the Whole Course'); |
} |
} |
} else { |
} else { |
$assignment=&Apache::lonxml::latex_special_symbols($assignment,'header'); |
$assignment=&Apache::lonxml::latex_special_symbols($assignment,'header'); |
Line 1543 sub print_page_in_course {
|
Line 1553 sub print_page_in_course {
|
|
|
# First is the overall page description. This is then followed by the |
# First is the overall page description. This is then followed by the |
# components of the page. Each of which must be printed independently. |
# components of the page. Each of which must be printed independently. |
|
|
my $the_page = shift(@page_resources); |
my $the_page = shift(@page_resources); |
|
|
|
|
foreach my $resource (@page_resources) { |
foreach my $resource (@page_resources) { |
my $resource_src = $resource->src(); # Essentially the URL of the resource. |
my $resource_src = $resource->src(); # Essentially the URL of the resource. |
$result .= $resource->title() . '\\\\'; |
$result .= $resource->title() . '\\\\'; |
Line 1746 sub recently_generated {
|
Line 1756 sub recently_generated {
|
# A reference to a page break hash. |
# A reference to a page break hash. |
# |
# |
# |
# |
use Data::Dumper; |
# use Data::Dumper; |
#sub dump_helper_vars { |
# sub dump_helper_vars { |
# my ($helper) = @_; |
# my ($helper) = @_; |
# my $helpervars = Dumper($helper->{'VARS'}); |
# my $helpervars = Dumper($helper->{'VARS'}); |
# &Apache::lonnet::logthis("Dump of helper vars:\n $helpervars"); |
# &Apache::lonnet::logthis("Dump of helper vars:\n $helpervars"); |
Line 1762 sub get_page_breaks {
|
Line 1772 sub get_page_breaks {
|
} |
} |
return %page_breaks; |
return %page_breaks; |
} |
} |
|
# |
|
# Returns text to insert for any extra vskip prior to the resource. |
|
# Parameters: |
|
# helper - Reference to the helper object driving the printout. |
|
# resource - Identifies the resource about to be printed. |
|
# |
|
# This is done as follows: |
|
# POSSIBLE_RESOURCES has the list of possible resources. |
|
# EXTRASPACE has the list of extra space values. |
|
# EXTRASPACE_UNITS is the set of resources for which the units are |
|
# mm. All others are 'in'. |
|
# |
|
# The resource is found in the POSSIBLE_RESOURCES to get the index |
|
# of the EXTRASPACE value. |
|
# |
|
# In order to speed this up for lengthy printouts, the first time, |
|
# POSSIBLE_RESOURCES is turned into a look up hash and |
|
# EXTRASPACE is turned into an array. |
|
# |
|
|
|
|
|
my %possible_resources; |
|
my %extraspace_mm; |
|
my @extraspace; |
|
my $skips_loaded = 0; |
|
|
|
# Function to load the skips hash and array |
|
|
|
sub load_skips { |
|
|
|
my ($helper) = @_; |
|
|
|
# If this is the first time, unrap the resources and extra spaces: |
|
|
|
if (!$skips_loaded) { |
|
@extraspace = (split(/\|\|\|/, $helper->{'VARS'}->{'EXTRASPACE'})); |
|
my @resource_list = (split(/\|\|\|/, $helper->{'VARS'}->{'POSSIBLE_RESOURCES'})); |
|
my $i = 0; |
|
foreach my $resource (@resource_list) { |
|
$possible_resources{$resource} = $i; |
|
$i++; |
|
} |
|
foreach my $mm_resource (split(/\|\|\|/, $helper->{'VARS'}->{'EXTRASPACE_UNITS'})) { |
|
$extraspace_mm{$mm_resource} = 1; |
|
} |
|
$skips_loaded = 1; |
|
} |
|
} |
|
|
|
sub get_extra_vspaces { |
|
my ($helper, $resource) = @_; |
|
|
|
&load_skips($helper); |
|
|
|
# Lookup the resource in the possible resources hash.. that is the index |
|
# into the extraspace array that gives us either an empty string or |
|
# the number of mm to skip: |
|
|
|
my $index = $possible_resources{$resource}; |
|
my $skip = $extraspace[$index]; |
|
|
|
my $result = ''; |
|
if ($skip ne '') { |
|
my $units = 'in'; |
|
if (defined($extraspace_mm{$resource})) { |
|
$units = 'mm'; |
|
} |
|
$result = '\vskip '.$skip.' '.$units; |
|
} |
|
|
|
|
|
return $result; |
|
|
|
|
|
} |
|
|
|
# |
|
# The resource chooser part of the helper needs more than just |
|
# the value of the extraspaces var to recover the value into a text |
|
# field option. This sub produces the required format for the saved var: |
|
# specifically |
|
# ||| separated fields of the form resourcename=value |
|
# |
|
# Parameters: |
|
# $helper - Refers to the helper we are configuring |
|
# Implicit input: |
|
# $helper->{'VARS'}->{'EXTRASPACE'} - the spaces helper var has the text field |
|
# value. |
|
# $helper->{'VARS'}->{'EXTRASPACE_UNITS'} - units for the skips (checkboxes). |
|
# $helper->{'VARS'}->{'POSSIBLE_RESOURCES'} - has the list of resources. ||| |
|
# separated of course. |
|
# Implicit outputs: |
|
# $env{'form.extraspace'} |
|
# $env{'form.extraspace_units'} |
|
# |
|
sub set_form_extraspace { |
|
my ($helper) = @_; |
|
|
|
# the most convenient way to do this is to drive from the skips arrays/hash. |
|
# may not be the fastest, but this is once per print request so it's not so |
|
# speed critical: |
|
|
|
&load_skips($helper); |
|
|
|
my $result = ''; |
|
|
|
foreach my $resource (keys(%possible_resources)) { |
|
my $vskip = $extraspace[$possible_resources{$resource}]; |
|
$result .= $resource .'=' . $vskip . '|||'; |
|
} |
|
|
|
$env{'form.extraspace'} = $result; |
|
$env{'form.extraspace_units'} = $helper->{'VARS'}->{'EXTRASPACE_UNITS'}; |
|
return $result; |
|
|
|
} |
|
|
# Output a sequence (recursively if neeed) |
# Output a sequence (recursively if neeed) |
# from construction space. |
# from construction space. |
Line 1933 ENDPART
|
Line 2059 ENDPART
|
# indexed by symb and contains 1's for each break. |
# indexed by symb and contains 1's for each break. |
|
|
$env{'form.pagebreaks'} = $helper->{'VARS'}->{'FINISHPAGE'}; |
$env{'form.pagebreaks'} = $helper->{'VARS'}->{'FINISHPAGE'}; |
|
&set_form_extraspace($helper); |
$env{'form.lastprinttype'} = $helper->{'VARS'}->{'PRINT_TYPE'}; |
$env{'form.lastprinttype'} = $helper->{'VARS'}->{'PRINT_TYPE'}; |
&Apache::loncommon::store_course_settings('print', |
&Apache::loncommon::store_course_settings('print', |
{'pagebreaks' => 'scalar', |
{'pagebreaks' => 'scalar', |
|
'extraspace' => 'scalar', |
|
'extraspace_units' => 'scalar', |
'lastprinttype' => 'scalar'}); |
'lastprinttype' => 'scalar'}); |
|
|
my %page_breaks = &get_page_breaks($helper); |
my %page_breaks = &get_page_breaks($helper); |
|
|
my $format_from_helper = $helper->{'VARS'}->{'FORMAT'}; |
my $format_from_helper = $helper->{'VARS'}->{'FORMAT'}; |
Line 2098 ENDPART
|
Line 2226 ENDPART
|
|
|
|
|
$currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|; |
$currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|; |
# $result .= &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
|
$result .= &print_construction_sequence($currentURL, $helper, %form, |
$result .= &print_construction_sequence($currentURL, $helper, %form, |
$LaTeXwidth); |
$LaTeXwidth); |
$result .= '\end{document}'; |
$result .= '\end{document}'; |
Line 2110 ENDPART
|
Line 2237 ENDPART
|
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;} |
if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;} |
$resources_printed .= $currentURL.':'; |
$resources_printed .= $currentURL.':'; |
my $texversion=&ssi_with_retries($currentURL, $ssi_retry_count, %form); |
my $texversion = &ssi_with_retries($currentURL, $ssi_retry_count, %form); |
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
my $annotation = &annotate($currentURL); |
my $annotation = &annotate($currentURL); |
$texversion =~ s/(\\end{document})/$annotation$1/; |
$texversion =~ s/(\\end{document})/$annotation$1/; |
Line 2143 ENDPART
|
Line 2270 ENDPART
|
|
|
|
|
} else { |
} else { |
&Apache::lonnet::logthis("Unsupported type handler"); |
|
$result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'}, |
$result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'}, |
$helper->{'VARS'}->{'symb'}); |
$helper->{'VARS'}->{'symb'}); |
} |
} |
Line 2164 ENDPART
|
Line 2290 ENDPART
|
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_resources_in_page')) |
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_resources_in_page')) |
{ |
{ |
&Apache::lonnet::logthis("Selectionmade => 3"); |
|
$selectionmade = 3; |
$selectionmade = 3; |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') |
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') |
) { |
) { |
Line 2204 ENDPART
|
Line 2329 ENDPART
|
$result.="\\newpage\n"; |
$result.="\\newpage\n"; |
} |
} |
} |
} |
my ($sequence,$middle_thingy,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]); |
$result .= &get_extra_vspaces($helper, $master_seq[$i]); |
|
my ($sequence,$middle_thingy,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]); |
$urlp=&Apache::lonnet::clutter($urlp); |
$urlp=&Apache::lonnet::clutter($urlp); |
$form{'symb'}=$master_seq[$i]; |
$form{'symb'}=$master_seq[$i]; |
|
|
&Apache::lonnet::logthis("Element $i Sequence $sequence Middle $middle_thingy URLP $urlp"); |
|
my $assignment=&Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header'); #title of the assignment which contains this problem |
my $assignment=&Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header'); #title of the assignment which contains this problem |
|
|
if ($selectionmade==7) {$helper->{VARS}->{'assignment'}=$assignment;} |
if ($selectionmade==7) {$helper->{VARS}->{'assignment'}=$assignment;} |
Line 2216 ENDPART
|
Line 2341 ENDPART
|
my $texversion=''; |
my $texversion=''; |
if ($urlp!~m|^/adm/| |
if ($urlp!~m|^/adm/| |
&& $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { |
&& $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { |
&Apache::lonnet::logthis("Problem"); |
|
$resources_printed .= $urlp.':'; |
$resources_printed .= $urlp.':'; |
&Apache::lonxml::remember_problem_counter(); |
&Apache::lonxml::remember_problem_counter(); |
&Apache::lonnet::logthis("Fetching tex for $urlp"); |
if ($flag_latex_header_remove eq 'NO') { |
my $debug = Dumper(%form); |
$texversion.=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); # RF |
&Apache::lonnet::logthis("Form: $debug"); |
$flag_latex_header_remove = 'YES'; |
|
} |
$texversion.=&ssi_with_retries($urlp, $ssi_retry_count, %form); |
$texversion.=&ssi_with_retries($urlp, $ssi_retry_count, %form); |
&Apache::lonnet::logthis("texversion so far: $texversion"); |
|
if ($urlp=~/\.page$/) { |
if ($urlp=~/\.page$/) { |
&Apache::lonnet::logthis("Special page actions"); |
|
($texversion,my $number_of_columns_page) = &page_cleanup($texversion); |
($texversion,my $number_of_columns_page) = &page_cleanup($texversion); |
if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;} |
if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;} |
$texversion =~ s/\\end{document}\d*/\\end{document}/; |
$texversion =~ s/\\end{document}\d*/\\end{document}/; |
Line 2248 ENDPART
|
Line 2370 ENDPART
|
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; |
} else { |
} else { |
if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) { |
if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) { |
&Apache::lonnet::logthis("problem printing"); |
|
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
$texversion =~ s/\\begin{document}//; |
$texversion =~ s/\\begin{document}//; |
my $title = &Apache::lonnet::gettitle($master_seq[$i]); |
my $title = &Apache::lonnet::gettitle($master_seq[$i]); |
Line 2270 ENDPART
|
Line 2391 ENDPART
|
} |
} |
|
|
if ($flag_latex_header_remove ne 'NO') { |
if ($flag_latex_header_remove ne 'NO') { |
&Apache::lonnet::logthis("Removing header/footer 1"); |
|
$texversion = &latex_header_footer_remove($texversion); |
$texversion = &latex_header_footer_remove($texversion); |
&Apache::lonnet::logthis("With h/f removed we have: $texversion"); |
|
} else { |
} else { |
$texversion =~ s/\\end{document}//; |
$texversion =~ s/\\end{document}//; |
} |
} |
Line 2296 ENDPART
|
Line 2415 ENDPART
|
} |
} |
} |
} |
$result .= $texversion; |
$result .= $texversion; |
&Apache::lonnet::logthis("About to set rem header true with $result"); |
|
$flag_latex_header_remove = 'YES'; |
$flag_latex_header_remove = 'YES'; |
} elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
} elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;} |
if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;} |
$resources_printed .= $urlp.':'; |
$resources_printed .= $urlp.':'; |
my $texversion=&ssi_with_retries($urlp, $ssi_retry_count, %form); |
my $texversion = &ssi_with_retries($urlp, $ssi_retry_count, %form); |
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
my $annotation = &annotate($urlp); |
my $annotation = &annotate($urlp); |
$texversion =~ s/(\\end{document)/$annotation$1/; |
$texversion =~ s/(\\end{document)/$annotation$1/; |
} |
} |
|
|
if ($flag_latex_header_remove ne 'NO') { |
if ($flag_latex_header_remove ne 'NO') { |
&Apache::lonnet::logthis("Removing header & footer 2"); |
|
$texversion = &latex_header_footer_remove($texversion); |
$texversion = &latex_header_footer_remove($texversion); |
} else { |
} else { |
$texversion =~ s/\\end{document}/\\vskip 0\.5mm\\noindent\\makebox\[\\textwidth\/\$number_of_columns\]\[b\]\{\\hrulefill\}/; |
$texversion =~ s/\\end{document}/\\vskip 0\.5mm\\noindent\\makebox\[\\textwidth\/\$number_of_columns\]\[b\]\{\\hrulefill\}/; |
Line 2337 ENDPART
|
Line 2454 ENDPART
|
$texversion=&unsupported($urlp,$helper->{'VARS'}->{'LATEX_TYPE'}, |
$texversion=&unsupported($urlp,$helper->{'VARS'}->{'LATEX_TYPE'}, |
$master_seq[$i]); |
$master_seq[$i]); |
if ($flag_latex_header_remove ne 'NO') { |
if ($flag_latex_header_remove ne 'NO') { |
&Apache::lonnet::logthis("Removing header/footer 3"); |
|
$texversion = &latex_header_footer_remove($texversion); |
$texversion = &latex_header_footer_remove($texversion); |
} else { |
} else { |
$texversion =~ s/\\end{document}//; |
$texversion =~ s/\\end{document}//; |
Line 2401 ENDPART
|
Line 2517 ENDPART
|
$helper->{'VARS'}->{'NUMBER_TO_PRINT'} = $#students+1; |
$helper->{'VARS'}->{'NUMBER_TO_PRINT'} = $#students+1; |
} |
} |
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
&Apache::lonnet::logthis("RESOURCES: ". $helper->{'VARS'}->{'RESOURCES'}); |
|
|
|
#loop over students |
#loop over students |
|
|
Line 2605 ENDPART
|
Line 2720 ENDPART
|
$newurlp=&path_to_problem($newurlp,$LaTeXwidth); |
$newurlp=&path_to_problem($newurlp,$LaTeXwidth); |
$texversion =~ s/(\\begin{minipage}{\\textwidth})/$1 $newurlp/; |
$texversion =~ s/(\\begin{minipage}{\\textwidth})/$1 $newurlp/; |
if ($flag_latex_header_remove ne 'NO') { |
if ($flag_latex_header_remove ne 'NO') { |
&Apache::lonnet::logthis("Removing header/footer: 4"); |
|
$texversion = &latex_header_footer_remove($texversion); |
$texversion = &latex_header_footer_remove($texversion); |
} else { |
} else { |
$texversion =~ s/\\end{document}//; |
$texversion =~ s/\\end{document}//; |
Line 2810 sub print_resources {
|
Line 2924 sub print_resources {
|
# so we will just rely on prntout.pl to strip ENDOFSTUDENTSTAMP from the |
# so we will just rely on prntout.pl to strip ENDOFSTUDENTSTAMP from the |
# postscript. Each ENDOFSTUDENTSTAMP will go on a line by itself. |
# postscript. Each ENDOFSTUDENTSTAMP will go on a line by itself. |
# |
# |
&Apache::lonnet::logthis("In print_resources"); |
my $syllabus_first = 0; |
|
|
foreach my $curresline (@{$master_seq}) { |
foreach my $curresline (@{$master_seq}) { |
&Apache::lonnet::logthis("Res: $curresline"); |
|
if (defined $page_breaks{$curresline}) { |
if (defined $page_breaks{$curresline}) { |
if($i != 0) { |
if($i != 0) { |
$current_output.= "\\newpage\n"; |
$current_output.= "\\newpage\n"; |
} |
} |
} |
} |
|
$current_output .= &get_extra_vspaces($helper, $curresline); |
$i++; |
$i++; |
|
|
if ( !($type eq 'problems' && |
if ( !($type eq 'problems' && |
Line 2831 sub print_resources {
|
Line 2944 sub print_resources {
|
&Apache::lonxml::remember_problem_counter(); |
&Apache::lonxml::remember_problem_counter(); |
|
|
my $rendered = &get_student_view_with_retries($curresline,$ssi_retry_count,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv); |
my $rendered = &get_student_view_with_retries($curresline,$ssi_retry_count,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv); |
&Apache::lonnet::logthis("student view: $rendered"); |
|
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || |
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || |
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { |
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { |
# Use a copy of the hash so we don't pervert it on future loop passes. |
# Use a copy of the hash so we don't pervert it on future loop passes. |
Line 2859 sub print_resources {
|
Line 2971 sub print_resources {
|
$rendered = $header.$body; |
$rendered = $header.$body; |
} |
} |
} |
} |
&Apache::lonnet::logthis("After preprending header: $rendered"); |
|
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
my $url = &Apache::lonnet::clutter($res_url); |
my $url = &Apache::lonnet::clutter($res_url); |
my $annotation = &annotate($url); |
my $annotation = &annotate($url); |
$rendered =~ s/(\\keephidden{ENDOFPROBLEM})/$annotation$1/; |
$rendered =~ s/(\\keephidden{ENDOFPROBLEM})/$annotation$1/; |
} |
} |
|
my $junk; |
if ($remove_latex_header eq 'YES') { |
if ($remove_latex_header eq 'YES') { |
&Apache::lonnet::logthis("Removing header/footer: 5"); |
|
$rendered = &latex_header_footer_remove($rendered); |
$rendered = &latex_header_footer_remove($rendered); |
} else { |
} else { |
$rendered =~ s/\\end{document}//; |
$rendered =~ s/\\end{document}//; |
} |
} |
$current_output .= $rendered; |
$current_output .= $rendered; |
} elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
} elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { |
|
if ($i == 1) { |
|
$syllabus_first = 1; |
|
} |
$printed .= $curresline.':'; |
$printed .= $curresline.':'; |
my $rendered = &get_student_view_with_retries($curresline,$ssi_retry_count,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv); |
my $rendered = &get_student_view_with_retries($curresline,$ssi_retry_count,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv); |
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') { |
Line 2881 sub print_resources {
|
Line 2995 sub print_resources {
|
$annotation =~ s/(\\end{document})/$annotation$1/; |
$annotation =~ s/(\\end{document})/$annotation$1/; |
} |
} |
if ($remove_latex_header eq 'YES') { |
if ($remove_latex_header eq 'YES') { |
&Apache::lonnet::logthis("Removing header/footer: 6"); |
|
$rendered = &latex_header_footer_remove($rendered); |
$rendered = &latex_header_footer_remove($rendered); |
} else { |
} else { |
$rendered =~ s/\\end{document}//; |
$rendered =~ s/\\end{document}//; |
Line 2891 sub print_resources {
|
Line 3004 sub print_resources {
|
my $url = &Apache::lonnet::clutter($res_url); |
my $url = &Apache::lonnet::clutter($res_url); |
my $rendered = &include_pdf($url); |
my $rendered = &include_pdf($url); |
if ($remove_latex_header ne 'NO') { |
if ($remove_latex_header ne 'NO') { |
&Apache::lonnet::logthis("Removing header/footer: 7"); |
|
$rendered = &latex_header_footer_remove($rendered); |
$rendered = &latex_header_footer_remove($rendered); |
} |
} |
$current_output .= $rendered; |
$current_output .= $rendered; |
} else { |
} else { |
my $rendered = &unsupported($res_url,$helper->{'VARS'}->{'LATEX_TYPE'},$curresline); |
my $rendered = &unsupported($res_url,$helper->{'VARS'}->{'LATEX_TYPE'},$curresline); |
if ($remove_latex_header ne 'NO') { |
if ($remove_latex_header ne 'NO') { |
&Apache::lonnet::logthis("Removing header/footer: 8"); |
|
$rendered = &latex_header_footer_remove($rendered); |
$rendered = &latex_header_footer_remove($rendered); |
} else { |
} else { |
$rendered =~ s/\\end{document}//; |
$rendered =~ s/\\end{document}//; |
Line 2920 sub print_resources {
|
Line 3031 sub print_resources {
|
my $header_start = ($columns_in_format == 1) ? '\lhead' |
my $header_start = ($columns_in_format == 1) ? '\lhead' |
: '\fancyhead[LO]'; |
: '\fancyhead[LO]'; |
$header_line = $header_start.'{'.$header_line.'}'; |
$header_line = $header_start.'{'.$header_line.'}'; |
if ($current_output=~/\\documentclass/) { |
if ($current_output=~/\\documentclass/ && (!$syllabus_first)) { |
$current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$header_line$namepostfix}\\vskip 5 mm /; |
$current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$header_line$namepostfix}\\vskip 5 mm /; |
|
} elsif ($syllabus_first) { |
|
|
|
$current_output =~ s/\\\\ Last updated:/Last updated:/ |
} else { |
} else { |
my $blankpages = |
my $blankpages = |
'\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'}; |
'\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'}; |
Line 3065 sub printHelper {
|
Line 3179 sub printHelper {
|
$helper->declareVar('PRINT_TYPE'); |
$helper->declareVar('PRINT_TYPE'); |
$helper->declareVar("showallfoils"); |
$helper->declareVar("showallfoils"); |
$helper->declareVar("STUDENTS"); |
$helper->declareVar("STUDENTS"); |
|
$helper->declareVar("EXTRASPACE"); |
|
|
|
|
|
|
|
|
# The page breaks can get loaded initially from the course environment: |
# The page breaks and extra spaces |
|
# can get loaded initially from the course environment: |
# But we only do this in the initial state so that they are allowed to change. |
# But we only do this in the initial state so that they are allowed to change. |
# |
# |
|
|
# $helper->{VARS}->{FINISHPAGE} = ''; |
|
|
|
&Apache::loncommon::restore_course_settings('print', |
&Apache::loncommon::restore_course_settings('print', |
{'pagebreaks' => 'scalar', |
{'pagebreaks' => 'scalar', |
|
'extraspace' => 'scalar', |
|
'extraspace_units' => 'scalar', |
'lastprinttype' => 'scalar'}); |
'lastprinttype' => 'scalar'}); |
|
|
# This will persistently load in the data we want from the |
# This will persistently load in the data we want from the |
Line 3087 sub printHelper {
|
Line 3203 sub printHelper {
|
if (!defined ($env{"form.CURRENT_STATE"})) { |
if (!defined ($env{"form.CURRENT_STATE"})) { |
|
|
$helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'}; |
$helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'}; |
|
$helper->{VARS}->{EXTRASPACE} = $env{'form.extraspace'}; |
|
$helper->{VARS}->{EXTRASPACE_UNITS} = $env{'form.extraspace_units'}; |
} else { |
} else { |
my $state = $env{"form.CURRENT_STATE"}; |
my $state = $env{"form.CURRENT_STATE"}; |
if ($state eq "START") { |
if ($state eq "START") { |
$helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'}; |
$helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'}; |
|
$helper->{VARS}->{EXTRASPACE} = $env{'form.extraspace'}; |
|
$helper->{VARS}->{EXTRASPACE_UNITS} = $env{'form.extraspace_units'}; |
|
|
} |
} |
} |
} |
|
|
Line 3151 sub printHelper {
|
Line 3272 sub printHelper {
|
} else { |
} else { |
$url = $helper->{VARS}->{'postdata'}; |
$url = $helper->{VARS}->{'postdata'}; |
$is_published=1; # From resource space. |
$is_published=1; # From resource space. |
&Apache::lonnet::logthis("Resource url $url"); |
|
} |
} |
$url = &Apache::lonnet::clutter($url); |
$url = &Apache::lonnet::clutter($url); |
if (!$resourceTitle) { # if the resource doesn't have a title, use the filename |
if (!$resourceTitle) { # if the resource doesn't have a title, use the filename |
Line 3210 sub printHelper {
|
Line 3330 sub printHelper {
|
if ($perm{'pav'}) { |
if ($perm{'pav'}) { |
$start_new_option = |
$start_new_option = |
"<option text='".&mt('Start new page<br />before selected'). |
"<option text='".&mt('Start new page<br />before selected'). |
"' variable='FINISHPAGE' />"; |
"' variable='FINISHPAGE' />". |
|
"<option text='".&mt('Extra space<br />before selected'). |
|
"' variable='EXTRASPACE' type='text' />" . |
|
"<option " . |
|
"' variable='POSSIBLE_RESOURCES' type='hidden' />". |
|
"<option text='".&mt('Space units<br />check for mm'). |
|
"' variable='EXTRASPACE_UNITS' type='checkbox' />" |
|
; |
|
|
|
|
} |
} |
|
|
# If not construction space user can print the components of a page: |
# If not construction space user can print the components of a page: |
Line 3221 sub printHelper {
|
Line 3350 sub printHelper {
|
my $varspostdata = $helper->{VARS}->{'postdata'}; |
my $varspostdata = $helper->{VARS}->{'postdata'}; |
my $varsassignment = $helper->{VARS}->{'assignment'}; |
my $varsassignment = $helper->{VARS}->{'assignment'}; |
my $page_navmap = Apache::lonnavmaps::navmap->new(); |
my $page_navmap = Apache::lonnavmaps::navmap->new(); |
my @page_resources = $page_navmap->retrieveResources($url); |
if (defined($page_navmap)) { |
if(defined($page_resources[0])) { |
my @page_resources = $page_navmap->retrieveResources($url); |
$page_ispage = $page_resources[0]->is_page(); |
if(defined($page_resources[0])) { |
$page_title = $page_resources[0]->title(); |
$page_ispage = $page_resources[0]->is_page(); |
my $resourcesymb = $page_resources[0]->symb(); |
$page_title = $page_resources[0]->title(); |
my ($pagemap, $pageid, $pageurl) = &Apache::lonnet::decode_symb($symb); |
my $resourcesymb = $page_resources[0]->symb(); |
if ($page_ispage) { |
my ($pagemap, $pageid, $pageurl) = &Apache::lonnet::decode_symb($symb); |
push @{$printChoices}, |
if ($page_ispage) { |
[&mt('Selected [_1]Problems[_2] from page [_3]', '<b>', '</b>', '<b><i>'.$page_title.'</i></b>'), |
push @{$printChoices}, |
'map_problems_in_page', |
[&mt('Selected [_1]Problems[_2] from page [_3]', '<b>', '</b>', '<b><i>'.$page_title.'</i></b>'), |
'CHOOSE_PROBLEMS_PAGE']; |
'map_problems_in_page', |
push @{$printChoices}, |
'CHOOSE_PROBLEMS_PAGE']; |
[&mt('Selected [_1]Resources[_2] from page [_3]', '<b>', '</b>', '<b><i>'.$page_title.'</i></b>'), |
push @{$printChoices}, |
'map_resources_in_page', |
[&mt('Selected [_1]Resources[_2] from page [_3]', '<b>', '</b>', '<b><i>'.$page_title.'</i></b>'), |
'CHOOSE_RESOURCES_PAGE']; |
'map_resources_in_page', |
} |
'CHOOSE_RESOURCES_PAGE']; |
|
} |
my $helperFragment = &generate_resource_chooser('CHOOSE_PROBLEMS_PAGE', |
my $helperFragment = &generate_resource_chooser('CHOOSE_PROBLEMS_PAGE', |
'Select Problem(s) to print', |
'Select Problem(s) to print', |
"multichoice='1' toponly='1' addstatus='1' closeallpages='1'", |
"multichoice='1' toponly='1' addstatus='1' closeallpages='1'", |
Line 3262 sub printHelper {
|
Line 3392 sub printHelper {
|
|
|
&Apache::lonxml::xmlparse($r, 'helper', $helperFragment); |
&Apache::lonxml::xmlparse($r, 'helper', $helperFragment); |
|
|
} |
} |
|
} |
} |
} |
|
|
if (($helper->{'VAR'}->{'construction'} ne '1' ) && |
if (($helper->{'VAR'}->{'construction'} ne '1' ) && |
Line 3277 sub printHelper {
|
Line 3408 sub printHelper {
|
push @{$printChoices}, [&mt('Selected [_1]Resources[_2] from folder [_3]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>'), |
push @{$printChoices}, [&mt('Selected [_1]Resources[_2] from folder [_3]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>'), |
'map_problems_pages', |
'map_problems_pages', |
'CHOOSE_PROBLEMS_HTML']; |
'CHOOSE_PROBLEMS_HTML']; |
&Apache::lonnet::logthis("Map url : $map"); |
|
my $helperFragment = &generate_resource_chooser('CHOOSE_PROBLEMS', |
my $helperFragment = &generate_resource_chooser('CHOOSE_PROBLEMS', |
'Select Problem(s) to print', |
'Select Problem(s) to print', |
'multichoice="1" toponly="1" addstatus="1" closeallpages="1"', |
'multichoice="1" toponly="1" addstatus="1" closeallpages="1"', |
Line 3387 ALL_PROBLEMS
|
Line 3517 ALL_PROBLEMS
|
'multichoice="1" addstatus="1" closeallpages="1"', |
'multichoice="1" addstatus="1" closeallpages="1"', |
'RESOURCES', |
'RESOURCES', |
'PRINT_FORMATTING', |
'PRINT_FORMATTING', |
'', |
$map, |
$isProblem, , $symbFilter, |
$isProblem, '', $symbFilter, |
$start_new_option); |
$start_new_option); |
$resource_selector .= <<RESOURCE_SELECTOR; |
$resource_selector .= <<RESOURCE_SELECTOR; |
<state name="PRINT_FORMATTING" title="How should results be printed?"> |
<state name="PRINT_FORMATTING" title="How should results be printed?"> |
Line 3516 RESOURCE_SELECTOR
|
Line 3646 RESOURCE_SELECTOR
|
$url, |
$url, |
$isProblem, '', $symbFilter, |
$isProblem, '', $symbFilter, |
$start_new_option); |
$start_new_option); |
&Apache::lonnet::logthis('XML for anonpage: '.$anon_page); |
|
&Apache::lonxml::xmlparse($r, 'helper', $anon_page); |
&Apache::lonxml::xmlparse($r, 'helper', $anon_page); |
|
|
|
|
Line 3924 FONT_SELECTION
|
Line 4053 FONT_SELECTION
|
<choice computer="problem">Homework Problem</choice> |
<choice computer="problem">Homework Problem</choice> |
<choice computer="exam">Exam Problem</choice> |
<choice computer="exam">Exam Problem</choice> |
<choice computer="survey">Survey question</choice> |
<choice computer="survey">Survey question</choice> |
|
,choice computer="anonsurvey"Anonymous survey question</choice> |
</dropdown> |
</dropdown> |
PROBTYPE |
PROBTYPE |
&Apache::lonxml::xmlparse($r, 'helper', $xmlfrag); |
&Apache::lonxml::xmlparse($r, 'helper', $xmlfrag); |