--- loncom/interface/londocs.pm 2009/07/01 13:16:42 1.374
+++ loncom/interface/londocs.pm 2010/12/11 14:28:12 1.447
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.374 2009/07/01 13:16:42 tempelho Exp $
+# $Id: londocs.pm,v 1.447 2010/12/11 14:28:12 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -35,6 +35,7 @@ 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;
@@ -116,17 +117,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('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; @@ -322,7 +347,7 @@ sub exportcourse { close(OUTPUT); chdir $cwd; $outcome .= '' - .&mt('Download the zip file from [_1]IMS '.lc($type).' archive[_2]' + .&mt('[_1]Your IMS package[_2] is ready for download.' ,'','') .'
'; if ($copyresult) { @@ -332,32 +357,42 @@ sub exportcourse { .''; } } 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.') + .'
' + .''; } } - $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package')); - $r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package')); + $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package')); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('IMS Export')); $r->print($outcome); $r->print(&Apache::loncommon::end_page()); } else { - my $display; - $display = ''); + &mt('Export').'" />'); } } @@ -980,7 +1007,7 @@ sub group_import { } sub breadcrumbs { - my ($where,$allowed,$type)=@_; + my ($allowed,$crstype)=@_; &Apache::lonhtmlcommon::clear_breadcrumbs(); my (@folders); if ($env{'form.pagepath'}) { @@ -995,6 +1022,15 @@ sub breadcrumbs { my $isencrypted=0; my $ishidden=0; my $is_random_order=0; + if (!$allowed) { + my $description = $env{'course.'.$env{'request.course.id'}.'.description'}; + &Apache::lonhtmlcommon::add_breadcrumb( + {'href' => '/adm/menu', + 'title'=> 'Go to main menu', + 'text' => $description, + }); + $plain .= $description.' >'; + } while (@folders) { my $folder=shift(@folders); my $foldername=shift(@folders); @@ -1014,11 +1050,7 @@ sub breadcrumbs { if ($3) { $isencrypted=1; } if ($4 ne '') { $is_random_order = 1; } if ($folder eq 'supplemental') { - if ($allowed) { - $name = &mt('Supplemental '.$type.' Documents'); - } else { - $name = &mt($type.' Documents'); - } + $name = &mt('Supplemental '.$crstype.' Documents'); } &Apache::lonhtmlcommon::add_breadcrumb( {'href'=>$url.$cpinfo, @@ -1030,7 +1062,7 @@ sub breadcrumbs { } $plain=~s/\>\;\s*$//; return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp', - 'LC_docs_path', undef, 1 ),$randompick,$ishidden,$isencrypted,$plain,$is_random_order); + undef, undef, 1 ),$randompick,$ishidden,$isencrypted,$plain,$is_random_order); } sub log_docs { @@ -1254,10 +1286,11 @@ sub print_paste_buffer { my ($r,$container) = @_; return if (!defined($env{'docs.markedcopy_url'})); - $r->print(<-ENDPASTE - $r->print(' '); + $r->print('
'); } sub do_paste_from_buffer { @@ -1473,8 +1506,7 @@ sub handle_edit_cmd { } sub editor { - my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_; - + my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype)=@_; my $container= ($env{'form.pagepath'}) ? 'page' : 'sequence'; @@ -1489,9 +1521,13 @@ sub editor { $LONCAPA::map::resources[$idx]=''; } - my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)= - &breadcrumbs($folder,$allowed,$type); - $r->print($breadcrumbtrail); + my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) = + &breadcrumbs($allowed,$crstype); + $r->print($breadcrumbtrail); + + unless ($allowed) { + $randompick = -1; + } # ------------------------------------------------------------ Process commands @@ -1569,34 +1605,73 @@ 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/) { + $->print(''.&mt('Settings').' | '); + } + $r->print(&Apache::loncommon::end_data_table_header_row()); + } + $r->print($output + .&Apache::loncommon::end_data_table() + ); + } else { + $r->print('
---|
'.&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/) { @@ -1640,13 +1715,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 = ''.&mt('Uploaded [_1]',''. + $stored.'').'
'; + } else { + my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$}); + + $$upload_output = ''.&mt('Unable to save file [_1].',''.$filename.'').'
'; + return; + } my $ext='false'; if ($url=~m{^http://}) { $ext='true'; } $url = &LONCAPA::map::qtunescape($url); @@ -1663,51 +1748,37 @@ sub process_file_upload { ($errtext,$fatal)=&storemap($coursenum,$coursedom, $folder.'.'.$container); if ($fatal) { - $$upload_output .= ''.$errtext.'
'; - return 'failed'; + $$upload_output = ''.$errtext.'
'; + return; } else { - if ($parseaction eq 'parse') { - my $total_embedded = keys(%{$allfiles}); + if ($parseaction eq 'parse' && $mimetype eq 'text/html') { + $$upload_output = $showupload; + my $total_embedded = scalar(keys(%{$allfiles})); if ($total_embedded > 0) { - my $num = 0; - my $state = ' - - - - - '; - $phase_status = 'phasetwo'; - - $$upload_output .= - 'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.'.&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 +2269,9 @@ sub verifycontent { if ($hash{$key}=~/\.(page|sequence)$/) { if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) { $r->print('
'.&mt('Done').'
'); } @@ -2218,9 +2291,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=''; @@ -2281,7 +2356,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\/.+)$/) { @@ -2326,7 +2401,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', @@ -2335,9 +2410,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'); @@ -2384,7 +2459,7 @@ ENDHEADERS ''.&mt('Done').'
'); &untiehash(); } @@ -2507,7 +2582,7 @@ sub changewarning { 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n". '// ]]>'."\n". ''."\n". -''. &mt($message,' "Edit ".&Apache::loncommon::course_type(), + text=>&Apache::loncommon::course_type().' Editor', faq=>273, bug=>'Instructor Interface', help => 'Docs_Adding_Course_Doc'}); @@ -2531,17 +2606,74 @@ sub init_breadcrumbs { bug=>'Instructor Interface'}); } +# subroutine to list form elements +sub create_list_elements { + my @formarr = @_; + my $list = ''; + for my $button (@formarr){ + for my $picture(keys %$button) { + $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'}); + } + } + return $list; +} + +# subroutine to create ul from list elements +sub create_form_ul { + my $list = shift; + my $ul = &Apache::lonhtmlcommon::htmltag('ul',$list, {class => 'LC_ListStyleNormal'}); + return $ul; +} + +# +# Start tabs +# + +sub startContentScreen { + my ($r,$mode)=@_; + $r->print('
'); + $r->print('
$lt{'copm'} '.$error.' '.$error.' '.$error.' '.$error.' '.$error.' '.
@@ -3336,35 +3443,80 @@ $r->print('');
return OK;
}
+sub embedded_form_elems {
+ my ($phase,$primaryurl,$newidx) = @_;
+ my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
+ return <
@@ -2869,17 +3013,15 @@ FUFORM
SEDFFORM
- my $extresourcesform=(<
' . $fileuploadform;
+
+ push @specialdocumentsforma, ({''=>$newnavform},
+ {''=>$newsmppageform},
+ {''=>$newsmpproblemform},
+ {''=>$newdropboxform},
+ {''=>$newexuploadform},
+ {''=>$newbulform},
+ {''=>$newaboutmeform},
+ {''=>$newaboutsomeoneform},
+ {''=>$newrosterform},);
- $specialdocumentsform="
$newpageform
$newsylform
$newgroupfileform";
+ $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
}
- $specialdocumentsform.="
$newnavform
$newsmppageform
-
$newsmpproblemform
$newdropboxform
-
$newexuploadform
$newbulform
-
$newaboutmeform
$newaboutsomeoneform
-
$newrosterform";
+
if($env{'form.pagepath'}) {
- $specialdocumentsform="
$newsmpproblemform
$newexuploadform";
+
+ @specialdocumentsforma=(
+ {''=>$newsmpproblemform},
+ {''=>$newexuploadform}
+ );
+ $specialdocumentsform= &create_form_ul(&create_list_elements(@specialdocumentsforma));
}
+my @tools = (
+# {''=>$extresourcesform},
+# {''=>$imspform},
+ {''=>$recoverform},
+ );
+
my %orderhash = (
- 'aa' => ['Upload Document',$fileuploadform.'
'.$newfolderform],
- 'bb' => ['Published Documents',$simpleeditdefaultform],
+ 'aa' => ['Import Documents',$fileuploadform],
+ 'bb' => ['Published Resources',$simpleeditdefaultform],
'cc' => ['Special Documents',$specialdocumentsform],
- 'dd' => ['Tools',$extresourcesform.'
'.$imspform.'
'.$recoverform.'
'.&generate_admin_options($containertag,$uploadtag,\%help,\%env)],
- 'zz' => ['Hide all Options'],
+ 'dd' => ['Tools', &create_form_ul(&create_list_elements(@tools)).&generate_admin_options(\%help,\%env)],
);
-my $tid='1';
-my $varcd = 'Main Course Documents';
-$r->print(&generate_edit_table($tid,$varcd,\%orderhash));
+unless($env{'form.pagepath'}) {
+ $orderhash{'00'} = ['Newfolder',$newfolderform];
+}
+
$hadchanges=0;
- my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$type);
- if ($error) {
- $r->print('
@@ -3229,42 +3338,30 @@ $r->print('
$lt{'comment'}:
-
+
-
-
- $help{'Uploading_From_Harddrive'}
-
-
SUPDOCFORM
+ $supupdocform .= &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'}))."";
my $supnewfolderform=(<
' . $supupdocform;
my %suporderhash = (
- 'ee' => ['Upload Document',$supupdocform.'
'.$supnewfolderform],
- 'ff' => ['Special Documents',$supnewextform.'
'.$supnewsylform.'
'.$supnewaboutmeform],
- 'zz' => ['Hide all Options'],
+ '00' => ['Supnewfolder', $supnewfolderform],
+ 'ee' => ['Import Documents',$supupdocform],
+ 'ff' => ['Special Documents',&create_form_ul(&create_list_elements(@specialdocs))]
);
+ if ($supplementalflag) {
+ my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype);
+ if ($error) {
+ $r->print('".&mt('Uploaded Document').' - '.
&Apache::lonnet::gettitle($r->uri).'