--- loncom/interface/londocs.pm 2009/06/08 18:04:45 1.370
+++ loncom/interface/londocs.pm 2012/04/16 19:31:57 1.482
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.370 2009/06/08 18:04:45 bisitz Exp $
+# $Id: londocs.pm,v 1.482 2012/04/16 19:31:57 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -26,8 +26,6 @@
# http://www.lon-capa.org/
#
-
-
package Apache::londocs;
use strict;
@@ -35,11 +33,13 @@ use Apache::Constants qw(:common :http);
use Apache::imsexport;
use Apache::lonnet;
use Apache::loncommon;
+use Apache::lonhtmlcommon;
use LONCAPA::map();
use Apache::lonratedt();
use Apache::lonxml;
use Apache::lonclonecourse;
use Apache::lonnavmaps;
+use Apache::lonnavdisplay();
use HTML::Entities;
use GDBM_File;
use Apache::lonlocal;
@@ -116,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) {
- return ''.
- &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs').'
';
- } else {
- return '
' - .&mt('Download the zip file from [_1]IMS '.lc($type).' archive[_2]' - ,'','') - .'
'; - if ($copyresult) { - $outcome .= '' - .&mt('The following errors occurred during export - [_1]' - ,$copyresult) - .'
'; - } - } else { - $outcome = '-ENDPASTE - $r->print(' '); + $r->print('
'); } sub do_paste_from_buffer { @@ -1429,7 +768,6 @@ sub update_parameter { sub handle_edit_cmd { my ($coursenum,$coursedom) =@_; - my ($cmd,$idx)=split('_',$env{'form.cmd'}); my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]; @@ -1437,7 +775,7 @@ sub handle_edit_cmd { if ($cmd eq 'del') { if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) && - ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) { + ($url!~/$LONCAPA::assess_page_seq_re/)) { &Apache::lonnet::removeuploadedurl($url); } else { &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]); @@ -1473,8 +811,8 @@ sub handle_edit_cmd { } sub editor { - my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_; - + my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype, + $supplementalflag,$orderhash,$iconpath)=@_; my $container= ($env{'form.pagepath'}) ? 'page' : 'sequence'; @@ -1489,10 +827,16 @@ sub editor { $LONCAPA::map::resources[$idx]=''; } - my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)= - &breadcrumbs($folder,$allowed,$type); + my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) = + &breadcrumbs($allowed,$crstype); $r->print($breadcrumbtrail); + my $jumpto = "uploaded/$coursedom/$coursenum/$folder.$container"; + + unless ($allowed) { + $randompick = -1; + } + # ------------------------------------------------------------ Process commands # ---------------- if they are for this folder and user allowed to make changes @@ -1569,36 +913,98 @@ sub editor { my $idx=0; my $shown=0; if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) { - $r->print(''.&mt('Parameters').':
'.&mt('Caution: this folder is set to randomly pick a subset of resources. Adding or removing resources from this folder will change the set of resources that the students see, resulting in spurious or missing credit for completed problems, not limited to ones you modify. Do not modify the contents of this folder if it is in active student use.').'
'); - } - if ($is_random_order) { - $r->print(''.&mt('Caution: this folder is set to randomly order its contents. Adding or removing resources from this folder will change the order of resources shown.').'
'); + ($is_random_order?'' + .&mt('Caution: this folder is set to randomly pick a subset' + .' of resources. Adding or removing resources from this' + .' folder will change the set of resources that the' + .' students see, resulting in spurious or missing credit' + .' for completed problems, not limited to ones you' + .' modify. Do not modify the contents of this folder if' + .' it is in active student use.') + .'
' + ); + } + if ($is_random_order) { + $r->print('' + .&mt('Caution: this folder is set to randomly order its' + .' contents. Adding or removing resources from this folder' + .' will change the order of resources shown.') + .'
' + ); + } + $r->print(''.&mt('Currently no documents.').' | '.&mt('Move').' | ' + .''.&mt('Actions').' | ' + .''.&mt('Document').' | '; + if ($folder !~ /^supplemental/) { + $to_show .= ''.&mt('Settings').' | '; + } + $to_show .= &Apache::loncommon::end_data_table_header_row(); + } + $to_show .= $output.' ' + .&Apache::loncommon::end_data_table() + .'
---|
'.&mt('Uploaded [_1]',''. + $stored.'').'
'; + } else { + my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$}); + + $$upload_output = ''.$errtext.'
'; - return 'failed'; + $$upload_output = ''.&mt('This file contains embedded multimedia objects, which need to be uploaded.').'
'.$embedded; + $nextphase = $uploadphase; + } else { + $$upload_output .= $embedded; + } + } else { + $$upload_output .= &mt('Embedded item(s) already present, so no additional upload(s) required').'\n"); foreach my $res ($navmap->retrieveResources()) { - $r->print($res->compTitle()."\t".$res->symb()."\n"); + $r->print($res->compTitle()."\t".$res->symb()."\n"); } $r->print("\n\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=(); @@ -2195,9 +1681,9 @@ sub verifycontent { if ($hash{$key}=~/\.(page|sequence)$/) { if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) { $r->print('
'.&mt('Done').'
'); } @@ -2218,9 +1703,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=''; @@ -2272,16 +1759,18 @@ sub checkversions { if (&Apache::lonnet::put('resourceversions',\%newsetversions, $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') { - $r->print(''.&mt('Resources').' | '. + "$lt{'mr'} | ". + "$lt{'ve'} | ". + "$lt{'vu'} | ". + ''.&mt('History').' | '. + ''); foreach my $key (sort(keys(%changes))) { if ($changes{$key}>$starttime) { my ($root,$extension)=($key=~/^(.*)\.(\w+)$/); my $currentversion=&Apache::lonnet::getversion($key); if ($currentversion<0) { - $currentversion=&mt('Could not be determined.'); + $currentversion=''.&mt('Could not be determined.').''; } my $linkurl=&Apache::lonnet::clutter($key); - $r->print( - '||||
---|---|---|---|---|---|---|---|---|
'. - &Apache::lonnet::gettitle($linkurl). - ' | ||||||||
'. - ' | '. - ''.$linkurl. - ' | |||||||
'. - ' | '. - &Apache::lonlocal::locallocaltime( - &Apache::lonnet::metadata($root.'.'.$extension, - 'lastrevisiondate') - ). - ' | '. - 'Most Recent: '. - ''.$currentversion.''. - ' | '. - 'In '.$type.': '. - ''); + $r->print( + &Apache::loncommon::end_data_table_header_row(). + &Apache::loncommon::start_data_table_row(). + ' | '.&Apache::lonnet::gettitle($linkurl).' '. + ''.$linkurl.' | '.
+ ''.$currentversion.' ('. + &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($root.'.'.$extension,'lastrevisiondate')).') | '.
+ ''); # Used in course my $usedversion=$hash{'version_'.$linkurl}; if (($usedversion) && ($usedversion ne 'mostrecent')) { - $r->print($usedversion); + if($usedversion != $currentversion){ + $r->print(''.$usedversion.''); + }else{ + $r->print($usedversion); + } } else { $r->print($currentversion); } - $r->print(' | '. - 'Use: '); + $r->print(' | '); # 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)))); - $r->print(' |
'); + 'mostrecent' => &mt('most recent'), + map {$_,$_} (1..$currentversion)})); my $lastold=1; for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { my $url=$root.'.'.$prevvers.'.'.$extension; @@ -2417,13 +1914,13 @@ ENDHEADERS # each of the four columns my $entries_per_col = 0; my $num_entries = ($currentversion-$lastold); - if ($num_entries % 4 == 0) { - $entries_per_col = $num_entries/4; + if ($num_entries % $num_ver_col == 0) { + $entries_per_col = $num_entries/$num_ver_col; } else { - $entries_per_col = $num_entries/4 + 1; + $entries_per_col = $num_entries/$num_ver_col + 1; } my $entries_count = 0; - $r->print(' | '); + $r->print(' | ');
my $cols_output = 1;
for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
my $url=$root.'.'.$prevvers.'.'.$extension;
@@ -2438,25 +1935,25 @@ ENDHEADERS
$r->print(' '.&mt('Diffs').'');
+ '" target="diffs">'.&mt('Diffs').'');
}
$r->print(' '); if (++$entries_count % $entries_per_col == 0) { - $r->print(' | ');
- if ($cols_output != 4) {
- $r->print(''); + $r->print(' | '); + if ($cols_output != $num_ver_col) { + $r->print(''); $cols_output++; } } } - while($cols_output++ < 4) { - $r->print(' | ') + while($cols_output++ < $num_ver_col) { + $r->print(' | '); } - $r->print(' |
+
+SEDFFORM
+ my @simpleeditdefaultforma = (
+ { '' => "$uploadtag$lt{'srch'}" },
+ { '' => "$lt{'impo'}$help{'Importing_LON-CAPA_Resource'}" },
+ { '' => "$lt{'wish'}" },
+ );
+ $simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma));
+ $simpleeditdefaultform .=(<
-
$help{'Load_Map'}
-
'.$error.'
'); - } - if ($hadchanges) { - &mark_hash_old(); - } + unless ($supplementalflag) { + my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, + $supplementalflag,\%orderhash,$iconpath); + if ($error) { + $r->print(''.$error.'
'); + } + if ($hadchanges) { + &mark_hash_old(); + } + + &changewarning($r,''); + } + } + +# Supplemental documents start here - &changewarning($r,''); -$r->print(''.$error.'
'); + } + } + } elsif ($supplementalflag) { + my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype, + $supplementalflag,'',$iconpath); + if ($error) { + $r->print(''.$error.'
'); + } + } -my $tid='2'; -my $varscd = 'Supplemental Course Documents'; + &endContentScreen($r); -$r->print(&generate_edit_table($tid,$varscd,\%suporderhash)); -my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type); - if ($error) { - $r->print(''.$error.'
'); - } -$r->print(''.
@@ -3316,52 +2979,237 @@ $r->print('');
return OK;
}
+sub embedded_form_elems {
+ my ($phase,$primaryurl,$newidx) = @_;
+ my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
+ return <
'.&mt('Not extracted.').'
'.
+ $error.'
'.$warning.'
'."\n"; + } + return $output; +} + +sub decompression_phase_two { + my ($destination,$dir_root,$londocroot,$docudom,$docuname,$container,$hiddenelem)= + &decompression_info(); + my $output; + if ($env{'form.archivedelete'}) { + $output = &remove_archive($docudom,$docuname,$container); + } + $output .= + &Apache::loncommon::process_extracted_files('coursedocs',$docudom,$docuname, + $destination,$dir_root,$hiddenelem); + return $output; +} + +sub remove_archive { + my ($docudom,$docuname,$container) = @_; + my $map = $env{'form.folder'}.'.'.$container; + my ($output,$delwarning,$delresult,$url); + my ($errtext,$fatal) = &mapread($docuname,$docudom,$map); + if ($fatal) { + if ($container eq 'page') { + $delwarning = &mt('An error occurred retrieving the contents of the current page.'); + } else { + $delwarning = &mt('An error occurred retrieving the contents of the current folder.'); + } + $delwarning .= &mt('As a result the archive file has not been removed.'); + } else { + my $currcmd = $env{'form.cmd'}; + my $position = $env{'form.position'}; + if ($position > 0) { + $env{'form.cmd'} = 'del_'.$position; + my ($title,$url,@rrest) = + split(/:/,$LONCAPA::map::resources[$LONCAPA::map::order[$position]]); + if (&handle_edit_cmd($docuname,$docudom)) { + ($errtext,$fatal) = &storemap($docuname,$docudom,$map); + if ($fatal) { + if ($container eq 'page') { + $delwarning = &mt('An error occurred updating the contents of the current page.'); + } else { + $delwarning = &mt('An error occurred updating the contents of the current folder.'); + } + } else { + $delresult = &mt('Archive file removed.'); + } + } + } + $env{'form.cmd'} = $currcmd; + } + if ($delwarning) { + $output = ''. + $delwarning. + '
'; + } + if ($delresult) { + $output .= ''. + $delresult. + '
'; + } + return $output; +} + sub generate_admin_options { - my ($containertag,$uploadtag,$help_ref,$env_ref) = @_; - my %lt=&Apache::lonlocal::texthash( + my ($help_ref,$env_ref) = @_; + my %lt=&Apache::lonlocal::texthash( 'vc' => 'Verify Content', 'cv' => 'Check/Set Resource Versions', 'ls' => 'List Symbs', - 'sl' => 'Show Log' + 'sl' => 'Show Log', + 'imse' => 'IMS Export', + 'dcd' => 'Dump Course Documents to Construction Space: available on other servers' ); my %help = %{$help_ref}; my %env = %{$env_ref}; my $dumpbut=&dumpbutton(); my $exportbut=&exportbutton(); - return (<