diff --git a/IServ_Elternimport_Divis.php b/IServ_Elternimport_Divis.php index 4ab67cc..55c280a 100644 --- a/IServ_Elternimport_Divis.php +++ b/IServ_Elternimport_Divis.php @@ -19,6 +19,7 @@ * $ php ./IServ_Elternimport_Divis.php iserv-user-export.csv divis-parents-export.csv > Parents_Import.csv */ +define ("MIN_NAME_MATCHING_PERCENTAGE", 85); define ("WRITE_TO_CONSOLE", true); define ("IS_CLI", (php_sapi_name() == "cli")); @@ -71,7 +72,10 @@ function find_parent_by_student ($firstname, $lastname) { // If match is bigger or equal to 85% and this match is higher // ranked than the last, make this the current best match - if ($perc >= 85 && $best_match["match_perc"] < $perc) { + if ( + $perc >= MIN_NAME_MATCHING_PERCENTAGE && + $best_match["match_perc"] < $perc + ) { console_write ("INFO: New best match '{$hash}' at {$perc}%"); $best_match = [ "match_perc" => $perc, diff --git a/README.md b/README.md index f3f1a4b..e27647b 100644 --- a/README.md +++ b/README.md @@ -4,15 +4,23 @@ This script takes two files, an IServ user export CSV and a DiViS student <> par and maps the parents to the IServ students, creating a third CSV file that can be imported into the IServ Elternverwaltung module. -The IServ user export CSV is expected to have the following columns: +The IServ user export CSV is expected to have the following columns: `Account;Vorname;Nachname;Status;"Erstellt am";"Erstellt von";"Interne ID";Benutzertyp;Import-ID;Klasse/Information;E-Mail-Adresse;Gruppen` -The student <> parents mapped CSV from DiViS should have the following columns: +The student <> parents mapped CSV from DiViS should have the following columns: `"Schüler Vorname","Schüler Nachname","Eltern 1 Vorname","Eltern 1 Nachname","Eltern 2 Vorname","Eltern 2 Nachname"` -The CSV exported by this script will have the following columns: +The CSV exported by this script will have the following columns: `Nachname;Vorname;Kind-ID;Klasse` +Rows that are not of type "Schüler" in the IServ user export CSV are skipped. Students for which a parent +was not found are skipped in the output CSV, however a warning is displayed. + +To compare the first and last name of the student to the DiViS list, the `similar_text()` PHP function is used to allow +minimal character spelling mistakes between the two files. This behaviour can be disabled by adjusting the +MIN_NAME_MATCHING_PERCENTAGE constant defined at the top of the script to 100, meaning the first and last names must +match exactly. Otherwise, only 85% of the name must match (typically equating to 1-2 different characters per full name). + Status messages, information and errors are always written to `STDERR`, while the generated CSV will be exported to `STDOUT`, meaning you can redirect the `STDOUT` output of this script to a file to export the CSV and still be able to read any informational messages: