Teacher cards short username handles characters
authorBill Erickson <berickxx@gmail.com>
Mon, 11 Sep 2017 18:25:13 +0000 (14:25 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Fixes bug in teacher account generator so that it properly handles
student_id values less than 4 characters for both numbers and letters.

Previously it would fail padding non-numeric IDs.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/utility-scripts/import_students/generate-patrons-from-csv.pl

index df672e8..f36903c 100755 (executable)
@@ -271,7 +271,7 @@ sub iterate_csv_rows {
         # If the ID value is less than 4 characters, pad the value 
         # with zeros to be 4 characters long.  This will effect
         # the barcode and password.  Only do this for teacher accounts.
-        $phash->{student_id} = sprintf('%0.4d', $phash->{student_id})
+        $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.