成绩册导出修正-总分列后移

This commit is contained in:
2026-08-10 16:41:51 +08:00 Unverified
parent 9eb0916c3f
commit 720ff6ef1d
2 changed files with 25 additions and 8 deletions
@@ -1,3 +1,4 @@
using ClosedXML.Excel;
using Jiaowu.Api.Contracts;
using Jiaowu.Api.Controllers;
using Jiaowu.Api.Domain.Academic;
@@ -83,8 +84,12 @@ public sealed class GradesPaginationTests
var sheet = new GradeSheet
{
TeachingTaskId = tasks[0].Id,
RegularWeight = 30,
FinalWeight = 70,
RegularWeight = 20,
FinalWeight = 60,
Items =
[
new GradeItem { Name = "实验", Weight = 20, SortOrder = 0 }
],
Records = students.Select(student => new GradeRecord
{
StudentId = student.Id
@@ -129,6 +134,18 @@ public sealed class GradesPaginationTests
var secondSheet = secondDetail.Value!.GetType().GetProperty("Sheet")!
.GetValue(secondDetail.Value)!;
Assert.Single(ReadItems(secondSheet, "Records"));
var templateResult = Assert.IsType<FileContentResult>(
await controller.DownloadTemplate(sheet.Id, CancellationToken.None));
using var stream = new MemoryStream(templateResult.FileContents);
using var workbook = new XLWorkbook(stream);
var worksheet = workbook.Worksheet("成绩导入");
Assert.Equal(
["学号", "姓名", "班级", "平时成绩", "实验", "期末成绩", "总分(自动计算)", "考试状态", "备注"],
worksheet.Row(1).CellsUsed().Select(cell => cell.GetString()));
Assert.Contains("D2*20/100", worksheet.Cell("G2").FormulaA1);
Assert.Contains("E2*20/100", worksheet.Cell("G2").FormulaA1);
Assert.Contains("F2*60/100", worksheet.Cell("G2").FormulaA1);
}
private static int ReadInt(object value, string property) =>