Files
ALL-teach_sys/frontend_土木水利/remove_choice_questions.py
KQL cd2e307402 初始化12个产业教务系统项目
主要内容:
- 包含12个产业的完整教务系统前端代码
- 智能启动脚本 (start-industry.sh)
- 可视化产业导航页面 (index.html)
- 项目文档 (README.md)

优化内容:
- 删除所有node_modules和.yoyo文件夹,从7.5GB减少到2.7GB
- 添加.gitignore文件避免上传不必要的文件
- 自动依赖管理和智能启动系统

产业列表:
1. 文旅产业 (5150)
2. 智能制造 (5151)
3. 智能开发 (5152)
4. 财经商贸 (5153)
5. 视觉设计 (5154)
6. 交通物流 (5155)
7. 大健康 (5156)
8. 土木水利 (5157)
9. 食品产业 (5158)
10. 化工产业 (5159)
11. 能源产业 (5160)
12. 环保产业 (5161)

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-24 14:14:14 +08:00

125 lines
4.5 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
# -*- coding: utf-8 -*-
"""
移除所有选择题(答案为"请参考题目选项中的正确答案"或类似内容的题目)
"""
import json
import re
from datetime import datetime
def remove_choice_questions():
# 读取mock文件
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
content = f.read()
# 备份
backup_name = f'src/mocks/resumeInterviewMock.js.backup_{datetime.now().strftime("%Y%m%d_%H%M%S")}_before_remove_choice'
with open(backup_name, 'w', encoding='utf-8') as f:
f.write(content)
print(f"已创建备份: {backup_name}")
# 读取面试题数据,重新生成不包含选择题的数据
with open('interview_questions_data.json', 'r', encoding='utf-8') as f:
interview_data = json.load(f)
# 所有岗位群
all_job_groups = [
"BIM建筑信息模型",
"房地产经纪",
"工程采购",
"工程监理",
"工程造价与资料管理",
"建筑安装工程",
"建筑测量",
"建筑工程检测",
"建筑工程设计",
"建筑工程制图",
"建筑节能",
"建筑施工与施工管理",
"施工安全管理",
"室内设计",
"招投标管理"
]
lines = content.split('\n')
for job_group in all_job_groups:
if job_group not in interview_data:
continue
questions = interview_data[job_group]
if not questions:
continue
# 过滤掉选择题(答案是单字母或包含"选择题"关键词的)
filtered_questions = []
for q in questions:
# 跳过选择题
if (q.get("answer") and len(q["answer"]) == 1 and q["answer"] in 'ABCD'):
continue
if "选择题" in q.get("question", ""):
continue
if "以下哪" in q.get("question", ""):
continue
if "下列哪" in q.get("question", ""):
continue
# 清理题目文本
clean_q = {
"id": q["id"],
"question": re.sub(r'^(选择题|填空题|判断题|问答题|情景题|案例|模拟)[:]', '', q["question"]).strip(),
"answer": q["answer"]
}
filtered_questions.append(clean_q)
if not filtered_questions:
print(f"警告: {job_group} 移除选择题后没有剩余题目")
continue
# 构建新的questions对象
questions_obj = [{
"id": f"group_{job_group}_q1",
"question": f"{job_group}面试题",
"subQuestions": filtered_questions
}]
# 查找并替换
for i, line in enumerate(lines):
if f'"name": "{job_group}"' in line:
# 找到岗位群查找questions字段
for j in range(i, min(i + 300, len(lines))):
if '"questions":' in lines[j]:
# 找到questions开始位置
if '[' in lines[j]:
# 找到对应的结束位置
bracket_count = 1
end_line = j + 1
while end_line < len(lines) and bracket_count > 0:
if '[' in lines[end_line]:
bracket_count += lines[end_line].count('[')
if ']' in lines[end_line]:
bracket_count -= lines[end_line].count(']')
if bracket_count == 0:
break
end_line += 1
# 生成新的JSON
questions_json = json.dumps(questions_obj, ensure_ascii=False, indent=4)
indented_json = questions_json.replace('\n', '\n ')
# 替换
del lines[j:end_line+1]
lines.insert(j, ' "questions": ' + indented_json)
print(f"✓ 已更新: {job_group} (剩余 {len(filtered_questions)} 道非选择题)")
break
break
# 写回文件
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
f.write('\n'.join(lines))
print("\n完成!已移除所有选择题")
if __name__ == "__main__":
remove_choice_questions()