--- loncom/interface/londocs.pm 2011/12/04 15:51:58 1.467
+++ loncom/interface/londocs.pm 2012/03/10 21:24:59 1.478
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.467 2011/12/04 15:51:58 raeburn Exp $
+# $Id: londocs.pm,v 1.478 2012/03/10 21:24:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -26,8 +26,6 @@
# http://www.lon-capa.org/
#
-
-
package Apache::londocs;
use strict;
@@ -41,6 +39,7 @@ use Apache::lonratedt();
use Apache::lonxml;
use Apache::lonclonecourse;
use Apache::lonnavmaps;
+use Apache::lonnavdisplay();
use HTML::Entities;
use GDBM_File;
use Apache::lonlocal;
@@ -264,809 +263,12 @@ sub dumpcourse {
}
}
-
-
sub exportbutton {
my $crstype = &Apache::loncommon::course_type();
return "".&mt('IMS Export')."".
&Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').' ';
}
-
-
-sub exportcourse {
- my $r=shift;
- my $crstype = &Apache::loncommon::course_type();
- my %discussiontime = &Apache::lonnet::dump('discussiontimes',
- $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
- my $numdisc = keys(%discussiontime);
- my $numprobs = 0;
- my $navmap = Apache::lonnavmaps::navmap->new();
- if (!defined($navmap)) {
- $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package').
- '
'.&mt('IMS Export Failed').'
'.
- '
');
- if ($crstype eq 'Community') {
- $r->print(&mt('Unable to retrieve information about community contents'));
- } else {
- $r->print(&mt('Unable to retrieve information about course contents'));
- }
- $r->print('
');
- if ($crstype eq 'Community') {
- $r->print(&mt('Return to Community Editor'));
- } else {
- $r->print(&mt('Return to Course Editor'));
- }
- $r->print('');
- &Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
- return;
- }
- my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
- my $curRes;
- my $outcome;
-
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['finishexport']);
- if ($env{'form.finishexport'}) {
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['archive','discussion']);
-
- my $format = $env{'form.format'};
- my @exportitems = &Apache::loncommon::get_env_multiple('form.archive');
- my @discussions = &Apache::loncommon::get_env_multiple('form.discussion');
- if (@exportitems == 0 && @discussions == 0) {
- $outcome =
- '
'
- .&mt('As you did not select any content items or discussions'
- .' for export, an IMS package has not been created.')
- .'
'
- .'
'
- .&mt('Please [_1]go back[_2] to select either content items'
- .' or discussions for export.'
- ,''
- ,'')
- .'
';
- } else {
- my $now = time;
- my %symbs;
- my $manifestok = 0;
- my $imsresources;
- my $tempexport;
- my $copyresult;
- my $testbank;
- my $ims_manifest = &create_ims_store($now,\$manifestok,\$outcome,\$tempexport,$format,\$testbank);
- if ($manifestok) {
- &build_package($now,$navmap,\@exportitems,\@discussions,\$outcome,$tempexport,\$copyresult,$ims_manifest,$format,$testbank);
- close($ims_manifest);
-
-#Create zip file in prtspool
- my $imszipfile = '/prtspool/'.
- $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
- time.'_'.rand(1000000000).'.zip';
- my $cwd = &Cwd::getcwd();
- my $imszip = '/home/httpd/'.$imszipfile;
- chdir $tempexport;
- open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
- close(OUTPUT);
- chdir $cwd;
- $outcome .= '
'
- .&mt('[_1]Your IMS package[_2] is ready for download.'
- ,'','')
- .'
';
- if ($copyresult) {
- $outcome .= '
'
- .&mt('The following errors occurred during export - [_1]'
- ,$copyresult)
- .'
';
- }
- } else {
- $outcome = '
'
- .&mt('Unfortunately you will not be able to retrieve'
- .' an IMS archive of your course at this time,'
- .' because there was a problem creating a'
- .' manifest file.')
- .'
');
-
- my $active = '';
-# does this user have privileges to modify docs?
- my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
-
- my $onclick;
- my $href;
-
- if ($allowed) {
+ if (($mode eq 'navmaps') || ($mode eq 'supplemental')) {
+ $r->print('