feat: improve WebUntis sync and competency insights
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
admin committed 2026-09-20 22:17:29 +02:00
1 parent cdb4637c65
commit f0c0479bcb
22 files changed
+1099 -76

No files matched your search

@@ -0,0 +1,36 @@
using LehrerApp.Core.Models;
namespace LehrerApp.Core.Services;
/// <summary>
/// Leitet aus den allgemeinen Mitarbeitsaspekten einen Kompetenzwert auf der gemeinsamen
/// Skala von -2 bis +2 ab. Explizite Kompetenzbewertungen werden vom Aufrufer bevorzugt.
/// </summary>
public static class ParticipationCompetencyEstimate
{
public static int? Estimate(IEnumerable<AspectRating> ratings,
IReadOnlyCollection<ParticipationAspect> aspects, DayHighlightKind? dayHighlight)
{
var aspectsByKey = aspects
.GroupBy(x => x.Key, StringComparer.OrdinalIgnoreCase)
.ToDictionary(x => x.Key, x => x.Last(), StringComparer.OrdinalIgnoreCase);
var normalized = ratings
.Where(x => aspectsByKey.ContainsKey(x.Key))
.Select(x =>
{
var aspect = aspectsByKey[x.Key];
return ParticipationRatingScale.Normalize(aspect.ValueType, x.Value, aspect.MaxPoints);
})
.ToList();
if (normalized.Count == 0) return null;
var adjustment = dayHighlight switch
{
DayHighlightKind.Standout => 1.0,
DayHighlightKind.Sleepy or DayHighlightKind.Rough => -1.0,
_ => 0.0,
};
return Math.Clamp((int)Math.Round(normalized.Average() + adjustment,
MidpointRounding.AwayFromZero), -2, 2);
}
}