Migrasi aman dari basis data produksi OBE-Mapping + rangkaian uji di repo

- pengguna: peran dosen_mk/dosen_rps_mk → dosen (peran lama dicatat di _peran_obe); hash password & ID utuh
- KRS: kolom nim → npm (nama internal); kelas '' pada penugasan = seluruh kelas MK sesuai KRS
- koordinator MK = dosen_rps_mk yang terakhir menyimpan RPS (bila tidak ada: yang pertama)
- ambang bawaan 50,1
- tests/: seluruh uji + gladi migrasi (tests/jalankan.sh [db-produksi]); lulus pada salinan DB produksi 13 Okt 2026

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Power BI Dev
2026-10-13 20:22:19 +07:00
co-authored by Claude Opus 5.5
parent 5e70003bd2
commit 9a6f4a2b17
12 changed files with 809 additions and 4 deletions
+73
View File
@@ -0,0 +1,73 @@
"""Uji rumus resmi (Dokumen Kurikulum 2026 Bab 10.3) dengan contoh Klinik 3:
CPL02 Mahasiswa 1 = 83/110 = 75,45 %. MK02: CPMK021 = 20/30, CPMK022 = 20/30;
MK03: CPMK023 = 43/50 — skor maks CPMK = 30, 30, 50 (Tabel 10.2), total CPL-02 = 110 (Tabel 10.3)."""
import sys
sys.path.insert(0, sys.argv[1])
from app import db, hitung
kur = {"cpl": {"CPL-02": {"desk": "contoh"}}, "cpmk": {},
"mk": {"MK02": {"nama": "MK02", "cpls": {"CPL-02": ["CPMK021", "CPMK022"]}},
"MK03": {"nama": "MK03", "cpls": {"CPL-02": ["CPMK023"]}}}}
peta = {
"MK02": {"kode": "MK02", "cpmks": [
{"kode": "CPMK021", "cpl": ["CPL-02"], "subs": [{"kode": "S021a"}, {"kode": "S021b"}]},
{"kode": "CPMK022", "cpl": ["CPL-02"], "subs": [{"kode": "S022"}]}]},
"MK03": {"kode": "MK03", "cpmks": [
{"kode": "CPMK023", "cpl": ["CPL-02"], "subs": [{"kode": "S023"}]}]},
}
skor_maks = {"MK02": {"CPMK021": 30.0, "CPMK022": 30.0}, "MK03": {"CPMK023": 50.0}}
db.kurikulum = lambda: kur
db.peta_mk = lambda k: peta.get(k)
db.skor_maks_mk = lambda k: skor_maks.get(k, {})
db.skor_maks_cpl = lambda: {"CPL-02": 110.0}
db.ambil_pengaturan = lambda: {"ambang": "70", "pola_npm": db.PENGATURAN_DEFAULT["pola_npm"]}
# bobot kisi-kisi RPS di dalam CPMK021: S021a 3× S021b → skor CPMK021 = (3·60 + 1·80)/4 = 65 ≠ 66,67
hitung._bobot_mk = lambda mk, t, c: {"S021a": 30, "S021b": 10} if mk == "MK02" else {}
gagal = 0
def cek(ok, pesan):
global gagal
print(("OK " if ok else "GAGAL"), pesan)
gagal += not ok
# 1) contoh Klinik 3 persis (skor Sub = skor CPMK)
hitung._bobot_mk = lambda mk, t, c: {}
rek = {"MK02": {"tahun": "2025/2026 Ganjil", "skor": {"S021a": 20 / 30 * 100, "S021b": 20 / 30 * 100,
"S022": 20 / 30 * 100}},
"MK03": {"tahun": "2025/2026 Genap", "skor": {"S023": 43 / 50 * 100}}}
c = hitung.capaian_mahasiswa("H1051221001", rek, {})
skor = c["cpl"]["CPL-02"]["skor"]
cek(abs(skor - 83 / 110 * 100) < 1e-9, f"CPL-02 = {skor:.2f} % (harapan {83/110*100:.2f})")
cek(c["cpl"]["CPL-02"]["status"] == "tercapai" and c["angkatan"] == "2022", "status tercapai, angkatan 2022")
cek(abs(c["cpl"]["CPL-02"]["bukti"] - 1.0) < 1e-9, "bukti 110/110 = 100 %")
# 2) bobot kisi-kisi RPS menimbang Sub di DALAM CPMK; antar-CPMK tetap skor maks resmi
hitung._bobot_mk = lambda mk, t, c: {"S021a": 30, "S021b": 10} if mk == "MK02" else {}
rek2 = {"MK02": {"tahun": "2025/2026 Ganjil", "skor": {"S021a": 60, "S021b": 80, "S022": 50}}}
c2 = hitung.capaian_mahasiswa("X", rek2, {})
harap = (30 * 65 + 30 * 50) / 60
cek(abs(c2["cpl"]["CPL-02"]["skor"] - harap) < 1e-9, f"tertimbang RPS di dalam CPMK: {c2['cpl']['CPL-02']['skor']:.2f} (harapan {harap:.2f})")
cek(abs(c2["cpmk"]["CPMK021"]["skor"] - 65) < 1e-9, "CPMK021 = (3·60 + 1·80)/4 = 65")
# 3) kelengkapan bukti = skor maks dinilai / total CPL: 60/110 = 54,5 % cukup; total 130 → 46 % kurang
cek(c2["cpl"]["CPL-02"]["status"] == "tidak", f"60/110 = {c2['cpl']['CPL-02']['bukti']:.0%} bukti cukup → status 'tidak' (skor 57,5 < 70)")
db.skor_maks_cpl = lambda: {"CPL-02": 130.0}
c3 = hitung.capaian_mahasiswa("X", rek2, {})
cek(c3["cpl"]["CPL-02"]["status"] == "bukti_kurang", f"60/130 = {c3['cpl']['CPL-02']['bukti']:.0%} → bukti_kurang")
# 4) urutan tahun (MK diulang memakai yang terakhir)
cek(hitung._urut_tahun("2025/2026 Genap") > hitung._urut_tahun("2025/2026 Ganjil")
and hitung._urut_tahun("2026/2027 Ganjil") > hitung._urut_tahun("2025/2026 Genap"), "urutan tahun ajaran")
# 5) rollup_mk: CPL dalam MK tertimbang skor maks (bukan bagi rata)
skor_maks["MK09"] = {"A": 80.0, "B": 20.0}
pm = {"kode": "MK09", "cpls": [{"kode": "CPL-02"}],
"cpmks": [{"kode": "A", "cpl": ["CPL-02"], "subs": [{"kode": "sa"}]},
{"kode": "B", "cpl": ["CPL-02"], "subs": [{"kode": "sb"}]}]}
r = hitung.rollup_mk(pm, {"mode": "agregat", "agregat": {"sa": 90, "sb": 40}}, 70)
cek(abs(r["cpl"]["CPL-02"]["skor"] - 80.0) < 1e-9, f"rollup_mk CPL = (80·90 + 20·40)/100 = {r['cpl']['CPL-02']['skor']:.1f}")
print("TOTAL GAGAL:", gagal)
sys.exit(1 if gagal else 0)