--- loncom/interface/lonprintout.pm 2009/10/26 09:55:32 1.560.2.7
+++ loncom/interface/lonprintout.pm 2009/11/17 11:32:23 1.565
@@ -2,7 +2,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.560.2.7 2009/10/26 09:55:32 foxr Exp $
+# $Id: lonprintout.pm,v 1.565 2009/11/17 11:32:23 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -499,8 +499,11 @@ sub printf_style_subst {
sub format_page_header {
my ($width, $format, $assignment, $course, $student, $section) = @_;
-
+
+
$width = &recalcto_mm($width); # Get width in mm.
+ my $chars_per_line = int($width/1.6); # Character/textline.
+
# Default format?
if ($format eq '') {
@@ -514,9 +517,8 @@ sub format_page_header {
# but only truncate the course.
# - 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 $sec_length = int($chars_per_line / 5);
@@ -552,7 +554,19 @@ sub format_page_header {
my $testPrintout = '\\\\'.&mt('Construction Space').' \\\\'.&mt('Test-Printout ');
$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;
@@ -1263,9 +1277,9 @@ sub page_format_transformation {
if ($selectionmade eq '4') {
if ($choice eq 'all_problems') {
- $assignment='Problems from the Whole Course';
+ $assignment=&mt('Problems from the Whole Course');
} else {
- $assignment='Resources from the Whole Course';
+ $assignment=&mt('Resources from the Whole Course');
}
} else {
$assignment=&Apache::lonxml::latex_special_symbols($assignment,'header');
@@ -1539,9 +1553,9 @@ sub print_page_in_course {
# First is the overall page description. This is then followed by the
# components of the page. Each of which must be printed independently.
-
my $the_page = shift(@page_resources);
+
foreach my $resource (@page_resources) {
my $resource_src = $resource->src(); # Essentially the URL of the resource.
$result .= $resource->title() . '\\\\';
@@ -2106,7 +2120,8 @@ ENDPART
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;}
$resources_printed .= $currentURL.':';
- my $texversion=&ssi_with_retries($currentURL, $ssi_retry_count, %form);
+ my $texversion = &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
+ $texversion .= &ssi_with_retries($currentURL, $ssi_retry_count, %form);
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
my $annotation = &annotate($currentURL);
$texversion =~ s/(\\end{document})/$annotation$1/;
@@ -2199,7 +2214,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];
@@ -2212,7 +2227,7 @@ ENDPART
&& $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
$resources_printed .= $urlp.':';
&Apache::lonxml::remember_problem_counter();
-
+ $texversion.=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); # RF
$texversion.=&ssi_with_retries($urlp, $ssi_retry_count, %form);
if ($urlp=~/\.page$/) {
($texversion,my $number_of_columns_page) = &page_cleanup($texversion);
@@ -2286,7 +2301,8 @@ ENDPART
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;}
$resources_printed .= $urlp.':';
- my $texversion=&ssi_with_retries($urlp, $ssi_retry_count, %form);
+ my $texversion = &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
+ $texversion .= &ssi_with_retries($urlp, $ssi_retry_count, %form);
if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
my $annotation = &annotate($urlp);
$texversion =~ s/(\\end{document)/$annotation$1/;
@@ -3193,22 +3209,23 @@ sub printHelper {
my $varspostdata = $helper->{VARS}->{'postdata'};
my $varsassignment = $helper->{VARS}->{'assignment'};
my $page_navmap = Apache::lonnavmaps::navmap->new();
- my @page_resources = $page_navmap->retrieveResources($url);
- if(defined($page_resources[0])) {
- $page_ispage = $page_resources[0]->is_page();
- $page_title = $page_resources[0]->title();
- my $resourcesymb = $page_resources[0]->symb();
- my ($pagemap, $pageid, $pageurl) = &Apache::lonnet::decode_symb($symb);
- if ($page_ispage) {
- push @{$printChoices},
- [&mt('Selected [_1]Problems[_2] from page [_3]', '', '', ''.$page_title.''),
- 'map_problems_in_page',
- 'CHOOSE_PROBLEMS_PAGE'];
- push @{$printChoices},
- [&mt('Selected [_1]Resources[_2] from page [_3]', '', '', ''.$page_title.''),
- 'map_resources_in_page',
- 'CHOOSE_RESOURCES_PAGE'];
- }
+ if (defined($page_navmap)) {
+ my @page_resources = $page_navmap->retrieveResources($url);
+ if(defined($page_resources[0])) {
+ $page_ispage = $page_resources[0]->is_page();
+ $page_title = $page_resources[0]->title();
+ my $resourcesymb = $page_resources[0]->symb();
+ my ($pagemap, $pageid, $pageurl) = &Apache::lonnet::decode_symb($symb);
+ if ($page_ispage) {
+ push @{$printChoices},
+ [&mt('Selected [_1]Problems[_2] from page [_3]', '', '', ''.$page_title.''),
+ 'map_problems_in_page',
+ 'CHOOSE_PROBLEMS_PAGE'];
+ push @{$printChoices},
+ [&mt('Selected [_1]Resources[_2] from page [_3]', '', '', ''.$page_title.''),
+ 'map_resources_in_page',
+ 'CHOOSE_RESOURCES_PAGE'];
+ }
my $helperFragment = &generate_resource_chooser('CHOOSE_PROBLEMS_PAGE',
'Select Problem(s) to print',
"multichoice='1' toponly='1' addstatus='1' closeallpages='1'",
@@ -3234,7 +3251,8 @@ sub printHelper {
&Apache::lonxml::xmlparse($r, 'helper', $helperFragment);
- }
+ }
+ }
}
if (($helper->{'VAR'}->{'construction'} ne '1' ) &&