Klausurverwaltung: Anlegen, Bearbeiten, Duplizieren, Status, Aufgaben
Implementiert TODO 1.1 (Klausur anlegen/verwalten) und die dazu passenden Teile von 1.2 (Aufgabenstruktur), da beides im selben Dialog verwaltet wird: - ExamDialog: Klausur anlegen/bearbeiten/duplizieren mit Aufgaben-Editor (Nr./Titel/Maximalpunkte/Gewichtung, sortierbar), Gesamtpunkte-Anzeige mit Warnung bei 0 Punkten, und Kompetenz-Zuordnung je Aufgabe. - Klausuren-Tab: Kontextmenü und Toolbar für Bearbeiten/Duplizieren/ Löschen (mit Rückfrage), farbcodierte Status-Spalte, SplitButton für Statuswechsel (Klick = nächster Status, Dropdown = manuelles Setzen). - ExamRepository.Delete löscht zugehörige ExamResults kaskadierend. - Gewichtung ist standardmäßig ausgeblendet (Checkbox zum Einblenden), NumericUpDown-Felder ohne Spinner-Buttons wegen eines Layout-Bugs im Avalonia-Standardtemplate, der das interne Textfeld auf wenige Pixel schrumpfen ließ. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Avalonia.Controls;
|
||||
using LehrerApp.Core.Interfaces;
|
||||
using LehrerApp.Core.Models;
|
||||
using LehrerApp.Desktop.ViewModels.Groups;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
@@ -13,7 +14,13 @@ public partial class GroupDetailView : UserControl
|
||||
{
|
||||
base.OnDataContextChanged(e);
|
||||
if (DataContext is GroupDetailViewModel vm)
|
||||
vm.OnAddStudent = ShowAddStudentDialog;
|
||||
{
|
||||
vm.OnAddStudent = ShowAddStudentDialog;
|
||||
vm.OnAddExam = ShowAddExamDialog;
|
||||
vm.OnEditExam = ShowEditExamDialog;
|
||||
vm.OnDuplicateExam = ShowDuplicateExamDialog;
|
||||
vm.OnConfirmDeleteExam = ShowDeleteExamDialog;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> ShowAddStudentDialog()
|
||||
@@ -32,4 +39,37 @@ public partial class GroupDetailView : UserControl
|
||||
|
||||
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>(),
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user