--- loncom/interface/coursecatalog.pm 2021/04/30 18:19:41 1.104 +++ loncom/interface/coursecatalog.pm 2021/06/15 20:52:26 1.105 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler for displaying the course catalog interface # -# $Id: coursecatalog.pm,v 1.104 2021/04/30 18:19:41 raeburn Exp $ +# $Id: coursecatalog.pm,v 1.105 2021/06/15 20:52:26 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1511,6 +1511,25 @@ sub construct_data_table { } 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(); @@ -1971,13 +1990,19 @@ sub identify_sections { sub get_valid_classes { my ($seclist,$xlist_items,$crscode,$owners,$cdom,$cnum) = @_; my $response; - my (@sections,@xlists,%possclasses,%okclasses,%validations); + my (@sections,@format_sections,@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); @@ -1986,9 +2011,10 @@ sub get_valid_classes { 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 ++; } @@ -2009,6 +2035,13 @@ sub get_valid_classes { join(', ',@{$validations{'sections'}}).'
'; } 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'}}); }