考试按实际日期、周次和节次融入周/日/总视图,并用橙色“考试”卡片区分。

即使固定课表尚未发布,只要考试已发布,也能正常显示。
考试计划、考场、监考教师和日期都会显示。
Excel 导出同步包含考试安排。
This commit is contained in:
2026-07-28 14:16:24 +08:00 Unverified
parent 9a75589282
commit a61dacff1a
3 changed files with 139 additions and 38 deletions
@@ -25,9 +25,14 @@ public static class TimetableExcelExporter
sheet.Row(1).Height = 34;
sheet.Range("A2:H2").Merge();
var examSummary = timetable.ExamEntries.Count > 0
? $" · 已融入 {timetable.ExamEntries.Count} 场考试"
: "";
sheet.Cell("A2").Value = timetable.Plan is null
? "本学期暂无可用课表版本"
: $"版本:{timetable.Plan.Version} · 状态:{PlanStatus(timetable.Plan.Status)} · 导出时间:{DateTime.Now:yyyy-MM-dd HH:mm}";
? timetable.ExamEntries.Count > 0
? $"固定课表尚未发布{examSummary} · 导出时间:{DateTime.Now:yyyy-MM-dd HH:mm}"
: "本学期暂无可用课表版本"
: $"版本:{timetable.Plan.Version} · 状态:{PlanStatus(timetable.Plan.Status)}{examSummary} · 导出时间:{DateTime.Now:yyyy-MM-dd HH:mm}";
sheet.Cell("A2").Style
.Font.SetFontColor(XLColor.FromHtml("#52677A"))
.Fill.SetBackgroundColor(XLColor.FromHtml("#EFF3F6"));
@@ -48,8 +53,11 @@ public static class TimetableExcelExporter
}
sheet.Row(headerRow).Height = 26;
var timedEntries = timetable.Entries
.Concat(timetable.ExamEntries)
.ToArray();
var periods = timetable.Slots.Select(x => x.PeriodNumber)
.Concat(timetable.Entries.SelectMany(x =>
.Concat(timedEntries.SelectMany(x =>
Enumerable.Range(x.StartPeriod, x.PeriodCount)))
.Distinct()
.Order()
@@ -72,7 +80,7 @@ public static class TimetableExcelExporter
for (var day = 1; day <= 7; day++)
{
var entries = timetable.Entries
var entries = timedEntries
.Where(x =>
x.DayOfWeek == day &&
x.StartPeriod <= period &&
@@ -86,7 +94,8 @@ public static class TimetableExcelExporter
if (entries.Count > 0)
{
cell.Style
.Fill.SetBackgroundColor(XLColor.FromHtml("#E8F3F2"))
.Fill.SetBackgroundColor(XLColor.FromHtml(
entries.Any(x => x.IsExam) ? "#FFF1E8" : "#E8F3F2"))
.Font.SetFontColor(XLColor.FromHtml("#173F4C"));
}
}
@@ -138,10 +147,17 @@ public static class TimetableExcelExporter
}
private static string EntryText(TimetableEntryDto entry) =>
$"{entry.CourseName}\n" +
$"{string.Join('、', entry.TeacherNames)}\n" +
$"{Location(entry)}\n" +
$"{entry.StartWeek}-{entry.EndWeek} 周";
entry.IsExam
? $"【考试】{entry.CourseName}\n" +
$"{entry.ExamPlanName}\n" +
$"{string.Join('、', entry.TeacherNames)}\n" +
$"{Location(entry)}\n" +
$"{entry.ExamDate:yyyy-MM-dd} · 第 {entry.StartPeriod}-" +
$"{entry.StartPeriod + entry.PeriodCount - 1} 节"
: $"{entry.CourseName}\n" +
$"{string.Join('、', entry.TeacherNames)}\n" +
$"{Location(entry)}\n" +
$"{entry.StartWeek}-{entry.EndWeek} 周";
private static string Location(TimetableEntryDto entry) =>
string.Join(" · ", new[]