Change update semester
This commit is contained in:
@@ -42,22 +42,23 @@ export async function POST() {
|
||||
}
|
||||
|
||||
// Calculate current semester based on tahun_angkatan and current date
|
||||
const yearsSinceEnrollment = currentYear - tahunAngkatan;
|
||||
let currentSemester = yearsSinceEnrollment * 2; // 2 semesters per year
|
||||
const years = currentYear - tahunAngkatan;
|
||||
let currentSemester: number;
|
||||
|
||||
// Adjust for current month (odd months = odd semesters, even months = even semesters)
|
||||
if (currentMonth >= 2 && currentMonth <= 7) {
|
||||
// February to July = odd semester (1, 3, 5, etc.)
|
||||
currentSemester += 1;
|
||||
if (currentMonth >= 8 && currentMonth <= 12) {
|
||||
// Agustus–Desember: semester ganjil tahun akademik berjalan
|
||||
currentSemester = years * 2 + 1;
|
||||
} else if (currentMonth >= 2 && currentMonth <= 7) {
|
||||
// Februari–Juli: semester genap tahun akademik berjalan
|
||||
currentSemester = years * 2 + 2;
|
||||
} else {
|
||||
// August to January = even semester (2, 4, 6, etc.)
|
||||
currentSemester += 2;
|
||||
// Januari: masih semester ganjil dari T.A. sebelumnya
|
||||
currentSemester = (years - 1) * 2 + 1;
|
||||
}
|
||||
|
||||
// Cap at semester 14 (7 years)
|
||||
if (currentSemester > 14) {
|
||||
currentSemester = 14;
|
||||
}
|
||||
// Jaga batas
|
||||
if (currentSemester < 1) currentSemester = 1;
|
||||
if (currentSemester > 14) currentSemester = 14;
|
||||
|
||||
// Update semester if different
|
||||
if (student.semester !== currentSemester) {
|
||||
|
||||
Reference in New Issue
Block a user