feat: Kompetenzzuordnungen von Freitext-Code auf stabile CompetencyItem.Id umgestellt (TODO 16.5)
Unit/Lesson/ExamTask/ParticipationSession referenzierten Kompetenzen bisher per Freitext-Code, case-insensitiv gegen den Katalog gematcht - fragil bei Umbenennungen und seit der Bildungsplan-Versionierung nicht mehr eindeutig (zwei Versionen können denselben Code vergeben). Neuer Werttyp CompetencyReference (ItemId + Code/Description-Momentaufnahme) löst das: solange die Id noch im Katalog auflösbar ist, zählt die live Fassung (Rename wirkt sofort), sonst bleibt die gespeicherte historische Fassung sichtbar statt spurlos zu verschwinden. Migration (Schema-Version 6) löst bestehende Codes gegen den Katalog auf; die zuvor dreifach duplizierte Kompetenz-Tag-UI ist jetzt in CompetencyTagGroupBuilder konsolidiert. add_lesson_competency/remove_lesson_competency nehmen jetzt itemId statt code und validieren gegen den Katalog (vorher ungeprüft). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f97edff2fe
commit
dc2f58c4dc
28 files changed
+691
-202
No files matched your search
@@ -586,7 +586,7 @@ public partial class UnitDialogViewModel : ObservableObject
|
||||
private readonly int _gradeLevel;
|
||||
private readonly Guid _competencyCatalogVersionId;
|
||||
private readonly Unit? _editingUnit;
|
||||
private readonly List<string> _competencyCodes;
|
||||
private readonly List<CompetencyReference> _competencyRefs;
|
||||
|
||||
[ObservableProperty] private string _title = "";
|
||||
[ObservableProperty] private string _startDateText = "";
|
||||
@@ -601,8 +601,8 @@ public partial class UnitDialogViewModel : ObservableObject
|
||||
|
||||
public string[] StatusOptions => UnitStatusDisplay.Options;
|
||||
public ObservableCollection<CompetencyTagGroup> CompetencyTagGroups { get; } = [];
|
||||
public string CompetencySummary => _competencyCodes.Count == 0
|
||||
? "Keine Kompetenzen" : $"{_competencyCodes.Count} Kompetenz(en)";
|
||||
public string CompetencySummary => _competencyRefs.Count == 0
|
||||
? "Keine Kompetenzen" : $"{_competencyRefs.Count} Kompetenz(en)";
|
||||
|
||||
/// Gruppe + Fach kommen von der Lerngruppe, nicht editierbar (jede Gruppe unterrichtet ein
|
||||
/// Fach) — beide zusammen zeigen, da dieselbe Klasse in mehreren Fächern (mehrere
|
||||
@@ -638,7 +638,7 @@ public partial class UnitDialogViewModel : ObservableObject
|
||||
GroupSubjectDisplay = string.IsNullOrWhiteSpace(subjectName)
|
||||
? $"{groupName} · kein Fach hinterlegt (siehe Lerngruppe)" : $"{groupName} · {subjectName}";
|
||||
|
||||
_competencyCodes = editingUnit is not null ? [.. editingUnit.Competencies] : [];
|
||||
_competencyRefs = editingUnit is not null ? [.. editingUnit.Competencies] : [];
|
||||
BuildCompetencyTagGroups();
|
||||
|
||||
if (editingUnit is not null)
|
||||
@@ -655,24 +655,22 @@ public partial class UnitDialogViewModel : ObservableObject
|
||||
{
|
||||
CompetencyTagGroups.Clear();
|
||||
if (!_subjectId.HasValue) return;
|
||||
var selected = _competencyCodes.ToHashSet();
|
||||
foreach (var domain in _competencyDomains.GetBySubjectAndGrade(_subjectId.Value, _gradeLevel, _competencyCatalogVersionId))
|
||||
{
|
||||
var group = new CompetencyTagGroup(domain.Name, domain.Code);
|
||||
foreach (var item in domain.Items.OrderBy(i => i.SortOrder))
|
||||
{
|
||||
var tag = new CompetencyTag(item.Code, item.Description, selected.Contains(item.Code));
|
||||
tag.OnChanged = OnCompetencyToggled;
|
||||
group.Items.Add(tag);
|
||||
}
|
||||
if (group.Items.Count > 0) CompetencyTagGroups.Add(group);
|
||||
}
|
||||
var catalog = _competencyDomains.GetBySubjectAndGrade(_subjectId.Value, _gradeLevel, _competencyCatalogVersionId);
|
||||
foreach (var group in CompetencyTagGroupBuilder.Build(catalog, _competencyRefs, OnCompetencyToggled))
|
||||
CompetencyTagGroups.Add(group);
|
||||
}
|
||||
|
||||
private void OnCompetencyToggled(string code, bool selected)
|
||||
private void OnCompetencyToggled(CompetencyTag tag)
|
||||
{
|
||||
if (selected) { if (!_competencyCodes.Contains(code)) _competencyCodes.Add(code); }
|
||||
else _competencyCodes.Remove(code);
|
||||
if (tag.IsSelected)
|
||||
{
|
||||
if (!_competencyRefs.Any(r => r.ItemId == tag.ItemId))
|
||||
_competencyRefs.Add(new CompetencyReference { ItemId = tag.ItemId, Code = tag.Code, Description = tag.Description });
|
||||
}
|
||||
else
|
||||
{
|
||||
_competencyRefs.RemoveAll(r => r.ItemId == tag.ItemId);
|
||||
}
|
||||
OnPropertyChanged(nameof(CompetencySummary));
|
||||
}
|
||||
|
||||
@@ -713,7 +711,7 @@ public partial class UnitDialogViewModel : ObservableObject
|
||||
Result.EndDate = endDate;
|
||||
Result.Status = UnitStatusDisplay.FromName(StatusName);
|
||||
Result.Notes = string.IsNullOrWhiteSpace(Notes) ? null : Notes.Trim();
|
||||
Result.Competencies = _competencyCodes;
|
||||
Result.Competencies = _competencyRefs;
|
||||
if (Result.Status == UnitStatus.Active)
|
||||
{
|
||||
// Pro Lerngruppe gibt es genau einen aktuellen Arbeitskontext. Frühere laufende
|
||||
|
||||
Reference in new issue
Block a user