授课资格:学院可直接选择本院教师、学期和课程并分配资格,服务端强制学院数据范围。[后端接口 (line 178)](/E:/jiaowu/src/Jiaowu.Api/Controllers/TeacherCourseApplicationsController.cs:178) · [页面 (line 151)](/E:/jiaowu/web/src/views/TeachingPreferencesView.vue:151) 学生培养方案:新增“我的培养方案”,展示学分进度及已完成、在读、重修中、未通过、待完成、未修读课程,并支持搜索筛选。[学生接口 (line 15)](/E:/jiaowu/src/Jiaowu.Api/Controllers/StudentCurriculumController.cs:15) · [学生页面 (line 88)](/E:/jiaowu/web/src/views/StudentCurriculumView.vue:88)
63 lines
2.0 KiB
C#
63 lines
2.0 KiB
C#
using Jiaowu.Api.Domain.Academic;
|
|
|
|
namespace Jiaowu.Api.Infrastructure.Graduation;
|
|
|
|
public enum StudentCourseProgressStatus
|
|
{
|
|
NotStarted = 1,
|
|
InProgress = 2,
|
|
Retaking = 3,
|
|
Completed = 4,
|
|
Failed = 5,
|
|
Pending = 6
|
|
}
|
|
|
|
public sealed record StudentCourseAttemptSnapshot(
|
|
decimal? TotalScore,
|
|
GradeExamStatus ExamStatus);
|
|
|
|
public sealed record StudentCourseProgressEvaluation(
|
|
StudentCourseProgressStatus Status,
|
|
bool HasPassedAttempt,
|
|
bool HasFailedAttempt);
|
|
|
|
public static class StudentCourseProgressRules
|
|
{
|
|
public static StudentCourseProgressEvaluation Evaluate(
|
|
IEnumerable<StudentCourseAttemptSnapshot> attempts,
|
|
bool isInProgress)
|
|
{
|
|
var attemptList = attempts.ToList();
|
|
var hasPassedAttempt = attemptList.Any(IsPassed);
|
|
var hasFailedAttempt = attemptList.Any(IsFailed);
|
|
var hasPendingAttempt = attemptList.Any(x =>
|
|
!IsPassed(x) &&
|
|
!IsFailed(x));
|
|
|
|
var status = hasPassedAttempt
|
|
? StudentCourseProgressStatus.Completed
|
|
: isInProgress && hasFailedAttempt
|
|
? StudentCourseProgressStatus.Retaking
|
|
: isInProgress
|
|
? StudentCourseProgressStatus.InProgress
|
|
: hasFailedAttempt
|
|
? StudentCourseProgressStatus.Failed
|
|
: hasPendingAttempt
|
|
? StudentCourseProgressStatus.Pending
|
|
: StudentCourseProgressStatus.NotStarted;
|
|
|
|
return new StudentCourseProgressEvaluation(
|
|
status,
|
|
hasPassedAttempt,
|
|
hasFailedAttempt);
|
|
}
|
|
|
|
public static bool IsPassed(StudentCourseAttemptSnapshot attempt) =>
|
|
attempt.ExamStatus == GradeExamStatus.Exempt ||
|
|
attempt.TotalScore is decimal score && score >= 60;
|
|
|
|
public static bool IsFailed(StudentCourseAttemptSnapshot attempt) =>
|
|
attempt.ExamStatus == GradeExamStatus.Absent ||
|
|
attempt.TotalScore is decimal score && score < 60;
|
|
}
|