Apply student status interruptions across teaching workflows
This commit is contained in:
1 parent
de8399d7de
commit
5ee8aedee1
25 files changed
+25358
-81
No files matched your search
@@ -4,6 +4,7 @@ using Jiaowu.Api.Domain.Identity;
|
||||
using Jiaowu.Api.Infrastructure.Auth;
|
||||
using Jiaowu.Api.Infrastructure.Graduation;
|
||||
using Jiaowu.Api.Infrastructure.Persistence;
|
||||
using Jiaowu.Api.Infrastructure.Teaching;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -472,20 +473,12 @@ public sealed class AcademicPlanningController(
|
||||
.GroupBy(x => x.CourseId)
|
||||
.Sum(group => group.Max(x => x.Credits));
|
||||
|
||||
var rosterTaskIds = TeachingTaskRosterQuery.TaskIdsForStudent(db, student.Id);
|
||||
var inProgressCourseIds = await db.TeachingTasks.AsNoTracking()
|
||||
.Where(task =>
|
||||
task.Status == TeachingTaskStatus.Published &&
|
||||
task.AcademicTerm!.IsCurrent &&
|
||||
student.Status == StudentStatus.Active &&
|
||||
!db.StudentStatusChangeCourseEffects.Any(effect => effect.StudentId == student.Id && effect.TeachingTaskId == task.Id) &&
|
||||
(task.Classes.Any(item =>
|
||||
item.AdministrativeClassId ==
|
||||
student.AdministrativeClassId) ||
|
||||
db.CourseEnrollments.Any(enrollment =>
|
||||
enrollment.StudentId == student.Id &&
|
||||
enrollment.Status == CourseEnrollmentStatus.Enrolled &&
|
||||
enrollment.CourseSelectionOffering!.TeachingTaskId ==
|
||||
task.Id)))
|
||||
rosterTaskIds.Contains(task.Id))
|
||||
.Select(x => x.CourseId)
|
||||
.Distinct()
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
@@ -69,6 +69,7 @@ public sealed class AttendanceController(
|
||||
item.AdministrativeClass.Major!.Name.Contains(classKeyword)));
|
||||
}
|
||||
var total = await tasks.CountAsync(cancellationToken);
|
||||
var interruptedPairs = TeachingTaskRosterQuery.InterruptedPairs(db);
|
||||
var result = await tasks
|
||||
.OrderBy(x => x.Course!.Code)
|
||||
.ThenBy(x => x.TaskNumber)
|
||||
@@ -89,6 +90,7 @@ public sealed class AttendanceController(
|
||||
student.AdministrativeClass!.CounselorUserId == scope.UserId) &&
|
||||
student.Status == StudentStatus.Active &&
|
||||
!db.StudentStatusChangeCourseEffects.Any(effect => effect.StudentId == student.Id && effect.TeachingTaskId == x.Id) &&
|
||||
!interruptedPairs.Any(pair => pair.StudentId == student.Id && pair.TeachingTaskId == x.Id) &&
|
||||
(x.Classes.Any(assignment =>
|
||||
assignment.AdministrativeClassId ==
|
||||
student.AdministrativeClassId) ||
|
||||
|
||||
@@ -825,8 +825,8 @@ public sealed class CourseSelectionsController(
|
||||
.ToListAsync(cancellationToken);
|
||||
if (students.Count != studentIds.Length)
|
||||
return ValidationProblem("存在无效的学生档案。");
|
||||
if (await db.StudentStatusChangeCourseEffects.AnyAsync(x =>
|
||||
studentIds.Contains(x.StudentId) && x.TeachingTaskId == task.Id, cancellationToken))
|
||||
if (await TeachingTaskRosterQuery.BlockedStudentIdsForTask(db, task.Id)
|
||||
.AnyAsync(studentId => studentIds.Contains(studentId), cancellationToken))
|
||||
return ConflictProblem("部分学生已因学籍异动退出该教学班,不能重新选入。");
|
||||
var inactive = students.FirstOrDefault(x => x.Status != StudentStatus.Active);
|
||||
if (inactive is not null)
|
||||
@@ -1032,8 +1032,8 @@ public sealed class CourseSelectionsController(
|
||||
return ValidationProblem("存在无效的学生档案。");
|
||||
if (students.Any(x => x.Status != StudentStatus.Active))
|
||||
return ConflictProblem("只有在籍学生可以办理强制选课。");
|
||||
if (await db.StudentStatusChangeCourseEffects.AnyAsync(x =>
|
||||
studentIds.Contains(x.StudentId) && x.TeachingTaskId == task.Id, cancellationToken))
|
||||
if (await TeachingTaskRosterQuery.BlockedStudentIdsForTask(db, task.Id)
|
||||
.AnyAsync(studentId => studentIds.Contains(studentId), cancellationToken))
|
||||
return ConflictProblem("部分学生已因学籍异动退出该教学班,不能重新选入。");
|
||||
|
||||
var existingEnrollments = await db.CourseEnrollments
|
||||
@@ -1426,8 +1426,8 @@ public sealed class CourseSelectionsController(
|
||||
if (offering is null) return NotFound();
|
||||
var round = offering.CourseSelectionRound!;
|
||||
var task = offering.TeachingTask!;
|
||||
if (await db.StudentStatusChangeCourseEffects.AnyAsync(x =>
|
||||
x.StudentId == student.Id && x.TeachingTaskId == task.Id, cancellationToken))
|
||||
if (await TeachingTaskRosterQuery.BlockedStudentIdsForTask(db, task.Id)
|
||||
.ContainsAsync(student.Id, cancellationToken))
|
||||
return ConflictProblem("该教学班已因学籍异动退出,请选择其他教学班。");
|
||||
var now = DateTime.UtcNow;
|
||||
if (!CourseSelectionRules.IsSelectionOpen(round, now))
|
||||
@@ -1801,6 +1801,7 @@ public sealed class CourseSelectionsController(
|
||||
if (academicTermId.HasValue)
|
||||
source = source.Where(x => x.AcademicTermId == academicTermId);
|
||||
|
||||
var interruptedPairs = TeachingTaskRosterQuery.InterruptedPairs(db);
|
||||
return Ok(await source
|
||||
.OrderByDescending(x => x.AcademicTerm!.StartDate)
|
||||
.ThenBy(x => x.Course!.Code)
|
||||
@@ -1818,6 +1819,7 @@ public sealed class CourseSelectionsController(
|
||||
StudentCount = db.Students.Count(student =>
|
||||
student.Status == StudentStatus.Active &&
|
||||
!db.StudentStatusChangeCourseEffects.Any(effect => effect.StudentId == student.Id && effect.TeachingTaskId == x.Id) &&
|
||||
!interruptedPairs.Any(pair => pair.StudentId == student.Id && pair.TeachingTaskId == x.Id) &&
|
||||
(x.Classes.Any(assignment =>
|
||||
assignment.AdministrativeClassId ==
|
||||
student.AdministrativeClassId) ||
|
||||
@@ -2154,8 +2156,8 @@ public sealed class CourseSelectionsController(
|
||||
var task = offering.TeachingTask!;
|
||||
if (student.Status != StudentStatus.Active)
|
||||
return new(false, "只有在籍学生可以选课或候补。");
|
||||
if (await db.StudentStatusChangeCourseEffects.AnyAsync(x =>
|
||||
x.StudentId == student.Id && x.TeachingTaskId == task.Id, cancellationToken))
|
||||
if (await TeachingTaskRosterQuery.BlockedStudentIdsForTask(db, task.Id)
|
||||
.ContainsAsync(student.Id, cancellationToken))
|
||||
return new(false, "该教学班已因学籍异动退出,请选择其他教学班。");
|
||||
if (task.Status != TeachingTaskStatus.Published)
|
||||
return new(false, "该教学班当前不可选。");
|
||||
|
||||
Loaded 3 of 25 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user