- Bumped the wire protocol version to 6, reflecting changes in the communication structure.
- Expanded the timetable API with new endpoints for fetching and managing lesson schedules, including `GET /api/schools/{id}/timetable` and `POST /api/schools/{id}/timetable/pin`.
- Updated the protocol documentation to include detailed descriptions of the new timetable features and message structures.
- Enhanced the client-side implementation to support the new timetable functionalities, including lesson pinning and unpinning.
- Revised server-side logic to handle timetable operations and ensure proper integration with existing school management features.
- Added tests to validate the new timetable functionalities and ensure robustness in handling lesson data.
32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using HSchool.Content;
|
|
using HSchool.People;
|
|
using HSchool.Schedule;
|
|
|
|
namespace HSchool.Simulation;
|
|
|
|
/// <summary>Turns a school's roster into planner input and back. The worker calls this, not the tick.</summary>
|
|
public static class SchoolTimetables
|
|
{
|
|
public static Timetable Build(
|
|
DefCatalog catalog,
|
|
MapLayout map,
|
|
Roster roster,
|
|
IReadOnlyList<LessonPlacement>? locked,
|
|
int weekDays)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(catalog);
|
|
ArgumentNullException.ThrowIfNull(map);
|
|
ArgumentNullException.ThrowIfNull(roster);
|
|
|
|
var classes = roster.Classes
|
|
.Select(item => new PlannerClass(item.Id, item.Year, item.Letter, item.RoomId, item.PupilIds.Count))
|
|
.ToArray();
|
|
var teachers = roster.People
|
|
.Where(person => person.IsStaff && person.Subjects.Count > 0)
|
|
.Select(person => new PlannerTeacher(person.Id, person.Subjects))
|
|
.ToArray();
|
|
|
|
return TimetablePlanner.Build(catalog, map, classes, teachers, locked, weekDays);
|
|
}
|
|
}
|