feat: add seating plans for learning groups

This commit is contained in:
2026-08-17 01:01:40 +02:00
parent fbf70df439
commit fe36f51886
19 changed files with 771 additions and 6 deletions
+58
View File
@@ -189,6 +189,9 @@ public sealed class RepositoryTests
var sectionId = Guid.NewGuid();
db.ParticipationSections.Insert(new ParticipationSection { Id = sectionId, GroupId = groupId });
var seatingPlanId = Guid.NewGuid();
db.SeatingPlans.Insert(new SeatingPlan { Id = seatingPlanId, GroupId = groupId, Name = "Raumplan" });
var documentationId = Guid.NewGuid();
db.Documentation.Insert(new Documentation { Id = documentationId, GroupId = groupId, StudentId = studentId });
@@ -214,6 +217,7 @@ public sealed class RepositoryTests
Assert.Null(db.ReportGrades.FindById(reportGradeId));
Assert.Null(db.GradingSchemes.FindById(gradingSchemeId));
Assert.Null(db.ParticipationSections.FindById(sectionId));
Assert.Null(db.SeatingPlans.FindById(seatingPlanId));
Assert.Null(db.Documentation.FindById(documentationId)?.GroupId);
Assert.Null(db.Tasks.FindById(taskId)?.GroupId);
Assert.Null(db.TimeEntries.FindById(timeEntryId)?.GroupId);
@@ -241,6 +245,60 @@ public sealed class RepositoryTests
// ── GroupMembershipRepository ────────────────────────────────────────────
[Fact]
public void SeatingPlanRepository_SpeichertMehrerePlaeneUndEindeutigeZuordnungen()
{
using var db = NewInMemoryContext();
var group = new LearningGroup { Name = "8a", SchoolYear = "2025/26" };
new GroupRepository(db).Save(group);
var anna = new Student { FirstName = "Anna", LastName = "A" };
var ben = new Student { FirstName = "Ben", LastName = "B" };
db.Students.InsertBulk([anna, ben]);
db.Memberships.InsertBulk([
new GroupMembership { GroupId = group.Id, StudentId = anna.Id },
new GroupMembership { GroupId = group.Id, StudentId = ben.Id },
]);
var repo = new SeatingPlanRepository(db);
repo.Save(new SeatingPlan
{
GroupId = group.Id, Name = "Standard", Room = "B204", Rows = 2, Columns = 2,
Assignments = [new SeatAssignment { Row = 0, Column = 0, StudentId = anna.Id }],
});
repo.Save(new SeatingPlan
{
GroupId = group.Id, Name = "Standard", Room = "Physik", Rows = 2, Columns = 3,
Assignments = [new SeatAssignment { Row = 1, Column = 2, StudentId = ben.Id }],
});
var plans = repo.GetByGroup(group.Id);
Assert.Equal(2, plans.Count);
Assert.Contains(plans, p => p.Room == "B204" && p.Assignments.Single().StudentId == anna.Id);
Assert.Contains(plans, p => p.Room == "Physik" && p.Assignments.Single().StudentId == ben.Id);
}
[Fact]
public void SeatingPlanRepository_LehntDoppeltZugeordnetenSchuelerAb()
{
using var db = NewInMemoryContext();
var group = new LearningGroup { Name = "8a", SchoolYear = "2025/26" };
new GroupRepository(db).Save(group);
var student = new Student { FirstName = "Anna", LastName = "A" };
db.Students.Insert(student);
db.Memberships.Insert(new GroupMembership { GroupId = group.Id, StudentId = student.Id });
var plan = new SeatingPlan
{
GroupId = group.Id, Name = "Standard", Rows = 2, Columns = 2,
Assignments =
[
new SeatAssignment { Row = 0, Column = 0, StudentId = student.Id },
new SeatAssignment { Row = 0, Column = 1, StudentId = student.Id },
],
};
Assert.Throws<InvalidOperationException>(() => new SeatingPlanRepository(db).Save(plan));
}
[Fact]
public void GroupMembershipRepository_Save_LehntZweiteZuordnungFuerGleichesPaarAb()
{