diff --git a/examples/content/traffic_light_arduino.md b/examples/content/traffic_light_arduino.md index 05bbe62..25ed3b8 100644 --- a/examples/content/traffic_light_arduino.md +++ b/examples/content/traffic_light_arduino.md @@ -336,3 +336,9 @@ const int Serial delay ---END_KEY_TEXT--- + +---EVALUATION_CONFIG--- +{ + "timeout_ms": 10000 +} +---END_EVALUATION_CONFIG--- diff --git a/frontend/src/lib/types/lesson.ts b/frontend/src/lib/types/lesson.ts index 6c645f5..030c29b 100644 --- a/frontend/src/lib/types/lesson.ts +++ b/frontend/src/lib/types/lesson.ts @@ -33,4 +33,5 @@ export interface LessonContent { language: string; language_display_name: string; active_tabs: string[]; + evaluation_config: Record; } diff --git a/frontend/src/routes/lesson/[slug]/+page.svelte b/frontend/src/routes/lesson/[slug]/+page.svelte index c6bb0b5..a8b777f 100644 --- a/frontend/src/routes/lesson/[slug]/+page.svelte +++ b/frontend/src/routes/lesson/[slug]/+page.svelte @@ -567,7 +567,8 @@ } if (type === 'velxio:compile_result' && e.data.success) { - setTimeout(() => handleVelxioSubmit(), 5000); + const timeout = data?.evaluation_config?.timeout_ms ?? 5000; + setTimeout(() => handleVelxioSubmit(), timeout); } }; window.addEventListener('message', onMessage); diff --git a/routes/lessons.py b/routes/lessons.py index 7496a4b..0f2a9f5 100644 --- a/routes/lessons.py +++ b/routes/lessons.py @@ -69,6 +69,15 @@ def api_lesson(filename): velxio_circuit = parsed_data.get('velxio_circuit', '') expected_serial_output = parsed_data.get('expected_serial_output', '') expected_wiring = parsed_data.get('expected_wiring', '') + + evaluation_config_raw = parsed_data.get('evaluation_config', '') + evaluation_config = {} + if evaluation_config_raw: + import json + try: + evaluation_config = json.loads(evaluation_config_raw) + except Exception: + pass if not initial_code: initial_code = ( @@ -119,6 +128,7 @@ def api_lesson(filename): 'velxio_circuit': velxio_circuit, 'expected_serial_output': expected_serial_output, 'expected_wiring': expected_wiring, + 'evaluation_config': evaluation_config, 'solution_code': solution_code, 'solution_circuit': solution_circuit, 'solution_python': solution_python, diff --git a/services/lesson_service.py b/services/lesson_service.py index 3cc8740..b492552 100644 --- a/services/lesson_service.py +++ b/services/lesson_service.py @@ -340,6 +340,9 @@ def render_markdown_content(file_path): expected_wiring, lesson_content = _extract_section( lesson_content, '---EXPECTED_WIRING---', '---END_EXPECTED_WIRING---') + evaluation_config, lesson_content = _extract_section( + lesson_content, '---EVALUATION_CONFIG---', '---END_EVALUATION_CONFIG---') + # Just use whichever initial code matched as the generic 'initial_code' for simplicity # if only one type exists, but return all as dictionary values. # Typically frontend uses 'initial_code' for legacy. @@ -381,6 +384,7 @@ def render_markdown_content(file_path): 'velxio_circuit': velxio_circuit, 'expected_serial_output': expected_serial_output, 'expected_wiring': expected_wiring, + 'evaluation_config': evaluation_config, 'active_tabs': active_tabs }