using Avalonia.Controls; using Avalonia.Interactivity; using LehrerApp.Desktop.ViewModels; using LehrerApp.Desktop.ViewModels.Groups; using Microsoft.Extensions.DependencyInjection; namespace LehrerApp.Desktop.Views.Groups; public partial class TeachingModeWindow : Window { public TeachingModeWindow() => InitializeComponent(); protected override void OnDataContextChanged(EventArgs e) { base.OnDataContextChanged(e); // Gleiches Muster wie LessonViewerDialog (4.5.3): Fenster schließt zuerst, dann Sprung // über die MainWindowViewModel-Singleton-Navigation in den Ziel-Tab der Gruppe. if (DataContext is TeachingModeViewModel vm) { vm.LessonInfo.OnNavigateToTab = tabIndex => { Close(); App.Services.GetRequiredService() .NavigateToGroupDetail(vm.LessonInfo.GroupId, tabIndex); }; // Nutzer-Feedback: Schnellbewertung (Mitarbeit) und Schnellanwesenheit/Hausaufgabe // direkt aus dem Unterrichtsmodus statt erst zum Mitarbeit-Tab wechseln zu müssen — // dieselben Dialoge wie in ParticipationTabView.axaml.cs, hier auf die zu dieser // Stunde gehörende Sitzung vorselektiert (siehe TeachingModeViewModel-Konstruktor). vm.Participation.OnQuickInput = ShowQuickInputDialog; vm.Participation.OnStatusQuickInput = ShowStatusQuickInputDialog; } } private async Task ShowQuickInputDialog(ParticipationTabViewModel tabVm) { if (tabVm.StudentRows.Count == 0) return; var quickVm = new QuickInputViewModel(tabVm.StudentRows.ToList(), tabVm.Aspects.ToList()); var dialog = new ParticipationQuickInputDialog { DataContext = quickVm }; await dialog.ShowDialog(this); (DataContext as TeachingModeViewModel)?.SeatingPlan.ReloadSeatBadgesFromRepository(); } private async Task ShowStatusQuickInputDialog(ParticipationTabViewModel tabVm) { if (tabVm.StudentRows.Count == 0 || tabVm.SelectedSession is null) return; var quickVm = new AttendanceHomeworkQuickInputViewModel(tabVm.StudentRows, tabVm.SelectedSessionDisplay); var dialog = new AttendanceHomeworkQuickInputDialog { DataContext = quickVm }; await dialog.ShowDialog(this); (DataContext as TeachingModeViewModel)?.SeatingPlan.ReloadSeatBadgesFromRepository(); } private void OnClose(object? sender, RoutedEventArgs e) => Close(); }