|
|
# 学生实验报告六模块同步 Implementation Plan
|
|
|
|
|
|
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
|
|
|
|
**Goal:** 让学生实验报告基于当前教学班的启用任务、AI 评分和六模块权重展示准确的成绩与任务明细。
|
|
|
|
|
|
**Architecture:** 后端新增 JWT 范围内的报告服务与只读接口;服务通过 `StudentTeachingClassResolver` 确定教学班,使用 `SchoolDefaultTaskService` 解析启用任务,并以 `StudentTrainingAnswer` 汇总模块分数。前端仅请求该接口,动态显示返回的六模块和任务明细,移除旧五模块、学习时长和访问次数数据流。
|
|
|
|
|
|
**Tech Stack:** Spring Boot、MyBatis、JUnit 5/Mockito、Vue 3、Vite、Node.js `assert`。
|
|
|
|
|
|
## Global Constraints
|
|
|
|
|
|
- 报告数据范围只由 JWT 当前学生及 `StudentTeachingClassResolver.resolveRequired` 决定,不接收客户端 `userId`、`schoolId` 或教学班 ID。
|
|
|
- 固定模块顺序为:互联网产品开发基础认知、市场洞察与需求分析、产品规划与设计、产品开发与测试验证、产品上线与运营推广、综合实训。
|
|
|
- 仅已启用、非 `TaskAllocation.PUBLICATION_MARKER` 的任务参与汇总;未评分任务按 0 分计入模块平均分。
|
|
|
- 默认权重为 10%、30%、10%、10%、20%、20%;报告不得调用旧五模块接口。
|
|
|
|
|
|
---
|
|
|
|
|
|
### Task 1: 后端六模块报告汇总服务
|
|
|
|
|
|
**Files:**
|
|
|
- Create: `src/main/java/com/sztzjy/linkCommerce/entity/dto/StudentExperimentReportDTO.java`
|
|
|
- Create: `src/main/java/com/sztzjy/linkCommerce/entity/dto/StudentExperimentReportModuleDTO.java`
|
|
|
- Create: `src/main/java/com/sztzjy/linkCommerce/entity/dto/StudentExperimentReportTaskDTO.java`
|
|
|
- Create: `src/main/java/com/sztzjy/linkCommerce/service/StudentExperimentReportService.java`
|
|
|
- Create: `src/main/java/com/sztzjy/linkCommerce/service/impl/StudentExperimentReportServiceImpl.java`
|
|
|
- Test: `src/test/java/com/sztzjy/linkCommerce/service/impl/StudentExperimentReportServiceImplTest.java`
|
|
|
|
|
|
**Interfaces:**
|
|
|
- Consumes: `StudentTeachingClassResolver.resolveRequired(JwtUser)`, `SchoolDefaultTaskService.resolveForTeachingClass(String)`, `TrainingTaskMapper.selectByTaskKey(String)`, `StudentTrainingAnswerMapper.selectByStudentClassAndTask(String,String,String)`, `TeachingClassScoreWeightMapper.selectByTeachingClassId(String)`。
|
|
|
- Produces: `StudentExperimentReportService.getCurrentReport(JwtUser)`,返回教学班名、排名、总分、`List<StudentExperimentReportModuleDTO>` 及 `List<StudentExperimentReportTaskDTO>`。
|
|
|
|
|
|
- [ ] **Step 1: 写出失败的服务测试**
|
|
|
|
|
|
```java
|
|
|
@Test
|
|
|
void reportUsesCurrentTeachingClassAndSixModuleDefaults() {
|
|
|
when(resolver.resolveRequired(student())).thenReturn("class-1");
|
|
|
when(taskService.resolveForTeachingClass("class-1")).thenReturn(Arrays.asList(allocation("task-a"), allocation("task-b")));
|
|
|
when(trainingTaskMapper.selectByTaskKey("task-a")).thenReturn(task("task-a", "市场洞察与需求分析", "需求访谈"));
|
|
|
when(trainingTaskMapper.selectByTaskKey("task-b")).thenReturn(task("task-b", "综合实训", "项目复盘"));
|
|
|
when(answerMapper.selectByStudentClassAndTask("student-1", "class-1", "task-a"))
|
|
|
.thenReturn(answer(80, true));
|
|
|
|
|
|
StudentExperimentReportDTO report = service.getCurrentReport(student());
|
|
|
|
|
|
assertEquals("class-1", report.getTeachingClassId());
|
|
|
assertEquals(6, report.getModules().size());
|
|
|
assertEquals(new BigDecimal("0.30"), module(report, "市场洞察与需求分析").getWeight());
|
|
|
assertEquals(new BigDecimal("80.00"), module(report, "市场洞察与需求分析").getScore());
|
|
|
assertEquals(new BigDecimal("0.00"), module(report, "综合实训").getScore());
|
|
|
assertEquals(1, report.getTasks().get(0).getCompletedTaskCount());
|
|
|
}
|
|
|
```
|
|
|
|
|
|
- [ ] **Step 2: 运行测试并确认失败**
|
|
|
|
|
|
Run: `mvn -q -Dtest=StudentExperimentReportServiceImplTest test`
|
|
|
|
|
|
Expected: FAIL,因为服务与 DTO 尚不存在。
|
|
|
|
|
|
- [ ] **Step 3: 实现 DTO 与最小汇总服务**
|
|
|
|
|
|
实现三个 DTO:
|
|
|
|
|
|
```java
|
|
|
class StudentExperimentReportDTO {
|
|
|
private String teachingClassId;
|
|
|
private String teachingClassName;
|
|
|
private Integer rank;
|
|
|
private BigDecimal totalScore;
|
|
|
private List<StudentExperimentReportModuleDTO> modules;
|
|
|
private List<StudentExperimentReportTaskDTO> tasks;
|
|
|
}
|
|
|
class StudentExperimentReportModuleDTO {
|
|
|
private String moduleName;
|
|
|
private BigDecimal weight;
|
|
|
private BigDecimal score;
|
|
|
private Integer completedTaskCount;
|
|
|
private Integer totalTaskCount;
|
|
|
}
|
|
|
class StudentExperimentReportTaskDTO {
|
|
|
private String taskName;
|
|
|
private String moduleName;
|
|
|
private String progressStatus;
|
|
|
private Boolean submitted;
|
|
|
private Integer aiAssessmentScore;
|
|
|
}
|
|
|
```
|
|
|
|
|
|
`getCurrentReport` 必须按顺序预建六个模块;对 `resolveForTeachingClass` 返回的任务过滤 `disabledStatus == 1` 与发布标记,查询任务定义和学生答案。每个启用任务都增加所属模块的任务数;`submitted == true` 或 `progressStatus == "COMPLETED"` 增加完成数;AI 分数为空按 0 加入模块总分。模块分数为模块任务分数之和除以任务数、保留两位。读取教学班权重,空记录仅使用默认值而不写数据库;总分为六模块分数乘权重之和、保留两位。通过当日 `StuRank` 的教学班与学生条件读取排名,未找到时排名为 `null`。
|
|
|
|
|
|
- [ ] **Step 4: 运行服务测试并确认通过**
|
|
|
|
|
|
Run: `mvn -q -Dtest=StudentExperimentReportServiceImplTest test`
|
|
|
|
|
|
Expected: PASS;覆盖默认权重、空 AI 分数、完成数与停用/发布标记过滤。
|
|
|
|
|
|
- [ ] **Step 5: 提交服务实现**
|
|
|
|
|
|
```bash
|
|
|
git add src/main/java/com/sztzjy/linkCommerce/entity/dto/StudentExperimentReport*.java src/main/java/com/sztzjy/linkCommerce/service/StudentExperimentReportService.java src/main/java/com/sztzjy/linkCommerce/service/impl/StudentExperimentReportServiceImpl.java src/test/java/com/sztzjy/linkCommerce/service/impl/StudentExperimentReportServiceImplTest.java
|
|
|
git commit -m "feat: add six-module student report service"
|
|
|
```
|
|
|
|
|
|
### Task 2: JWT 范围内的学生报告接口
|
|
|
|
|
|
**Files:**
|
|
|
- Create: `src/main/java/com/sztzjy/linkCommerce/controller/stu/StudentExperimentReportController.java`
|
|
|
- Test: `src/test/java/com/sztzjy/linkCommerce/controller/stu/StudentExperimentReportControllerTest.java`
|
|
|
|
|
|
**Interfaces:**
|
|
|
- Consumes: `StudentExperimentReportService.getCurrentReport(JwtUser)` 与 `TokenProvider.getJWTUser(HttpServletRequest)`。
|
|
|
- Produces: `GET /api/student/experiment-report/current`,返回 `ResultEntity<StudentExperimentReportDTO>`,无客户端范围参数。
|
|
|
|
|
|
- [ ] **Step 1: 写出失败的控制器测试**
|
|
|
|
|
|
```java
|
|
|
@Test
|
|
|
void currentReportDelegatesOnlyJwtStudent() {
|
|
|
JwtUser student = student();
|
|
|
StudentExperimentReportController controller = new StudentExperimentReportController() {
|
|
|
@Override
|
|
|
protected JwtUser currentUser(HttpServletRequest request) {
|
|
|
return student;
|
|
|
}
|
|
|
};
|
|
|
when(service.getCurrentReport(student)).thenReturn(new StudentExperimentReportDTO());
|
|
|
|
|
|
ResultEntity<StudentExperimentReportDTO> result = controller.current(request);
|
|
|
|
|
|
assertEquals(HttpStatus.OK, result.getStatusCode());
|
|
|
verify(service).getCurrentReport(student);
|
|
|
}
|
|
|
```
|
|
|
|
|
|
- [ ] **Step 2: 运行测试并确认失败**
|
|
|
|
|
|
Run: `mvn -q -Dtest=StudentExperimentReportControllerTest test`
|
|
|
|
|
|
Expected: FAIL,因为控制器路由尚不存在。
|
|
|
|
|
|
- [ ] **Step 3: 实现只读接口**
|
|
|
|
|
|
```java
|
|
|
@RestController
|
|
|
@RequestMapping("api/student/experiment-report")
|
|
|
public class StudentExperimentReportController {
|
|
|
@GetMapping("/current")
|
|
|
public ResultEntity<StudentExperimentReportDTO> current(HttpServletRequest request) {
|
|
|
JwtUser user = currentUser(request);
|
|
|
return new ResultEntity<>(HttpStatus.OK, "查询成功", reportService.getCurrentReport(user));
|
|
|
}
|
|
|
|
|
|
protected JwtUser currentUser(HttpServletRequest request) {
|
|
|
return TokenProvider.getJWTUser(request);
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
不要添加 `@AnonymousAccess`,不要接受 `userId`、`schoolId`、`classId` 请求参数;身份与教学班校验完全由服务使用 resolver 处理。
|
|
|
|
|
|
- [ ] **Step 4: 运行控制器与服务测试并确认通过**
|
|
|
|
|
|
Run: `mvn -q -Dtest=StudentExperimentReportControllerTest,StudentExperimentReportServiceImplTest test`
|
|
|
|
|
|
Expected: PASS。
|
|
|
|
|
|
- [ ] **Step 5: 提交接口实现**
|
|
|
|
|
|
```bash
|
|
|
git add src/main/java/com/sztzjy/linkCommerce/controller/stu/StudentExperimentReportController.java src/test/java/com/sztzjy/linkCommerce/controller/stu/StudentExperimentReportControllerTest.java
|
|
|
git commit -m "feat: expose current student experiment report"
|
|
|
```
|
|
|
|
|
|
### Task 3: 前端实验报告迁移
|
|
|
|
|
|
**Files:**
|
|
|
- Modify: `E:/workspace/dianshang/e-commerce-internet/src/api/index.js`
|
|
|
- Modify: `E:/workspace/dianshang/e-commerce-internet/src/views/test-report/index.vue`
|
|
|
- Create: `E:/workspace/dianshang/e-commerce-internet/tests/student-experiment-report.static.test.cjs`
|
|
|
|
|
|
**Interfaces:**
|
|
|
- Consumes: `getCurrentExperimentReport()`,请求 `GET /api/student/experiment-report/current`;响应 `data` 含 `totalScore`、`rank`、`modules`、`tasks`。
|
|
|
- Produces: 六模块成绩/权重/完成度表和任务明细表;不再请求 `getStuWeightScore`、`getUserVisitCount`、`getStudyTime`、`getUserRank`、`getStuModuleDetail`。
|
|
|
|
|
|
- [ ] **Step 1: 写出失败的前端契约检查**
|
|
|
|
|
|
```js
|
|
|
const assert = require("assert");
|
|
|
const fs = require("fs");
|
|
|
const path = require("path");
|
|
|
const root = path.resolve(__dirname, "..");
|
|
|
const api = fs.readFileSync(path.join(root, "src/api/index.js"), "utf8");
|
|
|
const page = fs.readFileSync(path.join(root, "src/views/test-report/index.vue"), "utf8");
|
|
|
|
|
|
assert(/getCurrentExperimentReport/.test(api));
|
|
|
assert(/\/api\/student\/experiment-report\/current/.test(api));
|
|
|
assert(/getCurrentExperimentReport/.test(page));
|
|
|
assert(/completedTaskCount/.test(page) && /totalTaskCount/.test(page));
|
|
|
assert(/aiAssessmentScore/.test(page) && /progressStatus/.test(page));
|
|
|
assert(!/getStuWeightScore|getUserVisitCount|getStudyTime|getUserRank|getStuModuleDetail/.test(page));
|
|
|
console.log("student experiment report static checks passed");
|
|
|
```
|
|
|
|
|
|
- [ ] **Step 2: 运行检查并确认失败**
|
|
|
|
|
|
Run: `node tests/student-experiment-report.static.test.cjs`
|
|
|
|
|
|
Expected: FAIL,因为新接口和动态六模块渲染尚未接入。
|
|
|
|
|
|
- [ ] **Step 3: 实现 API 与报告页面**
|
|
|
|
|
|
在 `src/api/index.js` 添加:
|
|
|
|
|
|
```js
|
|
|
export const getCurrentExperimentReport = () => request({
|
|
|
url: "/api/student/experiment-report/current",
|
|
|
method: "get",
|
|
|
});
|
|
|
```
|
|
|
|
|
|
将 `test-report/index.vue` 的旧五模块 `scoreItems`、访问次数、学习时长、旧接口请求与本地分析函数删除。加载时仅调用 `getCurrentExperimentReport()`,将 `data.modules` 作为成绩表数据、`data.tasks` 作为任务明细数据;成绩表显示模块名、权重百分比、分数、`completedTaskCount / totalTaskCount`,任务表显示任务名、模块、`progressStatus`、AI 评分。总分和排名取响应字段,学生信息继续取 `userStore`。
|
|
|
|
|
|
- [ ] **Step 4: 运行新增检查并确认通过**
|
|
|
|
|
|
Run: `node tests/student-experiment-report.static.test.cjs`
|
|
|
|
|
|
Expected: PASS,并输出 `student experiment report static checks passed`。
|
|
|
|
|
|
- [ ] **Step 5: 运行前端全量静态检查和生产构建**
|
|
|
|
|
|
Run: `Get-ChildItem -Path tests -Filter '*.cjs' | Sort-Object Name | ForEach-Object { node $_.FullName; if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } }`
|
|
|
|
|
|
Run: `npm run build:prod`
|
|
|
|
|
|
Expected: 所有静态检查和构建退出码为 0。
|
|
|
|
|
|
- [ ] **Step 6: 提交前端实现**
|
|
|
|
|
|
```bash
|
|
|
git add src/api/index.js src/views/test-report/index.vue tests/student-experiment-report.static.test.cjs
|
|
|
git commit -m "feat: update student experiment report modules"
|
|
|
```
|
|
|
|
|
|
### Task 4: 跨端回归
|
|
|
|
|
|
**Files:**
|
|
|
- Modify: none
|
|
|
|
|
|
**Interfaces:**
|
|
|
- Consumes: 已提交的后端接口和前端报告页。
|
|
|
- Produces: 通过 Maven 全量测试、前端静态检查和生产构建的合并候选。
|
|
|
|
|
|
- [ ] **Step 1: 运行后端全量测试**
|
|
|
|
|
|
Run: `mvn -q test`
|
|
|
|
|
|
Expected: PASS。
|
|
|
|
|
|
- [ ] **Step 2: 在前端重新运行全量静态检查**
|
|
|
|
|
|
Run: `Get-ChildItem -Path tests -Filter '*.cjs' | Sort-Object Name | ForEach-Object { node $_.FullName; if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } }`
|
|
|
|
|
|
Expected: PASS。
|
|
|
|
|
|
- [ ] **Step 3: 检查两个仓库的提交差异**
|
|
|
|
|
|
Run: `git diff --check HEAD~2..HEAD`
|
|
|
|
|
|
Expected: 无输出且退出码为 0。
|