--- loncom/interface/londocs.pm 2004/08/22 18:15:54 1.138
+++ loncom/interface/londocs.pm 2004/12/13 01:57:10 1.155
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.138 2004/08/22 18:15:54 raeburn Exp $
+# $Id: londocs.pm,v 1.155 2004/12/13 01:57:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -40,6 +40,7 @@ use Apache::lonnavmaps;
use HTML::Entities;
use GDBM_File;
use Apache::lonlocal;
+use Cwd;
my $iconpath;
@@ -254,6 +255,7 @@ sub exportcourse {
my $navmap = Apache::lonnavmaps::navmap->new();
my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
my $curRes;
+ my $outcome;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['finishexport']);
@@ -277,29 +279,49 @@ sub exportcourse {
$discussions[0] = $ENV{'form.discussion'};
}
}
- my $curRes;
- my $count;
- my %symbs;
- my $display;
- while ($curRes = $it->next()) {
- if (ref($curRes)) {
- $count ++;
- $symbs{$count} = $curRes->symb();
- if (grep/^$count$/,@exportitems) {
- $display.= 'Export content item '.$curRes->title()."
\n";
+ if (@exportitems == 0 && @discussions == 0) {
+ $outcome = '
As you did not select any content items or discussions for export, an IMS package has not been created. Please go back to select either content items or discussions for export';
+ } else {
+ my $now = time;
+ my $count = 0;
+ my %symbs;
+ my $manifestok = 0;
+ my $imsresources;
+ my $tempexport;
+ my $copyresult;
+ my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport);
+ if ($manifestok) {
+ &build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,\$tempexport,\$copyresult,$ims_manifest);
+ close($ims_manifest);
+
+#Create zip file in prtspool
+ my $imszipfile = '/prtspool/'.
+ $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
+ time.'_'.rand(1000000000).'.zip';
+# zip can cause an sh launch which can pass along all of %ENV
+# which can be too large for /bin/sh to handle
+ my %oldENV=%ENV;
+ undef(%ENV);
+ my $cwd = &Cwd::getcwd();
+ my $imszip = '/home/httpd/'.$imszipfile;
+ chdir $tempexport;
+ open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
+ close(OUTPUT);
+ chdir $cwd;
+ %ENV=%oldENV;
+ undef(%oldENV);
+ $outcome .= 'Download the zip file from IMS course archive
';
+ if ($copyresult) {
+ $outcome .= 'The following errors occurred during export - '.$copyresult;
}
- if (grep/^$count$/,@discussions) {
- $display.= 'Export discussion posts '.$curRes->title()."
\n";
- }
+ } else {
+ $outcome = '
Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.
';
}
}
$r->print('