feat: Unterrichtsmodus - konsolidierte Ansicht für die laufende Stunde
Verlaufsplan und Sitzplan bisher über mehrere Tabs verteilt, obwohl im Unterricht selbst beides gleichzeitig gebraucht wird. Neuer Button "▶ Unterricht" in der "Heute"-Tagesliste des Stundenplans (nur bei vorhandener Lesson) öffnet ein maximiertes Fenster: links der schreibgeschützte Verlaufsplan als kompakte Kartenliste, rechts der volle, unverändert wiederverwendete SeatingPlanTabView (Drag&Drop, Schnellbewertung, Situations-Tags, PDF-Export). TeachingModeViewModel baut auf dem bestehenden LessonViewerViewModel auf, dadurch kommen "Zur Mitarbeit"/"Zu den Noten" ohne Duplizierung mit. Neue SeatingPlanTabViewModel.SelectOrCreateSessionForLesson verknüpft die Mitarbeitssitzung automatisch mit der konkreten Stunde - anders als die bestehende EnsureTodaySession darf das hier sofort beim Start passieren, da durch den expliziten Klick für genau diese Stunde eindeutig feststeht, worum es geht (keine Geistersitzungs-Gefahr wie beim bloßen Tab-Öffnen). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -235,6 +235,65 @@ public sealed class SeatingPlanViewModelTests
|
||||
Assert.False(vm.Seats[1].IsOccupied);
|
||||
}
|
||||
|
||||
// ── Unterrichtsmodus (14.x): Sitzung mit einer konkreten Stunde verknüpfen ────────────────
|
||||
|
||||
[Fact]
|
||||
public void SelectOrCreateSessionForLesson_BereitsVerknuepfteSitzungVorhanden_WaehltSieAus()
|
||||
{
|
||||
var groupId = Guid.NewGuid();
|
||||
var lesson = new Lesson { GroupId = groupId, Date = DateOnly.FromDateTime(DateTime.Today), Topic = "Redox" };
|
||||
var existingSession = new ParticipationSession
|
||||
{ GroupId = groupId, Date = lesson.Date, LessonId = lesson.Id, Comment = "Redox" };
|
||||
var sessions = new FakeSessions([existingSession]);
|
||||
var plan = new SeatingPlan { GroupId = groupId, Name = "Standard", Rows = 1, Columns = 1 };
|
||||
var vm = new SeatingPlanTabViewModel(new FakeSeatingPlans([plan]), new FakeStudents([]),
|
||||
new FakeMemberships([]), sessions, new FakeEntries(), new FakeAspects());
|
||||
vm.Initialize(groupId, isReadOnly: false);
|
||||
|
||||
vm.SelectOrCreateSessionForLesson(lesson);
|
||||
|
||||
Assert.Equal(existingSession.Id, vm.SelectedSession?.Id);
|
||||
Assert.Single(sessions.GetByGroup(groupId));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SelectOrCreateSessionForLesson_KeineSitzungVorhanden_LegtVerknuepfteAnUndWaehltSieAus()
|
||||
{
|
||||
var groupId = Guid.NewGuid();
|
||||
var lesson = new Lesson
|
||||
{ GroupId = groupId, Date = DateOnly.FromDateTime(DateTime.Today), Topic = "Redox" };
|
||||
var sessions = new FakeSessions([]);
|
||||
var plan = new SeatingPlan { GroupId = groupId, Name = "Standard", Rows = 1, Columns = 1 };
|
||||
var vm = new SeatingPlanTabViewModel(new FakeSeatingPlans([plan]), new FakeStudents([]),
|
||||
new FakeMemberships([]), sessions, new FakeEntries(), new FakeAspects());
|
||||
vm.Initialize(groupId, isReadOnly: false);
|
||||
|
||||
vm.SelectOrCreateSessionForLesson(lesson);
|
||||
|
||||
var created = Assert.Single(sessions.GetByGroup(groupId));
|
||||
Assert.Equal(lesson.Id, created.LessonId);
|
||||
Assert.Equal(lesson.Topic, created.Comment);
|
||||
Assert.Equal(vm.SelectedSession?.Id, created.Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SelectOrCreateSessionForLesson_ArchivierteGruppe_LegtKeineSitzungAn()
|
||||
{
|
||||
var groupId = Guid.NewGuid();
|
||||
var lesson = new Lesson
|
||||
{ GroupId = groupId, Date = DateOnly.FromDateTime(DateTime.Today), Topic = "Redox" };
|
||||
var sessions = new FakeSessions([]);
|
||||
var plan = new SeatingPlan { GroupId = groupId, Name = "Standard", Rows = 1, Columns = 1 };
|
||||
var vm = new SeatingPlanTabViewModel(new FakeSeatingPlans([plan]), new FakeStudents([]),
|
||||
new FakeMemberships([]), sessions, new FakeEntries(), new FakeAspects());
|
||||
vm.Initialize(groupId, isReadOnly: true);
|
||||
|
||||
vm.SelectOrCreateSessionForLesson(lesson);
|
||||
|
||||
Assert.Empty(sessions.GetByGroup(groupId));
|
||||
Assert.Null(vm.SelectedSession);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShowSeatUndCanToggleHidden_HaengenVonBearbeitungsmodusUndBelegungAb()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
using LehrerApp.Core.Models;
|
||||
using LehrerApp.Desktop.ViewModels.Groups;
|
||||
using Xunit;
|
||||
|
||||
namespace LehrerApp.Desktop.Tests;
|
||||
|
||||
public sealed class TeachingModeViewModelTests
|
||||
{
|
||||
private static SeatingPlanTabViewModel BuildSeatingPlan(Guid groupId, FakeSessions? sessions = null,
|
||||
List<Student>? students = null, List<GroupMembership>? memberships = null,
|
||||
List<SeatingPlan>? plans = null) =>
|
||||
new(new FakeSeatingPlans(plans ?? [new SeatingPlan { GroupId = groupId, Name = "Standard", Rows = 1, Columns = 1 }]),
|
||||
new FakeStudents(students ?? []), new FakeMemberships(memberships ?? []),
|
||||
sessions ?? new FakeSessions([]), new FakeEntries(), new FakeAspects());
|
||||
|
||||
[Fact]
|
||||
public void Konstruktor_LaedtVerlaufsplanUndInitialisiertSitzplanFuerDieGruppe()
|
||||
{
|
||||
var group = new LearningGroup { Name = "Q1 Chemie" };
|
||||
var lesson = new Lesson
|
||||
{
|
||||
GroupId = group.Id, Date = DateOnly.FromDateTime(DateTime.Today), Topic = "Redox",
|
||||
Phases = [new LessonPhaseStep { Name = "Einstieg", DurationMinutes = 10, Activity = "Impuls" }],
|
||||
};
|
||||
var seatingPlan = BuildSeatingPlan(group.Id);
|
||||
|
||||
var vm = new TeachingModeViewModel(lesson, group, new FakeAlternativeLessonPaths([]), seatingPlan);
|
||||
|
||||
Assert.Equal("Q1 Chemie", vm.GroupName);
|
||||
Assert.Equal("Redox", vm.LessonInfo.Topic);
|
||||
Assert.Single(vm.LessonInfo.PhaseGroups.Single().Phases);
|
||||
Assert.True(vm.SeatingPlan.HasSelectedPlan);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Konstruktor_VerknuepftDieSitzungMitDieserStunde()
|
||||
{
|
||||
var group = new LearningGroup { Name = "Q1 Chemie" };
|
||||
var lesson = new Lesson
|
||||
{ GroupId = group.Id, Date = DateOnly.FromDateTime(DateTime.Today), Topic = "Redox" };
|
||||
var sessions = new FakeSessions([]);
|
||||
var seatingPlan = BuildSeatingPlan(group.Id, sessions);
|
||||
|
||||
var vm = new TeachingModeViewModel(lesson, group, new FakeAlternativeLessonPaths([]), seatingPlan);
|
||||
|
||||
var created = Assert.Single(sessions.GetByGroup(group.Id));
|
||||
Assert.Equal(lesson.Id, created.LessonId);
|
||||
Assert.Equal(vm.SeatingPlan.SelectedSession?.Id, created.Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Konstruktor_BereitsExistierendeVerknuepfteSitzung_WirdWiederverwendet()
|
||||
{
|
||||
var group = new LearningGroup { Name = "Q1 Chemie" };
|
||||
var lesson = new Lesson
|
||||
{ GroupId = group.Id, Date = DateOnly.FromDateTime(DateTime.Today), Topic = "Redox" };
|
||||
var existing = new ParticipationSession
|
||||
{ GroupId = group.Id, Date = lesson.Date, LessonId = lesson.Id, Comment = "Redox" };
|
||||
var sessions = new FakeSessions([existing]);
|
||||
var seatingPlan = BuildSeatingPlan(group.Id, sessions);
|
||||
|
||||
var vm = new TeachingModeViewModel(lesson, group, new FakeAlternativeLessonPaths([]), seatingPlan);
|
||||
|
||||
Assert.Single(sessions.GetByGroup(group.Id));
|
||||
Assert.Equal(existing.Id, vm.SeatingPlan.SelectedSession?.Id);
|
||||
}
|
||||
|
||||
/// Eine archivierte Gruppe darf im Unterrichtsmodus nicht bearbeitbar sein - genau wie in der
|
||||
/// normalen Gruppenansicht (GroupDetailViewModel.IsReadOnly).
|
||||
[Fact]
|
||||
public void Konstruktor_ArchivierteGruppe_InitialisiertSitzplanSchreibgeschuetzt()
|
||||
{
|
||||
var group = new LearningGroup { Name = "Q1 Chemie", IsActive = false };
|
||||
var lesson = new Lesson
|
||||
{ GroupId = group.Id, Date = DateOnly.FromDateTime(DateTime.Today), Topic = "Redox" };
|
||||
var seatingPlan = BuildSeatingPlan(group.Id);
|
||||
|
||||
var vm = new TeachingModeViewModel(lesson, group, new FakeAlternativeLessonPaths([]), seatingPlan);
|
||||
|
||||
Assert.False(vm.SeatingPlan.IsEditable);
|
||||
}
|
||||
}
|
||||
@@ -275,6 +275,44 @@ public sealed class TimetableViewModelTests
|
||||
Assert.Equal("Zur Lerngruppe", vm.TodayItems[0].OpenButtonLabel);
|
||||
}
|
||||
|
||||
// ── Unterrichtsmodus (14.x) ────────────────────────────────────────────────
|
||||
|
||||
[Fact]
|
||||
public async Task StartTeachingMode_MitVorhandenerLesson_OeffnetDenUnterrichtsmodus()
|
||||
{
|
||||
var today = DateOnly.FromDateTime(DateTime.Today);
|
||||
var group = new LearningGroup { Name = "Q1 Chemie" };
|
||||
var slots = new FakeTimetableSlots();
|
||||
slots.Add(new TimetableSlot { GroupId = group.Id, Weekday = today.DayOfWeek, PeriodNumber = 1 });
|
||||
var lesson = new Lesson { GroupId = group.Id, Date = today, LessonNumber = 1, Topic = "Redox" };
|
||||
var lessons = new FakeLessons();
|
||||
lessons.Add(lesson);
|
||||
var vm = BuildViewModel(slots, new FakeGroups([group]), lessons: lessons);
|
||||
Lesson? openedLesson = null;
|
||||
vm.OnOpenTeachingMode = l => { openedLesson = l; return Task.CompletedTask; };
|
||||
|
||||
await vm.StartTeachingModeCommand.ExecuteAsync(vm.TodayItems[0]);
|
||||
|
||||
Assert.Equal(lesson.Id, openedLesson?.Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task StartTeachingMode_OhneVorhandeneLesson_TutNichts()
|
||||
{
|
||||
var today = DateOnly.FromDateTime(DateTime.Today);
|
||||
var group = new LearningGroup { Name = "Q1 Chemie" };
|
||||
var slots = new FakeTimetableSlots();
|
||||
slots.Add(new TimetableSlot { GroupId = group.Id, Weekday = today.DayOfWeek, PeriodNumber = 1 });
|
||||
var vm = BuildViewModel(slots, new FakeGroups([group]));
|
||||
var opened = false;
|
||||
vm.OnOpenTeachingMode = _ => { opened = true; return Task.CompletedTask; };
|
||||
|
||||
await vm.StartTeachingModeCommand.ExecuteAsync(vm.TodayItems[0]);
|
||||
|
||||
Assert.False(opened);
|
||||
Assert.False(vm.TodayItems[0].HasLesson);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task OpenWeekCell_MitVorhandenerLesson_OeffnetDenViewer()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user