--- loncom/interface/lonprintout.pm 2008/04/04 16:46:23 1.519.2.4
+++ loncom/interface/lonprintout.pm 2009/09/10 23:36:03 1.545.2.5
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.519.2.4 2008/04/04 16:46:23 raeburn Exp $
+# $Id: lonprintout.pm,v 1.545.2.5 2009/09/10 23:36:03 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -37,8 +37,9 @@ use Apache::grades;
use Apache::edit;
use Apache::File();
use Apache::lonnavmaps;
-use Apache::admannotations;
use Apache::lonenc;
+use Apache::entities;
+
use HTTP::Response;
use LONCAPA::map();
@@ -95,8 +96,7 @@ sub fetch_raw_resource {
sub annotate {
my ($symb) = @_;
- my $annotation_text = &Apache::admannotations::get_annotation($symb, 1);
-
+ my $annotation_text = &Apache::loncommon::get_annotation($symb, 1);
my $result = "";
@@ -150,7 +150,7 @@ sub ssi_with_retries {
$ssi_error = 1;
$ssi_last_error_resource = $resource;
$ssi_last_error = $response->code . " " . $response->message;
- $content='\section*{!!! An error occurred !!!}';
+ $content='\section*{!!! An error occurred !!!}';
&Apache::lonnet::logthis("Error in SSI resource: $resource Error: $ssi_last_error");
}
@@ -160,6 +160,7 @@ sub ssi_with_retries {
sub get_student_view_with_retries {
my ($curresline,$retries,$username,$userdomain,$courseid,$target,$moreenv)=@_;
+
my ($content, $response) = &Apache::loncommon::get_student_view_with_retries($curresline,$retries,$username,$userdomain,$courseid,$target,$moreenv);
if (!$response->is_success) {
$ssi_error = 1;
@@ -169,6 +170,7 @@ sub get_student_view_with_retries {
&Apache::lonnet::logthis("Error in SSI (student view) resource: $curresline Error: $ssi_last_error User: $username:$userdomain");
}
return $content;
+
}
#
@@ -244,37 +246,42 @@ 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);
- }
- $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!!!
+ 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);
+ }
+ $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!!!
+ }
+
+ # 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/;
}
@@ -381,8 +388,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()
+ );
}
}
@@ -1487,10 +1534,10 @@ ENDPART
}
if ($helper->{'VARS'}->{'style_file'}=~/\w/) {
- &Apache::lonnet::appenv('construct.style' =>
- $helper->{'VARS'}->{'style_file'});
+ &Apache::lonnet::appenv({'construct.style' =>
+ $helper->{'VARS'}->{'style_file'}});
} elsif ($env{'construct.style'}) {
- &Apache::lonnet::delenv('construct\\.style');
+ &Apache::lonnet::delenv('construct.style');
}
@@ -1531,7 +1578,7 @@ ENDPART
$rndseed=$helper->{'VARS'}->{'curseed'};
}
$form{'rndseed'}=$rndseed;
- &Apache::lonnet::appenv(%moreenv);
+ &Apache::lonnet::appenv(\%moreenv);
&Apache::lonxml::clear_problem_counter();
@@ -1645,7 +1692,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
@@ -1653,7 +1701,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;
@@ -1679,7 +1728,8 @@ ENDPART
my $pbreakresources = keys %page_breaks;
for (my $i=0;$i<=$#master_seq;$i++) {
- &Apache::lonenc::reset_enc();
+ &Apache::lonenc::reset_enc();
+
# Note due to document structure, not allowed to put \newpage
# prior to the first resource
@@ -1689,10 +1739,11 @@ ENDPART
$result.="\\newpage\n";
}
}
- my ($sequence,$middle_thingy,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]);
+ my ($sequence,$middle_thingy,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]);
$urlp=&Apache::lonnet::clutter($urlp);
$form{'symb'}=$master_seq[$i];
+
my $assignment=&Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header'); #title of the assignment which contains this problem
if ($selectionmade==7) {$helper->{VARS}->{'assignment'}=$assignment;}
@@ -1806,12 +1857,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') {
@@ -1908,9 +1961,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 (
'.&mt('If the error persists, please contact the [_1] for assistance.',$helpurl).'
'. &mt('We apologize for the inconvenience.').'
'. - ''.&mt('Continue').''.$end_page); + ''.$continue_text.''.$end_page); } else { $r->print(<". - ': | ");
+ &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'); @@ -3092,7 +3175,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'; @@ -3123,10 +3208,13 @@ CHOOSE_FROM_ANY_SEQUENCE } Apache::lonhelper::dropdown->new(); - addMessage(" |
". - ': | "); + &addMessage(&Apache::lonhtmlcommon::row_closure() + .&Apache::lonhtmlcommon::row_title( + '' + ) + ); $paramHash = Apache::lonhelper::getParamHash(); $paramHash->{'variable'} = 'TABLE_CONTENTS'; $helper->declareVar('TABLE_CONTENTS'); @@ -3134,13 +3222,15 @@ CHOOSE_FROM_ANY_SEQUENCE ['No', 'no'], ['Yes', 'yes'] ]; Apache::lonhelper::dropdown->new(); - addMessage(" |
". - ': | "); + &addMessage(&Apache::lonhtmlcommon::row_title( + '' + ) + ); $paramHash = Apache::lonhelper::getParamHash(); $paramHash->{'variable'} = 'TABLE_INDEX'; $helper->declareVar('TABLE_INDEX'); @@ -3148,11 +3238,13 @@ CHOOSE_FROM_ANY_SEQUENCE ['No', 'no'], ['Yes', 'yes'] ]; Apache::lonhelper::dropdown->new(); - addMessage(" |
". - ': | "); + &addMessage(&Apache::lonhtmlcommon::row_closure()); + &addMessage(&Apache::lonhtmlcommon::row_title( + '' + ) + ); $paramHash = Apache::lonhelper::getParamHash(); $paramHash->{'variable'} = 'PRINT_DISCUSSIONS'; $helper->declareVar('PRINT_DISCUSSIONS'); @@ -3160,14 +3252,16 @@ CHOOSE_FROM_ANY_SEQUENCE ['No', 'no'], ['Yes', 'yes'] ]; Apache::lonhelper::dropdown->new(); - addMessage(" |
". - ': | "); + &addMessage(&Apache::lonhtmlcommon::row_title( + '' + ) + ); $paramHash = Apache::lonhelper::getParamHash(); $paramHash->{'variable'} = "PRINT_ANNOTATIONS"; $helper->declareVar("PRINT_ANNOTATIONS"); @@ -3175,16 +3269,16 @@ CHOOSE_FROM_ANY_SEQUENCE ['No', 'no'], ['Yes', 'yes']]; Apache::lonhelper::dropdown->new(); - addMessage(" |
"); + &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 .= ' |
+ | |
Problem Type: | "); + &addMessage(&Apache::lonhtmlcommon::row_title(&mt('Problem Type'))); # # Initial value from construction space: # @@ -3237,16 +3343,16 @@ RNDSEED PROBTYPE &Apache::lonxml::xmlparse($r, 'helper', $xmlfrag); - addMessage(" |
$PageLayout | -$NumberOfColumns | -$PaperType | -
- - - |
- - |