From 66012130685af725f3a188b514a5bbe624c41d13 Mon Sep 17 00:00:00 2001 From: cat_shark <1716967236@qq.com> Date: Thu, 21 May 2026 16:26:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=86=99=E4=BD=9C=E7=B1=BB?= =?UTF-8?q?=E9=A2=98=E5=9E=8B=E7=9A=84=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ef_course_autopilot.py | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/ef_course_autopilot.py b/ef_course_autopilot.py index a579b8a..4bf9029 100755 --- a/ef_course_autopilot.py +++ b/ef_course_autopilot.py @@ -311,23 +311,33 @@ def build_response_categorisation(task: TaskInfo) -> dict: def build_response_writing_challenge(task: TaskInfo) -> dict: - """writing-challenge: 写作挑战 — 优先使用expectedResponse,否则提交占位文本""" + """writing-challenge: 写作挑战 — 优先使用expectedResponse,否则生成足够字数的占位文本""" expected = task.expected_response.get("contents", {}).get("writingChallenge", {}) - if expected: + if expected and expected.get("userInput", "").strip(): return {"writingChallenge": expected} - # 回退:提交一段较长占位文本(确保满足最低字数要求) + # 从task_detail获取字数要求 + min_words = task.task_detail.get("writingChallenge", {}).get("minWordCount", 20) + + # 生成满足最低字数要求的占位文本 + paragraph = ( + "I think this is a very interesting topic. There are many things " + "to consider when writing about this subject. First of all, it is " + "important to understand the main ideas and think carefully about " + "the best way to express your thoughts. In my opinion, practice " + "is the key to success and everyone should try their best to " + "improve their skills every day. This is why I believe that " + "learning English is very useful for communication with people " + "from different countries and cultures around the world." + ) + word_count = len(paragraph.split()) + if word_count < min_words: + repeat = (min_words // word_count) + 1 + paragraph = " ".join([paragraph] * repeat) + return { "writingChallenge": { - "userInput": ( - "I think this is a good topic. There are many things to consider " - "when writing about this subject. First of all, it is important to " - "understand the main ideas and think carefully about the best way to " - "express your thoughts. In my opinion, practice is the key to success " - "and everyone should try their best to improve their skills every day. " - "This is why I believe that learning English is very useful for " - "communication with people from different countries and cultures." - ), + "userInput": paragraph, } }