');
+# Before
+ for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
+ my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
+ my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
+ if ($oldname ne $newname) {
+ $r->print(&LONCAPA::map::qtunescape($oldname));
+ }
+ }
+# After
+ $r->print('
');
+
+ for (my $idx=0;$idx<=$docslog{$id}{'logentry'}{'maxidx'};$idx++) {
+ my $oldname=(split(/\:/,$docslog{$id}{'logentry'}{'before_resources_'.$idx}))[0];
+ my $newname=(split(/\:/,$docslog{$id}{'logentry'}{'after_resources_'.$idx}))[0];
+ if ($oldname ne $newname) {
+ $r->print(&LONCAPA::map::qtunescape($newname));
+ }
+ }
+# End
+ $r->print('
'.&Apache::loncommon::end_data_table_row());
+ $shown++;
+ if (!($env{'form.show'} eq &mt('all')
+ || $shown<=$env{'form.show'})) { last; }
+ }
+ $r->print(&Apache::loncommon::end_data_table());
+ $r->print(&Apache::loncommon::end_page());
+}
+
+sub editor {
+ my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output)=@_;
my $errtext='';
my $fatal=0;
+ my $container='sequence';
+ if ($env{'form.pagepath'}) {
+ $container='page';
+ }
($errtext,$fatal)=
- &mapread($coursenum,$coursedom,$folder.'.sequence');
- if ($#Apache::lonratedt::order<1) {
- $Apache::lonratedt::order[0]=1;
- $Apache::lonratedt::resources[1]='';
+ &mapread($coursenum,$coursedom,$folder.'.'.$container);
+ if ($#LONCAPA::map::order<1) {
+ my $idx=&LONCAPA::map::getresidx();
+ if ($idx<=0) { $idx=1; }
+ $LONCAPA::map::order[0]=$idx;
+ $LONCAPA::map::resources[$idx]='';
+ }
+ if (defined($env{'form.markcopy'})) {
+# Mark for copying
+ my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
+ $env{'form.markedcopy_title'}=$title;
+ $env{'form.markedcopy_url'}=$url;
}
+ my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain)=&breadcrumbs($folder);
+ $r->print($breadcrumbtrail);
if ($fatal) {
$r->print('
'.$errtext.'
');
} else {
# ------------------------------------------------------------ Process commands
# ---------------- if they are for this folder and user allowed to make changes
- if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
+ if (($allowed) && ($env{'form.folder'} eq $folder)) {
# set parameters and change order
- if (defined($ENV{'form.setparms'})) {
- my $idx=$ENV{'form.setparms'};
+ &snapshotbefore();
+ if ($env{'form.changeparms'}) {
+ my $idx=$env{'form.setparms'};
# set parameters
- if ($ENV{'form.randpick_'.$idx}) {
- &Apache::lonratedt::storeparameter($idx,'parameter_randompick',$ENV{'form.randpick_'.$idx},'int_pos');
- } else {
- &Apache::lonratedt::delparameter($idx,'parameter_randompick');
- }
- if ($ENV{'form.hidprs_'.$idx}) {
- &Apache::lonratedt::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno');
+ if ($env{'form.randpick_'.$idx}) {
+ &LONCAPA::map::storeparameter($idx,'parameter_randompick',$env{'form.randpick_'.$idx},'int_pos');
+ &remember_parms($idx,'randompick','set',$env{'form.randpick_'.$idx});
} else {
- &Apache::lonratedt::delparameter($idx,'parameter_hiddenresource');
+ &LONCAPA::map::delparameter($idx,'parameter_randompick');
+ &remember_parms($idx,'randompick','del');
}
- if ($ENV{'form.encprs_'.$idx}) {
- &Apache::lonratedt::storeparameter($idx,'parameter_encrypturl','yes','string_yesno');
- } else {
- &Apache::lonratedt::delparameter($idx,'parameter_encrypturl');
+ if ($env{'form.hidprs_'.$idx}) {
+ &LONCAPA::map::storeparameter($idx,'parameter_hiddenresource','yes','string_yesno');
+ &remember_parms($idx,'hiddenresource','set',$env{'form.hidprs_'.$idx});
+ } else {
+ &LONCAPA::map::delparameter($idx,'parameter_hiddenresource');
+ &remember_parms($idx,'hiddenresource','del');
+ }
+ if ($env{'form.encprs_'.$idx}) {
+ &LONCAPA::map::storeparameter($idx,'parameter_encrypturl','yes','string_yesno');
+ &remember_parms($idx,'encrypturl','set',$env{'form.encprs_'.$idx});
+ } else {
+ &LONCAPA::map::delparameter($idx,'parameter_encrypturl');
+ &remember_parms($idx,'encrypturl','del');
+ }
+# store the changed version
+ ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
+ if ($fatal) {
+ $r->print('
'.$errtext.'
');
+ return;
}
+ }
- if ($ENV{'form.newpos'}) {
+ if ($env{'form.newpos'}) {
# change order
-
- my $newpos=$ENV{'form.newpos'}-1;
- my $currentpos=$ENV{'form.currentpos'}-1;
- my $i;
- my @neworder=();
- if ($newpos>$currentpos) {
+ my $newpos=$env{'form.newpos'}-1;
+ my $currentpos=$env{'form.currentpos'}-1;
+ my $i;
+ my @neworder=();
+ if ($newpos>$currentpos) {
# moving stuff up
- for ($i=0;$i<$currentpos;$i++) {
- $neworder[$i]=$Apache::lonratedt::order[$i];
- }
- for ($i=$currentpos;$i<$newpos;$i++) {
- $neworder[$i]=$Apache::lonratedt::order[$i+1];
- }
- $neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
- for ($i=$newpos+1;$i<=$#Apache::lonratedt::order;$i++) {
- $neworder[$i]=$Apache::lonratedt::order[$i];
- }
- } else {
+ for ($i=0;$i<$currentpos;$i++) {
+ $neworder[$i]=$LONCAPA::map::order[$i];
+ }
+ for ($i=$currentpos;$i<$newpos;$i++) {
+ $neworder[$i]=$LONCAPA::map::order[$i+1];
+ }
+ $neworder[$newpos]=$LONCAPA::map::order[$currentpos];
+ for ($i=$newpos+1;$i<=$#LONCAPA::map::order;$i++) {
+ $neworder[$i]=$LONCAPA::map::order[$i];
+ }
+ } else {
# moving stuff down
- for ($i=0;$i<$newpos;$i++) {
- $neworder[$i]=$Apache::lonratedt::order[$i];
- }
- $neworder[$newpos]=$Apache::lonratedt::order[$currentpos];
- for ($i=$newpos+1;$i<$currentpos+1;$i++) {
- $neworder[$i]=$Apache::lonratedt::order[$i-1];
- }
- for ($i=$currentpos+1;$i<=$#Apache::lonratedt::order;$i++) {
- $neworder[$i]=$Apache::lonratedt::order[$i];
- }
+ for ($i=0;$i<$newpos;$i++) {
+ $neworder[$i]=$LONCAPA::map::order[$i];
+ }
+ $neworder[$newpos]=$LONCAPA::map::order[$currentpos];
+ for ($i=$newpos+1;$i<$currentpos+1;$i++) {
+ $neworder[$i]=$LONCAPA::map::order[$i-1];
+ }
+ for ($i=$currentpos+1;$i<=$#LONCAPA::map::order;$i++) {
+ $neworder[$i]=$LONCAPA::map::order[$i];
}
- @Apache::lonratedt::order=@neworder;
}
+ @LONCAPA::map::order=@neworder;
# store the changed version
-
- ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.sequence');
+ ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
if ($fatal) {
$r->print('
'.$errtext.'
');
return;
}
-
}
+
+ if ($env{'form.pastemarked'}) {
+# paste resource to end of list
+ my $url=$env{'form.markedcopy_url'};
+ my $title=$env{'form.markedcopy_title'};
+# Maps need to be copied first
+ if (($url=~/\.(page|sequence)$/) || ($url=~/^\/uploaded\//)) {
+ $title=&mt('Copy of').' '.$title;
+ my $newid=$$.time;
+ $url=~/^(.+)\.(\w+)$/;
+ my $newurl=$1.$newid.'.'.$2;
+ my $storefn=$newurl;
+ $storefn=~s/^\/\w+\/\w+\/\w+\///;
+ &Apache::lonclonecourse::writefile
+ ($env{'request.course.id'},$storefn,
+ &Apache::lonnet::getfile($url));
+ $url=$newurl;
+ }
+ $title=~s/\\<\;/g;
+ $title=~s/\>/\>\;/g;
+ $title=~s/\:/\:/g;
+ my $ext='false';
+ if ($url=~/^http\:\/\//) { $ext='true'; }
+ $url=~s/\:/\:/g;
+# Now insert the URL at the bottom
+ my $newidx=&LONCAPA::map::getresidx($url);
+ $LONCAPA::map::resources[$newidx]=
+ $title.':'.$url.':'.$ext.':normal:res';
+ $LONCAPA::map::order[1+$#LONCAPA::map::order]=$newidx;
+# Store the result
+ ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);
+ if ($fatal) {
+ $r->print('
'.$errtext.'
');
+ return;
+ }
-# upload a file, if present
- if (($ENV{'form.uploaddoc.filename'}) &&
- ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
- if ( ($folder=~/^$1/) || ($1 eq 'default') ) {
-# this is for a course, not a user, so set coursedoc flag
-# probably the only place in the system where this should be "1"
- my $url=&Apache::lonnet::userfileupload('uploaddoc',1,'docs');
- my $ext='false';
- if ($url=~/^http\:\/\//) { $ext='true'; }
- $url=~s/\:/\:/g;
- my $comment=$ENV{'form.comment'};
- $comment=~s/\\<\;/g;
- $comment=~s/\>/\>\;/g;
- $comment=~s/\:/\:/g;
- if ($folder=~/^supplemental/) {
- $comment=time.'___&&&___'.$ENV{'user.name'}.'___&&&___'.
- $ENV{'user.domain'}.'___&&&___'.$comment;
- }
- my $newidx=$#Apache::lonratedt::resources+1;
- $Apache::lonratedt::resources[$newidx]=
- $comment.':'.$url.':'.$ext.':normal:res';
- $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=
- $newidx;
-
- ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.sequence');
- if ($fatal) {
- $r->print('
'.$errtext.'
');
- return;
- }
- }
- }
- if ($ENV{'form.cmd'}) {
- my ($cmd,$idx)=split(/\_/,$ENV{'form.cmd'});
+ }
+ $r->print($upload_output);
+ if ($env{'form.cmd'}) {
+ my ($cmd,$idx)=split(/\_/,$env{'form.cmd'});
if ($cmd eq 'del') {
- my (undef,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$idx]]);
- if ($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) {
+ my (undef,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]);
+ if (($url=~m|/+uploaded/\Q$coursedom\E/\Q$coursenum\E/|) &&
+ ($url!~/\.(page|sequence|problem|exam|quiz|assess|survey|form|library|task)$/)) {
&Apache::lonnet::removeuploadedurl($url);
+ } else {
+ &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
}
- for (my $i=$idx;$i<$#Apache::lonratedt::order;$i++) {
- $Apache::lonratedt::order[$i]=
- $Apache::lonratedt::order[$i+1];
+ for (my $i=$idx;$i<$#LONCAPA::map::order;$i++) {
+ $LONCAPA::map::order[$i] = $LONCAPA::map::order[$i+1];
+ }
+ $#LONCAPA::map::order--;
+ } elsif ($cmd eq 'cut') {
+ my (undef,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$idx]]);
+ &LONCAPA::map::makezombie($LONCAPA::map::order[$idx]);
+ for (my $i=$idx;$i<$#LONCAPA::map::order;$i++) {
+ $LONCAPA::map::order[$i] = $LONCAPA::map::order[$i+1];
}
- $#Apache::lonratedt::order--;
+ $#LONCAPA::map::order--;
} elsif ($cmd eq 'up') {
- if (($idx) && (defined($Apache::lonratedt::order[$idx-1]))) {
- my $i=$Apache::lonratedt::order[$idx-1];
- $Apache::lonratedt::order[$idx-1]=
- $Apache::lonratedt::order[$idx];
- $Apache::lonratedt::order[$idx]=$i;
+ if (($idx) && (defined($LONCAPA::map::order[$idx-1]))) {
+ my $i=$LONCAPA::map::order[$idx-1];
+ $LONCAPA::map::order[$idx-1] = $LONCAPA::map::order[$idx];
+ $LONCAPA::map::order[$idx] = $i;
}
} elsif ($cmd eq 'down') {
- if (defined($Apache::lonratedt::order[$idx+1])) {
- my $i=$Apache::lonratedt::order[$idx+1];
- $Apache::lonratedt::order[$idx+1]=
- $Apache::lonratedt::order[$idx];
- $Apache::lonratedt::order[$idx]=$i;
+ if (defined($LONCAPA::map::order[$idx+1])) {
+ my $i=$LONCAPA::map::order[$idx+1];
+ $LONCAPA::map::order[$idx+1] = $LONCAPA::map::order[$idx];
+ $LONCAPA::map::order[$idx] = $i;
}
} elsif ($cmd eq 'rename') {
+ my $ratstr = $LONCAPA::map::resources[$LONCAPA::map::order[$idx]];
my ($rtitle,@rrest)=split(/\:/,
- $Apache::lonratedt::resources[
- $Apache::lonratedt::order[$idx]]);
+ $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]);
my $comment=
- &HTML::Entities::decode($ENV{'form.title'});
+ &HTML::Entities::decode($env{'form.title'});
$comment=~s/\\<\;/g;
$comment=~s/\>/\>\;/g;
$comment=~s/\:/\:/g;
- $Apache::lonratedt::resources[
- $Apache::lonratedt::order[$idx]]=
- $comment.':'.join(':',@rrest);
-
+ if ($comment=~/\S/) {
+ $LONCAPA::map::resources[$LONCAPA::map::order[$idx]]=
+ $comment.':'.join(':',@rrest);
+ }
+# Devalidate title cache
+ my $renamed_url=$rrest[0];
+# Has the :-escaping
+ $renamed_url=~s/\&colon\;/\:/g;
+ &Apache::lonnet::devalidate_title_cache($renamed_url);
}
# Store the changed version
($errtext,$fatal)=&storemap($coursenum,$coursedom,
- $folder.'.sequence');
+ $folder.'.'.$container);
if ($fatal) {
$r->print('
'.$errtext.'
');
return;
}
}
# Group import/search
- if ($ENV{'form.importdetail'}) {
+ if ($env{'form.importdetail'}) {
my @imports;
- foreach (split(/\&/,$ENV{'form.importdetail'})) {
+# &Apache::lonnet::logthis("imp detail ".$env{'form.importdetail'});
+ foreach (split(/\&/,$env{'form.importdetail'})) {
if (defined($_)) {
my ($name,$url)=split(/\=/,$_);
- $name=&Apache::lonnet::unescape($name);
- $url=&Apache::lonnet::unescape($url);
+ $name=&unescape($name);
+ $url=&unescape($url);
push @imports, $name, $url;
}
}
# Store the changed version
- ($errtext,$fatal)=group_import($coursenum, $coursedom, $folder,
- @imports);
+ ($errtext,$fatal)=&group_import($coursenum, $coursedom, $folder,
+ $container,'londocs',@imports);
if ($fatal) {
$r->print('
'.$errtext.'
');
return;
}
}
# Loading a complete map
- if (($ENV{'form.importmap'}) && ($ENV{'form.loadmap'})) {
- foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) {
- my $idx=$#Apache::lonratedt::resources;
- $idx++;
- $Apache::lonratedt::resources[$idx]=$_;
- $Apache::lonratedt::order
- [$#Apache::lonratedt::order+1]=$idx;
- }
-
+ if ($env{'form.loadmap'}) {
+ if ($env{'form.importmap'}=~/\w/) {
+ foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
+ my ($title,$url,$ext,$type)=split(/\:/,$_);
+ my $idx=&LONCAPA::map::getresidx($url);
+ $LONCAPA::map::resources[$idx]=$_;
+ $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx;
+ }
# Store the changed version
- ($errtext,$fatal)=&storemap($coursenum,$coursedom,
- $folder.'.sequence');
- if ($fatal) {
- $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.').'
\n");
+ $r->print(''.&mt('Return to DOCS').'');
+}
+
+
+#
# -------------------------------------------------------------- Verify Content
#
sub verifycontent {
- my $r=shift;
+ my ($r) = @_;
+ my $type = &Apache::loncommon::course_type();
my $loaderror=&Apache::lonnet::overloaderror($r);
if ($loaderror) { return $loaderror; }
-
- $r->print('Verify Content'.
- &Apache::loncommon::bodytag('Verify Course Documents'));
+ $r->print(&Apache::loncommon::start_page('Verify '.$type.' Documents'));
$hashtied=0;
undef %alreadyseen;
%alreadyseen=();
&tiehash();
foreach (keys %hash) {
- if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) {
+ if ($hash{$_}=~/\.(page|sequence)$/) {
+ if (($_=~/^src_/) && ($alreadyseen{&unescape($hash{$_})})) {
+ $r->print(''.
+ &mt('The following sequence or page is included more than once in your '.$type.': ').
+ &unescape($hash{$_}).' '.
+ &mt('Note that grading records for problems included in this sequence or folder will overlap.'));
+ }
+ }
+ if (($_=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$_})})) {
&checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
}
}
@@ -756,12 +1999,19 @@ sub verifycontent {
&mt('Return to DOCS').'');
}
+
# -------------------------------------------------------------- Check Versions
+sub devalidateversioncache {
+ my $src=shift;
+ &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
+ &Apache::lonnet::clutter($src));
+}
+
sub checkversions {
- my $r=shift;
- $r->print('Check Versions'.
- &Apache::loncommon::bodytag('Check Course Document Versions'));
+ my ($r) = @_;
+ my $type = &Apache::loncommon::course_type();
+ $r->print(&Apache::loncommon::start_page("Check $type Document Versions"));
my $header='';
my $startsel='';
my $monthsel='';
@@ -772,53 +2022,57 @@ sub checkversions {
my $starttime=0;
my $haschanged=0;
my %setversions=&Apache::lonnet::dump('resourceversions',
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'});
$hashtied=0;
&tiehash();
my %newsetversions=();
- if ($ENV{'form.setmostrecent'}) {
+ if ($env{'form.setmostrecent'}) {
$haschanged=1;
foreach (keys %hash) {
if ($_=~/^ids\_(\/res\/.+)$/) {
$newsetversions{$1}='mostrecent';
+ &devalidateversioncache($1);
}
}
- } elsif ($ENV{'form.setcurrent'}) {
+ } elsif ($env{'form.setcurrent'}) {
$haschanged=1;
foreach (keys %hash) {
if ($_=~/^ids\_(\/res\/.+)$/) {
my $getvers=&Apache::lonnet::getversion($1);
if ($getvers>0) {
$newsetversions{$1}=$getvers;
+ &devalidateversioncache($1);
}
}
}
- } elsif ($ENV{'form.setversions'}) {
+ } elsif ($env{'form.setversions'}) {
$haschanged=1;
- foreach (keys %ENV) {
+ foreach (keys %env) {
if ($_=~/^form\.set_version_(.+)$/) {
my $src=$1;
- if (($ENV{$_}) && ($ENV{$_} ne $setversions{$src})) {
- $newsetversions{$src}=$ENV{$_};
+ if (($env{$_}) && ($env{$_} ne $setversions{$src})) {
+ $newsetversions{$src}=$env{$_};
+ &devalidateversioncache($src);
}
}
}
}
if ($haschanged) {
if (&Apache::lonnet::put('resourceversions',\%newsetversions,
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'}) eq 'ok') {
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'}) eq 'ok') {
$r->print('
'.&mt('Your Version Settings have been Stored').'
');
} else {
$r->print('
'.&mt('An Error Occured while Attempting to Store your Version Settings').'
');
}
- &changewarning($r,'');
+ &mark_hash_old();
}
- if ($ENV{'form.timerange'} eq 'all') {
+ &changewarning($r,'');
+ if ($env{'form.timerange'} eq 'all') {
# show all documents
- $header=&mt('All Documents in Course');
+ $header=&mt('All Documents in '.$type);
$allsel=1;
foreach (keys %hash) {
if ($_=~/^ids\_(\/res\/.+)$/) {
@@ -829,28 +2083,28 @@ sub checkversions {
} else {
# show documents which changed
%changes=&Apache::lonnet::dump
- ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+ ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'});
my $firstkey=(keys %changes)[0];
unless ($firstkey=~/^error\:/) {
- unless ($ENV{'form.timerange'}) {
- $ENV{'form.timerange'}=604800;
+ unless ($env{'form.timerange'}) {
+ $env{'form.timerange'}=604800;
}
- my $seltext=&mt('during the last').' '.$ENV{'form.timerange'}.' '
+ my $seltext=&mt('during the last').' '.$env{'form.timerange'}.' '
.&mt('seconds');
- if ($ENV{'form.timerange'}==-1) {
+ if ($env{'form.timerange'}==-1) {
$seltext='since start of course';
$startsel='selected';
- $ENV{'form.timerange'}=time;
+ $env{'form.timerange'}=time;
}
- $starttime=time-$ENV{'form.timerange'};
- if ($ENV{'form.timerange'}==2592000) {
+ $starttime=time-$env{'form.timerange'};
+ if ($env{'form.timerange'}==2592000) {
$seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
$monthsel='selected';
- } elsif ($ENV{'form.timerange'}==604800) {
+ } elsif ($env{'form.timerange'}==604800) {
$seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
$weeksel='selected';
- } elsif ($ENV{'form.timerange'}==86400) {
+ } elsif ($env{'form.timerange'}==86400) {
$seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
$daysel='selected';
}
@@ -860,10 +2114,10 @@ sub checkversions {
}
}
%setversions=&Apache::lonnet::dump('resourceversions',
- $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
- $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+ $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 Course',
+ ('st' => 'Version changes since start of '.$type,
'lm' => 'Version changes since last Month',
'lw' => 'Version changes since last Week',
'sy' => 'Version changes since Yesterday',
@@ -872,9 +2126,9 @@ sub checkversions {
'fi' => 'File',
'md' => 'Modification Date',
'mr' => 'Most recently published Version',
- 've' => 'Version used in Course',
- 'vu' => 'Set Version to be used in Course',
-'sv' => 'Set Versions to be used in Course according to Selections below',
+ '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',
'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
'di' => 'Differences');
@@ -921,7 +2175,7 @@ ENDHEADERS
'
Most Recent: '.
''.$currentversion.''.
'
'.
- '
In Course: '.
+ '
In '.$type.': '.
'');
# Used in course
my $usedversion=$hash{'version_'.$linkurl};
@@ -935,7 +2189,9 @@ ENDHEADERS
# Set version
$r->print(&Apache::loncommon::select_form($setversions{$linkurl},
'set_version_'.$linkurl,
- ('' => '',
+ ('select_form_order' =>
+ ['',1..$currentversion,'mostrecent'],
+ '' => '',
'mostrecent' => 'most recent',
map {$_,$_} (1..$currentversion))));
$r->print('
');
@@ -996,19 +2252,55 @@ ENDHEADERS
&untiehash();
}
+sub mark_hash_old {
+ my $retie_hash=0;
+ if ($hashtied) {
+ $retie_hash=1;
+ &untiehash();
+ }
+ &tiehash('write');
+ $hash{'old'}=1;
+ &untiehash();
+ if ($retie_hash) { &tiehash(); }
+}
+
+sub is_hash_old {
+ my $untie_hash=0;
+ if (!$hashtied) {
+ $untie_hash=1;
+ &tiehash();
+ }
+ my $return=$hash{'old'};
+ if ($untie_hash) { &untiehash(); }
+ return $return;
+}
+
sub changewarning {
- my ($r,$postexec)=@_;
- $r->print(
-''.
-'');
+&mt($message,' ').
+$help{'Caching'}.''."\n\n");
}
# ================================================================ Main Handler
@@ -1017,15 +2309,17 @@ sub handler {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
return OK if $r->header_only;
+ my $type = &Apache::loncommon::course_type();
# --------------------------------------------- Initialize help topics for this
- foreach ('Adding_Course_Doc','Main_Course_Documents',
- 'Adding_External_Resource','Navigate_Content',
- 'Adding_Folders','Docs_Overview', 'Load_Map',
- 'Supplemental', 'Score_Upload_Form',
- 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive') {
- $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
- }
+ foreach ('Adding_Course_Doc','Main_Course_Documents',
+ 'Adding_External_Resource','Navigate_Content',
+ 'Adding_Folders','Docs_Overview', 'Load_Map',
+ 'Supplemental','Score_Upload_Form','Adding_Pages',
+ 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
+ 'Check_Resource_Versions','Verify_Content') {
+ $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
+ }
# Composite help files
$help{'Syllabus'} = &Apache::loncommon::help_open_topic(
'Docs_About_Syllabus,Docs_Editing_Templated_Pages');
@@ -1038,206 +2332,196 @@ sub handler {
$help{'My Personal Info'} = &Apache::loncommon::help_open_topic(
'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
$help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
-
- if ($ENV{'form.verify'}) {
+
+# does this user have privileges to modify docs
+ my $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
+
+ if ($allowed && $env{'form.verify'}) {
&verifycontent($r);
- } elsif ($ENV{'form.versions'}) {
+ } elsif ($allowed && $env{'form.listsymbs'}) {
+ &list_symbs($r);
+ } elsif ($allowed && $env{'form.docslog'}) {
+ &docs_change_log($r);
+ } elsif ($allowed && $env{'form.versions'}) {
&checkversions($r);
- } elsif ($ENV{'form.dumpcourse'}) {
+ } elsif ($allowed && $env{'form.dumpcourse'}) {
&dumpcourse($r);
+ } elsif ($allowed && $env{'form.exportcourse'}) {
+ &exportcourse($r);
} else {
# is this a standard course?
- my $standard=($ENV{'request.course.uri'}=~/^\/uploaded\//);
- my $forcestandard;
+ my $standard=($env{'request.course.uri'}=~/^\/uploaded\//);
+ my $forcestandard = 0;
my $forcesupplement;
my $script='';
- my $allowed;
- my $events='';
my $showdoc=0;
+ my $containertag;
+ my $uploadtag;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['folderpath']);
- if ($ENV{'form.folderpath'}) {
- my (@folderpath)=split('&',$ENV{'form.folderpath'});
- $ENV{'form.foldername'}=&Apache::lonnet::unescape(pop(@folderpath));
- $ENV{'form.folder'}=pop(@folderpath);
- }
+ ['folderpath','pagepath',
+ 'pagesymb','markedcopy_url',
+ 'markedcopy_title']);
+ if ($env{'form.folderpath'}) {
+ my (@folderpath)=split('&',$env{'form.folderpath'});
+ $env{'form.foldername'}=&unescape(pop(@folderpath));
+ $env{'form.folder'}=pop(@folderpath);
+ }
+ if ($env{'form.pagepath'}) {
+ my (@pagepath)=split('&',$env{'form.pagepath'});
+ $env{'form.pagename'}=&unescape(pop(@pagepath));
+ $env{'form.folder'}=pop(@pagepath);
+ $containertag = ''.
+ '';
+ $uploadtag = ''.
+ '';
+ }
if ($r->uri=~/^\/adm\/coursedocs\/showdoc\/(.*)$/) {
$showdoc='/'.$1;
}
unless ($showdoc) { # got called from remote
- $forcestandard=($ENV{'form.folder'}=~/^default_/);
- $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
+ if (($env{'form.folder'}=~/^(?:group|default)_/) ||
+ ($env{'form.folder'} =~ m:^\d+/(pages|sequences)/:)) {
+ $forcestandard = 1;
+ }
+ $forcesupplement=($env{'form.folder'}=~/^supplemental_/);
-# does this user have privileges to post, etc?
- $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
if ($allowed) {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
$script=&Apache::lonratedt::editscript('simple');
}
} else { # got called in sequence from course
$allowed=0;
- $script=''.&Apache::lonmenu::registerurl(1,undef).'
-ENDDOCUMENT
- if ($allowed) {
- $r->print(<
-function makenewfolder(targetform,folderseq) {
- var foldername=prompt('Name of New Folder','New Folder');
- if (foldername) {
- targetform.importdetail.value=foldername+"="+folderseq;
- targetform.submit();
- }
-}
-
-function makenewext(targetname) {
- this.document.forms.extimport.useform.value=targetname;
- window.open('/adm/rat/extpickframe.html');
-}
-
-function makeexamupload() {
- var title=prompt('Listed Title for the Uploaded Score');
- if (title) {
- this.document.forms.newexamupload.importdetail.value=
- title+'=/res/lib/templates/examupload.problem';
- this.document.forms.newexamupload.submit();
- }
-}
-
-function makesmppage() {
- var title=prompt('Listed Title for the Page');
- if (title) {
- this.document.forms.newsmppg.importdetail.value=
- title+'=/adm/$udom/$uname/$now/smppg';
- this.document.forms.newsmppg.submit();
- }
-}
-
-function makesmpproblem() {
- var title=prompt('Listed Title for the Problem');
- if (title) {
- this.document.forms.newsmpproblem.importdetail.value=
- title+'=/res/lib/templates/simpleproblem.problem';
- this.document.forms.newsmpproblem.submit();
- }
-}
-
-function makebulboard() {
- var title=prompt('Listed Title for the Bulletin Board');
- if (title) {
- this.document.forms.newbul.importdetail.value=
- title+'=/adm/$udom/$uname/$now/bulletinboard';
- this.document.forms.newbul.submit();
- }
-}
-
-function makeabout() {
- var user=prompt("Enter user\@domain for User's 'About Me' Page");
- if (user) {
- var comp=new Array();
- comp=user.split('\@');
- if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) {
- if ((comp[0]) && (comp[1])) {
- this.document.forms.newaboutsomeone.importdetail.value=
- 'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme';
- this.document.forms.newaboutsomeone.submit();
- }
- }
- }
-}
-
-function makeims() {
- var caller = document.forms.ims.folder.value
- var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one"
- newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes")
- newWindow.location.href = newlocation
-}
-
-
-function finishpick() {
- var title=this.document.forms.extimport.title.value;
- var url=this.document.forms.extimport.url.value;
- var form=this.document.forms.extimport.useform.value;
- eval
- ('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+
- '";this.document.forms.'+form+'.submit();');
-}
-
-function changename(folderpath,index,oldtitle) {
- var title=prompt('New Title',oldtitle);
- if (title) {
- this.document.forms.renameform.title.value=title;
- this.document.forms.renameform.cmd.value='rename_'+index;
- this.document.forms.renameform.folderpath.value=folderpath;
- this.document.forms.renameform.submit();
- }
-}
+ $iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
-function removeres(folderpath,index,oldtitle) {
- if (confirm('Remove "'+oldtitle+'"?')) {
- this.document.forms.renameform.cmd.value='del_'+index;
- this.document.forms.renameform.folderpath.value=folderpath;
- this.document.forms.renameform.submit();
+ if ($allowed) {
+ $script .= &editing_js($udom,$uname);
}
-}
-
-
-
-ENDNEWSCRIPT
- }
# -------------------------------------------------------------------- Body tag
- $r->print(''.
- &Apache::loncommon::bodytag('Course Documents','',$events,
- '','',$showdoc).
- &Apache::loncommon::help_open_faq(273).
- &Apache::loncommon::help_open_bug('RAT'));
- unless ($showdoc) {
+ $script = '';
+ $r->print(&Apache::loncommon::start_page("$type Documents", $script,
+ {'force_register' => $showdoc,}).
+ &Apache::loncommon::help_open_menu('','',273,'RAT'));
+
+ my %allfiles = ();
+ my %codebase = ();
+ my ($upload_result,$upload_output);
+ if ($allowed) {
+ if (($env{'form.uploaddoc.filename'}) && ($env{'form.cmd'}=~/^upload_(\w+)/)) {
+# Process file upload - phase one - upload and parse primary file.
+ $upload_result = &process_file_upload(\$upload_output,$coursenum,
+ $coursedom,\%allfiles,
+ \%codebase,$1);
+ if ($upload_result eq 'phasetwo') {
+ $r->print($upload_output);
+ }
+ } elsif ($env{'form.phasetwo'}) {
+ my %newname = ();
+ my %origname = ();
+ my %attribs = ();
+ my $updateflag = 0;
+ my $residx = $env{'form.newidx'};
+ my $primary_url = &unescape($env{'form.primaryurl'});
+# Process file upload - phase two - gather secondary files.
+ for (my $i=0; $i<$env{'form.phasetwo'}; $i++) {
+ if ($env{'form.embedded_item_'.$i.'.filename'}) {
+ my $javacodebase;
+ $newname{$i} = &process_secondary_uploads(\$upload_output,$coursedom,$coursenum,'embedded_item_',$i,$residx);
+ $origname{$i} = &unescape($env{'form.embedded_orig_'.$i});
+ if (exists($env{'form.embedded_codebase_'.$i})) {
+ $javacodebase = &unescape($env{'form.embedded_codebase_'.$i});
+ $origname{$i} =~ s#^\Q$javacodebase\E/##;
+ }
+ my @attributes = ();
+ if ($env{'form.embedded_attrib_'.$i} =~ /:/) {
+ @attributes = split/:/,$env{'form.embedded_attrib_'.$i};
+ } else {
+ @attributes = ($env{'form.embedded_attrib_'.$i});
+ }
+ foreach (@attributes) {
+ push(@{$attribs{$i}},&unescape($_));
+ }
+ if ($javacodebase) {
+ $codebase{$i} = $javacodebase;
+ $codebase{$i} =~ s#/$##;
+ $updateflag = 1;
+ }
+ }
+ unless ($newname{$i} eq $origname{$i}) {
+ $updateflag = 1;
+ }
+ }
+# Process file upload - phase three - modify primary file
+ if ($updateflag) {
+ my ($content,$rtncode);
+ my $updateflag = 0;
+ my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode);
+ if ($getstatus eq 'ok') {
+ foreach my $item (keys %newname) {
+ if ($newname{$item} ne $origname{$item}) {
+ my $attrib_regexp = '';
+ if (@{$attribs{$item}} > 1) {
+ $attrib_regexp = join('|',@{$attribs{$item}});
+ } else {
+ $attrib_regexp = $attribs{$item}[0];
+ }
+ if ($content =~ m#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#) {
+ }
+ $content =~ s#($attrib_regexp\s*=\s*['"]?)\Q$origname{$item}\E(['"]?)#$1$newname{$item}$2#gi;
+ }
+ if (exists($codebase{$item})) {
+ $content =~ s/(codebase\s*=\s*["']?)\Q$codebase{$item}\E(["']?)/$1.$2/i; #' stupid emacs
+ }
+ }
+# Save edited file.
+ my $saveresult;
+ my $docuname=$env{'course.'.$env{'request.course.id'}.'.num'};
+ my $docudom=$env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $url = &Apache::lonnet::store_edited_file($primary_url,$content,$docudom,$docuname,\$saveresult);
+ } else {
+ &Apache::lonnet::logthis('retrieval of uploaded file - '.$primary_url.' - for editing, failed: '.$getstatus);
+ }
+ }
+ }
+ }
+
+ unless ($showdoc || $upload_result eq 'phasetwo') {
# -----------------------------------------------------------------------------
my %lt=&Apache::lonlocal::texthash(
- 'uplm' => 'Upload a new main course document',
- 'upls' => 'Upload a new supplemental course document',
- 'impp' => 'Import a published document',
+ 'uplm' => 'Upload a new main '.lc($type).' document',
+ 'upls' => 'Upload a new supplemental '.lc($type).' document',
+ 'impp' => 'Import a document',
+ 'pubd' => 'Published documents',
+ 'copm' => 'All documents out of a published map into this folder',
'spec' => 'Special documents',
'upld' => 'Upload Document',
'srch' => 'Search',
'impo' => 'Import',
+ 'book' => 'Import Bookmarks',
'selm' => 'Select Map',
'load' => 'Load Map',
+ 'reco' => 'Recover Deleted Resources',
'newf' => 'New Folder',
+ 'newp' => 'New Composite Page',
'extr' => 'External Resource',
'syll' => 'Syllabus',
'navc' => 'Navigate Contents',
'sipa' => 'Simple Page',
'sipr' => 'Simple Problem',
+ 'drbx' => 'Drop Box',
'scuf' => 'Score Upload Form',
'bull' => 'Bulletin Board',
'mypi' => 'My Personal Info',
@@ -1245,46 +2529,61 @@ ENDNEWSCRIPT
'imsf' => 'Import IMS package',
'file' => 'File',
'title' => 'Title',
- 'comment' => 'Comment'
+ 'comment' => 'Comment',
+ 'parse' => 'If HTML file, upload embedded images/multimedia files'
);
# -----------------------------------------------------------------------------
if ($allowed) {
my $dumpbut=&dumpbutton();
+ my $exportbut=&exportbutton();
my %lt=&Apache::lonlocal::texthash(
'vc' => 'Verify Content',
'cv' => 'Check/Set Resource Versions',
+ 'ls' => 'List Symbs',
+ 'sl' => 'Show Log'
);
- my $folderpath=$ENV{'form.folderpath'};
+ my $folderpath=$env{'form.folderpath'};
if (!$folderpath) {
- if ($ENV{'form.folder'} eq '' ||
- $ENV{'form.folder'} eq 'supplemental') {
+ if ($env{'form.folder'} eq '' ||
+ $env{'form.folder'} eq 'supplemental') {
$folderpath='default&'.
- &Apache::lonnet::escape(&mt('Main Course Documents'));
+ &escape(&mt('Main '.$type.' Documents'));
}
}
+ unless ($env{'form.pagepath'}) {
+ $containertag = '';
+ $uploadtag = '';
+ }
+
$r->print(<
-
+
+$containertag
ENDCOURSEVERIFY
$r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
- &mt('Editing the Table of Contents for your Course')));
+ &mt('Editing the Table of Contents for your '.$type)));
}
# --------------------------------------------------------- Standard documents
$r->print('