Neue Funktion Schüler austragen statt aus Kurs löschen.

This commit is contained in:
2026-08-15 23:38:42 +02:00
parent 52bb9c2c2f
commit da8d2bb1da
19 changed files with 473 additions and 114 deletions
@@ -48,6 +48,7 @@ public partial class GradeOverviewTabView : UserControl
var dialogVm = new CollectiveGradeDialogViewModel(
App.Services.GetRequiredService<IGradeRepository>(),
App.Services.GetRequiredService<IStudentRepository>(),
App.Services.GetRequiredService<IGroupMembershipRepository>(),
_vm!.GroupId);
var dialog = new CollectiveGradeDialog { DataContext = dialogVm };
@@ -66,7 +67,7 @@ public partial class GradeOverviewTabView : UserControl
App.Services.GetRequiredService<IGradingSchemeRepository>(),
App.Services.GetRequiredService<IReportGradeRepository>(),
App.Services.GetRequiredService<GradingService>(),
_vm!.GroupId, _vm.GroupType, _vm.GradingSystem, _vm.GroupLabel);
_vm!.GroupId, _vm.GroupType, _vm.GradingSystem, _vm.GroupLabel, _vm.SchoolYear);
var dialog = new ReportGradeDialog { DataContext = dialogVm };
var owner = TopLevel.GetTopLevel(this) as Window;
@@ -20,9 +20,14 @@
<Run Text="{Binding StudentCount}"/>
<Run Text=" Schüler"/>
</TextBlock>
<CheckBox Content="Ausgetretene anzeigen" IsChecked="{Binding ShowFormerStudents}"
VerticalAlignment="Center"/>
<Button Content=" Schüler" Command="{Binding AddStudentCommand}"/>
<Button Content=" Austragen" Command="{Binding RemoveStudentCommand}"
<Button Content="{Binding SelectedStudent.WithdrawActionLabel}"
Command="{Binding WithdrawStudentCommand}"
IsVisible="{Binding SelectedStudent, Converter={x:Static ObjectConverters.IsNotNull}}"/>
<Button Content="Austragung zurücknehmen" Command="{Binding ReinstateStudentCommand}"
IsVisible="{Binding SelectedStudent.HasExitDate}"/>
<Button Content=" Klausur" Command="{Binding AddExamCommand}"/>
</StackPanel>
</Grid>
@@ -52,8 +57,9 @@
CanUserResizeColumns="True"
Margin="0">
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding FullName}" Width="*"/>
<DataGridTextColumn Header="Zeitraum" Binding="{Binding PeriodLabel}" Width="90"/>
<DataGridTextColumn Header="Name" Binding="{Binding FullName}" Width="*"/>
<DataGridTextColumn Header="Zeitraum" Binding="{Binding PeriodLabel}" Width="190"/>
<DataGridTextColumn Header="Status" Binding="{Binding MembershipStatus}" Width="170"/>
<DataGridTemplateColumn Header="Niveau" Width="130"
IsVisible="{Binding IsDifferentiated}">
<DataGridTemplateColumn.CellTemplate>
@@ -17,6 +17,7 @@ public partial class GroupDetailView : UserControl
if (DataContext is GroupDetailViewModel vm)
{
vm.OnAddStudent = ShowAddStudentDialog;
vm.OnWithdrawStudent = ShowWithdrawStudentDialog;
vm.OnAddExam = ShowAddExamDialog;
vm.OnEditExam = ShowEditExamDialog;
vm.OnDuplicateExam = ShowDuplicateExamDialog;
@@ -42,6 +43,20 @@ public partial class GroupDetailView : UserControl
return await dialog.ShowDialog<bool>(owner);
}
private async Task<bool> ShowWithdrawStudentDialog(StudentSummary student)
{
if (DataContext is not GroupDetailViewModel vm || vm.Group is null) return false;
var memberships = App.Services.GetRequiredService<IGroupMembershipRepository>();
var membership = memberships.GetByStudentAndGroup(student.Id, vm.Group.Id);
if (membership is null) return false;
var dialogVm = new WithdrawStudentDialogViewModel(
memberships, membership, student.FullName, vm.Group.Name);
var dialog = new WithdrawStudentDialog { DataContext = dialogVm };
var owner = TopLevel.GetTopLevel(this) as Window;
return owner is not null && await dialog.ShowDialog<bool>(owner);
}
private Task<bool> ShowAddExamDialog(Guid groupId) =>
ShowExamDialog(groupId, editingExam: null, duplicateSource: null);
@@ -290,6 +290,7 @@ public partial class ParticipationTabView : UserControl
App.Services.GetRequiredService<IParticipationAspectRepository>(),
App.Services.GetRequiredService<IParticipationSectionRepository>(),
App.Services.GetRequiredService<IStudentRepository>(),
App.Services.GetRequiredService<IGroupMembershipRepository>(),
App.Services.GetRequiredService<IExamRepository>(),
App.Services.GetRequiredService<IExamResultRepository>(),
App.Services.GetRequiredService<IGradeRepository>(),
@@ -0,0 +1,42 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:LehrerApp.Desktop.ViewModels.Groups"
x:Class="LehrerApp.Desktop.Views.Groups.WithdrawStudentDialog"
x:DataType="vm:WithdrawStudentDialogViewModel"
Title="Schüler austragen"
Width="440" Height="330"
CanResize="False" WindowStartupLocation="CenterOwner">
<Grid RowDefinitions="*,Auto" Margin="24">
<StackPanel Grid.Row="0" Spacing="14">
<TextBlock Text="Schüler aus Lerngruppe austragen" Classes="dialogtitle"/>
<Border Background="{DynamicResource SystemControlBackgroundAltHighBrush}"
CornerRadius="6" Padding="12">
<Grid ColumnDefinitions="Auto,12,*" RowDefinitions="Auto,Auto">
<TextBlock Grid.Row="0" Grid.Column="0" Text="Schüler" Opacity="0.65"/>
<TextBlock Grid.Row="0" Grid.Column="2" Text="{Binding StudentName}" FontWeight="SemiBold"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="Lerngruppe" Opacity="0.65"/>
<TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding GroupName}" FontWeight="SemiBold"/>
</Grid>
</Border>
<StackPanel Spacing="5">
<TextBlock Text="Austrittsdatum" FontSize="12" Opacity="0.7"/>
<CalendarDatePicker SelectedDate="{Binding SelectedDate}"
DisplayDateStart="{Binding EarliestDate}"
HorizontalAlignment="Stretch"/>
<TextBlock Text="{Binding DateError}" Foreground="Red" FontSize="12"
IsVisible="{Binding DateError, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
</StackPanel>
<TextBlock Text="Die bisherige Gruppenzugehörigkeit und alle zugehörigen Leistungen bleiben erhalten."
FontSize="12" Opacity="0.65" TextWrapping="Wrap"/>
</StackPanel>
<Grid Grid.Row="1" ColumnDefinitions="*,8,*" Margin="0,18,0,0">
<Button Grid.Column="0" Content="Abbrechen" HorizontalAlignment="Stretch" Click="OnCancel"/>
<Button Grid.Column="2" Content="Austragen" HorizontalAlignment="Stretch" Click="OnSave"/>
</Grid>
</Grid>
</Window>
@@ -0,0 +1,19 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using LehrerApp.Desktop.ViewModels.Groups;
namespace LehrerApp.Desktop.Views.Groups;
public partial class WithdrawStudentDialog : Window
{
public WithdrawStudentDialog() => InitializeComponent();
private void OnSave(object? sender, RoutedEventArgs e)
{
if (DataContext is not WithdrawStudentDialogViewModel vm) return;
vm.SaveCommand.Execute(null);
if (vm.WasSaved) Close(true);
}
private void OnCancel(object? sender, RoutedEventArgs e) => Close(false);
}