From c6f958879ddfa6d58927d5b952d85dd2a2a86a06 Mon Sep 17 00:00:00 2001 From: dwindown Date: Fri, 3 Apr 2026 22:27:51 +0700 Subject: [PATCH] Accept exported option text in tryout snapshots --- app/services/tryout_json_import.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/services/tryout_json_import.py b/app/services/tryout_json_import.py index 4525e3d..7751841 100644 --- a/app/services/tryout_json_import.py +++ b/app/services/tryout_json_import.py @@ -72,7 +72,11 @@ def _extract_tryout_previews(payload: dict[str, Any]) -> list[tuple[str, dict[st def _normalize_question(question: dict[str, Any]) -> dict[str, Any]: raw_options = question.get("options") or [] - has_option_labels = any(bool((opt or {}).get("label")) for opt in raw_options if isinstance(opt, dict)) + has_option_labels = any( + bool(((opt or {}).get("text") or (opt or {}).get("label") or "").strip()) + for opt in raw_options + if isinstance(opt, dict) + ) normalized = { "source_question_id": str(question.get("id", "")), "title": str(question.get("title") or "").strip(), @@ -158,7 +162,7 @@ async def preview_tryout_json_import(payload: dict[str, Any], website_id: int, d warnings: list[str] = [] if missing_option_labels: warnings.append( - f"{missing_option_labels} question(s) have no visible option labels in the export; import will store raw reference data only." + f"{missing_option_labels} question(s) have no exported option text in the JSON; import will store raw reference data only." ) summary = QuestionDiffSummary(