--- loncom/interface/lonprintout.pm 2006/03/08 22:32:11 1.428 +++ loncom/interface/lonprintout.pm 2006/03/15 22:11:04 1.431 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.428 2006/03/08 22:32:11 albertel Exp $ +# $Id: lonprintout.pm,v 1.431 2006/03/15 22:11:04 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,6 +41,7 @@ use Apache::lonnavmaps; use Apache::lonratedt; use POSIX qw(strftime); use Apache::lonlocal; +use Carp; my %perm; @@ -238,7 +239,34 @@ sub encapsulate_minipage { } return $text; } +# +# The NUMBER_TO_PRINT and SPLIT_PDFS +# variables interact, this sub looks at these two parameters +# and comes up with a final value for NUMBER_TO_PRINT which can be: +# all - if SPLIT_PDFS eq 'all'. +# 1 - if SPLIT_PDFS eq 'oneper' +# section - if SPLIT_PDFS eq 'sections' +# - if SPLIT_PDFS eq 'usenumber' +# +sub adjust_number_to_print { + my $helper = shift; + my $split_pdf = $helper->{'VARS'}->{'SPLIT_PDFS'}; + + if ($split_pdf eq 'all') { + $helper->{'VARS'}->{'NUMBER_TO_PRINT'} = 'all'; + } elsif ($split_pdf eq 'oneper') { + $helper->{'VARS'}->{'NUMBER_TO_PRINT'} = 1; + } elsif ($split_pdf eq 'sections') { + $helper->{'VARS'}->{'NUMBER_TO_PRINT'} = 'section'; + } elsif ($split_pdf eq 'usenumber') { + # Unmodified. + } else { + # Error!!!! + + croak "bad SPLIT_PDFS: $split_pdf in lonprintout::adjust_number_to_print"; + } +} sub character_chart { my $result = shift; @@ -995,10 +1023,12 @@ sub output_data { my %parmhash = %$rparmhash; my $resources_printed = ''; my $html=&Apache::lonxml::xmlbegin(); - my $bodytag=&Apache::loncommon::bodytag('Preparing Printout'); + my $headtag = &Apache::loncommon::headtag('Preparing Printout'); + my $end_headtag = &Apache::loncommon::endheadtag(); + my $bodytag = &Apache::loncommon::bodytag('Preparing Printout'); $r->print(< +$headtag -LON-CAPA output for printing - +$end_headtag $bodytag

Please stand by while processing your print request, this may take some time ... @@ -1407,14 +1436,28 @@ ENDPART # Each element of the students array is of the form: # username:domain:section:last, first:status # + # Note that student sort is not compatible with printing + # 1 section per pdf...so that setting overrides. # - if ($helper->{'VARS'}->{'student_sort'} eq 1) { + if (($helper->{'VARS'}->{'student_sort'} eq 1) && + ($helper->{'VARS'}->{'SPLIT_PDFS'} ne "sections")) { @students = sort compare_names @students; } + &adjust_number_to_print($helper); + if ($helper->{'VARS'}->{'NUMBER_TO_PRINT'} eq '0' || $helper->{'VARS'}->{'NUMBER_TO_PRINT'} eq 'all' ) { $helper->{'VARS'}->{'NUMBER_TO_PRINT'}=$#students+1; } + # If we are splitting on section boundaries, we need + # to remember that in split_on_sections and + # print all of the students in the list. + # + my $split_on_sections = 0; + if ($helper->{'VARS'}->{'NUMBER_TO_PRINT'} eq 'section') { + $split_on_sections = 1; + $helper->{'VARS'}->{'NUMBER_TO_PRINT'} = $#students+1; + } my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'}; #loop over students @@ -1428,6 +1471,8 @@ ENDPART if ($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') {$moreenv{'problem_split'}='yes';} my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1,'inline','75'); my $student_counter=-1; + my $i = 0; + my $last_section = (split(/:/,$students[0]))[2]; foreach my $person (@students) { my $duefile="/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.due"; @@ -1436,7 +1481,15 @@ ENDPART print $temp_file "1969\n"; } $student_counter++; - my $i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'}); + if ($split_on_sections) { + my $this_section = (split(/:/,$person))[2]; + if ($this_section ne $last_section) { + $i++; + $last_section = $this_section; + } + } else { + $i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'}); + } my ($output,$fullname, $printed)=&print_resources($r,$helper, $person,$type, \%moreenv,\@master_seq, @@ -1718,12 +1771,12 @@ ENDPART "cgi.$identifier.coursedom" => $cdom, "cgi.$identifier.resources" => $resources_printed); -$r->print(<print(< Continue - - +$end_page FINALEND } @@ -2200,7 +2253,13 @@ ALL_PROBLEMS PAGESIZE -


Number of assignments printed at the same time: +
How do you want assignments split into PDF files?
+ + All assignments in a single PDF file + Each PDF contains exactly one section + Each PDF contains exactly one assignment + Specify Number: + "all" RESOURCE_SELECTOR @@ -2339,9 +2398,15 @@ CHOOSE_ANON1 Add three empty pages/column after each student\'s assignment - + PAGESIZE -
Number of assignments printed at the same time:
+
How do you want assignments split into PDF files?
+ + All assignments in a single PDF file + Each PDF contains exactly one section + Each PDF contains exactly one assignment + Specify Number: + "all"
RESOURCE_SELECTOR