Stundenplan und Untis-Namensabgleich verbessern
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
admin committed 2026-09-25 11:54:51 +02:00
1 parent 45b7a2b7e6
commit 960d52686a
8 files changed
+98 -51

No files matched your search

@@ -6,6 +6,7 @@ using LehrerApp.Core.Interfaces;
using LehrerApp.Core.Models;
using LehrerApp.Core.Services;
using LehrerApp.Desktop.Services;
using LehrerApp.Desktop.ViewModels.ClassTeacher;
namespace LehrerApp.Desktop.ViewModels.Groups;
@@ -130,7 +131,7 @@ public partial class WebUntisHomeworkComparisonViewModel : ObservableObject
foreach (var (entry, date) in ordered)
{
var nameKey = NameKey(entry.StudentName);
var nameKey = UntisNameMatching.NameKey(entry.StudentName);
var match = (classIndexes.TryGetValue(entry.ClassName, out var classIndex)
? classIndex.GetValueOrDefault(nameKey)
: null)
@@ -209,17 +210,11 @@ public partial class WebUntisHomeworkComparisonViewModel : ObservableObject
return null;
}
private static string NameKey(string value) => value.Trim().ToLowerInvariant();
// Wie bei den übrigen WebUntis-Abgleichen: beide Namensreihenfolgen registriert, aber nur falls
// innerhalb der Kandidaten eindeutig.
// Wie bei den übrigen WebUntis-Abgleichen: Reihenfolge und Satzzeichen werden normalisiert,
// aber nur innerhalb der Kandidaten eindeutige Namen automatisch zugeordnet.
private static Dictionary<string, Student> BuildNameIndex(IReadOnlyList<Student> candidates) =>
candidates
.SelectMany(student => new[]
{
NameKey($"{student.LastName} {student.FirstName}"),
NameKey($"{student.FirstName} {student.LastName}"),
}.Select(key => (Key: key, Student: student)))
.Select(student => (Key: UntisNameMatching.NameKey(student.FullName), Student: student))
.GroupBy(x => x.Key)
.Where(group => group.Select(x => x.Student).Distinct().Count() == 1)
.ToDictionary(group => group.Key, group => group.First().Student);