Commit 43f7e17d authored by wujipeng's avatar wujipeng
Browse files

教师-智能考评-成绩管理-优化

parent 1cd768fc
......@@ -23,4 +23,7 @@ public class TeacherScoreExamQueryDTO {
@ApiModelProperty("考试名称关键字,最多100个字符")
private String keyword;
@ApiModelProperty("批阅状态:ALL/PENDING_REVIEW/PUBLISHED,默认ALL")
private String status;
}
......@@ -46,7 +46,7 @@ public final class AdminHomeVO {
/** 管理首页的一类聚合待办。 */
@Data
public static class Todo {
/** TEACHING_PLAN/EXAM_REVIEW/LEAVE_APPROVAL/EQUIPMENT_MAINTENANCE。 */
/** TEACHING_PLAN/LEAVE_APPROVAL/EQUIPMENT_MAINTENANCE。 */
private String type;
private String title;
private Integer count;
......
......@@ -26,6 +26,12 @@ public class TeacherScoreExamVO {
private Integer expectedCount;
private Integer actualCount;
@ApiModelProperty("批阅状态:PENDING_REVIEW/PUBLISHED")
private String reviewStatus;
@ApiModelProperty("本场考试成绩是否已经正式发布")
private Boolean published;
@ApiModelProperty("已交卷、成绩已正式发布且成绩非空的学员数")
private Integer publishedScoreCount;
......
......@@ -11,6 +11,7 @@ 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.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -25,13 +26,15 @@ import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* 教师端-教学管理-阅卷管理
* 教师端“智能考评-成绩管理”批阅接口。
*
* <p>所有接口均从 Authorization 令牌解析当前教师,不接受客户端传入 teacherId;服务层
* 还会校验当前教师必须是考试配置的首席考评员,形成身份与业务归属两层访问控制。</p>
* <p>新接口统一挂在教师成绩管理路径下;旧的 {@code /exam/review} 路径暂时保留为兼容别名,
* 避免已对接的教师阅卷页面立即失效。无论使用哪个路径,控制器都会校验“教师”角色,服务层
* 还会校验当前教师必须是考试配置的首席考评员,管理员因此不能调用任何评分或发布接口。</p>
*/
@Api(tags = "教师端-成绩管理-批阅")
@RestController
@RequestMapping("/exam/review")
@RequestMapping({"/exam/teacher/scores/review", "/exam/review"})
public class ExamReviewController extends BaseController {
@Resource
......@@ -46,7 +49,7 @@ public class ExamReviewController extends BaseController {
HttpServletRequest request) {
ExamReviewTaskQueryDTO safeQuery = query == null ? new ExamReviewTaskQueryDTO() : query;
normalizePage(safeQuery);
UserEntity teacher = authenticatedUserService.current(request);
UserEntity teacher = currentTeacher(request);
startPage(safeQuery.getPageNum(), safeQuery.getPageSize());
return getDataTable(examReviewService.queryTasks(safeQuery, teacher.getId()));
}
......@@ -57,7 +60,7 @@ public class ExamReviewController extends BaseController {
HttpServletRequest request) {
ExamReviewStudentQueryDTO safeQuery = query == null ? new ExamReviewStudentQueryDTO() : query;
normalizePage(safeQuery);
UserEntity teacher = authenticatedUserService.current(request);
UserEntity teacher = currentTeacher(request);
startPage(safeQuery.getPageNum(), safeQuery.getPageSize());
return getDataTable(examReviewService.queryStudents(safeQuery, teacher.getId()));
}
......@@ -66,7 +69,7 @@ public class ExamReviewController extends BaseController {
@GetMapping("/students/{examStudentId}/paper")
public Result<ExamReviewPaperVO> paper(@PathVariable Integer examStudentId,
HttpServletRequest request) {
UserEntity teacher = authenticatedUserService.current(request);
UserEntity teacher = currentTeacher(request);
return Result.data(examReviewService.paper(examStudentId, teacher.getId()));
}
......@@ -75,14 +78,14 @@ public class ExamReviewController extends BaseController {
public Result<ExamReviewPaperVO> saveScores(@PathVariable Integer examStudentId,
@RequestBody ExamReviewSaveDTO body,
HttpServletRequest request) {
UserEntity teacher = authenticatedUserService.current(request);
UserEntity teacher = currentTeacher(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);
UserEntity teacher = currentTeacher(request);
return Result.data(examReviewService.publish(examId, teacher.getId()));
}
......@@ -90,10 +93,20 @@ public class ExamReviewController extends BaseController {
@GetMapping("/students/{examStudentId}/history")
public Result<List<ExamReviewRecordVO>> history(@PathVariable Integer examStudentId,
HttpServletRequest request) {
UserEntity teacher = authenticatedUserService.current(request);
UserEntity teacher = currentTeacher(request);
return Result.data(examReviewService.history(examStudentId, teacher.getId()));
}
/**
* 统一解析 JWT 并校验教师角色。不能只依赖考试的 chief_id 归属,因为角色校验失败时
* 应在进入阅卷业务之前立即拒绝,确保管理员端不存在可用的批阅写能力。
*/
private UserEntity currentTeacher(HttpServletRequest request) {
UserEntity teacher = authenticatedUserService.current(request);
authenticatedUserService.requireTeacher(teacher);
return teacher;
}
/**
* 统一分页边界,既避免非法页码,也限制一次查询过多数据拖慢阅卷工作台。
*/
......
......@@ -28,7 +28,7 @@ import java.util.List;
* 教师端“智能考评-成绩管理”接口。
*
* <p>所有入口都从 Authorization 解析当前教师,不提供 teacherId 请求参数;考试归属
* 还会在 Mapper 层按 chief_id 再次过滤,确保教师只能读取本人主考的正式成绩。</p>
* 还会在 Mapper 层按 chief_id 再次过滤,确保教师只能读取本人主考的待批阅或正式成绩。</p>
*/
@Api(tags = "教师端-成绩管理")
@RestController
......@@ -47,7 +47,7 @@ public class TeacherScoreController extends BaseController {
return Result.data(teacherScoreService.classes(currentTeacherId(request)));
}
@ApiOperation("本人主考的已发布历史考试分页列表")
@ApiOperation("本人主考的已结束考试分页列表(含待批阅和已发布)")
@PostMapping("/exams/page")
public TableDataInfo exams(@RequestBody(required = false) TeacherScoreExamQueryDTO query,
HttpServletRequest request) {
......
......@@ -26,8 +26,12 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
/**
* 教师端成绩查询与导出实现。
......@@ -40,6 +44,12 @@ public class TeacherScoreServiceImpl implements TeacherScoreService {
private static final int MAX_KEYWORD_LENGTH = 100;
private static final String STATUS_ALL = "ALL";
private static final String STATUS_PENDING = "PENDING_REVIEW";
private static final String STATUS_PUBLISHED = "PUBLISHED";
private static final Set<String> REVIEW_STATUSES = new HashSet<>(Arrays.asList(
STATUS_ALL, STATUS_PENDING, STATUS_PUBLISHED));
private static final String[] EXPORT_HEADERS = {
"序号", "考试名称", "考试类型", "班级", "学员姓名", "身份证号",
"参考状态", "成绩", "等级", "是否及格", "交卷时间", "答题时长"
......@@ -68,7 +78,7 @@ public class TeacherScoreServiceImpl implements TeacherScoreService {
@Override
@Transactional(readOnly = true)
public TeacherScoreExamVO exam(Integer examId, String teacherId) {
return requireOwnedPublishedExam(examId, teacherId);
return requireOwnedEndedExam(examId, teacherId);
}
@Override
......@@ -87,7 +97,7 @@ public class TeacherScoreServiceImpl implements TeacherScoreService {
* 先执行真正的学员列表查询。列表为空后再查考试归属,既不会吞掉分页设置,又能
* 区分“合法考试暂无匹配学员”和“考试不存在或越权”。
*/
requireOwnedPublishedExam(examId, safeTeacherId);
requireOwnedEndedExam(examId, safeTeacherId);
// result 可能是 PageHelper 的空 Page,必须原样返回以保留总记录数等分页元数据。
return result == null ? Collections.emptyList() : result;
}
......@@ -123,6 +133,12 @@ public class TeacherScoreServiceImpl implements TeacherScoreService {
requirePositiveId(query.getClassId(), "班级ID");
}
query.setKeyword(normalizeKeyword(query.getKeyword(), "考试名称关键字"));
String status = StringUtils.hasText(query.getStatus())
? query.getStatus().trim().toUpperCase(Locale.ROOT) : STATUS_ALL;
if (!REVIEW_STATUSES.contains(status)) {
throw new BusinessException("批阅状态只能是ALL、PENDING_REVIEW或PUBLISHED");
}
query.setStatus(status);
}
/** 清洗学员列表关键字;分页边界由 Controller 在启动 PageHelper 前统一处理。 */
......@@ -134,10 +150,10 @@ public class TeacherScoreServiceImpl implements TeacherScoreService {
}
/**
* 只返回当前教师本人主考、已经结束且正式发布的考试。
* Mapper 将不存在、未结束、未发布和不属于本人统一查询为空,避免暴露其他考试状态。
* 只返回当前教师本人主考且已经结束的考试,待批阅场次也允许进入成绩管理。
* Mapper 将不存在、未结束和不属于本人统一查询为空,避免通过考试 ID 探测他人数据。
*/
private TeacherScoreExamVO requireOwnedPublishedExam(Integer examId, String teacherId) {
private TeacherScoreExamVO requireOwnedEndedExam(Integer examId, String teacherId) {
requirePositiveId(examId, "考试ID");
String safeTeacherId = requireTeacherId(teacherId);
TeacherScoreExamVO exam = teacherScoreMapper.findExam(examId, safeTeacherId);
......@@ -147,6 +163,15 @@ public class TeacherScoreServiceImpl implements TeacherScoreService {
return exam;
}
/** 导出只允许正式成绩;待批阅场次可在页面查看,但不能生成带暂存分的成绩单。 */
private TeacherScoreExamVO requireOwnedPublishedExam(Integer examId, String teacherId) {
TeacherScoreExamVO exam = requireOwnedEndedExam(examId, teacherId);
if (!Boolean.TRUE.equals(exam.getPublished())) {
throw new BusinessException("本场考试成绩尚未正式发布,不能导出");
}
return exam;
}
private String requireTeacherId(String teacherId) {
if (!StringUtils.hasText(teacherId)) {
throw new BusinessException("当前教师身份无效");
......
......@@ -75,18 +75,16 @@
limit 6
</select>
<!-- 待办按业务类别聚合,零数量也返回,前端无需补齐固定卡片。 -->
<!--
管理员首页只保留管理员职责范围内的待办。试卷批阅由首席考评教师负责,因此这里
不再返回 EXAM_REVIEW,避免管理员端重新出现“去批阅”的错误入口。
-->
<select id="selectTodos" resultType="com.platform.business.model.vo.AdminHomeVO$Todo">
select 'TEACHING_PLAN' as type, '教案待审核' as title,
count(*) as count, 'admin-plan' as target, 3 as priority
from teaching_plan plan
where plan.status = 'PENDING' and coalesce(plan.del_flag, 0) = 0
union all
select 'EXAM_REVIEW', '试卷待批阅', count(distinct e.id), 'review', 4
from exam e
inner join exam_student attempt on attempt.exam_id = e.id
where coalesce(attempt.submit, 0) = 1 and coalesce(attempt.mark_flag, 0) = 0
union all
select 'LEAVE_APPROVAL', '请假待审批', count(*), 'leave', 2
from student_leave_application leave_application
where leave_application.status = 'PENDING'
......
......@@ -3,12 +3,11 @@
<mapper namespace="com.platform.business.mapper.TeacherScoreMapper">
<!--
成绩页面只展示已结束且考试主记录已经发布的考试。结束时间使用考试开始时间加时长
计算,避免仅按日期判断时把仍在进行的考试提前暴露到历史成绩页面。
成绩页面展示当前教师负责且已经结束的考试,包括待批阅和已发布场次。结束时间使用
考试开始时间加时长计算,避免仅按日期判断时把仍在进行的考试提前暴露到成绩页面。
-->
<sql id="visibleExamCondition">
e.chief_id = #{teacherId}
AND IFNULL(e.mark_flag, 0) = 1
AND DATE_ADD(e.exam_time, INTERVAL IFNULL(e.duration, 0) MINUTE) &lt;= NOW()
</sql>
......@@ -16,7 +15,7 @@
应考、实考与正式成绩是三个不同口径:
1. 应考统计全部 exam_student;
2. 实考只判断 submit;
3. 分数统计还要求学员 mark_flag 已发布且 score 非空。
3. 分数统计同时要求考试和学员 mark_flag 已发布且 score 非空。
这样历史异常数据或补交试卷不会把未发布分数混入最高分、平均分和及格率。
-->
<sql id="examSummaryColumns">
......@@ -32,41 +31,51 @@
COUNT(es.id) AS expectedCount,
COALESCE(SUM(CASE WHEN IFNULL(es.submit, 0) = 1 THEN 1 ELSE 0 END), 0) AS actualCount,
COALESCE(SUM(CASE
WHEN IFNULL(es.submit, 0) = 1
WHEN IFNULL(e.mark_flag, 0) = 1
AND IFNULL(es.submit, 0) = 1
AND IFNULL(es.mark_flag, 0) = 1
AND es.score IS NOT NULL THEN 1 ELSE 0
END), 0) AS publishedScoreCount,
MAX(CASE
WHEN IFNULL(es.submit, 0) = 1
WHEN IFNULL(e.mark_flag, 0) = 1
AND IFNULL(es.submit, 0) = 1
AND IFNULL(es.mark_flag, 0) = 1 THEN es.score
END) AS highestScore,
MIN(CASE
WHEN IFNULL(es.submit, 0) = 1
WHEN IFNULL(e.mark_flag, 0) = 1
AND IFNULL(es.submit, 0) = 1
AND IFNULL(es.mark_flag, 0) = 1 THEN es.score
END) AS lowestScore,
ROUND(AVG(CASE
WHEN IFNULL(es.submit, 0) = 1
WHEN IFNULL(e.mark_flag, 0) = 1
AND IFNULL(es.submit, 0) = 1
AND IFNULL(es.mark_flag, 0) = 1 THEN es.score
END), 1) AS averageScore,
CASE
WHEN SUM(CASE
WHEN IFNULL(es.submit, 0) = 1
WHEN IFNULL(e.mark_flag, 0) = 1
AND IFNULL(es.submit, 0) = 1
AND IFNULL(es.mark_flag, 0) = 1
AND es.score IS NOT NULL THEN 1 ELSE 0
END) = 0 THEN NULL
ELSE ROUND(
SUM(CASE
WHEN IFNULL(es.submit, 0) = 1
WHEN IFNULL(e.mark_flag, 0) = 1
AND IFNULL(es.submit, 0) = 1
AND IFNULL(es.mark_flag, 0) = 1
AND es.score IS NOT NULL
AND es.score &gt;= IFNULL(e.pass_score, 60) THEN 1 ELSE 0
END) * 100.0 /
SUM(CASE
WHEN IFNULL(es.submit, 0) = 1
WHEN IFNULL(e.mark_flag, 0) = 1
AND IFNULL(es.submit, 0) = 1
AND IFNULL(es.mark_flag, 0) = 1
AND es.score IS NOT NULL THEN 1 ELSE 0
END), 2)
END AS passRate
END AS passRate,
CASE WHEN IFNULL(e.mark_flag, 0) = 1
THEN 'PUBLISHED' ELSE 'PENDING_REVIEW' END AS reviewStatus,
CASE WHEN IFNULL(e.mark_flag, 0) = 1 THEN TRUE ELSE FALSE END AS published
</sql>
<sql id="examSummaryJoins">
......@@ -77,7 +86,7 @@
<sql id="examSummaryGroup">
GROUP BY e.id, e.class_id, e.name, e.type, c.name, e.exam_time, e.duration,
e.total_score, e.pass_score
e.total_score, e.pass_score, e.mark_flag
</sql>
<select id="queryClasses" resultType="com.platform.business.model.vo.TeacherScoreClassOptionVO">
......@@ -98,6 +107,12 @@
<if test="query.keyword != null and query.keyword != ''">
AND e.name LIKE CONCAT('%', #{query.keyword}, '%')
</if>
<if test="query.status == 'PUBLISHED'">
AND IFNULL(e.mark_flag, 0) = 1
</if>
<if test="query.status == 'PENDING_REVIEW'">
AND IFNULL(e.mark_flag, 0) = 0
</if>
<include refid="examSummaryGroup"/>
ORDER BY e.exam_time DESC, e.id DESC
</select>
......@@ -123,17 +138,20 @@
e.type AS examType,
CASE WHEN IFNULL(es.submit, 0) = 1 THEN TRUE ELSE FALSE END AS submitted,
CASE
WHEN IFNULL(es.submit, 0) = 1
WHEN IFNULL(e.mark_flag, 0) = 1
AND IFNULL(es.submit, 0) = 1
AND IFNULL(es.mark_flag, 0) = 1
AND es.score IS NOT NULL THEN TRUE ELSE FALSE
END AS published,
CASE
WHEN IFNULL(es.submit, 0) = 1
WHEN IFNULL(e.mark_flag, 0) = 1
AND IFNULL(es.submit, 0) = 1
AND IFNULL(es.mark_flag, 0) = 1 THEN es.score
ELSE NULL
END AS score,
CASE
WHEN IFNULL(es.submit, 0) = 0
WHEN IFNULL(e.mark_flag, 0) = 0
OR IFNULL(es.submit, 0) = 0
OR IFNULL(es.mark_flag, 0) = 0
OR es.score IS NULL THEN NULL
WHEN es.score &lt; IFNULL(e.pass_score, 60) THEN '不及格'
......@@ -142,7 +160,8 @@
ELSE '及格'
END AS grade,
CASE
WHEN IFNULL(es.submit, 0) = 0
WHEN IFNULL(e.mark_flag, 0) = 0
OR IFNULL(es.submit, 0) = 0
OR IFNULL(es.mark_flag, 0) = 0
OR es.score IS NULL THEN NULL
WHEN es.score &gt;= IFNULL(e.pass_score, 60) THEN TRUE ELSE FALSE
......@@ -158,7 +177,6 @@
LEFT JOIN class c ON c.id = es.class_id
WHERE es.exam_id = #{examId}
AND e.chief_id = #{teacherId}
AND IFNULL(e.mark_flag, 0) = 1
AND DATE_ADD(e.exam_time, INTERVAL IFNULL(e.duration, 0) MINUTE) &lt;= NOW()
</sql>
......
# 教师端阅卷管理接口
所有接口统一使用前缀 `/exam/review`,并从请求头 `Authorization` 中解析当前登录教师。
所有接口统一使用前缀 `/exam/teacher/scores/review`,并从请求头 `Authorization` 中解析当前登录教师,
同时校验账号具备“教师”角色。旧前缀 `/exam/review` 暂时作为兼容别名保留;管理员账号使用任一前缀
都会被拒绝。
客户端不能指定 `teacherId`;服务端仅允许考试字段 `chief_id` 为当前教师的任务被查询、评分或发布。
部署前请先执行 `src/main/resources/sql/exam_review.sql` 创建评分审计表。现有数据库还需包含项目原查询已经使用的
......@@ -8,7 +10,7 @@
## 1. 阅卷任务列表
`POST /exam/review/tasks/page`
`POST /exam/teacher/scores/review/tasks/page`
```json
{
......@@ -24,7 +26,7 @@
## 2. 阅卷工作台考生列表
`POST /exam/review/students/page`
`POST /exam/teacher/scores/review/students/page`
```json
{
......@@ -41,7 +43,7 @@
## 3. 获取考生试卷
`GET /exam/review/students/{examStudentId}/paper`
`GET /exam/teacher/scores/review/students/{examStudentId}/paper`
返回`examType`和考试类型对应的互斥明细。理论考试返回试卷元数据、题型汇总及`questions`;
实训考试返回第三方`practiceItems`,其中明细`id`用于后续保存评分,`basicScore`为第三方提供的
......@@ -50,7 +52,7 @@
## 4. 保存阅卷进度
`PUT /exam/review/students/{examStudentId}/scores`
`PUT /exam/teacher/scores/review/students/{examStudentId}/scores`
```json
{
......@@ -71,13 +73,13 @@
## 5. 发布成绩
`PUT /exam/review/tasks/{examId}/publish`
`PUT /exam/teacher/scores/review/tasks/{examId}/publish`
发布前会锁定本场考试及全部已交卷考生。理论考试校验试卷与主观题评分完整性;实训考试校验第三方明细存在并重新
汇总教师复核后的项目分数。随后更新`exam_student.score`并统一设置考生和考试的`mark_flag=1`,任一步失败都会回滚。
## 6. 评分追溯记录
`GET /exam/review/students/{examStudentId}/history`
`GET /exam/teacher/scores/review/students/{examStudentId}/history`
返回每次分数变化和最终发布操作,包括教师、题号、调整前后分数、评分说明及时间。教师只能查看本人阅卷任务中的记录。
......@@ -73,11 +73,11 @@
| `GET /home/admin/statistics` | 学员、班级、教师、考试 KPI |
| `GET /home/admin/classes` | 理论掌握率可筛选的未归档班级 |
| `GET /home/admin/theory-mastery?classId=1` | 最多 6 个一级知识点掌握率;不传班级统计全平台 |
| `GET /home/admin/todos` | 教案、阅卷、请假、设备维护四类待办 |
| `GET /home/admin/todos` | 教案、请假、设备维护三类管理员待办 |
| `GET /home/admin/class-status` | 待开班、进行中、已结课、已结业分布 |
| `GET /home/admin/student-activity` | 最近 7 天登录/答题人数及活跃摘要 |
待办类型固定为:`TEACHING_PLAN`、`EXAM_REVIEW`、`LEAVE_APPROVAL`、`EQUIPMENT_MAINTENANCE`。
待办类型固定为:`TEACHING_PLAN`、`LEAVE_APPROVAL`、`EQUIPMENT_MAINTENANCE`。试卷批阅只出现在教师首页,管理员首页不返回该待办。
班级状态固定为:`NOT_STARTED`、`ONGOING`、`FINISHED`、`GRADUATED`。有学员且所有学员账户均为 `GRADUATED/ARCHIVED` 时优先判定为已结业。
......
......@@ -2,7 +2,7 @@
管理端接口统一使用 `/exam/admin/scores` 前缀。每次请求都必须携带 `Authorization`,服务端从
JWT解析当前用户并校验 `phone_role.role_name=管理员`。本模块只提供查询和导出;评分与发布仍由
首席考评教师通过 `/exam/review` 完成。
首席考评教师通过 `/exam/teacher/scores/review` 完成。
部署前依次执行已有 `sql/exam_management.sql`、`sql/exam_review.sql`,再执行
`sql/student_score_management.sql`。
......
......@@ -11,10 +11,10 @@
## 统计口径
- 页面只展示已经结束且 `exam.mark_flag = 1` 的考试。
- 页面展示当前教师担任主考且已经结束的考试,包含待批阅和已发布场次。
- 应考人数:该场考试全部 `exam_student` 记录数。
- 实考人数:`exam_student.submit = 1` 的人数。
- 最高分、最低分、平均分:只统计已交卷、`exam_student.mark_flag = 1` 且成绩非空的记录,平均分保留一位小数。
- 最高分、最低分、平均分:只统计考试与学员成绩都已发布、已交卷且成绩非空的记录,平均分保留一位小数。
- 及格率:达到该场 `exam.pass_score` 的正式成绩人数 ÷ 正式成绩人数,保留两位小数。
- 没有正式成绩时,最高分、最低分、平均分和及格率均返回 `null`,不会返回误导性的零。
......@@ -22,7 +22,7 @@
`GET /exam/teacher/scores/classes`
只返回当前教师担任主考且存在已发布历史考试的班级:
只返回当前教师担任主考且存在已结束考试的班级:
```json
{
......@@ -45,11 +45,13 @@
"pageNum": 1,
"pageSize": 10,
"keyword": "月考",
"classId": 12
"classId": 12,
"status": "ALL"
}
```
`keyword` 和 `classId` 均可省略。返回项目统一 `TableDataInfo`,`rows` 中每项结构如下:
`keyword` 和 `classId` 均可省略。`status` 支持 `ALL/PENDING_REVIEW/PUBLISHED`,默认
`ALL`。返回项目统一 `TableDataInfo`,`rows` 中每项结构如下:
```json
{
......@@ -64,6 +66,8 @@
"passScore": 60,
"expectedCount": 32,
"actualCount": 31,
"reviewStatus": "PUBLISHED",
"published": true,
"publishedScoreCount": 31,
"highestScore": 96,
"lowestScore": 52,
......@@ -78,8 +82,9 @@
`GET /exam/teacher/scores/exams/{examId}`
返回结构与考试列表行一致,用于成绩详情页头部。考试不存在、不是当前教师主考、尚未
结束或成绩未发布时,统一提示“考试不存在或无权访问”,避免通过 ID 探测其他考试。
返回结构与考试列表行一致,用于成绩详情页头部。待批阅考试允许查看汇总和应考学员,
但未发布分数不会返回。考试不存在、不是当前教师主考或尚未结束时,统一提示
“考试不存在或无权访问”,避免通过 ID 探测其他考试。
## 4. 应考学员成绩分页
......@@ -126,4 +131,18 @@
`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,文件名为
“考试名称_成绩单.xlsx”。导出不受页面关键字和分页影响,包含全部应考学员;缺考人员
标记为“缺考”且成绩单元格留空。前端应按二进制 Blob 接收响应,并优先从
`Content-Disposition` 读取 UTF-8 文件名。
`Content-Disposition` 读取 UTF-8 文件名。待批阅考试禁止导出。
## 6. 批阅接口
批阅接口统一位于 `/exam/teacher/scores/review`:
- `POST /tasks/page`:分页查询当前教师的待批阅/已完成任务。
- `POST /students/page`:分页查询某场考试已交卷学员。
- `GET /students/{examStudentId}/paper`:获取理论答题或实训项目明细。
- `PUT /students/{examStudentId}/scores`:暂存主观题或实训项目评分。
- `PUT /tasks/{examId}/publish`:校验评分完整性并发布整场成绩。
- `GET /students/{examStudentId}/history`:查询评分追溯记录。
所有接口均从 JWT 获取当前用户,先校验“教师”角色,再校验考试 `chief_id` 归属。管理员
成绩管理 `/exam/admin/scores` 仍只有查询和导出,不提供评分、重评分或发布接口。
......@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
import java.io.InputStream;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
/** 确保三套首页动态SQL均能被MyBatis解析并注册。 */
......@@ -25,6 +26,12 @@ class HomeMapperXmlTest {
"com.platform.business.mapper.TeacherHomeMapper.selectTodayAttendance"));
assertTrue(configuration.hasStatement(
"com.platform.business.mapper.AdminHomeMapper.countSevenDayActiveStudents"));
// 批阅属于教师职责,管理员首页 SQL 不应再生成试卷待批阅入口。
String adminTodoSql = configuration.getMappedStatement(
"com.platform.business.mapper.AdminHomeMapper.selectTodos")
.getBoundSql(null).getSql().toUpperCase();
assertFalse(adminTodoSql.contains("EXAM_REVIEW"));
}
private static void parse(Configuration configuration, String resource) throws Exception {
......
......@@ -14,7 +14,7 @@ import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertTrue;
/** 教师成绩 SQL 的启动解析、教师归属限制和正式成绩统计口径测试。 */
/** 教师成绩 SQL 的启动解析、教师归属限制、待批阅可见性和正式成绩口径测试。 */
class TeacherScoreMapperXmlTest {
private static final String NAMESPACE = "com.platform.business.mapper.TeacherScoreMapper.";
......@@ -57,17 +57,33 @@ class TeacherScoreMapperXmlTest {
assertTrue(sql.contains("count(es.id) as expectedcount"));
assertTrue(sql.contains("es.submit"));
assertTrue(sql.contains("e.mark_flag"));
assertTrue(sql.contains("es.mark_flag"));
assertTrue(sql.contains("max(case"));
assertTrue(sql.contains("min(case"));
assertTrue(sql.contains("round(avg(case"));
assertTrue(sql.contains("es.score >= ifnull(e.pass_score, 60)"));
assertTrue(sql.contains("then null"));
assertTrue(sql.contains("pending_review"));
assertTrue(sql.contains("published"));
}
@Test
void pendingReviewFilterShouldKeepUnpublishedExamRowsVisible() throws Exception {
Configuration configuration = parse();
TeacherScoreExamQueryDTO query = new TeacherScoreExamQueryDTO();
query.setStatus("PENDING_REVIEW");
Map<String, Object> params = new HashMap<>();
params.put("teacherId", "teacher-1");
params.put("query", query);
String sql = compact(boundSql(configuration, "queryExams", params));
assertTrue(sql.contains("and ifnull(e.mark_flag, 0) = 0"));
}
private void assertVisibleExamProtection(String sql) {
assertTrue(sql.contains("e.chief_id = ?"));
assertTrue(sql.contains("ifnull(e.mark_flag, 0) = 1"));
assertTrue(sql.contains("date_add(e.exam_time"));
}
......
......@@ -47,6 +47,7 @@ class TeacherScoreServiceImplTest {
service.exams(query, " teacher-1 ");
assertEquals("月考", query.getKeyword());
assertEquals("ALL", query.getStatus());
assertNull(query.getClassId());
verify(teacherScoreMapper).queryExams("teacher-1", query);
}
......@@ -64,7 +65,7 @@ class TeacherScoreServiceImplTest {
}
@Test
void detailShouldHideMissingUnpublishedFutureAndOtherTeacherExamWithSameMessage() {
void detailShouldHideMissingFutureAndOtherTeacherExamWithSameMessage() {
when(teacherScoreMapper.findExam(7, "teacher-1")).thenReturn(null);
BusinessException error = assertThrows(BusinessException.class,
......@@ -95,6 +96,7 @@ class TeacherScoreServiceImplTest {
TeacherScoreExamVO exam = new TeacherScoreExamVO();
exam.setExamId(1);
exam.setExamName("污水一级月考");
exam.setPublished(true);
when(teacherScoreMapper.findExam(1, "teacher-1")).thenReturn(exam);
TeacherScoreStudentVO present = student("张三", true, true, BigDecimal.ZERO, false);
......@@ -126,6 +128,35 @@ class TeacherScoreServiceImplTest {
}
}
@Test
void pendingExamShouldBeVisibleButMustNotBeExported() {
TeacherScoreExamVO pending = new TeacherScoreExamVO();
pending.setExamId(2);
pending.setPublished(false);
pending.setReviewStatus("PENDING_REVIEW");
when(teacherScoreMapper.findExam(2, "teacher-1")).thenReturn(pending);
assertEquals("PENDING_REVIEW", service.exam(2, "teacher-1").getReviewStatus());
BusinessException error = assertThrows(BusinessException.class,
() -> service.exportExam(2, "teacher-1", new MockHttpServletResponse()));
assertEquals("本场考试成绩尚未正式发布,不能导出", error.getMessage());
}
@Test
void examQueryShouldValidateReviewStatus() {
TeacherScoreExamQueryDTO query = new TeacherScoreExamQueryDTO();
query.setStatus(" pending_review ");
when(teacherScoreMapper.queryExams("teacher-1", query))
.thenReturn(Collections.emptyList());
service.exams(query, "teacher-1");
assertEquals("PENDING_REVIEW", query.getStatus());
query.setStatus("REVIEWED_BY_ADMIN");
assertThrows(BusinessException.class, () -> service.exams(query, "teacher-1"));
}
private TeacherScoreStudentVO student(String name, boolean submitted, boolean published,
BigDecimal score, Boolean passed) {
TeacherScoreStudentVO student = new TeacherScoreStudentVO();
......
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