Show scoped military retention deadlines

This commit is contained in:
biss committed 2026-11-08 16:22:08 +08:00
1 parent 9c8c504d98
commit 78b7af8ccc
5 files changed
+78 -5

No files matched your search

@@ -112,6 +112,39 @@ public sealed class StudentStatusChangesController(
.ToListAsync(token));
}
[HttpGet("discharge-deadlines")]
[Authorize(Roles = SystemRoles.Counselor + "," + SystemRoles.CollegeAdmin + "," + SystemRoles.AcademicAdmin + "," + SystemRoles.SuperAdmin)]
public async Task<ActionResult> GetDischargeDeadlines(CancellationToken token)
{
var students = ScopedStudents().Where(x => !x.IsArchived && x.Status == StudentStatus.Retained);
var reports = await db.StudentMilitaryDischargeReports.AsNoTracking()
.Where(report => students.Any(student => student.Id == report.StudentId) &&
db.StudentStatusChanges.Where(change => change.StudentId == report.StudentId &&
change.Type == StudentStatusChangeType.Enlistment && change.State == StudentStatusChangeState.Approved)
.OrderByDescending(change => change.ApprovedAt).ThenByDescending(change => change.Id)
.Select(change => change.Id).FirstOrDefault() == report.EnlistmentChangeId &&
db.StudentMilitaryDischargeReports.Where(other => other.StudentId == report.StudentId &&
other.EnlistmentChangeId == report.EnlistmentChangeId)
.OrderByDescending(other => other.ReportedAt).ThenByDescending(other => other.Id)
.Select(other => other.Id).FirstOrDefault() == report.Id)
.OrderBy(report => report.DischargeDate).ThenBy(report => report.StudentId)
.Take(100)
.Select(report => new
{
report.StudentId, report.DischargeDate, report.ReportedAt,
StudentNumber = db.Students.Where(student => student.Id == report.StudentId).Select(student => student.StudentNumber).FirstOrDefault(),
StudentName = db.Students.Where(student => student.Id == report.StudentId).Select(student => student.Name).FirstOrDefault(),
ClassName = db.Students.Where(student => student.Id == report.StudentId).Select(student => student.AdministrativeClass!.Name).FirstOrDefault()
}).ToListAsync(token);
var today = DateOnly.FromDateTime(DateTime.UtcNow);
return Ok(reports.Select(report => new
{
report.StudentId, report.StudentNumber, report.StudentName, report.ClassName, report.DischargeDate,
report.ReportedAt, RetainedUntil = report.DischargeDate.AddYears(2),
DaysRemaining = report.DischargeDate.AddYears(2).DayNumber - today.DayNumber
}));
}
[HttpGet("students/{studentId:guid}/options")]
[Authorize(Roles = SystemRoles.Counselor + "," + SystemRoles.CollegeAdmin + "," + SystemRoles.AcademicAdmin + "," + SystemRoles.SuperAdmin)]
public async Task<ActionResult> GetStudentOptions(Guid studentId, CancellationToken token)
@@ -672,8 +672,20 @@ public sealed class ApprovalsControllerTests
var scope = new CollegeDataScope(fixture.CurrentCourse.CollegeId);
var authorized = new StudentStatusChangesController(fixture.Db, scope);
Assert.IsType<CreatedResult>(await authorized.ReportStudentDischarge(fixture.Student.Id,
new StudentDischargeReportRequest(today, "代为登记"), CancellationToken.None));
Assert.Equal(scope.Current.UserId, (await fixture.Db.StudentMilitaryDischargeReports.SingleAsync()).ReportedByUserId);
new StudentDischargeReportRequest(today.AddDays(-1), "代为登记"), CancellationToken.None));
Assert.IsType<CreatedResult>(await authorized.ReportStudentDischarge(fixture.Student.Id,
new StudentDischargeReportRequest(today, "更正登记"), CancellationToken.None));
Assert.All(await fixture.Db.StudentMilitaryDischargeReports.ToListAsync(), report => Assert.Equal(scope.Current.UserId, report.ReportedByUserId));
var deadlines = Assert.IsType<OkObjectResult>(await authorized.GetDischargeDeadlines(CancellationToken.None));
using var deadlineJson = System.Text.Json.JsonDocument.Parse(System.Text.Json.JsonSerializer.Serialize(deadlines.Value,
new System.Text.Json.JsonSerializerOptions(System.Text.Json.JsonSerializerDefaults.Web)));
Assert.Equal(1, deadlineJson.RootElement.GetArrayLength());
Assert.Equal(fixture.Student.Id, deadlineJson.RootElement[0].GetProperty("studentId").GetGuid());
Assert.Equal(today.ToString("yyyy-MM-dd"), deadlineJson.RootElement[0].GetProperty("dischargeDate").GetString());
var otherDeadlines = Assert.IsType<OkObjectResult>(await outsider.GetDischargeDeadlines(CancellationToken.None));
using var otherJson = System.Text.Json.JsonDocument.Parse(System.Text.Json.JsonSerializer.Serialize(otherDeadlines.Value,
new System.Text.Json.JsonSerializerOptions(System.Text.Json.JsonSerializerDefaults.Web)));
Assert.Equal(0, otherJson.RootElement.GetArrayLength());
}
[Fact]
+1 -1
View File
@@ -246,7 +246,7 @@ export default {
teachingPreferences: {
teacherTitle: 'Teaching course applications', reviewerTitle: 'Teaching eligibility review', teacherDescription: 'Apply for courses you are willing to teach before scheduling. College approval is required before public-course teaching tasks can be assigned.', reviewerDescription: 'Review teacher applications or assign teachers directly. Approved teachers enter the eligible pool for the selected term and course.', apply: 'Apply for course', assign: 'Assign teacher directly', teacher: 'Teacher', selectTermSubject: 'Select term and course', college: 'College', reviewAssign: 'Review or assign directly', academicOffice: 'Academic affairs', mergeAssign: 'Merge classes and assign teacher', scheduling: 'Scheduling', generateTimetable: 'Generate timetable', allTerms: 'All terms', allStatuses: 'All statuses', refresh: 'Refresh', total: '{count} records', applicant: 'Applicant', course: 'Applied course', term: 'Term', statement: 'Application statement', status: 'Status', reviewComment: 'Review comment', actions: 'Actions', withdraw: 'Withdraw', review: 'Review', processed: 'Processed', emptyTeacher: 'No teaching course applications', emptyReviewer: 'No applications awaiting review', submitTitle: 'Apply for a teaching course', proposedCourse: 'Proposed course', statementPlaceholder: 'Describe relevant teaching experience, research interests, or other context', cancel: 'Cancel', submitReview: 'Submit for college review', reviewTitle: 'Review teaching eligibility', teacherStatement: 'Teacher statement', notProvided: 'Not provided', conclusion: 'Decision', approve: 'Approve', reject: 'Reject', confirmReview: 'Confirm review', assignmentTitle: 'Assign teaching eligibility directly', assignmentHint: 'No teacher application is required. Saving immediately grants eligibility for the selected term and course.', teacherPlaceholder: 'Select by employee number or name', courseLabel: 'Course', coursePlaceholder: 'Select by code or name', credits: '{count} credits', assignmentComment: 'Assignment note', assignmentPlaceholder: 'Enter department arrangements, specialization, or other basis', confirmAssign: 'Confirm assignment', statuses: { Pending: 'Pending review', Approved: 'Approved', Rejected: 'Rejected', Withdrawn: 'Withdrawn' }, messages: { selectTermCourse: 'Select a term and course.', submitted: 'Course application submitted for college review.', withdrawConfirm: 'Withdraw the teaching application for “{course}”?', withdrawTitle: 'Withdraw application', approved: 'Application approved.', rejected: 'Application rejected.', selectAll: 'Select a term, teacher, and course.', assigned: 'Teaching eligibility assigned directly.' },
},
statusChangeImpact: { dischargeReport: 'Report or correct discharge date', dischargeReportHint: 'This is a report for university verification. Corrections are retained; it does not automatically resume study or change status.', dischargeNotes: 'Report notes', reportedBy: 'Reported by', reportedAt: 'Reported at', recordDischarge: 'Save report', dischargeRecorded: 'Discharge date reported for university verification.', retentionUntil: 'Reference retention date based on the report: {date}; the university must verify it.', retentionReview: 'The retention date is approaching or needs review; contact the university promptly.', gradeWeights: 'Evaluation: {method} · Coursework weight: {regular}% · Final weight: {final}%', evaluation: { Percentage: 'Percentage', PassFail: 'Pass/fail', LetterGrade: 'Letter grade' }, viewArchivedGrades: 'View archived grades', noArchivedGrades: 'No unsubmitted grades were archived for this change.', archiveTime: 'Archived: {date} · Actor: {actor}', gradeSummary: 'Coursework: {regular} · Final: {final} · Total: {total} · Exam status: {exam}', gradeResult: 'Result: {result} · Passed: {passed} · Grade point: {point}', acknowledgeDraftArchive: 'I have reviewed the unsubmitted grades and approve archiving them before removing these courses.', proxyApply: 'Apply for a student', proxyStudent: 'Student', proxyStudentHint: 'Enter at least two characters of a student number or name', proxyStudentRequired: 'Select an eligible student without a pending application.', proxySubmitted: 'Submitted by staff', registryGuard: 'Use student status changes or record correction to change status or class.', correctionTitle: 'Correct a data entry error', correctionHint: 'Only for entry errors before the student or related classes have teaching, grade, exam or status-change records; the actor and reason are recorded.', correctionCurrent: 'Current: {status} · {className}', correctionStatus: 'Corrected status', correctionReason: 'Reason for correction (at least 10 characters)', correctionConfirm: 'Confirm correction', correctionRequired: 'Select a student, status and class, and enter a reason of at least 10 characters.', correctionSaved: 'Record correction saved.', catchUpFilter: 'Catch-up after status change', catchUpNeeded: 'Missed during a status change; catch-up needed (not a retake)', catchUpInProgress: 'Catch-up in progress (not a retake)', receivingPending: 'Receiving college review pending', receivingReviewed: 'Receiving college reviewed', receivingApprove: 'Receiving college approves', receivingReject: 'Receiving college rejects', majorTransferHint: 'Cross-college transfers require receiving-college review. Course recognition follows university rules.', classTransition: 'Class change', demotionTermHint: 'Incomplete classes exclusive to the original class are removed; shared classes and independent electives are kept.', resumptionTerm: 'Resumption term', resumptionTermHint: 'Takes effect upon approval; classes missed during leave are not automatically added.', serviceDate: 'Enlistment date', serviceDateRequired: 'Select the enlistment date', dischargeDate: 'Discharge date', dischargeDateRequired: 'Select the discharge date', retained: 'Status retained', targetClass: 'Target class', targetClassRequired: 'Select the target class', targetClassHint: 'Select an active class in the original major; a change of major requires separate approval.', affectedTerm: 'First affected term', affectedTermRequired: 'Select the first affected term', affectedTermHint: 'Incomplete courses from this term onward will be removed; valid results will be retained.', courseImpact: 'Course impact preview', courseImpactHint: 'The final review recalculates this list. Unpublished or exceptional results require prior review.', course: 'Teaching class', disposition: 'Disposition', impact: { Remove: 'Remove course', RemoveEmptyGrade: 'Remove course and empty grade row', ArchiveDraftGrade: 'Confirm archiving unsubmitted grade before removal', KeepGrade: 'Keep valid result', ReviewRequired: 'Review grade first' } },
statusChangeImpact: { deadlinesTitle: 'Discharge retention date review', deadlinesHint: 'Based on reported dates; shows the earliest 100 records in your scope. Reports and actual deadlines require university verification.', referenceDate: 'Reference date', deadlineState: 'Reminder', deadlineReview: 'Approaching or needs review', deadlineTracked: 'Reported', dischargeReport: 'Report or correct discharge date', dischargeReportHint: 'This is a report for university verification. Corrections are retained; it does not automatically resume study or change status.', dischargeNotes: 'Report notes', reportedBy: 'Reported by', reportedAt: 'Reported at', recordDischarge: 'Save report', dischargeRecorded: 'Discharge date reported for university verification.', retentionUntil: 'Reference retention date based on the report: {date}; the university must verify it.', retentionReview: 'The retention date is approaching or needs review; contact the university promptly.', gradeWeights: 'Evaluation: {method} · Coursework weight: {regular}% · Final weight: {final}%', evaluation: { Percentage: 'Percentage', PassFail: 'Pass/fail', LetterGrade: 'Letter grade' }, viewArchivedGrades: 'View archived grades', noArchivedGrades: 'No unsubmitted grades were archived for this change.', archiveTime: 'Archived: {date} · Actor: {actor}', gradeSummary: 'Coursework: {regular} · Final: {final} · Total: {total} · Exam status: {exam}', gradeResult: 'Result: {result} · Passed: {passed} · Grade point: {point}', acknowledgeDraftArchive: 'I have reviewed the unsubmitted grades and approve archiving them before removing these courses.', proxyApply: 'Apply for a student', proxyStudent: 'Student', proxyStudentHint: 'Enter at least two characters of a student number or name', proxyStudentRequired: 'Select an eligible student without a pending application.', proxySubmitted: 'Submitted by staff', registryGuard: 'Use student status changes or record correction to change status or class.', correctionTitle: 'Correct a data entry error', correctionHint: 'Only for entry errors before the student or related classes have teaching, grade, exam or status-change records; the actor and reason are recorded.', correctionCurrent: 'Current: {status} · {className}', correctionStatus: 'Corrected status', correctionReason: 'Reason for correction (at least 10 characters)', correctionConfirm: 'Confirm correction', correctionRequired: 'Select a student, status and class, and enter a reason of at least 10 characters.', correctionSaved: 'Record correction saved.', catchUpFilter: 'Catch-up after status change', catchUpNeeded: 'Missed during a status change; catch-up needed (not a retake)', catchUpInProgress: 'Catch-up in progress (not a retake)', receivingPending: 'Receiving college review pending', receivingReviewed: 'Receiving college reviewed', receivingApprove: 'Receiving college approves', receivingReject: 'Receiving college rejects', majorTransferHint: 'Cross-college transfers require receiving-college review. Course recognition follows university rules.', classTransition: 'Class change', demotionTermHint: 'Incomplete classes exclusive to the original class are removed; shared classes and independent electives are kept.', resumptionTerm: 'Resumption term', resumptionTermHint: 'Takes effect upon approval; classes missed during leave are not automatically added.', serviceDate: 'Enlistment date', serviceDateRequired: 'Select the enlistment date', dischargeDate: 'Discharge date', dischargeDateRequired: 'Select the discharge date', retained: 'Status retained', targetClass: 'Target class', targetClassRequired: 'Select the target class', targetClassHint: 'Select an active class in the original major; a change of major requires separate approval.', affectedTerm: 'First affected term', affectedTermRequired: 'Select the first affected term', affectedTermHint: 'Incomplete courses from this term onward will be removed; valid results will be retained.', courseImpact: 'Course impact preview', courseImpactHint: 'The final review recalculates this list. Unpublished or exceptional results require prior review.', course: 'Teaching class', disposition: 'Disposition', impact: { Remove: 'Remove course', RemoveEmptyGrade: 'Remove course and empty grade row', ArchiveDraftGrade: 'Confirm archiving unsubmitted grade before removal', KeepGrade: 'Keep valid result', ReviewRequired: 'Review grade first' } },
performance: {
title: 'System performance', description: 'Trace response-time costs from API endpoints into the database.', rangeAria: 'Performance report time range', refreshAria: 'Refresh performance report', notConfigured: 'Waiting for a performance data source', unavailable: 'Performance data is unavailable', fallbackNote: 'Business APIs continue operating normally. The report will not fall back to reading the academic business database.', openDashboard: 'Open monitoring platform', sampleConclusion: 'Sample conclusion', requestCount: 'Total requests', endpointP95: 'Endpoint P95', errorRate: '5xx rate', databaseP95: 'Database P95', slowQueries: 'Slow queries', queryFailures: 'Query failures', chartAria: 'Request rate and endpoint P95 trend', noSamples: 'The data source is connected, but no request metrics were received in this time range.', endpointRanking: 'Endpoint latency ranking', endpointMetrics: 'P95 / requests / 5xx', endpointCounts: '{count} requests · {errors} errors', noEndpoints: 'No endpoint metrics in this range.', databaseRanking: 'Database query ranking', databaseMetrics: 'P95 / calls / slow queries', databaseCounts: '{count} calls · {slow} slow', noDatabase: 'No database metrics in this range.', generatedAt: 'Generated {date} · Page data uses a short cache', viewTraces: 'View raw traces', requestsPerSecond: 'Requests / second', requestRate: 'Request rate', ranges: { '15m': '15 minutes', '1h': '1 hour', '24h': '24 hours', '7d': '7 days' }, notes: { waiting: 'Waiting for metric samples', failedDatabase: 'Database command failures detected', serverErrors: 'Server error rate needs attention', slowQueries: 'Queries exceeded the slow-query threshold', healthy: 'No significant anomalies in the current sample window' },
},
Loaded 3 of 5 files, more files were not shown because too many files have changed in this diff. Show more