feat: add optional student nickname for informal display
Keep legal first and last names for formal lists; show DisplayFirstName on teams, calendars, and import matching so two Josiahs can be told apart. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,6 +9,10 @@ public class AssignmentRequirementParser : CsvParserBase
|
||||
{
|
||||
}
|
||||
|
||||
public AssignmentRequirementParser(StreamReader reader, bool ignoreBlankLines = true) : base(reader, ignoreBlankLines)
|
||||
{
|
||||
}
|
||||
|
||||
public AssignmentRequirement[] Parse(ICollection<EventDefinition> events, ICollection<Student> students)
|
||||
{
|
||||
var assumptions = new List<AssignmentRequirement>();
|
||||
@@ -20,7 +24,11 @@ public class AssignmentRequirementParser : CsvParserBase
|
||||
|
||||
var studentArray =
|
||||
studentColumns
|
||||
.Select(c => students.FirstOrDefault(s => s.FirstName == c)).ToArray();
|
||||
.Select(c => students.FirstOrDefault(s =>
|
||||
string.Equals(s.DisplayFirstName, c, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(s.Nickname, c, StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(s.FirstName, c, StringComparison.OrdinalIgnoreCase)))
|
||||
.ToArray();
|
||||
|
||||
while (CsvReader.Read())
|
||||
{
|
||||
|
||||
@@ -23,7 +23,14 @@ public static class FuzzyStudentMatcher
|
||||
|
||||
public static int Score(Student student, string name)
|
||||
{
|
||||
var candidates = new[] { student.Name, student.FirstNameLastName, student.LastNameFirstName };
|
||||
var candidates = new[]
|
||||
{
|
||||
student.Name,
|
||||
student.FirstNameLastName,
|
||||
student.LastNameFirstName,
|
||||
student.DisplayFirstName,
|
||||
student.Nickname
|
||||
}.Where(c => !string.IsNullOrWhiteSpace(c));
|
||||
return candidates.Max(candidate => Math.Max(Fuzz.Ratio(candidate, name), Fuzz.TokenSetRatio(candidate, name)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,10 @@ namespace Core.Parsers
|
||||
{
|
||||
}
|
||||
|
||||
public TeamParser(StreamReader reader, bool ignoreBlankLines = true) : base(reader, ignoreBlankLines)
|
||||
{
|
||||
}
|
||||
|
||||
public Team[] Parse(ICollection<EventDefinition> events, ICollection<Student> students)
|
||||
{
|
||||
var teams = new List<Team>();
|
||||
@@ -118,7 +122,9 @@ namespace Core.Parsers
|
||||
{
|
||||
Fuzz.Ratio(s.Name, studentName),
|
||||
Fuzz.Ratio(s.FirstNameLastName, studentName),
|
||||
Fuzz.Ratio(s.FirstName, studentName)
|
||||
Fuzz.Ratio(s.FirstName, studentName),
|
||||
Fuzz.Ratio(s.DisplayFirstName, studentName),
|
||||
string.IsNullOrWhiteSpace(s.Nickname) ? 0 : Fuzz.Ratio(s.Nickname, studentName)
|
||||
}.Max()
|
||||
where rat > 90
|
||||
orderby rat descending
|
||||
|
||||
Reference in New Issue
Block a user