version 1.272, 2004/02/03 21:38:18
|
version 1.280, 2004/02/26 20:50:00
|
Line 647 sub path_to_problem {
|
Line 647 sub path_to_problem {
|
return '{\small\noindent\verb|'.$newurlp.'|\vskip 0 mm}'; |
return '{\small\noindent\verb|'.$newurlp.'|\vskip 0 mm}'; |
} |
} |
|
|
|
sub recalcto_mm { |
|
my $textwidth=shift; |
|
my $LaTeXwidth; |
|
if ($textwidth=~/(\d+\.?\d*)\s*cm/) { |
|
$LaTeXwidth = $1*10; |
|
} elsif ($textwidth=~/(\d+\.?\d*)\s*mm/) { |
|
$LaTeXwidth = $1; |
|
} elsif ($textwidth=~/(\d+\.?\d*)\s*in/) { |
|
$LaTeXwidth = $1*25.4; |
|
} |
|
$LaTeXwidth.=' mm'; |
|
return $LaTeXwidth; |
|
} |
|
|
sub output_data { |
sub output_data { |
my ($r,$helper,$rparmhash) = @_; |
my ($r,$helper,$rparmhash) = @_; |
my %parmhash = %$rparmhash; |
my %parmhash = %$rparmhash; |
Line 696 ENDPART
|
Line 710 ENDPART
|
} |
} |
my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle,$numberofcolumns); |
my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle,$numberofcolumns); |
my $assignment = $ENV{'form.assignment'}; |
my $assignment = $ENV{'form.assignment'}; |
my $LaTeXwidth; |
my $LaTeXwidth=&recalcto_mm($textwidth); |
if ($textwidth=~/(\d+\.?\d*)\s*cm/) { |
|
$LaTeXwidth = $1*10; |
|
} elsif ($textwidth=~/(\d+\.?\d*)\s*mm/) { |
|
$LaTeXwidth = $1; |
|
} elsif ($textwidth=~/(\d+\.?\d*)\s*in/) { |
|
$LaTeXwidth = $1*25.4; |
|
} |
|
$LaTeXwidth.=' mm'; |
|
my @print_array=(); |
my @print_array=(); |
|
my @student_names=(); |
|
|
if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') { |
if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') { |
#-- single document - problem, page, html, xml, ... |
#-- single document - problem, page, html, xml, ... |
Line 733 ENDPART
|
Line 740 ENDPART
|
} |
} |
my %form; |
my %form; |
$form{'grade_target'}='tex'; |
$form{'grade_target'}='tex'; |
$form{'textwidth'}=$LaTeXwidth; |
if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && |
|
$helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { |
|
$form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'}); |
|
} else { |
|
$form{'textwidth'}=$LaTeXwidth; |
|
} |
$form{'problem_split'}=$parmhash{'problem_stream_switch'}; |
$form{'problem_split'}=$parmhash{'problem_stream_switch'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
if ($helper->{'VARS'}->{'curseed'}) { |
if ($helper->{'VARS'}->{'curseed'}) { |
Line 743 ENDPART
|
Line 755 ENDPART
|
&Apache::lonnet::appenv(%moreenv); |
&Apache::lonnet::appenv(%moreenv); |
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonxml::init_counter(); |
&Apache::lonxml::init_counter(); |
$texversion=&Apache::lonnet::ssi($currentURL,%form); |
$texversion.=&Apache::lonnet::ssi($currentURL,%form); |
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonnet::delenv('request.filename'); |
&Apache::lonnet::delenv('request.filename'); |
} |
} |
Line 798 ENDPART
|
Line 810 ENDPART
|
if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') { |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') { |
my %form; |
my %form; |
$form{'grade_target'}='tex'; |
$form{'grade_target'}='tex'; |
$form{'textwidth'}=$LaTeXwidth; |
if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && |
|
$helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { |
|
$form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'}); |
|
} else { |
|
$form{'textwidth'}=$LaTeXwidth; |
|
} |
$form{'problem_split'}=$parmhash{'problem_stream_switch'}; |
$form{'problem_split'}=$parmhash{'problem_stream_switch'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
$form{'rndseed'}=$rndseed; |
$form{'rndseed'}=$rndseed; |
Line 844 ENDPART
|
Line 861 ENDPART
|
} elsif ($currentURL=~/\/smppg$/) { |
} elsif ($currentURL=~/\/smppg$/) { |
my %form; |
my %form; |
$form{'grade_target'}='tex'; |
$form{'grade_target'}='tex'; |
$form{'textwidth'}=$LaTeXwidth; |
if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && |
|
$helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { |
|
$form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'}); |
|
} else { |
|
$form{'textwidth'}=$LaTeXwidth; |
|
} |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
my $texversion=&Apache::lonnet::ssi($currentURL,%form); |
my $texversion=&Apache::lonnet::ssi($currentURL,%form); |
$result .= $texversion; |
$result .= $texversion; |
Line 866 ENDPART
|
Line 888 ENDPART
|
#-- produce an output string |
#-- produce an output string |
my %form=(); |
my %form=(); |
$form{'grade_target'}='tex'; |
$form{'grade_target'}='tex'; |
$form{'textwidth'}=$LaTeXwidth; |
if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && |
|
$helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { |
|
$form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'}); |
|
} else { |
|
$form{'textwidth'}=$LaTeXwidth; |
|
} |
$form{'problem_split'}=$parmhash{'problem_stream_switch'}; |
$form{'problem_split'}=$parmhash{'problem_stream_switch'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; |
my $flag_latex_header_remove = 'NO'; |
my $flag_latex_header_remove = 'NO'; |
Line 955 ENDPART
|
Line 982 ENDPART
|
$selectionmade=8; |
$selectionmade=8; |
} |
} |
my @students=split /\|\|\|/, $helper->{'VARS'}->{'STUDENTS'}; |
my @students=split /\|\|\|/, $helper->{'VARS'}->{'STUDENTS'}; |
if ($helper->{'VARS'}->{'NUMBER_TO_PRINT'} eq '0') {$helper->{'VARS'}->{'NUMBER_TO_PRINT'}=$#students+1;} |
if ($helper->{'VARS'}->{'NUMBER_TO_PRINT'} eq '0' || |
|
$helper->{'VARS'}->{'NUMBER_TO_PRINT'} eq 'all' ) { |
|
$helper->{'VARS'}->{'NUMBER_TO_PRINT'}=$#students+1; |
|
} |
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; |
#loop over students |
#loop over students |
my $flag_latex_header_remove = 'NO'; |
my $flag_latex_header_remove = 'NO'; |
my %moreenv; |
my %moreenv; |
$moreenv{'form.textwidth'}=$LaTeXwidth; |
if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && |
|
$helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { |
|
$moreenv{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'}); |
|
} else { |
|
$moreenv{'textwidth'}=$LaTeXwidth; |
|
} |
&Apache::lonnet::appenv(%moreenv); |
&Apache::lonnet::appenv(%moreenv); |
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1); |
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1); |
my $student_counter=-1; |
my $student_counter=-1; |
Line 1024 ENDPART
|
Line 1059 ENDPART
|
$current_output = '\strut\\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 '.$blanspages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}}} \vskip -5 mm '.$current_output; |
$current_output = '\strut\\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 '.$blanspages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}}} \vskip -5 mm '.$current_output; |
} |
} |
$print_array[int($student_counter/$helper->{'VARS'}->{'NUMBER_TO_PRINT'})].=$current_output; |
$print_array[int($student_counter/$helper->{'VARS'}->{'NUMBER_TO_PRINT'})].=$current_output; |
|
$student_names[int($student_counter/$helper->{'VARS'}->{'NUMBER_TO_PRINT'})].=$person.':'.$fullname.'_END_'; |
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonnet::delenv('form.counter'); |
&Apache::lonxml::init_counter(); |
&Apache::lonxml::init_counter(); |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
Line 1048 ENDPART
|
Line 1084 ENDPART
|
if ($urlp=~/\//) { |
if ($urlp=~/\//) { |
my %form; |
my %form; |
$form{'grade_target'}='tex'; |
$form{'grade_target'}='tex'; |
$form{'textwidth'}=$LaTeXwidth; |
if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ && |
|
$helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) { |
|
$form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'}); |
|
} else { |
|
$form{'textwidth'}=$LaTeXwidth; |
|
} |
$form{'rndseed'}=$rndseed; |
$form{'rndseed'}=$rndseed; |
if ($urlp =~ m|/home/([^/]+)/public_html|) { |
if ($urlp =~ m|/home/([^/]+)/public_html|) { |
$urlp =~ s|/home/([^/]*)/public_html|/~$1|; |
$urlp =~ s|/home/([^/]*)/public_html|/~$1|; |
Line 1117 ENDPART
|
Line 1158 ENDPART
|
} |
} |
#-- writing .tex file in prtspool |
#-- writing .tex file in prtspool |
my $temp_file; |
my $temp_file; |
my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout_".time."_".rand(10000000).".tex"; |
my $identifier = &Apache::loncommon::get_cgi_id(); |
unless ($temp_file = Apache::File->new('>'.$filename)) { |
my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout_".$identifier.".tex"; |
$r->log_error("Couldn't open $filename for output $!"); |
if (!($#print_array>0)) { |
return SERVER_ERROR; |
unless ($temp_file = Apache::File->new('>'.$filename)) { |
} |
$r->log_error("Couldn't open $filename for output $!"); |
print $temp_file $result; |
return SERVER_ERROR; |
my $begin=index($result,'\begin{document}',0); |
} |
my $inc=substr($result,0,$begin+16); |
print $temp_file $result; |
my $newfilename=$filename; |
my $begin=index($result,'\begin{document}',0); |
if ($#print_array>0) { |
my $inc=substr($result,0,$begin+16); |
for (my $i=1;$i<=$#print_array;$i++) { |
} else { |
my $anobegin=index($print_array[$i],'\setcounter{page}',0); |
my $begin=index($result,'\begin{document}',0); |
substr($print_array[$i],0,$anobegin)=''; |
my $inc=substr($result,0,$begin+16); |
$print_array[$i]=$inc.$print_array[$i].'\end{document}'; |
for (my $i=0;$i<=$#print_array;$i++) { |
|
if ($i==0) { |
|
$print_array[$i]=$result; |
|
} else { |
|
my $anobegin=index($print_array[$i],'\setcounter{page}',0); |
|
substr($print_array[$i],0,$anobegin)=''; |
|
$print_array[$i]=$inc.$print_array[$i].'\end{document}'; |
|
} |
my $temp_file; |
my $temp_file; |
$newfilename =~s/\.tex$/_add$i\.tex/; |
my $newfilename=$filename; |
|
my $num=$i+1; |
|
$newfilename =~s/\.tex$/_$num\.tex/; |
unless ($temp_file = Apache::File->new('>'.$newfilename)) { |
unless ($temp_file = Apache::File->new('>'.$newfilename)) { |
$r->log_error("Couldn't open $newfilename for output $!"); |
$r->log_error("Couldn't open $newfilename for output $!"); |
return SERVER_ERROR; |
return SERVER_ERROR; |
} |
} |
print $temp_file $print_array[$i]; |
print $temp_file $print_array[$i]; |
} |
} |
|
} |
|
my $student_names=''; |
|
if ($#print_array>0) { |
|
for (my $i=0;$i<=$#print_array;$i++) { |
|
$student_names.=$student_names[$i].'_ENDPERSON_'; |
|
} |
|
} else { |
|
if ($#student_names>-1) { |
|
$student_names=$student_names[0].'_ENDPERSON_'; |
|
} else { |
|
my $fullname = &get_name($ENV{'user.name'},$ENV{'user.domain'}); |
|
$student_names=join(':',$ENV{'user.name'},$ENV{'user.domain'}, |
|
$ENV{'request.course.sec'},$fullname). |
|
'_ENDPERSON_'.'_END_'; |
|
} |
|
} |
|
|
|
my $URLback=''; #link to original document |
|
if ($helper->{'VARS'}->{'construction'} ne '1') { |
|
#prints published resource |
|
$URLback=$helper->{'VARS'}->{'postdata'}; |
|
} else { |
|
#prints resource from the construction space |
|
$URLback='/'.$helper->{'VARS'}->{'filename'}; |
|
if ($URLback=~/([^?]+)/) { |
|
$URLback=$1; |
|
$URLback=~s|^/~|/priv/|; |
|
} |
} |
} |
|
|
my $identifier = time.'_'.int(rand(1000)); |
|
&Apache::lonnet::appenv('cgi.'.$identifier.'.file' => $filename, |
&Apache::lonnet::appenv('cgi.'.$identifier.'.file' => $filename, |
'cgi.'.$identifier.'.layout' => $laystyle, |
'cgi.'.$identifier.'.layout' => $laystyle, |
'cgi.'.$identifier.'.numcol' => $numberofcolumns, |
'cgi.'.$identifier.'.numcol' => $numberofcolumns, |
Line 1150 ENDPART
|
Line 1226 ENDPART
|
'cgi.'.$identifier.'tableofcontents' => $helper->{'VARS'}->{'TABLE_CONTENTS'}, |
'cgi.'.$identifier.'tableofcontents' => $helper->{'VARS'}->{'TABLE_CONTENTS'}, |
'cgi.'.$identifier.'tableofindex' => $helper->{'VARS'}->{'TABLE_INDEX'}, |
'cgi.'.$identifier.'tableofindex' => $helper->{'VARS'}->{'TABLE_INDEX'}, |
'cgi.'.$identifier.'role' => $ENV{'request.role.adv'}, |
'cgi.'.$identifier.'role' => $ENV{'request.role.adv'}, |
'cgi.'.$identifier.'numberoffiles' => $#print_array); |
'cgi.'.$identifier.'numberoffiles' => $#print_array, |
|
'cgi.'.$identifier.'studentnames' => $student_names, |
|
'cgi.'.$identifier.'backref' => $URLback,); |
|
|
|
|
$r->print(<<FINALEND); |
$r->print(<<FINALEND); |
<meta http-equiv="Refresh" content="0; url=/cgi-bin/printout.pl?$identifier"> |
<meta http-equiv="Refresh" content="0; url=/cgi-bin/printout.pl?$identifier"> |
</body> |
</body> |
Line 1435 CHOOSE_STUDENTS
|
Line 1512 CHOOSE_STUDENTS
|
$paramHash = Apache::lonhelper::getParamHash(); |
$paramHash = Apache::lonhelper::getParamHash(); |
$paramHash->{'variable'} = 'NUMBER_TO_PRINT'; |
$paramHash->{'variable'} = 'NUMBER_TO_PRINT'; |
$helper->declareVar('NUMBER_TO_PRINT'); |
$helper->declareVar('NUMBER_TO_PRINT'); |
addMessage("<input type='text' name='NUMBER_TO_PRINT.forminput' size='3' value='0' /><hr width='33%' />"); |
addMessage("<input type='text' name='NUMBER_TO_PRINT.forminput' size='3' value='all' /><hr width='33%' />"); |
|
|
if ($helper->{VARS}->{'assignment'}) { |
if ($helper->{VARS}->{'assignment'}) { |
push @{$printChoices}, ["<b>Resources</b> from <b><i>$sequenceTitle</i></b> for <b>selected students</b>", 'resources_for_students', 'CHOOSE_STUDENTS1']; |
push @{$printChoices}, ["<b>Resources</b> from <b><i>$sequenceTitle</i></b> for <b>selected students</b>", 'resources_for_students', 'CHOOSE_STUDENTS1']; |
Line 1463 CHOOSE_STUDENTS1
|
Line 1540 CHOOSE_STUDENTS1
|
$paramHash = Apache::lonhelper::getParamHash(); |
$paramHash = Apache::lonhelper::getParamHash(); |
$paramHash->{'variable'} = 'NUMBER_TO_PRINT'; |
$paramHash->{'variable'} = 'NUMBER_TO_PRINT'; |
$helper->declareVar('NUMBER_TO_PRINT'); |
$helper->declareVar('NUMBER_TO_PRINT'); |
addMessage("<input type='text' name='NUMBER_TO_PRINT.forminput' size='3' value='0' /><hr width='33%' />"); |
addMessage("<input type='text' name='NUMBER_TO_PRINT.forminput' size='3' value='all' /><hr width='33%' />"); |
} |
} |
|
|
# FIXME: That RE should come from a library somewhere. |
# FIXME: That RE should come from a library somewhere. |
Line 1861 sub render {
|
Line 1938 sub render {
|
</table> |
</table> |
|
|
<p>Hint: Some instructors like to leave scratch space for the student by |
<p>Hint: Some instructors like to leave scratch space for the student by |
making the width much smaller then the width of the page.</p> |
making the width much smaller than the width of the page.</p> |
|
|
ELEMENTHTML |
ELEMENTHTML |
|
|