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
@@ -0,0 +1,91 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using LehrerApp.Core.Models;
|
||||
|
||||
namespace LehrerApp.Desktop.ViewModels.Groups;
|
||||
|
||||
// ── Kompetenz-Tags ──────────────────────────────────────────────────────────────
|
||||
//
|
||||
// Gemeinsame Toggle-UI für die drei Stellen, an denen Kompetenzen aus dem Katalog einem anderen
|
||||
// Objekt zugeordnet werden (Unterrichtseinheit, Klausuraufgabe, Mitarbeit-Sitzung) - vor der
|
||||
// Umstellung auf CompetencyItem.Id (TODO 16.5) war die Bau-Logik dreifach fast identisch
|
||||
// dupliziert, jetzt an einer Stelle.
|
||||
|
||||
public class CompetencyTagGroup(string name, string code)
|
||||
{
|
||||
public string Name { get; } = name;
|
||||
public string Code { get; } = code;
|
||||
public string DisplayName { get; } = string.IsNullOrEmpty(code) ? name : $"{name} ({code})";
|
||||
public List<CompetencyTag> Items { get; } = [];
|
||||
}
|
||||
|
||||
public partial class CompetencyTag : ObservableObject
|
||||
{
|
||||
public Guid ItemId { get; }
|
||||
public string Code { get; }
|
||||
public string Description { get; }
|
||||
public string Display { get; }
|
||||
|
||||
[ObservableProperty] private bool _isSelected;
|
||||
|
||||
/// <summary>Reicht die Tag-Instanz selbst durch, statt nur Id/Zustand - der Aufrufer liest
|
||||
/// Code/Description direkt vom Tag, ohne eine eigene Lookup-Tabelle führen zu müssen.</summary>
|
||||
public Action<CompetencyTag>? OnChanged { get; set; }
|
||||
|
||||
public CompetencyTag(Guid itemId, string code, string description, bool isSelected)
|
||||
{
|
||||
ItemId = itemId;
|
||||
Code = code;
|
||||
Description = description;
|
||||
Display = string.IsNullOrEmpty(code) ? description : $"[{code}] {description}";
|
||||
_isSelected = isSelected;
|
||||
}
|
||||
|
||||
partial void OnIsSelectedChanged(bool value) => OnChanged?.Invoke(this);
|
||||
}
|
||||
|
||||
public static class CompetencyTagGroupBuilder
|
||||
{
|
||||
/// <summary>Baut Tag-Gruppen aus dem aktuellen Katalog plus eine synthetische Gruppe "Nicht mehr
|
||||
/// im Katalog" für bereits zugeordnete Referenzen, deren ItemId im übergebenen Katalog nicht
|
||||
/// auflösbar ist (gelöscht, andere Bildungsplan-Version, oder nie aufgelöster Import) - zeigt
|
||||
/// deren gespeicherte Momentaufnahme, damit eine Zuordnung nie stillschweigend verschwindet
|
||||
/// (Kernanliegen von TODO 16.5). Tags der Katalog-Gruppen sind auf/abwählbar; Tags der
|
||||
/// "Nicht mehr im Katalog"-Gruppe sind immer bereits ausgewählt (es gibt keinen Katalogeintrag,
|
||||
/// dem man sie stattdessen zuordnen könnte) und lassen sich nur abwählen/entfernen.</summary>
|
||||
public static List<CompetencyTagGroup> Build(
|
||||
IReadOnlyList<CompetencyDomain> catalog, List<CompetencyReference> selected,
|
||||
Action<CompetencyTag> onChanged)
|
||||
{
|
||||
var groups = new List<CompetencyTagGroup>();
|
||||
var matchedIds = new HashSet<Guid>();
|
||||
|
||||
foreach (var domain in catalog.OrderBy(d => d.SortOrder))
|
||||
{
|
||||
var group = new CompetencyTagGroup(domain.Name, domain.Code);
|
||||
foreach (var item in domain.Items.OrderBy(i => i.SortOrder))
|
||||
{
|
||||
var isSelected = selected.Any(s => s.ItemId == item.Id);
|
||||
if (isSelected) matchedIds.Add(item.Id);
|
||||
group.Items.Add(new CompetencyTag(item.Id, item.Code, item.Description, isSelected)
|
||||
{
|
||||
OnChanged = onChanged,
|
||||
});
|
||||
}
|
||||
if (group.Items.Count > 0) groups.Add(group);
|
||||
}
|
||||
|
||||
var orphaned = selected.Where(s => !matchedIds.Contains(s.ItemId)).ToList();
|
||||
if (orphaned.Count > 0)
|
||||
{
|
||||
var group = new CompetencyTagGroup("Nicht mehr im Katalog", "");
|
||||
foreach (var reference in orphaned)
|
||||
group.Items.Add(new CompetencyTag(reference.ItemId, reference.Code, reference.Description, isSelected: true)
|
||||
{
|
||||
OnChanged = onChanged,
|
||||
});
|
||||
groups.Add(group);
|
||||
}
|
||||
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public partial class ExamDialogViewModel : ObservableObject
|
||||
// gerade eine andere Niveau-Variante (E/G/Förder) derselben Klausur anzulegen.
|
||||
SelectedNiveauName = isDuplicate ? "–" : NiveauDisplay.ToName(source.Niveau);
|
||||
foreach (var t in source.Tasks.OrderBy(t => t.Nr))
|
||||
AddTaskInternal(t.Title, t.MaxPoints, t.Weight, [.. t.CompetencyCodes]);
|
||||
AddTaskInternal(t.Title, t.MaxPoints, t.Weight, [.. t.Competencies]);
|
||||
UseWeighting = Tasks.Any(t => Math.Abs(t.Weight - 1.0) > 0.0001);
|
||||
foreach (var e in source.GradingKey.OrderByDescending(e => e.MinPercent))
|
||||
AddGradingKeyRowInternal(e.Grade, e.MinPercent);
|
||||
@@ -148,10 +148,10 @@ public partial class ExamDialogViewModel : ObservableObject
|
||||
RecomputeTotals();
|
||||
}
|
||||
|
||||
private void AddTaskInternal(string? title, double maxPoints, double weight, List<string> competencyCodes)
|
||||
private void AddTaskInternal(string? title, double maxPoints, double weight, List<CompetencyReference> competencies)
|
||||
{
|
||||
var item = new ExamTaskEditItem(title, maxPoints, weight, competencyCodes,
|
||||
BuildCompetencyTagGroups(competencyCodes))
|
||||
var item = new ExamTaskEditItem(title, maxPoints, weight, competencies,
|
||||
BuildCompetencyTagGroups(competencies))
|
||||
{
|
||||
OnChanged = RecomputeTotals,
|
||||
OnRemove = RemoveTask,
|
||||
@@ -162,19 +162,13 @@ public partial class ExamDialogViewModel : ObservableObject
|
||||
RenumberTasks();
|
||||
}
|
||||
|
||||
private List<CompetencyTagGroup> BuildCompetencyTagGroups(List<string> selectedCodes)
|
||||
private List<CompetencyTagGroup> BuildCompetencyTagGroups(List<CompetencyReference> selected)
|
||||
{
|
||||
var groups = new List<CompetencyTagGroup>();
|
||||
if (!_subjectId.HasValue) return groups;
|
||||
var selected = selectedCodes.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))
|
||||
group.Items.Add(new CompetencyTag(item.Code, item.Description, selected.Contains(item.Code)));
|
||||
if (group.Items.Count > 0) groups.Add(group);
|
||||
}
|
||||
return groups;
|
||||
if (!_subjectId.HasValue) return [];
|
||||
var catalog = _competencyDomains.GetBySubjectAndGrade(_subjectId.Value, _gradeLevel, _competencyCatalogVersionId);
|
||||
// onChanged wird hier bewusst nicht gesetzt (bleibt null) - ExamTaskEditItem verdrahtet
|
||||
// tag.OnChanged selbst auf seinen eigenen OnCompetencyToggled-Handler, siehe Konstruktor.
|
||||
return CompetencyTagGroupBuilder.Build(catalog, selected, _ => { });
|
||||
}
|
||||
|
||||
private void RemoveTask(ExamTaskEditItem item)
|
||||
@@ -368,12 +362,12 @@ public partial class ExamTaskEditItem : ObservableObject
|
||||
[ObservableProperty] private bool _isCompetencyPanelOpen;
|
||||
[ObservableProperty] private bool _showWeight;
|
||||
|
||||
public List<string> CompetencyCodes { get; }
|
||||
public List<CompetencyReference> Competencies { get; }
|
||||
public ObservableCollection<CompetencyTagGroup> CompetencyTagGroups { get; } = [];
|
||||
|
||||
public string CompetencySummary => CompetencyCodes.Count == 0
|
||||
public string CompetencySummary => Competencies.Count == 0
|
||||
? "Keine Kompetenzen"
|
||||
: $"{CompetencyCodes.Count} Kompetenz(en)";
|
||||
: $"{Competencies.Count} Kompetenz(en)";
|
||||
|
||||
public Action? OnChanged { get; set; }
|
||||
public Action<ExamTaskEditItem>? OnRemove { get; set; }
|
||||
@@ -381,12 +375,12 @@ public partial class ExamTaskEditItem : ObservableObject
|
||||
public Action<ExamTaskEditItem>? OnMoveDown { get; set; }
|
||||
|
||||
public ExamTaskEditItem(string? title, double maxPoints, double weight,
|
||||
List<string> competencyCodes, List<CompetencyTagGroup> tagGroups)
|
||||
List<CompetencyReference> competencies, List<CompetencyTagGroup> tagGroups)
|
||||
{
|
||||
_title = title ?? "";
|
||||
_maxPoints = maxPoints;
|
||||
_weight = weight;
|
||||
CompetencyCodes = competencyCodes;
|
||||
Competencies = competencies;
|
||||
foreach (var g in tagGroups)
|
||||
{
|
||||
foreach (var tag in g.Items) tag.OnChanged = OnCompetencyToggled;
|
||||
@@ -394,10 +388,17 @@ public partial class ExamTaskEditItem : ObservableObject
|
||||
}
|
||||
}
|
||||
|
||||
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 (!Competencies.Any(r => r.ItemId == tag.ItemId))
|
||||
Competencies.Add(new CompetencyReference { ItemId = tag.ItemId, Code = tag.Code, Description = tag.Description });
|
||||
}
|
||||
else
|
||||
{
|
||||
Competencies.RemoveAll(r => r.ItemId == tag.ItemId);
|
||||
}
|
||||
OnPropertyChanged(nameof(CompetencySummary));
|
||||
OnChanged?.Invoke();
|
||||
}
|
||||
@@ -415,6 +416,6 @@ public partial class ExamTaskEditItem : ObservableObject
|
||||
Title = string.IsNullOrWhiteSpace(Title) ? null : Title.Trim(),
|
||||
MaxPoints = MaxPoints,
|
||||
Weight = Weight,
|
||||
CompetencyCodes = CompetencyCodes,
|
||||
Competencies = Competencies,
|
||||
};
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public partial class ParticipationTabViewModel : ObservableObject
|
||||
[ObservableProperty] private bool _isReadOnly;
|
||||
|
||||
public string SelectedSessionDisplay => SelectedSession?.Display ?? "";
|
||||
public List<string> ActiveCompetencyCodes { get; private set; } = [];
|
||||
public List<CompetencyReference> ActiveCompetencies { get; private set; } = [];
|
||||
|
||||
public ObservableCollection<ParticipationSessionItem> Sessions { get; } = [];
|
||||
public ObservableCollection<ParticipationStudentRow> StudentRows { get; } = [];
|
||||
@@ -132,14 +132,14 @@ public partial class ParticipationTabViewModel : ObservableObject
|
||||
{
|
||||
StudentRows.Clear();
|
||||
CompetencyTagGroups.Clear();
|
||||
ActiveCompetencyCodes = [];
|
||||
ActiveCompetencies = [];
|
||||
QuickInputCommand.NotifyCanExecuteChanged();
|
||||
StatusQuickInputCommand.NotifyCanExecuteChanged();
|
||||
RebuildColumnsSignal++;
|
||||
return;
|
||||
}
|
||||
LoadCompetencyTags(value.Id); // sets ActiveCompetencyCodes first
|
||||
LoadGrid(value.Id); // uses ActiveCompetencyCodes, fires RebuildColumnsSignal++
|
||||
LoadCompetencyTags(value.Id); // sets ActiveCompetencies first
|
||||
LoadGrid(value.Id); // uses ActiveCompetencies, fires RebuildColumnsSignal++
|
||||
}
|
||||
|
||||
private void LoadGrid(Guid sessionId)
|
||||
@@ -159,7 +159,7 @@ public partial class ParticipationTabViewModel : ObservableObject
|
||||
|
||||
var entry = entries.FirstOrDefault(e => e.StudentId == s.Id)
|
||||
?? new ParticipationEntry { SessionId = sessionId, StudentId = s.Id };
|
||||
var row = new ParticipationStudentRow(s.Id, s.FullName, entry, Aspects.ToList(), ActiveCompetencyCodes);
|
||||
var row = new ParticipationStudentRow(s.Id, s.FullName, entry, Aspects.ToList(), ActiveCompetencies);
|
||||
row.OnRatingChanged = (sid, key, val) => SaveRating(sessionId, sid, key, val);
|
||||
row.OnCompetencyRatingChanged = (sid, code, val) => SaveCompetencyRating(sessionId, sid, code, val);
|
||||
row.HomeworkChangedCallback = (sid, val) => SaveHomework(sessionId, sid, val);
|
||||
@@ -237,35 +237,31 @@ public partial class ParticipationTabViewModel : ObservableObject
|
||||
{
|
||||
CompetencyTagGroups.Clear();
|
||||
var session = _sessions.GetById(sessionId);
|
||||
ActiveCompetencyCodes = session?.CompetencyCodes?.ToList() ?? [];
|
||||
ActiveCompetencies = session?.Competencies?.ToList() ?? [];
|
||||
|
||||
if (!_subjectId.HasValue) return;
|
||||
var active = ActiveCompetencyCodes.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, active.Contains(item.Code));
|
||||
tag.OnChanged = (code, sel) => OnTagToggled(code, sel);
|
||||
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, ActiveCompetencies, OnTagToggled))
|
||||
CompetencyTagGroups.Add(group);
|
||||
}
|
||||
|
||||
private void OnTagToggled(string code, bool selected)
|
||||
private void OnTagToggled(CompetencyTag tag)
|
||||
{
|
||||
if (SelectedSession is null) return;
|
||||
var session = _sessions.GetById(SelectedSession.Id);
|
||||
if (session is null) return;
|
||||
if (selected) { if (!session.CompetencyCodes.Contains(code)) session.CompetencyCodes.Add(code); }
|
||||
else { session.CompetencyCodes.Remove(code); }
|
||||
if (tag.IsSelected)
|
||||
{
|
||||
if (!session.Competencies.Any(r => r.ItemId == tag.ItemId))
|
||||
session.Competencies.Add(new CompetencyReference { ItemId = tag.ItemId, Code = tag.Code, Description = tag.Description });
|
||||
}
|
||||
else
|
||||
{
|
||||
session.Competencies.RemoveAll(r => r.ItemId == tag.ItemId);
|
||||
}
|
||||
_sessions.Save(session);
|
||||
|
||||
ActiveCompetencyCodes = session.CompetencyCodes.ToList();
|
||||
ActiveCompetencies = session.Competencies.ToList();
|
||||
if (StudentCompetencyRatingsVisible)
|
||||
LoadGrid(SelectedSession.Id); // reloads rows with updated cells, fires RebuildColumnsSignal++
|
||||
}
|
||||
@@ -369,22 +365,25 @@ public partial class ParticipationTabViewModel : ObservableObject
|
||||
_entries.Save(entry);
|
||||
}
|
||||
|
||||
private void SaveCompetencyRating(Guid sessionId, Guid studentId, string code, int? value)
|
||||
// "key" ist der Kompetenz-ItemId als String (siehe ParticipationStudentRow/RatingCell) - reiner
|
||||
// In-Memory-Transport zwischen Zelle und Save-Callback, nie persistiert.
|
||||
private void SaveCompetencyRating(Guid sessionId, Guid studentId, string key, int? value)
|
||||
{
|
||||
var itemId = Guid.Parse(key);
|
||||
var entry = _entries.GetBySessionAndStudent(sessionId, studentId)
|
||||
?? new ParticipationEntry
|
||||
{
|
||||
SessionId = sessionId,
|
||||
StudentId = studentId,
|
||||
};
|
||||
var existing = entry.CompetencyRatings.FirstOrDefault(r => r.Code == code);
|
||||
var existing = entry.CompetencyRatings.FirstOrDefault(r => r.ItemId == itemId);
|
||||
if (value is null)
|
||||
{
|
||||
if (existing is not null) entry.CompetencyRatings.Remove(existing);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existing is null) entry.CompetencyRatings.Add(new CompetencyRating { Code = code, Value = value.Value });
|
||||
if (existing is null) entry.CompetencyRatings.Add(new CompetencyRating { ItemId = itemId, Value = value.Value });
|
||||
else existing.Value = value.Value;
|
||||
}
|
||||
_entries.Save(entry);
|
||||
@@ -425,7 +424,7 @@ public partial class ParticipationStudentRow : ObservableObject
|
||||
public Action<Guid, DayHighlightKind?>? DayHighlightChangedCallback { get; set; }
|
||||
|
||||
public ParticipationStudentRow(Guid id, string name, ParticipationEntry entry,
|
||||
List<AspectColumnDef> aspects, List<string> competencyCodes)
|
||||
List<AspectColumnDef> aspects, List<CompetencyReference> competencies)
|
||||
{
|
||||
StudentId = id;
|
||||
Name = name;
|
||||
@@ -442,10 +441,12 @@ public partial class ParticipationStudentRow : ObservableObject
|
||||
Cells.Add(cell);
|
||||
}
|
||||
|
||||
foreach (var code in competencyCodes)
|
||||
// AspectKey trägt hier den Kompetenz-ItemId als String - reiner In-Memory-Transport
|
||||
// zwischen Zelle und Save-Callback (siehe SaveCompetencyRating), nie persistiert.
|
||||
foreach (var competency in competencies)
|
||||
{
|
||||
var existing = entry.CompetencyRatings.FirstOrDefault(r => r.Code == code);
|
||||
var cell = new RatingCell(id, code, existing?.Value);
|
||||
var existing = entry.CompetencyRatings.FirstOrDefault(r => r.ItemId == competency.ItemId);
|
||||
var cell = new RatingCell(id, competency.ItemId.ToString("D"), existing?.Value);
|
||||
cell.OnChanged = (sid, key, val) => OnCompetencyRatingChanged?.Invoke(sid, key, val);
|
||||
CompetencyCells.Add(cell);
|
||||
}
|
||||
@@ -726,37 +727,6 @@ public partial class RatingCell : ObservableObject
|
||||
private void UpdateLabel() => DisplayLabel = ParticipationRatingScale.DisplayLabel(Type, Value);
|
||||
}
|
||||
|
||||
// ── Kompetenz-Tags ────────────────────────────────────────────────────────────
|
||||
|
||||
public class CompetencyTagGroup(string name, string code)
|
||||
{
|
||||
public string Name { get; } = name;
|
||||
public string Code { get; } = code;
|
||||
public string DisplayName { get; } = string.IsNullOrEmpty(code) ? name : $"{name} ({code})";
|
||||
public List<CompetencyTag> Items { get; } = [];
|
||||
}
|
||||
|
||||
public partial class CompetencyTag : ObservableObject
|
||||
{
|
||||
public string Code { get; }
|
||||
public string Description { get; }
|
||||
public string Display { get; }
|
||||
|
||||
[ObservableProperty] private bool _isSelected;
|
||||
|
||||
public Action<string, bool>? OnChanged { get; set; }
|
||||
|
||||
public CompetencyTag(string code, string description, bool isSelected)
|
||||
{
|
||||
Code = code;
|
||||
Description = description;
|
||||
Display = string.IsNullOrEmpty(code) ? description : $"[{code}] {description}";
|
||||
_isSelected = isSelected;
|
||||
}
|
||||
|
||||
partial void OnIsSelectedChanged(bool value) => OnChanged?.Invoke(Code, value);
|
||||
}
|
||||
|
||||
// ── Hilfsklassen ──────────────────────────────────────────────────────────────
|
||||
|
||||
public class AspectColumnDef
|
||||
|
||||
@@ -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