[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
foxr
lon-capa-cvs@mail.lon-capa.org
Tue, 14 Mar 2006 23:24:47 -0000
foxr Tue Mar 14 18:24:47 2006 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
Last part of Enh. req. 3809
Support selection of number of assignments per printout
with radio button including 1 section per file.
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.428 loncom/interface/lonprintout.pm:1.429
--- loncom/interface/lonprintout.pm:1.428 Wed Mar 8 17:32:11 2006
+++ loncom/interface/lonprintout.pm Tue Mar 14 18:24:46 2006
@@ -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.429 2006/03/14 23:24:46 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -41,6 +41,7 @@
use Apache::lonratedt;
use POSIX qw(strftime);
use Apache::lonlocal;
+use Carp;
my %perm;
@@ -238,7 +239,34 @@
}
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'
+# <unchanged> - 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;
@@ -1407,14 +1435,28 @@
# 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 +1470,8 @@
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 ($junku, $junkd, $last_section) = split /:/,$students[0];
foreach my $person (@students) {
my $duefile="/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.due";
@@ -1436,7 +1480,16 @@
print $temp_file "1969\n";
}
$student_counter++;
- my $i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'});
+ if ($split_on_sections) {
+ my $this_section;
+ ($junku, $junkd, $this_section) = split /:/,$person;
+ 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,
@@ -2200,7 +2253,13 @@
</state>
<state name="NUMBER_PER_PDF" title="Number printed at once">
<nextstate>PAGESIZE</nextstate>
- <message><hr width='33%' /><b>Number of assignments printed at the same time: </b></message>
+ <message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message>
+ <choices variable="SPLIT_PDFS">
+ <choice computer="all">All assignments in a single PDF file</choice>
+ <choice computer="sections">Each PDF contains exactly one section</choice>
+ <choice computer="oneper">Each PDF contains exactly one assignment</choice>
+ <choice computer="usenumber">Specify Number:</choice>
+ </choices>
<string variable="NUMBER_TO_PRINT" maxlength="5" size="5"><defaultvalue>"all"</defaultvalue></string>
</state>
RESOURCE_SELECTOR
@@ -2339,9 +2398,15 @@
<choice computer='3'>Add three empty pages/column after each student\'s assignment</choice>
</choices>
</state>
- <state name="NUMBER_PER_PDF title="Number assingnments per pdf">
+ <state name="NUMBER_PER_PDF" title="Number assignments per pdf">
<nextstate>PAGESIZE</nextstate>
- <message><hr width='33%' /><b>Number of assignments printed at the same time: </b></message>
+ <message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message>
+ <choices variable="SPLIT_PDFS">
+ <choice computer="all">All assignments in a single PDF file</choice>
+ <choice computer="sections">Each PDF contains exactly one section</choice>
+ <choice computer="oneper">Each PDF contains exactly one assignment</choice>
+ <choice computer="usenumber">Specify Number:</choice>
+ </choices>
<string variable="NUMBER_TO_PRINT" maxlength="5" size="5"><defaultvalue>"all"</defaultvalue></string>
</state>
RESOURCE_SELECTOR