KI-gestützte Planungsunterstützung (4.5.9) + Kompetenzkatalog-Import (8.1.2)
KI-Unterstützung: neuer Einstellungen-Tab (Anmeldung, Guthaben) und Button im Planungs-Tab, der Einheiten+Stunden als JSON an ein neues PHP-Backend (ai-backend/) sendet und die Antwort als prüfbare Vorschlagsliste zurückbringt. Provider-Aufruf, Guthabenverwaltung und Abrechnung nach echten Token-Kosten laufen serverseitig, der Desktop-Client sieht nie einen LLM-API-Key. Zentral abgesichert: eine von der KI zurückgegebene Stunden-Id, die zu keiner echten Lesson der Einheit passt, wird nie als Update übernommen, sondern immer als neue Stunde behandelt. Kompetenzkatalog-Import (8.1.2): JSON-Export/Import für Kompetenzkataloge.
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using LehrerApp.Core.Services;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace LehrerApp.Desktop.ViewModels.Settings;
|
||||
|
||||
public partial class CompetencyCatalogImportViewModel : ObservableObject
|
||||
{
|
||||
private readonly SettingsViewModel _settings;
|
||||
private readonly CompetencyCatalogImportPreview _preview;
|
||||
|
||||
[ObservableProperty] private ImportModeOption _selectedMode;
|
||||
[ObservableProperty] private bool _replaceConfirmed;
|
||||
[ObservableProperty] private string _error = "";
|
||||
|
||||
public IReadOnlyList<ImportModeOption> Modes { get; }
|
||||
public ObservableCollection<CompetencyImportConflictItem> Conflicts { get; } = [];
|
||||
public IReadOnlyList<string> Warnings => _preview.Warnings;
|
||||
public string Target => $"{_preview.SubjectName} · Klassenstufe {_preview.GradeLevel}";
|
||||
public string Summary =>
|
||||
$"{_preview.NewDomains} neue Bereiche · {_preview.NewCompetencies} neue Kompetenzen · " +
|
||||
$"{_preview.UnchangedCompetencies} unverändert · {_preview.Conflicts.Count} Konflikte";
|
||||
public bool HasWarnings => Warnings.Count > 0;
|
||||
public bool HasConflicts => Conflicts.Count > 0;
|
||||
public bool IsMerge => SelectedMode.Mode == CompetencyCatalogImportMode.Merge;
|
||||
public bool IsReplace => SelectedMode.Mode == CompetencyCatalogImportMode.Replace;
|
||||
|
||||
public CompetencyCatalogImportViewModel(
|
||||
SettingsViewModel settings, CompetencyCatalogImportPreview preview)
|
||||
{
|
||||
_settings = settings;
|
||||
_preview = preview;
|
||||
Modes =
|
||||
[
|
||||
new(CompetencyCatalogImportMode.Merge, "Zusammenführen (empfohlen)"),
|
||||
new(CompetencyCatalogImportMode.Replace, "Vorhandenen Katalog ersetzen"),
|
||||
];
|
||||
_selectedMode = Modes[0];
|
||||
foreach (var conflict in preview.Conflicts)
|
||||
Conflicts.Add(new CompetencyImportConflictItem(conflict));
|
||||
}
|
||||
|
||||
partial void OnSelectedModeChanged(ImportModeOption value)
|
||||
{
|
||||
Error = "";
|
||||
ReplaceConfirmed = false;
|
||||
OnPropertyChanged(nameof(IsMerge));
|
||||
OnPropertyChanged(nameof(IsReplace));
|
||||
}
|
||||
|
||||
public bool TryApply()
|
||||
{
|
||||
Error = "";
|
||||
if (IsReplace && !ReplaceConfirmed)
|
||||
{
|
||||
Error = "Bitte bestätige das vollständige Ersetzen des vorhandenen Katalogs.";
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var importedConflicts = Conflicts
|
||||
.Where(x => x.UseImported)
|
||||
.Select(x => x.Id)
|
||||
.ToHashSet(StringComparer.Ordinal);
|
||||
_settings.ApplyCatalogImport(_preview, SelectedMode.Mode, importedConflicts);
|
||||
return true;
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
Error = ex.Message;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record ImportModeOption(CompetencyCatalogImportMode Mode, string Label);
|
||||
|
||||
public partial class CompetencyImportConflictItem : ObservableObject
|
||||
{
|
||||
[ObservableProperty] private bool _useImported;
|
||||
|
||||
public string Id { get; }
|
||||
public string Location { get; }
|
||||
public string ExistingValue { get; }
|
||||
public string ImportedValue { get; }
|
||||
|
||||
public CompetencyImportConflictItem(CompetencyCatalogImportConflict conflict)
|
||||
{
|
||||
Id = conflict.Id;
|
||||
Location = conflict.Location;
|
||||
ExistingValue = conflict.ExistingValue;
|
||||
ImportedValue = conflict.ImportedValue;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user