[LON-CAPA-cvs] cvs: modules /msu localenroll.pm
raeburn
raeburn at source.lon-capa.org
Sun Sep 5 14:58:35 EDT 2021
raeburn Sun Sep 5 18:58:35 2021 EDT
Modified files:
/modules/msu localenroll.pm
Log:
- Integration with MSU campus information systems
Using student's preferred first name (if available) and extracting
generational post-nominals (II, III, IV, V, VI, VII, Jr or Sr).
Index: modules/msu/localenroll.pm
diff -u modules/msu/localenroll.pm:1.81 modules/msu/localenroll.pm:1.82
--- modules/msu/localenroll.pm:1.81 Thu Jun 17 17:12:10 2021
+++ modules/msu/localenroll.pm Sun Sep 5 18:58:35 2021
@@ -1,6 +1,6 @@
# functions to glue school database system into Lon-CAPA for
# automated enrollment
-# $Id: localenroll.pm,v 1.81 2021/06/17 17:12:10 raeburn Exp $
+# $Id: localenroll.pm,v 1.82 2021/09/05 18:58:35 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -190,22 +190,30 @@
$subj =~tr/a-z/A-Z/;
$crse =~tr/a-z/A-Z/;
$sec =~s/^_//;
- my $sth = $dbh->prepare("SELECT Pid,Pilot_Id,Student_Name,Sctn_Crdt_Hours FROM RO_ClassList WHERE (Term_Code = '$sem' AND Subj_Code = '$subj' AND Crse_Code = '$crse' AND Sctn_Code = '$sec') ORDER BY Student_Name");
+ my $sth = $dbh->prepare("SELECT Pid,Pilot_Id,Student_Name,Student_Preferred_First_Name,Sctn_Crdt_Hours FROM RO_ClassList WHERE (Term_Code = '$sem' AND Subj_Code = '$subj' AND Crse_Code = '$crse' AND Sctn_Code = '$sec') ORDER BY Student_Name");
$sth->execute();
- while ( my($pid,$pilot,$name,$credits) = $sth->fetchrow_array ) {
+ while ( my($pid,$pilot,$name,$first,$credits) = $sth->fetchrow_array ) {
if ($pilot =~ /^\w{2,8}$/) {
$pilotcount ++;
$name =~ s/^\s+//;
$name =~ s/\s+$//;
- my ($last,$given,$first,$middle);
- $last = substr($name,0,index($name,","));
- $given = substr($name,index($name,",")+1);
- $given =~ s/^\s//g;
+ $first =~ s/^\s+//;
+ $first =~ s/\s+$//;
+ my ($last,$given,$middle,$generation);
+ ($last,$given) = split(/\,/,$name,2);
+ $last =~ s/\s+$//;
+ if ($last =~ /^([\w\s]+)\s+(II|III|IV|V|VI|VII|Jr|Sr)$/) {
+ $last = $1;
+ $generation = $2;
+ }
+ $given =~ s/^\s+//;
if ($given =~ m/\w\s+\w/) {
- $first = substr($given,0,index($given," "));
- $middle = substr($given,index($given," ")+1);
- $middle =~ s/\s//g;
- } else {
+ (my $officialfirst,$middle) = split(/\s+/,$given,2);
+ if ($first eq '') {
+ $first = $officialfirst;
+ }
+ $middle =~ s/\s+$//;
+ } elsif ($first eq '') {
$first = $given;
}
$first =~ s/\s+$//;
More information about the LON-CAPA-cvs
mailing list