--- loncom/interface/lonprintout.pm 2009/10/26 10:16:56 1.562
+++ loncom/interface/lonprintout.pm 2009/12/21 12:11:51 1.568
@@ -2,7 +2,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.562 2009/10/26 10:16:56 foxr Exp $
+# $Id: lonprintout.pm,v 1.568 2009/12/21 12:11:51 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;
@@ -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() . '\\\\';
@@ -2094,7 +2108,6 @@ ENDPART
$currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;
-# $result .= &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
$result .= &print_construction_sequence($currentURL, $helper, %form,
$LaTeXwidth);
$result .= '\end{document}';
@@ -2106,7 +2119,7 @@ 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 = &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/;
@@ -2139,7 +2152,6 @@ ENDPART
} else {
- &Apache::lonnet::logthis("Unsupported type handler");
$result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'},
$helper->{'VARS'}->{'symb'});
}
@@ -2199,7 +2211,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 +2224,10 @@ ENDPART
&& $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
$resources_printed .= $urlp.':';
&Apache::lonxml::remember_problem_counter();
-
+ if ($flag_latex_header_remove eq 'NO') {
+ $texversion.=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); # RF
+ $flag_latex_header_remove = 'YES';
+ }
$texversion.=&ssi_with_retries($urlp, $ssi_retry_count, %form);
if ($urlp=~/\.page$/) {
($texversion,my $number_of_columns_page) = &page_cleanup($texversion);
@@ -2286,7 +2301,7 @@ 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 = &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/;
@@ -2790,7 +2805,7 @@ sub print_resources {
# so we will just rely on prntout.pl to strip ENDOFSTUDENTSTAMP from the
# postscript. Each ENDOFSTUDENTSTAMP will go on a line by itself.
#
-
+ my $syllabus_first = 0;
foreach my $curresline (@{$master_seq}) {
if (defined $page_breaks{$curresline}) {
if($i != 0) {
@@ -2849,6 +2864,9 @@ sub print_resources {
}
$current_output .= $rendered;
} elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {
+ if ($i == 1) {
+ $syllabus_first = 1;
+ }
$printed .= $curresline.':';
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') {
@@ -2893,8 +2911,11 @@ sub print_resources {
my $header_start = ($columns_in_format == 1) ? '\lhead'
: '\fancyhead[LO]';
$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 /;
+ } elsif ($syllabus_first) {
+
+ $current_output =~ s/\\\\ Last updated:/Last updated:/
} else {
my $blankpages =
'\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'};
@@ -3193,22 +3214,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 +3256,8 @@ sub printHelper {
&Apache::lonxml::xmlparse($r, 'helper', $helperFragment);
- }
+ }
+ }
}
if (($helper->{'VAR'}->{'construction'} ne '1' ) &&