--- loncom/interface/lonprintout.pm 2006/03/08 22:32:11 1.428 +++ loncom/interface/lonprintout.pm 2006/04/18 10:03:45 1.437 @@ -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.437 2006/04/18 10:03:45 foxr 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; @@ -994,12 +1022,8 @@ sub output_data { my ($r,$helper,$rparmhash) = @_; my %parmhash = %$rparmhash; my $resources_printed = ''; - my $html=&Apache::lonxml::xmlbegin(); - my $bodytag=&Apache::loncommon::bodytag('Preparing Printout'); - $r->print(< - -LON-CAPA output for printing - -$bodytag -

-Please stand by while processing your print request, this may take some time ... -

ENDPART + my $start_page = &Apache::loncommon::start_page('Preparing Printout',$js); + my $msg = &mt('Please stand by while processing your print request, this may take some time ...'); + $r->print($start_page."\n

\n$msg\n

\n"); # fetch the pagebreaks and store them in the course environment # The page breaks will be pulled into the hash %page_breaks which is @@ -1098,6 +1119,8 @@ ENDPART $selectionmade = 1; if ($cleanURL!~m|^/adm/| && $cleanURL=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { + if ($cleanURL =~/\.page/) { + } my $rndseed=time; my $texversion=''; if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') { @@ -1298,6 +1321,8 @@ ENDPART my $texversion=''; if ($urlp!~m|^/adm/| && $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { + if ($urlp =!/\.page/) { + } $resources_printed .= $urlp.':'; &Apache::lonxml::remember_problem_counter(); @@ -1407,14 +1432,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 +1467,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 +1477,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 +1767,12 @@ ENDPART "cgi.$identifier.coursedom" => $cdom, "cgi.$identifier.resources" => $resources_printed); -$r->print(<print(< Continue - - +$end_page FINALEND } @@ -1779,6 +1828,8 @@ sub print_resources { if (&Apache::lonnet::allowed('bre',$res_url)) { if ($res_url!~m|^ext/| && $res_url=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { + if ($res_url =~ /\.page/) { + } $printed .= $curresline.':'; &Apache::lonxml::remember_problem_counter(); @@ -2189,7 +2240,6 @@ ALL_PROBLEMS - NUMBER_PER_PDF
How should the results be printed?
Start each student\'s assignment on a new page/column (add a pagefeed after each assignment) @@ -2197,11 +2247,15 @@ ALL_PROBLEMS Add two empty pages/column after each student\'s assignment Add three empty pages/column after each student\'s assignment -
- PAGESIZE -
Number of assignments printed at the same time:
- "all" +
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: +
RESOURCE_SELECTOR @@ -2212,6 +2266,7 @@ RESOURCE_SELECTOR Sort by section then student Sort by students across sections. +


$resource_selector @@ -2243,8 +2298,17 @@ CHOOSE_STUDENTS if ($code =~ /^[A-Z]+$/) { # Alpha code $choice = &letters_to_num($code); } - $code_selection .= ' '.$code."\n"; + push(@{$helper->{DATA}{ALL_CODE_CHOICES}},[$code,$choice]); + } + if (%codes_to_print) { + $code_selection .=' + + push(@{$state->{CHOICES}},@{$helper->{DATA}{ALL_CODE_CHOICES}}); + + '.$/; } + + open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab'); my $codechoice=''; foreach my $line () { @@ -2299,6 +2363,12 @@ CHOOSE_STUDENTS
+ Choose single code from list + + + $code_selection + +
Reprint a set of saved CODEs: @@ -2338,11 +2408,15 @@ CHOOSE_ANON1 Add two empty pages/column after each student\'s assignment Add three empty pages/column after each student\'s assignment - - PAGESIZE -
Number of assignments printed at the same time:
- "all" +
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: +
RESOURCE_SELECTOR @@ -2352,6 +2426,7 @@ RESOURCE_SELECTOR Sort by section then student Sort by students across sections. +


@@ -2399,6 +2474,12 @@ CHOOSE_STUDENTS1
+ Choose single code from list + + + $code_selection + +
Reprint a set of saved CODEs: