- Dashboard: Fehlzeiten-Warnung lädt Mitarbeitssitzungen einmal vorab statt pro Schüler/Eintrag einzeln nachzuschlagen (N+1 vermieden); neues IParticipationSessionRepository.GetAll() dafür. - CI: .gitea/workflows/ci.yml baut und testet bei jedem Push/PR. Dabei fehlende Release|Any CPU-Konfiguration für 6 Projekte in der .sln behoben (LehrerApp.Data.Tests wurde bei Release-Builds der Solution bislang stillschweigend übersprungen). TreatWarningsAsErrors jetzt aktiv. - SettingsViewModel (1986 Zeilen) als partial class auf 20 Themen- dateien aufgeteilt, Verhalten unverändert. - Backup: optionaler zweiter Sicherungsordner (USB-Stick/Netzlaufwerk, best-effort) und Integritätsprüfung nach jedem Backup (DatabaseEncryptionService.CanOpenAndRead). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
81 lines
3.2 KiB
C#
81 lines
3.2 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using LehrerApp.Core.Interfaces;
|
|
using LehrerApp.Core.Models;
|
|
using LehrerApp.Core.Services;
|
|
using LehrerApp.Data;
|
|
using LehrerApp.Desktop.Services;
|
|
using LehrerApp.Desktop.ViewModels.Planning;
|
|
using LehrerApp.Sync;
|
|
using LehrerApp.Sync.Crypto;
|
|
using System.Collections.ObjectModel;
|
|
using System.Globalization;
|
|
using System.Security.Cryptography;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace LehrerApp.Desktop.ViewModels.Settings;
|
|
|
|
public partial class SettingsViewModel
|
|
{
|
|
// ── Gewichtungsschema-Voreinstellungen (2.3.3) ───────────────────────────
|
|
|
|
[ObservableProperty] private GradingSchemeEditItem _classScheme = null!;
|
|
[ObservableProperty] private GradingSchemeEditItem _courseScheme = null!;
|
|
|
|
// ── Gewichtungsschema-Voreinstellungen: Laden ────────────────────────────
|
|
|
|
private void LoadGradingSchemes()
|
|
{
|
|
ClassScheme = new GradingSchemeEditItem(
|
|
_gradingSchemes.GetDefaultForType(GroupType.Class)
|
|
?? new GradingScheme { GroupType = GroupType.Class, ExamsPercent = 50, ParticipationPercent = 40, OtherPercent = 10 },
|
|
"Klassen", _gradingSchemes, _grading);
|
|
CourseScheme = new GradingSchemeEditItem(
|
|
_gradingSchemes.GetDefaultForType(GroupType.Course)
|
|
?? new GradingScheme { GroupType = GroupType.Course, ExamsPercent = 60, ParticipationPercent = 30, OtherPercent = 10 },
|
|
"Kurse", _gradingSchemes, _grading);
|
|
}
|
|
}
|
|
|
|
// ── GradingSchemeEditItem (2.3) ────────────────────────────────────────────────
|
|
|
|
public partial class GradingSchemeEditItem : ObservableObject
|
|
{
|
|
private readonly GradingScheme _scheme;
|
|
private readonly IGradingSchemeRepository _repo;
|
|
private readonly GradingService _grading;
|
|
|
|
public string Label { get; }
|
|
|
|
[ObservableProperty] private double _examsPercent;
|
|
[ObservableProperty] private double _participationPercent;
|
|
[ObservableProperty] private double _otherPercent;
|
|
[ObservableProperty] private string _validationMessage = "";
|
|
[ObservableProperty] private string _statusMessage = "";
|
|
|
|
public GradingSchemeEditItem(GradingScheme scheme, string label, IGradingSchemeRepository repo, GradingService grading)
|
|
{
|
|
_scheme = scheme; _repo = repo; _grading = grading;
|
|
Label = label;
|
|
_examsPercent = scheme.ExamsPercent;
|
|
_participationPercent = scheme.ParticipationPercent;
|
|
_otherPercent = scheme.OtherPercent;
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void Save()
|
|
{
|
|
_scheme.ExamsPercent = ExamsPercent;
|
|
_scheme.ParticipationPercent = ParticipationPercent;
|
|
_scheme.OtherPercent = OtherPercent;
|
|
|
|
var error = _grading.ValidateGradingScheme(_scheme);
|
|
if (error is not null) { ValidationMessage = error; StatusMessage = ""; return; }
|
|
|
|
ValidationMessage = "";
|
|
_repo.Save(_scheme);
|
|
StatusMessage = "Gespeichert.";
|
|
}
|
|
}
|