[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface coursecatalog.pm

raeburn raeburn at source.lon-capa.org
Sat Apr 28 20:31:26 EDT 2018


raeburn		Sun Apr 29 00:31:26 2018 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	coursecatalog.pm 
  Log:
  - For 2.11
    Backport 1.95
  
  
Index: loncom/interface/coursecatalog.pm
diff -u loncom/interface/coursecatalog.pm:1.88.2.1 loncom/interface/coursecatalog.pm:1.88.2.2
--- loncom/interface/coursecatalog.pm:1.88.2.1	Sun Oct 23 21:21:56 2016
+++ loncom/interface/coursecatalog.pm	Sun Apr 29 00:31:25 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler for displaying the course catalog interface
 #
-# $Id: coursecatalog.pm,v 1.88.2.1 2016/10/23 21:21:56 raeburn Exp $
+# $Id: coursecatalog.pm,v 1.88.2.2 2018/04/29 00:31:25 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1607,27 +1607,33 @@
 sub get_valid_classes {
     my ($seclist,$xlist_items,$crscode,$owners,$cdom,$cnum) = @_;
     my $response;
-    my %validations;
+    my (@sections, at xlists,%possclasses,%okclasses,%validations);
     @{$validations{'sections'}} = ();
     @{$validations{'xlists'}} = ();
     my $totalitems = 0;
     if ($seclist) {
-        foreach my $sec (split(/, /,$seclist)) {
+        @sections = split(/,\s+/,$seclist);
+        map { $possclasses{$crscode.$_} = 1; } @sections;
+    }
+    if ($xlist_items) {
+        @xlists = split(/,\s+/,$xlist_items);
+        map { $possclasses{$_} = 1; } @xlists;
+    }
+    my %okclasses = &Apache::lonnet::auto_validate_instclasses($cdom,$cnum,$owners,
+                                                               \%possclasses);
+    if (keys(%okclasses)) {
+        foreach my $sec (@sections) {
             my $class = $crscode.$sec;
-            if (&Apache::lonnet::auto_validate_class_sec($cdom,$cnum,$owners,
-							 $class) eq 'ok') {
+            if ($okclasses{$crscode.$sec}) {
                 if (!grep(/^\Q$sec$\E/,@{$validations{'sections'}})) {
                     push(@{$validations{'sections'}},$sec);
                     $totalitems ++;
                 }
             }
         }
-    }
-    if ($xlist_items) {
-        foreach my $item (split(/, /,$xlist_items)) {
-            if (&Apache::lonnet::auto_validate_class_sec($cdom,$cnum,$owners,
-							 $item) eq 'ok') {
-                if (!grep(/^\Q$item$\E/,@{$validations{'xlists'}})) {
+        foreach my $item (@xlists) {
+            if ($okclasses{$item}) {
+                if (!grep(/^\Q$item\E$/,@{$validations{'xlists'}})) {
                     push(@{$validations{'xlists'}},$item);
                     $totalitems ++;
                 }




More information about the LON-CAPA-cvs mailing list