Fix Untis homework comparison and student selection
This commit is contained in:
1 parent
1291b24478
commit
f3e23ad207
8 files changed
+372
-66
No files matched your search
@@ -82,7 +82,7 @@ public partial class WebUntisDocumentationComparisonViewModel : ObservableObject
|
||||
try
|
||||
{
|
||||
var ownStudents = _students.GetAll();
|
||||
var globalIndex = BuildNameIndex(ownStudents);
|
||||
var globalIndex = UntisNameMatching.BuildNameIndex(ownStudents);
|
||||
// Zusätzlich pro Klasse (aktuelles Schuljahr) indiziert: löst den Fall "gleicher Name in
|
||||
// verschiedenen Klassen" auf, den ein rein globaler Namensabgleich nicht unterscheiden könnte.
|
||||
var currentSchoolYear = _schoolYears.CurrentSchoolYear();
|
||||
@@ -91,7 +91,8 @@ public partial class WebUntisDocumentationComparisonViewModel : ObservableObject
|
||||
.GroupBy(g => g.Name, StringComparer.OrdinalIgnoreCase)
|
||||
.ToDictionary(
|
||||
g => g.Key,
|
||||
g => BuildNameIndex(g.SelectMany(x => _students.GetByGroup(x.Id)).Distinct().ToList()),
|
||||
g => UntisNameMatching.BuildClassNameIndex(ownStudents,
|
||||
g.SelectMany(x => _students.GetByGroup(x.Id))),
|
||||
StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var entries = await _untis.GetOwnClassRegisterEventsAsync(start, end);
|
||||
@@ -173,15 +174,6 @@ public partial class WebUntisDocumentationComparisonViewModel : ObservableObject
|
||||
Status = $"{selected.Count} Einträge aus WebUntis übernommen.";
|
||||
}
|
||||
|
||||
// Die gemeinsame Untis-Normalisierung ignoriert Reihenfolge, Komma und abweichende Leerzeichen.
|
||||
// Mehrdeutige Namen bleiben weiterhin bewusst ohne automatische Vorauswahl.
|
||||
private static Dictionary<string, Student> BuildNameIndex(IReadOnlyList<Student> candidates) =>
|
||||
candidates
|
||||
.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);
|
||||
|
||||
private static bool TryDate(int value, out DateOnly date) =>
|
||||
DateOnly.TryParseExact(value.ToString(), "yyyyMMdd", out date);
|
||||
}
|
||||
Reference in new issue
Block a user