[LON-CAPA-cvs] cvs: loncom /interface lonpopulate.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Fri, 12 Dec 2003 00:45:49 -0000


raeburn		Thu Dec 11 19:45:49 2003 EDT

  Modified files:              
    /loncom/interface	lonpopulate.pm 
  Log:
  Addition to lonpopulate.pm to support processing of section changes where the available course sections have been generated from an institutional list.  Some cosmetic changes to add crosslistings interface.
  
  
Index: loncom/interface/lonpopulate.pm
diff -u loncom/interface/lonpopulate.pm:1.5 loncom/interface/lonpopulate.pm:1.6
--- loncom/interface/lonpopulate.pm:1.5	Wed Dec 10 21:54:51 2003
+++ loncom/interface/lonpopulate.pm	Thu Dec 11 19:45:49 2003
@@ -1,5 +1,5 @@
 # automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.5 2003/12/11 02:54:51 raeburn Exp $
+# $Id: lonpopulate.pm,v 1.6 2003/12/12 00:45:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1205,7 +1205,7 @@
                      push @badowner,$ENV{"form.$xl"}.":".$ENV{"form.$gp"};
                   } 
               } else {
-                  push @badxlists, $ENV{"form.$xl"}.":".$ENV{"form.$gp"};
+                  push @badxlists, $ENV{"form.$xl"}.":".$ENV{"form.$gp"}.":".$coursecheck;
               }
           }
       }
@@ -1222,23 +1222,36 @@
       my %cenv = ('internal.crosslistings' => $xliststr);
       my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
       if ($reply !~ /^ok$/) {
-          $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/>";
+          $response = "There was a problem processing your requested changes. The automated enrollment settings for this course have been left unchanged.<br/><br/>";
       } else {
           $response = "The courses listed below are now crosslisted with this LON-CAPA course, and students enrolling in these course sections will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.<br/><ul>\n";
+          foreach (@allxlists) {
+              my ($xlist,$gp) = split/:/,$_;
+              $response .= "<li>$xlist - ID: $gp</li>\n";
+          }
+          $response .= "</ul><br/><br/>\n";
+      }
+  } else {
+      if ($xliststr =~ m/:/) {
+          my @oldxlists = ();
+          if ($xliststr =~ m/,/) {
+              @oldxlists = split/,/,$xliststr;
+          } else {
+              $oldxlists[0] = $xliststr;
+          }
+          $response .= "Although no new crosslistings were added, the courses listed below continue to be crosslisted with your LON-CAPA course.<br/><ul>\n";
+          foreach (@oldxlists) {
+              my ($xlist,$gp) = split/:/,$_;
+              $response .= "<li>$xlist - ID: $gp</li>\n";
+          }
+          $response .= "</ul><br/><br/>\n";
       }
   }
-
-  foreach (@allxlists) {
-      my ($xlist,$gp) = split/:/,$_;
-      $response .= "<li>$xlist - ID: $gp</li>\n";
-  }
-  $response .= "</ul><br/><br/>\n";
-
   if (@badxlists > 0) {
       $response .= "The courses listed below could not be included in the crosslistings for this LON-CAPA course, because they are not valid courses according to your institution's official schedule of classes and sections.<br/><ul>\n";
       foreach (@badxlists) {
-          my ($xlist,$gp) = split/:/,$_;
-          $response .= "<li>$xlist - ID: $gp</li>\n";
+          my ($xlist,$gp,$prob) = split/:/,$_;
+          $response .= "<li>$xlist - ID: $gp - Error: $prob</li>\n";
       }
       $response .= "</ul><br/><br/>\n";
   }
@@ -1263,6 +1276,7 @@
   my @sections = ();
   my $seccount = 0;
   my $removecount = 0;
+  my $addcount = 0;
   my $secstr = '';
   my $response = '';
   my $coursecode = $settings{'internal.coursecode'};
@@ -1271,14 +1285,44 @@
   } elsif ($settings{'internal.sectionnums'} ne '') {
       $currsections[0] = $settings{'internal.sectionnums'};
   }
-                                                                                                     
-  if (@currsections > 0) {
+
+  if ( exists($ENV{'form.secshow'}) ) {
+     for (my $i=0; $i<$ENV{'form.secshow'}; $i++) {
+         my $gp = "loncapasec_".$i;
+         my $secnum = "secnum_".$i;
+         my $sec = "sec_".$i;
+         if ( exists( $ENV{"form.$sec"} ) ) {
+            my $secentry;
+            if ( exists( $ENV{"form.$secnum"} ) ) { 
+                $secentry = $ENV{"form.$secnum"}.':';
+            }
+            if ( exists( $ENV{"form.$gp"} ) ) {
+                $secentry .= $ENV{"form.$gp"};
+            }
+            push @sections, $secentry;
+            $seccount ++;
+            unless (grep/^$ENV{"form.$secnum"}:/,@currsections) {
+                $addcount ++;
+            }
+         }
+     }
+     if (@currsections > 0) {
+         for (my $i=0; $i<@currsections; $i++) {
+             if ($currsections[$i] =~ m/^(\w+:)/ ) {
+                my $oldsec  = $1;
+                unless (grep/^$oldsec/,@sections) {
+                    $removecount ++;
+                }
+             }
+         }
+     }
+  } elsif (@currsections > 0) {
       for (my $i=0; $i<@currsections; $i++) {
           my $sec = "sec_".$i;
           my $gp = "secgp_".$i;
           if ( exists($ENV{"form.$sec"}) ) {
               my $secentry = '';
-              if ($currsections[$i] =~ m/^(\w+:)/) {
+              if ($currsections[$i] =~ m/^(\w+:)/ ) {
                   $secentry = $1;
               }
               if ( exists($ENV{"form.$gp"}) ) {
@@ -1305,8 +1349,12 @@
       if ($removecount > 0) {
           $response = "A total of $removecount sections have been removed from the list of sections which contribute to enrollment in LON-CAPA course: $realm ($coursecode).<br/><br/>";
       }
+      if ($addcount > 0) {
+          $response .= "A total of $addcount sections have been added to the list of
+sections which contribute to enrollment in LON-CAPA course: $realm ($coursecode).<br/><br/>";
+      }
       if ($seccount > 0) { 
-          $response .= "Students enrolling in the $seccount section(s) listed below will continue to be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.<br/><ul>\n";
+          $response .= "Students enrolling in the $seccount section(s) listed below will be automatically added to the class roster for the course, if you have chosen to enable a nightly automated enrollment update.<br/><ul>\n";
           foreach (@sections) {
               my ($sec,$gp) = split/:/,$_;
               $response .= "<li>$sec  - ID: $gp</li>\n";