权限修复

This commit is contained in:
2026-08-09 22:10:44 +08:00 Unverified
parent c26e082a77
commit d4abdd3db4
3 changed files with 48 additions and 0 deletions
@@ -151,6 +151,7 @@ public sealed class GradesController(
var task = await AccessibleTasks()
.Include(x => x.Teachers)
.ThenInclude(x => x.Teacher)
.FirstOrDefaultAsync(x => x.Id == request.TeachingTaskId, cancellationToken);
if (task is null) return NotFound();
if (task.Status is not (TeachingTaskStatus.Published or TeachingTaskStatus.Closed))
@@ -737,6 +737,7 @@ public sealed class MakeupExamsController(
.Include(x => x.Enrollments)
.Include(x => x.TeachingTask!)
.ThenInclude(x => x.Teachers)
.ThenInclude(x => x.Teacher)
.FirstOrDefaultAsync(x => x.Id == id, cancellationToken);
if (session is null) return NotFound();
if (session.MakeupExamPlan!.Status != MakeupExamPlanStatus.Published)
@@ -227,6 +227,7 @@ public sealed class TeachingWorkflowRosterTests
Assert.IsType<CreatedResult>(attendanceResult);
Assert.Equal(1, await db.AttendanceRecords.CountAsync());
db.ChangeTracker.Clear();
var grades = new GradesController(db, scope);
var gradeResult = await grades.CreateSheet(
new GradeSheetRequest(task.Id, 40, 60, []),
@@ -234,6 +235,51 @@ public sealed class TeachingWorkflowRosterTests
Assert.IsType<CreatedResult>(gradeResult);
Assert.Equal(1, await db.GradeRecords.CountAsync());
var makeupPlan = new MakeupExamPlan
{
AcademicTermId = term.Id,
Name = "补考成绩录入测试",
Status = MakeupExamPlanStatus.Published,
PublishedAt = DateTime.UtcNow
};
var makeupSession = new MakeupExamSession
{
MakeupExamPlanId = makeupPlan.Id,
TeachingTaskId = task.Id,
ExamDate = new DateOnly(2027, 2, 20),
StartPeriod = 1,
PeriodCount = 2,
StartsAt = new DateTime(2027, 2, 20, 8, 0, 0, DateTimeKind.Utc),
EndsAt = new DateTime(2027, 2, 20, 9, 50, 0, DateTimeKind.Utc),
Enrollments =
[
new MakeupExamEnrollment
{
StudentId = student.Id,
Reason = MakeupReason.Failed
}
]
};
makeupPlan.Sessions.Add(makeupSession);
db.MakeupExamPlans.Add(makeupPlan);
await db.SaveChangesAsync();
db.ChangeTracker.Clear();
var makeup = new MakeupExamsController(
db,
scope,
new MakeupExamEligibilityService(db));
Assert.IsType<NoContentResult>(await makeup.RecordScores(
makeupSession.Id,
[new RecordMakeupScoreRequest(student.Id, 75)],
CancellationToken.None));
Assert.Equal(
75,
await db.MakeupExamEnrollments
.Where(x => x.MakeupExamSessionId == makeupSession.Id)
.Select(x => x.MakeupScore)
.SingleAsync());
var selections = new CourseSelectionsController(db, scope);
Assert.Single(ReadItems(await selections.GetMyTeachingTasks(
term.Id,