Neue Abwensenheitsmodi plus Upgrade Sitzplan

This commit is contained in:
2026-08-19 12:27:12 +02:00
parent 1731e5088e
commit b2c1b15167
16 changed files with 383 additions and 30 deletions
@@ -6,6 +6,24 @@ namespace LehrerApp.Desktop.Tests;
public sealed class QuickInputViewModelTests
{
[Theory]
[InlineData(AttendanceStatus.Late, false, "Verspätet", "V")]
[InlineData(AttendanceStatus.SignificantlyLate, false, "Erheblich verspätet", "V!")]
[InlineData(AttendanceStatus.LeftDuringClass, true, "Während des Unterrichts abgängig", "A")]
[InlineData(AttendanceStatus.LearningIsland, true, "Lerninsel", "L")]
[InlineData(AttendanceStatus.Suspended, true, "Suspendiert", "S")]
public void ZusaetzlicheAnwesenheitsstatus_HabenAnzeigeUndPassendeAbwesenheitswertung(
AttendanceStatus status, bool isAbsent, string label, string symbol)
{
var row = new ParticipationStudentRow(Guid.NewGuid(), "Anna",
new ParticipationEntry { Attendance = status }, [], []);
Assert.Equal(isAbsent, row.IsAbsent);
Assert.Equal(label, row.AttendanceTooltip);
Assert.Equal(symbol, row.AttendanceLabel);
Assert.False(string.IsNullOrWhiteSpace(AttendanceDisplay.Color(status)));
}
[Fact]
public void ZurueckZuVorherigemSchueler_ZeigtBereitsGesetzteBewertung()
{
@@ -1,11 +1,41 @@
using LehrerApp.Core.Models;
using LehrerApp.Desktop.ViewModels.Groups;
using LehrerApp.Desktop.Views.Groups;
using Xunit;
namespace LehrerApp.Desktop.Tests;
public sealed class SeatingPlanViewModelTests
{
[Fact]
public void TafelpositionWirdAusPlanGeladenUndBeimBearbeitenGespeichert()
{
var groupId = Guid.NewGuid();
var plan = new SeatingPlan
{
GroupId = groupId,
Name = "Standard",
Rows = 1,
Columns = 1,
IsBoardAtBottom = true,
};
var plans = new FakeSeatingPlans([plan]);
var tabVm = new SeatingPlanTabViewModel(
plans, new FakeStudents([]), new FakeMemberships([]),
new FakeSessions([]), new FakeEntries(), new FakeAspects());
tabVm.Initialize(groupId, isReadOnly: false);
Assert.True(tabVm.IsBoardAtBottom);
Assert.False(tabVm.IsBoardAtTop);
var dialogVm = tabVm.CreateDialogViewModel(plan);
dialogVm.IsBoardAtBottom = false;
dialogVm.SaveCommand.Execute(null);
Assert.False(plans.GetById(plan.Id)!.IsBoardAtBottom);
}
[Fact]
public void AuswahlEinesBereitsZugeordnetenSchuelers_VerschiebtIhnAufDenNeuenPlatz()
{
@@ -27,6 +57,7 @@ public sealed class SeatingPlanViewModelTests
var vm = new SeatingPlanTabViewModel(plans, students, memberships,
new FakeSessions([]), new FakeEntries(), new FakeAspects());
vm.Initialize(groupId, isReadOnly: false);
vm.IsEditMode = true;
vm.Seats[1].SelectedOption = vm.StudentOptions.Single(o => o.StudentId == student.Id);
@@ -75,6 +106,7 @@ public sealed class SeatingPlanViewModelTests
var vm = new SeatingPlanTabViewModel(plans, students, memberships,
new FakeSessions([]), new FakeEntries(), new FakeAspects());
vm.Initialize(groupId, isReadOnly: false);
vm.IsEditMode = true;
vm.MoveSeat(vm.Seats[0], vm.Seats[1]);
@@ -83,6 +115,78 @@ public sealed class SeatingPlanViewModelTests
Assert.Equal(2, plans.GetById(plan.Id)!.Assignments.Count);
}
[Fact]
public void Ansichtsmodus_VerhindertVerschiebenUndBlendetBearbeitungsbefehleAus()
{
var groupId = Guid.NewGuid();
var student = new Student { FirstName = "Anna", LastName = "A" };
var plan = new SeatingPlan
{
GroupId = groupId, Name = "Standard", Rows = 1, Columns = 2,
Assignments = [new SeatAssignment { Row = 0, Column = 0, StudentId = student.Id }],
};
var vm = new SeatingPlanTabViewModel(
new FakeSeatingPlans([plan]), new FakeStudents([student]),
new FakeMemberships([new GroupMembership { GroupId = groupId, StudentId = student.Id }]),
new FakeSessions([]), new FakeEntries(), new FakeAspects());
vm.Initialize(groupId, isReadOnly: false);
vm.MoveSeat(vm.Seats[0], vm.Seats[1]);
Assert.False(vm.IsEditMode);
Assert.False(vm.CanEditLayout);
Assert.False(vm.EditPlanCommand.CanExecute(null));
Assert.Equal(student.Id, vm.Seats[0].SelectedOption.StudentId);
Assert.Null(vm.Seats[1].SelectedOption.StudentId);
vm.IsEditMode = true;
Assert.True(vm.CanEditLayout);
Assert.True(vm.EditPlanCommand.CanExecute(null));
Assert.All(vm.Seats, seat => Assert.True(seat.CanEdit));
}
[Fact]
public void Tischabstaende_WerdenBeimBearbeitenProSpaltengrenzeGespeichert()
{
var groupId = Guid.NewGuid();
var plan = new SeatingPlan
{
GroupId = groupId, Name = "Standard", Rows = 2, Columns = 4,
ColumnGapWidths = [0, 80, 20],
};
var plans = new FakeSeatingPlans([plan]);
var vm = new SeatingPlanDialogViewModel(plans, groupId, plan);
Assert.Equal([0m, 80m, 20m], vm.ColumnGaps.Select(g => g.Width));
vm.ColumnGaps[0].Width = 40;
vm.SaveCommand.Execute(null);
Assert.Equal([40d, 80d, 20d], plans.GetById(plan.Id)!.ColumnGapWidths);
}
[Fact]
public void SitzplanPanel_FuegtAbstandNurAnKonfigurierterSpaltengrenzeEin()
{
var panel = new SeatingPlanPanel
{
Columns = 3,
ColumnGapWidths = [0, 70],
};
for (var i = 0; i < 6; i++)
panel.Children.Add(new Avalonia.Controls.Border { Width = 100, Height = 50 });
panel.Measure(Avalonia.Size.Infinity);
panel.Arrange(new Avalonia.Rect(panel.DesiredSize));
Assert.Equal(370, panel.DesiredSize.Width);
Assert.Equal(100, panel.DesiredSize.Height);
Assert.Equal(0, panel.Children[0].Bounds.X);
Assert.Equal(100, panel.Children[1].Bounds.X);
Assert.Equal(270, panel.Children[2].Bounds.X);
Assert.Equal(270, panel.Children[5].Bounds.X);
}
[Fact]
public void SitzplatzBewertung_ErstelltHeutigeSitzungUndSpeichertAlleDreiBereiche()
{