"src/main/java/com/git@gitlab.ruzhoukj.com:wujipeng/ops.git" did not exist on "9380abc7141dc92317cec99ad07bd03a8b84ed55"
Commit 98e0a708 authored by wujipeng's avatar wujipeng
Browse files

教师端-教学管理-阅卷管理

parent 8f8b9d12
package com.platform.business.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 阅卷工作台保存评分请求。
*
* <p>请求按考生维度提交,可只传本次发生变化的题目。服务端会校验每道题确实属于
* 当前考生、当前考试且为主观题,避免通过篡改题目ID修改其他试卷。</p>
*/
@Data
public class ExamReviewSaveDTO {
@ApiModelProperty(value = "需要保存的主观题评分", required = true)
private List<ExamReviewScoreItemDTO> scores;
}
package com.platform.business.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* 单道主观题的评分内容。
*/
@Data
public class ExamReviewScoreItemDTO {
@ApiModelProperty(value = "考生答题明细ID", required = true)
private String questionId;
@ApiModelProperty(value = "本题得分,必须在0至题目满分之间", required = true)
private BigDecimal score;
@ApiModelProperty(value = "可选评分说明,最多1000个字符")
private String comment;
}
package com.platform.business.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 阅卷工作台左侧考生列表查询条件。
*/
@Data
public class ExamReviewStudentQueryDTO {
@ApiModelProperty(value = "页码,从1开始", example = "1")
private int pageNum = 1;
@ApiModelProperty(value = "每页条数,最大100", example = "20")
private int pageSize = 20;
@ApiModelProperty(value = "考试ID", required = true)
private Integer examId;
@ApiModelProperty(value = "班级ID,用于校验前端从任务行传入的考试与班级关系", required = true)
private Integer classId;
@ApiModelProperty(value = "考生姓名、身份证号或所属单位关键字")
private String keyword;
}
package com.platform.business.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 教师端阅卷任务分页查询条件。
*/
@Data
public class ExamReviewTaskQueryDTO {
@ApiModelProperty(value = "页码,从1开始", example = "1")
private int pageNum = 1;
@ApiModelProperty(value = "每页条数,最大100", example = "10")
private int pageSize = 10;
@ApiModelProperty(value = "考试名称关键字")
private String keyword;
@ApiModelProperty(value = "阅卷状态:ALL、PENDING、COMPLETED", example = "PENDING")
private String status = "ALL";
}
......@@ -64,4 +64,15 @@ public class ExamEntity {
@ApiModelProperty(value = "考试状态")
@TableField(exist = false)
private Boolean status;
/**
* 阅卷发布标记。
*
* <p>false/null 表示本场考试仍处于待阅卷或阅卷暂存阶段,true 表示本场考试的
* 已交试卷均已发布成绩。该字段此前已在 ExamMapper.xml 中使用,这里补齐实体映射,
* 便于阅卷发布事务通过 MyBatis-Plus 安全更新。</p>
*/
@ApiModelProperty(value = "阅卷成绩是否已发布")
@TableField("mark_flag")
private Boolean markFlag;
}
package com.platform.business.model.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 阅卷评分审计记录。
*
* <p>每次教师保存发生变化的题目分数、以及最终发布考生成绩时,都会写入一条不可变记录。
* 该表只承担审计职责,当前有效分数仍以答题明细和考生考试记录为准,从而避免日志数据
* 参与核心成绩计算。</p>
*/
@Data
@TableName("exam_review_score_log")
public class ExamReviewScoreLogEntity {
@TableId(type = IdType.ASSIGN_ID)
private String id;
@ApiModelProperty("考试ID")
@TableField("exam_id")
private Integer examId;
@ApiModelProperty("考生考试记录ID")
@TableField("exam_student_id")
private Integer examStudentId;
@ApiModelProperty("答题明细ID;发布记录不对应单题时为空")
@TableField("question_id")
private String questionId;
@ApiModelProperty("阅卷教师ID")
@TableField("reviewer_id")
private String reviewerId;
@ApiModelProperty("变更前分数")
@TableField("previous_score")
private BigDecimal previousScore;
@ApiModelProperty("变更后分数")
@TableField("new_score")
private BigDecimal newScore;
@ApiModelProperty("操作类型:SAVE-保存评分,PUBLISH-发布成绩")
private String action;
@ApiModelProperty("评分说明")
@TableField("review_comment")
private String reviewComment;
@ApiModelProperty("操作时间")
@TableField("created_at")
private Date createdAt;
}
......@@ -50,6 +50,16 @@ public class ExamStudentEntity {
@ApiModelProperty(value = "是否交卷")
private Boolean submit;
/**
* 当前考生的阅卷发布标记。
*
* <p>评分暂存时不修改该字段;教师点击“发布”后才设置为 true,避免未完成的
* 主观题评分被当作正式成绩。项目已有查询 SQL 依赖 mark_flag,这里补齐实体字段。</p>
*/
@ApiModelProperty(value = "阅卷成绩是否已发布")
@TableField("mark_flag")
private Boolean markFlag;
@ApiModelProperty(value = "答题时长")
private String duration;
......
package com.platform.business.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 阅卷工作台单个考生的完整试卷数据。
*/
@Data
public class ExamReviewPaperVO {
private Integer examId;
private Integer classId;
private String examName;
private String className;
private String paperId;
private String paperName;
@ApiModelProperty("试卷总分")
private Double paperTotal;
@ApiModelProperty("考试时长,单位:分钟")
private Integer duration;
private ExamReviewStudentVO student;
private List<ExamReviewScoreSummaryVO> scoreSummaries;
private List<ExamReviewQuestionVO> questions;
@ApiModelProperty("当前已评分总分,未发布时仅供教师预览")
private Double currentTotalScore;
@ApiModelProperty("是否所有主观题均已评分")
private Boolean scoringCompleted;
@ApiModelProperty("成绩是否已经发布")
private Boolean published;
}
package com.platform.business.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 阅卷工作台右侧试卷中的单道题目。
*/
@Data
public class ExamReviewQuestionVO {
private String questionId;
private String sequence;
private String type;
private String problem;
private String optionA;
private String optionB;
private String optionC;
private String optionD;
private String optionE;
@ApiModelProperty("标准答案,仅阅卷教师端返回")
private String answer;
@ApiModelProperty("考生答案")
private String actualChoice;
@ApiModelProperty("题目满分")
private Double maxScore;
@ApiModelProperty("当前得分;客观题由系统判分,主观题由教师评分")
private Double actualScore;
private Boolean result;
private Boolean partiallyRight;
@ApiModelProperty("是否需要教师手动评分")
private Boolean manualScoreRequired;
@ApiModelProperty("是否已完成本题评分")
private Boolean reviewed;
}
package com.platform.business.model.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 返回给教师端的评分追溯记录。
*/
@Data
public class ExamReviewRecordVO {
private String id;
private String questionId;
private String questionSequence;
private String questionType;
private String reviewerId;
private String reviewerName;
private BigDecimal previousScore;
private BigDecimal newScore;
@ApiModelProperty("操作类型:SAVE、PUBLISH")
private String action;
private String reviewComment;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createdAt;
}
package com.platform.business.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 按题型汇总的打分情况,用于阅卷工作台中栏展示。
*/
@Data
public class ExamReviewScoreSummaryVO {
private String type;
private Integer questionCount;
private Integer reviewedCount;
private Double maxScore;
private Double actualScore;
@ApiModelProperty("该题型是否已全部完成评分")
private Boolean completed;
}
package com.platform.business.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 阅卷工作台考生列表及考生信息区数据。
*/
@Data
public class ExamReviewStudentVO {
@ApiModelProperty("考生考试记录ID")
private Integer examStudentId;
private Integer examId;
private Integer classId;
private String studentId;
private String studentName;
private String idCard;
@ApiModelProperty("所属单位/部门")
private String department;
private String className;
@ApiModelProperty("考试作答时间段")
private String answerTime;
@ApiModelProperty("正式发布后的总分;未发布时可能仍为系统自动判分结果")
private Double score;
@ApiModelProperty("主观题总数")
private Integer subjectiveCount;
@ApiModelProperty("已评分主观题数")
private Integer scoredSubjectiveCount;
@ApiModelProperty("是否已经发布成绩")
private Boolean published;
}
package com.platform.business.model.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* 教师端阅卷任务列表项。
*/
@Data
public class ExamReviewTaskVO {
private Integer examId;
private Integer classId;
private String examName;
private String className;
private String examType;
private String paperId;
private String paperName;
@ApiModelProperty("试卷总分")
private Double paperTotal;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
private Date examTime;
@ApiModelProperty("考试时长,单位:分钟")
private Integer duration;
@ApiModelProperty("按考试开始时间和时长计算出的阅卷任务截止时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
private Date deadline;
@ApiModelProperty("应考人数")
private Integer totalCount;
@ApiModelProperty("已交卷份数")
private Integer submittedCount;
@ApiModelProperty("已发布成绩份数")
private Integer reviewedCount;
@ApiModelProperty("待发布成绩份数")
private Integer pendingCount;
@ApiModelProperty("阅卷状态:PENDING、COMPLETED")
private String reviewStatus;
}
......@@ -131,6 +131,13 @@
<version>3.9.1.2184</version>
</plugin>
<!-- 使用支持 JUnit 5 的 Surefire,确保阅卷、消息中心等业务单元测试会被真正执行。 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
......
package com.platform.business.constant;
/**
* 阅卷管理状态及操作常量。
*
* <p>接口统一使用稳定的英文状态值,前端可自行映射“待阅卷/已阅卷”等中文文案,
* 避免数据库查询和展示文案耦合。</p>
*/
public final class ExamReviewConstants {
public static final String STATUS_ALL = "ALL";
public static final String STATUS_PENDING = "PENDING";
public static final String STATUS_COMPLETED = "COMPLETED";
public static final String ACTION_SAVE = "SAVE";
public static final String ACTION_PUBLISH = "PUBLISH";
public static final String SUBJECTIVE_TYPE = "主观题";
/** 单次保存题数上限,防止异常请求占用过多数据库行锁。 */
public static final int MAX_SCORE_BATCH_SIZE = 500;
private ExamReviewConstants() {
}
}
package com.platform.business.controller;
import com.platform.business.model.dto.ExamReviewSaveDTO;
import com.platform.business.model.dto.ExamReviewStudentQueryDTO;
import com.platform.business.model.dto.ExamReviewTaskQueryDTO;
import com.platform.business.model.entity.UserEntity;
import com.platform.business.model.vo.ExamReviewPaperVO;
import com.platform.business.model.vo.ExamReviewRecordVO;
import com.platform.business.service.AuthenticatedUserService;
import com.platform.business.service.ExamReviewService;
import com.platform.controller.BaseController;
import com.platform.model.resp.Result;
import com.platform.page.TableDataInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* 教师端“教学管理-阅卷管理”接口。
*
* <p>所有接口均从 Authorization 令牌解析当前教师,不接受客户端传入 teacherId;服务层
* 还会校验当前教师必须是考试配置的首席考评员,形成身份与业务归属两层访问控制。</p>
*/
@RestController
@RequestMapping("/exam/review")
public class ExamReviewController extends BaseController {
@Resource
private ExamReviewService examReviewService;
@Resource
private AuthenticatedUserService authenticatedUserService;
@ApiOperation("教师端-阅卷任务分页列表")
@PostMapping("/tasks/page")
public TableDataInfo taskPage(@RequestBody(required = false) ExamReviewTaskQueryDTO query,
HttpServletRequest request) {
ExamReviewTaskQueryDTO safeQuery = query == null ? new ExamReviewTaskQueryDTO() : query;
normalizePage(safeQuery);
UserEntity teacher = authenticatedUserService.current(request);
startPage(safeQuery.getPageNum(), safeQuery.getPageSize());
return getDataTable(examReviewService.queryTasks(safeQuery, teacher.getId()));
}
@ApiOperation("教师端-阅卷工作台考生分页列表")
@PostMapping("/students/page")
public TableDataInfo studentPage(@RequestBody ExamReviewStudentQueryDTO query,
HttpServletRequest request) {
ExamReviewStudentQueryDTO safeQuery = query == null ? new ExamReviewStudentQueryDTO() : query;
normalizePage(safeQuery);
UserEntity teacher = authenticatedUserService.current(request);
startPage(safeQuery.getPageNum(), safeQuery.getPageSize());
return getDataTable(examReviewService.queryStudents(safeQuery, teacher.getId()));
}
@ApiOperation("教师端-获取单个考生的阅卷试卷及打分汇总")
@GetMapping("/students/{examStudentId}/paper")
public Result<ExamReviewPaperVO> paper(@PathVariable Integer examStudentId,
HttpServletRequest request) {
UserEntity teacher = authenticatedUserService.current(request);
return Result.data(examReviewService.paper(examStudentId, teacher.getId()));
}
@ApiOperation("教师端-暂存单个考生的主观题评分")
@PutMapping("/students/{examStudentId}/scores")
public Result<ExamReviewPaperVO> saveScores(@PathVariable Integer examStudentId,
@RequestBody ExamReviewSaveDTO body,
HttpServletRequest request) {
UserEntity teacher = authenticatedUserService.current(request);
return Result.data(examReviewService.saveScores(examStudentId, body, teacher.getId()));
}
@ApiOperation("教师端-发布本场考试全部已交试卷的阅卷成绩")
@PutMapping("/tasks/{examId}/publish")
public Result<Boolean> publish(@PathVariable Integer examId, HttpServletRequest request) {
UserEntity teacher = authenticatedUserService.current(request);
return Result.data(examReviewService.publish(examId, teacher.getId()));
}
@ApiOperation("教师端-查看单个考生的评分追溯记录")
@GetMapping("/students/{examStudentId}/history")
public Result<List<ExamReviewRecordVO>> history(@PathVariable Integer examStudentId,
HttpServletRequest request) {
UserEntity teacher = authenticatedUserService.current(request);
return Result.data(examReviewService.history(examStudentId, teacher.getId()));
}
/**
* 统一分页边界,既避免非法页码,也限制一次查询过多数据拖慢阅卷工作台。
*/
private void normalizePage(ExamReviewTaskQueryDTO query) {
query.setPageNum(query.getPageNum() <= 0 ? 1 : query.getPageNum());
query.setPageSize(normalizePageSize(query.getPageSize(), 10));
}
private void normalizePage(ExamReviewStudentQueryDTO query) {
query.setPageNum(query.getPageNum() <= 0 ? 1 : query.getPageNum());
query.setPageSize(normalizePageSize(query.getPageSize(), 20));
}
private int normalizePageSize(int pageSize, int defaultSize) {
if (pageSize <= 0) {
return defaultSize;
}
return Math.min(pageSize, 100);
}
}
package com.platform.business.controller;
/**
* @Author: wujipeng
* @Description: TODO
* @Date: 2026/8/10 17:34
* @Version: 1.0
*/
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/mark/exam")
public class MarkExamController {
}
package com.platform.business.mapper;
import com.platform.business.model.dto.ExamReviewStudentQueryDTO;
import com.platform.business.model.dto.ExamReviewTaskQueryDTO;
import com.platform.business.model.entity.ExamEntity;
import com.platform.business.model.entity.ExamStudentEntity;
import com.platform.business.model.entity.TheoreticalPaperStudentDetailEntity;
import com.platform.business.model.vo.ExamReviewQuestionVO;
import com.platform.business.model.vo.ExamReviewRecordVO;
import com.platform.business.model.vo.ExamReviewStudentVO;
import com.platform.business.model.vo.ExamReviewTaskVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 阅卷管理专用数据访问层。
*
* <p>阅卷查询涉及考试、班级、考生和试题多表聚合,独立 Mapper 可避免继续扩大原有
* ExamMapper,同时把发布时需要的行锁 SQL 集中维护。</p>
*/
@Mapper
public interface ExamReviewMapper {
List<ExamReviewTaskVO> queryTasks(@Param("teacherId") String teacherId,
@Param("query") ExamReviewTaskQueryDTO query);
ExamReviewTaskVO findTask(@Param("examId") Integer examId,
@Param("teacherId") String teacherId);
ExamEntity lockTask(@Param("examId") Integer examId,
@Param("teacherId") String teacherId);
List<ExamReviewStudentVO> queryStudents(@Param("teacherId") String teacherId,
@Param("query") ExamReviewStudentQueryDTO query);
ExamReviewStudentVO findStudent(@Param("examStudentId") Integer examStudentId,
@Param("teacherId") String teacherId);
ExamStudentEntity lockStudent(@Param("examStudentId") Integer examStudentId,
@Param("teacherId") String teacherId);
List<ExamReviewQuestionVO> queryQuestions(@Param("examId") Integer examId,
@Param("studentId") String studentId);
List<TheoreticalPaperStudentDetailEntity> lockQuestions(
@Param("questionIds") List<String> questionIds,
@Param("examId") Integer examId,
@Param("studentId") String studentId);
int updateQuestionScore(@Param("questionId") String questionId,
@Param("actualScore") Double actualScore,
@Param("result") Boolean result,
@Param("partiallyRight") Boolean partiallyRight);
List<ExamStudentEntity> lockSubmittedStudents(@Param("examId") Integer examId);
int countSubmittedWithoutPaper(@Param("examId") Integer examId);
int countUnscoredSubjective(@Param("examId") Integer examId);
Double calculateStudentScore(@Param("examId") Integer examId,
@Param("studentId") String studentId);
int publishStudent(@Param("examStudentId") Integer examStudentId,
@Param("score") Double score);
int publishTask(@Param("examId") Integer examId);
List<ExamReviewRecordVO> queryHistory(@Param("examStudentId") Integer examStudentId);
}
package com.platform.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.platform.business.model.entity.ExamReviewScoreLogEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 评分审计日志写入 Mapper。
*/
@Mapper
public interface ExamReviewScoreLogMapper extends BaseMapper<ExamReviewScoreLogEntity> {
}
package com.platform.business.service;
import com.platform.business.model.dto.ExamReviewSaveDTO;
import com.platform.business.model.dto.ExamReviewStudentQueryDTO;
import com.platform.business.model.dto.ExamReviewTaskQueryDTO;
import com.platform.business.model.vo.ExamReviewPaperVO;
import com.platform.business.model.vo.ExamReviewRecordVO;
import com.platform.business.model.vo.ExamReviewStudentVO;
import com.platform.business.model.vo.ExamReviewTaskVO;
import java.util.List;
/**
* 教师端阅卷管理服务。
*/
public interface ExamReviewService {
List<ExamReviewTaskVO> queryTasks(ExamReviewTaskQueryDTO query, String teacherId);
List<ExamReviewStudentVO> queryStudents(ExamReviewStudentQueryDTO query, String teacherId);
ExamReviewPaperVO paper(Integer examStudentId, String teacherId);
ExamReviewPaperVO saveScores(Integer examStudentId, ExamReviewSaveDTO request, String teacherId);
boolean publish(Integer examId, String teacherId);
List<ExamReviewRecordVO> history(Integer examStudentId, String teacherId);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment