Commit Graph

192 Commits

Author SHA1 Message Date
a2nr 7e17da46c2 fix(frontend): hide CircuitJS toolbar & menu bar in lesson embeds
Append &hideMenu=true to the circuitjs.html iframe src used by
renderCircuitEmbeds so lesson content embeds render clean without
the toolbar and menu bar. The embed path in CircuitEditor.svelte
is untouched, so the editor keeps its full toolbar.

Verified:
- Bundle contains embed URL (with hideMenu=true) and editor URL
  (without) as separate variants
- svelte-check: 0 errors
- /lesson/rangkaian_dasar returns 200 on the running stack
2026-08-12 07:49:34 +07:00
a2nr 24502380aa feat(quiz): strict focus-loss anti-cheat + audit attempt
Kebijakan strict: kehilangan fokus saat kuis aktif langsung mengakhiri kuis
dengan penalti, satu attempt per kuis tercatat audit, pembahasan disembunyikan
saat focus_lost, badge pelanggaran muncul di laporan guru.

Backend:
- tabel quiz_attempts (migration 0002) + endpoint POST /quiz-attempts/submit
  idempotent dengan unique constraint (satu attempt per token+lesson, 409
  untuk duplikat), bounded termination_reason
- models/repositories/storage: QuizAttempt + record/query pelanggaran untuk
  laporan guru (progress)

Frontend:
- quiz-integrity.ts: policy hub (isFocusLossEvent, terminateQuiz,
  shouldShowQuizReview) + attempt_id via crypto.randomUUID()
- lesson.svelte.ts: finalisasi idempotent; sendBeacon untuk exit path yang
  bisa suspend (focus_lost/page_unload), fetch keepalive untuk reason lain
- QuizTab.svelte: summary menyembunyikan pembahasan saat focus_lost
- progress/+page.svelte: badge pelanggaran focus_lost di laporan guru
- APP_VERSION 26 -> 27

Tests & docs:
- 204 backend test pass (unit host + integrasi container, DB elemes_test)
- 107 frontend test pass, svelte-check 0 error
- docs/12-quiz-integrity.md (baru), docs/07-quiz-authoring.md + README FAQ
  anti-cheat diperbarui
2026-08-11 20:55:39 +07:00
a2nr a14a212cc6 test(elemes): lock all three exportall build tags; note runbuild for unbundled services 2026-08-10 12:03:53 +07:00
a2nr c83a47b357 fix(elemes): align exportall/importall image tags with podman-compose (lms-*, not lms-c-*) 2026-08-10 12:03:10 +07:00
a2nr 5508c2dc7a docs: replace hard-coded container names with service-based podman-compose/label resolution 2026-08-10 11:34:54 +07:00
a2nr c453ddde2d test(elemes): per-command log assertions + cover dbupgrade/dbstatus/dbrestore 2026-08-10 11:29:09 +07:00
a2nr 394eb11082 refactor(elemes): delegate run_compose to run_compose_out; fail dbbackup on pg_dump error 2026-08-10 11:29:09 +07:00
a2nr 3935b7e01e test(elemes): add regression test for dynamic PROJECT_NAME resolution 2026-08-10 11:25:44 +07:00
a2nr 6ba508c7bc fix(verify): skip stale check when image tag unknown (avoid bogus podman images call) 2026-08-10 11:25:44 +07:00
a2nr 0b513b3900 docs(exportall): update image name hints to match compose (lms-backend, lms-frontend, lms-velxio) 2026-08-10 11:23:20 +07:00
a2nr 34ab1cde73 fix(verify): dynamic label-based verification for any PROJECT_NAME 2026-08-10 11:23:13 +07:00
a2nr 8976acd154 fix(dbbackup,dbrestore): use compose_exec for postgres service 2026-08-10 11:22:59 +07:00
a2nr 34dc9c9b90 fix(teacher,dbupgrade,dbstatus): use compose_exec for elemes service 2026-08-10 11:22:50 +07:00
a2nr a0c69ece8e fix(db_init): use compose_exec/compose_restart instead of hard-coded container names 2026-08-10 11:22:41 +07:00
a2nr 4f73bd725e feat(elemes): add compose_exec/compose_restart helpers for service-targeted ops 2026-08-10 11:22:28 +07:00
a2nr c356e234fa fix(frontend): resolve 26 svelte-check type errors
- add @types/node for hooks.server process/env types
- fix katex auto-render import path (contrib/auto-render)
- declare global Web Bluetooth API types in ble-deployer
- guard simApi null in CircuitEditor autosave interval
- default-type imports for CodeEditor/CircuitEditor
- make lesson slug getter non-nullable
- add expected_flowchart to LessonContent type
- key lesson workspace by slug; drop phantom onReset prop
- guard CodeTab render when lesson data is null
2026-08-09 12:28:17 +07:00
a2nr 9ee92cfaaf feat(teacher): manajemen akun guru canonical + first-run otomatis; cabut backend CSV (PG only)
- feat: ./elemes.sh teacher — upsert satu akun guru canonical (prompt nama default TEACHER_NAME, token tersembunyi via stdin, rotasi token saat guru sudah ada, idempotent); TEACHER_NAME/TEACHER_TOKEN di .env
- feat: first-run otomatis — db_init jalankan alembic upgrade head + bootstrap guru bila TEACHER_TOKEN terisi (run/runbuild/runclearbuild)
- refactor: backend CSV dicabut penuh — hapus mount tokens_siswa.csv, TOKENS_FILE, STORAGE_BACKEND=csv, csv_backend.py, csv_importer.py, generate_tokens.py, script migrate/verify/export CSV, command generatetoken/dbimport/dbverify/dbexport/synclessons; storage fail-loud postgresql-only
- fix: dbrestore gagal diam-diam saat restore ke DB berisi data (dump tanpa --clean) — dbbackup kini --clean --if-exists + dbrestore reset schema public; roundtrip terverifikasi
- test: suite kontrak PG-native + route auth/progress integrasi PG; 183 passed container, 96 passed host, frontend 91 passed
- docs: README, documentation.md, docs/01/02/11, load-test/README disinkronkan ke realita PostgreSQL-only; proposal.md dipertahankan (historis)
- chore: load-test token sintetis di-seed ke PG (content_parser), config.py bersih TOKENS_FILE, .dockerignore/.gitignore dibersihkan
2026-08-09 11:21:08 +07:00
a2nr d602b0f642 feat(student-management): kelola siswa round-trip CSV + bulk delete (PG)
- Export siswa terpilih/seluruh + progress ke CSV round-trip (token tidak
  pernah diekspor; teacher tidak ikut; urutan deterministik)
- Import preview all-or-nothing: siswa existing di-restore (nama+progress,
  token lama dipertahankan), siswa baru dibuat dari student_id kosong +
  token; conflict tidak menyebut raw token/digest
- Bulk delete multi-seleksi dengan validasi ketat (teacher terlindungi,
  zero-delete bila ada ID bermasalah)
- fix(import): deteksi delimiter berbasis schema — menerima titik koma
  (;) maupun koma (,), ekspor tetap ';' + BOM; header tab/campuran ditolak
  dengan pesan jelas (regresi: file Excel/Sheets kini bisa diimpor)
- refactor: progress_status.py — kontrak status legacy tunggal dipakai
  storage PG, export, dan import; report siswa hanya role student
- UI /progress: dialog import/export + bulk delete, selection store,
  respon import tanpa raw token; APP_VERSION 22 -> 26
- ops: ORIGIN env var di podman-compose.yml
- docs: README section 9 (workflow round-trip + delimiter) dan
  docs/11-database-migration (kelola siswa via round-trip CSV)
- test: parser round-trip (45), repositories, route management (24,
  PostgreSQL), frontend 91, fixtures CSV valid/invalid
2026-08-09 07:29:19 +07:00
a2nr ac37db5c91 feat(storage): migrasi penyimpanan CSV ke PostgreSQL (SQLAlchemy + Alembic)
- facade storage: csv_backend + postgres_backend, dipilih via STORAGE_BACKEND
- token disimpan sebagai HMAC-SHA256 digest (TOKEN_PEPPER), tanpa plaintext
- schema alembic 0001: users, access_tokens, lessons, student_progress
- importer CSV idempotent + dry-run + sparse model (not_started tanpa row)
- lesson registry: sync dari home.md (lesson hilang di-deactivate, bukan dihapus)
- routes progress/auth: report & reset via DB, validasi via token hash
- elemes.sh: dbupgrade/dbstatus/dbimport/synclessons/dbverify/dbbackup/dbrestore/dbexport
- podman-compose: service postgres (PG18), tokens_siswa.csv mount :ro
- frontend: api client + progress page; tests kontrak dual-backend + isolasi DB
- load-test: skenario database (locustfile_db.py)
- docs: 01-11 termasuk 11-database-migration.md (arsitektur & operasional)
2026-08-08 04:57:08 +00:00
a2nr 575787af59 test(load-test): task sesi interaktif + parser konten rekursif + e2e smoke check
- content_parser.py: scan rekursif subfolder (dasar/arduino/circuit) + inject 50 token
- locustfile.py: task interactive_session_python (create→poll→input→verify→delete)
- e2e_session_check.py: smoke-test 13 skenario via proxy Flask
- README: skenario load test 50 pengguna 2 device
chore(elemes): update velxio submodule ke elemes-v3.2 (2b17470)
2026-08-02 14:14:59 +00:00
a2nr ec66d794a8 feat(playground): alur interaktif Run→prompt→jawab + file tree collapsible & dukungan .h
- store: normalisasi lifecycle sesi (runStatus/runSessionId/outputCursor/runError,
  stdinQueue tetap untuk kompatibilitas)
- +page.svelte: session controller — start, polling recursive setTimeout non-overlap,
  delta output via cursor, stop + cleanup unmount/generation counter
- ConsolePanel.svelte: input interaktif (onSendInput/onStop async, mode antrean vs kirim)
- FileTree.svelte: validasi rename (foo.h diterima di C), tombol + langsung mode rename,
  collapsible shell dengan handle persisten
- playground-files.ts: validasi nama file (basename, traversal, duplikat case-insensitive)
- api.ts/compiler.ts: client sesi interaktif
- tests: playground.test.ts + playground-files.test.ts
2026-08-02 14:14:53 +00:00
a2nr c103b55dc4 feat(compiler-worker): sesi interaktif PTY untuk playground — Python input() dan C scanf() tanpa EOFError
- session_manager.py: InteractiveSession + SessionManager (PTY Python/C, bounded
  output buffer, delta cursor, sweeper, semaphore compile max 2, limit 50 sesi)
- app.py: hybrid — endpoint batch /execute lama dipertahankan + endpoint sesi baru
  (POST /sessions, GET delta output, POST input, DELETE stop) + health
- Dockerfile: gunicorn gthread 1 worker/32 thread (registry in-memory aman)
- routes/compile.py: proxy Flask /compile/sessions + anon slot lifecycle + rate limit
- podman-compose.yml: env COMPILER_WORKER_BASE_URL
- tests: test_session_manager.py (baru) + test_app.py + services/tests/test_compile_sessions.py
2026-08-02 14:14:45 +00:00
a2nr ddfbbb80f3 feat(playground): FileTree filter per bahasa — C dan Python dipisah
- FileTree menerima prop language ('c' | 'python', default 'c')
- hanya merender file dengan ekstensi yang cocok (.c atau .py)
- tombol + buat file dengan ekstensi bahasa aktif
- header menampilkan nama bahasa (C/Python), bukan generik 'File'
2026-08-01 22:39:20 +00:00
a2nr 152ca85718 fix(playground): Run mengonsumsi stdinQueue atomik via consumeStdin()
- runActiveFile() memanggil consumeStdin() (antrean + draft, digabung, dikosongkan)
- pesan info jika stdin kosong: program yang membaca input akan mendapat EOF
- hapus pembacaan consoleInput langsung yang menyebabkan baris hilang
2026-08-01 22:38:47 +00:00
a2nr a92411fa45 fix(playground): Kirim menambah baris ke stdinQueue, bukan hanya history 2026-08-01 22:36:52 +00:00
a2nr a14eb70038 test(compiler-worker): regression test stdin passthrough untuk Python input() dan C scanf() 2026-08-01 22:34:51 +00:00
a2nr 1aef334d59 feat(playground): stdinQueue di store — enqueue/consume/clear atomik 2026-08-01 22:34:32 +00:00
a2nr dbed014474 feat(playground): multi-tab playground + FileTree + Console + stdin wiring to compile worker
- playground route: velxio/flowchart/circuit/code tabs with auto-save
- FileTree + ConsolePanel for C/Python code tab
- compileCode() forwards stdin through routes/compile.py to compiler_worker
- compiler_worker run_c_code/run_python_code accept stdin, pass via subprocess.run(input=)
- known issue: Console UI does not queue stdin properly → fix in next cycle
2026-08-01 22:32:54 +00:00
a2nr 0ee39f152e refactor(compose): adaptasi pola network tailscale ala firefly-iii
- Semua service share netns elemes-ts (network_mode: service:elemes-ts),
  hapus bridge network elemes_network
- lms-tail.json: proxy target 127.0.0.1 (bukan nama service DNS)
- flowchart pindah port 80 → 8081 (konflik port di netns bersama),
  tambah nginx.conf custom + EXPOSE 8081
- env internal (COMPILER_WORKER_URL, VELXIO_COMPILER_URL, API_BACKEND,
  hooks fallback, vite dev proxy) → 127.0.0.1
- fix format volume velxio-data/velxio-arduino-libs agar kompatibel
  podman-compose 1.0.6 (named volume standar)
2026-08-01 12:56:51 +00:00
a2nr 52771bc264 chore(elemes): update velxio submodule to elemes-v3.2 branch
Update velxio submodule pointer to the new integration branch that contains:
- EmbedBridge.ts PostMessage bridge for iframe integration
- DeployProgress UI for compile/transfer/flash status
- BASE_URL customization for /velxio/ path
- Backend auth, project, and database endpoints for Elemes LMS
- SerialMonitor BLE/Hardware toggle support
2026-08-01 06:02:04 +00:00
a2nr 02d5969619 refactor(quiz): restructure quiz session, question view, and tab safety
Restructure quiz flow into QuizSession primitive + atomic quiz state in
LessonManager, and extract QuizQuestionView for split-view display.

Tab-safety fix: add lesson-tabs.ts with pickDefaultTab(), getAvailableTabs()
mirroring the exact {#if} conditions in +page.svelte, and ensureActiveTab()
safety-net that falls back to pickDefaultTab() when the desired tab is not
rendered. A reactive $effect in lesson/[slug]/+page.svelte validates
activeTab against lesson data on every change, preventing the "tab quiz
kosong" (empty workspace) regression for quiz-only lessons and phantom-tab
state after data changes.

Files:
- lib/services/lesson-tabs.ts (+test): pure helpers, 18 tests pass
- lesson/[slug]/+page.svelte: ensureActiveTab reactive guard + QuizQuestionView
- lesson/[slug]/lesson.svelte.ts: atomic startQuiz, getExitStatus, idempotent
  submit on navigate/exit
- lib/services/quiz-session.ts (+test), lib/types/quiz.ts, QuizTab.svelte
  (mgr-driven), QuizQuestionView.svelte, lesson.css
- services/lesson_service.py, services/tests/test_lesson_service_quiz.py
  (test_lesson_service_quiz.py), requirements.txt (+pytest)
- docs/07-quiz-authoring.md
- version.ts APP_VERSION 21 -> 22 (forces SW update for the fix)
- examples/content/dasar/quiz_test.md synced to live content root
2026-08-01 00:14:29 +07:00
a2nr e0324a77c0 add example content 2026-07-27 22:14:45 +07:00
a2nr 2f689afc27 feat: implement sub-home/bab feature
- Generalize _read_md_cached() for generic file caching
- Add find_sub_home_for_lesson() and get_sub_home_data() helpers
- Add /api/bab/<folder> endpoint
- Detect sub-home in api_lesson for nav context
- Skip sub-home.md in find_lesson_file() and _parse_lesson_links()
- Add title to bab frontend page data
- Update generate_tokens.py & content_parser.py to skip sub-home.md
2026-07-27 22:01:01 +07:00
a2nr 9637740ea9 feat(quiz): add login gate, one-attempt enforcement, and exit penalty 2026-07-27 21:16:50 +07:00
a2nr 32ef89159a refactor(DeployTab): mode toggle inline in serial monitor + deploy FAB 2026-07-26 11:49:01 +07:00
a2nr bbdc53e601 refactor: playground self-contained full-viewport via svelte:head style 2026-07-24 15:54:29 +07:00
a2nr f705f1f314 fix: playground full-viewport width (override container max-width) 2026-07-24 15:41:36 +07:00
a2nr 455d449d1e fix: circuit tab full height in playground (override fixed 550px) 2026-07-24 14:03:44 +07:00
a2nr 1b2c51f72f chore: bump version to 19 for playground multi-tab 2026-07-24 13:46:18 +07:00
a2nr 589f3a148d feat: playground multi-tab (Velxio/Flowchart/Circuit/Code) with auto-save 2026-07-24 13:45:28 +07:00
a2nr 7e1139e7d1 refactor: make FlowchartTab eval button conditional on onRun prop 2026-07-24 13:44:25 +07:00
a2nr 8e89fde3c1 fix: docked editor panel height + quiz image parser + assets dir config
- fix(layout): editor-area docked mode sekarang height:70vh (sebelumnya
  max-height:85vh tanpa height, menyebabkan tab Arduino/velxio menciut
  ke 150px karena iframe tidak punya intrinsic height)
- fix(layout): tambah overflow:hidden pada velxio/flowchart/quiz panel
  untuk mencegah nested scrollable flex collapse
- feat(quiz): parser image dari 'image:' directive dan markdown ![alt](path)
  di question flashcard; konversi bare filename ke /assets/ path
- feat(assets): ASSETS_DIR derived dari CONTENT_DIR untuk support
  custom content directory (bukan hardcoded 'assets')
- fix(quiz): QuizTab container gunakan flex:1+min-height:0 (bukan height:100%)
- chore: hapus placeholder examples/assets/put_your_image.here
2026-07-21 20:50:01 +07:00
a2nr 156480b26f Merge dev → master: USB deployer get_sync fix (buffered pump)
Consolidates all dev work including the orphaned-read race fix:
- Single read-pump feeds a FIFO ByteStreamBuffer; readExact/drain/
  serial monitor consume from buffer (no orphaned reader.read()).
- DTR timing 50ms+100ms, port reuse, pre-sync drain.
- Vitest + ByteStreamBuffer unit tests (7 pass).
- APP_VERSION 18 for SW cache-bust.

Verified on CH340 (1a86:7523): INSYNC 0x14 + STK_OK 0x10
received cleanly, deploy succeeds.
2026-07-20 07:52:16 +07:00
a2nr 98adc0b860 fix(usb-deployer): review fixes — reset pumpRunning on exit, clear buffer on readExact timeout
WARN-1: pumpRunning now reset to false when the pump loop exits via
{done} or error, so future startPump() isn't a silent no-op.
WARN-3: readExact clears rxBuffer on timeout to avoid stale bytes
leaking into the next non-retried STK500 command.
2026-07-19 19:15:20 +07:00
a2nr 6f2f9c589a chore(frontend): bump APP_VERSION to 18 for SW cache-bust
Service worker evicts old caches on activate, so users always
get the new usb-deployer bundle with the read-pump fix instead
of a stale cached one.
2026-07-19 19:09:45 +07:00
a2nr 056b1a47b6 refactor(usb-deployer): serial monitor + flashBuffer + lifecycle use pump
- startSerialMonitor/setBaudRate stop+restart pump, subscribe rxBuffer.onData
- flashBuffer stops pump, reuses/reopens port, starts pump, drains before sync
- stopReaderWriter now just releases locks; cleanup stops pump first
- remove dead keepReading field
2026-07-19 19:09:10 +07:00
a2nr f7c088013a fix(usb-deployer): read from rxBuffer, kill orphaned-read race in get_sync
readExact and drainStray now consume the FIFO buffer fed by the pump
instead of calling reader.read() directly. No orphaned reader.read()
promise can swallow optiboot INSYNC/OK replies anymore. This is the
core fix for "get_sync failed after N attempts".
2026-07-19 19:06:44 +07:00
a2nr 121d592ce0 feat(usb-deployer): add read pump + start pump after pair
Single pump loop becomes the only reader.read() caller, feeding
rxBuffer. Serial monitor + readExact/drain will consume from the
buffer (next tasks). Build passes.
2026-07-19 19:05:54 +07:00
a2nr bf4b1a4932 feat(frontend): add vitest + ByteStreamBuffer FIFO for orphan-read fix
Test runner setup (vitest) plus deadline-based FIFO buffer that
becomes the single sink for serial bytes. readExact keeps
partial bytes buffered on timeout — the exact case that dropped
optiboot INSYNC/OK replies under the orphaned-reader race.
7 unit tests pass.
2026-07-19 19:03:40 +07:00
a2nr 8bb52682a3 docs(usb-deployer): document v3.2 get_sync fix (timing, drain, fail-fast) 2026-07-19 16:54:19 +07:00