--- loncom/interface/lonprintout.pm 2008/04/04 16:38:34 1.529
+++ loncom/interface/lonprintout.pm 2009/01/23 16:00:46 1.548
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.529 2008/04/04 16:38:34 raeburn Exp $
+# $Id: lonprintout.pm,v 1.548 2009/01/23 16:00:46 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -39,6 +39,8 @@ use Apache::File();
use Apache::lonnavmaps;
use Apache::admannotations;
use Apache::lonenc;
+use Apache::entities;
+
use HTTP::Response;
use LONCAPA::map();
@@ -227,9 +229,11 @@ sub printf_style_subst {
# %a - Assignment name.
# %c - Course name.
# %n - Student name.
+# %s - The section if it is supplied.
#
sub format_page_header {
- my ($width, $format, $assignment, $course, $student) = @_;
+ my ($width, $format, $assignment, $course, $student, $section) = @_;
+
$width = &recalcto_mm($width); # Get width in mm.
# Default format?
@@ -246,38 +250,43 @@ sub format_page_header {
# - Allow the assignment to be 2 lines (wrapped).
#
my $chars_per_line = $width/2; # Character/textline.
+
- my $firstline = "$student $course";
- if (length($firstline) > $chars_per_line) {
- my $lastchar = $chars_per_line - length($student) - 1;
- if ($lastchar > 0) {
- $course = substr($course, 0, $lastchar);
- } else { # Nothing left of course:
- $course = '';
- }
- }
- if (length($assignment) > $chars_per_line) {
- $assignment = substr($assignment, 0, $chars_per_line);
+ my $name_length = int($chars_per_line *3 /4);
+ my $sec_length = int($chars_per_line / 5);
+
+ $format = "%$name_length".'n';
+
+ if ($section) {
+ $format .= ' - Sec: '."%$sec_length".'s';
}
-
- $format = "\\textbf{$student} $course \\hfill \\thepage \\\\ \\textit{$assignment}";
-
- } else {
- # An open question is how to handle long user formatted page headers...
- # A possible future is to support e.g. %na so that the user can control
- # the truncation of the elements that can appear in the header.
- #
- $format = &printf_style_subst("a", $format, $assignment);
- $format = &printf_style_subst("c", $format, $course);
- $format = &printf_style_subst("n", $format, $student);
-
- # If the user put %'s in the format string, they must be escaped
- # to \% else LaTeX will think they are comments and terminate
- # the line.. which is bad!!!
+ $format .= '\\\\%c \\\\ %a';
+
}
+ # An open question is how to handle long user formatted page headers...
+ # A possible future is to support e.g. %na so that the user can control
+ # the truncation of the elements that can appear in the header.
+ #
+ $format = &printf_style_subst("a", $format, $assignment);
+ $format = &printf_style_subst("c", $format, $course);
+ $format = &printf_style_subst("n", $format, $student);
+ $format = &printf_style_subst("s", $format, $section);
+
+
+ # If the user put %'s in the format string, they must be escaped
+ # to \% else LaTeX will think they are comments and terminate
+ # the line.. which is bad!!!
+
+ # If the user has role author, $course and $assignment are empty so
+ # there is '\\ \\ ' in the page header. That's cause a error in LaTeX
+ if($format =~ /\\\\\s\\\\\s/) {
+ #TODO find sensible caption for page header
+ my $testPrintout = '\\\\'.&mt('Construction Space').' \\\\'.&mt('Test-Printout ');
+ $format =~ s/\\\\\s\\\\\s/$testPrintout/;
+ }
return $format;
@@ -383,8 +392,8 @@ sub is_valid_alpha_code {
sub is_code_valid {
my ($code_value, $code_option) = @_;
my ($code_type, $code_length) = ('letter', 6); # defaults.
- open(FG, $Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
- foreach my $line (
';
+ my $ext_text = 'pdf' ? &mt('PDF File'):&mt('Zip File');
+ my $result=&Apache::loncommon::start_data_table_row()
+ .''
+ .''.$ext_text.''
+ .' '
+ .''.&Apache::lonlocal::locallocaltime($cctime).' '
+ .''.$csize.' '
+ .&Apache::loncommon::end_data_table_row();
if ($ext eq 'pdf') { $pdf_result .= $result; }
if ($ext eq 'zip') { $zip_result .= $result; }
}
+ if ($zip_result || $pdf_result) {
+ $r->print('
');
+ }
if ($zip_result) {
- $r->print(''.&mt('Recently generated printout zip files')."
\n"
- .$zip_result);
+ $r->print(''.&mt('Recently generated printout zip files')."
\n"
+ .&Apache::loncommon::start_data_table()
+ .&Apache::loncommon::start_data_table_header_row()
+ .''.&mt('Download').' '
+ .''.&mt('Creation Date').' '
+ .''.&mt('File Size (Bytes)').' '
+ .&Apache::loncommon::end_data_table_header_row()
+ .$zip_result
+ .&Apache::loncommon::end_data_table()
+ );
}
if ($pdf_result) {
- $r->print(''.&mt('Recently generated printouts')."
\n"
- .$pdf_result);
+ $r->print(''.&mt('Recently generated printouts')."
\n"
+ .&Apache::loncommon::start_data_table()
+ .&Apache::loncommon::start_data_table_header_row()
+ .''.&mt('Download').' '
+ .''.&mt('Creation Date').' '
+ .''.&mt('File Size (Bytes)').' '
+ .&Apache::loncommon::end_data_table_header_row()
+ .$pdf_result
+ .&Apache::loncommon::end_data_table()
+ );
}
}
@@ -1460,7 +1505,7 @@ ENDPART
my ($result,$selectionmade) = ('','');
my $number_of_columns = 1; #used only for pages to determine the width of the cell
my @temporary_array=split /\|/,$format_from_helper;
- my ($laystyle,$numberofcolumns,$papersize)=@temporary_array;
+ my ($laystyle,$numberofcolumns,$papersize,$pdfFormFields)=@temporary_array;
if ($laystyle eq 'L') {
$laystyle='album';
} else {
@@ -1481,6 +1526,7 @@ ENDPART
my %form;
$form{'grade_target'} = 'tex';
$form{'textwidth'} = &get_textwidth($helper, $LaTeXwidth);
+ $form{'pdfFormFields'} = $pdfFormFields;
# If form.showallfoils is set, then request all foils be shown:
# privilege will be enforced both by not allowing the
@@ -1652,7 +1698,8 @@ ENDPART
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') or
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_resources') or # BUGBUG
- ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences')) {
+ ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences')
+ ) {
#-- produce an output string
@@ -1660,7 +1707,8 @@ ENDPART
$selectionmade = 2;
} elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') {
$selectionmade = 3;
- } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') {
+ } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems')
+ ) {
$selectionmade = 4;
} elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_resources') { #BUGBUG
$selectionmade = 4;
@@ -1764,7 +1812,6 @@ ENDPART
if (($selectionmade == 4) and ($assignment ne $prevassignment)) {
my $name = &get_name();
my $courseidinfo = &get_course();
- if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
$prevassignment=$assignment;
my $header_text = $parmhash{'print_header_format'};
$header_text = &format_page_header($textwidth, $header_text,
@@ -1815,12 +1862,14 @@ ENDPART
}
$result .= '\end{document}';
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') ||
+ ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems_students') ||
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_students')){
#-- prints assignments for whole class or for selected students
my $type;
- if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') {
+ if (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') ||
+ ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems_students') ) {
$selectionmade=5;
$type='problems';
} elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_students') {
@@ -1917,9 +1966,9 @@ ENDPART
my $selected_code = $helper->{'VARS'}->{'CODE_SELECTED_FROM_LIST'};
my $code_option=$helper->{'VARS'}->{'CODE_OPTION'};
- open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
+ my @lines = &Apache::grades::get_scantronformat_file();
my ($code_type,$code_length)=('letter',6);
- foreach my $line (
");
+ &addMessage(&Apache::lonhtmlcommon::end_pick_box());
}
Apache::lonprintout::page_format_state->new("FORMAT");
@@ -3350,23 +3454,25 @@ sub render {
my $PaperType=&mt('Paper type');
my $landscape=&mt('Landscape');
my $portrait=&mt('Portrait');
- $result .= < ");
+ &addMessage(&Apache::lonhtmlcommon::row_closure());
$startedTable = 1;
}
@@ -3109,10 +3190,12 @@ CHOOSE_FROM_ANY_SEQUENCE
": ".
- ': ");
+ &addMessage('
'
+ .''.&mt('Print Options').'
'
+ .&Apache::lonhtmlcommon::start_pick_box()
+# .&Apache::lonhtmlcommon::row_headline()
+# .''.&mt('Print Options').'
'
+# .&Apache::lonhtmlcommon::row_closure()
+ .&Apache::lonhtmlcommon::row_title(
+ ''
+ )
+ );
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{'variable'} = 'ANSWER_TYPE';
$helper->declareVar('ANSWER_TYPE');
@@ -3097,7 +3178,7 @@ CHOOSE_FROM_ANY_SEQUENCE
['Only Answers', 'only']
];
Apache::lonhelper::dropdown->new();
- addMessage("");
$startedTable = 1;
} else {
- addMessage(" ".
- ': ");
+ &addMessage(&Apache::lonhtmlcommon::row_title(
+ ''
+ )
+ );
}
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{'variable'} = 'LATEX_TYPE';
@@ -3128,10 +3211,13 @@ CHOOSE_FROM_ANY_SEQUENCE
}
Apache::lonhelper::dropdown->new();
- addMessage(" ");
+ &addMessage(&Apache::lonhtmlcommon::row_closure());
if (not $helper->{VARS}->{'construction'}) {
- addMessage("".
- ': ");
+ &addMessage(&Apache::lonhtmlcommon::row_closure()
+ .&Apache::lonhtmlcommon::row_title(
+ ''
+ )
+ );
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{'variable'} = 'TABLE_CONTENTS';
$helper->declareVar('TABLE_CONTENTS');
@@ -3139,13 +3225,15 @@ CHOOSE_FROM_ANY_SEQUENCE
['No', 'no'],
['Yes', 'yes'] ];
Apache::lonhelper::dropdown->new();
- addMessage(" ");
- addMessage("".
- ': ");
+ &addMessage(&Apache::lonhtmlcommon::row_title(
+ ''
+ )
+ );
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{'variable'} = 'TABLE_INDEX';
$helper->declareVar('TABLE_INDEX');
@@ -3153,11 +3241,13 @@ CHOOSE_FROM_ANY_SEQUENCE
['No', 'no'],
['Yes', 'yes'] ];
Apache::lonhelper::dropdown->new();
- addMessage(" ");
+ &addMessage(&Apache::lonhtmlcommon::row_closure());
# Prompt for printing annotations too.
- addMessage("".
- ': ");
+ &addMessage(&Apache::lonhtmlcommon::row_closure());
+ &addMessage(&Apache::lonhtmlcommon::row_title(
+ ''
+ )
+ );
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{'variable'} = 'PRINT_DISCUSSIONS';
$helper->declareVar('PRINT_DISCUSSIONS');
@@ -3165,14 +3255,16 @@ CHOOSE_FROM_ANY_SEQUENCE
['No', 'no'],
['Yes', 'yes'] ];
Apache::lonhelper::dropdown->new();
- addMessage(" ");
+ &addMessage(&Apache::lonhtmlcommon::row_closure());
- addMessage("".
- ': ");
+ &addMessage(&Apache::lonhtmlcommon::row_title(
+ ''
+ )
+ );
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{'variable'} = "PRINT_ANNOTATIONS";
$helper->declareVar("PRINT_ANNOTATIONS");
@@ -3180,16 +3272,16 @@ CHOOSE_FROM_ANY_SEQUENCE
['No', 'no'],
['Yes', 'yes']];
Apache::lonhelper::dropdown->new();
- addMessage(" ");
+ &addMessage(&Apache::lonhtmlcommon::row_closure(1));
}
if ($helper->{'VARS'}->{'construction'}) {
@@ -3198,32 +3290,44 @@ CHOOSE_FROM_ANY_SEQUENCE
my $stylefiletext=&mt("Use style file");
my $selectfiletext=&mt("Select style file");
- my $xmlfrag .= <<"RNDSEED";
- ");
+ &addMessage(&Apache::lonhtmlcommon::row_title(&mt('Foils')));
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{'multichoice'} = "true";
$paramHash->{'allowempty'} = "true";
$paramHash->{'variable'} = "showallfoils";
$paramHash->{'CHOICES'} = [ ["Show all foils", "1"] ];
Apache::lonhelper::choices->new();
- addMessage("
- :
-
-
- :
-
+ my $xmlfrag .= '
+ ");
+ &addMessage(&Apache::lonhtmlcommon::row_closure(1));
- }
+ }
}
if ($startedTable) {
- addMessage("Problem Type: ");
+ &addMessage(&Apache::lonhtmlcommon::row_title(&mt('Problem Type')));
#
# Initial value from construction space:
#
@@ -3242,16 +3346,16 @@ RNDSEED
PROBTYPE
&Apache::lonxml::xmlparse($r, 'helper', $xmlfrag);
- addMessage(" '.$PageLayout.' '
+ .''.$NumberOfColumns.' '
+ .''.$PaperType.' '
+ .''.$pdfFormLabel.' '
+ .&Apache::loncommon::end_data_table_header_row()
+ .&Apache::loncommon::start_data_table_row()
+ .''
+ .' ';
-
'
+ .''
+ .'
-
-
";
+ $result .= <
+
+
-
- $PageLayout
- $NumberOfColumns
- $PaperType
-
-
-
-
-
-
-
+
+HTML
+ $result.=&Apache::loncommon::end_data_table_row()
+ .&Apache::loncommon::end_data_table();
+
return $result;
}
@@ -3406,7 +3524,7 @@ sub postprocess {
my $helper = Apache::lonhelper->getHelper();
$helper->{VARS}->{$var} =
$env{"form.$var.layout"} . '|' . $env{"form.$var.cols"} . '|' .
- $env{"form.$var.paper"};
+ $env{"form.$var.paper"} . '|' . $env{"form.$var.pdfFormFields"};
return 1;
}
@@ -3518,50 +3636,36 @@ sub render {
} else {
$size{'margin'} += 2.54;
}
- my %text = ('format' => 'How should each column be formatted?',
- 'width' => 'Width:',
- 'height' => 'Height:',
- 'margin' => 'Left Margin:',);
- %text = &Apache::lonlocal::texthash(%text);
-
- $result .= <
$text{'width'} | -- |
- |
-
$text{'height'} | -- |
- |
-
$text{'margin'} | -- |
- |
-
'.$lt{'format'}.'
' + .&Apache::lonhtmlcommon::start_pick_box() + .&Apache::lonhtmlcommon::row_title($lt{'width'}) + .'' + .'Hint: Some instructors like to leave scratch space for the student by + # making the width much smaller than the width of the page.
return $result; }