--- loncom/interface/lonprintout.pm 2005/08/29 10:06:52 1.389
+++ loncom/interface/lonprintout.pm 2005/10/30 02:24:34 1.395
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.389 2005/08/29 10:06:52 foxr Exp $
+# $Id: lonprintout.pm,v 1.395 2005/10/30 02:24:34 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -42,8 +42,6 @@ use Apache::lonratedt;
use POSIX qw(strftime);
use Apache::lonlocal;
-my $resources_printed = '';
-
#
# Convert a numeric code to letters
#
@@ -508,6 +506,7 @@ sub character_chart {
$result =~ s/&(prod|\#8719);/\\ensuremath\{\\prod\}/g;
$result =~ s/&(sum|\#8721);/\\ensuremath\{\\sum\}/g;
$result =~ s/&(minus|\#8722);/\\ensuremath\{-\}/g;
+ $result =~ s/–/\\ensuremath\{-\}/g;
$result =~ s/&(lowast|\#8727);/\\ensuremath\{*\}/g;
$result =~ s/&(radic|\#8730);/\\ensuremath\{\\surd\}/g;
$result =~ s/&(prop|\#8733);/\\ensuremath\{\\propto\}/g;
@@ -822,6 +821,7 @@ sub print_latex_header {
$output.='\newcommand{\keephidden}[1]{}\renewcommand{\deg}{$^{\circ}$}'."\n".
'\usepackage{longtable}\usepackage{textcomp}\usepackage{makeidx}'."\n".
'\usepackage[dvips]{graphicx}\usepackage{epsfig}'."\n".
+ '\usepackage{wrapfig}'.
'\usepackage{picins}\usepackage{calc}'."\n".
'\newenvironment{choicelist}{\begin{list}{}{\setlength{\rightmargin}{0in}'."\n".
'\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.05in}'."\n".
@@ -903,6 +903,29 @@ sub unsupported {
#
+# List of recently generated print files
+#
+
+sub recently_generated {
+ my $r=shift;
+ my $prtspool=$r->dir_config('lonPrtDir');
+ $r->print('
'.&mt('Recently generated printouts').'
');
+ opendir(DIR,$prtspool);
+ while (my $filename=readdir(DIR)) {
+ if ($filename=~/^$env{'user.name'}\_$env{'user.domain'}\_printout\_(\d+)\_.*.pdf$/) {
+ my ($cdev,$cino,$cmode,$cnlink,
+ $cuid,$cgid,$crdev,$csize,
+ $catime,$cmtime,$cctime,
+ $cblksize,$cblocks)=stat($prtspool.'/'.$filename);
+ $r->print ("".
+ &mt('Generated').' '.&Apache::lonlocal::locallocaltime($cctime).
+ ' ('.$csize.' bytes)
');
+ }
+ }
+ closedir(DIR);
+}
+
+#
# Retrieve the hash of page breaks.
#
# Inputs:
@@ -926,6 +949,7 @@ sub get_page_breaks {
sub output_data {
my ($r,$helper,$rparmhash) = @_;
my %parmhash = %$rparmhash;
+ my $resources_printed = '';
my $html=&Apache::lonxml::xmlbegin();
my $bodytag=&Apache::loncommon::bodytag('Preparing Printout');
$r->print(<declareVar("showallfoils");
# The page breaks can get loaded initially from the course environment:
+ # But we only do this in the initial state so that they are allowed to change.
+ #
- if((!defined($env{"form.CURRENT_STATE"})) ||
- ($env{'form.CURRENT_STATE'} == "START")) {
- $helper->{VARS}->{FINISHPAGE} = ""; # In case they did a back e.g.
- }
-
-
+ $helper->{VARS}->{FINISHPAGE} = '';
&Apache::loncommon::restore_course_settings('print',
{'pagebreaks' => 'scalar',
'lastprinttype' => 'scalar'});
-
- if("$helper->{VARS}->{PRINT_TYPE}" eq "$env{'form.lastprinttype'}") {
- $helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'};
+
+ if($helper->{VARS}->{PRINT_TYPE} eq $env{'form.lastprinttype'}) {
+ if (!defined ($env{"form.CURRENT_STATE"})) {
+
+ $helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'};
+ } else {
+ my $state = $env{"form.CURRENT_STATE"};
+ if ($state eq "START") {
+ $helper->{VARS}->{FINISHPAGE} = $env{'form.pagebreaks'};
+ }
+ }
+
}
@@ -1975,7 +2005,7 @@ sub printHelper {
$helper->declareVar('SEQUENCE');
# Useful for debugging: Dump the help vars
-# $r->print(Dumper($helper->{VARS}));
+# $r->print(Dumper($helper->{VARS}));
# $r->print($map);
# If we're in a sequence...
@@ -2321,6 +2351,8 @@ CHOOSE_FROM_SUBDIR
CHOOSE_FROM_ANY_SEQUENCE
return \$res->is_sequence;
return $urlValue;
+ return \$res->hasResource(\$res,sub { return !\$_[0]->is_sequence() },0,0);
+
@@ -2453,7 +2485,6 @@ RNDSEED
$helper->{'VARS'}->{'style_file'}=$env{'form.style_file_value'};
}
-
}
@@ -2480,7 +2511,9 @@ RNDSEED
}
$r->print($helper->display());
-
+ if ($helper->{STATE} eq 'START') {
+ &recently_generated($r);
+ }
&Apache::lonhelper::unregisterHelperTags();
return OK;