Add intelligent random student picker
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
admin committed 2026-09-29 14:02:48 +02:00
1 parent 770a1833c8
commit c79d96c5ec
7 files changed
+426

No files matched your search

@@ -0,0 +1,77 @@
<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.RandomStudentPickerWindow"
x:DataType="vm:RandomStudentPickerViewModel"
Title="Schüler ziehen"
Width="430" MinHeight="390"
SizeToContent="Height"
CanResize="False"
WindowStartupLocation="CenterScreen">
<Grid RowDefinitions="Auto,*,Auto,Auto" Margin="24">
<Grid Grid.Row="0" ColumnDefinitions="*,Auto" Margin="0,0,0,18">
<StackPanel Spacing="3">
<TextBlock Text="Schüler ziehen" Classes="dialogtitle"/>
<TextBlock Text="Eigenständiges Fenster für die Bildschirmfreigabe"
FontSize="12" Opacity="0.55"/>
</StackPanel>
<Button Grid.Column="1" Content="↺" Command="{Binding ResetCommand}"
ToolTip.Tip="Ziehung zurücksetzen" FontSize="18"
Width="38" Height="38"/>
</Grid>
<Border Grid.Row="1" x:Name="RevealCard"
MinHeight="190" Padding="24"
Background="{DynamicResource AppAccentSoftBackgroundBrush}"
BorderBrush="{DynamicResource AppFilterActiveBorderBrush}"
BorderThickness="1" CornerRadius="18">
<Border.Transitions>
<Transitions>
<DoubleTransition Property="Opacity" Duration="0:0:0.18"/>
</Transitions>
</Border.Transitions>
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Spacing="12">
<TextBlock Text="◆" HorizontalAlignment="Center" FontSize="20"
Foreground="{DynamicResource AppAccentOnSoftBrush}"/>
<TextBlock Text="{Binding SelectedStudentName}"
HorizontalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap"
FontSize="34" FontWeight="SemiBold"
Foreground="{DynamicResource AppFilterActiveForegroundBrush}"/>
<TextBlock Text="{Binding StatusText}" HorizontalAlignment="Center"
TextAlignment="Center" TextWrapping="Wrap" FontSize="12" Opacity="0.7"/>
</StackPanel>
</Border>
<Button Grid.Row="2" Content="🎲 Ziehen" x:Name="DrawButton"
IsEnabled="{Binding CanDraw}" Click="OnDraw"
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"
FontSize="18" FontWeight="SemiBold" Height="54" Margin="0,16,0,12"/>
<Expander Grid.Row="3" Header="Optionen" IsExpanded="False">
<StackPanel Spacing="10" Margin="0,10,0,0">
<TextBlock Text="Lerngruppe" FontSize="12" Opacity="0.7"/>
<ComboBox ItemsSource="{Binding Groups}" SelectedItem="{Binding SelectedGroup}"
HorizontalAlignment="Stretch">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="vm:StudentDrawGroup">
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Text="Auswahlart" FontSize="12" Opacity="0.7" Margin="0,4,0,0"/>
<ComboBox ItemsSource="{Binding SelectionModeOptions}"
SelectedItem="{Binding SelectionModeName}"
HorizontalAlignment="Stretch"/>
<CheckBox Content="Mündliche Mitarbeit berücksichtigen"
IsChecked="{Binding ConsiderParticipation}"
IsEnabled="{Binding IsIntelligent}" Margin="0,4,0,0"/>
<TextBlock Text="Wenig aktive oder bislang schwächere Schüler werden wahrscheinlicher gezogen; direkte Wiederholungen werden vermieden."
IsVisible="{Binding IsIntelligent}" TextWrapping="Wrap"
FontSize="11" Opacity="0.55"/>
</StackPanel>
</Expander>
</Grid>
</Window>
@@ -0,0 +1,26 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using LehrerApp.Desktop.ViewModels.Groups;
namespace LehrerApp.Desktop.Views.Groups;
public partial class RandomStudentPickerWindow : Window
{
private bool _isAnimating;
public RandomStudentPickerWindow() => InitializeComponent();
private async void OnDraw(object? sender, RoutedEventArgs e)
{
if (_isAnimating || DataContext is not RandomStudentPickerViewModel vm ||
!vm.DrawCommand.CanExecute(null)) return;
_isAnimating = true;
var card = this.FindControl<Border>("RevealCard");
if (card is not null) card.Opacity = 0.15;
await Task.Delay(150);
vm.DrawCommand.Execute(null);
if (card is not null) card.Opacity = 1;
_isAnimating = false;
}
}
+3
View File
@@ -46,6 +46,9 @@
IsEnabled="{Binding CanPersonalizeWorksheet}"
ToolTip.Tip="Nur verfügbar, während eine einzelne Lerngruppe geöffnet ist"/>
</MenuItem>
<MenuItem Header="Unterricht">
<MenuItem Header="Schüler ziehen…" Click="OnOpenRandomStudentPicker"/>
</MenuItem>
</Menu>
<DrawerPage x:Name="RootDrawer"
DrawerLength="220"
@@ -22,6 +22,7 @@ public partial class MainWindow : Window
private SyncEngine? _syncEngine;
private bool _finalSyncStarted;
private bool _closeAfterFinalSync;
private RandomStudentPickerWindow? _randomStudentPickerWindow;
public MainWindow()
{
@@ -71,6 +72,27 @@ public partial class MainWindow : Window
await new PersonalizeWorksheetDialog { DataContext = dialogVm }.ShowDialog(this);
}
private void OnOpenRandomStudentPicker(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
if (_randomStudentPickerWindow is not null)
{
_randomStudentPickerWindow.Activate();
return;
}
var currentGroupId = (DataContext as MainWindowViewModel)?.CurrentGroupDetail?.Group?.Id;
var vm = new RandomStudentPickerViewModel(
App.Services.GetRequiredService<IStudentRepository>(),
App.Services.GetRequiredService<IGroupRepository>(),
App.Services.GetRequiredService<IGroupMembershipRepository>(),
App.Services.GetRequiredService<IParticipationSessionRepository>(),
App.Services.GetRequiredService<IParticipationRepository>(),
currentGroupId);
_randomStudentPickerWindow = new RandomStudentPickerWindow { DataContext = vm };
_randomStudentPickerWindow.Closed += (_, _) => _randomStudentPickerWindow = null;
_randomStudentPickerWindow.Show();
}
private void OnWindowKeyDown(object? sender, KeyEventArgs e)
{
if (DataContext is not MainWindowViewModel vm) return;