\n");
+ $r->print(&Apache::loncommon::end_data_table());
&untiehash();
$r->print(
- '');
+ '');
}
}
@@ -309,10 +318,10 @@ sub exportcourse {
chdir $cwd;
$outcome .= &mt('Download the zip file from IMS '.lc($type).' archive ',$imszipfile,);
if ($copyresult) {
- $outcome .= 'The following errors occurred during export - '.$copyresult;
+ $outcome .= &mt('The following errors occurred during export - [_1]',$copyresult);
}
} else {
- $outcome = ' 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. ';
+ $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.').' ';
}
}
$r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'));
@@ -818,7 +827,7 @@ sub extract_media {
$dirpath = $url;
$container = '';
}
- &Apache::lonnet::extract_embedded_items(undef,undef,\%allfiles,\%codebase,$content);
+ &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,$content);
foreach my $embed_file (keys(%allfiles)) {
my $filename;
if ($embed_file =~ m#([^/]+)$#) {
@@ -924,7 +933,7 @@ sub group_import {
my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
'output',$1.$2);
if ($result != m|^/uploaded/|) {
- $errtext.='Map not saved: A network error occured when trying to save the new map. ';
+ $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
$fatal = 2;
}
if ($fatal) {
@@ -949,7 +958,7 @@ sub group_import {
}
sub breadcrumbs {
- my ($where)=@_;
+ my ($where,$allowed,$type)=@_;
&Apache::lonhtmlcommon::clear_breadcrumbs();
my (@folders);
if ($env{'form.pagepath'}) {
@@ -963,23 +972,32 @@ sub breadcrumbs {
my $randompick=-1;
my $isencrypted=0;
my $ishidden=0;
+ my $is_random_order=0;
while (@folders) {
my $folder=shift(@folders);
- my $foldername=shift(@folders);
+ my $foldername=shift(@folders);
if ($folderpath) {$folderpath.='&';}
$folderpath.=$folder.'&'.$foldername;
my $url='/adm/coursedocs?folderpath='.
&escape($folderpath);
- my $name=&unescape($foldername);
-# randompick number, hidden, encrypted is appended with ":"s to the foldername
- $name=~s/\:(\d*)\:(\w*)\:(\w*)$//;
- if ($1 ne '') {
+ my $name=&unescape($foldername);
+# randompick number, hidden, encrypted, random order, is appended with ":"s to the foldername
+ $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//;
+ if ($1 ne '') {
$randompick=$1;
} else {
$randompick=-1;
}
if ($2) { $ishidden=1; }
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');
+ }
+ }
&Apache::lonhtmlcommon::add_breadcrumb(
{'href'=>$url.$cpinfo,
'title'=>$name,
@@ -991,7 +1009,7 @@ sub breadcrumbs {
}
$plain=~s/\>\;\s*$//;
return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp',
- 'LC_docs_path'),$randompick,$ishidden,$isencrypted,$plain);
+ 'LC_docs_path'),$randompick,$ishidden,$isencrypted,$plain,$is_random_order);
}
sub log_docs {
@@ -1082,6 +1100,7 @@ sub docs_change_log {
my %lt=('hiddenresource' => 'Resources hidden',
'encrypturl' => 'URL hidden',
'randompick' => 'Randomly pick',
+ 'randomorder' => 'Randomly ordered',
'set' => 'set to',
'del' => 'deleted');
$r->print(&Apache::loncommon::display_filter().
@@ -1164,7 +1183,7 @@ sub docs_change_log {
$r->print('');
if ($docslog{$id}{'logentry'}{'parameter_res'}) {
$r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':
');
- foreach my $parameter ('randompick','hiddenresource','encrypturl') {
+ foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {
if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
$r->print('
'.
&mt($lt{$parameter}.' '.$lt{$docslog{$id}{'logentry'}{'parameter_action_'.$parameter}}.' [_1]',
@@ -1198,12 +1217,15 @@ sub update_paste_buffer {
# Mark for copying
my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
if (&is_supplemental_title($title)) {
+ &Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title});
($title) = &parse_supplemental_title($title);
+ } elsif ($env{'docs.markedcopy_supplemental'}) {
+ &Apache::lonnet::delenv('docs\\.markedcopy_supplemental');
}
$url=~s{http(:|:)//https(:|:)//}{https$2//};
- &Apache::lonnet::appenv('docs.markedcopy_title' => $title,
- 'docs.markedcopy_url' => $url);
+ &Apache::lonnet::appenv({'docs.markedcopy_title' => $title,
+ 'docs.markedcopy_url' => $url});
delete($env{'form.markcopy'});
}
@@ -1224,9 +1246,13 @@ ENDPASTE
&LONCAPA::map::qtescape($env{'docs.markedcopy_url'}).')');
} else {
my $extension = (split(/\./,$env{'docs.markedcopy_url'}))[-1];
- my $type = &Apache::loncommon::filedescription($extension);
- my $icon = '';
+ my $icon = &Apache::loncommon::icon($extension);
+ if ($extension eq 'sequence' &&
+ $env{'docs.markedcopy_url'} =~ m{/default_\d+\.sequence$ }x) {
+ $icon = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
+ $icon .= '/folder_closed.gif';
+ }
+ $icon = '';
$r->print($icon.$type.': '. &parse_supplemental_title(&LONCAPA::map::qtescape($env{'docs.markedcopy_title'})));
}
if ($container eq 'page') {
@@ -1243,7 +1269,7 @@ ENDPASTE
}
sub do_paste_from_buffer {
- my ($coursenum,$coursedom) = @_;
+ my ($coursenum,$coursedom,$folder) = @_;
return 0 if (!$env{'form.pastemarked'});
@@ -1285,6 +1311,20 @@ sub do_paste_from_buffer {
$url = &LONCAPA::map::qtunescape($url);
# Now insert the URL at the bottom
my $newidx = &LONCAPA::map::getresidx($url);
+ if ($env{'docs.markedcopy_supplemental'}) {
+ if ($folder =~ /^supplemental/) {
+ $title = $env{'docs.markedcopy_supplemental'};
+ } else {
+ (undef,undef,$title) =
+ &parse_supplemental_title($env{'docs.markedcopy_supplemental'});
+ }
+ } else {
+ if ($folder=~/^supplemental/) {
+ $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
+ $env{'user.domain'}.'___&&&___'.$title;
+ }
+ }
+
$LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
push(@LONCAPA::map::order, $newidx);
# Store the result
@@ -1292,7 +1332,8 @@ sub do_paste_from_buffer {
my %parameter_type = ( 'randompick' => 'int_pos',
'hiddenresource' => 'string_yesno',
- 'encrypturl' => 'string_yesno',);
+ 'encrypturl' => 'string_yesno',
+ 'randomorder' => 'string_yesno',);
my $valid_parameters_re = join('|',keys(%parameter_type));
# set parameters
sub update_parameter {
@@ -1362,7 +1403,7 @@ sub handle_edit_cmd {
}
sub editor {
- my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$which)=@_;
+ my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$type)=@_;
my $container= ($env{'form.pagepath'}) ? 'page'
: 'sequence';
@@ -1378,8 +1419,8 @@ sub editor {
$LONCAPA::map::resources[$idx]='';
}
- my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain)=
- &breadcrumbs($folder);
+ my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)=
+ &breadcrumbs($folder,$allowed,$type);
$r->print($breadcrumbtrail);
# ------------------------------------------------------------ Process commands
@@ -1404,7 +1445,7 @@ sub editor {
}
if ($env{'form.pastemarked'}) {
- &do_paste_from_buffer($coursenum,$coursedom);
+ &do_paste_from_buffer($coursenum,$coursedom,$folder);
($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
return $errtext if ($fatal);
}
@@ -1452,7 +1493,7 @@ sub editor {
# ---------------------------------------------------------------- Print screen
my $idx=0;
my $shown=0;
- if (($ishidden) || ($isencrypted) || ($randompick>=0)) {
+ if (($ishidden) || ($isencrypted) || ($randompick>=0) || ($is_random_order)) {
$r->print('
':'').
@@ -1462,6 +1503,9 @@ sub editor {
if ($randompick>=0) {
$r->print('
'.&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('
');
foreach my $res (@LONCAPA::map::order) {
my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
@@ -1478,8 +1522,9 @@ sub editor {
$r->print('
'.&mt('Currently no documents.').'
');
}
$r->print("\n
\n");
-
- &print_paste_buffer($r,$container);
+ if ($allowed) {
+ &print_paste_buffer($r,$container);
+ }
return;
}
@@ -1560,8 +1605,8 @@ sub process_file_upload {
$$upload_output .=
'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA. '.
- &ask_for_embedded_content('/adm/coursedocs',
- $state,$allfiles,$codebase);
+ &Apache::loncommon::ask_for_embedded_content(
+ '/adm/coursedocs',$state,$allfiles,$codebase);
} else {
$$upload_output .= 'No embedded items identified ';
}
@@ -1571,55 +1616,6 @@ sub process_file_upload {
return $phase_status;
}
-sub ask_for_embedded_content {
- my ($actionurl,$state,$allfiles,$codebase,$args)=@_;
- my $upload_output = '
-
';
- return $upload_output;
-}
-
sub process_secondary_uploads {
my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;
my $folder=$env{'form.folder'};
@@ -1691,7 +1687,6 @@ sub entryline {
my $line='
';
my ($form_start,$form_end);
# Edit commands
- my $container;
my ($container, $type, $esc_path, $path, $symb);
if ($env{'form.folderpath'}) {
$type = 'folder';
@@ -1744,7 +1739,7 @@ sub entryline {
# no copy for published maps
$nocopy = 1;
} else {
- foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url))) {
+ foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
my ($title,$url,$ext,$type)=split(/\:/,$_);
if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
$nocopy=1;
@@ -1884,7 +1879,7 @@ END
$url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
}
}
- my $parameterset=' ';
+ my ($parameterset,$rand_order_text) = (' ', ' ');
if ($isfolder || $extension eq 'sequence') {
my $foldername=&escape($foldertitle);
my $folderpath=$env{'form.folderpath'};
@@ -1896,7 +1891,9 @@ END
.':'.((&LONCAPA::map::getparameter($orderidx,
'parameter_hiddenresource'))[0]=~/^yes$/i)
.':'.((&LONCAPA::map::getparameter($orderidx,
- 'parameter_encrypturl'))[0]=~/^yes$/i);
+ 'parameter_encrypturl'))[0]=~/^yes$/i)
+ .':'.((&LONCAPA::map::getparameter($orderidx,
+ 'parameter_randomorder'))[0]=~/^yes$/i);
$url.='folderpath='.&escape($folderpath).$cpinfo;
$parameterset='';
-
+ my $ro_set=
+ ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
+ $rand_order_text ='
+';
}
if ($ispage) {
my $pagename=&escape($pagetitle);
@@ -1956,6 +1956,7 @@ END
$form_end
+
$form_start $rand_order_text $form_end
$form_start $parameterset $form_end
ENDPARMS
}
@@ -1998,6 +1999,9 @@ sub checkonthis {
$r->rflush();
if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
$r->print("\n ");
+ if ($level==0) {
+ $r->print(" ");
+ }
for (my $i=0;$i<=$level*5;$i++) {
$r->print(' ');
}
@@ -2007,7 +2011,7 @@ sub checkonthis {
my $result=&Apache::lonnet::repcopy(
&Apache::lonnet::filelocation('',$url));
if ($result eq 'ok') {
- $r->print(''.&mt('ok').'');
+ $r->print(''.&mt('ok').'');
$r->rflush();
&Apache::lonnet::countacc($url);
$url=~/\.(\w+)$/;
@@ -2017,7 +2021,7 @@ sub checkonthis {
for (my $i=0;$i<=$level*5;$i++) {
$r->print(' ');
}
- $r->print('- '.&mt('Rendering').': ');
+ $r->print('- '.&mt('Rendering:').' ');
my ($errorcount,$warningcount)=split(/:/,
&Apache::lonnet::ssi_body($url,
('grade_target'=>'web',
@@ -2026,13 +2030,11 @@ sub checkonthis {
($warningcount)) {
if ($errorcount) {
$r->print(''.
- $errorcount.' '.
- &mt('error(s)').' ');
+ &mt('[quant,_1,error]',$errorcount).'');
}
if ($warningcount) {
$r->print(''.
- $warningcount.' '.
- &mt('warning(s)').'');
+ &mt('[quant,_1,warning]',$warningcount).'');
}
} else {
$r->print(''.&mt('ok').'');
@@ -2050,15 +2052,15 @@ sub checkonthis {
$r->print(''.&mt('connection down').'');
} elsif ($result eq 'not_found') {
unless ($url=~/\$/) {
- $r->print(''.&mt('not found').'');
+ $r->print(''.&mt('not found').'');
} else {
$r->print(''.&mt('unable to verify variable URL').'');
}
} else {
$r->print(''.&mt('access denied').'');
}
- }
- }
+ }
+ }
}
@@ -2423,7 +2425,7 @@ sub init_breadcrumbs {
my ($form,$text)=@_;
&Apache::lonhtmlcommon::clear_breadcrumbs();
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs",
- text=>&Apache::loncommon::course_type()." Documents",
+ text=>"Edit ".&Apache::loncommon::course_type(),
faq=>273,
bug=>'Instructor Interface',
help => 'Docs_Adding_Course_Doc'});
@@ -2497,6 +2499,26 @@ sub handler {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['folderpath','pagepath',
'pagesymb']);
+# No folderpath, no pagepath, see if we have something stored
+ if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
+ &Apache::loncommon::restore_course_settings('docs_folderpath',
+ {'folderpath' => 'scalar'});
+ }
+ if (!$env{'form.folderpath'}) {
+ &Apache::loncommon::restore_course_settings('docs_folderpath',
+ {'pagepath' => 'scalar'});
+ }
+ if ($env{'form.pagepath'}) {
+ $env{'form.folderpath'}='';
+ }
+ if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
+ $env{'form.folderpath'} = 'supplemental&'.
+ &escape(&mt('Supplemental '.$type.' Documents')).'&'.
+ $env{'form.folderpath'};
+ }
+ &Apache::loncommon::store_course_settings('docs_folderpath',
+ {'pagepath' => 'scalar',
+ 'folderpath' => 'scalar'});
if ($env{'form.folderpath'}) {
my (@folderpath)=split('&',$env{'form.folderpath'});
$env{'form.foldername'}=&unescape(pop(@folderpath));
@@ -2558,9 +2580,13 @@ sub handler {
if (($env{'form.uploaddoc.filename'}) &&
($env{'form.cmd'}=~/^upload_(\w+)/)) {
# Process file upload - phase one - upload and parse primary file.
+ undef($hadchanges);
$upload_result = &process_file_upload(\$upload_output,$coursenum,
$coursedom,\%allfiles,
\%codebase,$1);
+ if ($hadchanges) {
+ &mark_hash_old();
+ }
if ($upload_result eq 'phasetwo') {
$r->print($upload_output);
}
@@ -2754,7 +2780,7 @@ ENDCOURSEVERIFY
}
$hadchanges=0;
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,
- $upload_output);
+ $upload_output,$type);
if ($error) {
$r->print('