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
@@ -1,3 +1,5 @@
|
||||
using LehrerApp.Core.Models;
|
||||
|
||||
namespace LehrerApp.Desktop.ViewModels.ClassTeacher;
|
||||
|
||||
/// <summary>
|
||||
@@ -20,4 +22,21 @@ public static class UntisNameMatching
|
||||
.Where(w => w.Length > 0)
|
||||
.Select(w => w.ToLowerInvariant())
|
||||
.OrderBy(w => w, StringComparer.Ordinal));
|
||||
|
||||
/// <summary>Verwendet die Instanzen aus der Auswahlliste. Repository-Abfragen für eine Klasse
|
||||
/// liefern neue Student-Objekte mit derselben Id, die ein ComboBox.SelectedItem nicht erkennt.</summary>
|
||||
public static Dictionary<string, Student> BuildClassNameIndex(IReadOnlyList<Student> candidates,
|
||||
IEnumerable<Student> classStudents)
|
||||
{
|
||||
var classStudentIds = classStudents.Select(s => s.Id).ToHashSet();
|
||||
return BuildNameIndex(candidates.Where(s => classStudentIds.Contains(s.Id)));
|
||||
}
|
||||
|
||||
public static Dictionary<string, Student> BuildNameIndex(IEnumerable<Student> candidates) =>
|
||||
candidates
|
||||
.Select(student => (Key: NameKey(student.FullName), Student: student))
|
||||
.Where(x => x.Key.Length > 0)
|
||||
.GroupBy(x => x.Key)
|
||||
.Where(group => group.Select(x => x.Student.Id).Distinct().Count() == 1)
|
||||
.ToDictionary(group => group.Key, group => group.First().Student);
|
||||
}
|
||||
Reference in new issue
Block a user