--- loncom/interface/lonprintout.pm 2004/08/19 20:02:21 1.328
+++ loncom/interface/lonprintout.pm 2004/11/13 09:30:26 1.337
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.328 2004/08/19 20:02:21 albertel Exp $
+# $Id: lonprintout.pm,v 1.337 2004/11/13 09:30:26 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -41,10 +41,7 @@ use Apache::lonnavmaps;
use Apache::lonratedt;
use POSIX qw(strftime);
use Apache::lonlocal;
-use GDBM_File;
-
-my %hash;
my $LaTeXwidth = 0;
@@ -229,7 +226,7 @@ sub character_chart {
$result =~ s/&(\#219|Ucirc);/\\^{U}/g;
$result =~ s/&(\#220|Uuml);/\\\"{U}/g;
$result =~ s/&(\#221|Yacute);/\\\'{Y}/g;
- $result =~ s/&(\#223|szlig);/\\ss/g;
+ $result =~ s/&(\#223|szlig);/{\\ss}/g;
$result =~ s/&(\#224|agrave);/\\\`{a}/g;
$result =~ s/&(\#225|aacute);/\\\'{a}/g;
$result =~ s/&(\#226|acirc);/\\^{a}/g;
@@ -519,10 +516,10 @@ sub page_format_transformation {
$fancypagestatement="\\rhead{}\\chead{}\\lhead{\\textbf{$name} $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}";
}
if ($layout eq 'album') {
- $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}$topmargintoinsert\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\usepackage{fancyhdr}\\pagestyle{fancy}$fancypagestatement\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1} /;
+ $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}$topmargintoinsert\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\usepackage{fancyhdr}\\addtolength{\\headheight}{\\baselineskip}\\pagestyle{fancy}$fancypagestatement\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1} /;
} elsif ($layout eq 'book') {
if ($choice ne 'All class print') {
- $text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset $topmargintoinsert\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\usepackage{fancyhdr}\\pagestyle{fancy}$fancypagestatement\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}/;
+ $text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset $topmargintoinsert\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\usepackage{fancyhdr}\\addtolength{\\headheight}{\\baselineskip}\\pagestyle{fancy}$fancypagestatement\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}/;
} else {
$text =~ s/\\pagestyle{fancy}\\rhead{}\\chead{}\s*\\begin{document}/\\textheight = $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset $topmargintoinsert\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\begin{document}\\voffset=-0\.8cm\\setcounter{page}{1} \\vskip 5 mm /;
}
@@ -554,9 +551,11 @@ sub page_cleanup {
sub details_for_menu {
-
- my $name_of_resourse = &Apache::lonnet::gettitle($ENV{'form.postdata'});
- my $symbolic = &Apache::lonnet::symbread($ENV{'form.postdata'});
+ my ($helper)=@_;
+ my $postdata=$ENV{'form.postdata'};
+ if (!$postdata) { $postdata=$helper->{VARS}{'postdata'}; }
+ my $name_of_resource = &Apache::lonnet::gettitle($postdata);
+ my $symbolic = &Apache::lonnet::symbread($postdata);
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($symbolic);
$map=&Apache::lonnet::clutter($map);
my $name_of_sequence = &Apache::lonnet::gettitle($map);
@@ -569,8 +568,7 @@ sub details_for_menu {
$ENV{'request.course.uri'} =~ m|([^/]+)$|;
$name_of_map = $1;
}
- return ($name_of_resourse,$name_of_sequence,$name_of_map);
-
+ return ($name_of_resource,$name_of_sequence,$name_of_map);
}
@@ -1015,7 +1013,7 @@ ENDPART
my $courseidinfo = &get_course();
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
$prevassignment=$assignment;
- $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip -5 mm ';
+ $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip 5 mm ';
}
$result .= $texversion;
$flag_latex_header_remove = 'YES';
@@ -1043,6 +1041,7 @@ ENDPART
$result .= $texversion;
$flag_latex_header_remove = 'YES';
}
+ if (&Apache::loncommon::connection_aborted($r)) { last; }
}
&Apache::lonnet::delenv('form.counter');
if ($flag_page_in_sequence eq 'YES') {$result =~ s/\\usepackage{calc}/\\usepackage{calc}\\usepackage{longtable}/;}
@@ -1067,6 +1066,7 @@ ENDPART
#loop over students
my $flag_latex_header_remove = 'NO';
my %moreenv;
+ $moreenv{'instructor_comments'}='hide';
$moreenv{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
$moreenv{'print_discussions'}=$helper->{'VARS'}->{'PRINT_DISCUSSIONS'};
if ($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') {$moreenv{'problem_split'}='yes';}
@@ -1085,6 +1085,7 @@ ENDPART
$student_names[$i].=$person.':'.$fullname.'_END_';
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,&mt('last student').' '.$fullname);
$flag_latex_header_remove = 'YES';
+ if (&Apache::loncommon::connection_aborted($r)) { last; }
}
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
$result .= $print_array[0].' \end{document}';
@@ -1095,20 +1096,13 @@ ENDPART
my $num_todo=$helper->{'VARS'}->{'NUMBER_TO_PRINT_TOTAL'};
my $code_name=$helper->{'VARS'}->{'ANON_CODE_STORAGE_NAME'};
my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'};
- my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
- my ($type) = split(/_/,$helper->{'VARS'}->{'PRINT_TYPE'});
- my $number_per_page=$helper->{'VARS'}->{'NUMBER_TO_PRINT'};
- if ($number_per_page eq '0' || $number_per_page eq 'all') {
- $number_per_page=$num_todo;
- }
- my $flag_latex_header_remove = 'NO';
my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth));
- my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$num_todo,'inline','75');
my $seed=time+($$<<16)+($$);
my @allcodes;
if ($old_name) {
my %result=&Apache::lonnet::get('CODEs',[$old_name],$cdom,$cnum);
@allcodes=split(',',$result{$old_name});
+ $num_todo=scalar(@allcodes);
} else {
my %allcodes;
srand($seed);
@@ -1122,6 +1116,14 @@ ENDPART
}
@allcodes=keys(%allcodes);
}
+ my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
+ my ($type) = split(/_/,$helper->{'VARS'}->{'PRINT_TYPE'});
+ my $number_per_page=$helper->{'VARS'}->{'NUMBER_TO_PRINT'};
+ if ($number_per_page eq '0' || $number_per_page eq 'all') {
+ $number_per_page=$num_todo;
+ }
+ my $flag_latex_header_remove = 'NO';
+ my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$num_todo,'inline','75');
my $count=0;
foreach my $code (sort(@allcodes)) {
my $file_num=int($count/$number_per_page);
@@ -1134,6 +1136,7 @@ ENDPART
&mt('last assignment').' '.$fullname);
$flag_latex_header_remove = 'YES';
$count++;
+ if (&Apache::loncommon::connection_aborted($r)) { last; }
}
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
$result .= $print_array[0].' \end{document}';
@@ -1355,10 +1358,9 @@ sub print_resources {
my $current_counter=$ENV{'form.counter'};
if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
- my %form;
- $form{'answer_output_mode'}='tex';
- $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
- my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,$ENV{'request.course.id'},%form);
+ $moreenv->{'answer_output_mode'}='tex';
+ $moreenv->{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
+ my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,$ENV{'request.course.id'},%{$moreenv});
&Apache::lonnet::appenv(('form.counter' => $current_counter));
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
$rendered=~s/(\\keephidden{ENDOFPROBLEM})/$ansrendered$1/;
@@ -1401,17 +1403,18 @@ sub print_resources {
}
$remove_latex_header = 'YES';
}
+ if (&Apache::loncommon::connection_aborted($r)) { last; }
}
my $courseidinfo = &get_course();
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection}
my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header');
if ($current_output=~/\\documentclass/) {
- $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\lhead{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$currentassignment}$namepostfix}\\vskip 3 mm /;
+ $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\lhead{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$currentassignment}$namepostfix}}\\vskip 5 mm /;
} else {
my $blankpages = '';
for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blankpages.='\clearpage\strut\clearpage';}
- $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}'.$namepostfix.'}} \vskip -5 mm '.$current_output;
+ $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}'.$namepostfix.'}} \vskip 5 mm '.$current_output;
}
return ($current_output,$fullname);
@@ -1470,11 +1473,6 @@ use Data::Dumper;
sub printHelper {
my $r = shift;
- if ($ENV{'request.course.id'}) {
- my $fn=$ENV{'request.course.fn'};
- tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640);
- }
-
if ($r->header_only) {
if ($ENV{'browser.mathml'}) {
&Apache::loncommon::content_type($r,'text/xml');
@@ -1536,7 +1534,7 @@ sub printHelper {
}
- my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu;
+ my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu($helper);
if ($sequenceTitle ne '') {$helper->{VARS}->{'assignment'}=$sequenceTitle;}
@@ -1705,7 +1703,7 @@ CHOOSE_STUDENTS
my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
my @names=&Apache::lonnet::getkeys('CODEs',$cdom,$cnum);
my $namechoice='';
- foreach my $name (@names) {
+ foreach my $name (sort {uc($a) cmp uc($b)} @names) {
if ($name =~ /^error: 2 /) { next; }
$namechoice.=''.$name.'';
}
@@ -1959,9 +1957,7 @@ RNDSEED
$r->print($helper->display());
- Apache::lonhelper::unregisterHelperTags();
-
- untie %hash;
+ &Apache::lonhelper::unregisterHelperTags();
return OK;
}