[LON-CAPA-cvs] cvs: modules /msu localenroll.pm
raeburn
raeburn at source.lon-capa.org
Sun Jan 9 18:46:37 EST 2022
raeburn Sun Jan 9 23:46:37 2022 EDT
Modified files:
/modules/msu localenroll.pm
Log:
- Integration with MSU campus information systems
- Automated updates for first name, middle name, last name etc. will
convert results in uppercase to only first letter of each word capitalized
(including hyphenated names). Special cases for last names:
von Name, O'Name and McName include appropriate capitalization.
- Automated updates for middle name will convert to a middle initial only,
unless user is a student, or middle name contains multiple words.
Index: modules/msu/localenroll.pm
diff -u modules/msu/localenroll.pm:1.84 modules/msu/localenroll.pm:1.85
--- modules/msu/localenroll.pm:1.84 Wed Sep 8 23:36:58 2021
+++ modules/msu/localenroll.pm Sun Jan 9 23:46:37 2022
@@ -1,6 +1,6 @@
# functions to glue school database system into Lon-CAPA for
# automated enrollment
-# $Id: localenroll.pm,v 1.84 2021/09/08 23:36:58 raeburn Exp $
+# $Id: localenroll.pm,v 1.85 2022/01/09 23:46:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -217,6 +217,22 @@
$first = $given;
}
$first =~ s/\s+$//;
+ foreach my $item ($first,$middle) {
+ next if ($item eq '');
+ if ($item eq uc($item)) {
+ $item =~ s/([\w']+)/\u\L$1/g;
+ }
+ }
+ if (($last ne '') && ($last eq uc($last))) {
+ $last =~ s/([\w']+)/\u\L$1/g;
+ if ($last =~ /^Von\s+\w+/) {
+ $last =~ s/^V/v/;
+ } elsif ($last =~ /^O'\w+/) {
+ $last =~ s/^(O')(\w)/$1\u$2/;
+ } elsif ($last =~ /^Mc\w{2,}/) {
+ $last =~ s/^(Mc)(\w)/$1\u$2/;
+ }
+ }
$pid =~ s/^1(\d{8})$/A$1/;
print FILE qq| <student username="$pilot">
<autharg>MSU.EDU</autharg>
@@ -1736,7 +1752,7 @@
$first = $officialfirst;
}
$middle =~ s/\s+$//;
- unless ($type eq 'Student') {
+ if (($middle ne '') && ($type ne 'Student') & ($middle !~ /\s/)) {
$middle = substr($middle, 0, 1);
}
} elsif ($first eq '') {
@@ -1748,7 +1764,22 @@
$generation = $2;
}
$first =~ s/\s+$//;
- ($first,$middle,$last) = map { ucfirst(lc($_)); } ($first,$middle,$last);
+ foreach my $item ($first,$middle) {
+ next if ($item eq '');
+ if ($item eq uc($item)) {
+ $item =~ s/([\w']+)/\u\L$1/g;
+ }
+ }
+ if (($last ne '') && ($last eq uc($last))) {
+ $last =~ s/([\w']+)/\u\L$1/g;
+ if ($last =~ /^Von\s+\w+/) {
+ $last =~ s/^V/v/;
+ } elsif ($last =~ /^O'\w+/) {
+ $last =~ s/^(O')(\w)/$1\u$2/;
+ } elsif ($last =~ /^Mc\w{2,}/) {
+ $last =~ s/^(Mc)(\w)/$1\u$2/;
+ }
+ }
if (ref($instusers->{$uname}) eq 'HASH') {
unless ($type eq '') {
if (ref($instusers->{$uname}{'inststatus'}) eq 'ARRAY') {
@@ -1859,7 +1890,22 @@
$name =~ s/\Q$last\E$//;
}
$name =~ s/^\s+|\s+$//g;
- ($first,$name,$last) = map { ucfirst(lc($_)); } ($first,$name,$last);
+ foreach my $item ($first,$name) {
+ next if ($item eq '');
+ if ($item eq uc($item)) {
+ $item =~ s/([\w']+)/\u\L$1/g;
+ }
+ }
+ if (($last ne '') && ($last eq uc($last))) {
+ $last =~ s/([\w']+)/\u\L$1/g;
+ if ($last =~ /^Von\s+\w+/) {
+ $last =~ s/^V/v/;
+ } elsif ($last =~ /^O'\w+/) {
+ $last =~ s/^(O')(\w)/$1\u$2/;
+ } elsif ($last =~ /^Mc\w{2,}/) {
+ $last =~ s/^(Mc)(\w)/$1\u$2/;
+ }
+ }
my $type = $entry->get_value('employeeType');
unless (($type eq 'Faculty') || ($type eq 'Staff')) {
$type = $entry->get_value('title');
@@ -1867,10 +1913,10 @@
undef($type);
}
}
- if ($type eq 'Student') {
- $middle = $name;
- } else {
+ if (($name ne '') && ($type ne 'Student') & ($name !~ /\s/)) {
$middle = substr($name, 0, 1);
+ } else {
+ $middle = $name;
}
if (ref($types) eq 'ARRAY') {
if (@{$types} > 0) {
@@ -1957,8 +2003,28 @@
$name =~ s/\Q$last\E$//;
}
$name =~ s/^\s+|\s+$//g;
- my $middle = substr($name, 0, 1);
- ($first,$middle,$last) = map { ucfirst(lc($_)); } ($first,$middle,$last);
+ my $middle;
+ if (($name ne '') && ($type ne 'Student') & ($name !~ /\S/)) {
+ $middle = substr($name, 0, 1);
+ } else {
+ $middle = $name;
+ }
+ foreach my $item ($first,$middle) {
+ next if ($item eq '');
+ if ($item eq uc($item)) {
+ $item =~ s/([\w']+)/\u\L$1/g;
+ }
+ }
+ if (($last ne '') && ($last eq uc($last))) {
+ $last =~ s/([\w']+)/\u\L$1/g;
+ if ($last =~ /^Von\s+\w+/) {
+ $last =~ s/^V/v/;
+ } elsif ($last =~ /^O'\w+/) {
+ $last =~ s/^(O')(\w)/$1\u$2/;
+ } elsif ($last =~ /^Mc\w{2,}/) {
+ $last =~ s/^(Mc)(\w)/$1\u$2/;
+ }
+ }
$instusers->{$uname} = {firstname => $first,
middlename => $middle,
lastname => $last,
More information about the LON-CAPA-cvs
mailing list