优化考试排考

This commit is contained in:
2026-07-27 19:31:19 +08:00 Unverified
parent 64decdab7e
commit c3e8a42641
14 changed files with 7013 additions and 272 deletions
@@ -41,7 +41,26 @@ public sealed class TeachingWorkflowRosterTests
NormalizedUserName = "202601001",
DisplayName = "周同学"
};
var college = new College { Code = "CS", Name = "计算机学院" };
var campus = new Campus { Code = "MAIN", Name = "主校区" };
var college = new College
{
Code = "CS",
Name = "计算机学院",
CampusId = campus.Id
};
var building = new Building
{
Code = "B01",
Name = "第一教学楼",
CampusId = campus.Id
};
var classroom = new Classroom
{
Code = "B01-101",
Name = "101",
BuildingId = building.Id,
Capacity = 60
};
var major = new Major
{
Code = "080901",
@@ -120,7 +139,10 @@ public sealed class TeachingWorkflowRosterTests
db.AddRange(
teacherUser,
studentUser,
campus,
college,
building,
classroom,
major,
administrativeClass,
student,
@@ -130,22 +152,57 @@ public sealed class TeachingWorkflowRosterTests
task);
await db.SaveChangesAsync();
var examSession = new ExamSession
{
TeachingTaskId = task.Id,
ExamDate = new DateOnly(2027, 1, 8),
StartPeriod = 1,
PeriodCount = 2,
StartsAt = new DateTime(2027, 1, 8, 8, 0, 0, DateTimeKind.Utc),
EndsAt = new DateTime(2027, 1, 8, 9, 50, 0, DateTimeKind.Utc),
RequiredInvigilatorCount = 1
};
var examPlan = new ExamPlan
{
AcademicTermId = term.Id,
Name = "期末考试",
Status = ExamPlanStatus.Published,
Sessions =
Status = ExamPlanStatus.Draft,
Sessions = [examSession],
Rooms =
[
new ExamSession
new ExamRoomAssignment
{
TeachingTaskId = task.Id,
CourseId = course.Id,
ClassroomId = classroom.Id,
ExamDate = new DateOnly(2027, 1, 8),
StartPeriod = 1,
PeriodCount = 2,
StartsAt = new DateTime(2027, 1, 8, 8, 0, 0, DateTimeKind.Utc),
EndsAt = new DateTime(2027, 1, 8, 9, 50, 0, DateTimeKind.Utc),
RequiredInvigilatorCount = 1
RequiredInvigilatorCount = 1,
SessionLinks =
[
new ExamRoomSession
{
ExamSessionId = examSession.Id
}
],
Seats =
[
new ExamSeatAssignment
{
ExamSessionId = examSession.Id,
StudentId = student.Id,
SeatNumber = 1
}
],
Invigilators =
[
new ExamRoomInvigilator
{
TeacherId = teacher.Id
}
]
}
]
};
@@ -195,10 +252,14 @@ public sealed class TeachingWorkflowRosterTests
managerScope,
new ExamArrangementService(db),
NoOpAppCache.Instance);
var publishResult = await exams.Publish(examPlan.Id, CancellationToken.None);
Assert.IsType<NoContentResult>(publishResult);
var planResult = Assert.IsType<OkObjectResult>(
await exams.GetPlan(examPlan.Id, CancellationToken.None));
var planSessions = ReadEnumerableProperty(planResult.Value!, "Sessions");
Assert.Equal(1, ReadIntProperty(planSessions.Single(), "StudentCount"));
Assert.Single(ReadEnumerableProperty(planSessions.Single(), "ExamRooms"));
var examSessionId = examPlan.Sessions.Single().Id;
var rosterResult = Assert.IsType<OkObjectResult>(
@@ -212,6 +273,13 @@ public sealed class TeachingWorkflowRosterTests
NoOpAppCache.Instance);
Assert.Single(ReadItems(
await studentExams.GetMySchedule(CancellationToken.None)));
var teacherExams = new ExamsController(
db,
scope,
new ExamArrangementService(db),
NoOpAppCache.Instance);
Assert.Single(ReadItems(
await teacherExams.GetMySchedule(CancellationToken.None)));
var exportResult = Assert.IsType<FileContentResult>(
await exams.ExportSignInSheets(examPlan.Id, CancellationToken.None));