@@ -617,13 +617,29 @@ def _err(msg: str) -> Result:
617617
618618 # ── parse & validate inputs ──────────────────────────────────────────
619619
620+ # Parse response (student's graph)
621+ response_dict = _to_dictish (response ) or {}
622+
623+ # Check if response contains frontend pipe-delimited format and convert
624+ if is_frontend_format (response_dict ):
625+ parsed_graph = parse_frontend_graph (response_dict )
626+ response_dict = {"graph" : parsed_graph }
627+
620628 try :
621- resp = Response .model_validate (_to_dictish ( response ) or {} )
629+ resp = Response .model_validate (response_dict )
622630 except ValidationError as e :
623631 return _err (f"Invalid response schema: { e } " )
624632
633+ # Parse answer (teacher's reference)
634+ answer_dict = _to_dictish (answer ) or {}
635+
636+ # Check if answer contains frontend pipe-delimited format and convert
637+ if is_frontend_format (answer_dict ):
638+ parsed_graph = parse_frontend_graph (answer_dict )
639+ answer_dict = {"graph" : parsed_graph }
640+
625641 try :
626- ans = Answer .model_validate (_to_dictish ( answer ) or {} )
642+ ans = Answer .model_validate (answer_dict )
627643 except ValidationError as e :
628644 return _err (f"Invalid answer schema: { e } " )
629645
@@ -633,7 +649,7 @@ def _err(msg: str) -> Result:
633649 except ValidationError as e :
634650 if ans .graph is None :
635651 return _err (
636- "Testing: Invalid params schema. Expected e.g. "
652+ "Invalid params schema. Expected e.g. "
637653 "{'evaluation_type': 'connectivity'|'bipartite'|'graph_coloring'|...}. "
638654 f"Error: { e } "
639655 )
0 commit comments