version 1.469, 2006/07/31 10:32:00
|
version 1.475, 2006/08/03 00:26:39
|
Line 833 sub latex_corrections {
|
Line 833 sub latex_corrections {
|
# $result =~ s/\\includegraphics{/\\includegraphics\[width=\\minipagewidth\]{/g; |
# $result =~ s/\\includegraphics{/\\includegraphics\[width=\\minipagewidth\]{/g; |
$result =~ s/\$number_of_columns/$number_of_columns/g; |
$result =~ s/\$number_of_columns/$number_of_columns/g; |
if ($selectionmade eq '1' || $answer_mode eq 'only') { |
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 $1/; |
$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/; |
} else { |
} 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 $1/; |
$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{longtable}\s*)(\\strut\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill})/$2$1/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; |
$result =~ s/(\\end{longtable}\s*)\\strut\\newline/$1/g; |
Line 893 sub IndexCreation {
|
Line 893 sub IndexCreation {
|
|
|
sub print_latex_header { |
sub print_latex_header { |
my $mode=shift; |
my $mode=shift; |
my $output='\documentclass[letterpaper,twoside]{article}'; |
my $output='\documentclass[letterpaper,twoside]{article}\raggedbottom'; |
if (($mode eq 'batchmode') || (!$perm{'pav'})) { |
if (($mode eq 'batchmode') || (!$perm{'pav'})) { |
$output.='\batchmode'; |
$output.='\batchmode'; |
} |
} |
Line 1754 ENDPART
|
Line 1754 ENDPART
|
$result = &page_format_transformation($papersize,$laystyle,$numberofcolumns,$helper->{'VARS'}->{'PRINT_TYPE'},$result,$helper->{VARS}->{'assignment'},$helper->{'VARS'}->{'TABLE_CONTENTS'},$helper->{'VARS'}->{'TABLE_INDEX'},$selectionmade); |
$result = &page_format_transformation($papersize,$laystyle,$numberofcolumns,$helper->{'VARS'}->{'PRINT_TYPE'},$result,$helper->{VARS}->{'assignment'},$helper->{'VARS'}->{'TABLE_CONTENTS'},$helper->{'VARS'}->{'TABLE_INDEX'},$selectionmade); |
$result = &latex_corrections($number_of_columns,$result,$selectionmade, |
$result = &latex_corrections($number_of_columns,$result,$selectionmade, |
$helper->{'VARS'}->{'ANSWER_TYPE'}); |
$helper->{'VARS'}->{'ANSWER_TYPE'}); |
for (my $i=1;$i<=$#print_array;$i++) { |
|
$print_array[$i] = |
|
&latex_corrections($number_of_columns,$print_array[$i], |
|
$selectionmade, |
|
$helper->{'VARS'}->{'ANSWER_TYPE'}); |
|
} |
|
#if ($numberofcolumns == 1) { |
#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'} /; |
Line 1786 ENDPART
|
Line 1780 ENDPART
|
if ($i==0) { |
if ($i==0) { |
$print_array[$i]=$result; |
$print_array[$i]=$result; |
} else { |
} else { |
|
$print_array[$i].='\end{document}'; |
|
$print_array[$i] = |
|
&latex_corrections($number_of_columns,$print_array[$i], |
|
$selectionmade, |
|
$helper->{'VARS'}->{'ANSWER_TYPE'}); |
|
|
my $anobegin=index($print_array[$i],'\setcounter{page}',0); |
my $anobegin=index($print_array[$i],'\setcounter{page}',0); |
substr($print_array[$i],0,$anobegin)=''; |
substr($print_array[$i],0,$anobegin)=''; |
$print_array[$i]=$inc.$print_array[$i].'\end{document}'; |
$print_array[$i]=$inc.$print_array[$i]; |
} |
} |
my $temp_file; |
my $temp_file; |
my $newfilename=$filename; |
my $newfilename=$filename; |
Line 2003 sub print_resources {
|
Line 2003 sub print_resources {
|
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{'.$HeaderLine.'}'.$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."\n\\special{ps:ENDOFSTUDENTSTAMP}\n".'\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]{'.$HeaderLine.'}'.$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."\n\\special{ps:ENDOFSTUDENTSTAMP}\n".'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{'.$HeaderLine.'}'.$namepostfix.'} \vskip 5 mm '.$current_output; |
} |
} |
} |
} |
# |
# |
# Close the student bracketing. |
# Close the student bracketing. |
# |
# |
$current_output .= "\n\\special{ps:ENDOFSTUDENTSTAMP}\n"; |
|
return ($current_output,$fullname, $printed); |
return ($current_output,$fullname, $printed); |
|
|
} |
} |
Line 2318 ALL_PROBLEMS
|
Line 2317 ALL_PROBLEMS
|
|
|
if ($helper->{VARS}->{'assignment'}) { |
if ($helper->{VARS}->{'assignment'}) { |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>selected students</b>",$sequenceTitle), 'problems_for_students', 'CHOOSE_STUDENTS']; |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>selected students</b>",$sequenceTitle), 'problems_for_students', 'CHOOSE_STUDENTS']; |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>anonymous students</b>",$sequenceTitle), 'problems_for_anon', 'CHOOSE_ANON1']; |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>CODEd assignments</b>",$sequenceTitle), 'problems_for_anon', 'CHOOSE_ANON1']; |
} |
} |
|
|
# resource_selector will hold a few states that: |
# resource_selector will hold a few states that: |
Line 2405 CHOOSE_STUDENTS
|
Line 2404 CHOOSE_STUDENTS
|
} |
} |
if (%codes_to_print) { |
if (%codes_to_print) { |
$code_selection .=' |
$code_selection .=' |
<message><b>Choose single code from list</b></message> |
<message><b>Choose single CODE from list:</b></message> |
<message></td><td></message> |
<message></td><td></message> |
<dropdown variable="CODE_SELECTED_FROM_LIST" multichoice="0" allowempty="0"> |
<dropdown variable="CODE_SELECTED_FROM_LIST" multichoice="0" allowempty="0"> |
<choice></choice> |
<choice></choice> |
Line 2462 CHOOSE_STUDENTS
|
Line 2461 CHOOSE_STUDENTS
|
</dropdown> |
</dropdown> |
<message></td></tr><tr><td colspan="2"></td></tr><tr><td></message> |
<message></td></tr><tr><td colspan="2"></td></tr><tr><td></message> |
<message></td></tr><tr><td></table></message> |
<message></td></tr><tr><td></table></message> |
<message><br /><hr /><h3>Print a Specific Code </h3><br /><table></message> |
<message><br /><hr /><h3>Print a Specific CODE </h3><br /><table></message> |
<message><tr><td><b>Enter a CODE to print:</b></td><td></message> |
<message><tr><td><b>Enter a CODE to print:</b></td><td></message> |
<string variable="SINGLE_CODE" size="10"> |
<string variable="SINGLE_CODE" size="10"> |
<validator> |
<validator> |
Line 2476 CHOOSE_STUDENTS
|
Line 2475 CHOOSE_STUDENTS
|
} |
} |
</validator> |
</validator> |
</string> |
</string> |
<message></td</tr><tr><td></message> |
<message></td></tr><tr><td></message> |
$code_selection |
$code_selection |
<message></td></tr></table></message> |
<message></td></tr></table></message> |
<message><hr /><h3>Reprint a Set of Saved Codes</h3><table><tr><td></message> |
<message><hr /><h3>Reprint a Set of Saved CODEs</h3><table><tr><td></message> |
<message><b>Select saved CODEs:</b></message> |
<message><b>Select saved CODEs:</b></message> |
<message></td><td></message> |
<message></td><td></message> |
<dropdown variable="REUSE_OLD_CODES"> |
<dropdown variable="REUSE_OLD_CODES"> |
Line 2493 CHOOSE_ANON1
|
Line 2492 CHOOSE_ANON1
|
|
|
if ($helper->{VARS}->{'assignment'}) { |
if ($helper->{VARS}->{'assignment'}) { |
push @{$printChoices}, [&mt("Selected <b>Resources</b> from folder <b><i>[_1]</i></b> for <b>selected students</b>",$sequenceTitle), 'resources_for_students', 'CHOOSE_STUDENTS1']; |
push @{$printChoices}, [&mt("Selected <b>Resources</b> from folder <b><i>[_1]</i></b> for <b>selected students</b>",$sequenceTitle), 'resources_for_students', 'CHOOSE_STUDENTS1']; |
push @{$printChoices}, [&mt("Selected <b>Resources</b> from folder <b><i>[_1]</i></b> for <b>anonymous students</b>",$sequenceTitle), 'resources_for_anon', 'CHOOSE_ANON2']; |
push @{$printChoices}, [&mt("Selected <b>Resources</b> from folder <b><i>[_1]</i></b> for <b>CODEd assignments</b>",$sequenceTitle), 'resources_for_anon', 'CHOOSE_ANON2']; |
} |
} |
|
|
|
|
Line 2544 RESOURCE_SELECTOR
|
Line 2543 RESOURCE_SELECTOR
|
CHOOSE_STUDENTS1 |
CHOOSE_STUDENTS1 |
|
|
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON2); |
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON2); |
<state name="CHOOSE_ANON2" title="Select Students and Resources"> |
<state name="CHOOSE_ANON2" title="Select CODEd Assignments"> |
<nextstate>SELECT_RESOURCES</nextstate> |
<nextstate>SELECT_RESOURCES</nextstate> |
<message><table><tr><td><b>Number of anonymous assignments to print:</b></td><td></message> |
<message><h4>Fill out one of the forms below</h4></message> |
|
<message><br /><hr /> <br /></message> |
|
<message><h3>Generate new CODEd Assignments</h3></message> |
|
<message><table><tr><td><b>Number of CODEd assignments to print:</b></td><td></message> |
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"> |
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"> |
<validator> |
<validator> |
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
Line 2568 CHOOSE_STUDENTS1
|
Line 2570 CHOOSE_STUDENTS1
|
<dropdown variable="CODE_OPTION" multichoice="0" allowempty="0"> |
<dropdown variable="CODE_OPTION" multichoice="0" allowempty="0"> |
$codechoice |
$codechoice |
</dropdown> |
</dropdown> |
<message></td></tr><tr><td colspan="2"><hr width='33%' /></td></tr><tr><td></message> |
<message></td></tr><tr><td></table></message> |
<message></td></tr><tr><td></message> |
<message><br /><hr /><h3>Print a Specific CODE </h3><br /><table></message> |
<message><b>Enter a CODE to print:</b></td><td></message> |
<message><tr><td><b>Enter a CODE to print:</b></td><td></message> |
<string variable="SINGLE_CODE" size="10"> |
<string variable="SINGLE_CODE" size="10"> |
<validator> |
<validator> |
if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} && |
if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} && |
Line 2583 CHOOSE_STUDENTS1
|
Line 2585 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></message> |
$code_selection |
$code_selection |
<message><b>Reprint a set of saved CODEs:</b></message> |
<message></td></tr></table></message> |
|
<message><hr /><h3>Reprint a Set of Saved CODEs</h3><table><tr><td></message> |
|
<message><b>Select saved CODEs:</b></message> |
<message></td><td></message> |
<message></td><td></message> |
<dropdown variable="REUSE_OLD_CODES"> |
<dropdown variable="REUSE_OLD_CODES"> |
$namechoice |
$namechoice |
</dropdown> |
</dropdown> |
<message></td></tr></table></message> |
<message></td></tr></table></message> |
<message><hr width='33%' /></message> |
|
</state> |
</state> |
$resource_selector |
$resource_selector |
CHOOSE_ANON2 |
CHOOSE_ANON2 |
Line 3030 sub render {
|
Line 3033 sub render {
|
} |
} |
} |
} |
|
|
$result .= <<ELEMENTHTML; |
# Adjust margin for LaTeX margin: .. requires units == cm or in. |
|
|
|
if ($size{'margin_unit'} eq 'in') { |
|
$size{'margin'} += 1; |
|
} else { |
|
$size{'margin'} += 2.54; |
|
} |
|
$result .= <<ELEMENTHTML; |
|
|
|
|
|
|
<p>How should each column be formatted?</p> |
<p>How should each column be formatted?</p> |
|
|
Line 3074 ELEMENTHTML
|
Line 3084 ELEMENTHTML
|
return $result; |
return $result; |
} |
} |
|
|
# If the user didn't select 1 column, skip this state. |
|
sub preprocess { |
sub preprocess { |
my $self = shift; |
my $self = shift; |
my $helper = Apache::lonhelper::getHelper(); |
my $helper = Apache::lonhelper::getHelper(); |
Line 3107 sub preprocess {
|
Line 3117 sub preprocess {
|
|
|
foreach my $dim ('width', 'height', 'lmargin') { |
foreach my $dim ('width', 'height', 'lmargin') { |
my ($value, $units) = split(/ /, $size{$dim}); |
my ($value, $units) = split(/ /, $size{$dim}); |
|
|
&Apache::lonnet::logthis("$dim : $value : $units"); |
|
|
|
$helper->{VARS}->{"$var.".$dim} = $value; |
$helper->{VARS}->{"$var.".$dim} = $value; |
$helper->{VARS}->{"$var.".$dim.'unit'} = $units; |
$helper->{VARS}->{"$var.".$dim.'unit'} = $units; |
|
|
Line 3149 sub postprocess {
|
Line 3157 sub postprocess {
|
} |
} |
if ($lmargin !~ /^-?[0-9]*(\.[0-9]*)?$/) { |
if ($lmargin !~ /^-?[0-9]*(\.[0-9]*)?$/) { |
$error .= "Invalid left margin; please type only a number.<br />\n"; |
$error .= "Invalid left margin; please type only a number.<br />\n"; |
|
} else { |
|
# Adjust for LaTeX 1.0 inch margin: |
|
|
|
if ($env{"form.${var}.lmarginunit"} eq "in") { |
|
$helper->{VARS}->{$var.'.lmargin'} = $lmargin - 1; |
|
} else { |
|
$helper->{VARS}->{$var.'.lmargin'} = $lmargin - 2.54; |
|
} |
} |
} |
|
|
if (!$error) { |
if (!$error) { |