Untis API Integration
This commit is contained in:
@@ -25,6 +25,9 @@
|
||||
<Button Content="+ Schüler" Command="{Binding AddStudentCommand}" IsEnabled="{Binding IsEditable}"/>
|
||||
<Button Content="⇩ Teilnehmer importieren…" Click="OnImportParticipantsClick"
|
||||
IsEnabled="{Binding IsEditable}"/>
|
||||
<Button Content="↻ Aus WebUntis…" Click="OnImportParticipantsFromWebUntisClick"
|
||||
IsEnabled="{Binding IsEditable}"/>
|
||||
<Button Content="Fehlzeiten abgleichen…" Click="OnCompareWebUntisAbsencesClick"/>
|
||||
<Button Content="{Binding SelectedStudent.WithdrawActionLabel}"
|
||||
Command="{Binding WithdrawStudentCommand}"
|
||||
IsVisible="{Binding SelectedStudent, Converter={x:Static ObjectConverters.IsNotNull}}"/>
|
||||
|
||||
@@ -13,6 +13,7 @@ using LehrerApp.Desktop.Views.Shared;
|
||||
using LehrerApp.Desktop.Views.Students;
|
||||
using LehrerApp.Desktop.Views.Workload;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Text;
|
||||
|
||||
namespace LehrerApp.Desktop.Views.Groups;
|
||||
|
||||
@@ -113,18 +114,7 @@ public partial class GroupDetailView : UserControl
|
||||
throw new InvalidDataException("Die Importdatei ist größer als 20 MB.");
|
||||
|
||||
var importFile = new ImportFile(files[0].Name, buffer.ToArray());
|
||||
var preview = await Task.Run(async () =>
|
||||
await service.AnalyzeAsync(importFile, vm.Group.Id).ConfigureAwait(false));
|
||||
var dialogVm = new StudentImportDialogViewModel(service, preview, files[0].Name);
|
||||
var dialog = new StudentImportDialog { DataContext = dialogVm };
|
||||
if (!await dialog.ShowDialog<bool>(owner)) return;
|
||||
|
||||
vm.LoadStudents();
|
||||
vm.ParticipationTab.RefreshCurrentGrid();
|
||||
var result = dialogVm.Result!;
|
||||
App.Services.GetRequiredService<NotificationService>().ShowSuccess(
|
||||
$"Teilnehmerimport abgeschlossen: {result.CreatedStudents} neu, "
|
||||
+ $"{result.UpdatedStudents} ergänzt, {result.CreatedMemberships} zugeordnet.");
|
||||
await ShowStudentImportPreview(owner, vm, importFile, files[0].Name);
|
||||
}
|
||||
catch (Exception ex) when (ex is ImportFormatException
|
||||
or InvalidDataException
|
||||
@@ -135,6 +125,85 @@ public partial class GroupDetailView : UserControl
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnImportParticipantsFromWebUntisClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var owner = TopLevel.GetTopLevel(this) as Window;
|
||||
if (owner is null || DataContext is not GroupDetailViewModel vm || vm.Group is null) return;
|
||||
try
|
||||
{
|
||||
var untis = App.Services.GetRequiredService<WebUntisIntegrationService>();
|
||||
var selectionVm = new WebUntisClassSelectionViewModel(untis);
|
||||
var selection = new WebUntisClassSelectionDialog { DataContext = selectionVm };
|
||||
await selectionVm.InitializeAsync();
|
||||
if (!await selection.ShowDialog<bool>(owner) || selectionVm.SelectedClass is null) return;
|
||||
|
||||
var report = await untis.GetStudentsAsync(selectionVm.SelectedClass.Name);
|
||||
var importFile = BuildWebUntisStudentImport(report);
|
||||
await ShowStudentImportPreview(owner, vm, importFile,
|
||||
$"WebUntis · {selectionVm.SelectedClass.Name}");
|
||||
}
|
||||
catch (WebUntisIntegrationException ex)
|
||||
{
|
||||
App.Services.GetRequiredService<NotificationService>().ShowError(ex.Message);
|
||||
}
|
||||
catch (Exception ex) when (ex is ImportFormatException or InvalidDataException)
|
||||
{
|
||||
App.Services.GetRequiredService<NotificationService>().ShowError(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnCompareWebUntisAbsencesClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var owner = TopLevel.GetTopLevel(this) as Window;
|
||||
if (owner is null || DataContext is not GroupDetailViewModel vm || vm.Group is null) return;
|
||||
var dialogVm = new WebUntisAbsenceComparisonViewModel(vm.Group,
|
||||
App.Services.GetRequiredService<WebUntisIntegrationService>(),
|
||||
App.Services.GetRequiredService<IStudentRepository>(),
|
||||
App.Services.GetRequiredService<IParticipationSessionRepository>(),
|
||||
App.Services.GetRequiredService<IParticipationRepository>());
|
||||
await new WebUntisAbsenceComparisonDialog { DataContext = dialogVm }.ShowDialog(owner);
|
||||
vm.ParticipationTab.RefreshCurrentGrid();
|
||||
}
|
||||
|
||||
private static ImportFile BuildWebUntisStudentImport(UntisStudentReportDto report)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
builder.AppendLine("longName\tforeName\tgender\tbirthDate\tklasse.name\texternKey\taddress.email\taddress.mobile\taddress.phone\taddress.city\taddress.postCode\taddress.street");
|
||||
foreach (var student in report.Students)
|
||||
{
|
||||
var values = new[]
|
||||
{
|
||||
student.LongName ?? student.Name, student.ForeName, student.Gender,
|
||||
student.BirthDate?.ToString() ?? student.BirthDateRaw, student.ClassName,
|
||||
student.ExternKey.ToString(), student.Address.Email, student.Address.Mobile,
|
||||
student.Address.Phone, student.Address.City, student.Address.PostCode, student.Address.Street,
|
||||
};
|
||||
builder.AppendLine(string.Join('\t', values.Select(SafeTsv)));
|
||||
}
|
||||
return new ImportFile("webuntis-students.csv", Encoding.UTF8.GetBytes(builder.ToString()));
|
||||
}
|
||||
|
||||
private static string SafeTsv(string? value) => (value ?? "").Replace('\t', ' ')
|
||||
.Replace('\r', ' ').Replace('\n', ' ');
|
||||
|
||||
private static async Task ShowStudentImportPreview(Window owner, GroupDetailViewModel vm,
|
||||
ImportFile importFile, string sourceName)
|
||||
{
|
||||
var service = App.Services.GetRequiredService<StudentImportService>();
|
||||
var preview = await Task.Run(async () =>
|
||||
await service.AnalyzeAsync(importFile, vm.Group!.Id).ConfigureAwait(false));
|
||||
var dialogVm = new StudentImportDialogViewModel(service, preview, sourceName);
|
||||
var dialog = new StudentImportDialog { DataContext = dialogVm };
|
||||
if (!await dialog.ShowDialog<bool>(owner)) return;
|
||||
|
||||
vm.LoadStudents();
|
||||
vm.ParticipationTab.RefreshCurrentGrid();
|
||||
var result = dialogVm.Result!;
|
||||
App.Services.GetRequiredService<NotificationService>().ShowSuccess(
|
||||
$"Teilnehmerimport abgeschlossen: {result.CreatedStudents} neu, "
|
||||
+ $"{result.UpdatedStudents} ergänzt, {result.CreatedMemberships} zugeordnet.");
|
||||
}
|
||||
|
||||
private async Task<bool> ShowWithdrawStudentDialog(StudentSummary student)
|
||||
{
|
||||
if (DataContext is not GroupDetailViewModel vm || vm.Group is null) return false;
|
||||
|
||||
@@ -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.WebUntisAbsenceComparisonDialog"
|
||||
x:DataType="vm:WebUntisAbsenceComparisonViewModel"
|
||||
Title="Fehlzeiten mit WebUntis abgleichen" Width="850" Height="620"
|
||||
MinWidth="700" MinHeight="450" WindowStartupLocation="CenterOwner">
|
||||
<Grid RowDefinitions="Auto,Auto,*,Auto" Margin="24" RowSpacing="12">
|
||||
<StackPanel Grid.Row="0" Spacing="4">
|
||||
<TextBlock Text="Fehlzeiten mit WebUntis abgleichen" Classes="dialogtitle"/>
|
||||
<TextBlock Text="Nur markierte Zeilen mit einer vorhandenen lokalen Kursstunde werden übernommen."
|
||||
FontSize="12" Opacity="0.65"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" Spacing="8">
|
||||
<DatePicker SelectedDate="{Binding StartDate}"/>
|
||||
<TextBlock Text="bis" VerticalAlignment="Center"/>
|
||||
<DatePicker SelectedDate="{Binding EndDate}"/>
|
||||
<Button Content="Fehlzeiten laden" Command="{Binding LoadCommand}" IsEnabled="{Binding !Busy}"/>
|
||||
</StackPanel>
|
||||
<ScrollViewer Grid.Row="2">
|
||||
<ItemsControl ItemsSource="{Binding Rows}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:WebUntisAbsenceRow">
|
||||
<Grid ColumnDefinitions="Auto,1.5*,90,90,1.5*,1.5*" ColumnSpacing="8" Margin="0,3">
|
||||
<CheckBox Grid.Column="0" IsChecked="{Binding Selected}" IsEnabled="{Binding CanApply}"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding StudentName}" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="2" Text="{Binding DateLabel}" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="3" Text="{Binding TimeLabel}" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="4" Text="{Binding UntisStatus}" TextWrapping="Wrap" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="5" Text="{Binding LocalStatus}" TextWrapping="Wrap" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
<Grid Grid.Row="3" ColumnDefinitions="*,Auto,Auto" ColumnSpacing="8">
|
||||
<TextBlock Grid.Column="0" Text="{Binding Status}" FontSize="12" TextWrapping="Wrap" VerticalAlignment="Center"/>
|
||||
<Button Grid.Column="1" Content="Schließen" Click="OnClose"/>
|
||||
<Button Grid.Column="2" Content="Markierte übernehmen" Command="{Binding ApplyCommand}" IsEnabled="{Binding !Busy}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,10 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace LehrerApp.Desktop.Views.Groups;
|
||||
|
||||
public partial class WebUntisAbsenceComparisonDialog : Window
|
||||
{
|
||||
public WebUntisAbsenceComparisonDialog() => InitializeComponent();
|
||||
private void OnClose(object? sender, RoutedEventArgs e) => Close();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:LehrerApp.Desktop.ViewModels.Groups"
|
||||
xmlns:svc="clr-namespace:LehrerApp.Desktop.Services"
|
||||
x:Class="LehrerApp.Desktop.Views.Groups.WebUntisClassSelectionDialog"
|
||||
x:DataType="vm:WebUntisClassSelectionViewModel"
|
||||
Title="Schüler aus WebUntis" Width="480" SizeToContent="Height"
|
||||
CanResize="False" WindowStartupLocation="CenterOwner">
|
||||
<Grid RowDefinitions="*,Auto" Margin="24">
|
||||
<StackPanel Grid.Row="0" Spacing="12">
|
||||
<TextBlock Text="WebUntis-Klasse auswählen" Classes="dialogtitle"/>
|
||||
<TextBlock Text="Die Schülerliste wird danach im gewohnten Importdialog geprüft."
|
||||
FontSize="12" Opacity="0.65" TextWrapping="Wrap"/>
|
||||
<Grid ColumnDefinitions="*,Auto" ColumnSpacing="8">
|
||||
<ComboBox Grid.Column="0" ItemsSource="{Binding SchoolYears}" SelectedItem="{Binding SelectedSchoolYear}">
|
||||
<ComboBox.ItemTemplate><DataTemplate x:DataType="svc:UntisSchoolYearDto"><TextBlock Text="{Binding Name}"/></DataTemplate></ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<Button Grid.Column="1" Content="Klassen laden" Command="{Binding LoadClassesCommand}" IsEnabled="{Binding !Busy}"/>
|
||||
</Grid>
|
||||
<ComboBox ItemsSource="{Binding Classes}" SelectedItem="{Binding SelectedClass}" PlaceholderText="Klasse auswählen">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="svc:UntisClassDto">
|
||||
<TextBlock><Run Text="{Binding Name}"/><Run Text=" — "/><Run Text="{Binding LongName}"/></TextBlock>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<TextBlock Text="{Binding Status}" FontSize="12" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1" ColumnDefinitions="*,8,*" Margin="0,20,0,0">
|
||||
<Button Grid.Column="0" Content="Abbrechen" Click="OnCancel"/>
|
||||
<Button Grid.Column="2" Content="Schülerliste laden" IsEnabled="{Binding CanConfirm}" Click="OnConfirm"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,15 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using LehrerApp.Desktop.ViewModels.Groups;
|
||||
|
||||
namespace LehrerApp.Desktop.Views.Groups;
|
||||
|
||||
public partial class WebUntisClassSelectionDialog : Window
|
||||
{
|
||||
public WebUntisClassSelectionDialog() => InitializeComponent();
|
||||
private void OnCancel(object? sender, RoutedEventArgs e) => Close(false);
|
||||
private void OnConfirm(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is WebUntisClassSelectionViewModel { SelectedClass: not null }) Close(true);
|
||||
}
|
||||
}
|
||||
@@ -308,6 +308,11 @@
|
||||
<ContentPage Header="Bearbeiten">
|
||||
<ScrollViewer>
|
||||
<StackPanel Margin="32,20,32,28" Spacing="10">
|
||||
<StackPanel Orientation="Horizontal" Spacing="8" Margin="0,0,0,6">
|
||||
<Button Content="Aus WebUntis laden…" Command="{Binding ImportWebUntisTimetableCommand}"/>
|
||||
<TextBlock Text="Importiert oder vergleicht eine typische Unterrichtswoche; Vertretungen bleiben im iCal-Abgleich."
|
||||
FontSize="11" Opacity="0.6" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<!-- Zeilenweise (GridRows) statt eines flachen UniformGrid, siehe Kommentar im
|
||||
Wochenraster oben (Heute-Tab) - gleicher Grund (Grid.RowDefinitions lässt sich
|
||||
nicht per {Binding} setzen). -->
|
||||
|
||||
@@ -5,6 +5,7 @@ using LehrerApp.Core.Services;
|
||||
using LehrerApp.Desktop.ViewModels.Planning;
|
||||
using LehrerApp.Desktop.ViewModels.Groups;
|
||||
using LehrerApp.Desktop.Views.Groups;
|
||||
using LehrerApp.Desktop.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace LehrerApp.Desktop.Views.Planning;
|
||||
@@ -20,11 +21,27 @@ public partial class TimetableView : UserControl
|
||||
{
|
||||
vm.OnEditSlot = ShowSlotDialog;
|
||||
vm.OnAddSubstitution = ShowSubstitutionDialog;
|
||||
vm.OnImportWebUntisTimetable = ShowWebUntisTimetableDialog;
|
||||
vm.OnOpenLessonViewer = ShowLessonViewerDialog;
|
||||
vm.OnOpenTeachingMode = ShowTeachingMode;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ShowWebUntisTimetableDialog()
|
||||
{
|
||||
var owner = TopLevel.GetTopLevel(this) as Window;
|
||||
if (owner is null) return;
|
||||
var vm = new WebUntisTimetableImportViewModel(
|
||||
App.Services.GetRequiredService<WebUntisIntegrationService>(),
|
||||
App.Services.GetRequiredService<WebUntisSettingsService>(),
|
||||
App.Services.GetRequiredService<ITimetableSlotRepository>(),
|
||||
App.Services.GetRequiredService<IGroupRepository>());
|
||||
var dialog = new WebUntisTimetableImportDialog { DataContext = vm };
|
||||
vm.OnCreateGroup = dialog.CreateGroupAsync;
|
||||
await vm.InitializeAsync();
|
||||
await dialog.ShowDialog<bool>(owner);
|
||||
}
|
||||
|
||||
private async Task ShowTeachingMode(Lesson lesson)
|
||||
{
|
||||
var owner = TopLevel.GetTopLevel(this) as Window;
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:LehrerApp.Desktop.ViewModels.Planning"
|
||||
xmlns:svc="clr-namespace:LehrerApp.Desktop.Services"
|
||||
x:Class="LehrerApp.Desktop.Views.Planning.WebUntisTimetableImportDialog"
|
||||
x:DataType="vm:WebUntisTimetableImportViewModel"
|
||||
Title="Stundenplan aus WebUntis" Width="820" Height="650"
|
||||
MinWidth="680" MinHeight="480" WindowStartupLocation="CenterOwner">
|
||||
<Grid RowDefinitions="Auto,Auto,*,Auto" Margin="24" RowSpacing="14">
|
||||
<StackPanel Grid.Row="0" Spacing="4">
|
||||
<TextBlock Text="Stundenplan aus WebUntis" Classes="dialogtitle"/>
|
||||
<TextBlock Text="Wähle eine typische Unterrichtswoche. Vorhandene Einträge werden vorgeschlagen und erst nach Bestätigung ersetzt."
|
||||
FontSize="12" Opacity="0.65" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1" ColumnDefinitions="2*,*,Auto" ColumnSpacing="10">
|
||||
<ComboBox Grid.Column="0" ItemsSource="{Binding Teachers}" SelectedItem="{Binding SelectedTeacher}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="svc:UntisTeacherDto"><TextBlock Text="{Binding DisplayName}"/></DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<DatePicker Grid.Column="1" SelectedDate="{Binding WeekDate}"/>
|
||||
<Button Grid.Column="2" Content="Woche laden" Command="{Binding LoadCommand}" IsEnabled="{Binding !Busy}"/>
|
||||
</Grid>
|
||||
<ScrollViewer Grid.Row="2">
|
||||
<ItemsControl ItemsSource="{Binding Rows}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:WebUntisTimetableRow">
|
||||
<Grid ColumnDefinitions="48,85,2*,2*,Auto" ColumnSpacing="8" Margin="0,3">
|
||||
<TextBlock Grid.Column="0" Text="{Binding WeekdayLabel}" VerticalAlignment="Center" FontWeight="SemiBold"/>
|
||||
<StackPanel Grid.Column="1">
|
||||
<TextBlock Text="{Binding PeriodNumber, StringFormat={}{0}. Std.}" FontSize="12"/>
|
||||
<TextBlock Text="{Binding TimeLabel}" FontSize="10" Opacity="0.6"/>
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Column="2" Text="{Binding UntisLabel}" TextWrapping="Wrap" VerticalAlignment="Center"/>
|
||||
<ComboBox Grid.Column="3" ItemsSource="{Binding GroupOptions}" SelectedItem="{Binding SelectedGroup}"
|
||||
PlaceholderText="nicht übernehmen">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:WebUntisGroupOption"><TextBlock Text="{Binding DisplayName}"/></DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<Button Grid.Column="4" Content="Neue Gruppe…" FontSize="11"
|
||||
Command="{Binding $parent[ItemsControl].((vm:WebUntisTimetableImportViewModel)DataContext).CreateGroupCommand}"
|
||||
CommandParameter="{Binding}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
<Grid Grid.Row="3" ColumnDefinitions="*,Auto,Auto" ColumnSpacing="8">
|
||||
<TextBlock Grid.Column="0" Text="{Binding Status}" FontSize="12" TextWrapping="Wrap" VerticalAlignment="Center"/>
|
||||
<Button Grid.Column="1" Content="Abbrechen" Click="OnCancel"/>
|
||||
<Button Grid.Column="2" Content="Zuordnung übernehmen" Command="{Binding SaveCommand}" Click="OnSave"
|
||||
IsEnabled="{Binding !Busy}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,36 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using LehrerApp.Core.Models;
|
||||
using LehrerApp.Desktop.ViewModels.Groups;
|
||||
using LehrerApp.Desktop.ViewModels.Planning;
|
||||
using LehrerApp.Desktop.Views.Groups;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace LehrerApp.Desktop.Views.Planning;
|
||||
|
||||
public partial class WebUntisTimetableImportDialog : Window
|
||||
{
|
||||
public WebUntisTimetableImportDialog() => InitializeComponent();
|
||||
|
||||
private void OnCancel(object? sender, RoutedEventArgs e) => Close(false);
|
||||
private void OnSave(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is WebUntisTimetableImportViewModel { Saved: true }) Close(true);
|
||||
}
|
||||
|
||||
public async Task<LearningGroup?> CreateGroupAsync(WebUntisTimetableRow source)
|
||||
{
|
||||
var vm = App.Services.GetRequiredService<AddGroupDialogViewModel>();
|
||||
vm.Name = source.SuggestedGroupName;
|
||||
vm.Subject = source.SubjectName ?? "";
|
||||
vm.GradeLevel = ParseGrade(source.SuggestedGroupName) ?? 10;
|
||||
var dialog = new AddGroupDialog { DataContext = vm };
|
||||
return await dialog.ShowDialog<bool>(this) ? vm.Result : null;
|
||||
}
|
||||
|
||||
private static int? ParseGrade(string value)
|
||||
{
|
||||
var digits = new string(value.TakeWhile(char.IsDigit).ToArray());
|
||||
return int.TryParse(digits, out var grade) && grade is >= 1 and <= 13 ? grade : null;
|
||||
}
|
||||
}
|
||||
@@ -967,7 +967,40 @@
|
||||
|
||||
<TextBlock Text="Untis-Einbettung" FontSize="18" FontWeight="SemiBold"/>
|
||||
<TextBlock FontSize="12" Opacity="0.6" TextWrapping="Wrap"
|
||||
Text="Bindet den persönlichen WebUntis-Stundenplan und den schulweiten Jahresplan als zwei unabhängige iCal-Quellen ein."/>
|
||||
Text="Bindet WebUntis-Daten über deinen persönlichen Zugang ein. Der bestehende iCal-Abgleich für Vertretungen bleibt davon unabhängig."/>
|
||||
|
||||
<TextBlock Text="WebUntis-API" FontSize="16" FontWeight="SemiBold"/>
|
||||
<TextBlock FontSize="12" Opacity="0.6" TextWrapping="Wrap"
|
||||
Text="Ermöglicht Stundenplan-, Schüler- und Fehlzeitenabgleich. Die Zugangsdaten werden nur auf diesem Gerät verschlüsselt gespeichert; der LehrerApp-Server hält sie und die WebUntis-Sitzung nur im Arbeitsspeicher."/>
|
||||
<Grid ColumnDefinitions="*,*" RowDefinitions="Auto,Auto" ColumnSpacing="8" RowSpacing="8">
|
||||
<StackPanel Grid.Row="0" Grid.Column="0" Spacing="4">
|
||||
<TextBlock Text="Schule" FontSize="12" Opacity="0.7"/>
|
||||
<TextBox Text="{Binding UntisSchool}" PlaceholderText="Schulkennung, nicht Anzeigename"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" Spacing="4">
|
||||
<TextBlock Text="Server (optional)" FontSize="12" Opacity="0.7"/>
|
||||
<TextBox Text="{Binding UntisHost}" PlaceholderText="z. B. arche.webuntis.com"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Spacing="4">
|
||||
<TextBlock Text="Benutzername" FontSize="12" Opacity="0.7"/>
|
||||
<TextBox Text="{Binding UntisUsername}"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" Spacing="4">
|
||||
<TextBlock Text="Passwort" FontSize="12" Opacity="0.7"/>
|
||||
<TextBox Text="{Binding UntisPassword}" PasswordChar="●"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<TextBlock FontSize="11" Opacity="0.6" TextWrapping="Wrap"
|
||||
Text="Die Schulkennung steht in der WebUntis-Anmelde-URL hinter ?school=. Als Server kannst du auch die vollständige Anmelde-URL einfügen; Server und Schulkennung sind häufig verschieden."/>
|
||||
<TextBlock Text="{Binding UntisApiStatus}" FontSize="12" TextWrapping="Wrap"/>
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
<Button Content="Anmeldung prüfen und speichern" Command="{Binding UntisSaveApiCommand}"
|
||||
IsEnabled="{Binding !UntisApiBusy}"/>
|
||||
<Button Content="API-Zugang entfernen" Command="{Binding UntisRemoveApiCommand}"
|
||||
IsVisible="{Binding UntisApiIsConfigured}" IsEnabled="{Binding !UntisApiBusy}"/>
|
||||
</StackPanel>
|
||||
|
||||
<Separator Margin="0,8"/>
|
||||
|
||||
<TextBlock Text="WebUntis-Stundenplan-Abgleich" FontSize="16" FontWeight="SemiBold"/>
|
||||
<TextBlock FontSize="12" Opacity="0.6" TextWrapping="Wrap"
|
||||
|
||||
Reference in New Issue
Block a user