CI / build-and-test (push) Canceled after 0s
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>
117 lines
5.3 KiB
C#
117 lines
5.3 KiB
C#
using LehrerApp.Core.Models;
|
|
using LehrerApp.Desktop.ViewModels.ClassTeacher;
|
|
using LehrerApp.Desktop.ViewModels.Students;
|
|
using LehrerApp.Desktop.Views.Shared;
|
|
using Xunit;
|
|
|
|
namespace LehrerApp.Desktop.Tests;
|
|
|
|
/// Tests für Standardformulierungen, schülerabhängige Bausteine im Vorgang-Dialog, den WebUntis-Stand
|
|
/// der Klassenlehrer-Vorgänge und die Wochentags-Ausrichtung des kompakten Monatskalenders.
|
|
public sealed class VorgangBausteineTests
|
|
{
|
|
[Fact]
|
|
public void KompakterKalender_BeginntInDerSpalteDesWochentags()
|
|
{
|
|
// 1. September 2026 ist ein Dienstag -> eine Leerzelle (Montag) davor.
|
|
var days = Enumerable.Range(1, 30).Select(d => new ClassTeacherCompactCalendarDay(
|
|
new DateOnly(2026, 9, d), "", "#00000000", "", false)).ToList();
|
|
|
|
var cells = CompactMonthCalendar.BuildCells(days);
|
|
|
|
Assert.True(cells[0].IsPlaceholder);
|
|
Assert.Equal(new DateOnly(2026, 9, 1), cells[1].Day!.Date);
|
|
Assert.Equal(31, cells.Count);
|
|
}
|
|
|
|
[Fact]
|
|
public void KompakterKalender_MonatsbeginnAmMontag_OhneLeerzelle()
|
|
{
|
|
var days = new[] { new ClassTeacherCompactCalendarDay(new DateOnly(2026, 6, 1), "", "", "", false) };
|
|
Assert.False(CompactMonthCalendar.BuildCells(days)[0].IsPlaceholder);
|
|
}
|
|
|
|
[Fact]
|
|
public void Standardformulierung_WirdAlsZeileAngehaengt()
|
|
{
|
|
var vm = new VorgangDialogViewModel([new StudentOption(Guid.NewGuid(), "Anna")], null,
|
|
phraseBlocks: VorgangPhraseBlocks.ForStudent(new DateOnly(2026, 9, 26))) { Description = "Notiz" };
|
|
|
|
vm.InsertPhraseCommand.Execute(vm.PhraseBlocks.First(p => p.Label == "Klassenleitung informiert"));
|
|
|
|
Assert.Equal("Notiz\n26.09.2026: Klassenleitung informiert.", vm.Description);
|
|
}
|
|
|
|
[Fact]
|
|
public void SchuelerBausteine_FolgenDerAuswahlImDialog()
|
|
{
|
|
var anna = new StudentOption(Guid.NewGuid(), "Anna");
|
|
var ben = new StudentOption(Guid.NewGuid(), "Ben");
|
|
var vm = new VorgangDialogViewModel([anna, ben], null,
|
|
studentQuickBlocks: ids => ids.Select(id => new VorgangQuickBlock(id == anna.Id ? "A" : "B", "")).ToList());
|
|
|
|
Assert.False(vm.HasQuickBlocks);
|
|
vm.StudentOptions[1].IsSelected = true;
|
|
Assert.Equal(["B"], vm.QuickBlocks.Select(b => b.Label));
|
|
vm.StudentOptions[0].IsSelected = true;
|
|
Assert.Equal(["A", "B"], vm.QuickBlocks.Select(b => b.Label));
|
|
}
|
|
|
|
private static ClassAbsenceDaySummaryRow Absence(DateOnly date, string name, int periods, bool unexcused,
|
|
bool fullDay = false, string reason = "Krankheit") => new(date, name, null, periods, periods * 45,
|
|
["M"], [1], [unexcused ? "nicht entschuldigt" : "entschuldigt"], [reason], null, null, fullDay);
|
|
|
|
[Fact]
|
|
public void KlassenlehrerStand_ZaehltFehlzeitenVerspaetungenUndKlassenbuch()
|
|
{
|
|
var student = new StudentOption(Guid.NewGuid(), "Beispiel Anna");
|
|
var today = new DateOnly(2026, 9, 26);
|
|
var absences = new[]
|
|
{
|
|
Absence(today.AddDays(-3), "Anna Beispiel", 6, unexcused: true, fullDay: true),
|
|
Absence(today.AddDays(-5), "Anna Beispiel", 2, unexcused: false),
|
|
Absence(today.AddDays(-6), "Anna Beispiel", 0, unexcused: false, reason: "Verspätung"),
|
|
Absence(today.AddDays(-3), "Ben Fremd", 6, unexcused: true),
|
|
};
|
|
var register = new[]
|
|
{
|
|
new ClassTeacherClassRegisterRow(today.AddDays(-2), "D", "Anna Beispiel", "MUE", "Hausaufgaben fehlen", "Negativ", null),
|
|
new ClassTeacherClassRegisterRow(today.AddDays(-1), "E", "Anna Beispiel", "SCH", "Lob", "Positiv", null),
|
|
};
|
|
|
|
var facts = ClassTeacherStudentFacts.Build(student, "Anna Beispiel", "2026/27", today, absences, register);
|
|
|
|
Assert.Equal(8, facts.AbsentPeriods);
|
|
Assert.Equal(1, facts.UnexcusedDays);
|
|
Assert.Single(facts.LateDays);
|
|
Assert.Equal(1, facts.NegativeRegisterCount);
|
|
Assert.Single(facts.HomeworkEntries);
|
|
Assert.Contains("8 Fehlstunden an 2 Tagen", facts.AbsenceShort);
|
|
|
|
var labels = facts.QuickBlocks(withName: true).Select(b => b.Label).ToList();
|
|
Assert.Contains("Fehlzeiten · Beispiel Anna", labels);
|
|
|
|
var ctx = facts.TemplateContext(new Vorgang { Title = "Fehlzeiten", Tags = ["Absentismus"] });
|
|
Assert.Equal([facts.AbsenceShort], ctx.SituationLines);
|
|
var letter = VorgangDocumentationTemplates.Build(VorgangDocumentationTemplates.ParentLetter,
|
|
new Vorgang { Title = "Fehlzeiten", Tags = ["Absentismus"] }, ctx)!;
|
|
Assert.StartsWith("Sehr geehrte Erziehungsberechtigte von Anna Beispiel", letter.ParentLetterData!.DraftContent);
|
|
}
|
|
|
|
[Fact]
|
|
public void Vorlage_KlassenleitungInformieren()
|
|
{
|
|
var id = Guid.NewGuid();
|
|
var ctx = new VorgangTemplateContext(id, "Anna Beispiel", new DateOnly(2026, 9, 26), ["Fehlquote 25 %"],
|
|
new Dictionary<string, VorgangSnapshot>());
|
|
|
|
var doc = VorgangDocumentationTemplates.Build(VorgangDocumentationTemplates.InformClassTeacher,
|
|
new Vorgang { Title = "Fehlzeiten" }, ctx)!;
|
|
|
|
Assert.Equal(DocumentationType.Conversation, doc.Type);
|
|
Assert.Equal(["Klassenleitung"], doc.Participants);
|
|
Assert.Contains("Klassenleitung am 26.09.2026 informiert über:\n- Fehlquote 25 %", doc.Content);
|
|
Assert.Equal(id, doc.StudentId);
|
|
}
|
|
}
|