This commit is contained in:
1 parent
cdb4637c65
commit
f0c0479bcb
22 files changed
+1099
-76
No files matched your search
@@ -40,7 +40,8 @@ public sealed class CompetencyOverviewViewModelTests
|
||||
Items = [k1],
|
||||
});
|
||||
var vm = new CompetencyOverviewTabViewModel(units, new FakeExams([exam]), results,
|
||||
catalog, versions, new FakeStudents([student]), new CompetencyAnalysisService());
|
||||
catalog, versions, new FakeStudents([student]), new FakeSessions([]), new FakeEntries(),
|
||||
new FakeAspects(), new CompetencyAnalysisService());
|
||||
|
||||
vm.Initialize(group);
|
||||
|
||||
@@ -70,4 +71,52 @@ public sealed class CompetencyOverviewViewModelTests
|
||||
|
||||
Assert.Equal("Stand solide", row.Recommendation);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Initialize_AutomatischeMitarbeitsschaetzung_FuelltKompetenzprofil()
|
||||
{
|
||||
var subjectId = Guid.NewGuid();
|
||||
var group = new LearningGroup { SubjectId = subjectId, GradeLevel = 8 };
|
||||
var student = new Student { FirstName = "Ada", LastName = "Lovelace" };
|
||||
var competency = new CompetencyItem { Code = "K1", Description = "Kompetenz" };
|
||||
var versions = new FakeCompetencyCatalogVersions();
|
||||
var version = versions.GetOrCreateDefault(subjectId);
|
||||
var catalog = new FakeCompetencyDomains();
|
||||
catalog.Add(new CompetencyDomain
|
||||
{
|
||||
SubjectId = subjectId,
|
||||
GradeLevel = 8,
|
||||
VersionId = version.Id,
|
||||
Name = "Bereich",
|
||||
Items = [competency],
|
||||
});
|
||||
var session = new ParticipationSession
|
||||
{
|
||||
GroupId = group.Id,
|
||||
Competencies = [new CompetencyReference
|
||||
{
|
||||
ItemId = competency.Id,
|
||||
Code = competency.Code,
|
||||
Description = competency.Description,
|
||||
}],
|
||||
};
|
||||
var entries = new FakeEntries();
|
||||
entries.Add(new ParticipationEntry
|
||||
{
|
||||
SessionId = session.Id,
|
||||
StudentId = student.Id,
|
||||
Ratings = [new AspectRating { Key = "quality", Value = 1 }],
|
||||
});
|
||||
|
||||
var vm = new CompetencyOverviewTabViewModel(new FakeUnits(), new FakeExams([]),
|
||||
new FakeResults(), catalog, versions, new FakeStudents([student]),
|
||||
new FakeSessions([session]), entries, new FakeAspects(), new CompetencyAnalysisService());
|
||||
|
||||
vm.Initialize(group);
|
||||
|
||||
var row = Assert.Single(vm.Rows);
|
||||
Assert.Equal("1× bewertet", row.ParticipationCoverage);
|
||||
Assert.Contains("75 %", row.GroupResult);
|
||||
Assert.Contains("1 Mitarbeitswert", row.StudentResult);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,8 @@ public sealed class GroupDetailViewModelTests
|
||||
new PlanningTabViewModel(new FakeUnits(), new FakeLessons(), groups, subjects,
|
||||
new FakeCompetencyDomains(), new FakeCompetencyCatalogVersions(), TestSupport.BuildAiSettingsService(), new FakeSessions([])),
|
||||
new CompetencyOverviewTabViewModel(new FakeUnits(), exams, new FakeResults(),
|
||||
new FakeCompetencyDomains(), new FakeCompetencyCatalogVersions(), students, new CompetencyAnalysisService()),
|
||||
new FakeCompetencyDomains(), new FakeCompetencyCatalogVersions(), students,
|
||||
new FakeSessions([]), new FakeEntries(), new FakeAspects(), new CompetencyAnalysisService()),
|
||||
new SeatingPlanTabViewModel(new FakeSeatingPlans(), students, memberships,
|
||||
new FakeSessions([]), new FakeEntries(), new FakeAspects()),
|
||||
new GroupDocumentationTabViewModel(new FakeDocumentation(), students, groups));
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
using LehrerApp.Core.Interfaces;
|
||||
using LehrerApp.Core.Models;
|
||||
using LehrerApp.Core.Services;
|
||||
using LehrerApp.Desktop.Services;
|
||||
using Xunit;
|
||||
|
||||
namespace LehrerApp.Desktop.Tests;
|
||||
|
||||
public sealed class WebUntisRestSyncProcessorTests
|
||||
{
|
||||
private static readonly DateOnly Monday = new(2026, 9, 28);
|
||||
|
||||
[Fact]
|
||||
public void Process_AusfallImDoppelblock_SchreibtBeideStundenUndIstIdempotent()
|
||||
{
|
||||
var group = new LearningGroup { Id = Guid.NewGuid(), Name = "8c" };
|
||||
var mappings = new FakeUntisSlotMappings();
|
||||
mappings.Add(new UntisSlotMapping
|
||||
{
|
||||
Weekday = DayOfWeek.Tuesday, StartTime = new TimeOnly(9, 40), Summary = "NAT",
|
||||
ClassToken = "8c", Kind = SubstitutionKind.Lesson, GroupId = group.Id,
|
||||
PeriodNumber = 3, CoveredPeriods = [3, 4], Confirmed = true,
|
||||
});
|
||||
var substitutions = new FakeSubstitutionEntries();
|
||||
var processor = BuildProcessor(mappings, substitutions, new RecordingExams(), [group]);
|
||||
var cancelled = Entry([100, 101], "2026-09-29T09:40", "2026-09-29T11:10",
|
||||
"NORMAL_TEACHING_PERIOD", "CANCELLED", "NAT", "8c");
|
||||
|
||||
var first = processor.Process([cancelled], Monday, Monday.AddDays(13), Monday.AddDays(27));
|
||||
var second = processor.Process([cancelled], Monday, Monday.AddDays(13), Monday.AddDays(27));
|
||||
|
||||
Assert.Equal(2, first.SubstitutionChanges);
|
||||
Assert.Equal(0, second.SubstitutionChanges);
|
||||
Assert.Equal([3, 4], substitutions.GetAll().Select(entry => entry.PeriodNumber).Order().ToArray());
|
||||
Assert.All(substitutions.GetAll(), entry => Assert.Equal(SubstitutionKind.Cancelled, entry.Kind));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Process_Exam_LegtArbeitMitTitelAnUndEntferntSieNachVerschwinden()
|
||||
{
|
||||
var group = new LearningGroup { Id = Guid.NewGuid(), Name = "Mat_E" };
|
||||
var mappings = new FakeUntisSlotMappings();
|
||||
mappings.Add(new UntisSlotMapping
|
||||
{
|
||||
Weekday = DayOfWeek.Tuesday, StartTime = new TimeOnly(9, 40), Summary = "Mat_E",
|
||||
ClassToken = "10a;10b;10c;Gastro", Kind = SubstitutionKind.Lesson, GroupId = group.Id,
|
||||
PeriodNumber = 3, CoveredPeriods = [3, 4], Confirmed = true,
|
||||
});
|
||||
var exams = new RecordingExams();
|
||||
var processor = BuildProcessor(mappings, new FakeSubstitutionEntries(), exams, [group]);
|
||||
var exam = Entry([2002979, 2002982], "2026-09-29T09:40", "2026-09-29T11:10",
|
||||
"EXAM", "REGULAR", "Mat_E", "10a", "Arbeit 1. Mathearbeit");
|
||||
|
||||
var imported = processor.Process([exam], Monday, Monday.AddDays(13), Monday.AddDays(27));
|
||||
var unchanged = processor.Process([exam], Monday, Monday.AddDays(13), Monday.AddDays(27));
|
||||
var removed = processor.Process([], Monday, Monday.AddDays(13), Monday.AddDays(27));
|
||||
|
||||
Assert.Equal(1, imported.ExamChanges);
|
||||
Assert.Equal(0, unchanged.ExamChanges);
|
||||
Assert.Equal(1, removed.ExamChanges);
|
||||
Assert.Empty(exams.GetAll());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Process_ManuelleArbeitAmSelbenTag_WirdNichtDupliziertOderGeloescht()
|
||||
{
|
||||
var group = new LearningGroup { Id = Guid.NewGuid(), Name = "Mat_E" };
|
||||
var manual = new Exam { GroupId = group.Id, Date = new DateOnly(2026, 9, 29), Title = "1. Arbeit" };
|
||||
var exams = new RecordingExams([manual]);
|
||||
var mappings = new FakeUntisSlotMappings();
|
||||
mappings.Add(new UntisSlotMapping
|
||||
{
|
||||
Weekday = DayOfWeek.Tuesday, StartTime = new TimeOnly(9, 40), Summary = "Mat_E",
|
||||
ClassToken = "10a", GroupId = group.Id, PeriodNumber = 3, CoveredPeriods = [3, 4], Confirmed = true,
|
||||
});
|
||||
var processor = BuildProcessor(mappings, new FakeSubstitutionEntries(), exams, [group]);
|
||||
|
||||
processor.Process([Entry([1], "2026-09-29T09:40", "2026-09-29T11:10", "EXAM", "REGULAR",
|
||||
"Mat_E", "10a", "Arbeit aus WebUntis")], Monday, Monday.AddDays(13), Monday.AddDays(27));
|
||||
|
||||
Assert.Same(manual, Assert.Single(exams.GetAll()));
|
||||
Assert.Null(manual.ExternalId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Process_UebernommeneRegulaereAufsicht_WirdAlsAenderungErfasst()
|
||||
{
|
||||
var duties = new FakeSupervisionDuties();
|
||||
duties.Add(new SupervisionDuty { Weekday = DayOfWeek.Wednesday, AfterPeriod = 2, Location = "PH grün" });
|
||||
var substitutions = new FakeSubstitutionEntries();
|
||||
var processor = BuildProcessor(new FakeUntisSlotMappings(), substitutions, new RecordingExams(), [], duties);
|
||||
var entry = new UntisTimetableGridEntryDto([17], new DateTime(2026, 9, 30, 9, 20, 0),
|
||||
new DateTime(2026, 9, 30, 9, 40, 0), "BREAK_SUPERVISION", "CHANGED", "SUBSTITUTED",
|
||||
null, null, null, null,
|
||||
[new UntisGridResourceChangeDto(null,
|
||||
new UntisGridResourceDto("TEACHER", "REMOVED", "HED", null, "HED"))]);
|
||||
|
||||
processor.Process([entry], Monday, Monday.AddDays(13), Monday.AddDays(27));
|
||||
|
||||
var change = Assert.Single(substitutions.GetAll());
|
||||
Assert.Equal(SubstitutionKind.Supervision, change.Kind);
|
||||
Assert.Equal(2, change.AfterPeriod);
|
||||
Assert.Contains("übernommen", change.Description);
|
||||
}
|
||||
|
||||
private static WebUntisRestSyncProcessor BuildProcessor(FakeUntisSlotMappings mappings,
|
||||
FakeSubstitutionEntries substitutions, IExamRepository exams, List<LearningGroup> groups,
|
||||
FakeSupervisionDuties? supervisionDuties = null)
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), $"lehrerapp-rest-sync-tests-{Guid.NewGuid():N}");
|
||||
Directory.CreateDirectory(path);
|
||||
var periods = new PeriodScheduleService(path);
|
||||
periods.SetPeriods([
|
||||
new PeriodTimeEntry { PeriodNumber = 2, Start = new TimeOnly(8, 35), End = new TimeOnly(9, 20) },
|
||||
new PeriodTimeEntry { PeriodNumber = 3, Start = new TimeOnly(9, 40), End = new TimeOnly(10, 25) },
|
||||
new PeriodTimeEntry { PeriodNumber = 4, Start = new TimeOnly(10, 25), End = new TimeOnly(11, 10) },
|
||||
]);
|
||||
return new WebUntisRestSyncProcessor(mappings, substitutions, exams, new FakeGroups(groups),
|
||||
supervisionDuties ?? new FakeSupervisionDuties(), periods);
|
||||
}
|
||||
|
||||
private static UntisTimetableGridEntryDto Entry(IReadOnlyList<int> ids, string start, string end,
|
||||
string type, string status, string subject, string className, string? lessonInfo = null) => new(
|
||||
ids, DateTime.Parse(start), DateTime.Parse(end), type, status, null, null, null, lessonInfo, null,
|
||||
[
|
||||
new UntisGridResourceChangeDto(new UntisGridResourceDto("CLASS", "REGULAR", className, null, className), null),
|
||||
new UntisGridResourceChangeDto(new UntisGridResourceDto("SUBJECT", "REGULAR", subject, null, subject), null),
|
||||
]);
|
||||
|
||||
private sealed class RecordingExams(List<Exam>? initial = null) : IExamRepository
|
||||
{
|
||||
private readonly List<Exam> _all = initial ?? [];
|
||||
public Exam? GetById(Guid id) => _all.FirstOrDefault(exam => exam.Id == id);
|
||||
public List<Exam> GetAll() => _all.ToList();
|
||||
public List<Exam> GetByGroup(Guid groupId) => _all.Where(exam => exam.GroupId == groupId).ToList();
|
||||
public void Save(Exam exam) { _all.RemoveAll(item => item.Id == exam.Id); _all.Add(exam); }
|
||||
public void Delete(Guid id) => _all.RemoveAll(exam => exam.Id == id);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user