$phash->{student_id} = sprintf('%04s', $phash->{student_id})
if $is_teacher && length($phash->{student_id}) < 4;
- # All teacher ID's, which can be alpha-numeric, are upper case.
- # Student ID's can also be alpha-numeric, but remain in the
- # provided case.
- $phash->{student_id} = uc($phash->{student_id}) if $is_teacher;
+ if ($is_college) {
+ # College student/teacher IDs are email addresses.
+ my $s = $phash->{student_id};
+ # Remove the @domain just in case
+ $s =~ s/@.*//g;
+ # Barcodes cannot have non-ascii chars, strip them.
+ $s =~ s/[^[:ascii:]]//g;
+ # Email barcodes are lowercase
+ $s = lc($s);
+ # a minimal set of characters are allowed.
+ $s =~ s/[^a-z0-9_\-\.]//g;
+ $phash->{student_id} = $s;
+
+ } elsif ($is_teacher) {
+ # All non-college teacher ID's, which can be alpha-numeric,
+ # are upper case. Student ID's can also be alpha-numeric,
+ # but remain in the provided case.
+ $phash->{student_id} = uc($phash->{student_id});
+ }
# Avoid processing duplicates
next if $seen{$phash->{student_id}};
$phash->{barcode} = $district_code;
$phash->{barcode} = uc($district_code) if $is_college;
- $phash->{barcode} .= 't' if $is_teacher;
+ if ($is_teacher) {
+ $phash->{barcode} .= $is_college ? 'e' : 't';
+ }
$phash->{barcode} .= $phash->{student_id};
$row_handler->($phash);