# Achievement Qztc

课程目标达成情况分析表生成工具。根据Excel学生数据替换Word模板中的课程目标达成情况，生成新的分析表。

- Repository: https://github.com/LeoYeAI/agent-master-skills (2171 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add LeoYeAI/agent-master-skills --skill achievement-qztc -g -a claude-code -y`
Codex: `npx skills add LeoYeAI/agent-master-skills --skill achievement-qztc -g -a codex -y`
Cursor: `npx skills add LeoYeAI/agent-master-skills --skill achievement-qztc -g -a cursor -y`
Gemini CLI: `npx skills add LeoYeAI/agent-master-skills --skill achievement-qztc -g -a gemini-cli -y`

## Description

课程目标达成情况分析表生成工具。根据Excel学生数据替换Word模板中的课程目标达成情况，生成新的分析表。

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 课程目标达成情况分析表生成工具（QZTC版）

根据Excel学生数据替换Word模板中的课程目标达成情况，生成新的分析表。

## 适用场景

- 根据Excel学生名单生成课程目标达成情况分析表
- 自动计算各课程目标的达成值（随机生成成绩，百分比表示）

---

## 文件路径

- **模板文件**: `/Volumes/qztcm09/Desktop/temp/课程目标达成情况分析表-数据可视化-模版.docx`
- **Excel数据**: `/Volumes/qztcm09/Desktop/temp/数据可视化技术23级计算机.xls`

---

## 使用步骤

### 步骤1：读取Excel数据

```python
import pandas as pd
import shutil
import random
from docx import Document
from datetime import datetime

# 读取Excel
df = pd.read_excel('/Users/qztcm09/Desktop/temp/数据可视化技术23级计算机.xls')

# 排除旷考学生
df = df[df['备注'] != '旷考'].reset_index(drop=True)

# 自动判断当前学年和学期
now = datetime.now()
year = now.year
month = now.month
day= now.day

if 1 <= month <= 6:
    # 1-6月：第一学期（上学年）
    academic_year = f"{year-1} - {year}"
    semester = "一"
else:
    # 7-12月：第二学期（上学年）
    academic_year = f"{year-1} - {year}"
    semester = "二"

print(f"当前学年: {academic_year}, 学期: {semester}学期")

# 从"班级"字段提取年级、班级、专业信息
# 专业名称提取支持两种情况：
#   情况1: "23级计算机" → 年级=23, 专业=计算机
#   情况2: "23级软工2班" → 年级=23, 专业=软工
import re
class_name = df['班级'].iloc[0] if '班级' in df.columns else ''
match = re.search(r'(\d+)级', str(class_name))
grade = match.group(1) if match else ''  # 如 "23"
# 提取专业：匹配 "XX级" 后面到 "XX班" 或结尾的部分
match = re.search(r'\d+级(.+?)(?:\d+班)?$', str(class_name))
major = match.group(1).strip() if match else ''  # 如 "计算机" 或 "软工"


# 获取学生信息
students = df[['学号', '姓名']].copy()
print(f"学生人数: {len(students)}")
```

### 步骤2：复制模板并打开

```python
template_path = '/Users/qztcm09/Desktop/temp/课程目标达成情况分析表-数据可视化-模版.docx'
output_path = '/Users/qztcm09/Desktop/temp/课程目标达成情况分析表-数据可视化-23级计算机.docx'

shutil.copy(template_path, output_path)
doc = Document(output_path)
```

### 步骤3：通用文本替换

**⚠️ 重要：Word占位符可能被拆分成多个run，且表格单元格中可能有换行，需要特殊处理，保留原格式**

The rest: https://github.com/LeoYeAI/agent-master-skills/blob/HEAD/skills/achievement-qztc/SKILL.md
