已完成“成绩管理与学业档案”模块:
教师批量录入平时、期中、期末成绩。 自动计算总评、绩点和及格状态。 支持缺考、缓考、免修。 教师提交 → 学院审核/退回 → 校级发布。 学生只能查看正式发布成绩。 自动统计平均分、完成度、及格率和加权 GPA。 SQLite 本地增量升级和 MySQL 正式迁移均已完成。 分级权限在前后端同时校验。
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using Jiaowu.Api.Domain.Academic;
|
||||
using Jiaowu.Api.Infrastructure.Grades;
|
||||
|
||||
namespace Jiaowu.Api.Tests;
|
||||
|
||||
public sealed class GradeCalculatorTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(30, 0, 70, true)]
|
||||
[InlineData(20, 20, 60, true)]
|
||||
[InlineData(30, 20, 40, false)]
|
||||
[InlineData(-10, 40, 70, false)]
|
||||
public void Weights_must_be_non_negative_and_total_one_hundred(
|
||||
decimal regular,
|
||||
decimal midterm,
|
||||
decimal final,
|
||||
bool expected)
|
||||
{
|
||||
Assert.Equal(
|
||||
expected,
|
||||
GradeCalculator.AreWeightsValid(regular, midterm, final));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Total_uses_configured_weights_and_one_decimal_rounding()
|
||||
{
|
||||
var total = GradeCalculator.CalculateTotal(
|
||||
83,
|
||||
null,
|
||||
91,
|
||||
30,
|
||||
0,
|
||||
70,
|
||||
GradeExamStatus.Normal);
|
||||
|
||||
Assert.Equal(88.6m, total);
|
||||
Assert.Equal(3.7m, GradeCalculator.CalculateGradePoint(total));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Missing_required_component_keeps_total_unresolved()
|
||||
{
|
||||
Assert.Null(GradeCalculator.CalculateTotal(
|
||||
83,
|
||||
null,
|
||||
null,
|
||||
30,
|
||||
0,
|
||||
70,
|
||||
GradeExamStatus.Normal));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(GradeExamStatus.Absent)]
|
||||
[InlineData(GradeExamStatus.Deferred)]
|
||||
[InlineData(GradeExamStatus.Exempt)]
|
||||
public void Exceptional_exam_status_has_no_numeric_total(GradeExamStatus status)
|
||||
{
|
||||
Assert.Null(GradeCalculator.CalculateTotal(90, null, 90, 30, 0, 70, status));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user