--- loncom/interface/londocs.pm 2009/10/04 13:58:02 1.389
+++ loncom/interface/londocs.pm 2012/02/28 02:02:16 1.477
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.389 2009/10/04 13:58:02 tempelho Exp $
+# $Id: londocs.pm,v 1.477 2012/02/28 02:02:16 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;
@@ -117,17 +116,22 @@ sub authorhosts {
sub dumpbutton {
my ($home,$other,%outhash)=&authorhosts();
- my $type = &Apache::loncommon::course_type();
+ my $crstype = &Apache::loncommon::course_type();
if ($home+$other==0) { return ''; }
if ($home) {
- my $link = "".&mt('Dump '.$type.' DOCS to Construction Space')."";
- return $link.' '.
- &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs').' ';
- } else {
- return '
'.
- &mt('Dump '.$type.
- ' DOCS to Construction Space: available on other servers').
- '
';
+ my $link =
+ ""
+ .&mt('Dump '.$crstype.' Documents to Construction Space')
+ .'';
+ return
+ $link.' '
+ .&Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs')
+ .' ';
+ } else {
+ return
+ &mt('Dump '.$crstype.' Documents to Construction Space: available on other servers');
}
}
@@ -141,10 +145,10 @@ sub clean {
sub dumpcourse {
my ($r) = @_;
- my $type = &Apache::loncommon::course_type();
- $r->print(&Apache::loncommon::start_page('Dump '.$type.' DOCS to Construction Space').
+ my $crstype = &Apache::loncommon::course_type();
+ $r->print(&Apache::loncommon::start_page('Dump '.$crstype.' Documents to Construction Space').
'');
+ '');
}
}
-
-
sub exportbutton {
- my $type = &Apache::loncommon::course_type();
- return "".&mt('IMS Export')."".
+ 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 $type = &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 $navmap = Apache::lonnavmaps::navmap->new();
- if (!defined($navmap)) {
- $r->print(&Apache::loncommon::start_page('Export '.$type.' to IMS Package').
- '
'.&mt('IMS Export Failed').'
'.
- '
'.
- &mt('Unable to retrieve information about course contents').
- '
'.&mt('Return to Course Editor').'');
- &Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($type).':'.$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 @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 $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';
- my $cwd = &Cwd::getcwd();
- my $imszip = '/home/httpd/'.$imszipfile;
- chdir $tempexport;
- open(OUTPUT, "zip -r $imszip * 2> /dev/null |");
- close(OUTPUT);
- chdir $cwd;
- if ($copyresult) {
- $outcome .= '
'
- .&mt('The following errors occurred during export - [_1]'
- ,$copyresult)
- .'
';
- }
- $outcome .= '
'
- .&mt('[_1]Your IMS package[_2] is ready for download.'
- ,'','')
- .'
';
- } else {
- $outcome = '
'
- .&mt('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.')
- .'
'
+ .&Apache::loncommon::end_scrollbox();
+ }
+ my $tid = 1;
+ if ($supplementalflag) {
+ $tid = 2;
}
if ($allowed) {
+ $r->print(&generate_edit_table($tid,$orderhash,$to_show,$iconpath,$jumpto));
&print_paste_buffer($r,$container);
+ } else {
+ if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
+ #Function Box for Supplemental Content for users with mdc priv.
+ my $funcname = &mt('Folder Editor');
+ $r->print(
+ &Apache::loncommon::head_subbox(
+ &Apache::lonhtmlcommon::start_funclist().
+ &Apache::lonhtmlcommon::add_item_funclist(
+ ''.
+ ''.
+ ''.$funcname.'').
+ &Apache::lonhtmlcommon::end_funclist()));
+ }
+ $r->print($to_show);
}
return;
}
@@ -1658,11 +1012,10 @@ sub editor {
sub process_file_upload {
my ($upload_output,$coursenum,$coursedom,$allfiles,$codebase,$uploadcmd) = @_;
# upload a file, if present
- my $parseaction;
- if ($env{'form.parserflag'}) {
+ my ($parseaction,$showupload,$nextphase,$mimetype);
+ if ($env{'form.parserflag'}) {
$parseaction = 'parse';
}
- my $phase_status;
my $folder=$env{'form.folder'};
if ($folder eq '') {
$folder='default';
@@ -1681,7 +1034,8 @@ sub process_file_upload {
$LONCAPA::map::resources[1]='';
}
if ($fatal) {
- return 'failed';
+ $$upload_output = '
'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'
';
+ return;
}
my $destination = 'docs/';
if ($folder =~ /^supplemental/) {
@@ -1692,13 +1046,23 @@ sub process_file_upload {
} elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
$destination .= $2.'/';
}
-# this is for a course, not a user, so set coursedoc flag
-# probably the only place in the system where this should be "1"
+# this is for a course, not a user, so set context to coursedoc.
my $newidx=&LONCAPA::map::getresidx();
$destination .= $newidx;
- my $url=&Apache::lonnet::userfileupload('uploaddoc',1,$destination,
+ my $url=&Apache::lonnet::userfileupload('uploaddoc','coursedoc',$destination,
$parseaction,$allfiles,
- $codebase);
+ $codebase,undef,undef,undef,undef,
+ undef,undef,\$mimetype);
+ if ($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E.*/([^/]+)$}) {
+ my $stored = $1;
+ $showupload = '
ENDPARMS
}
$line.=&Apache::loncommon::end_data_table_row();
@@ -2209,34 +1599,33 @@ List Symbs
sub list_symbs {
my ($r) = @_;
- my $type = &Apache::loncommon::course_type();
+ my $crstype = &Apache::loncommon::course_type();
$r->print(&Apache::loncommon::start_page('Symb List'));
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List'));
+ &startContentScreen($r,'tools');
my $navmap = Apache::lonnavmaps::navmap->new();
if (!defined($navmap)) {
$r->print('
'.&mt('Retrieval of List Failed').'
'.
'
'.
&mt('Unable to retrieve information about course contents').
'
');
- &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'});
+ &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
} else {
$r->print("
\n");
}
- $r->print(''.&mt('Return to DOCS').'');
}
sub verifycontent {
my ($r) = @_;
- my $type = &Apache::loncommon::course_type();
- my $loaderror=&Apache::lonnet::overloaderror($r);
- if ($loaderror) { return $loaderror; }
- $r->print(&Apache::loncommon::start_page('Verify '.$type.' Documents'));
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$type.' Documents'));
+ my $crstype = &Apache::loncommon::course_type();
+ $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents'));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents'));
+ &startContentScreen($r,'tools');
$hashtied=0;
undef %alreadyseen;
%alreadyseen=();
@@ -2245,9 +1634,9 @@ sub verifycontent {
if ($hash{$key}=~/\.(page|sequence)$/) {
if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
$r->print(''.
- &mt('The following sequence or page is included more than once in your '.$type.': ').
+ &mt('The following sequence or page is included more than once in your '.$crstype.':').' '.
&unescape($hash{$key}).' '.
- &mt('Note that grading records for problems included in this sequence or folder will overlap.'));
+ &mt('Note that grading records for problems included in this sequence or folder will overlap.').'');
}
}
if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
@@ -2255,8 +1644,7 @@ sub verifycontent {
}
}
&untiehash();
- $r->print('
');
}
@@ -2268,9 +1656,11 @@ sub devalidateversioncache {
sub checkversions {
my ($r) = @_;
- my $type = &Apache::loncommon::course_type();
- $r->print(&Apache::loncommon::start_page("Check $type Document Versions"));
- $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $type Document Versions"));
+ my $crstype = &Apache::loncommon::course_type();
+ $r->print(&Apache::loncommon::start_page("Check $crstype Document Versions"));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Document Versions"));
+ &startContentScreen($r,'tools');
+
my $header='';
my $startsel='';
my $monthsel='';
@@ -2331,7 +1721,7 @@ sub checkversions {
&changewarning($r,'');
if ($env{'form.timerange'} eq 'all') {
# show all documents
- $header=&mt('All Documents in '.$type);
+ $header=&mt('All Documents in '.$crstype);
$allsel=1;
foreach my $key (keys(%hash)) {
if ($key=~/^ids\_(\/res\/.+)$/) {
@@ -2376,7 +1766,7 @@ sub checkversions {
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'});
my %lt=&Apache::lonlocal::texthash
- ('st' => 'Version changes since start of '.$type,
+ ('st' => 'Version changes since start of '.$crstype,
'lm' => 'Version changes since last Month',
'lw' => 'Version changes since last Week',
'sy' => 'Version changes since Yesterday',
@@ -2385,9 +1775,9 @@ sub checkversions {
'fi' => 'File',
'md' => 'Modification Date',
'mr' => 'Most recently published Version',
- 've' => 'Version used in '.$type,
- 'vu' => 'Set Version to be used in '.$type,
-'sv' => 'Set Versions to be used in '.$type.' according to Selections below',
+ 've' => 'Version used in '.$crstype,
+ 'vu' => 'Set Version to be used in '.$crstype,
+'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
'di' => 'Differences');
@@ -2434,7 +1824,7 @@ ENDHEADERS
'
Most Recent: '.
''.$currentversion.''.
'
'.
- '
In '.$type.': '.
+ '
In '.$crstype.': '.
'');
# Used in course
my $usedversion=$hash{'version_'.$linkurl};
@@ -2448,11 +1838,11 @@ ENDHEADERS
# Set version
$r->print(&Apache::loncommon::select_form($setversions{$linkurl},
'set_version_'.$linkurl,
- ('select_form_order' =>
+ {'select_form_order' =>
['',1..$currentversion,'mostrecent'],
'' => '',
- 'mostrecent' => 'most recent',
- map {$_,$_} (1..$currentversion))));
+ 'mostrecent' => &mt('most recent'),
+ map {$_,$_} (1..$currentversion)}));
$r->print('