feat: add evaluation configuration support in lesson content and API
parent
7acce0b610
commit
7c069660f6
|
|
@ -336,3 +336,9 @@ const int
|
|||
Serial
|
||||
delay
|
||||
---END_KEY_TEXT---
|
||||
|
||||
---EVALUATION_CONFIG---
|
||||
{
|
||||
"timeout_ms": 10000
|
||||
}
|
||||
---END_EVALUATION_CONFIG---
|
||||
|
|
|
|||
|
|
@ -33,4 +33,5 @@ export interface LessonContent {
|
|||
language: string;
|
||||
language_display_name: string;
|
||||
active_tabs: string[];
|
||||
evaluation_config: Record<string, any>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue