[LON-CAPA-cvs] cvs: rat / map.pm loncom/interface londocs.pm loncom/lonnet/perl lonnet.pm
raeburn
raeburn at source.lon-capa.org
Sat Oct 22 13:24:55 EDT 2022
raeburn Sat Oct 22 17:24:55 2022 EDT
Modified files:
/loncom/interface londocs.pm
/loncom/lonnet/perl lonnet.pm
/rat map.pm
Log:
- Bug 6975
Code to trigger updates of cached Supplemental Content information for a
course moved from londocs.pm to lonnet.pm to facilitate reuse, and called
after uploading file and/or extracting archive file using Course Editor.
-------------- next part --------------
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.683 loncom/interface/londocs.pm:1.684
--- loncom/interface/londocs.pm:1.683 Wed Oct 19 02:10:20 2022
+++ loncom/interface/londocs.pm Sat Oct 22 17:24:54 2022
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.683 2022/10/19 02:10:20 raeburn Exp $
+# $Id: londocs.pm,v 1.684 2022/10/22 17:24:54 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -5931,6 +5931,7 @@
my %codebase = ();
my ($upload_result,$upload_output,$uploadphase);
if ($canedit) {
+ undef($suppchanges);
if (($env{'form.uploaddoc.filename'}) &&
($env{'form.cmd'}=~/^upload_(\w+)/)) {
my $context = $1;
@@ -5942,6 +5943,10 @@
if ($hadchanges) {
&mark_hash_old();
}
+ if ($suppchanges) {
+ &Apache::lonnet::update_supp_caches($coursedom,$coursenum);
+ undef($suppchanges);
+ }
$r->print($upload_output);
} elsif ($env{'form.phase'} eq 'upload_embedded') {
# Process file upload - phase two - upload embedded objects
@@ -6903,25 +6908,7 @@
$r->print('<p><span class="LC_error">'.$error.'</span></p>');
}
if ($suppchanges) {
- my %servers = &Apache::lonnet::internet_dom_servers($coursedom);
- my @ids=&Apache::lonnet::current_machine_ids();
- foreach my $server (keys(%servers)) {
- next if (grep(/^\Q$server\E$/, at ids));
- my $hashid=$coursenum.':'.$coursedom;
- my $cachekey = &escape('showsupp').':'.&escape($hashid);
- &Apache::lonnet::remote_devalidate_cache($server,[$cachekey]);
- }
- &Apache::lonnet::has_unhidden_suppfiles($coursenum,$coursedom,1);
- &Apache::lonnet::count_supptools($coursenum,$coursedom,1);
- my $now = time;
- if ($env{'request.course.id'} eq $coursedom.'_'.$coursenum) {
- &Apache::lonnet::appenv({'request.course.suppupdated' => $now});
- }
- &Apache::lonnet::put('environment',{'internal.supplementalchange' => $now},
- $coursedom,$coursenum);
- &Apache::lonnet::appenv(
- {'course.'.$coursedom.'_'.$coursenum.'.internal.supplementalchange' => $now});
- &Apache::lonnet::do_cache_new('suppchange',$coursedom.'_'.$coursenum,$now,600);
+ &Apache::lonnet::update_supp_caches($coursedom,$coursenum);
undef($suppchanges);
}
}
@@ -7092,6 +7079,10 @@
if ($url eq $env{'form.archiveurl'}) {
if (&handle_edit_cmd($docuname,$docudom)) {
($errtext,$fatal) = &storemap($docuname,$docudom,$map,1);
+ if ($suppchanges) {
+ &Apache::lonnet::update_supp_caches($docudom,$docuname);
+ undef($suppchanges);
+ }
if ($fatal) {
if ($container eq 'page') {
$delwarning = &mt('An error occurred updating the contents of the current page.');
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1496 loncom/lonnet/perl/lonnet.pm:1.1497
--- loncom/lonnet/perl/lonnet.pm:1.1496 Wed Oct 19 00:03:11 2022
+++ loncom/lonnet/perl/lonnet.pm Sat Oct 22 17:24:55 2022
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1496 2022/10/19 00:03:11 raeburn Exp $
+# $Id: lonnet.pm,v 1.1497 2022/10/22 17:24:55 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -12485,7 +12485,7 @@
}
sub has_unhidden_suppfiles {
- my ($cnum,$cdom,$ignorecache)=@_;
+ my ($cnum,$cdom,$ignorecache,$possdell)=@_;
my $hashid=$cnum.':'.$cdom;
my ($showsupp,$cached);
unless ($ignorecache) {
@@ -12494,7 +12494,7 @@
unless (defined($cached)) {
my $chome=&homeserver($cnum,$cdom);
unless ($chome eq 'no_host') {
- my ($supplemental) = &get_supplemental($cnum,$cdom,$ignorecache);
+ my ($supplemental) = &get_supplemental($cnum,$cdom,$ignorecache,$possdel);
if (ref($supplemental) eq 'HASH') {
if ((ref($supplemental->{'ids'}) eq 'HASH') && (ref($supplemental->{'hidden'}) eq 'HASH')) {
foreach my $key (keys(%{$supplemental->{'ids'}})) {
@@ -13710,6 +13710,29 @@
&devalidate_cache_new('suppchange',$hashid);
}
+sub update_supp_caches {
+ my ($cdom,$cnum) = @_;
+ my %servers = &internet_dom_servers($cdom);
+ my @ids=¤t_machine_ids();
+ foreach my $server (keys(%servers)) {
+ next if (grep(/^\Q$server\E$/, at ids));
+ my $hashid=$cnum.':'.$cdom;
+ my $cachekey = &escape('showsupp').':'.&escape($hashid);
+ &remote_devalidate_cache($server,[$cachekey]);
+ }
+ &has_unhidden_suppfiles($cnum,$cdom,1,1);
+ &count_supptools($cnum,$cdom,1);
+ my $now = time;
+ if ($env{'request.course.id'} eq $cdom.'_'.$cnum) {
+ &Apache::lonnet::appenv({'request.course.suppupdated' => $now});
+ }
+ &put('environment',{'internal.supplementalchange' => $now},
+ $cdom,$cnum);
+ &Apache::lonnet::appenv(
+ {'course.'.$cdom.'_'.$cnum.'.internal.supplementalchange' => $now});
+ &do_cache_new('suppchange',$cdom.'_'.$cnum,$now,600);
+}
+
# ------------------------------------------------- Update symbolic store links
sub symblist {
Index: rat/map.pm
diff -u rat/map.pm:1.15 rat/map.pm:1.16
--- rat/map.pm:1.15 Sat Jun 14 19:05:00 2014
+++ rat/map.pm Sat Oct 22 17:24:55 2022
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# routines for modyfing .sequence and .page files
#
-# $Id: map.pm,v 1.15 2014/06/14 19:05:00 raeburn Exp $
+# $Id: map.pm,v 1.16 2022/10/22 17:24:55 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -678,10 +678,12 @@
}
}
$outstr.="</map>\n";
+ my ($cdom,$cnum,$mapname);
if ($fn=~m{^/*uploaded/($LONCAPA::domain_re)/($LONCAPA::courseid_re)/(.*)$}) {
+ ($cdom,$cnum,$mapname) = ($1,$2,$3);
$env{'form.output'}=$outstr;
- my $result=&Apache::lonnet::finishuserfileupload($2,$1,
- 'output',$3);
+ my $result=&Apache::lonnet::finishuserfileupload($cnum,$cdom,
+ 'output',$mapname);
if ($result != m|^/uploaded/|) {
$errtext.='Map not saved: A network error occurred when trying to save the map. ';
}
@@ -696,13 +698,19 @@
if ($dotimeupdate) {
unless ($errtext) {
if ($env{'request.course.id'}) {
- my $now = time;
- &Apache::lonnet::put('environment',{'internal.contentchange' => $now},
- $env{'course.'.$env{'request.course.id'}.'.domain'},
- $env{'course.'.$env{'request.course.id'}.'.num'});
- &Apache::lonnet::appenv(
- {'course.'.$env{'request.course.id'}.'.internal.contentchange' => $now});
- &Apache::lonnet::do_cache_new('crschange',$env{'request.course.id'},$now,600);
+ if (($cdom eq $env{'course.'.$env{'request.course.id'}.'.domain'}) &&
+ ($cnum eq $env{'course.'.$env{'request.course.id'}.'.num'}) &&
+ ($mapname =~ /^supplemental(|_\d+)\.sequence$/)) {
+ &Apache::lonnet::update_supp_caches($cdom,$cnum);
+ } else {
+ my $now = time;
+ &Apache::lonnet::put('environment',{'internal.contentchange' => $now},
+ $env{'course.'.$env{'request.course.id'}.'.domain'},
+ $env{'course.'.$env{'request.course.id'}.'.num'});
+ &Apache::lonnet::appenv(
+ {'course.'.$env{'request.course.id'}.'.internal.contentchange' => $now});
+ &Apache::lonnet::do_cache_new('crschange',$env{'request.course.id'},$now,600);
+ }
}
}
}
More information about the LON-CAPA-cvs
mailing list