--- loncom/interface/londocs.pm 2010/03/18 13:48:45 1.422
+++ loncom/interface/londocs.pm 2011/01/21 01:30:07 1.451
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.422 2010/03/18 13:48:45 onken Exp $
+# $Id: londocs.pm,v 1.451 2011/01/21 01:30:07 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -121,7 +121,7 @@ sub dumpbutton {
if ($home+$other==0) { return ''; }
if ($home) {
my $link =
- ""
.&mt('Dump '.$crstype.' Documents to Construction Space')
@@ -268,7 +268,7 @@ sub dumpcourse {
sub exportbutton {
my $crstype = &Apache::loncommon::course_type();
- return "".&mt('IMS Export')."".
+ return "".&mt('IMS Export')."".
&Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'
';
}
@@ -1521,12 +1521,11 @@ sub editor {
$LONCAPA::map::resources[$idx]='';
}
- my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order);
- if ($allowed) {
- ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) =
+ my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order) =
&breadcrumbs($allowed,$crstype);
$r->print($breadcrumbtrail);
- } else {
+
+ unless ($allowed) {
$randompick = -1;
}
@@ -1607,13 +1606,12 @@ sub editor {
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' @@ -1637,7 +1635,9 @@ sub editor { $r->print('
' @@ -1679,11 +1683,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'; @@ -1702,7 +1705,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/) { @@ -1713,13 +1717,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); @@ -1736,51 +1750,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') { + 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').''.&mt('Done').'
' - .'' - .&mt('Back to Course Editor') - .'
' - ); + $r->print(''.&mt('Done').'
'); } @@ -2303,6 +2296,8 @@ sub checkversions { 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=''; @@ -2480,11 +2475,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' => &mt('most recent'), - map {$_,$_} (1..$currentversion)))); + map {$_,$_} (1..$currentversion)})); $r->print('
@@ -2995,14 +3017,15 @@ SEDFFORM
SEDFFORM
- my $extresourcesform=(< '.$error.' '.$error.' '.$error.' '.$error.' '.$error.' '.
@@ -3476,9 +3452,45 @@ $r->print('');
return OK;
}
+sub embedded_form_elems {
+ my ($phase,$primaryurl,$newidx) = @_;
+ my $folderpath = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
+ return <
');
- }
- $r->print('
' . $fileuploadform;
+
+ @gradingforma=(
+ {''=>$newsmpproblemform},
+ {''=>$newdropboxform},
+ {''=>$newexuploadform},
+
+ );
+ $gradingform = &create_form_ul(&create_list_elements(@gradingforma));
+
+ @communityforma=(
+ {''=>$newbulform},
+ {''=>$newaboutmeform},
+ {''=>$newaboutsomeoneform},
+ {''=>$newrosterform},
+ {''=>$newgroupfileform},
+ );
+ $communityform = &create_form_ul(&create_list_elements(@communityforma));
- $specialdocumentsform = create_form_ul(create_list_elements(@specialdocumentsforma));
-if($env{'form.pagepath'}) {
-
- @specialdocumentsforma=(
- {''=>$newsmpproblemform},
- {''=>$newexuploadform}
- );
- $specialdocumentsform= create_form_ul(create_list_elements(@specialdocumentsforma));
-}
my @tools = (
# {''=>$extresourcesform},
# {''=>$imspform},
- {''=>$recoverform},
+ {''=>$recoverform},
);
-my @importdoc = (
- {''=>$extresourcesform},
- {''=>$imspform},
-);
-$fileuploadform = create_form_ul(create_list_elements(@importdoc)) . '
' . $fileuploadform;
my %orderhash = (
- '00' => ['Newfolder',$newfolderform],
'aa' => ['Import Documents',$fileuploadform],
'bb' => ['Published Resources',$simpleeditdefaultform],
- 'cc' => ['Special Documents',$specialdocumentsform],
- 'dd' => ['Tools', create_form_ul(create_list_elements(@tools)).&generate_admin_options($containertag,$uploadtag,\%help,\%env)],
+ 'cc' => ['Grading Resources',$gradingform],
+ 'ff' => ['Tools', &create_form_ul(&create_list_elements(@tools)).&generate_admin_options(\%help,\%env)],
);
-my $tid='1';
+unless ($env{'form.pagepath'}) {
+ $orderhash{'00'} = ['Newfolder',$newfolderform];
+ $orderhash{'dd'} = ['Community Resources',$communityform];
+ $orderhash{'ee'} = ['Special Documents',$specialdocumentsform];
+}
+
$hadchanges=0;
- my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype);
- if ($error) {
- $r->print('
' . $supupdocform;
+$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)) . '
' . $supupdocform;
my %suporderhash = (
'00' => ['Supnewfolder', $supnewfolderform],
'ee' => ['Import Documents',$supupdocform],
- 'ff' => ['Special Documents',create_form_ul(create_list_elements(@specialdocs))]
+ 'ff' => ['Special Documents',&create_form_ul(&create_list_elements(@specialdocs))]
);
-
- my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype);
- if ($error) {
- $r->print('".&mt('Uploaded Document').' - '.
&Apache::lonnet::gettitle($r->uri).'