- Sel template berisi tabel contoh bersarang kini dibersihkan saat ditimpa: dokumen sah OOXML, Word tidak lagi menganggapnya rusak lalu mengacak tata letak - Blok naratif (Peta CPL-CPMK, Deskripsi, Bahan Kajian, Pustaka, Media, Pengampu, Prasyarat) ditulis ke baris template asli, bukan indeks yang bergeser setelah daftar CPL/CPMK/Sub digandakan - Komponen penilaian tanpa bobot & Sub-CPMK tidak dicetak; template rps_untan.docx versi rapi - Portofolio: kolom NIM - tests/uji_unduh_rps.py: ke-10 RPS produksi sah & label sejajar (generator lama: 10/10 gagal) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4a68df4592
commit
81082a52c0
@@ -14,5 +14,6 @@ if [ -n "$1" ]; then
|
||||
if PYTHONIOENCODING=utf-8 python tests/uji_migrasi_prod.py "$ROOT" "$1" > tests/uji_migrasi_prod.log 2>&1; then echo "OK uji_migrasi_prod"; else echo "GAGAL uji_migrasi_prod"; gagal=1; fi
|
||||
# memakai tests/migrasi.db hasil gladi di atas
|
||||
if PYTHONIOENCODING=utf-8 python tests/uji_rps_kustom.py "$ROOT" > tests/uji_rps_kustom.log 2>&1; then echo "OK uji_rps_kustom"; else echo "GAGAL uji_rps_kustom"; gagal=1; fi
|
||||
if PYTHONIOENCODING=utf-8 python tests/uji_unduh_rps.py "$ROOT" > tests/uji_unduh_rps.log 2>&1; then echo "OK uji_unduh_rps"; else echo "GAGAL uji_unduh_rps"; gagal=1; fi
|
||||
fi
|
||||
exit $gagal
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
"""RPS .docx unduhan untuk SEMUA RPS di DB hasil gladi migrasi (tests/migrasi.db):
|
||||
(1) sah secara OOXML — tak ada sel yang diakhiri tabel bersarang tanpa paragraf (Word menganggap
|
||||
rusak lalu mengacak tata letak); (2) isi blok naratif berada di baris berlabel yang benar."""
|
||||
import io, os, sys
|
||||
os.environ["DB_PATH"] = os.path.join(os.path.dirname(os.path.abspath(__file__)), "migrasi.db")
|
||||
sys.path.insert(0, sys.argv[1])
|
||||
from docx import Document
|
||||
from docx.oxml.ns import qn
|
||||
from fastapi.testclient import TestClient
|
||||
from app import main, db, auth
|
||||
|
||||
gagal = []
|
||||
def cek(ok, pesan):
|
||||
print(("OK " if ok else "GAGAL"), pesan)
|
||||
if not ok: gagal.append(pesan)
|
||||
|
||||
k = next(r[0] for r in db.get_conn().execute("SELECT id FROM pengguna WHERE role='kaprodi'"))
|
||||
t = auth.token_baru(); db.buat_sesi(k, t); c = TestClient(main.app); c.cookies.set("sesi", t)
|
||||
|
||||
def baris(tb, awalan):
|
||||
for row in tb.rows:
|
||||
sel = row.cells
|
||||
if sel[0].text.strip().startswith(awalan):
|
||||
return " ".join(x.text for x in sel[1:])
|
||||
return None
|
||||
|
||||
for (mk,) in db.get_conn().execute("SELECT mk_kode FROM rps ORDER BY mk_kode").fetchall():
|
||||
data = db.ambil_rps(mk)["data"]
|
||||
r = c.get(f"/rps/{mk}/unduh")
|
||||
if r.status_code != 200:
|
||||
cek(False, f"{mk}: unduh → {r.status_code}"); continue
|
||||
doc = Document(io.BytesIO(r.content))
|
||||
rusak = [tc for tc in doc.element.body.iter(qn("w:tc")) if len(tc) and tc[-1].tag == qn("w:tbl")]
|
||||
tb = doc.tables[0]
|
||||
harap = {
|
||||
"Peta CPL": "→",
|
||||
"Diskripsi Singkat": (data.get("deskripsi") or "").strip()[:40],
|
||||
"Bahan Kajian": (data.get("bahan_kajian") or "").strip()[:30].replace("\r", ""),
|
||||
"Dosen Pengampu": (data["identitas"].get("pengampu") or "").strip(),
|
||||
"Matakuliah syarat": (data["identitas"].get("prasyarat") or "—").strip(),
|
||||
}
|
||||
salah = [lab for lab, isi in harap.items() if isi and isi not in (baris(tb, lab) or "").replace("\r", "")]
|
||||
cek(not rusak and not salah, f"{mk}: OOXML sah ({len(rusak)} sel rusak) · label sejajar isi {salah or ''}")
|
||||
print("TOTAL GAGAL:", len(gagal)); sys.exit(1 if gagal else 0)
|
||||
Reference in New Issue
Block a user