Files
ALL-teach_sys/frontend_土木水利/update_remaining_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

85 lines
2.7 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
更新剩余的空questions数组
"""
import json
import re
from datetime import datetime
def update_remaining_questions():
# 读取面试题数据
with open('interview_questions_data.json', 'r', encoding='utf-8') as f:
interview_data = json.load(f)
# 读取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")}_remaining'
with open(backup_name, 'w', encoding='utf-8') as f:
f.write(content)
print(f"已创建备份: {backup_name}")
# 定义需要更新的岗位群映射
updates_map = {
"房地产经纪": "房地产经纪",
"工程采购": "工程采购",
"工程造价与资料管理": "工程造价与资料管理",
"建筑安装工程": "建筑安装工程",
"建筑工程检测": "建筑工程检测",
"建筑工程设计": "建筑工程设计",
"建筑施工与施工管理": "建筑施工与施工管理"
}
updated = 0
# 为每个岗位群更新questions
for job_group_name, data_key in updates_map.items():
if data_key not in interview_data:
print(f"未找到 {data_key} 的面试题数据")
continue
questions = interview_data[data_key]
if not questions:
continue
# 限制题目数量
max_questions = min(10, len(questions))
selected_questions = questions[:max_questions]
# 构建questions数组
questions_obj = [{
"id": f"group_{job_group_name}_q1",
"question": f"{job_group_name}面试题",
"subQuestions": selected_questions
}]
# 查找并替换
# 使用正则表达式查找该岗位群的questions字段
pattern = rf'("name":\s*"{re.escape(job_group_name)}"[^}}]*?"questions":\s*)\[\]'
def replace_func(match):
nonlocal updated
questions_json = json.dumps(questions_obj, ensure_ascii=False, indent=4)
# 调整缩进
questions_json = questions_json.replace('\n', '\n ')
updated += 1
return match.group(1) + questions_json
content = re.sub(pattern, replace_func, content, flags=re.DOTALL)
if updated > 0:
print(f"已更新: {job_group_name} ({len(selected_questions)} 道题)")
# 写回文件
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
f.write(content)
print(f"\n总共更新了 {updated} 个岗位群的面试题")
return updated
if __name__ == "__main__":
update_remaining_questions()