Schülerberichte und erweiterte Deckblatt-Bausteine ergänzen
CI / build-and-test (push) Canceled after 0s
CI / build-and-test (push) Canceled after 0s
This commit is contained in:
1 parent
336869e75f
commit
e2f019667a
31 files changed
+961
-14
No files matched your search
@@ -21,6 +21,17 @@ public partial class ExamCoverSheetDialogViewModel : ObservableObject
|
||||
private readonly GradingService _grading;
|
||||
private readonly TemplateStore _loader;
|
||||
private readonly ITemplateBatchRenderer _renderer;
|
||||
private readonly Exam? _original;
|
||||
private readonly Dictionary<Guid, ExamResult> _originalResults;
|
||||
[ObservableProperty] private ReportInterimRunChoice? _selectedInterimRun;
|
||||
[ObservableProperty] private bool _usesInterimGrades;
|
||||
public ObservableCollection<ReportInterimRunChoice> InterimRuns { get; } = [];
|
||||
|
||||
partial void OnSelectedTemplateChanged(LetterTemplateChoice? value)
|
||||
{
|
||||
UsesInterimGrades = value is not null &&
|
||||
DrawingBoxLocator.Find(_loader.Load(value.Model), ReportTextDrawing.InterimGrades) is not null;
|
||||
}
|
||||
|
||||
[ObservableProperty] private LetterTemplateChoice? _selectedTemplate;
|
||||
[ObservableProperty] private bool _fillResults;
|
||||
@@ -50,12 +61,19 @@ public partial class ExamCoverSheetDialogViewModel : ObservableObject
|
||||
public ExamCoverSheetDialogViewModel(Exam exam, LearningGroup group, string subjectName,
|
||||
IStudentRepository students, IGroupMembershipRepository memberships, IExamResultRepository results,
|
||||
GradingService grading, IReadOnlyList<TemplateStore> templateStores, ITemplateBatchRenderer renderer,
|
||||
string teacherAbbreviation = "")
|
||||
string teacherAbbreviation = "", IExamRepository? exams = null, IInterimGradeRepository? interims = null)
|
||||
{
|
||||
_teacherAbbreviation = teacherAbbreviation;
|
||||
_coverTitle = exam.Title;
|
||||
_exam = exam; _group = group; _subjectName = subjectName; _grading = grading; _renderer = renderer;
|
||||
_loader = templateStores[0];
|
||||
_original = exam.RepeatOfExamId is { } originalId ? exams?.GetById(originalId) : null;
|
||||
_originalResults = exam.RepeatOfExamId is { } firstId
|
||||
? results.GetByExam(firstId).ToDictionary(r => r.StudentId) : [];
|
||||
foreach (var run in (interims?.GetByGroup(group.Id) ?? [])
|
||||
.GroupBy(g => (g.Date, g.Occasion)).OrderByDescending(g => g.Key.Date).ThenBy(g => g.Key.Occasion))
|
||||
InterimRuns.Add(new(run.Key.Date, run.Key.Occasion, run.ToList()));
|
||||
// Bewusste Auswahl statt stillschweigend den neuesten Zwischenstand zu drucken.
|
||||
foreach (var template in templateStores.SelectMany(x => x.GetTemplates()).Where(x => x.IsExamCover)
|
||||
.DistinctBy(x => x.Id).OrderBy(x => x.Name, StringComparer.CurrentCultureIgnoreCase))
|
||||
Templates.Add(new(template));
|
||||
@@ -87,10 +105,20 @@ public partial class ExamCoverSheetDialogViewModel : ObservableObject
|
||||
try
|
||||
{
|
||||
var loaded = _loader.Load(SelectedTemplate.Model);
|
||||
if (UsesInterimGrades && SelectedInterimRun is null)
|
||||
{ StatusMessage = "Bitte einen gespeicherten Notenzwischenstand auswählen."; return false; }
|
||||
if (UsesInterimGrades)
|
||||
{
|
||||
var missing = included.Where(s => !SelectedInterimRun!.Grades.Any(g => g.StudentId == s.Model.Id)).ToList();
|
||||
if (missing.Count > 0)
|
||||
{ StatusMessage = "Im gewählten Zwischenstand fehlen: " + string.Join(", ", missing.Select(s => s.FullName)) + ". Bitte Schüler abwählen oder einen anderen Durchgang wählen."; return false; }
|
||||
}
|
||||
var today = DateOnly.FromDateTime(DateTime.Now);
|
||||
var data = included.Select(s => (ITemplateDataProvider)new LetterDataProvider(
|
||||
ExamCoverPlaceholderBuilder.Build(_exam, _group, _subjectName, s.Model, s.Result, FillResults,
|
||||
_grading, loaded, today, s.Niveau, TeacherAbbreviation, CoverTitle))).ToList();
|
||||
_grading, loaded, today, s.Niveau, TeacherAbbreviation, CoverTitle,
|
||||
_original, _originalResults.GetValueOrDefault(s.Model.Id),
|
||||
UsesInterimGrades ? SelectedInterimRun!.Grades.Single(g => g.StudentId == s.Model.Id) : null))).ToList();
|
||||
ReportProgress(0, included.Count);
|
||||
IsGenerating = true;
|
||||
var progress = new Progress<int>(done => ReportProgress(done, included.Count));
|
||||
@@ -110,7 +138,7 @@ public partial class ExamCoverSheetDialogViewModel : ObservableObject
|
||||
StatusMessage = message;
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or InvalidDataException or UnauthorizedAccessException or TemplateValidationException)
|
||||
catch (Exception ex) when (ex is IOException or InvalidDataException or UnauthorizedAccessException or TemplateValidationException or QuestPDF.Drawing.Exceptions.DocumentLayoutException)
|
||||
{ StatusMessage = $"Deckblätter konnten nicht erzeugt werden: {ex.Message}"; return false; }
|
||||
finally { IsGenerating = false; }
|
||||
}
|
||||
@@ -146,3 +174,8 @@ public partial class ExamCoverStudentChoice : ObservableObject
|
||||
_isIncluded = result is not { Absent: true };
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record ReportInterimRunChoice(DateOnly Date, string Occasion, IReadOnlyList<InterimGrade> Grades)
|
||||
{
|
||||
public string Label => $"{Date:dd.MM.yyyy} · {Occasion}";
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public partial class PersonalizeWorksheetDialogViewModel : ObservableObject
|
||||
IStudentRepository students, WorksheetTemplateStore templates, ITemplateRenderer renderer)
|
||||
{
|
||||
_group = group; _templates = templates; _renderer = renderer;
|
||||
foreach (var template in templates.Store.GetTemplates().Where(x => !x.IsExamCover)) Templates.Add(new(template));
|
||||
foreach (var template in templates.Store.GetTemplates().Where(x => !x.IsExamCover && !x.IsStudentReport)) Templates.Add(new(template));
|
||||
SelectedTemplate = Templates.FirstOrDefault();
|
||||
foreach (var id in studentIds)
|
||||
if (students.GetById(id) is { } student) Students.Add(new(student));
|
||||
|
||||
Reference in new issue
Block a user