ai_member_xiaoyan/scripts/fix_components.py

175 lines
4.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""Fix component configs: clean wrong rows + write correct rows."""
import json, subprocess
TOKEN = "t-g1045kg0ZYXHLVSY7EFUPUJUOLBGTOLYLPDKWLYN"
SHEET_ID = "wMQVyV"
SPREADSHEET_TOKEN = "It4AsFkC7hXHc4te9yUcyLHRnOe"
# === STEP 1: Clean up wrongly written rows ===
clear_rows = [120, 129, 133, 144, 146, 147, 162, 163, 164, 178, 179]
for row in clear_rows:
body = {"valueRange": {"range": f"{SHEET_ID}!F{row}:F{row}", "values": [[""]]}}
result = subprocess.run([
"curl", "-s", "-X", "PUT",
f"https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/{SPREADSHEET_TOKEN}/values",
"-H", f"Authorization: Bearer {TOKEN}",
"-H", "Content-Type: application/json",
"-d", json.dumps(body, ensure_ascii=False)
], capture_output=True, text=True)
resp = json.loads(result.stdout)
print(f"CLEAR Row {row}: code={resp.get('code')}")
# === STEP 2: Fix rows with old 情境引入 (replace with 无) ===
fix_rows = {
# Row 119: 对话选择-配图 - change Eva 情境引入 to 无
119: """【任务标题】
查看关闭的门
【资源配置】
图片时机:
互动内容
互动反馈
【情境引入】
【互动内容】
要求:选择正确的回复
选项:(音频)
选项1Look, the door is closed.(正确)
- 反馈: 无
选项2Look, the door is open.
- 反馈 Eva: No, this door is closed. Look again.
【后置对话】
""",
# Row 128: 对话挖空-配图 - change Vicky 情境引入 to 无
128: """【任务标题】
还剩最后一扇门
【资源配置】
图片时机:
互动内容
互动反馈
【情境引入】
【互动内容】
Only one ___ left.(音频)
选项1door正确
选项2room
【互动反馈】
正确 Vicky : Yes! Just one more room.
错误 Vicky : Think about it. What do we open?
【后置对话】
""",
}
for row, content in sorted(fix_rows.items()):
body = {"valueRange": {"range": f"{SHEET_ID}!F{row}:F{row}", "values": [[content]]}}
result = subprocess.run([
"curl", "-s", "-X", "PUT",
f"https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/{SPREADSHEET_TOKEN}/values",
"-H", f"Authorization: Bearer {TOKEN}",
"-H", "Content-Type: application/json",
"-d", json.dumps(body, ensure_ascii=False)
], capture_output=True, text=True)
resp = json.loads(result.stdout)
print(f"FIX Row {row}: code={resp.get('code')}")
# === STEP 3: Write new content to empty rows ===
new_rows = {
# Row 152: 看图拼词 (1217413)
152: """【任务标题】
拼写 door 的英文
【资源配置】
图片文件名1217413.png
【互动内容】
任务描述:请拼出门的英文单词
题干d(2)r
答案oo
选项o, a, e, r, n, p
辅助信息:门的英文是 door / 中间有两个一样的字母哦
【后置对话】
""",
# Row 168: 对话挖空 (1217414)
168: """【任务标题】
回忆窗户的状态
【资源配置】无
【情境引入】
【互动内容】
I remember that. It was ___ before.(音频)
选项1closed正确
选项2open
【互动反馈】
正确 Alex : Yes, it was closed. But now it's different.
错误 Alex : No. Think about what I just said about the window.
【后置对话】
""",
# Row 169: 对话挖空 (1217415)
169: """【任务标题】
发现窗户现在是开着的
【资源配置】无
【情境引入】
【互动内容】
But now it's ___.(音频)
选项1open正确
选项2closed
【互动反馈】
正确 Alex : Right! Someone opened it!
错误 Alex : Look at the window again. Is it really closed now?
【后置对话】
""",
# Row 188: 对话朗读 (1217416)
188: """【任务标题】
问候 Grace 和 Dan
【资源配置】图片时机:无
【情境引入】无
【互动内容】
User : I'm glad you get home!(朗读)
【后置对话】
""",
}
for row, content in sorted(new_rows.items()):
body = {"valueRange": {"range": f"{SHEET_ID}!F{row}:F{row}", "values": [[content]]}}
result = subprocess.run([
"curl", "-s", "-X", "PUT",
f"https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/{SPREADSHEET_TOKEN}/values",
"-H", f"Authorization: Bearer {TOKEN}",
"-H", "Content-Type: application/json",
"-d", json.dumps(body, ensure_ascii=False)
], capture_output=True, text=True)
resp = json.loads(result.stdout)
print(f"WRITE Row {row}: code={resp.get('code')}")
print("\nDone! All operations completed.")