[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /lonnet/perl lonnet.pm
raeburn
raeburn at source.lon-capa.org
Sat Sep 1 22:14:01 EDT 2018
raeburn Sun Sep 2 02:14:01 2018 EDT
Modified files: (Branch: version_2_11_X)
/loncom/lonnet/perl lonnet.pm
Log:
- For 2.11
Backport 1.1381, 1.1382.
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1172.2.94 loncom/lonnet/perl/lonnet.pm:1.1172.2.95
--- loncom/lonnet/perl/lonnet.pm:1.1172.2.94 Sun Apr 29 00:53:23 2018
+++ loncom/lonnet/perl/lonnet.pm Sun Sep 2 02:13:59 2018
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1172.2.94 2018/04/29 00:53:23 raeburn Exp $
+# $Id: lonnet.pm,v 1.1172.2.95 2018/09/02 02:13:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -9652,13 +9652,25 @@
sub is_course {
my ($cdom, $cnum) = scalar(@_) == 1 ?
($_[0] =~ /^($match_domain)_($match_courseid)$/) : @_;
-
- return unless $cdom and $cnum;
-
- my %courses = &courseiddump($cdom, '.', 1, '.', '.', $cnum, undef, undef,
- '.');
-
- return unless(exists($courses{$cdom.'_'.$cnum}));
+ return unless (($cdom =~ /^$match_domain$/) && ($cnum =~ /^$match_courseid$/));
+ my $uhome=&homeserver($cnum,$cdom);
+ my $iscourse;
+ if (grep { $_ eq $uhome } current_machine_ids()) {
+ $iscourse = &LONCAPA::Lond::is_course($cdom,$cnum);
+ } else {
+ my $hashid = $cdom.':'.$cnum;
+ ($iscourse,my $cached) = &is_cached_new('iscourse',$hashid);
+ unless (defined($cached)) {
+ my %courses = &courseiddump($cdom, '.', 1, '.', '.',
+ $cnum,undef,undef,'.');
+ $iscourse = 0;
+ if (exists($courses{$cdom.'_'.$cnum})) {
+ $iscourse = 1;
+ }
+ &do_cache_new('iscourse',$hashid,$iscourse,3600);
+ }
+ }
+ return unless($iscourse);
return wantarray ? ($cdom, $cnum) : $cdom.'_'.$cnum;
}
More information about the LON-CAPA-cvs
mailing list