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

@@ -15,6 +15,9 @@ public partial class CompetencyOverviewTabViewModel : ObservableObject
private readonly ICompetencyDomainRepository _catalog;
private readonly ICompetencyCatalogVersionRepository _versions;
private readonly IStudentRepository _students;
private readonly IParticipationSessionRepository _participationSessions;
private readonly IParticipationRepository _participationEntries;
private readonly IParticipationAspectRepository _participationAspects;
private readonly CompetencyAnalysisService _analysis;
private LearningGroup? _group;
@@ -35,7 +38,9 @@ public partial class CompetencyOverviewTabViewModel : ObservableObject
public CompetencyOverviewTabViewModel(IUnitRepository units, IExamRepository exams,
IExamResultRepository results, ICompetencyDomainRepository catalog,
ICompetencyCatalogVersionRepository versions,
IStudentRepository students, CompetencyAnalysisService analysis)
IStudentRepository students, IParticipationSessionRepository participationSessions,
IParticipationRepository participationEntries, IParticipationAspectRepository participationAspects,
CompetencyAnalysisService analysis)
{
_units = units;
_exams = exams;
@@ -43,6 +48,9 @@ public partial class CompetencyOverviewTabViewModel : ObservableObject
_catalog = catalog;
_versions = versions;
_students = students;
_participationSessions = participationSessions;
_participationEntries = participationEntries;
_participationAspects = participationAspects;
_analysis = analysis;
}
@@ -72,7 +80,12 @@ public partial class CompetencyOverviewTabViewModel : ObservableObject
var units = _units.GetByGroup(_group.Id);
var exams = _exams.GetByGroup(_group.Id);
var results = exams.SelectMany(x => _results.GetByExam(x.Id)).ToList();
var analysis = _analysis.Analyze(domains, units, exams, results);
var sessions = _participationSessions.GetByGroup(_group.Id);
var entries = sessions.SelectMany(x => _participationEntries.GetBySession(x.Id)).ToList();
var aspects = _participationAspects.GetDefaults()
.Concat(_participationAspects.GetByGroup(_group.Id)).ToList();
if (aspects.Count == 0) aspects = [.. DefaultParticipationAspects.All];
var analysis = _analysis.Analyze(domains, units, exams, results, sessions, entries, aspects);
StudentOptions.Clear();
foreach (var student in _students.GetByGroup(_group.Id)
@@ -130,6 +143,9 @@ public partial class CompetencyOverviewRow : ObservableObject
public string ExamCoverage => CoverageText(
_item.AssessedExamCount, "geprüft", _item.PlannedExamCount, "geplant");
public string GroupResult => ScoreText(_item.GroupScore, includeParticipants: true);
public string ParticipationCoverage => _item.ParticipationSessionCount == 0
? "–"
: $"{_item.ParticipationSessionCount}× bewertet";
public CompetencyOverviewRow(CompetencyAnalysisItem item, Guid? studentId, double threshold)
{
@@ -182,7 +198,18 @@ public partial class CompetencyOverviewRow : ObservableObject
private static string ScoreText(CompetencyScore? score, bool includeParticipants)
{
if (score is null) return "–";
var evidence = score.EvidenceCount == 1 ? "1 Aufgabenwert" : $"{score.EvidenceCount} Aufgabenwerte";
var evidenceParts = new List<string>();
if (score.ExamEvidenceCount > 0)
evidenceParts.Add(score.ExamEvidenceCount == 1
? "1 Aufgabenwert"
: $"{score.ExamEvidenceCount} Aufgabenwerte");
if (score.ParticipationEvidenceCount > 0)
evidenceParts.Add(score.ParticipationEvidenceCount == 1
? "1 Mitarbeitswert"
: $"{score.ParticipationEvidenceCount} Mitarbeitswerte");
var evidence = evidenceParts.Count > 0
? string.Join(" · ", evidenceParts)
: score.EvidenceCount == 1 ? "1 Wert" : $"{score.EvidenceCount} Werte";
return includeParticipants
? $"{score.Percent:0.#} % · {score.ParticipantCount} Schüler · {evidence}"
: $"{score.Percent:0.#} % · {evidence}";
@@ -767,26 +767,14 @@ public class AspectColumnDef
/// Tagesform als die fachliche Kompetenz beschreibt.</summary>
public static class ParticipationCompetencyEstimate
{
private const double DayHighlightAdjustment = 1.0;
public static int? Estimate(List<AspectRating> ratings, IReadOnlyList<AspectColumnDef> aspects, DayHighlightKind? dayHighlight)
{
var normalized = ratings
.Select(r => (Rating: r, Def: aspects.FirstOrDefault(a => a.Key == r.Key)))
.Where(x => x.Def is not null)
.Select(x => ParticipationRatingScale.Normalize(x.Def!.ValueType, x.Rating.Value, x.Def.MaxPoints))
.ToList();
if (normalized.Count == 0) return null;
var adjustment = dayHighlight switch
{
DayHighlightKind.Standout => DayHighlightAdjustment,
DayHighlightKind.Sleepy or DayHighlightKind.Rough => -DayHighlightAdjustment,
_ => 0,
};
var estimate = (int)Math.Round(normalized.Average() + adjustment, MidpointRounding.AwayFromZero);
return Math.Clamp(estimate, -2, 2);
}
=> LehrerApp.Core.Services.ParticipationCompetencyEstimate.Estimate(ratings,
aspects.Select(x => new ParticipationAspect
{
Key = x.Key,
ValueType = x.ValueType,
MaxPoints = x.MaxPoints,
}).ToList(), dayHighlight);
}
public class ParticipationSessionItem
@@ -33,6 +33,20 @@ public partial class SettingsViewModel
[ObservableProperty] private string _untisPassword = "";
[ObservableProperty] private string _untisApiStatus = "";
[ObservableProperty] private bool _untisApiBusy;
public bool UntisScheduleSyncIsConfigured => UntisApiIsConfigured || UntisIsConfigured;
public string UntisScheduleSyncSource => UntisApiIsConfigured
? "Direkter WebUntis-REST-Abgleich aktiv; iCal wird nur ohne API-Zugang verwendet."
: "iCal-Fallback aktiv.";
partial void OnUntisApiIsConfiguredChanged(bool value)
{
OnPropertyChanged(nameof(UntisScheduleSyncIsConfigured));
OnPropertyChanged(nameof(UntisScheduleSyncSource));
}
partial void OnUntisIsConfiguredChanged(bool value)
{
OnPropertyChanged(nameof(UntisScheduleSyncIsConfigured));
OnPropertyChanged(nameof(UntisScheduleSyncSource));
}
[ObservableProperty] private string? _untisHomeroomClassName;
public string UntisHomeroomClassDisplay => UntisHomeroomClassName is { Length: > 0 } name
? $"Ausgewählt: {name}"
@@ -44,8 +58,8 @@ public partial class SettingsViewModel
// ── WebUntis-iCal-Abgleich: Laden / Speichern / Entfernen / Jetzt abrufen ────
//
// Wie bei Sync deckt ein Neustart das Registrieren von UntisSyncService ab
// (AppBootstrapper registriert es nur einmalig beim Start, wenn URL+Enabled vorliegen).
// UntisSyncService ist immer registriert und entscheidet je Abruf: REST bei vorhandenem
// API-Zugang, sonst der weiterhin unterstützte iCal-Fallback.
private void LoadUntisSettings()
{