[LON-CAPA-cvs] cvs: loncom /interface coursecatalog.pm courseclassifier.pm lonnotify.pm lonsupportreq.pm lonuserutils.pm /lonnet/perl lonnet.pm
raeburn
raeburn at source.lon-capa.org
Tue Jul 23 09:59:01 EDT 2019
raeburn Tue Jul 23 13:59:01 2019 EDT
Modified files:
/loncom/interface coursecatalog.pm courseclassifier.pm lonnotify.pm
lonsupportreq.pm lonuserutils.pm
/loncom/lonnet/perl lonnet.pm
Log:
- Self-cataloging of courses based on institutional code is cached for 1 hour.
-------------- next part --------------
Index: loncom/interface/coursecatalog.pm
diff -u loncom/interface/coursecatalog.pm:1.101 loncom/interface/coursecatalog.pm:1.102
--- loncom/interface/coursecatalog.pm:1.101 Tue Jul 23 01:30:35 2019
+++ loncom/interface/coursecatalog.pm Tue Jul 23 13:58:53 2019
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler for displaying the course catalog interface
#
-# $Id: coursecatalog.pm,v 1.101 2019/07/23 01:30:35 raeburn Exp $
+# $Id: coursecatalog.pm,v 1.102 2019/07/23 13:58:53 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -281,7 +281,7 @@
}
document.coursecats.catalog_maxdepth.value = depth;
} else {
- document.coursecats.currcat_0.value = '';
+ document.coursecats.currcat_0.value = '';
document.coursecats.catalog_maxdepth.value = '';
}
document.coursecats.submit();
@@ -623,8 +623,6 @@
} elsif (ref($crscatsref) eq 'HASH') {
unless (exists($crscatsref->{$env{'form.'.$key}})) {
delete($env{'form.'.$key});
- } else {
- delete($env{'form.'.$key});
}
} else {
delete($env{'form.'.$key});
@@ -637,16 +635,11 @@
sub get_instcode_allowable {
my ($codedom,$possvalref) = @_;
return 1 unless (ref($possvalref) eq 'HASH');
- my $caller = 'global';
- my %coursecodes = ();
- my %codes = ();
- my @codetitles = ();
- my %cat_titles = ();
- my %cat_order = ();
- my $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom);
- if ($totcodes > 0) {
- if (&Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,
- \%codes,\@codetitles,\%cat_titles,\%cat_order) eq 'ok') {
+ my $instcats = &Apache::lonnet::get_dom_instcats($codedom);
+ if (ref($instcats) eq 'HASH') {
+ if ((ref($instcats->{'codetitles'}) eq 'ARRAY') && (ref($instcats->{'codes'}) eq 'HASH')) {
+ my %codes = %{$instcats->{'codes'}};
+ my @codetitles = @{$instcats->{'codetitles'}};
my @standardnames = &Apache::loncommon::get_standard_codeitems();
my %local_to_standard;
for (my $i=0; $i<@codetitles; $i++) {
@@ -771,13 +764,9 @@
sub instcode_course_selector {
my ($r,$codedom,$formname,$domdesc,$catlinks,$catjs,$codetitles,$cattype,$canviewall) = @_;
- my %coursecodes = ();
- my %codes = ();
my %cat_titles = ();
my %cat_order = ();
- my %cat_items;
- my $caller = 'global';
- my $format_reply;
+ my %cat_items = ();
my %add_entries = (topmargin => "0",
marginheight => "0",);
my ($jscript,$totcodes,$numtitles,$lasttitle) =
Index: loncom/interface/courseclassifier.pm
diff -u loncom/interface/courseclassifier.pm:1.26 loncom/interface/courseclassifier.pm:1.27
--- loncom/interface/courseclassifier.pm:1.26 Wed Jan 18 21:24:39 2017
+++ loncom/interface/courseclassifier.pm Tue Jul 23 13:58:53 2019
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utilities for classifying courses based on institutional code
#
-# $Id: courseclassifier.pm,v 1.26 2017/01/18 21:24:39 raeburn Exp $
+# $Id: courseclassifier.pm,v 1.27 2019/07/23 13:58:53 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -34,22 +34,6 @@
use Apache::lonlocal;
use LONCAPA;
-sub retrieve_instcodes {
- my ($coursecodes,$codedom) = @_;
- my $totcodes;
- my %courses = &Apache::lonnet::courseiddump($codedom,'.',1,'.','.','.',
- undef,undef,'Course');
- foreach my $course (keys(%courses)) {
- if (ref($courses{$course}) eq 'HASH') {
- if ($courses{$course}{'inst_code'} ne '') {
- $$coursecodes{$course} = $courses{$course}{'inst_code'};
- $totcodes ++;
- }
- }
- }
- return $totcodes;
-}
-
sub sort_cats {
my ($num,$cat_order,$codetitles,$idsarrayref,$sorted) = @_;
my @unsorted = @{$idsarrayref};
@@ -533,15 +517,18 @@
sub instcode_selectors_data {
my ($codedom,$formname,$cat_items,$codetitles,$cat_titles,$cat_order,$officialjs) = @_;
- my ($jscript,%coursecodes,%codes,%idlist,%idnums,%idlist_titles,
- %by_year,%by_sem,%by_dept);
- my ($numtitles,$lasttitle);
- my $caller = 'global';
- my $totcodes = &retrieve_instcodes(\%coursecodes,$codedom);
- if ($totcodes > 0) {
- if (&Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,
- \%codes,$codetitles,$cat_titles,$cat_order) eq 'ok') {
- &build_code_selections(\%codes,$codetitles,$cat_titles,$cat_order,
+ my ($jscript,$codes,%idlist,%idnums,%idlist_titles,%by_year,%by_sem,%by_dept);
+ my ($numtitles,$lasttitle,$totcodes);
+ my $instcats = &Apache::lonnet::get_dom_instcats($codedom);
+ if (ref($instcats) eq 'HASH') {
+ if ((ref($instcats->{'codetitles'}) eq 'ARRAY') && (ref($instcats->{'codes'}) eq 'HASH') &&
+ (ref($instcats->{'cat_titles'}) eq 'HASH') && (ref($instcats->{'cat_order'}) eq 'HASH')) {
+ %{$codes} = %{$instcats->{'codes'}};
+ @{$codetitles} = @{$instcats->{'codetitles'}};
+ %{$cat_titles} = %{$instcats->{'cat_titles'}};
+ %{$cat_order} = %{$instcats->{'cat_order'}};
+ $totcodes = scalar(keys(%{$codes}));
+ &build_code_selections($codes,$codetitles,$cat_titles,$cat_order,
\%idlist,\%idnums,\%idlist_titles);
my ($scripttext,$longtitles) =
&javascript_definitions($codetitles,\%idlist,\%idlist_titles,
@@ -1061,16 +1048,17 @@
sub instcode_from_selectors {
my ($cdom,$noregexps) = @_;
my $instcode;
- my $caller = 'global';
- my (%coursecodes,%codes, at codetitles,%cat_titles,%cat_order,
- %codedefaults, at code_order);
- my $format_reply =
- &Apache::lonnet::auto_instcode_format($caller,$cdom,\%coursecodes,
- \%codes,\@codetitles,\%cat_titles,\%cat_order);
+ my (@codetitles,%codedefaults, at code_order);
+ my $instcats = &Apache::lonnet::get_dom_instcats($cdom);
+ if (ref($instcats) eq 'HASH') {
+ if (ref($instcats->{'codetitles'}) eq 'ARRAY') {
+ @codetitles = @{$instcats->{'codetitles'}};
+ }
+ }
my $defaults_result =
&Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
\@code_order);
- if (($defaults_result eq 'ok') && ($format_reply eq 'ok')) {
+ if (($defaults_result eq 'ok') && (@codetitles > 0)) {
my @standardnames = &Apache::loncommon::get_standard_codeitems();
my %local_to_standard;
for (my $i=0; $i<@codetitles; $i++) {
Index: loncom/interface/lonnotify.pm
diff -u loncom/interface/lonnotify.pm:1.42 loncom/interface/lonnotify.pm:1.43
--- loncom/interface/lonnotify.pm:1.42 Wed Jan 18 21:07:31 2017
+++ loncom/interface/lonnotify.pm Tue Jul 23 13:58:53 2019
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Sending messages
#
-# $Id: lonnotify.pm,v 1.42 2017/01/18 21:07:31 raeburn Exp $
+# $Id: lonnotify.pm,v 1.43 2019/07/23 13:58:53 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -378,7 +378,6 @@
sub print_selection_form {
my ($r,$formname,$cdom) = @_;
- my %coursecodes = ();
my %codes = ();
my @codetitles = ();
my %cat_titles = ();
@@ -386,9 +385,7 @@
my %idlist = ();
my %idnums = ();
my %idlist_titles = ();
- my $caller = 'global';
my $totcodes = 0;
- my $format_reply;
my $jscript = '';
my %lt=&Apache::lonlocal::texthash(
'buil' => 'Building valid e-mail address from username, if missing from preferences:',
@@ -399,10 +396,15 @@
&Apache::lonhtmlcommon::add_breadcrumb
({text=>"Select Audience"});
- $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$cdom,$totcodes);
- if ($totcodes > 0) {
- $format_reply = &Apache::lonnet::auto_instcode_format($caller,$cdom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order);
- if ($format_reply eq 'ok') {
+ my $instcats = &Apache::lonnet::get_dom_instcats($cdom);
+ if (ref($instcats) eq 'HASH') {
+ if ((ref($instcats->{'codetitles'}) eq 'ARRAY') && (ref($instcats->{'codes'}) eq 'HASH') &&
+ (ref($instcats->{'cat_titles'}) eq 'HASH') && (ref($instcats->{'cat_order'}) eq 'HASH')) {
+ %codes = %{$instcats->{'codes'}};
+ @codetitles = @{$instcats->{'codetitles'}};
+ %cat_titles = %{$instcats->{'cat_titles'}};
+ %cat_order = %{$instcats->{'cat_order'}};
+ $totcodes = scalar(keys(%codes));
my $numtypes = @codetitles;
&Apache::courseclassifier::build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);
my ($scripttext,$longtitles) = &Apache::courseclassifier::javascript_definitions(\@codetitles,\%idlist,\%idlist_titles,\%idnums,\%cat_titles);
Index: loncom/interface/lonsupportreq.pm
diff -u loncom/interface/lonsupportreq.pm:1.95 loncom/interface/lonsupportreq.pm:1.96
--- loncom/interface/lonsupportreq.pm:1.95 Sun Jun 16 05:49:43 2019
+++ loncom/interface/lonsupportreq.pm Tue Jul 23 13:58:53 2019
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Helpdesk request form
#
-# $Id: lonsupportreq.pm,v 1.95 2019/06/16 05:49:43 raeburn Exp $
+# $Id: lonsupportreq.pm,v 1.96 2019/07/23 13:58:53 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -151,7 +151,6 @@
}
}
- my %coursecodes;
my %codes;
my @codetitles;
my %cat_titles;
@@ -159,9 +158,7 @@
my %idlist;
my %idnums;
my %idlist_titles;
- my $caller = 'global';
my $totcodes = 0;
- my $format_reply;
my $jscript = '';
my $loaditems = qq|
function initialize_codes() {
@@ -169,10 +166,17 @@
}
|;
unless ($helpform{'course'} eq 'no') {
- $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$codedom);
- if ($totcodes > 0) {
- $format_reply = &Apache::lonnet::auto_instcode_format($caller,$codedom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order);
- if ($format_reply eq 'ok') {
+ my $instcats = &Apache::lonnet::get_dom_instcats($codedom);
+ if (ref($instcats) eq 'HASH') {
+ if ((ref($instcats->{'codetitles'}) eq 'ARRAY') && (ref($instcats->{'codes'}) eq 'HASH') &&
+ (ref($instcats->{'cat_titles'}) eq 'HASH') && (ref($instcats->{'cat_order'}) eq 'HASH')) {
+ %codes = %{$instcats->{'codes'}};
+ @codetitles = @{$instcats->{'codetitles'}};
+ %cat_titles = %{$instcats->{'cat_titles'}};
+ %cat_order = %{$instcats->{'cat_order'}};
+ $totcodes = scalar(keys(%codes));
+ }
+ if ($totcodes > 0) {
my $numtypes = @codetitles;
&Apache::courseclassifier::build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);
my ($scripttext,$longtitles) = &Apache::courseclassifier::javascript_definitions(\@codetitles,\%idlist,\%idlist_titles,\%idnums,\%cat_titles);
@@ -714,8 +718,12 @@
$coursecode = $env{'form.coursecode'};
if ($coursecode eq '') {
my $totcodes = 0;
- my %coursecodes;
- $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$defdom);
+ my $instcats = &Apache::lonnet::get_dom_instcats($defdom);
+ if (ref($instcats) eq 'HASH') {
+ if (ref($instcats->{'codes'}) eq 'HASH') {
+ $totcodes = scalar(keys(%{$instcats->{'codes'}}));
+ }
+ }
my @standardnames = &Apache::loncommon::get_standard_codeitems();
if ($totcodes > 0) {
my $noregexps = 1;
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.200 loncom/interface/lonuserutils.pm:1.201
--- loncom/interface/lonuserutils.pm:1.200 Sat May 11 21:34:01 2019
+++ loncom/interface/lonuserutils.pm Tue Jul 23 13:58:53 2019
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.200 2019/05/11 21:34:01 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.201 2019/07/23 13:58:53 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2433,7 +2433,6 @@
sub courses_selector {
my ($cdom,$formname) = @_;
- my %coursecodes = ();
my %codes = ();
my @codetitles = ();
my %cat_titles = ();
@@ -2446,14 +2445,15 @@
my $jscript = '';
my $totcodes = 0;
- $totcodes =
- &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,
- $cdom,$totcodes);
- if ($totcodes > 0) {
- $format_reply =
- &Apache::lonnet::auto_instcode_format($caller,$cdom,\%coursecodes,
- \%codes,\@codetitles,\%cat_titles,\%cat_order);
- if ($format_reply eq 'ok') {
+ my $instcats = &Apache::lonnet::get_dom_instcats($cdom);
+ if (ref($instcats) eq 'HASH') {
+ if ((ref($instcats->{'codetitles'}) eq 'ARRAY') && (ref($instcats->{'codes'}) eq 'HASH') &&
+ (ref($instcats->{'cat_titles'}) eq 'HASH') && (ref($instcats->{'cat_order'}) eq 'HASH')) {
+ %codes = %{$instcats->{'codes'}};
+ @codetitles = @{$instcats->{'codetitles'}};
+ %cat_titles = %{$instcats->{'cat_titles'}};
+ %cat_order = %{$instcats->{'cat_order'}};
+ $totcodes = scalar(keys(%codes));
my $numtypes = @codetitles;
&Apache::courseclassifier::build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);
my ($scripttext,$longtitles) = &Apache::courseclassifier::javascript_definitions(\@codetitles,\%idlist,\%idlist_titles,\%idnums,\%cat_titles);
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1412 loncom/lonnet/perl/lonnet.pm:1.1413
--- loncom/lonnet/perl/lonnet.pm:1.1412 Tue Jul 23 01:30:44 2019
+++ loncom/lonnet/perl/lonnet.pm Tue Jul 23 13:59:01 2019
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1412 2019/07/23 01:30:44 raeburn Exp $
+# $Id: lonnet.pm,v 1.1413 2019/07/23 13:59:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2682,7 +2682,7 @@
if (ref($domconfig{'coursecategories'}) eq 'HASH') {
$domdefaults{'catauth'} = 'std';
$domdefaults{'catunauth'} = 'std';
- if ($domconfig{'coursecategories'}{'auth'}) {
+ if ($domconfig{'coursecategories'}{'auth'}) {
$domdefaults{'catauth'} = $domconfig{'coursecategories'}{'auth'};
}
if ($domconfig{'coursecategories'}{'unauth'}) {
@@ -2738,7 +2738,46 @@
}
&Apache::lonnet::do_cache_new('cats',$dom,$cats,3600);
}
- return $cats;
+ return $cats;
+}
+
+sub get_dom_instcats {
+ my ($dom) = @_;
+ return unless (&domain($dom));
+ my ($instcats,$cached)=&is_cached_new('instcats',$dom);
+ unless (defined($cached)) {
+ my (%coursecodes,%codes, at codetitles,%cat_titles,%cat_order);
+ my $totcodes = &retrieve_instcodes(\%coursecodes,$dom);
+ if ($totcodes > 0) {
+ my $caller = 'global';
+ if (&auto_instcode_format($caller,$dom,\%coursecodes,\%codes,
+ \@codetitles,\%cat_titles,\%cat_order) eq 'ok') {
+ $instcats = {
+ codes => \%codes,
+ codetitles => \@codetitles,
+ cat_titles => \%cat_titles,
+ cat_order => \%cat_order,
+ };
+ &do_cache_new('instcats',$dom,$instcats,3600);
+ }
+ }
+ }
+ return $instcats;
+}
+
+sub retrieve_instcodes {
+ my ($coursecodes,$dom) = @_;
+ my $totcodes;
+ my %courses = &courseiddump($dom,'.',1,'.','.','.',undef,undef,'Course');
+ foreach my $course (keys(%courses)) {
+ if (ref($courses{$course}) eq 'HASH') {
+ if ($courses{$course}{'inst_code'} ne '') {
+ $$coursecodes{$course} = $courses{$course}{'inst_code'};
+ $totcodes ++;
+ }
+ }
+ }
+ return $totcodes;
}
sub course_portal_url {
More information about the LON-CAPA-cvs
mailing list