From c9a9747f1082cae04a0ae0c28ec139bfba622865 Mon Sep 17 00:00:00 2001 From: Jingwen Tong Date: Wed, 22 Apr 2026 10:10:19 +0800 Subject: [PATCH 1/6] Update TEACHER_GUIDE.md --- TEACHER_GUIDE.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TEACHER_GUIDE.md b/TEACHER_GUIDE.md index 9ce88ca..71736e0 100644 --- a/TEACHER_GUIDE.md +++ b/TEACHER_GUIDE.md @@ -21,7 +21,7 @@ git init git add . git commit -m "初始化数字调制解调实验平台" git branch -M main -git remote add origin https://github.com/你的用户名/wireless-modulation-experiment.git +git remote add origin https://github.com/jwentong/wireless-modulation-experiment.git git push -u origin main ``` @@ -39,7 +39,7 @@ git push -u origin main **方法1**:使用私有子模块 ```bash # 将grading移到私有仓库 -git submodule add https://github.com/你的用户名/wireless-modulation-grading.git grading +git submodule add https://github.com/jwentong/wireless-modulation-grading.git grading ``` **方法2**:在学生 fork 后删除 grading/ @@ -49,7 +49,7 @@ git submodule add https://github.com/你的用户名/wireless-modulation-grading ```yaml - name: 拉取评分脚本 run: | - git clone https://github.com/教师/wireless-modulation-grading.git grading + git clone https://github.com/jwentong/wireless-modulation-grading.git grading ``` --- @@ -72,7 +72,7 @@ git submodule add https://github.com/你的用户名/wireless-modulation-grading 3. 预习实验指导:[链接] 实验模板仓库: -https://github.com/教师/wireless-modulation-experiment +https://github.com/jwentong/wireless-modulation-experiment 提交截止时间:2026年5月1日 23:59 From ccc1e270442a25fdf22ed8854aee744591416569 Mon Sep 17 00:00:00 2001 From: Jingwen Tong Date: Thu, 23 Apr 2026 20:28:16 +0800 Subject: [PATCH 2/6] Update grading.yml --- .github/workflows/grading.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/grading.yml b/.github/workflows/grading.yml index 2a546b7..014ebfb 100644 --- a/.github/workflows/grading.yml +++ b/.github/workflows/grading.yml @@ -13,7 +13,7 @@ jobs: steps: - name: 检出代码 - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 设置Python环境 uses: actions/setup-python@v4 From af744aa990e6270c90cf1fbf6afa612384c7e61f Mon Sep 17 00:00:00 2001 From: Jingwen Tong Date: Thu, 23 Apr 2026 20:35:30 +0800 Subject: [PATCH 3/6] Update grading.yml --- .github/workflows/grading.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/grading.yml b/.github/workflows/grading.yml index 014ebfb..4d5cd71 100644 --- a/.github/workflows/grading.yml +++ b/.github/workflows/grading.yml @@ -13,7 +13,7 @@ jobs: steps: - name: 检出代码 - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: 设置Python环境 uses: actions/setup-python@v4 @@ -73,7 +73,7 @@ jobs: cat grade_result.txt - name: 上传评分报告 - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: grading-report path: | From 895786b1f035522354c6fa4812b1361952d729d8 Mon Sep 17 00:00:00 2001 From: Jingwen Tong Date: Thu, 23 Apr 2026 20:53:25 +0800 Subject: [PATCH 4/6] Update grading.yml --- .github/workflows/grading.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/grading.yml b/.github/workflows/grading.yml index 4d5cd71..47a6643 100644 --- a/.github/workflows/grading.yml +++ b/.github/workflows/grading.yml @@ -10,6 +10,12 @@ on: jobs: grading: runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + issues: write + + steps: steps: - name: 检出代码 From 7d1c7d436394b187b5f39e00bcb0d680491bd4ec Mon Sep 17 00:00:00 2001 From: Jingwen Tong Date: Thu, 23 Apr 2026 21:01:06 +0800 Subject: [PATCH 5/6] Update grading.yml --- .github/workflows/grading.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/grading.yml b/.github/workflows/grading.yml index 47a6643..7487a72 100644 --- a/.github/workflows/grading.yml +++ b/.github/workflows/grading.yml @@ -19,7 +19,7 @@ jobs: steps: - name: 检出代码 - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: 设置Python环境 uses: actions/setup-python@v4 From 16b0c11ffe439d75153757fccabde23b960e5042 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 23 Apr 2026 22:30:21 +0800 Subject: [PATCH 6/6] =?UTF-8?q?fix:=20=E5=BD=BB=E5=BA=95=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?grading.yml-pull=5Frequest=5Ftarget+=E6=9D=83=E9=99=90+?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8D=87=E7=BA=A7+=E5=AD=A6=E7=94=9FID?= =?UTF-8?q?=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/grading.yml | 170 +++++++++++++++++----------------- 1 file changed, 87 insertions(+), 83 deletions(-) diff --git a/.github/workflows/grading.yml b/.github/workflows/grading.yml index 7487a72..ad5001d 100644 --- a/.github/workflows/grading.yml +++ b/.github/workflows/grading.yml @@ -1,87 +1,89 @@ -name: 自动评分系统 +name: 自动评分系统 on: - pull_request: + pull_request_target: types: [opened, synchronize, reopened] push: branches: - main +permissions: + contents: read + pull-requests: write + issues: write + jobs: grading: runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write - issues: write - - steps: - + timeout-minutes: 10 + steps: - name: 检出代码 uses: actions/checkout@v4 - + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: 设置Python环境 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.11' - + - name: 安装依赖 run: | python -m pip install --upgrade pip pip install -r requirements.txt - + - name: 运行环境测试 id: env_test continue-on-error: true run: | python src/test_environment.py - + - name: 运行BPSK测试 id: bpsk_test continue-on-error: true run: | python -m pytest grading/test_bpsk.py -v --tb=short > bpsk_result.txt 2>&1 cat bpsk_result.txt - + - name: 运行QPSK测试 id: qpsk_test continue-on-error: true run: | python -m pytest grading/test_qpsk.py -v --tb=short > qpsk_result.txt 2>&1 cat qpsk_result.txt - + - name: 运行16-QAM测试 id: qam_test continue-on-error: true run: | python -m pytest grading/test_qam16.py -v --tb=short > qam_result.txt 2>&1 cat qam_result.txt - + - name: 检查实验报告 id: report_check continue-on-error: true run: | python grading/check_report.py > report_result.txt 2>&1 cat report_result.txt - + - name: 代码质量检查 id: pylint_check continue-on-error: true run: | python -m pylint src/modulation.py --score=y > pylint_result.txt 2>&1 || true cat pylint_result.txt - + - name: 计算总评分 id: calculate_grade run: | python grading/calculate_grade.py > grade_result.txt 2>&1 cat grade_result.txt - + - name: 上传评分报告 uses: actions/upload-artifact@v4 with: - name: grading-report + name: grading-report-${{ github.event.pull_request.user.login || github.actor }} path: | grade_report.json grade_result.txt @@ -90,81 +92,83 @@ jobs: qam_result.txt report_result.txt pylint_result.txt - + - name: 评论PR - if: github.event_name == 'pull_request' - uses: actions/github-script@v6 + if: github.event_name == 'pull_request_target' + uses: actions/github-script@v7 with: script: | const fs = require('fs'); - - // 读取评分结果 + let gradeText = ''; try { gradeText = fs.readFileSync('grade_result.txt', 'utf8'); } catch (error) { gradeText = '评分系统运行失败,请检查代码。'; } - - // 构造评论内容 + + const student = context.payload.pull_request.user.login; + const comment = `## 🤖 自动评分结果 - - ${gradeText} - - --- - - ### 📊 详细测试结果 - -
- 点击查看BPSK测试详情 - - \`\`\` - ${fs.readFileSync('bpsk_result.txt', 'utf8').substring(0, 2000)} - \`\`\` - -
- -
- 点击查看QPSK测试详情 - - \`\`\` - ${fs.readFileSync('qpsk_result.txt', 'utf8').substring(0, 2000)} - \`\`\` - -
- -
- 点击查看16-QAM测试详情 - - \`\`\` - ${fs.readFileSync('qam_result.txt', 'utf8').substring(0, 2000)} - \`\`\` - -
- -
- 点击查看报告检查详情 - - \`\`\` - ${fs.readFileSync('report_result.txt', 'utf8').substring(0, 1000)} - \`\`\` - -
- - --- - - 💡 **提示**: - - 如果测试未通过,请查看上方的详细错误信息 - - 修改代码后重新提交会触发自动评分 - - 完整的评分报告可在 Actions 的 Artifacts 中下载 - - ⏰ **评分时间**: ${new Date().toLocaleString('zh-CN', {timeZone: 'Asia/Shanghai'})} - `; - - // 发布评论 + +**提交者**: @${student} + +\`\`\` +${gradeText} +\`\`\` + +--- + +### 📊 详细测试结果 + +
+点击查看BPSK测试详情 + +\`\`\` +${fs.readFileSync('bpsk_result.txt', 'utf8').substring(0, 2000)} +\`\`\` + +
+ +
+点击查看QPSK测试详情 + +\`\`\` +${fs.readFileSync('qpsk_result.txt', 'utf8').substring(0, 2000)} +\`\`\` + +
+ +
+点击查看16-QAM测试详情 + +\`\`\` +${fs.readFileSync('qam_result.txt', 'utf8').substring(0, 2000)} +\`\`\` + +
+ +
+点击查看报告检查详情 + +\`\`\` +${fs.readFileSync('report_result.txt', 'utf8').substring(0, 1000)} +\`\`\` + +
+ +--- + +💡 **提示**: +- 如果测试未通过,请查看上方的详细错误信息 +- 修改代码后重新提交会触发自动评分 +- 完整评分报告可在 Actions 的 Artifacts 中下载 + +⏰ **评分时间**: ${new Date().toLocaleString('zh-CN', {timeZone: 'Asia/Shanghai'})}`; + github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: comment - }); + }); \ No newline at end of file