Für Fächer mit Binnendifferenzierung (z.B. Mathematik E/G-Niveau, Förderniveau) innerhalb derselben Lerngruppe: - LearningGroup.IsDifferentiated: neue Checkbox in den Stammdaten, aktiviert die Niveau-Funktionen optional für Klassen und Kurse. - Enrollment.Niveau: Niveau-Zuordnung je Schüler innerhalb der Gruppe, editierbar über eine neue Spalte im Schüler-Tab (nur sichtbar bei differenzierter Gruppe). - Exam.Niveau: Klausuren können optional einem Niveau zugeordnet werden. Workflow nutzt die bestehende Duplizieren-Funktion (1.1.4): G-Klausur anlegen, für die E-Variante duplizieren und eigene Aufgaben/Punkte vergeben — Niveau wird beim Duplizieren bewusst zurückgesetzt, damit nicht versehentlich zwei gleiche entstehen. - Punkteeingabe und Auswertung filtern automatisch auf die Schüler mit passendem Niveau; Klausuren ohne Niveau-Zuordnung verhalten sich unverändert (gesamte Gruppe). Beide Dialoge zeigen das Niveau als Badge im Titel, die Klausurenliste als eigene Spalte. - Individuelle Förderklausuren (nur für einen Schüler) laufen pragmatisch über die bestehende Abwesend-Markierung der übrigen Schüler statt über eine eigene Pro-Schüler-Zuordnung. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
112 lines
4.5 KiB
C#
112 lines
4.5 KiB
C#
using Avalonia.Controls;
|
|
using LehrerApp.Core.Interfaces;
|
|
using LehrerApp.Core.Models;
|
|
using LehrerApp.Core.Services;
|
|
using LehrerApp.Desktop.ViewModels.Groups;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace LehrerApp.Desktop.Views.Groups;
|
|
|
|
public partial class GroupDetailView : UserControl
|
|
{
|
|
public GroupDetailView() => InitializeComponent();
|
|
|
|
protected override void OnDataContextChanged(EventArgs e)
|
|
{
|
|
base.OnDataContextChanged(e);
|
|
if (DataContext is GroupDetailViewModel vm)
|
|
{
|
|
vm.OnAddStudent = ShowAddStudentDialog;
|
|
vm.OnAddExam = ShowAddExamDialog;
|
|
vm.OnEditExam = ShowEditExamDialog;
|
|
vm.OnDuplicateExam = ShowDuplicateExamDialog;
|
|
vm.OnConfirmDeleteExam = ShowDeleteExamDialog;
|
|
vm.OnGradeExam = ShowGradeExamDialog;
|
|
vm.OnEvaluateExam = ShowEvaluateExamDialog;
|
|
}
|
|
}
|
|
|
|
private async Task<bool> ShowAddStudentDialog()
|
|
{
|
|
if (DataContext is not GroupDetailViewModel vm || vm.Group is null) return false;
|
|
|
|
var dialogVm = new AddStudentToGroupDialogViewModel(
|
|
App.Services.GetRequiredService<IStudentRepository>(),
|
|
App.Services.GetRequiredService<IEnrollmentRepository>(),
|
|
vm.Group.Id,
|
|
vm.Group.SchoolYear);
|
|
|
|
var dialog = new AddStudentToGroupDialog { DataContext = dialogVm };
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
if (owner is null) return false;
|
|
|
|
return await dialog.ShowDialog<bool>(owner);
|
|
}
|
|
|
|
private Task<bool> ShowAddExamDialog(Guid groupId) =>
|
|
ShowExamDialog(groupId, editingExam: null, duplicateSource: null);
|
|
|
|
private Task<bool> ShowEditExamDialog(Exam exam) =>
|
|
ShowExamDialog(exam.GroupId, editingExam: exam, duplicateSource: null);
|
|
|
|
private Task<bool> ShowDuplicateExamDialog(Exam exam) =>
|
|
ShowExamDialog(exam.GroupId, editingExam: null, duplicateSource: exam);
|
|
|
|
private async Task<bool> ShowExamDialog(Guid groupId, Exam? editingExam, Exam? duplicateSource)
|
|
{
|
|
if (DataContext is not GroupDetailViewModel vm || vm.Group is null) return false;
|
|
|
|
var dialogVm = new ExamDialogViewModel(
|
|
App.Services.GetRequiredService<IExamRepository>(),
|
|
App.Services.GetRequiredService<ICompetencyDomainRepository>(),
|
|
App.Services.GetRequiredService<IGradingKeyTemplateRepository>(),
|
|
App.Services.GetRequiredService<GradingService>(),
|
|
groupId, vm.Group.SubjectId, vm.Group.GradeLevel, vm.Group.GradingSystem,
|
|
vm.Group.Subject ?? "", vm.Group.IsDifferentiated, editingExam, duplicateSource);
|
|
|
|
var dialog = new ExamDialog { DataContext = dialogVm };
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
if (owner is null) return false;
|
|
|
|
return await dialog.ShowDialog<bool>(owner);
|
|
}
|
|
|
|
private async Task<bool> ShowDeleteExamDialog(ExamSummary exam)
|
|
{
|
|
var dialog = new DeleteExamDialog { DataContext = exam.Title };
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
return owner is not null && await dialog.ShowDialog<bool>(owner);
|
|
}
|
|
|
|
private async Task ShowGradeExamDialog(Exam exam)
|
|
{
|
|
if (DataContext is not GroupDetailViewModel vm || vm.Group is null) return;
|
|
|
|
var dialogVm = new ExamGradingDialogViewModel(
|
|
App.Services.GetRequiredService<IExamResultRepository>(),
|
|
App.Services.GetRequiredService<IStudentRepository>(),
|
|
App.Services.GetRequiredService<IEnrollmentRepository>(),
|
|
App.Services.GetRequiredService<GradingService>(),
|
|
exam, vm.Group.Id, vm.Group.SchoolYear);
|
|
|
|
var dialog = new ExamGradingDialog { DataContext = dialogVm };
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
if (owner is not null) await dialog.ShowDialog(owner);
|
|
}
|
|
|
|
private async Task ShowEvaluateExamDialog(Exam exam)
|
|
{
|
|
if (DataContext is not GroupDetailViewModel vm || vm.Group is null) return;
|
|
|
|
var dialogVm = new ExamEvaluationDialogViewModel(
|
|
App.Services.GetRequiredService<IExamRepository>(),
|
|
App.Services.GetRequiredService<IExamResultRepository>(),
|
|
App.Services.GetRequiredService<GradingService>(),
|
|
exam, vm.Group.GradingSystem);
|
|
|
|
var dialog = new ExamEvaluationDialog { DataContext = dialogVm };
|
|
var owner = TopLevel.GetTopLevel(this) as Window;
|
|
if (owner is not null) await dialog.ShowDialog(owner);
|
|
}
|
|
}
|