--- loncom/interface/lonprintout.pm 2006/04/18 10:03:45 1.437 +++ loncom/interface/lonprintout.pm 2006/06/30 04:23:29 1.450 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.437 2006/04/18 10:03:45 foxr Exp $ +# $Id: lonprintout.pm,v 1.450 2006/06/30 04:23:29 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,6 +42,8 @@ use Apache::lonratedt; use POSIX qw(strftime); use Apache::lonlocal; use Carp; +use lib '/home/httpd/lib/perl/'; +use LONCAPA; my %perm; @@ -700,14 +702,15 @@ 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=&Apache::lonxml::latex_special_symbols($plainname,'header'); + $plainname = &escape_LaTeX($plainname); return $plainname; } sub get_course { my $courseidinfo; if (defined($env{'request.course.id'})) { - $courseidinfo = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::unescape($env{'course.'.$env{'request.course.id'}.'.description'}),'header'); + $courseidinfo = &Apache::lonxml::latex_special_symbols(&unescape($env{'course.'.$env{'request.course.id'}.'.description'}),'header'); } return $courseidinfo; } @@ -1119,8 +1122,6 @@ ENDPART $selectionmade = 1; if ($cleanURL!~m|^/adm/| && $cleanURL=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { - if ($cleanURL =~/\.page/) { - } my $rndseed=time; my $texversion=''; if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') { @@ -1261,7 +1262,7 @@ ENDPART } if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;} $result .= '\end{document}'; - } elsif ($cleanURL=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { + } elsif ($cleanURL=~/\/(smppg|grppg|syllabus|aboutme|bulletinboard)$/) { $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;} $resources_printed .= $currentURL.':'; @@ -1321,12 +1322,9 @@ ENDPART my $texversion=''; if ($urlp!~m|^/adm/| && $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { - if ($urlp =!/\.page/) { - } $resources_printed .= $urlp.':'; &Apache::lonxml::remember_problem_counter(); - $texversion.=&Apache::lonnet::ssi($urlp,%form); if ($urlp=~/\.page$/) { ($texversion,my $number_of_columns_page) = &page_cleanup($texversion); @@ -1382,7 +1380,7 @@ ENDPART } $result .= $texversion; $flag_latex_header_remove = 'YES'; - } elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { + } elsif ($urlp=~/\/(smppg|grppg|syllabus|aboutme|bulletinboard)$/) { $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;} $resources_printed .= $urlp.':'; @@ -1675,13 +1673,12 @@ ENDPART $selectionmade, $helper->{'VARS'}->{'ANSWER_TYPE'}); } - #changes page's parameters for the one column output - if ($numberofcolumns == 1) { - $result =~ s/\\textwidth\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /; - $result =~ s/\\textheight\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textheight $helper->{'VARS'}->{'pagesize.height'} $helper->{'VARS'}->{'pagesize.heightunit'} /; - $result =~ s/\\evensidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\evensidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /; - $result =~ s/\\oddsidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\oddsidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /; - } + + $result =~ s/\\textwidth\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /; + $result =~ s/\\textheight\s*=?\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textheight $helper->{'VARS'}->{'pagesize.height'} $helper->{'VARS'}->{'pagesize.heightunit'} /; + $result =~ s/\\evensidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\evensidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /; + $result =~ s/\\oddsidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\oddsidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /; + #-- writing .tex file in prtspool my $temp_file; @@ -1737,7 +1734,7 @@ ENDPART my $URLback=''; #link to original document if ($helper->{'VARS'}->{'construction'} ne '1') { #prints published resource - $URLback=&Apache::lonnet::escape('/adm/flip?postdata=return:'); + $URLback=&escape('/adm/flip?postdata=return:'); } else { #prints resource from the construction space $URLback='/'.$helper->{'VARS'}->{'filename'}; @@ -1806,6 +1803,9 @@ sub print_resources { $namepostfix="\\\\Name: "; $fullname = "CODE - ".$moreenv->{'CODE'}; } + # Fullname may have special latex characters that need \ prefixing: + # + my $i = 0; #goes through all resources, checks if they are available for #current student, and produces output @@ -1814,6 +1814,16 @@ sub print_resources { my %page_breaks = &get_page_breaks($helper); my @format_array = split(/\|/,$helper->{'VARS'}->{'FORMAT'}); my $columns_in_format = $format_array[1]; + # + # end each student with a + # Special that allows the post processor to even out the page + # counts later. Nasty problem this... it would be really + # nice to put the special in as a postscript comment + # e.g. \special{ps:\ENDOFSTUDENTSTAMP} unfortunately, + # The special gets passed the \ and dvips puts it in the output file + # so we will just rely on prntout.pl to strip ENDOFSTUDENTSTAMP from the + # postscript. Each ENDOFSTUDENTSTAMP will go on a line by itself. + # foreach my $curresline (@{$master_seq}) { if (defined $page_breaks{$curresline}) { @@ -1828,8 +1838,6 @@ sub print_resources { if (&Apache::lonnet::allowed('bre',$res_url)) { if ($res_url!~m|^ext/| && $res_url=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { - if ($res_url =~ /\.page/) { - } $printed .= $curresline.':'; &Apache::lonxml::remember_problem_counter(); @@ -1866,7 +1874,7 @@ sub print_resources { $rendered =~ s/\\end{document}//; } $current_output .= $rendered; - } elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { + } elsif ($res_url=~/\/(smppg|grppg|syllabus|aboutme|bulletinboard)$/) { $printed .= $curresline.':'; my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv); @@ -1911,6 +1919,10 @@ sub print_resources { $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; } } + # + # Close the student bracketing. + # + $current_output .= "\n\\special{ps:ENDOFSTUDENTSTAMP}\n"; return ($current_output,$fullname, $printed); } @@ -2185,7 +2197,7 @@ 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|aboutme|bulletinboard)$/)) { + ($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|grppg|aboutme|bulletinboard)$/)) { push @{$printChoices}, ['Problems from entire course', 'all_problems', 'ALL_PROBLEMS']; push @{$printChoices}, ['Resources from entire course', 'all_resources', 'ALL_RESOURCES']; @@ -2253,8 +2265,8 @@ ALL_PROBLEMS All assignments in a single PDF file Each PDF contains exactly one section Each PDF contains exactly one assignment - - Specify Number: + + Specify the number of assignments per PDF: RESOURCE_SELECTOR @@ -2302,10 +2314,16 @@ CHOOSE_STUDENTS } if (%codes_to_print) { $code_selection .=' - - push(@{$state->{CHOICES}},@{$helper->{DATA}{ALL_CODE_CHOICES}}); - + Choose single code from list + + + + push(@{$state->{CHOICES}},@{$helper->{DATA}{ALL_CODE_CHOICES}}); + + +
'.$/; + } @@ -2363,12 +2381,9 @@ CHOOSE_STUDENTS
- Choose single code from list - - $code_selection - -
+ + Reprint a set of saved CODEs: @@ -2414,8 +2429,8 @@ CHOOSE_ANON1 All assignments in a single PDF file Each PDF contains exactly one section Each PDF contains exactly one assignment - - Specify Number: + + Specify the number of assignments per PDF: RESOURCE_SELECTOR @@ -2474,12 +2489,7 @@ CHOOSE_STUDENTS1
- Choose single code from list - - $code_selection - -
Reprint a set of saved CODEs: @@ -2888,6 +2898,12 @@ sub render { $result .= '
' . $self->{ERROR_MSG} . '
'; } + my $width = 18; + my $format = $helper->{VARS}->{$self->{'formatvar'}}; + if (substr($format, 2, 1) ne '1') { + $width = 9; + } + $result .= <How should the column be formatted?

@@ -2895,7 +2911,7 @@ sub render { - +
Width: