Neben Wiederholung und Nachschreibarbeit gibt es im Arbeitsdialog die Art Förderarbeit (Exam.IsSupportWork). Sie darf am Tag der ersten Arbeit liegen, übernimmt dessen Datum als Vorschlag und ersetzt wie eine Nachschreibarbeit nur fehlende Noten. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
104 lines
4.1 KiB
C#
104 lines
4.1 KiB
C#
using LehrerApp.Core.Models;
|
|
using LehrerApp.Core.Services;
|
|
using Xunit;
|
|
|
|
namespace LehrerApp.Tests;
|
|
|
|
public class ExamCoverSheetServiceTests
|
|
{
|
|
[Fact]
|
|
public void Columns_BonusaufgabeHatKeineNummerUndZaehltNichtMit()
|
|
{
|
|
List<ExamTask> tasks =
|
|
[
|
|
new() { Nr = 1, MaxPoints = 5 },
|
|
new() { Nr = 2, MaxPoints = 3, IsBonus = true },
|
|
new() { Nr = 3, MaxPoints = 12 },
|
|
];
|
|
|
|
var columns = ExamCoverSheetService.Columns(tasks, ExamVariant.A, null);
|
|
|
|
Assert.Equal(["1", "", "2"], columns.Select(c => c.Number));
|
|
Assert.True(columns[1].IsBonus);
|
|
Assert.All(columns, c => Assert.Null(c.AchievedPoints));
|
|
}
|
|
|
|
[Fact]
|
|
public void Columns_NurAufgabenDerGeschriebenenFassung_MitPunktenAusDerGesamtreihenfolge()
|
|
{
|
|
List<ExamTask> tasks =
|
|
[
|
|
new() { Nr = 1, MaxPoints = 5 },
|
|
new() { Nr = 2, MaxPoints = 6, Variant = ExamVariant.A },
|
|
new() { Nr = 3, MaxPoints = 7, Variant = ExamVariant.B },
|
|
new() { Nr = 4, MaxPoints = 4 },
|
|
];
|
|
|
|
var columns = ExamCoverSheetService.Columns(tasks, ExamVariant.B, [4, 0, 6.5, 3]);
|
|
|
|
Assert.Equal(["1", "2", "3"], columns.Select(c => c.Number));
|
|
Assert.Equal([5, 7, 4], columns.Select(c => c.MaxPoints));
|
|
Assert.Equal([4, 6.5, 3], columns.Select(c => c.AchievedPoints!.Value));
|
|
}
|
|
|
|
[Fact]
|
|
public void IsCorrected_AbwesendOderLeer_GiltNichtAlsKorrigiert()
|
|
{
|
|
Assert.False(ExamCoverSheetService.IsCorrected(null));
|
|
Assert.False(ExamCoverSheetService.IsCorrected(new ExamResult()));
|
|
Assert.False(ExamCoverSheetService.IsCorrected(new ExamResult { Absent = true, Points = [1] }));
|
|
Assert.True(ExamCoverSheetService.IsCorrected(new ExamResult { Points = [1] }));
|
|
Assert.True(ExamCoverSheetService.IsCorrected(new ExamResult { Grade = "2" }));
|
|
}
|
|
|
|
[Fact]
|
|
public void Includes_NiveauKlausur_NurPassendesNiveau()
|
|
{
|
|
var exam = new Exam { Date = new DateOnly(2025, 12, 18), Niveau = Niveau.G };
|
|
|
|
Assert.True(ExamParticipantService.Includes(exam, new GroupMembership { Niveau = Niveau.G }, false, false));
|
|
Assert.False(ExamParticipantService.Includes(exam, new GroupMembership { Niveau = Niveau.E }, false, false));
|
|
}
|
|
|
|
[Fact]
|
|
public void Includes_Foerderarbeit_BlendetSchuelerMitNoteDerErstenArbeitAus()
|
|
{
|
|
var original = new Exam();
|
|
var support = new Exam { IsSupportWork = true, RepeatOfExamId = original.Id, Date = original.Date };
|
|
var wrote = Guid.NewGuid();
|
|
var supported = Guid.NewGuid();
|
|
List<ExamResult> originalResults =
|
|
[
|
|
new() { ExamId = original.Id, StudentId = wrote, Grade = "3" },
|
|
new() { ExamId = original.Id, StudentId = supported, Absent = true },
|
|
];
|
|
|
|
var wroteOriginal = ExamParticipantService.WroteOriginal(support, _ => originalResults);
|
|
|
|
Assert.Equal([wrote], wroteOriginal);
|
|
Assert.False(ExamParticipantService.Includes(support, null, false, wroteOriginal.Contains(wrote)));
|
|
Assert.True(ExamParticipantService.Includes(support, null, false, wroteOriginal.Contains(supported)));
|
|
}
|
|
|
|
[Fact]
|
|
public void Includes_Nachschreibarbeit_OhneErgebnisNurWerDieErsteArbeitVersaeumtHat()
|
|
{
|
|
var original = new Exam();
|
|
var makeUp = new Exam { IsMakeUp = true, RepeatOfExamId = original.Id };
|
|
var wrote = Guid.NewGuid();
|
|
var missed = Guid.NewGuid();
|
|
List<ExamResult> originalResults =
|
|
[
|
|
new() { ExamId = original.Id, StudentId = wrote, Grade = "3" },
|
|
new() { ExamId = original.Id, StudentId = missed, Absent = true },
|
|
];
|
|
|
|
var wroteOriginal = ExamParticipantService.WroteOriginal(makeUp, _ => originalResults);
|
|
|
|
Assert.Equal([wrote], wroteOriginal);
|
|
Assert.False(ExamParticipantService.Includes(makeUp, null, false, wroteOriginal.Contains(wrote)));
|
|
Assert.True(ExamParticipantService.Includes(makeUp, null, true, wroteOriginal.Contains(wrote)));
|
|
Assert.True(ExamParticipantService.Includes(makeUp, null, false, wroteOriginal.Contains(missed)));
|
|
}
|
|
}
|