--- loncom/interface/lonprintout.pm 2006/08/03 00:26:39 1.475
+++ loncom/interface/lonprintout.pm 2006/08/22 14:44:39 1.482
@@ -2,7 +2,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.475 2006/08/03 00:26:39 albertel Exp $
+# $Id: lonprintout.pm,v 1.482 2006/08/22 14:44:39 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -812,6 +812,8 @@ sub details_for_menu {
if (!$postdata) { $postdata=$helper->{VARS}{'postdata'}; }
my $name_of_resource = &Apache::lonnet::gettitle($postdata);
my $symbolic = &Apache::lonnet::symbread($postdata);
+ return if ( $symbolic eq '');
+
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($symbolic);
$map=&Apache::lonnet::clutter($map);
my $name_of_sequence = &Apache::lonnet::gettitle($map);
@@ -827,16 +829,21 @@ sub details_for_menu {
return ($name_of_resource,$name_of_sequence,$name_of_map);
}
+sub copyright_line {
+ return '\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 } ';
+}
+my $end_of_student = "\n".'\special{ps:ENDOFSTUDENTSTAMP}'."\n";
sub latex_corrections {
my ($number_of_columns,$result,$selectionmade,$answer_mode) = @_;
# $result =~ s/\\includegraphics{/\\includegraphics\[width=\\minipagewidth\]{/g;
- $result =~ s/\$number_of_columns/$number_of_columns/g;
+ my $copyright = ©right_line();
if ($selectionmade eq '1' || $answer_mode eq 'only') {
- $result =~ s/(\\end{document})/\\strut\\vskip 0 mm\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License \newpage \n\\special{ps:ENDOFSTUDENTSTAMP}\n $1/;
+ $result =~ s/(\\end{document})/\\strut\\vskip 0 mm $copyright $end_of_student $1/;
} else {
- $result =~ s/(\\end{document})/\\strut\\vspace\*{-4 mm}\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License \newpage \n\\special{ps:ENDOFSTUDENTSTAMP}\n $1/;
+ $result =~ s/(\\end{document})/\\strut\\vspace\*{-4 mm}\\newline $copyright $end_of_student $1/;
}
+ $result =~ s/\$number_of_columns/$number_of_columns/g;
$result =~ s/(\\end{longtable}\s*)(\\strut\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill})/$2$1/g;
$result =~ s/(\\end{longtable}\s*)\\strut\\newline/$1/g;
#-- LaTeX corrections
@@ -1114,7 +1121,9 @@ sub print_construction_sequence {
# If necessary, encapsulate answer in minipage:
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
- my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}).'}\vskip 0 mm ';
+ my $title = &Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'});
+ $title = &Apache::lonxml::latex_special_symbols($title);
+ my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
$body.=&path_to_problem($urlp,$LaTeXwidth);
$body.='\vskip 1 mm '.$answer.'\end{document}';
$body = &encapsulate_minipage($body);
@@ -1309,7 +1318,9 @@ ENDPART
} else {
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
if ($helper->{'VARS'}->{'construction'} ne '1') {
- $texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}).'}\vskip 0 mm ';
+ my $title = &Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'});
+ $title = &Apache::lonxml::latex_special_symbols($title);
+ $texversion.='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
$texversion.=&path_to_problem($cleanURL,$LaTeXwidth);
} else {
$texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm ';
@@ -1430,7 +1441,9 @@ ENDPART
} else {
if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
- my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($master_seq[$i]).'}\vskip 0 mm ';
+ my $title = &Apache::lonnet::gettitle($master_seq[$i]);
+ $title = &Apache::lonxml::latex_special_symbols($title);
+ my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
$body .= &path_to_problem ($urlp,$LaTeXwidth);
$body .='\vskip 1 mm '.$answer;
$body = &encapsulate_minipage($body);
@@ -1899,8 +1912,7 @@ sub print_resources {
&Apache::lonxml::clear_problem_counter();
my %page_breaks = &get_page_breaks($helper);
- my @format_array = split(/\|/,$helper->{'VARS'}->{'FORMAT'});
- my $columns_in_format = $format_array[1];
+ my $columns_in_format = (split(/\|/,$helper->{'VARS'}->{'FORMAT'}))[1];
#
# end each student with a
# Special that allows the post processor to even out the page
@@ -1948,8 +1960,10 @@ sub print_resources {
my $header =&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
- my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($curresline).'}\vskip 0 mm ';
- $body .=&path_to_problem($res_url,$LaTeXwidth);
+ my $title = &Apache::lonnet::gettitle($curresline);
+ $title = &Apache::lonxml::latex_special_symbols($title);
+ my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
+ $body .=&path_to_problem($res_url,$LaTeXwidth);
$body .='\vskip 1 mm '.$ansrendered;
$body = &encapsulate_minipage($body);
$rendered = $header.$body;
@@ -1990,23 +2004,23 @@ 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{$HeaderLine$namepostfix}}\\vskip 5 mm /;
- } else {
- $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fancyhead[LO]{$HeaderLine$namepostfix}}\\vskip 5 mm /;
+ my $header_line =
+ &format_page_header($parmhash{'print_header_format'},
+ $currentassignment, $courseidinfo, $fullname);
+ my $header_start = ($columns_in_format == 1) ? '\lhead'
+ : '\fancyhead[LO]';
+ $header_line = $header_start.'{'.$header_line.'}';
- }
+ if ($current_output=~/\\documentclass/) {
+ $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$header_line$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."\n\\special{ps:ENDOFSTUDENTSTAMP}\n".'\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."\n\\special{ps:ENDOFSTUDENTSTAMP}\n".'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{'.$HeaderLine.'}'.$namepostfix.'} \vskip 5 mm '.$current_output;
- }
+ my $blankpages =
+ '\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'};
+
+ $current_output = '\strut\vspace*{-6 mm}\\newline'.
+ ©right_line().' \newpage '.$blankpages.$end_of_student.
+ '\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent'.
+ $header_line.$namepostfix.'} \vskip 5 mm '.$current_output;
}
#
# Close the student bracketing.
@@ -2147,6 +2161,9 @@ sub printHelper {
} else {
if ($env{'form.postdata'}) {
$helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($env{'form.postdata'});
+ if ( $helper->{VARS}->{'symb'} eq '') {
+ $helper->{VARS}->{'postdata'} = $env{'form.postdata'};
+ }
}
if ($env{'form.symb'}) {
$helper->{VARS}->{'symb'} = $env{'form.symb'};
@@ -2182,9 +2199,14 @@ sub printHelper {
$subdir = substr($helper->{VARS}->{'filename'},
0, rindex($helper->{VARS}->{'filename'}, '/') + 1);
} else {
- ($map, $id, $url) = &Apache::lonnet::decode_symb($symb);
- $helper->{VARS}->{'postdata'} =
- &Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url));
+ if ($symb ne '') {
+ ($map, $id, $url) = &Apache::lonnet::decode_symb($symb);
+ $helper->{VARS}->{'postdata'} =
+ &Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url));
+ } else {
+ $url = $helper->{VARS}->{'postdata'};
+ }
+ $url = &Apache::lonnet::clutter($url);
if (!$resourceTitle) { # if the resource doesn't have a title, use the filename
my $postdata = $helper->{VARS}->{'postdata'};
@@ -2205,11 +2227,6 @@ sub printHelper {
# "Delete everything after the last slash."
$subdir =~ s|/[^/]+$||;
- if (not $helper->{VARS}->{'construction'}) {
- $subdir=$Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'.$subdir;
- }
- # "Remove all duplicate slashes."
- $subdir =~ s|/+|/|g;
# What can be printed is a very dynamic decision based on
# lots of factors. So we need to dynamically build this list.
@@ -2601,12 +2618,20 @@ 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("Selected Problems from current subdirectory [_1]",$subdir), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
+ if ($perm{'pav'}
+ && $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'
+ && (defined($helper->{'VARS'}->{'construction'})
+ ||
+ (&Apache::lonnet::allowed('bre',$subdir) eq 'F'
+ &&
+ $helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)
+ )
+ ) {
- my $f = '$filename';
+ my $pretty_dir = &Apache::lonnet::hreflocation($subdir);
+ push @{$printChoices}, [&mt("Selected Problems from current subdirectory [_1]",$pretty_dir), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
my $xmlfrag = <
+
PAGESIZE