refactor: Dashboard-Handlungsbedarf zu einer Karte zusammenfassen
Fasst die sieben Kacheln, die tatsaechlich "wo muss ich reagieren" beantworten (Entschuldigungen, Fehlzeiten-Warnung, Foerderplan-Wiedervorlage, Korrekturen, ungeplante Stunden, Auffaelligkeiten, Unterrichtszeit-Nacherfassung), zu einer Karte "Handlungsbedarf" mit Filter-Chips zusammen statt sieben eigener Sichtbarkeits-Schalter. Neues gemeinsames Modell AttentionItem/AttentionGroup/AttentionAction traegt nur Anzeigedaten - die Datenbeschaffung bleibt unveraendert in den jeweiligen DashboardViewModel.LoadXxx-Methoden, die am Ende ein AttentionItem statt ihrer eigenen Item-Klasse erzeugen. RebuildAttention() gruppiert nach Art (feste Reihenfolge) und wendet Filter an, ohne die Repos erneut abzufragen. SupportPlanDueItem, CorrectionProgressItem, UnplannedLessonItem und DashboardAlertItem entfallen (nur dashboard-intern verwendet); OpenExcuseItem und AttendanceWarningItem bleiben bestehen, da GroupOverviewViewModel sie weiterhin nutzt. Fuenf Navigations-Commands wurden durch ein einziges OpenAttentionItemCommand ersetzt. Bewusste Verhaltensaenderung: LoadAlerts dupliziert Fehlzeiten-Ueberschreitungen nicht mehr in die Auffaelligkeiten-Gruppe, da dieselbe Zahl sonst zweimal in derselben Karte erschiene (vorher durch zwei getrennte Kacheln nicht sichtbar). Details und Testanpassungen siehe TODO.md, Abschnitt 9 (Dashboard).
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace LehrerApp.Desktop.ViewModels;
|
||||
|
||||
/// <summary>Die sieben Dashboard-Kacheln, die tatsächlich "wo muss ich reagieren" beantworten
|
||||
/// (siehe <see cref="DashboardViewModel.AttentionCount"/>), zusammengefasst zu einer Karte mit
|
||||
/// Filter-Chips statt sieben eigenen Sichtbarkeits-Schaltern. Reihenfolge hier ist die Reihenfolge
|
||||
/// der Gruppen in der zusammengefassten Ansicht (siehe DashboardViewModel.RebuildAttention) — sie
|
||||
/// übernimmt bewusst die frühere Sortierung aus DashboardSettingsService.DefaultCardOrder, damit
|
||||
/// sich nichts, was Nutzer bereits kennen, unvorhersehbar umsortiert.
|
||||
/// "Klausurwochen" (examload) bleibt bewusst außen vor: die Einträge dort sind Wochen-Aggregate,
|
||||
/// keine Einzelvorgänge, die sich abhaken oder anklicken lassen — sie passen nicht ins Item-Modell.</summary>
|
||||
public enum AttentionKind { MissingTeachingTime, Excuse, Correction, Unplanned, Alert, Attendance, SupportPlan }
|
||||
|
||||
/// <summary>Eine Inline-Aktion auf einem Handlungsbedarf-Eintrag (z.B. "Entschuldigt"/"Unentschuldigt",
|
||||
/// "Erfassen"). Verwendet ICommand statt Action, damit die bereits vorhandenen generierten
|
||||
/// RelayCommands (OpenExcuseItem.MarkExcusedCommand, DashboardViewModel.AddMissingTeachingTimeCommand)
|
||||
/// direkt weiterverwendet werden können, statt sie in einen zweiten Delegate-Typ zu verpacken.</summary>
|
||||
public sealed record AttentionAction(string Label, ICommand Command, object? Parameter = null);
|
||||
|
||||
/// <summary>Gemeinsame Projektion für die sieben Handlungsbedarf-Arten. Trägt nur Anzeigedaten —
|
||||
/// die eigentliche Beschaffung bleibt unverändert in den jeweiligen DashboardViewModel.LoadXxx-
|
||||
/// Methoden; sie erzeugen am Ende ein AttentionItem statt (wie vorher) ihre eigene Item-Klasse in
|
||||
/// ihre eigene ObservableCollection einzutragen.</summary>
|
||||
public sealed class AttentionItem
|
||||
{
|
||||
public AttentionKind Kind { get; }
|
||||
public string Title { get; }
|
||||
public string Subtitle { get; }
|
||||
/// <summary>Kurztext rechts neben dem Titel — Fehlzeitenquote, Alert-Kind-Label. Meist leer.</summary>
|
||||
public string TrailingText { get; }
|
||||
public string DateDisplay { get; }
|
||||
public bool IsOverdue { get; }
|
||||
public AlertSeverity? Severity { get; }
|
||||
/// <summary>Nur bei Korrekturen gesetzt (0–100); steuert die ProgressBar. Eigenes HasProgress statt
|
||||
/// Nullability, damit die ProgressBar-Bindung ein einfaches int (kompatibel mit Value:double) bleibt.</summary>
|
||||
public int ProgressPercent { get; }
|
||||
public bool HasProgress { get; }
|
||||
/// <summary>Text unter der ProgressBar, z.B. "3 von 5 Arbeiten bewertet". Nur bei Korrekturen gesetzt.</summary>
|
||||
public string ProgressLabel { get; }
|
||||
/// <summary>Färbt TrailingText wie die frühere Fehlzeiten-Warnung (fest "Foreground=Red") ein —
|
||||
/// nur bei Attendance gesetzt, weil ein AttentionItem dieser Art per Konstruktion nur entsteht,
|
||||
/// wenn die Fehlzeitenquote den Schwellenwert bereits überschreitet.</summary>
|
||||
public bool IsWarningTrailing { get; }
|
||||
public IReadOnlyList<AttentionAction> Actions { get; }
|
||||
public Action? Navigate { get; }
|
||||
|
||||
public AttentionItem(AttentionKind kind, string title, string subtitle = "", string trailingText = "",
|
||||
string dateDisplay = "", bool isOverdue = false, AlertSeverity? severity = null,
|
||||
int progressPercent = 0, string progressLabel = "", bool hasProgress = false,
|
||||
bool isWarningTrailing = false, IReadOnlyList<AttentionAction>? actions = null, Action? navigate = null)
|
||||
{
|
||||
Kind = kind;
|
||||
Title = title;
|
||||
Subtitle = subtitle;
|
||||
TrailingText = trailingText;
|
||||
DateDisplay = dateDisplay;
|
||||
IsOverdue = isOverdue;
|
||||
Severity = severity;
|
||||
ProgressPercent = progressPercent;
|
||||
ProgressLabel = progressLabel;
|
||||
HasProgress = hasProgress;
|
||||
IsWarningTrailing = isWarningTrailing;
|
||||
Actions = actions ?? [];
|
||||
Navigate = navigate;
|
||||
}
|
||||
|
||||
public bool HasSubtitle => !string.IsNullOrWhiteSpace(Subtitle);
|
||||
public bool HasTrailingText => !string.IsNullOrWhiteSpace(TrailingText);
|
||||
public bool HasDate => !string.IsNullOrWhiteSpace(DateDisplay);
|
||||
public bool HasActions => Actions.Count > 0;
|
||||
public bool HasSeverity => Severity is not null;
|
||||
public bool IsHighSeverity => Severity == AlertSeverity.High;
|
||||
public bool IsMediumSeverity => Severity == AlertSeverity.Medium;
|
||||
}
|
||||
|
||||
/// <summary>Eine Kind-Gruppe innerhalb der zusammengefassten Handlungsbedarf-Liste. Items behalten
|
||||
/// die Sortierung, die ihre jeweilige LoadXxx-Methode schon immer produziert hat (z.B. Fehlzeiten
|
||||
/// nach Quote absteigend, Korrekturen nach Datum) — ein zweites, generisches "Importance"-Sortieren
|
||||
/// quer über alle Arten würde diese bewusst gewählten Reihenfolgen wieder zerstören.</summary>
|
||||
public sealed class AttentionGroup(AttentionKind kind, string header, IReadOnlyList<AttentionItem> items)
|
||||
{
|
||||
public AttentionKind Kind { get; } = kind;
|
||||
public string Header { get; } = header;
|
||||
public IReadOnlyList<AttentionItem> Items { get; } = items;
|
||||
public int Count => Items.Count;
|
||||
}
|
||||
|
||||
/// <summary>Ein Filter-Chip für eine Handlungsbedarf-Art in der zusammengefassten Karte — ersetzt
|
||||
/// die frühere Sichtbarkeit je Einzelkachel (siehe DashboardViewModel.LoadAttentionFilters).</summary>
|
||||
public partial class AttentionFilterOption : ObservableObject
|
||||
{
|
||||
[ObservableProperty] private bool _isActive = true;
|
||||
public AttentionKind Kind { get; }
|
||||
public string Label { get; }
|
||||
public Action? OnChanged { get; set; }
|
||||
|
||||
public AttentionFilterOption(AttentionKind kind, string label)
|
||||
{
|
||||
Kind = kind;
|
||||
Label = label;
|
||||
}
|
||||
|
||||
partial void OnIsActiveChanged(bool value) => OnChanged?.Invoke();
|
||||
}
|
||||
@@ -89,20 +89,43 @@ public partial class DashboardViewModel : ObservableObject
|
||||
public ObservableCollection<TaskItem> OpenTasks { get; } = [];
|
||||
public ObservableCollection<GroupChip> CurrentGroups { get; } = [];
|
||||
public ObservableCollection<CalendarDayCell> CalendarDays { get; } = [];
|
||||
public ObservableCollection<OpenExcuseItem> OpenExcuses { get; } = [];
|
||||
public ObservableCollection<AttendanceWarningItem> AttendanceWarnings { get; } = [];
|
||||
public ObservableCollection<ExamWeekLoadItem> ExamWeekLoads { get; } = [];
|
||||
public ObservableCollection<MissingTeachingTimeItem> MissingTeachingTimeEntries { get; } = [];
|
||||
public ObservableCollection<SupportPlanDueItem> SupportPlanReviews { get; } = [];
|
||||
public ObservableCollection<UpcomingDateItem> UpcomingDates { get; } = [];
|
||||
public ObservableCollection<CorrectionProgressItem> OpenCorrections { get; } = [];
|
||||
public ObservableCollection<UnplannedLessonItem> UnplannedLessons { get; } = [];
|
||||
public ObservableCollection<DashboardAlertItem> Alerts { get; } = [];
|
||||
public ObservableCollection<CalendarEventItem> SelectedDayEvents { get; } = [];
|
||||
public ObservableCollection<DashboardCardOption> DashboardCards { get; } = [];
|
||||
public ObservableCollection<DashboardWeatherWarningItem> WeatherWarnings { get; } = [];
|
||||
// Zusammengefasste "Handlungsbedarf"-Karte (vormals sieben eigene Kacheln/Collections:
|
||||
// Entschuldigungen, Fehlzeiten, Förderplan, Korrekturen, ungeplante Stunden, Auffälligkeiten,
|
||||
// Unterrichtszeit-Nacherfassung — siehe AttentionItem.cs). Attention traegt nur, was nach
|
||||
// Filterung (AttentionFilters) tatsaechlich angezeigt wird; die Rohdaten je Art liegen in den
|
||||
// privaten _xyzItems-Feldern und werden von RebuildAttention() neu zusammengesetzt, sobald sich
|
||||
// Daten oder Filter aendern — ohne die Repos erneut abzufragen.
|
||||
public ObservableCollection<AttentionGroup> Attention { get; } = [];
|
||||
public ObservableCollection<AttentionFilterOption> AttentionFilters { get; } = [];
|
||||
public static string[] CalendarWeekdayHeaders { get; } = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"];
|
||||
|
||||
private readonly List<OpenExcuseItem> _excuses = [];
|
||||
private readonly List<AttentionItem> _attendanceItems = [];
|
||||
private readonly List<AttentionItem> _supportItems = [];
|
||||
private readonly List<AttentionItem> _correctionItems = [];
|
||||
private readonly List<AttentionItem> _unplannedItems = [];
|
||||
private readonly List<AttentionItem> _alertItems = [];
|
||||
private readonly List<AttentionItem> _missingTimeItems = [];
|
||||
|
||||
/// Reihenfolge und Überschriften der Gruppen in der zusammengefassten Handlungsbedarf-Karte —
|
||||
/// übernimmt die frühere Kachel-Reihenfolge aus DashboardSettingsService.DefaultCardOrder,
|
||||
/// damit sich für Nutzer nichts unvorhersehbar umsortiert.
|
||||
private static readonly (AttentionKind Kind, string Header)[] AttentionGroupOrder =
|
||||
[
|
||||
(AttentionKind.MissingTeachingTime, "Unterrichtszeit nacherfassen"),
|
||||
(AttentionKind.Excuse, "Offene Entschuldigungen"),
|
||||
(AttentionKind.Correction, "Offene Korrekturen"),
|
||||
(AttentionKind.Unplanned, "Ungeplante Stunden"),
|
||||
(AttentionKind.Alert, "Auffälligkeiten"),
|
||||
(AttentionKind.Attendance, "Fehlzeiten-Warnung"),
|
||||
(AttentionKind.SupportPlan, "Förderplan-Wiedervorlage"),
|
||||
];
|
||||
|
||||
// Navigation-Callback – wird von App.axaml.cs verdrahtet
|
||||
public Action<Guid>? OnNavigateToGroup { get; set; }
|
||||
public Action<Guid>? OnNavigateToStudent { get; set; }
|
||||
@@ -125,21 +148,15 @@ public partial class DashboardViewModel : ObservableObject
|
||||
public DashboardCardOption TodayCard => Card("today");
|
||||
public DashboardCardOption TasksCard => Card("tasks");
|
||||
public DashboardCardOption CalendarCard => Card("calendar");
|
||||
public DashboardCardOption ExcusesCard => Card("excuses");
|
||||
public DashboardCardOption UpcomingCard => Card("upcoming");
|
||||
public DashboardCardOption CorrectionsCard => Card("corrections");
|
||||
public DashboardCardOption UnplannedCard => Card("unplanned");
|
||||
public DashboardCardOption AlertsCard => Card("alerts");
|
||||
public DashboardCardOption AttendanceCard => Card("attendance");
|
||||
public DashboardCardOption ExamLoadCard => Card("examload");
|
||||
public DashboardCardOption MissingTeachingTimeCard => Card("missingteachingtime");
|
||||
public DashboardCardOption SupportCard => Card("support");
|
||||
public DashboardCardOption GroupsCard => Card("groups");
|
||||
public DashboardCardOption AttentionCard => Card("attention");
|
||||
public int TodayLessonCount => TodaysLessons.Count;
|
||||
public int OpenTaskCount => OpenTasks.Count;
|
||||
public int UpcomingCount => UpcomingDates.Count;
|
||||
public int AttentionCount => OpenExcuses.Count + AttendanceWarnings.Count + SupportPlanReviews.Count
|
||||
+ OpenCorrections.Count + UnplannedLessons.Count + Alerts.Count + MissingTeachingTimeEntries.Count;
|
||||
public int AttentionCount => _excuses.Count + _attendanceItems.Count + _supportItems.Count
|
||||
+ _correctionItems.Count + _unplannedItems.Count + _alertItems.Count + _missingTimeItems.Count;
|
||||
public string TodayLessonSummary => TodayLessonCount == 1 ? "1 Stunde" : $"{TodayLessonCount} Stunden";
|
||||
public string OpenTaskSummary => OpenTaskCount == 1 ? "1 Aufgabe" : $"{OpenTaskCount} Aufgaben";
|
||||
public string AttentionSummary => AttentionCount == 1 ? "1 offener Punkt" : $"{AttentionCount} offene Punkte";
|
||||
@@ -181,6 +198,7 @@ public partial class DashboardViewModel : ObservableObject
|
||||
annualPlanSync.DataChanged += () => Avalonia.Threading.Dispatcher.UIThread.Post(LoadCalendar);
|
||||
}
|
||||
LoadDashboardCards();
|
||||
LoadAttentionFilters();
|
||||
Load();
|
||||
RefreshWebUntisHealth();
|
||||
}
|
||||
@@ -265,6 +283,7 @@ public partial class DashboardViewModel : ObservableObject
|
||||
LoadOpenCorrections(groups, today);
|
||||
LoadUnplannedLessons(groups, today);
|
||||
LoadAlerts(groups, today);
|
||||
RebuildAttention();
|
||||
UpdateDashboardSummary();
|
||||
}
|
||||
|
||||
@@ -273,16 +292,10 @@ public partial class DashboardViewModel : ObservableObject
|
||||
TodayCard.IsEmpty = TodaysLessons.Count == 0;
|
||||
TasksCard.IsEmpty = OpenTasks.Count == 0;
|
||||
CalendarCard.IsEmpty = false;
|
||||
ExcusesCard.IsEmpty = OpenExcuses.Count == 0;
|
||||
UpcomingCard.IsEmpty = UpcomingDates.Count == 0;
|
||||
CorrectionsCard.IsEmpty = OpenCorrections.Count == 0;
|
||||
UnplannedCard.IsEmpty = UnplannedLessons.Count == 0;
|
||||
AlertsCard.IsEmpty = Alerts.Count == 0;
|
||||
AttendanceCard.IsEmpty = AttendanceWarnings.Count == 0;
|
||||
ExamLoadCard.IsEmpty = ExamWeekLoads.Count == 0;
|
||||
MissingTeachingTimeCard.IsEmpty = MissingTeachingTimeEntries.Count == 0;
|
||||
SupportCard.IsEmpty = SupportPlanReviews.Count == 0;
|
||||
GroupsCard.IsEmpty = CurrentGroups.Count == 0;
|
||||
AttentionCard.IsEmpty = AttentionCount == 0;
|
||||
|
||||
// Erst nachdem alle IsEmpty-Werte stehen: welche Kachel tatsaechlich gerendert wird, haengt
|
||||
// ueber EffectiveIsVisible daran, und davon wiederum die Zeilen-/Spaltenzuordnung.
|
||||
@@ -353,7 +366,7 @@ public partial class DashboardViewModel : ObservableObject
|
||||
|
||||
private void LoadAttendanceWarnings(DateOnly today)
|
||||
{
|
||||
AttendanceWarnings.Clear();
|
||||
_attendanceItems.Clear();
|
||||
var schoolYear = _sy.CurrentSchoolYear();
|
||||
var from = _sy.SchoolYearStart(schoolYear);
|
||||
var to = _sy.SchoolYearEnd(schoolYear);
|
||||
@@ -376,9 +389,13 @@ public partial class DashboardViewModel : ObservableObject
|
||||
items.Add(new AttendanceWarningItem(student.Id, student.FullName, balance.AbsenceRatePercent));
|
||||
}
|
||||
foreach (var item in items.OrderByDescending(i => i.AbsenceRatePercent))
|
||||
AttendanceWarnings.Add(item);
|
||||
_attendanceItems.Add(ToAttentionItem(item));
|
||||
}
|
||||
|
||||
private AttentionItem ToAttentionItem(AttendanceWarningItem w) => new(
|
||||
AttentionKind.Attendance, w.StudentName, trailingText: $"{w.AbsenceRatePercent:0.#} %",
|
||||
isWarningTrailing: true, navigate: () => OnNavigateToStudent?.Invoke(w.StudentId));
|
||||
|
||||
// ── Klausurwochen (Nutzer-Feedback) ───────────────────────────────────────
|
||||
//
|
||||
// Persönliche Klausurlast über alle Kurse hinweg — anders als die klassenbezogene
|
||||
@@ -410,7 +427,7 @@ public partial class DashboardViewModel : ObservableObject
|
||||
|
||||
private void LoadMissingTeachingTime(DateOnly today)
|
||||
{
|
||||
MissingTeachingTimeEntries.Clear();
|
||||
_missingTimeItems.Clear();
|
||||
var firstDay = today.AddDays(-MissingTeachingTimeLookbackDays);
|
||||
var publicHolidayDates = Enumerable.Range(firstDay.Year, today.Year - firstDay.Year + 1)
|
||||
.SelectMany(y => _publicHolidays.GetHolidays(y, _calendarSettings.State))
|
||||
@@ -445,14 +462,15 @@ public partial class DashboardViewModel : ObservableObject
|
||||
items.Add(new MissingTeachingTimeItem(date, windowStart, windowEnd));
|
||||
}
|
||||
foreach (var item in items.OrderBy(i => i.Date))
|
||||
MissingTeachingTimeEntries.Add(item);
|
||||
_missingTimeItems.Add(new AttentionItem(AttentionKind.MissingTeachingTime, item.DateDisplay,
|
||||
actions: [new AttentionAction("Erfassen", AddMissingTeachingTimeCommand, item)]));
|
||||
}
|
||||
|
||||
// ── Förderplan-Wiedervorlage (5.3.2) ──────────────────────────────────────
|
||||
|
||||
private void LoadSupportPlanReviews(DateOnly today)
|
||||
{
|
||||
SupportPlanReviews.Clear();
|
||||
_supportItems.Clear();
|
||||
var dueBy = today.AddDays(SupportPlanDueWithinDays);
|
||||
|
||||
var due = _documentation.GetAll()
|
||||
@@ -465,8 +483,11 @@ public partial class DashboardViewModel : ObservableObject
|
||||
{
|
||||
var student = _students.GetById(d.StudentId);
|
||||
if (student is null) continue;
|
||||
SupportPlanReviews.Add(new SupportPlanDueItem(
|
||||
d.StudentId, student.FullName, d.Title, d.SupportData!.ReviewDate!.Value, today));
|
||||
var reviewDate = d.SupportData!.ReviewDate!.Value;
|
||||
var studentId = d.StudentId;
|
||||
_supportItems.Add(new AttentionItem(AttentionKind.SupportPlan, student.FullName, subtitle: d.Title,
|
||||
dateDisplay: reviewDate.ToString("dd.MM.yyyy"), isOverdue: reviewDate < today,
|
||||
navigate: () => OnNavigateToStudent?.Invoke(studentId)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,7 +532,7 @@ public partial class DashboardViewModel : ObservableObject
|
||||
|
||||
private void LoadOpenCorrections(IReadOnlyDictionary<Guid, LearningGroup> groups, DateOnly today)
|
||||
{
|
||||
OpenCorrections.Clear();
|
||||
_correctionItems.Clear();
|
||||
foreach (var group in groups.Values)
|
||||
foreach (var exam in _exams.GetByGroup(group.Id)
|
||||
.Where(e => e.Status is ExamStatus.Conducted or ExamStatus.Graded)
|
||||
@@ -519,8 +540,13 @@ public partial class DashboardViewModel : ObservableObject
|
||||
{
|
||||
var (expected, evaluated) = ExamCorrectionCounter.Count(exam,
|
||||
_memberships.GetByGroup(group.Id), _examResults.GetByExam(exam.Id));
|
||||
OpenCorrections.Add(new CorrectionProgressItem(exam.Id, group.Id, exam.Title,
|
||||
group.Name, exam.Date, evaluated, expected, today));
|
||||
var percent = expected == 0 ? 0 : (int)Math.Round(evaluated * 100.0 / expected);
|
||||
var groupId = group.Id;
|
||||
_correctionItems.Add(new AttentionItem(AttentionKind.Correction, exam.Title, subtitle: group.Name,
|
||||
dateDisplay: exam.Date.ToString("dd.MM.yyyy"),
|
||||
isOverdue: exam.Date < today.AddDays(-7) && evaluated < expected,
|
||||
progressPercent: percent, progressLabel: $"{evaluated} von {expected} Arbeiten bewertet", hasProgress: true,
|
||||
navigate: () => OnNavigateToExam?.Invoke(groupId)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -536,14 +562,14 @@ public partial class DashboardViewModel : ObservableObject
|
||||
|
||||
private void LoadUnplannedLessons(IReadOnlyDictionary<Guid, LearningGroup> groups, DateOnly today)
|
||||
{
|
||||
UnplannedLessons.Clear();
|
||||
_unplannedItems.Clear();
|
||||
var lastDay = today.AddDays(UnplannedLessonsLookaheadDays);
|
||||
var publicHolidayDates = Enumerable.Range(today.Year, lastDay.Year - today.Year + 1)
|
||||
.SelectMany(y => _publicHolidays.GetHolidays(y, _calendarSettings.State))
|
||||
.Select(h => h.Date).ToHashSet();
|
||||
var schoolHolidays = _schoolHolidays.GetAll();
|
||||
|
||||
var items = new List<UnplannedLessonItem>();
|
||||
var items = new List<(DateOnly Date, int PeriodNumber, LearningGroup Group)>();
|
||||
foreach (var group in groups.Values.Where(g => g.RequiresLessonPlanning))
|
||||
{
|
||||
var slots = _timetableSlots.GetByGroup(group.Id);
|
||||
@@ -572,12 +598,19 @@ public partial class DashboardViewModel : ObservableObject
|
||||
{
|
||||
continue;
|
||||
}
|
||||
items.Add(new UnplannedLessonItem(group.Id, group.Name, date, slot.PeriodNumber, today));
|
||||
items.Add((date, slot.PeriodNumber, group));
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var item in items.OrderBy(i => i.Date).ThenBy(i => i.PeriodNumber).ThenBy(i => i.GroupName))
|
||||
UnplannedLessons.Add(item);
|
||||
foreach (var (date, periodNumber, group) in items.OrderBy(i => i.Date).ThenBy(i => i.PeriodNumber)
|
||||
.ThenBy(i => i.Group.Name))
|
||||
{
|
||||
var dateDisplay = date == today ? "Heute" : date == today.AddDays(1) ? "Morgen" : date.ToString("dd.MM.");
|
||||
var groupId = group.Id;
|
||||
_unplannedItems.Add(new AttentionItem(AttentionKind.Unplanned,
|
||||
$"{group.Name} · {periodNumber}. Stunde", dateDisplay: dateDisplay,
|
||||
navigate: () => OnNavigateToUnplannedLesson?.Invoke(groupId)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Erkennt, ob eine Stunde ohne eigene Lesson bereits Teil einer Doppelstunde ist, die
|
||||
@@ -609,11 +642,11 @@ public partial class DashboardViewModel : ObservableObject
|
||||
|
||||
private void LoadAlerts(IReadOnlyDictionary<Guid, LearningGroup> groups, DateOnly today)
|
||||
{
|
||||
Alerts.Clear();
|
||||
foreach (var warning in AttendanceWarnings)
|
||||
Alerts.Add(new DashboardAlertItem(warning.StudentId, null, warning.StudentName,
|
||||
"Fehlzeiten", $"Fehlzeitenquote {warning.AbsenceRatePercent:0.#} %", AlertSeverity.High));
|
||||
|
||||
_alertItems.Clear();
|
||||
// Fehlzeiten-Auffälligkeiten erscheinen in der zusammengefassten Handlungsbedarf-Karte
|
||||
// bereits als eigene Gruppe "Fehlzeiten-Warnung" (LoadAttendanceWarnings) — eine weitere
|
||||
// Kopie hier wäre jetzt eine sichtbare Dopplung derselben Schüler/Zahl, die vor dem Merge
|
||||
// durch zwei getrennte Kacheln (Auffälligkeiten vs. Fehlzeiten-Warnung) nicht auffiel.
|
||||
foreach (var group in groups.Values)
|
||||
{
|
||||
var groupReportGrades = _reportGrades.GetByGroup(group.Id);
|
||||
@@ -622,6 +655,7 @@ public partial class DashboardViewModel : ObservableObject
|
||||
{
|
||||
var student = _students.GetById(membership.StudentId);
|
||||
if (student is null) continue;
|
||||
var studentId = student.Id;
|
||||
var values = _grades.GetByStudentAndGroup(student.Id, group.Id)
|
||||
.OrderBy(g => g.Date)
|
||||
.Select(g => int.TryParse(g.Value, out var value) ? (int?)value : null)
|
||||
@@ -635,9 +669,10 @@ public partial class DashboardViewModel : ObservableObject
|
||||
? recent - previous >= 1.0
|
||||
: previous - recent >= 3.0;
|
||||
if (declined)
|
||||
Alerts.Add(new DashboardAlertItem(student.Id, group.Id, student.FullName,
|
||||
"Notenabfall", $"{group.Name}: zuletzt {recent:0.0}, zuvor {previous:0.0}",
|
||||
AlertSeverity.Medium));
|
||||
_alertItems.Add(new AttentionItem(AttentionKind.Alert, student.FullName,
|
||||
subtitle: $"{group.Name}: zuletzt {recent:0.0}, zuvor {previous:0.0}",
|
||||
trailingText: "Notenabfall", severity: AlertSeverity.Medium,
|
||||
navigate: () => OnNavigateToStudent?.Invoke(studentId)));
|
||||
}
|
||||
|
||||
var latestReport = groupReportGrades
|
||||
@@ -646,9 +681,10 @@ public partial class DashboardViewModel : ObservableObject
|
||||
var effective = latestReport?.OverrideValue ?? latestReport?.CalculatedValue;
|
||||
if (int.TryParse(effective, out var reportValue)
|
||||
&& (group.GradingSystem == GradingSystem.Grades1To6 ? reportValue >= 5 : reportValue <= 4))
|
||||
Alerts.Add(new DashboardAlertItem(student.Id, group.Id, student.FullName,
|
||||
"Versetzungsgefährdung", $"{group.Name}: aktueller Stand {reportValue}",
|
||||
AlertSeverity.High));
|
||||
_alertItems.Add(new AttentionItem(AttentionKind.Alert, student.FullName,
|
||||
subtitle: $"{group.Name}: aktueller Stand {reportValue}",
|
||||
trailingText: "Versetzungsgefährdung", severity: AlertSeverity.High,
|
||||
navigate: () => OnNavigateToStudent?.Invoke(studentId)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -670,13 +706,65 @@ public partial class DashboardViewModel : ObservableObject
|
||||
private static string CardTitle(string key) => key switch
|
||||
{
|
||||
"today" => "Heute", "tasks" => "Offene Aufgaben", "calendar" => "Kalender",
|
||||
"excuses" => "Offene Entschuldigungen", "upcoming" => "Anstehende Termine",
|
||||
"corrections" => "Offene Korrekturen", "unplanned" => "Ungeplante Stunden", "alerts" => "Auffälligkeiten",
|
||||
"attendance" => "Fehlzeiten-Warnung", "support" => "Förderplan-Wiedervorlage",
|
||||
"groups" => "Meine Lerngruppen", "examload" => "Klausurwochen",
|
||||
"missingteachingtime" => "Unterrichtszeit nacherfassen", _ => key,
|
||||
"upcoming" => "Anstehende Termine", "groups" => "Meine Lerngruppen", "examload" => "Klausurwochen",
|
||||
"attention" => "Handlungsbedarf", _ => key,
|
||||
};
|
||||
|
||||
// ── Handlungsbedarf: Filter-Chips ─────────────────────────────────────────
|
||||
//
|
||||
// Ersetzt die frühere Sichtbarkeit je Einzelkachel (sieben Schalter im "Bereiche anpassen"-
|
||||
// Panel) durch Filter-Chips innerhalb der zusammengefassten Karte — dichter, und der
|
||||
// naheliegende Ort, weil alle sieben jetzt eine Karte sind. Bewusst nur für die Dauer der
|
||||
// Sitzung (keine Persistenz über DashboardSettingsService): das JSON-Format dort ist eine
|
||||
// flache Liste von Kachel-Einstellungen, eine zweite Objektform nur für diese sieben Filter
|
||||
// hätte das Dateiformat aufgespalten, ohne dass "welche Handlungsbedarf-Art blende ich
|
||||
// dauerhaft aus" bisher als Bedürfnis geäußert wurde.
|
||||
|
||||
private void LoadAttentionFilters()
|
||||
{
|
||||
AttentionFilters.Clear();
|
||||
foreach (var (kind, header) in AttentionGroupOrder)
|
||||
{
|
||||
var option = new AttentionFilterOption(kind, header) { OnChanged = RebuildAttention };
|
||||
AttentionFilters.Add(option);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsAttentionFilterActive(AttentionKind kind) =>
|
||||
AttentionFilters.FirstOrDefault(f => f.Kind == kind)?.IsActive ?? true;
|
||||
|
||||
/// <summary>Setzt Attention aus den bereits geladenen _xyzItems-Feldern neu zusammen — reine
|
||||
/// Umsortierung/Filterung im Speicher, kein Repo-Zugriff. Wird nach jedem Load() sowie nach
|
||||
/// jeder punktuellen Änderung (Entschuldigung aufgelöst, Zeit nacherfasst, Filter-Chip
|
||||
/// umgeschaltet) aufgerufen.</summary>
|
||||
private void RebuildAttention()
|
||||
{
|
||||
var byKind = new Dictionary<AttentionKind, IReadOnlyList<AttentionItem>>
|
||||
{
|
||||
[AttentionKind.MissingTeachingTime] = _missingTimeItems,
|
||||
[AttentionKind.Excuse] = _excuses.Select(ToAttentionItem).ToList(),
|
||||
[AttentionKind.Correction] = _correctionItems,
|
||||
[AttentionKind.Unplanned] = _unplannedItems,
|
||||
[AttentionKind.Alert] = _alertItems,
|
||||
[AttentionKind.Attendance] = _attendanceItems,
|
||||
[AttentionKind.SupportPlan] = _supportItems,
|
||||
};
|
||||
|
||||
Attention.Clear();
|
||||
foreach (var (kind, header) in AttentionGroupOrder)
|
||||
{
|
||||
if (!IsAttentionFilterActive(kind)) continue;
|
||||
var items = byKind[kind];
|
||||
if (items.Count == 0) continue;
|
||||
Attention.Add(new AttentionGroup(kind, header, items));
|
||||
}
|
||||
}
|
||||
|
||||
private static AttentionItem ToAttentionItem(OpenExcuseItem e) => new(
|
||||
AttentionKind.Excuse, e.StudentName, subtitle: $"{e.GroupName} · {e.DateDisplay}",
|
||||
actions: [new AttentionAction("Entschuldigt", e.MarkExcusedCommand),
|
||||
new AttentionAction("Unentschuldigt", e.MarkUnexcusedCommand)]);
|
||||
|
||||
// Zaehlt bewusst EffectiveIsVisible, nicht IsVisible: eine eingeschaltete, aber gerade leere
|
||||
// HideWhenEmpty-Kachel wird nicht gerendert und darf deshalb auch keinen Rasterplatz belegen,
|
||||
// sonst bleibt an ihrer Stelle eine Luecke im zweispaltigen Grid.
|
||||
@@ -721,11 +809,10 @@ public partial class DashboardViewModel : ObservableObject
|
||||
SaveAndApplyCardLayout();
|
||||
}
|
||||
|
||||
[RelayCommand] private void OpenStudentAttendance(AttendanceWarningItem? item)
|
||||
{ if (item is not null) OnNavigateToStudent?.Invoke(item.StudentId); }
|
||||
|
||||
[RelayCommand] private void OpenStudentSupportPlan(SupportPlanDueItem? item)
|
||||
{ if (item is not null) OnNavigateToStudent?.Invoke(item.StudentId); }
|
||||
/// <summary>Ersetzt die früheren fünf eigenen Navigations-Commands (OpenStudentAttendance,
|
||||
/// OpenStudentSupportPlan, OpenCorrection, OpenUnplannedLesson, OpenAlert) — jedes AttentionItem
|
||||
/// trägt sein Sprungziel bereits als Closure in Navigate.</summary>
|
||||
[RelayCommand] private void OpenAttentionItem(AttentionItem? item) => item?.Navigate?.Invoke();
|
||||
|
||||
[RelayCommand]
|
||||
private async Task AddMissingTeachingTime(MissingTeachingTimeItem? item)
|
||||
@@ -733,12 +820,13 @@ public partial class DashboardViewModel : ObservableObject
|
||||
if (item is null || OnAddMissingTeachingTime is null) return;
|
||||
await OnAddMissingTeachingTime(item);
|
||||
LoadMissingTeachingTime(DateOnly.FromDateTime(DateTime.Today));
|
||||
RebuildAttention();
|
||||
UpdateDashboardSummary();
|
||||
}
|
||||
|
||||
private void LoadOpenExcuses(List<LearningGroup> groups, DateOnly today)
|
||||
{
|
||||
OpenExcuses.Clear();
|
||||
_excuses.Clear();
|
||||
var cutoff = today.AddDays(-OpenExcuseMaxAgeDays);
|
||||
|
||||
var items = new List<OpenExcuseItem>();
|
||||
@@ -757,8 +845,7 @@ public partial class DashboardViewModel : ObservableObject
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var item in items.OrderBy(i => i.Date))
|
||||
OpenExcuses.Add(item);
|
||||
_excuses.AddRange(items.OrderBy(i => i.Date));
|
||||
}
|
||||
|
||||
private void ResolveExcuse(OpenExcuseItem item, AttendanceStatus status)
|
||||
@@ -767,7 +854,8 @@ public partial class DashboardViewModel : ObservableObject
|
||||
if (entry is null) return;
|
||||
entry.Attendance = status;
|
||||
_participationEntries.Save(entry);
|
||||
OpenExcuses.Remove(item);
|
||||
_excuses.Remove(item);
|
||||
RebuildAttention();
|
||||
UpdateDashboardSummary();
|
||||
}
|
||||
|
||||
@@ -968,12 +1056,6 @@ public partial class DashboardViewModel : ObservableObject
|
||||
else OnNavigateToGroup?.Invoke(groupId);
|
||||
}
|
||||
}
|
||||
[RelayCommand] private void OpenCorrection(CorrectionProgressItem? item)
|
||||
{ if (item is not null) OnNavigateToExam?.Invoke(item.GroupId); }
|
||||
[RelayCommand] private void OpenUnplannedLesson(UnplannedLessonItem? item)
|
||||
{ if (item is not null) OnNavigateToUnplannedLesson?.Invoke(item.GroupId); }
|
||||
[RelayCommand] private void OpenAlert(DashboardAlertItem? item)
|
||||
{ if (item is not null) OnNavigateToStudent?.Invoke(item.StudentId); }
|
||||
[RelayCommand] private void Refresh() => Load();
|
||||
|
||||
[RelayCommand] private Task AddTask() => AddTaskInternal(startAsReminder: false);
|
||||
@@ -1122,26 +1204,6 @@ public class MissingTeachingTimeItem(DateOnly date, TimeOnly windowStart, TimeOn
|
||||
public string DateDisplay { get; } = date.ToString("dddd, dd.MM.", De);
|
||||
}
|
||||
|
||||
// ── Förderplan-Wiedervorlage (5.3.2) ──────────────────────────────────────────
|
||||
|
||||
public class SupportPlanDueItem
|
||||
{
|
||||
public Guid StudentId { get; }
|
||||
public string StudentName { get; }
|
||||
public string Title { get; }
|
||||
public string ReviewDateDisplay { get; }
|
||||
public bool IsOverdue { get; }
|
||||
|
||||
public SupportPlanDueItem(Guid studentId, string studentName, string title, DateOnly reviewDate, DateOnly today)
|
||||
{
|
||||
StudentId = studentId;
|
||||
StudentName = studentName;
|
||||
Title = title;
|
||||
ReviewDateDisplay = reviewDate.ToString("dd.MM.yyyy");
|
||||
IsOverdue = reviewDate < today;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CalendarDayCell : ObservableObject
|
||||
{
|
||||
[ObservableProperty] private bool _isSelected;
|
||||
@@ -1217,46 +1279,8 @@ public sealed class UpcomingDateItem(UpcomingDateKind kind, DateOnly date, strin
|
||||
};
|
||||
}
|
||||
|
||||
public sealed class CorrectionProgressItem(Guid examId, Guid groupId, string title, string groupName,
|
||||
DateOnly date, int completed, int total, DateOnly today)
|
||||
{
|
||||
public Guid ExamId { get; } = examId;
|
||||
public Guid GroupId { get; } = groupId;
|
||||
public string Title { get; } = title;
|
||||
public string GroupName { get; } = groupName;
|
||||
public DateOnly Date { get; } = date;
|
||||
public int Completed { get; } = completed;
|
||||
public int Total { get; } = total;
|
||||
public int Percent => Total == 0 ? 0 : (int)Math.Round(Completed * 100.0 / Total);
|
||||
public string ProgressDisplay => $"{Completed} von {Total} Arbeiten bewertet";
|
||||
public string DateDisplay => Date.ToString("dd.MM.yyyy");
|
||||
public bool IsOverdue => Date < today.AddDays(-7) && Completed < Total;
|
||||
}
|
||||
|
||||
public sealed class UnplannedLessonItem(Guid groupId, string groupName, DateOnly date, int periodNumber, DateOnly today)
|
||||
{
|
||||
public Guid GroupId { get; } = groupId;
|
||||
public string GroupName { get; } = groupName;
|
||||
public DateOnly Date { get; } = date;
|
||||
public int PeriodNumber { get; } = periodNumber;
|
||||
public string DateDisplay => Date == today ? "Heute" : Date == today.AddDays(1) ? "Morgen" : Date.ToString("dd.MM.");
|
||||
public string Display => $"{GroupName} · {PeriodNumber}. Stunde";
|
||||
}
|
||||
|
||||
public enum AlertSeverity { Medium, High }
|
||||
|
||||
public sealed class DashboardAlertItem(Guid studentId, Guid? groupId, string studentName,
|
||||
string kindLabel, string detail, AlertSeverity severity)
|
||||
{
|
||||
public Guid StudentId { get; } = studentId;
|
||||
public Guid? GroupId { get; } = groupId;
|
||||
public string StudentName { get; } = studentName;
|
||||
public string KindLabel { get; } = kindLabel;
|
||||
public string Detail { get; } = detail;
|
||||
public AlertSeverity Severity { get; } = severity;
|
||||
public string SeverityColor => Severity == AlertSeverity.High ? "#D32F2F" : "#F59E0B";
|
||||
}
|
||||
|
||||
public partial class DashboardCardOption : ObservableObject
|
||||
{
|
||||
[ObservableProperty] private bool _isVisible;
|
||||
@@ -1281,8 +1305,7 @@ public partial class DashboardCardOption : ObservableObject
|
||||
{
|
||||
Key = key;
|
||||
Title = title;
|
||||
HideWhenEmpty = key is "excuses" or "upcoming" or "corrections" or "unplanned"
|
||||
or "alerts" or "attendance" or "support";
|
||||
HideWhenEmpty = key is "upcoming" or "attention";
|
||||
_isVisible = isVisible;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user