--- loncom/Lond.pm 2017/05/18 22:13:52 1.10 +++ loncom/Lond.pm 2018/08/09 14:04:30 1.11 @@ -1,6 +1,6 @@ # The LearningOnline Network # -# $Id: Lond.pm,v 1.10 2017/05/18 22:13:52 raeburn Exp $ +# $Id: Lond.pm,v 1.11 2018/08/09 14:04:30 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -783,6 +783,35 @@ sub dump_profile_database { return $qresult; } +sub is_course { + my ($cdom,$cnum) = @_; + + return unless (($cdom =~ /^$LONCAPA::match_domain$/) && + ($cnum =~ /^$LONCAPA::match_courseid$/)); + my $hashid = $cdom.':'.$cnum; + my ($iscourse,$cached) = + &Apache::lonnet::is_cached_new('iscourse',$hashid); + unless (defined($cached)) { + my $hashref = + &tie_domain_hash($cdom, "nohist_courseids", &GDBM_WRCREAT()); + if (ref($hashref) eq 'HASH') { + my $esc_key = &escape($cdom.'_'.$cnum); + if (exists($hashref->{$esc_key})) { + $iscourse = 1; + } else { + $iscourse = 0; + } + &Apache::lonnet::do_cache_new('iscourse',$hashid,$iscourse,3600); + unless (&untie_domain_hash($hashref)) { + &logthis("Failed to untie tied hash for nohist_courseids.db for $cdom"); + } + } else { + &logthis("Failed to tie hash for nohist_courseids.db for $cdom"); + } + } + return $iscourse; +} + sub server_certs { my ($perlvar) = @_; my %pemfiles = (