Implement comprehensive academic workflow enhancements
This commit is contained in:
1 parent
b4e5663c28
commit
9f533ad02a
12 files changed
+7420
-13
No files matched your search
@@ -67,6 +67,14 @@ public sealed class AutomaticScheduleGeneratorTests
|
||||
WHERE name = 'SchedulingMode'
|
||||
""")
|
||||
.AnyAsync(value => value > 0));
|
||||
Assert.True(await db.Database
|
||||
.SqlQueryRaw<int>(
|
||||
"""
|
||||
SELECT COUNT(*) AS "Value"
|
||||
FROM pragma_table_info('Classrooms')
|
||||
WHERE name = 'Floor'
|
||||
""")
|
||||
.AnyAsync(value => value > 0));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -502,4 +510,83 @@ public sealed class AutomaticScheduleGeneratorTests
|
||||
Assert.Equal(1, await db.Buildings.CountAsync());
|
||||
Assert.Equal(2, await db.Classrooms.CountAsync());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Generator_prefers_ground_floor_for_class_with_mobility_accessibility_need()
|
||||
{
|
||||
await using var connection = new SqliteConnection("Data Source=:memory:");
|
||||
await connection.OpenAsync();
|
||||
var options = new DbContextOptionsBuilder<AppDbContext>()
|
||||
.UseSqlite(connection)
|
||||
.Options;
|
||||
await using var db = new AppDbContext(options);
|
||||
await db.Database.EnsureCreatedAsync();
|
||||
|
||||
var term = new AcademicTerm
|
||||
{
|
||||
Code = "2026-A11Y", Name = "无障碍排课测试", AcademicYear = "2026-2027",
|
||||
Season = TermSeason.Autumn, StartDate = new DateOnly(2026, 9, 1),
|
||||
EndDate = new DateOnly(2027, 1, 15)
|
||||
};
|
||||
var college = new College { Code = "A11Y", Name = "无障碍学院" };
|
||||
var major = new Major
|
||||
{
|
||||
Code = "A11Y-M", Name = "无障碍专业", College = college,
|
||||
DegreeType = "本科", SchoolingYears = 4
|
||||
};
|
||||
var administrativeClass = new AdministrativeClass
|
||||
{
|
||||
Code = "A11Y-01", Name = "无障碍一班", Major = major, Grade = 2026
|
||||
};
|
||||
var student = new Student
|
||||
{
|
||||
StudentNumber = "A11Y-001", Name = "学生甲", AdministrativeClass = administrativeClass,
|
||||
EnrollmentYear = 2026, EnrollmentDate = new DateOnly(2026, 9, 1),
|
||||
SpecialTags = "肢体残疾,听力障碍"
|
||||
};
|
||||
var campus = new Campus { Code = "A11Y-C", Name = "无障碍校区" };
|
||||
var building = new Building { Code = "A11Y-B", Name = "无障碍教学楼", Campus = campus };
|
||||
var groundFloorRoom = new Classroom
|
||||
{
|
||||
Code = "A11Y-101", Name = "首层教室", Building = building, Capacity = 30, Floor = 1
|
||||
};
|
||||
var upperFloorRoom = new Classroom
|
||||
{
|
||||
Code = "A11Y-301", Name = "三层教室", Building = building, Capacity = 30, Floor = 3
|
||||
};
|
||||
var course = new Course
|
||||
{
|
||||
Code = "A11Y-COURSE", Name = "无障碍课程", College = college,
|
||||
Credits = 1, TotalHours = 2, LectureHours = 2
|
||||
};
|
||||
var task = new TeachingTask
|
||||
{
|
||||
TaskNumber = "A11Y-TASK", Name = "无障碍教学班", AcademicTerm = term,
|
||||
Course = course, Capacity = 1, StartWeek = 1, EndWeek = 1, WeeklyHours = 2,
|
||||
Status = TeachingTaskStatus.Published,
|
||||
Classes = [new TeachingTaskClass { AdministrativeClass = administrativeClass }]
|
||||
};
|
||||
var plan = new SchedulePlan { AcademicTerm = term, Name = "无障碍方案", Version = "V1" };
|
||||
db.AddRange(term, college, major, administrativeClass, student, campus, building,
|
||||
groundFloorRoom, upperFloorRoom, course, task, plan);
|
||||
db.ScheduleTimeSlots.AddRange(
|
||||
new ScheduleTimeSlot
|
||||
{
|
||||
AcademicTerm = term, PeriodNumber = 1, Name = "第 1 节",
|
||||
StartsAt = new TimeOnly(8, 0), EndsAt = new TimeOnly(8, 45)
|
||||
},
|
||||
new ScheduleTimeSlot
|
||||
{
|
||||
AcademicTerm = term, PeriodNumber = 2, Name = "第 2 节",
|
||||
StartsAt = new TimeOnly(8, 55), EndsAt = new TimeOnly(9, 40)
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
var result = await new AutomaticScheduleGenerator(db)
|
||||
.GenerateAsync(plan, CancellationToken.None);
|
||||
|
||||
var entry = Assert.Single(await db.ScheduleEntries.ToListAsync());
|
||||
Assert.Equal(1, result.CompletedTasks);
|
||||
Assert.Equal(groundFloorRoom.Id, entry.ClassroomId);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user