Files
Power BI DevandClaude Opus 5.5 199c217c3b Visualisasi pembobotan CPMK + rekap kelas tertimbang bobot RPS
- Metodologi: kartu "Alur Pembobotan per MK" (Komponen RPS -> Sub-CPMK -> CPMK,
  CPMK -> CPL skor maks resmi, perbandingan porsi RPS vs skor maks)
- Peta Visual: mode "Bobot (skor maks resmi)" pada diagram alur, label persen
  (tiap CPL 100%), angka mentah Tabel 10.2/10.3 di tooltip
- rollup_mk: Sub-CPMK -> CPMK kini tertimbang bobot kisi-kisi RPS (sebelumnya
  rata sederhana), sama dengan jalur per mahasiswa; semua pemanggil diperbarui
- Uji: rekap kelas = rata-rata capaian per mahasiswa

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 07:03:21 +07:00

111 lines
6.9 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""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}")
# 5b) rollup_mk: Sub-CPMK → CPMK tertimbang bobot kisi-kisi RPS (sama dengan jalur per mahasiswa)
pw = {"kode": "MK10", "cpls": [{"kode": "CPL-02"}],
"cpmks": [{"kode": "A", "cpl": ["CPL-02"], "subs": [{"kode": "s1"}, {"kode": "s2"}]}]}
skor_maks["MK10"] = {"A": 100.0}
nd = {"mode": "agregat", "agregat": {"s1": 90, "s2": 60}}
cek(abs(hitung.rollup_mk(pw, nd, 70)["cpmk"]["A"]["skor"] - 75.0) < 1e-9, "tanpa bobot RPS → rata sederhana (90+60)/2 = 75")
rw = hitung.rollup_mk(pw, nd, 70, {"s1": 30.0, "s2": 10.0})
cek(abs(rw["cpmk"]["A"]["skor"] - 82.5) < 1e-9, f"bobot RPS 30:10 → (30·90 + 10·60)/40 = {rw['cpmk']['A']['skor']:.1f}")
nm = {"mode": "per_mahasiswa", "mahasiswa": [{"npm": "m1", "skor": {"s1": 90, "s2": 60}},
{"npm": "m2", "skor": {"s1": 70, "s2": 100}}]}
kelas = hitung.rollup_mk(pw, nm, 70, {"s1": 30.0, "s2": 10.0})["cpmk"]["A"]["skor"]
per_mhs = hitung.sebaran_cpmk(pw, nm, 70, {"s1": 30.0, "s2": 10.0})["A"]["rata_mhs"]
cek(abs(kelas - per_mhs) < 1e-9, f"rekap kelas ({kelas:.2f}) = rata-rata capaian per mahasiswa ({per_mhs:.2f})")
# 6) Panduan Kurikulum APTIKOM 2024 hal. 117: 50 mhs → 30 di atas, 5 sesuai, 15 di bawah 50,01
from app import cqi
pa = {"kode": "MK08", "cpls": [{"kode": "CPL-08"}],
"cpmks": [{"kode": "CPMK081", "cpl": ["CPL-08"], "subs": [{"kode": "s1"}, {"kode": "s2"}]}]}
skor_maks["MK08"] = {"CPMK081": 100.0}
mhs = ([{"npm": f"a{i}", "skor": {"s1": 80, "s2": 70}} for i in range(30)] +
[{"npm": f"b{i}", "skor": {"s1": 50.01, "s2": 50.01}} for i in range(5)] +
[{"npm": f"c{i}", "skor": {"s1": 30, "s2": 40}} for i in range(15)])
sb = hitung.sebaran_cpmk(pa, {"mode": "per_mahasiswa", "mahasiswa": mhs}, 50.01)["CPMK081"]
cek((sb["atas"], sb["sesuai"], sb["bawah"], sb["n"]) == (30, 5, 15, 50), f"sebaran APTIKOM 30/5/15 dari 50: {sb}")
cek(abs(sb["pct_tuntas"] - 70.0) < 1e-9, "% tuntas = (30 + 5) / 50 = 70 %")
sc = hitung.sebaran_cpl_mk(pa, {"mode": "per_mahasiswa", "mahasiswa": mhs}, 50.01)["CPL-08"]
cek(abs(sc["pct_tuntas"] - 70.0) < 1e-9, "sebaran CPL dalam MK = sebaran CPMK tunggalnya")
db.ambil_pengaturan = lambda: {"ambang": "50.01", "target_tuntas": "75"}
cek(cqi.tercapai(None, 70.0) is False, "70 % < ambang batas MK 75 % → belum tercapai (FAILED)")
cek(cqi.tercapai(40.0, 80.0) is True, "status hanya dari %: rata-rata 40 tetapi 80 % tuntas → tercapai")
cek(cqi.tercapai(60.0, None) is True and cqi.tercapai(40.0, None) is False, "data agregat: skor ≥ ambang")
cek(cqi.tercapai(None, None) is None, "belum terukur")
# bobot kisi-kisi RPS menimbang Sub di dalam CPMK per mahasiswa: (3·80 + 1·40)/4 = 70
sb2 = hitung.sebaran_cpmk(pa, {"mode": "per_mahasiswa", "mahasiswa": [{"npm": "x", "skor": {"s1": 80, "s2": 40}}]},
50.01, {"s1": 30, "s2": 10})["CPMK081"]
cek(abs(sb2["rata_mhs"] - 70.0) < 1e-9, f"skor CPMK mahasiswa tertimbang RPS = {sb2['rata_mhs']}")
print("TOTAL GAGAL:", gagal)
sys.exit(1 if gagal else 0)