Dashboard warnings (attendance, homework, lateness) get a "Details" flyout with key figures, a list of dates and the compact month calendar from the class teacher overview, now extracted as a shared control. The calendar now aligns days under their weekday (Mo-So header, blank leading cells). Creating Vorgänge and documentation is supported by quick blocks with the current figures, dated standard phrases (e.g. "Klassenleitung informiert") and documentation templates (status snapshot, conversation, informing the class/subject teachers, parent call, parent letter). The class teacher Vorgänge tab uses WebUntis figures (absences across all subjects, class register) for the same blocks and templates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0f6cadc9c8
commit
aa326cf8b6
25 files changed
+1571
-75
No files matched your search
@@ -3,6 +3,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using LehrerApp.Core.Interfaces;
|
||||
using LehrerApp.Core.Models;
|
||||
using LehrerApp.Core.Services;
|
||||
using LehrerApp.Desktop.Services;
|
||||
using LehrerApp.Desktop.ViewModels.Students;
|
||||
|
||||
@@ -26,6 +27,10 @@ public partial class ClassTeacherCasesViewModel : ObservableObject
|
||||
|
||||
private string _className = "";
|
||||
private List<StudentOption> _rosterStudentOptions = [];
|
||||
// WebUntis-Stand je Schüler*in für Schnellbausteine/Vorlagen (ClassTeacherStudentFacts) — erst
|
||||
// beim Öffnen eines Dialogs geladen (EnsureFactsAsync), nicht bei jedem Neuladen der Liste.
|
||||
private Dictionary<Guid, ClassTeacherStudentFacts> _facts = [];
|
||||
private Guid? _documentationDraftId;
|
||||
|
||||
public ObservableCollection<VorgangItem> Cases { get; } = [];
|
||||
|
||||
@@ -98,7 +103,10 @@ public partial class ClassTeacherCasesViewModel : ObservableObject
|
||||
.Where(n => n != "");
|
||||
var item = new VorgangItem(vorgang, string.Join(", ", names), LinkDocumentation,
|
||||
UnlinkDocumentation, RemoveClassRegisterEntry, EditDocumentation)
|
||||
{ IsRevealed = revealedIds.Contains(vorgang.Id) };
|
||||
{
|
||||
IsRevealed = revealedIds.Contains(vorgang.Id),
|
||||
OnCreateFromTemplate = CreateDocumentationFromTemplate,
|
||||
};
|
||||
|
||||
var linkedIds = vorgang.DocumentationIds.ToHashSet();
|
||||
foreach (var doc in allDocs.Where(d => linkedIds.Contains(d.Id)))
|
||||
@@ -117,10 +125,83 @@ public partial class ClassTeacherCasesViewModel : ObservableObject
|
||||
|
||||
private void NotifyState() => OnPropertyChanged(nameof(HasCases));
|
||||
|
||||
/// Lädt Fehlzeiten und Klassenbucheinträge des laufenden Schuljahres (aus dem Untis-Cache, der
|
||||
/// kalte Bereich ist dort dauerhaft gespeichert) und leitet daraus den Stand je Schüler*in ab.
|
||||
/// Scheitert der Abruf (offline, Sitzung abgelaufen), gibt es eben nur die Standardformulierungen
|
||||
/// statt eines Fehlers — der Dialog selbst soll davon nicht abhängen.
|
||||
private async Task EnsureFactsAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var sy = new SchoolYearService();
|
||||
var schoolYear = sy.CurrentSchoolYear();
|
||||
var today = DateOnly.FromDateTime(DateTime.Today);
|
||||
var start = sy.SchoolYearStart(schoolYear);
|
||||
var absencesTask = _cache.GetAbsencesAsync(_className, start, today);
|
||||
var registerTask = _cache.GetClassRegisterEventsAsync(_className, start, today);
|
||||
await Task.WhenAll(absencesTask, registerTask);
|
||||
|
||||
var absenceDays = ClassAbsenceDaySummaryRow.GroupByStudentAndDay(absencesTask.Result);
|
||||
var register = registerTask.Result
|
||||
.Select(e => (Entry: e, Valid: DateOnly.TryParseExact(e.Date.ToString(), "yyyyMMdd", out var d), Date: d))
|
||||
.Where(x => x.Valid)
|
||||
.Select(x => new ClassTeacherClassRegisterRow(x.Date, x.Entry.Subject, x.Entry.StudentName,
|
||||
x.Entry.TeacherUsername, x.Entry.CategoryName, x.Entry.CategoryGroup, x.Entry.Text))
|
||||
.ToList();
|
||||
_facts = _rosterStudentOptions.ToDictionary(o => o.Id, o => ClassTeacherStudentFacts.Build(o,
|
||||
NaturalName(o), schoolYear, today, absenceDays, register));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Bewusst still: ohne WebUntis fehlen nur die Zahlen-Bausteine, Standardformulierungen
|
||||
// und Vorlagen (dann ohne Zahlen) bleiben nutzbar.
|
||||
_facts = [];
|
||||
}
|
||||
}
|
||||
|
||||
private string NaturalName(StudentOption option) =>
|
||||
_students.GetById(option.Id) is { } s ? $"{s.FirstName} {s.LastName}".Trim() : option.Name;
|
||||
|
||||
/// Schnellbausteine für die aktuell im Dialog ausgewählten Schüler*innen — bei mehreren mit Namen.
|
||||
public IReadOnlyList<VorgangQuickBlock> QuickBlocksFor(IReadOnlyList<Guid> studentIds) => studentIds
|
||||
.Where(_facts.ContainsKey)
|
||||
.SelectMany(id => _facts[id].QuickBlocks(withName: studentIds.Count > 1))
|
||||
.ToList();
|
||||
|
||||
public bool IsNewDocumentationDraft(Documentation doc) => doc.Id == _documentationDraftId;
|
||||
|
||||
/// Vorlagen beziehen sich auf die/den erste/n Beteiligte/n des Vorgangs (Dokumentation gehört immer
|
||||
/// zu genau einer Person) — der Dialog bietet deshalb auch nur diese Person an, sonst passten die
|
||||
/// eingesetzten Zahlen nicht mehr zur gewählten Person.
|
||||
private async Task CreateDocumentationFromTemplate(VorgangItem item, string key)
|
||||
{
|
||||
if (OnEditDocumentation is null) return;
|
||||
var option = _rosterStudentOptions.FirstOrDefault(o => item.Model.StudentIds.Contains(o.Id));
|
||||
if (option is null) return;
|
||||
await EnsureFactsAsync();
|
||||
var context = _facts.TryGetValue(option.Id, out var facts)
|
||||
? facts.TemplateContext(item.Model)
|
||||
: new VorgangTemplateContext(option.Id, NaturalName(option), DateOnly.FromDateTime(DateTime.Today), [],
|
||||
new Dictionary<string, VorgangSnapshot>());
|
||||
var draft = VorgangDocumentationTemplates.Build(key, item.Model, context);
|
||||
if (draft is null) return;
|
||||
|
||||
_documentationDraftId = draft.Id;
|
||||
Documentation? result;
|
||||
try { result = await OnEditDocumentation(option.Id, [option], draft); }
|
||||
finally { _documentationDraftId = null; }
|
||||
if (result is null) return;
|
||||
_documentation.Save(result);
|
||||
item.Model.DocumentationIds.Add(result.Id);
|
||||
_vorgaenge.Save(item.Model);
|
||||
await LoadInternal();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task AddVorgang()
|
||||
{
|
||||
if (OnEditVorgang is null) return;
|
||||
await EnsureFactsAsync();
|
||||
var result = await OnEditVorgang(_rosterStudentOptions, null);
|
||||
if (result is null) return;
|
||||
_vorgaenge.Save(result);
|
||||
@@ -131,6 +212,7 @@ public partial class ClassTeacherCasesViewModel : ObservableObject
|
||||
private async Task EditVorgang(VorgangItem? item)
|
||||
{
|
||||
if (item is null || OnEditVorgang is null) return;
|
||||
await EnsureFactsAsync();
|
||||
var result = await OnEditVorgang(_rosterStudentOptions, item.Model);
|
||||
if (result is null) return;
|
||||
_vorgaenge.Save(result);
|
||||
|
||||
Reference in new issue
Block a user