[LON-CAPA-cvs] cvs: modules /msu localenroll.pm

raeburn raeburn@source.lon-capa.org
Sun, 13 Sep 2009 14:35:57 -0000


raeburn		Sun Sep 13 14:35:57 2009 EDT

  Modified files:              
    /modules/msu	localenroll.pm 
  Log:
  - Split $term into $sem and $year before case change.
  - Default description is of form: GLG201, Fall 2009 - The Dynamic Earth
  
  
Index: modules/msu/localenroll.pm
diff -u modules/msu/localenroll.pm:1.45 modules/msu/localenroll.pm:1.46
--- modules/msu/localenroll.pm:1.45	Sun Sep 13 03:14:30 2009
+++ modules/msu/localenroll.pm	Sun Sep 13 14:35:57 2009
@@ -1,6 +1,6 @@
 # functions to glue school database system into Lon-CAPA for
 # automated enrollment
-# $Id: localenroll.pm,v 1.45 2009/09/13 03:14:30 raeburn Exp $
+# $Id: localenroll.pm,v 1.46 2009/09/13 14:35:57 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -305,10 +305,12 @@
                     ss => 'Spring',
                     us => 'Summer',
                   );
-    if ($instcode =~ m/^([suf]s\d{2})(\w{2,3})(\d{3,4}\w?)$/) {
-        my $term = $1;
-        my $subj = $2;
-        my $crse = $3;
+    if ($instcode =~ m/^([suf]s)(\d{2})(\w{2,3})(\d{3,4}\w?)$/) {
+        my $sem = $1;
+        my $year = $2;
+        my $term = $sem.$year;
+        my $subj = $3;
+        my $crse = $4;
         $subj =~tr/a-z/A-Z/;
         $crse =~tr/a-z/A-Z/;
         $term =~tr/a-z/A-Z/;
@@ -351,17 +353,18 @@
                     my $count = $dbh->selectrow_array( "SELECT count(*) FROM SISCRSS WHERE Subj_Code = $quotedsubj AND Crse_Code= $quotedcrse AND Sctn_Term_Code =$quotedterm ");
                     if ($count > 0) {
                         $outcome = 'valid';
+                        $description = $subj.$crse;
+                        $year =~ s/^0//;
+                        my $longyr = 2000 + int($year);
+                        if (defined($longsem{$sem}) && ($year)) {
+                            $description .= ', '.$longsem{$sem}.' '.$longyr;
+                        }
                         eval {
-                            $description = $dbh->selectrow_array( "SELECT DISTINCT(Crse_Title) FROM SISCRSD WHERE (Subj_Code = $quotedsubj AND Crse_Code= $quotedcrse)");
-                            if ($description ne '') {
-                                my ($sem,$year) = ($term =~ /^([suf]s)(\d{2})$/);
-                                $year =~ s/^0//;
-                                my $longyr = 2000 + int($year);
-                                if (defined($longsem{$sem}) && ($year)) {
-                                    $description = $longsem{$sem}.', '.$longyr.' - '.$description;
-                                }
+                            my $title = $dbh->selectrow_array( "SELECT DISTINCT(Crse_Title) FROM SISCRSD WHERE (Subj_Code = $quotedsubj AND Crse_Code= $quotedcrse)");
+                            if ($title ne '') {
+                                $description .= ' - '.$title;
                             }
-                        }
+                        };
                     } else {
                         $outcome = "There was no match in the MSU $database database to the combination of semester ($term), subject ($subj), course number ($crse) you entered.";
                     }