[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface coursecatalog.pm
raeburn
raeburn at source.lon-capa.org
Sun Jun 20 13:49:08 EDT 2021
raeburn Sun Jun 20 17:49:08 2021 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface coursecatalog.pm
Log:
- For 2.11
Backport 1.105
Index: loncom/interface/coursecatalog.pm
diff -u loncom/interface/coursecatalog.pm:1.88.2.7 loncom/interface/coursecatalog.pm:1.88.2.8
--- loncom/interface/coursecatalog.pm:1.88.2.7 Fri Aug 2 00:24:02 2019
+++ loncom/interface/coursecatalog.pm Sun Jun 20 17:49:08 2021
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler for displaying the course catalog interface
#
-# $Id: coursecatalog.pm,v 1.88.2.7 2019/08/02 00:24:02 raeburn Exp $
+# $Id: coursecatalog.pm,v 1.88.2.8 2021/06/20 17:49:08 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1469,6 +1469,25 @@
}
my $count = 1;
my $totalsec = 0;
+ my %clutteredxlists;
+ foreach my $course (keys(%courseinfo)) {
+ if (ref($courseinfo{$course}) eq 'HASH') {
+ if ($courseinfo{$course}{'xlist'} ne '') {
+ my $crskey = $courseinfo{$course}{'cnum'}.':'.$courseinfo{$course}{'code'};
+ my @xlists = split(/,\s/,$courseinfo{$course}{'xlist'});
+ $clutteredxlists{$crskey} = \@xlists;
+ }
+ }
+ }
+ if (keys(%clutteredxlists)) {
+ my %reformattedxlists = &Apache::lonnet::auto_instsec_reformat($domain,'declutter',\%clutteredxlists);
+ foreach my $crskey (keys(%reformattedxlists)) {
+ if (ref($reformattedxlists{$crskey}) eq 'ARRAY') {
+ my $course = $domain.'_'.(split(/:/,$crskey))[0];
+ $courseinfo{$course}{'xlist'} = join(', ',@{$reformattedxlists{$crskey}});
+ }
+ }
+ }
foreach my $item (@sorted_courses) {
foreach my $course (@{$Sortby{$item}}) {
$output.=&Apache::loncommon::start_data_table_row();
@@ -1924,13 +1943,19 @@
sub get_valid_classes {
my ($seclist,$xlist_items,$crscode,$owners,$cdom,$cnum) = @_;
my $response;
- my (@sections, at xlists,%possclasses,%okclasses,%validations);
+ my (@sections, at format_sections, at xlists,%possclasses,%okclasses,%validations);
@{$validations{'sections'}} = ();
@{$validations{'xlists'}} = ();
my $totalitems = 0;
if ($seclist) {
@sections = split(/,\s+/,$seclist);
- map { $possclasses{$crscode.$_} = 1; } @sections;
+ my $crskey = $cnum.':'.$crscode;
+ my %formattedsec = &Apache::lonnet::auto_instsec_reformat($cdom,'clutter',
+ {$crskey => \@sections});
+ if (ref($formattedsec{$crskey}) eq 'ARRAY') {
+ @format_sections = @{$formattedsec{$crskey}};
+ map { $possclasses{$crscode.$_} = 1; } @format_sections;
+ }
}
if ($xlist_items) {
@xlists = split(/,\s+/,$xlist_items);
@@ -1939,9 +1964,10 @@
my %okclasses = &Apache::lonnet::auto_validate_instclasses($cdom,$cnum,$owners,
\%possclasses);
if (keys(%okclasses)) {
- foreach my $sec (@sections) {
- if ($okclasses{$crscode.$sec}) {
- if (!grep(/^\Q$sec$\E/,@{$validations{'sections'}})) {
+ for (my $i=0; $i<@sections; $i++) {
+ if ($okclasses{$crscode.$format_sections[$i]}) {
+ my $sec = $sections[$i];
+ if (!grep(/^\Q$sec\E$/,@{$validations{'sections'}})) {
push(@{$validations{'sections'}},$sec);
$totalitems ++;
}
@@ -1962,6 +1988,13 @@
join(', ',@{$validations{'sections'}}).'<br />';
}
if (@{$validations{'xlists'}}) {
+ my $crskey = $cnum.':'.$crscode;
+ my %reformattedxlists =
+ &Apache::lonnet::auto_instsec_reformat($cdom,'declutter',
+ {$crskey => $validations{'xlists'}});
+ if (ref($reformattedxlists{$crskey}) eq 'ARRAY') {
+ $validations{'xlists'} = $reformattedxlists{$crskey};
+ }
$response .= &mt('Courses:').' '.
join(', ',@{$validations{'xlists'}});
}
More information about the LON-CAPA-cvs
mailing list