Files
ALL-teach_sys/frontend_土木水利/update_profile_overview.py

186 lines
6.4 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import random
def update_profile_overview():
"""更新个人档案页面数据为葛荣景的信息"""
# 读取土木水利个人档案数据
with open('网页未导入数据/土木水利产业/土木水利个人档案.json', 'r', encoding='utf-8') as f:
civil_profiles = json.load(f)
# 读取头像列表
with open('网页未导入数据/头像列表.json', 'r', encoding='utf-8') as f:
avatars = json.load(f)
# 找到葛荣景的数据第4位
ge_rongjing = civil_profiles[3] # 索引3是第4个学生
# 创建个人档案数据
profile_data = {
"studentInfo": {
"name": ge_rongjing["学员名称"],
"realName": ge_rongjing["学员名称"],
"studentId": ge_rongjing["学号"],
"studentNo": ge_rongjing["学号"],
"avatar": avatars[3]["url"] if isinstance(avatars[3], dict) else avatars[3], # 使用第4个头像
"school": ge_rongjing["学校名称"],
"major": ge_rongjing["专业名称"],
"className": "土木水利班",
"grade": "2023级",
"studyPhase": "复合能力培养",
"stageName": ge_rongjing["垂直方向"],
"mbti": ge_rongjing["MBTI"],
"mbtiType": ge_rongjing["MBTI"],
"enrollmentDate": "2023-09-01",
"expectedGraduation": "2026-06-30",
"credits": int(ge_rongjing["学分"]),
"gpa": 4.5,
"classRank": int(ge_rongjing["班级排名"]),
"totalStudents": 45,
"myRank": {
"rank": int(ge_rongjing["班级排名"]),
"score": int(ge_rongjing["学分"])
}
},
"studyStatistics": {
"studyTime": {
"personal": 298,
"classAverage": 272
},
"courseCompletion": {
"personalProgress": 95,
"classAverageProgress": 89
},
"homeworkCompletion": {
"personalProgress": 98,
"classAverageProgress": 71
},
"attendance": {
"attendanceRate": 97,
"absenceRate": 3
},
"ranking": {
"study": {"rank": 4, "total": 45},
"attendance": {"rank": 5, "total": 45},
"homework": {"rank": 3, "total": 45}
}
},
"learningProgress": {
"overallProgress": 88,
"currentStage": "复合能力培养",
"stageProgress": 65,
"completedModules": [
"建筑力学基础",
"工程制图与CAD",
"建筑材料与构造",
"工程测量技术"
],
"ongoingModules": [
"施工技术与组织",
"工程造价管理",
"BIM技术应用",
"项目管理实务"
],
"upcomingModules": [
"实习实训",
"毕业设计"
]
},
"skills": [
"AutoCAD精通",
"BIM建模",
"工程测量",
"施工管理",
"造价预算",
"项目管理",
"质量控制",
"团队协作"
],
"certificates": [
{
"name": "BIM建模师证书",
"issueDate": "2024-10-15",
"issuer": "中国建设教育协会"
},
{
"name": "施工员证书",
"issueDate": "2024-11-20",
"issuer": "住房和城乡建设部"
}
],
"projects": [
{
"name": "苏州园林改造工程设计",
"role": "设计助理",
"period": "2024.09 - 2024.11",
"status": "已完成"
},
{
"name": "校园建筑BIM建模项目",
"role": "主要建模人员",
"period": "2024.10 - 至今",
"status": "进行中"
}
],
"ranking": {
"myRank": {
"rank": int(ge_rongjing["班级排名"]),
"score": int(ge_rongjing["学分"]),
"totalStudents": 45,
"trend": "up",
"change": 1
},
"classInfo": {
"className": "土木水利班",
"totalStudents": 45,
"averageScore": 78.5
},
"rankings": []
}
}
# 构建班级排名数据
for i, student in enumerate(civil_profiles[:10]):
ranking_item = {
"rank": i + 1,
"studentId": student["学号"],
"studentName": student["学员名称"],
"name": student["学员名称"],
"avatar": avatars[i]["url"] if i < len(avatars) and isinstance(avatars[i], dict) else (avatars[i] if i < len(avatars) else avatars[0]),
"score": int(student["学分"]),
"credits": int(student["学分"]),
"school": student["学校名称"],
"major": student["专业名称"],
"isMe": student["学员名称"] == "葛荣景"
}
profile_data["ranking"]["rankings"].append(ranking_item)
# 生成JavaScript代码
js_code = f"""// 更新个人档案数据 - 葛荣景
mockData.profileOverview = {json.dumps(profile_data, ensure_ascii=False, indent=2)};"""
print("生成的JavaScript代码预览")
print("=" * 50)
print(js_code[:1000])
print("..." if len(js_code) > 1000 else "")
print("=" * 50)
# 保存到文件
with open('profile_overview_update.js', 'w', encoding='utf-8') as f:
f.write(js_code)
print(f"\n✅ 个人档案数据已生成,保存在 profile_overview_update.js")
print(f"📋 数据包含:")
print(f" - 学生姓名: {ge_rongjing['学员名称']}")
print(f" - 学号: {ge_rongjing['学号']}")
print(f" - 学校: {ge_rongjing['学校名称']}")
print(f" - 专业: {ge_rongjing['专业名称']}")
print(f" - 班级排名: {ge_rongjing['班级排名']}")
print(f" - 学分: {ge_rongjing['学分']}")
print(f" - MBTI: {ge_rongjing['MBTI']}")
if __name__ == "__main__":
update_profile_overview()