--- loncom/interface/lonprintout.pm 2004/02/13 21:13:21 1.276 +++ loncom/interface/lonprintout.pm 2004/02/26 20:50:00 1.280 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.276 2004/02/13 21:13:21 sakharuk Exp $ +# $Id: lonprintout.pm,v 1.280 2004/02/26 20:50:00 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -982,7 +982,10 @@ ENDPART $selectionmade=8; } 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'}; #loop over students my $flag_latex_header_remove = 'NO'; @@ -1155,35 +1158,52 @@ ENDPART } #-- writing .tex file in prtspool my $temp_file; - my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout_".time."_".rand(10000000).".tex"; - unless ($temp_file = Apache::File->new('>'.$filename)) { - $r->log_error("Couldn't open $filename for output $!"); - return SERVER_ERROR; - } - print $temp_file $result; - my $begin=index($result,'\begin{document}',0); - my $inc=substr($result,0,$begin+16); - if ($#print_array>0) { - for (my $i=1;$i<=$#print_array;$i++) { - 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 $identifier = &Apache::loncommon::get_cgi_id(); + my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout_".$identifier.".tex"; + if (!($#print_array>0)) { + unless ($temp_file = Apache::File->new('>'.$filename)) { + $r->log_error("Couldn't open $filename for output $!"); + return SERVER_ERROR; + } + print $temp_file $result; + my $begin=index($result,'\begin{document}',0); + my $inc=substr($result,0,$begin+16); + } else { + my $begin=index($result,'\begin{document}',0); + my $inc=substr($result,0,$begin+16); + 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 $newfilename=$filename; - $newfilename =~s/\.tex$/_add$i\.tex/; + my $num=$i+1; + $newfilename =~s/\.tex$/_$num\.tex/; unless ($temp_file = Apache::File->new('>'.$newfilename)) { $r->log_error("Couldn't open $newfilename for output $!"); return SERVER_ERROR; } 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 @@ -1193,10 +1213,12 @@ ENDPART } else { #prints resource from the construction space $URLback='/'.$helper->{'VARS'}->{'filename'}; - if ($URLback=~/([^?]+)/) {$URLback=$1;} + if ($URLback=~/([^?]+)/) { + $URLback=$1; + $URLback=~s|^/~|/priv/|; + } } - my $identifier = time.'_'.int(rand(1000)); &Apache::lonnet::appenv('cgi.'.$identifier.'.file' => $filename, 'cgi.'.$identifier.'.layout' => $laystyle, 'cgi.'.$identifier.'.numcol' => $numberofcolumns, @@ -1490,7 +1512,7 @@ CHOOSE_STUDENTS $paramHash = Apache::lonhelper::getParamHash(); $paramHash->{'variable'} = 'NUMBER_TO_PRINT'; $helper->declareVar('NUMBER_TO_PRINT'); - addMessage("
"); + addMessage("
"); if ($helper->{VARS}->{'assignment'}) { push @{$printChoices}, ["Resources from $sequenceTitle for selected students", 'resources_for_students', 'CHOOSE_STUDENTS1']; @@ -1518,7 +1540,7 @@ CHOOSE_STUDENTS1 $paramHash = Apache::lonhelper::getParamHash(); $paramHash->{'variable'} = 'NUMBER_TO_PRINT'; $helper->declareVar('NUMBER_TO_PRINT'); - addMessage("
"); + addMessage("
"); } # FIXME: That RE should come from a library somewhere. @@ -1916,7 +1938,7 @@ sub render {

Hint: Some instructors like to leave scratch space for the student by -making the width much smaller then the width of the page.

+making the width much smaller than the width of the page.

ELEMENTHTML