Neuer Dialog ExamGradingDialog, erreichbar über "Punkte eingeben" im Klausuren-Tab (Button + Kontextmenü bei ausgewählter Klausur): - Eingaberaster: Schüler-Zeilen × Aufgaben-Spalten, Summe und Note live über GradingService.CalculateGrade() berechnet. - Tab bewegt sich nativ zur nächsten Zelle; Enter/Pfeil-Hoch/Pfeil-Runter springen zur gleichen Spalte in der Nachbarzeile (auch über noch nicht realisierte, virtualisierte Zeilen hinweg via ScrollIntoView). Komma oder Punkt als Dezimaltrennzeichen werden beide akzeptiert. - Abwesend-Checkbox (Note zeigt dann "abwesend") und Kommentarfeld pro Schüler. - Punkte außerhalb 0..Maximalpunkte werden rot markiert und bewusst nicht gespeichert; der zuletzt gültige Stand bleibt erhalten. - Autosave nach jeder Zelle, kein Speichern-Button nötig. Dabei nebenbei behoben: die Schülerliste berücksichtigt jetzt Enrollment- Zeiträume (H1/H2/Custom) relativ zum Klausurdatum, analog zur bereits bestehenden Logik im Mitarbeit-Tab, statt pauschal alle im Schuljahr eingeschriebenen Schüler zu zeigen. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
96 lines
3.8 KiB
C#
96 lines
3.8 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;
|
|
}
|
|
}
|
|
|
|
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 ?? "", 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);
|
|
}
|
|
}
|