diff --git a/frontend/src/lib/components/TeacherVelxioEditor.svelte b/frontend/src/lib/components/TeacherVelxioEditor.svelte
index ba436c7..f7ad9a4 100644
--- a/frontend/src/lib/components/TeacherVelxioEditor.svelte
+++ b/frontend/src/lib/components/TeacherVelxioEditor.svelte
@@ -5,10 +5,12 @@
let {
initialCode = '',
initialCircuit = '',
+ onTransfer,
onSave
}: {
initialCode?: string;
initialCircuit?: string;
+ onTransfer?: (state: { code: string; circuit: string }) => void;
onSave?: (state: { code: string; circuit: string }) => void;
} = $props();
@@ -63,17 +65,23 @@
showFeedback('Dimuat ulang dari dokumen');
}
- function handleSave() {
+ function handleTransfer() {
const state = getCurrentState();
if (!state) {
showFeedback('Gagal membaca state simulator');
return;
}
- if (onSave) {
+ if (onTransfer) {
+ onTransfer(state);
+ } else if (onSave) {
onSave(state);
}
- showFeedback('Tersimpan ke dokumen!');
+ showFeedback('Hasil dipindahkan ke editor');
+ }
+
+ function handleSave() {
+ handleTransfer();
}
function showFeedback(msg: string) {
@@ -137,17 +145,7 @@
-
-
-
- {isReady ? 'Simulator Siap (Mode Lengkap)' : 'Menghubungkan Simulator...'}
-
- {#if saveFeedback}
- {saveFeedback}
- {/if}
-
-
-
@@ -215,6 +227,13 @@
flex-wrap: wrap;
}
+ .toolbar-left {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ flex-wrap: wrap;
+ }
+
.toolbar-status {
display: flex;
align-items: center;
@@ -292,13 +311,13 @@
cursor: not-allowed;
}
- .btn-save {
+ .btn-transfer {
background: var(--color-primary, #0d6efd);
color: #ffffff;
border-color: var(--color-primary, #0d6efd);
}
- .btn-save:hover:not(:disabled) {
+ .btn-transfer:hover:not(:disabled) {
background: var(--color-primary-dark, #0a58ca);
border-color: var(--color-primary-dark, #0a58ca);
}
diff --git a/frontend/src/routes/lesson/[slug]/DeployTab.svelte b/frontend/src/routes/lesson/[slug]/DeployTab.svelte
index ebc6fde..2da456c 100644
--- a/frontend/src/routes/lesson/[slug]/DeployTab.svelte
+++ b/frontend/src/routes/lesson/[slug]/DeployTab.svelte
@@ -163,12 +163,21 @@
deployMessage = 'Mengompilasi kode...';
let code = '';
+ let boardFqbn = 'arduino:avr:uno';
if (velxioIframe) {
const state = getVelxioState(velxioIframe);
if (state?.code) {
code = state.code;
}
+ if (state?.circuit) {
+ try {
+ const parsed = JSON.parse(state.circuit);
+ if (parsed?.board) {
+ boardFqbn = parsed.board;
+ }
+ } catch {}
+ }
}
if (!code) {
@@ -179,7 +188,7 @@
throw new Error('Tidak ada kode Arduino untuk di-deploy');
}
- const res = await getHexContent({ code, board_fqbn: 'arduino:avr:uno' });
+ const res = await getHexContent({ code, board_fqbn: boardFqbn });
if (!res.success || !res.hex_content) {
throw new Error(res.error || 'Kompilasi gagal');
diff --git a/frontend/src/routes/teacher/content/+page.svelte b/frontend/src/routes/teacher/content/+page.svelte
index 6ebbc51..6ba2df4 100644
--- a/frontend/src/routes/teacher/content/+page.svelte
+++ b/frontend/src/routes/teacher/content/+page.svelte
@@ -209,9 +209,8 @@
}
}
- async function handleSaveVelxioFromTab(state: { code: string; circuit: string }) {
+ function handleTransferVelxioFromTab(state: { code: string; circuit: string }) {
applyVelxioToBody(state.code, state.circuit);
- await mgr.handleSave();
}
async function handleSaveAction() {
@@ -375,10 +374,40 @@
'\n---EXPECTED_SERIAL_OUTPUT---\n' +
'LED ON\nLED OFF\n' +
'---END_EXPECTED_SERIAL_OUTPUT---\n' +
+ '\n---EXPECTED_WIRING---\n' +
+ '{\n' +
+ ' "wires": [\n' +
+ ' {\n' +
+ ' "start": { "componentId": "arduino-uno", "pinName": "13" },\n' +
+ ' "end": { "componentId": "led-builtin", "pinName": "A" }\n' +
+ ' },\n' +
+ ' {\n' +
+ ' "start": { "componentId": "arduino-uno", "pinName": "GND" },\n' +
+ ' "end": { "componentId": "led-builtin", "pinName": "C" }\n' +
+ ' }\n' +
+ ' ]\n' +
+ '}\n' +
+ '---END_EXPECTED_WIRING---\n' +
'\n---KEY_TEXT---\n' +
'kata_kunci\n' +
'---END_KEY_TEXT---\n',
},
+ {
+ id: 'expected-wiring',
+ label: 'Expected Wiring',
+ group: 'set_soal',
+ snippet:
+ '\n---EXPECTED_WIRING---\n' +
+ '{\n' +
+ ' "wires": [\n' +
+ ' {\n' +
+ ' "start": { "componentId": "arduino-uno", "pinName": "13" },\n' +
+ ' "end": { "componentId": "led-builtin", "pinName": "A" }\n' +
+ ' }\n' +
+ ' ]\n' +
+ '}\n' +
+ '---END_EXPECTED_WIRING---\n',
+ },
{
id: 'set-flowchart',
label: 'Set Flowchart',
@@ -648,7 +677,7 @@
{#snippet saveActions()}
{#if mgr.activePath && !isAssetFile}
-
{:else if dynTab.id === 'flowchart'}