--- loncom/interface/lonprintout.pm 2006/06/30 21:37:05 1.452
+++ loncom/interface/lonprintout.pm 2006/07/14 21:03:47 1.458
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.452 2006/06/30 21:37:05 albertel Exp $
+# $Id: lonprintout.pm,v 1.458 2006/07/14 21:03:47 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -46,6 +46,35 @@ use lib '/home/httpd/lib/perl/';
use LONCAPA;
my %perm;
+my %parmhash;
+
+
+# Format a header according to a format.
+#
+
+# Substitutions:
+# %a - Assignment name.
+# %c - Course name.
+# %n - Student name.
+#
+sub format_page_header {
+ my ($format, $assignment, $course, $student) = @_;
+
+ # Default format?
+
+ if ($format eq '') {
+ $format = "\\textbf{$student} $course \\hfill \\thepage \\\\ \\textit{$assignment}";
+
+ } else {
+ $format =~ s/%a/$assignment/g;
+ $format =~ s/%c/$course/g;
+ $format =~ s/%n/$student/g;
+ }
+
+
+ return $format;
+
+}
#
# Convert a numeric code to letters
@@ -702,8 +731,7 @@ sub get_name {
if (!defined($udom)) { $udom=$env{'user.domain'}; }
my $plainname=&Apache::loncommon::plainname($uname,$udom);
if ($plainname=~/^\s*$/) { $plainname=$uname.'@'.$udom; }
- # $plainname=&Apache::lonxml::latex_special_symbols($plainname,'header');
- $plainname = &escape_LaTeX($plainname);
+ $plainname=&Apache::lonxml::latex_special_symbols($plainname,'header');
return $plainname;
}
@@ -718,22 +746,28 @@ sub get_course {
sub page_format_transformation {
my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment,$tableofcontents,$indexlist,$selectionmade) = @_;
my ($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin);
+
if ($selectionmade eq '4') {
$assignment='Problems from the Whole Course';
} else {
$assignment=&Apache::lonxml::latex_special_symbols($assignment,'header');
}
($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin) = &page_format($papersize,$layout,$numberofcolumns,$topmargin);
+
+
my $name = &get_name();
my $courseidinfo = &get_course();
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
+ my $header_text = $parmhash{'print_header_format'};
+ $header_text = &format_page_header($header_text, $assignment,
+ $courseidinfo, $name);
my $topmargintoinsert = '';
if ($topmargin ne '0') {$topmargintoinsert='\setlength{\topmargin}{'.$topmargin.'}';}
my $fancypagestatement='';
if ($numberofcolumns eq '2') {
- $fancypagestatement="\\fancyhead{}\\fancyhead[LO]{\\textbf{$name} $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}";
+ $fancypagestatement="\\fancyhead{}\\fancyhead[LO]{$header_text}";
} else {
- $fancypagestatement="\\rhead{}\\chead{}\\lhead{\\textbf{$name} $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}";
+ $fancypagestatement="\\rhead{}\\chead{}\\lhead{$header_text}";
}
if ($layout eq 'album') {
$text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}$topmargintoinsert\n\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\n\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\usepackage{fancyhdr}\\addtolength{\\headheight}{\\baselineskip}\n\\pagestyle{fancy}$fancypagestatement\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}\n /;
@@ -1262,7 +1296,7 @@ ENDPART
}
if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;}
$result .= '\end{document}';
- } elsif ($cleanURL=~/\/(smppg|grppg|syllabus|aboutme|bulletinboard)$/) {
+ } elsif ($cleanURL=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;}
$resources_printed .= $currentURL.':';
@@ -1372,15 +1406,20 @@ ENDPART
my $courseidinfo = &get_course();
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
$prevassignment=$assignment;
+ my $header_text = $parmhash{'print_header_format'};
+ $header_text = &format_page_header($header_text,
+ $assignment,
+ $courseidinfo,
+ $name);
if ($numberofcolumns eq '1') {
- $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip 5 mm ';
+ $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{'.$header_text.'}} \vskip 5 mm ';
} else {
- $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip 5 mm ';
+ $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{'.$header_text.'}} \vskip 5 mm ';
}
}
$result .= $texversion;
$flag_latex_header_remove = 'YES';
- } elsif ($urlp=~/\/(smppg|grppg|syllabus|aboutme|bulletinboard)$/) {
+ } elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;}
$resources_printed .= $urlp.':';
@@ -1875,7 +1914,7 @@ sub print_resources {
$rendered =~ s/\\end{document}//;
}
$current_output .= $rendered;
- } elsif ($res_url=~/\/(smppg|grppg|syllabus|aboutme|bulletinboard)$/) {
+ } elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {
$printed .= $curresline.':';
my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);
@@ -1904,20 +1943,22 @@ sub print_resources {
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection}
my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header');
+ my $HeaderLine = $parmhash{'print_header_format'};
+ $HeaderLine = format_page_header($HeaderLine, $currentassignment, $courseidinfo, $fullname);
if ($current_output=~/\\documentclass/) {
if ($columns_in_format == 1) {
- $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\lhead{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$currentassignment}$namepostfix}}\\vskip 5 mm /;
+ $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\lhead{$HeaderLine$namepostfix}}\\vskip 5 mm /;
} else {
- $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fancyhead[LO]{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$currentassignment}$namepostfix}}\\vskip 5 mm /;
+ $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fancyhead[LO]{$HeaderLine$namepostfix}}\\vskip 5 mm /;
}
} else {
my $blankpages = '';
for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blankpages.='\clearpage\strut\clearpage';}
if ($columns_in_format == 1) {
- $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}'.$namepostfix.'}} \vskip 5 mm '.$current_output;
+ $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{'.$HeaderLine.'}'.$namepostfix.'} \vskip 5 mm '.$current_output;
} else {
- $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}'.$namepostfix.'}} \vskip 5 mm '.$current_output;
+ $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{'.$HeaderLine.'}'.$namepostfix.'} \vskip 5 mm '.$current_output;
}
}
#
@@ -1942,7 +1983,7 @@ sub handler {
}
- my %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'});
+ %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'});
@@ -2139,7 +2180,7 @@ sub printHelper {
my $paramHash;
if ($resourceTitle) {
- push @{$printChoices}, ["$resourceTitle (".&mt('what you just saw on the screen').")", 'current_document', 'PAGESIZE'];
+ push @{$printChoices}, ["$resourceTitle (".&mt('the resource you just saw on the screen').")", 'current_document', 'PAGESIZE'];
}
# Useful filter strings
@@ -2157,37 +2198,35 @@ sub printHelper {
# If we're in a sequence...
+ my $startnew=&mt('Start new page
before selected');
if (($helper->{'VARS'}->{'construction'} ne '1') &&
$helper->{VARS}->{'postdata'} &&
$helper->{VARS}->{'assignment'}) {
# Allow problems from sequence
- push @{$printChoices}, ["".&mt('Problems')." ".&mt('in')." $sequenceTitle", 'map_problems', 'CHOOSE_PROBLEMS'];
+ push @{$printChoices}, [&mt('Selected Problems in folder [_1]',$sequenceTitle), 'map_problems', 'CHOOSE_PROBLEMS'];
# Allow all resources from sequence
- push @{$printChoices}, ["".&mt('Resources')." ".&mt('in')." $sequenceTitle", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];
-
+ push @{$printChoices}, [&mt('Selected Resources in folder [_1]',$sequenceTitle), 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];
my $helperFragment = <
- (mark them then click "next" button)
PAGESIZE
return $isProblem;
$map
return $symbFilter;
-
+
- (mark them then click "next" button)
PAGESIZE
return $isNotMap;
$map
return $symbFilter;
-
+
HELPERFRAGMENT
@@ -2198,37 +2237,35 @@ HELPERFRAGMENT
# If the user has pfo (print for otheres) allow them to print all
# problems and resources in the entier course, optionally for selected students
if ($perm{'pfo'} &&
- ($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|grppg|aboutme|bulletinboard)$/)) {
+ ($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) {
- push @{$printChoices}, ['Problems from entire course', 'all_problems', 'ALL_PROBLEMS'];
- push @{$printChoices}, ['Resources from entire course', 'all_resources', 'ALL_RESOURCES'];
+ push @{$printChoices}, ['Selected Problems from entire course', 'all_problems', 'ALL_PROBLEMS'];
+ push @{$printChoices}, ['Selected Resources from entire course', 'all_resources', 'ALL_RESOURCES'];
&Apache::lonxml::xmlparse($r, 'helper', <
- (mark them then click "next" button)
PAGESIZE
return $isProblemOrMap;
return $isNotMap;
return $symbFilter;
-
+
- (Mark them then click "next" button)
PAGESIZE
return $isNotMap;
return $symbFilter;
-
+
ALL_PROBLEMS
if ($helper->{VARS}->{'assignment'}) {
- push @{$printChoices}, ["".&mt('Problems')." ".&mt('from')." $sequenceTitle ".&mt('for')." ".&mt('selected students')."", 'problems_for_students', 'CHOOSE_STUDENTS'];
- push @{$printChoices}, ["".&mt('Problems')." ".&mt('from')." $sequenceTitle ".&mt('for')." ".&mt('anonymous students')."", 'problems_for_anon', 'CHOOSE_ANON1'];
+ push @{$printChoices}, [&mt("Selected Problems from folder [_1] for selected students",$sequenceTitle), 'problems_for_students', 'CHOOSE_STUDENTS'];
+ push @{$printChoices}, [&mt("Selected Problems from folder [_1] for anonymous students",$sequenceTitle), 'problems_for_anon', 'CHOOSE_ANON1'];
}
# resource_selector will hold a few states that:
@@ -2249,7 +2286,7 @@ ALL_PROBLEMS
return $isProblem;
$map
return $symbFilter;
-
+
@@ -2399,8 +2436,8 @@ CHOOSE_ANON1
if ($helper->{VARS}->{'assignment'}) {
- push @{$printChoices}, ["".&mt('Resources')." ".&mt('from')." $sequenceTitle ".&mt('for')." ".&mt('selected students')."", 'resources_for_students', 'CHOOSE_STUDENTS1'];
- push @{$printChoices}, ["".&mt('Resources')." ".&mt('from')." $sequenceTitle ".&mt('for')." ".&mt('anonymous students')."", 'resources_for_anon', 'CHOOSE_ANON2'];
+ push @{$printChoices}, [&mt("Selected Resources from folder [_1] for selected students",$sequenceTitle), 'resources_for_students', 'CHOOSE_STUDENTS1'];
+ push @{$printChoices}, [&mt("Selected Resources from folder [_1] for anonymous students",$sequenceTitle), 'resources_for_anon', 'CHOOSE_ANON2'];
}
@@ -2413,7 +2450,7 @@ CHOOSE_ANON1
return $isNotMap;
$map
return $symbFilter;
-
+
@@ -2506,12 +2543,12 @@ CHOOSE_ANON2
# FIXME: That RE should come from a library somewhere.
if ((((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or defined $helper->{'VARS'}->{'construction'}) and $perm{'pav'} and $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/') {
- push @{$printChoices}, ["".&mt('Problems')." ".&mt('from current subdirectory')." $subdir", 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
+ push @{$printChoices}, [&mt("Selected Problems from current subdirectory [_1]",$subdir), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
my $f = '$filename';
my $xmlfrag = <
- (mark them then click "next" button)
+
PAGESIZE
return '$subdir';
@@ -2532,7 +2569,7 @@ CHOOSE_FROM_SUBDIR
# Allow the user to select any sequence in the course, feed it to
# another resource selector for that sequence
if (!$helper->{VARS}->{'construction'}) {
- push @$printChoices, ["Resources from selected sequence in course",
+ push @$printChoices, ["Selected Resources from selected folder in course",
'select_sequences', 'CHOOSE_SEQUENCE'];
my $escapedSequenceName = $helper->{VARS}->{'SEQUENCE'};
#Escape apostrophes and backslashes for Perl
@@ -2557,7 +2594,7 @@ CHOOSE_FROM_SUBDIR
return $isProblem
return '$escapedSequenceName';
return $symbFilter;
-
+
CHOOSE_FROM_ANY_SEQUENCE