Schüler hinzufügen, Kompetenzen

This commit is contained in:
2026-06-23 13:46:39 +02:00
parent b2211270b4
commit 220969fdfa
23 changed files with 1230 additions and 88 deletions
@@ -21,6 +21,11 @@ public partial class ParticipationTabView : UserControl
vm.OnAddSession = ShowAddSessionDialog;
vm.OnQuickInput = ShowQuickInputDialog;
vm.Aspects.CollectionChanged += (_, _) => BuildColumns();
vm.PropertyChanged += (_, pe) =>
{
if (pe.PropertyName == nameof(ParticipationTabViewModel.RebuildColumnsSignal))
BuildColumns();
};
BuildColumns();
}
}
@@ -39,25 +44,43 @@ public partial class ParticipationTabView : UserControl
Width = new DataGridLength(160, DataGridLengthUnitType.Pixel),
});
// Aspekt-Spalten
foreach (var (aspect, i) in _vm.Aspects.Select((a, i) => (a, i)))
{
var capturedIndex = i;
var idx = i;
grid.Columns.Add(new DataGridTemplateColumn
{
Header = $"{aspect.Label} [{AspectShortcut(i)}]",
Width = new DataGridLength(1, DataGridLengthUnitType.Star),
CellTemplate = BuildCellTemplate(capturedIndex),
Header = $"{aspect.Label} [{AspectShortcut(i)}]",
Width = new DataGridLength(1, DataGridLengthUnitType.Star),
CellTemplate = BuildCellTemplate(idx, forCompetency: false),
});
}
// Kompetenz-Spalten (opt-in)
if (_vm.StudentCompetencyRatingsVisible && _vm.ActiveCompetencyCodes.Count > 0)
{
foreach (var (code, i) in _vm.ActiveCompetencyCodes.Select((c, i) => (c, i)))
{
var idx = i;
grid.Columns.Add(new DataGridTemplateColumn
{
Header = code,
Width = new DataGridLength(80, DataGridLengthUnitType.Pixel),
CellTemplate = BuildCellTemplate(idx, forCompetency: true),
});
}
}
}
private static IDataTemplate BuildCellTemplate(int aspectIndex)
private static IDataTemplate BuildCellTemplate(int cellIndex, bool forCompetency)
{
return new FuncDataTemplate<ParticipationStudentRow>((row, _) =>
{
if (row is null) return new TextBlock();
var cell = row.Cells.ElementAtOrDefault(aspectIndex);
var cell = forCompetency
? row.CompetencyCells.ElementAtOrDefault(cellIndex)
: row.Cells.ElementAtOrDefault(cellIndex);
if (cell is null) return new TextBlock();
var panel = new StackPanel
@@ -73,10 +96,10 @@ public partial class ParticipationTabView : UserControl
{
var btn = new Button
{
Content = label,
Padding = new Avalonia.Thickness(5, 1),
Content = label,
Padding = new Avalonia.Thickness(5, 1),
FontSize = 11,
Opacity = cell.Value == val ? 1.0 : 0.3,
Opacity = cell.Value == val ? 1.0 : 0.3,
};
var capturedVal = val;
btn.Click += (_, _) => cell.SetValue(capturedVal);