--- loncom/interface/lonprintout.pm 2010/07/13 00:16:28 1.582
+++ loncom/interface/lonprintout.pm 2011/03/11 05:01:36 1.586
@@ -2,7 +2,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.582 2010/07/13 00:16:28 raeburn Exp $
+# $Id: lonprintout.pm,v 1.586 2011/03/11 05:01:36 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -256,6 +256,37 @@ CHOOSE_ANON1
return $result;
}
+sub generate_format_selector {
+ my ($helper,$title,$nextstate) = @_;
+ my $secpdfoption;
+ unless (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon') ||
+ ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon_page') ||
+ ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon') ) {
+ $secpdfoption = 'Each PDF contains exactly one section';
+ }
+ return <
+ $nextstate
+
How should the results be printed?
+
+ Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)
+ Add one empty page/column after each student\'s assignment
+ Add two empty pages/column after each student\'s assignment
+ Add three empty pages/column after each student\'s assignment
+
+ PAGESIZE
+
How do you want assignments split into PDF files?
+
+ All assignments in a single PDF file
+ $secpdfoption
+ Each PDF contains exactly one assignment
+
+ Specify the number of assignments per PDF:
+
+
+RESOURCE_SELECTOR
+}
+
#-----------------------------------------------------------------------
@@ -1707,8 +1738,8 @@ sub print_page_in_course {
# List of recently generated print files
#
sub recently_generated {
- my $r=shift;
- my $prtspool=$r->dir_config('lonPrtDir');
+ my ($prtspool) = @_;
+ my $output;
my $zip_result;
my $pdf_result;
opendir(DIR,$prtspool);
@@ -1741,10 +1772,10 @@ sub recently_generated {
if ($ext eq 'zip') { $zip_result .= $result; }
}
if ($zip_result || $pdf_result) {
- $r->print('
');
+ $output ='
';
}
if ($zip_result) {
- $r->print(''.&mt('Recently generated printout zip files')."
\n"
+ $output .=''.&mt('Recently generated printout zip files')."
\n"
.&Apache::loncommon::start_data_table()
.&Apache::loncommon::start_data_table_header_row()
.''.&mt('Download').' | '
@@ -1752,11 +1783,10 @@ sub recently_generated {
.''.&mt('File Size (Bytes)').' | '
.&Apache::loncommon::end_data_table_header_row()
.$zip_result
- .&Apache::loncommon::end_data_table()
- );
+ .&Apache::loncommon::end_data_table();
}
if ($pdf_result) {
- $r->print(''.&mt('Recently generated printouts')."
\n"
+ $output .=''.&mt('Recently generated printouts')."
\n"
.&Apache::loncommon::start_data_table()
.&Apache::loncommon::start_data_table_header_row()
.''.&mt('Download').' | '
@@ -1764,9 +1794,9 @@ sub recently_generated {
.''.&mt('File Size (Bytes)').' | '
.&Apache::loncommon::end_data_table_header_row()
.$pdf_result
- .&Apache::loncommon::end_data_table()
- );
+ .&Apache::loncommon::end_data_table();
}
+ return $output;
}
#
@@ -3077,7 +3107,9 @@ sub print_resources {
if (&Apache::loncommon::connection_aborted($r)) { last; }
}
-
+ if ($syllabus_first) {
+ $current_output =~ s/\\\\ Last updated:/Last updated:/
+ }
my $courseidinfo = &get_course();
my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header');
my $header_line =
@@ -3086,11 +3118,8 @@ sub print_resources {
my $header_start = ($columns_in_format == 1) ? '\lhead'
: '\fancyhead[LO]';
$header_line = $header_start.'{'.$header_line.'}';
- if ($current_output=~/\\documentclass/ && (!$syllabus_first)) {
+ if ($current_output=~/\\documentclass/) {
$current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$header_line$namepostfix}\\vskip 5 mm /;
- } elsif ($syllabus_first) {
-
- $current_output =~ s/\\\\ Last updated:/Last updated:/
} else {
my $blankpages =
'\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'};
@@ -3163,6 +3192,11 @@ sub init_perm {
$perm{'pfo'}=&Apache::lonnet::allowed('pfo',
$env{'request.course.id'}.'/'.$env{'request.course.sec'});
}
+ $perm{'vgr'}=&Apache::lonnet::allowed('vgr',$env{'request.course.id'});
+ if (!$perm{'vgr'}) {
+ $perm{'vgr'}=&Apache::lonnet::allowed('vgr',
+ $env{'request.course.id'}.'/'.$env{'request.course.sec'});
+ }
}
sub get_randomly_ordered_warning {
@@ -3575,27 +3609,15 @@ ALL_PROBLEMS
$map,
$isProblem, '', $symbFilter,
$start_new_option);
- $resource_selector .= <
-
How should the results be printed?
-
- Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)
- Add one empty page/column after each student\'s assignment
- Add two empty pages/column after each student\'s assignment
- Add three empty pages/column after each student\'s assignment
-
- PAGESIZE
-
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 the number of assignments per PDF:
-
-
-RESOURCE_SELECTOR
- $resource_selector .= &generate_resource_chooser('CHOOSE_STUDENTS_PAGE',
+ my $secpdfoption;
+ unless (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon') ||
+ ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon_page') ||
+ ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon') ) {
+ $secpdfoption = 'Each PDF contains exactly one section';
+ }
+ $resource_selector .= &generate_format_selector($helper,
+ 'How should results be printed?').
+ &generate_resource_chooser('CHOOSE_STUDENTS_PAGE',
'Select Problem(s) to print',
"multichoice='1' addstatus='1' closeallpages ='1'",
'RESOURCES',
@@ -3723,28 +3745,12 @@ RESOURCE_SELECTOR
$start_new_option
-
-
- 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)
- Add one empty page/column after each student\'s assignment
- Add two empty pages/column after each student\'s assignment
- Add three empty pages/column after each student\'s assignment
-
- PAGESIZE
-
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 the number of assignments per PDF:
-
-
RESOURCE_SELECTOR
+ my $nextstate = 'NUMBER_PER_PDF';
+ $resource_selector .= &generate_format_selector($helper,
+ 'Format of the print job',
+ $nextstate);
&Apache::lonxml::xmlparse($r, 'helper', <
@@ -3902,7 +3908,7 @@ CHOOSE_FROM_ANY_SEQUENCE
my $startedTable = 0; # have we started an HTML table yet? (need
# to close it later)
- if (($perm{'pav'} and &Apache::lonnet::allowed('vgr',$env{'request.course.id'})) or
+ if (($perm{'pav'} and $perm{'vgr'}) or
($helper->{VARS}->{'construction'} eq '1')) {
&addMessage('
'
.''.&mt('Print Options').'
'
@@ -4149,10 +4155,12 @@ PROBTYPE
return $helper;
}
- $r->print($helper->display());
+ my $footer;
if ($helper->{STATE} eq 'START') {
- &recently_generated($r);
+ my $prtspool=$r->dir_config('lonPrtDir');
+ $footer = &recently_generated($prtspool);
}
+ $r->print($helper->display($footer));
&Apache::lonhelper::unregisterHelperTags();
return OK;