version 1.443, 2006/06/19 21:40:29
|
version 1.456, 2006/07/07 21:55:05
|
Line 46 use lib '/home/httpd/lib/perl/';
|
Line 46 use lib '/home/httpd/lib/perl/';
|
use LONCAPA; |
use LONCAPA; |
|
|
my %perm; |
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 |
# Convert a numeric code to letters |
Line 702 sub get_name {
|
Line 731 sub get_name {
|
if (!defined($udom)) { $udom=$env{'user.domain'}; } |
if (!defined($udom)) { $udom=$env{'user.domain'}; } |
my $plainname=&Apache::loncommon::plainname($uname,$udom); |
my $plainname=&Apache::loncommon::plainname($uname,$udom); |
if ($plainname=~/^\s*$/) { $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'); |
return $plainname; |
return $plainname; |
} |
} |
|
|
Line 717 sub get_course {
|
Line 746 sub get_course {
|
sub page_format_transformation { |
sub page_format_transformation { |
my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment,$tableofcontents,$indexlist,$selectionmade) = @_; |
my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment,$tableofcontents,$indexlist,$selectionmade) = @_; |
my ($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin); |
my ($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin); |
|
|
if ($selectionmade eq '4') { |
if ($selectionmade eq '4') { |
$assignment='Problems from the Whole Course'; |
$assignment='Problems from the Whole Course'; |
} else { |
} else { |
$assignment=&Apache::lonxml::latex_special_symbols($assignment,'header'); |
$assignment=&Apache::lonxml::latex_special_symbols($assignment,'header'); |
} |
} |
($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin) = &page_format($papersize,$layout,$numberofcolumns,$topmargin); |
($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin) = &page_format($papersize,$layout,$numberofcolumns,$topmargin); |
|
|
|
|
my $name = &get_name(); |
my $name = &get_name(); |
my $courseidinfo = &get_course(); |
my $courseidinfo = &get_course(); |
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
|
my $header_text = $parmhash{'print_header_format'}; |
|
$header_text = &format_page_header($header_text, $assignment, |
|
$courseidinfo, $name); |
my $topmargintoinsert = ''; |
my $topmargintoinsert = ''; |
if ($topmargin ne '0') {$topmargintoinsert='\setlength{\topmargin}{'.$topmargin.'}';} |
if ($topmargin ne '0') {$topmargintoinsert='\setlength{\topmargin}{'.$topmargin.'}';} |
my $fancypagestatement=''; |
my $fancypagestatement=''; |
if ($numberofcolumns eq '2') { |
if ($numberofcolumns eq '2') { |
$fancypagestatement="\\fancyhead{}\\fancyhead[LO]{\\textbf{$name} $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}"; |
$fancypagestatement="\\fancyhead{}\\fancyhead[LO]{$header_text}"; |
} else { |
} else { |
$fancypagestatement="\\rhead{}\\chead{}\\lhead{\\textbf{$name} $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}"; |
$fancypagestatement="\\rhead{}\\chead{}\\lhead{$header_text}"; |
} |
} |
if ($layout eq 'album') { |
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 /; |
$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 /; |
Line 1371 ENDPART
|
Line 1406 ENDPART
|
my $courseidinfo = &get_course(); |
my $courseidinfo = &get_course(); |
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
$prevassignment=$assignment; |
$prevassignment=$assignment; |
|
my $header_text = $parmhash{'print_header_format'}; |
|
$header_text = &format_page_header($header_text, |
|
$assignment, |
|
$courseidinfo, |
|
$name); |
if ($numberofcolumns eq '1') { |
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 { |
} 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; |
$result .= $texversion; |
Line 1561 ENDPART
|
Line 1601 ENDPART
|
} |
} |
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
my ($type) = split(/_/,$helper->{'VARS'}->{'PRINT_TYPE'}); |
my ($type) = split(/_/,$helper->{'VARS'}->{'PRINT_TYPE'}); |
|
&adjust_number_to_print($helper); |
my $number_per_page=$helper->{'VARS'}->{'NUMBER_TO_PRINT'}; |
my $number_per_page=$helper->{'VARS'}->{'NUMBER_TO_PRINT'}; |
if ($number_per_page eq '0' || $number_per_page eq 'all') { |
if ($number_per_page eq '0' || $number_per_page eq 'all') { |
$number_per_page=$num_todo; |
$number_per_page=$num_todo; |
Line 1672 ENDPART
|
Line 1713 ENDPART
|
$selectionmade, |
$selectionmade, |
$helper->{'VARS'}->{'ANSWER_TYPE'}); |
$helper->{'VARS'}->{'ANSWER_TYPE'}); |
} |
} |
|
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/\\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/\\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/\\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/\\oddsidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\oddsidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /; |
|
} |
|
|
#-- writing .tex file in prtspool |
#-- writing .tex file in prtspool |
my $temp_file; |
my $temp_file; |
Line 1802 sub print_resources {
|
Line 1843 sub print_resources {
|
$namepostfix="\\\\Name: "; |
$namepostfix="\\\\Name: "; |
$fullname = "CODE - ".$moreenv->{'CODE'}; |
$fullname = "CODE - ".$moreenv->{'CODE'}; |
} |
} |
|
# Fullname may have special latex characters that need \ prefixing: |
|
# |
|
|
my $i = 0; |
my $i = 0; |
#goes through all resources, checks if they are available for |
#goes through all resources, checks if they are available for |
#current student, and produces output |
#current student, and produces output |
Line 1899 sub print_resources {
|
Line 1943 sub print_resources {
|
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection} |
if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection} |
my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header'); |
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); |
|
&Apache::lonnet::logthis("Hdr format: $HeaderLine"); |
if ($current_output=~/\\documentclass/) { |
if ($current_output=~/\\documentclass/) { |
if ($columns_in_format == 1) { |
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 { |
} 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 { |
} else { |
my $blankpages = ''; |
my $blankpages = ''; |
for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blankpages.='\clearpage\strut\clearpage';} |
for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blankpages.='\clearpage\strut\clearpage';} |
if ($columns_in_format == 1) { |
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 { |
} 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; |
} |
} |
} |
} |
# |
# |
Line 1937 sub handler {
|
Line 1984 sub handler {
|
} |
} |
|
|
|
|
my %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'}); |
%parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'}); |
|
|
|
|
|
|
Line 2261 ALL_PROBLEMS
|
Line 2308 ALL_PROBLEMS
|
<choice computer="all">All assignments in a single PDF file</choice> |
<choice computer="all">All assignments in a single PDF file</choice> |
<choice computer="sections">Each PDF contains exactly one section</choice> |
<choice computer="sections">Each PDF contains exactly one section</choice> |
<choice computer="oneper">Each PDF contains exactly one assignment</choice> |
<choice computer="oneper">Each PDF contains exactly one assignment</choice> |
<choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT" relateddefault="all"> |
<choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT"> |
Specify Number:</choice> |
Specify the number of assignments per PDF:</choice> |
</choices> |
</choices> |
</state> |
</state> |
RESOURCE_SELECTOR |
RESOURCE_SELECTOR |
Line 2300 CHOOSE_STUDENTS
|
Line 2347 CHOOSE_STUDENTS
|
} |
} |
} |
} |
|
|
my $code_selection = "<choice></choice>\n"; |
my $code_selection; |
foreach my $code (sort {uc($a) cmp uc($b)} (keys(%codes_to_print))) { |
foreach my $code (sort {uc($a) cmp uc($b)} (keys(%codes_to_print))) { |
my $choice = $code; |
my $choice = $code; |
if ($code =~ /^[A-Z]+$/) { # Alpha code |
if ($code =~ /^[A-Z]+$/) { # Alpha code |
Line 2310 CHOOSE_STUDENTS
|
Line 2357 CHOOSE_STUDENTS
|
} |
} |
if (%codes_to_print) { |
if (%codes_to_print) { |
$code_selection .=' |
$code_selection .=' |
<exec> |
<message><b>Choose single code from list</b></message> |
push(@{$state->{CHOICES}},@{$helper->{DATA}{ALL_CODE_CHOICES}}); |
<message></td><td></message> |
</exec> |
<dropdown variable="CODE_SELECTED_FROM_LIST" multichoice="0" allowempty="0"> |
|
<choice></choice> |
|
<exec> |
|
push(@{$state->{CHOICES}},@{$helper->{DATA}{ALL_CODE_CHOICES}}); |
|
</exec> |
|
</dropdown> |
|
<message></td></tr><tr><td colspan="2"><hr width=\'33%\' /></td></tr><tr><td></message> |
'.$/; |
'.$/; |
|
|
} |
} |
|
|
|
|
Line 2371 CHOOSE_STUDENTS
|
Line 2425 CHOOSE_STUDENTS
|
</validator> |
</validator> |
</string> |
</string> |
<message></td></tr><tr><td colspan="2"><hr width='33%' /></td></tr><tr><td></message> |
<message></td></tr><tr><td colspan="2"><hr width='33%' /></td></tr><tr><td></message> |
<message><b>Choose single code from list</b></message> |
|
<message></td><td></message> |
|
<choices variable="CODE_SELECTED_FROM_LIST" multichoice="0" allowempty="0"> |
|
$code_selection |
$code_selection |
</choices> |
|
<message></td></tr><tr><td colspan="2"><hr width='33%' /></td></tr><tr><td></message> |
|
<message><b>Reprint a set of saved CODEs:</b></message> |
<message><b>Reprint a set of saved CODEs:</b></message> |
<message></td><td></message> |
<message></td><td></message> |
<dropdown variable="REUSE_OLD_CODES"> |
<dropdown variable="REUSE_OLD_CODES"> |
Line 2422 CHOOSE_ANON1
|
Line 2473 CHOOSE_ANON1
|
<choice computer="all">All assignments in a single PDF file</choice> |
<choice computer="all">All assignments in a single PDF file</choice> |
<choice computer="sections">Each PDF contains exactly one section</choice> |
<choice computer="sections">Each PDF contains exactly one section</choice> |
<choice computer="oneper">Each PDF contains exactly one assignment</choice> |
<choice computer="oneper">Each PDF contains exactly one assignment</choice> |
<choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT" relateddefault="all"> |
<choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT"> |
Specify Number:</choice> |
Specify the number of assignments per PDF:</choice> |
</choices> |
</choices> |
</state> |
</state> |
RESOURCE_SELECTOR |
RESOURCE_SELECTOR |
Line 2482 CHOOSE_STUDENTS1
|
Line 2533 CHOOSE_STUDENTS1
|
</validator> |
</validator> |
</string> |
</string> |
<message></td></tr><tr><td colspan="2"><hr width='33%' /></td></tr><tr><td></message> |
<message></td></tr><tr><td colspan="2"><hr width='33%' /></td></tr><tr><td></message> |
<message><b>Choose single code from list</b></message> |
|
<message></td><td></message> |
|
<dropdown variable="CODE_SELECTED_FROM_LIST" multichoice="0" allowempty="0"> |
|
$code_selection |
$code_selection |
</dropdown> |
|
<message></td></tr><tr><td colspan="2"><hr width='33%' /></td></tr><tr><td></message> |
|
<message><b>Reprint a set of saved CODEs:</b></message> |
<message><b>Reprint a set of saved CODEs:</b></message> |
<message></td><td></message> |
<message></td><td></message> |
<dropdown variable="REUSE_OLD_CODES"> |
<dropdown variable="REUSE_OLD_CODES"> |
Line 2950 sub preprocess {
|
Line 2996 sub preprocess {
|
my $helper = Apache::lonhelper::getHelper(); |
my $helper = Apache::lonhelper::getHelper(); |
|
|
my $format = $helper->{VARS}->{$self->{'formatvar'}}; |
my $format = $helper->{VARS}->{$self->{'formatvar'}}; |
# if (substr($format, 2, 1) ne '1') { |
if (substr($format, 2, 1) ne '1') { |
# $helper->changeState($self->{NEXTSTATE}); |
$helper->changeState($self->{NEXTSTATE}); |
# } |
} |
|
|
return 1; |
return 1; |
} |
} |