教学点名强化

This commit is contained in:
2026-07-25 16:16:23 +08:00 Unverified
parent 2c6103d3ae
commit d02b0c56a1
10 changed files with 486 additions and 6 deletions
@@ -21,6 +21,7 @@ public sealed class GradesController(
SystemRoles.SuperAdmin + "," +
SystemRoles.AcademicAdmin + "," +
SystemRoles.CollegeAdmin + "," +
SystemRoles.Counselor + "," +
SystemRoles.Teacher;
private const string Reviewers =
@@ -587,6 +588,15 @@ public sealed class GradesController(
if (scope.Scope == DataScope.All) return source;
if (scope.Scope == DataScope.College)
return source.Where(x => x.Course!.CollegeId == scope.RestrictedCollegeId);
if (scope.IsInRole(SystemRoles.Counselor))
{
// Counselor sees grades for courses in their managed classes' college
var collegeIds = db.AdministrativeClasses
.Where(c => c.CounselorUserId == scope.UserId)
.Select(c => c.Major!.CollegeId)
.Distinct();
return source.Where(x => collegeIds.Contains(x.Course!.CollegeId));
}
if (scope.IsInRole(SystemRoles.Teacher))
return source.Where(x =>
x.Teachers.Any(item => item.Teacher!.UserId == scope.UserId));