PaperBasicInfo
parent
7534893261
commit
82747a18ff
|
|
@ -0,0 +1,15 @@
|
||||||
|
-- =====================================================================
|
||||||
|
-- 变更说明:
|
||||||
|
-- 1. paper_question_rel 表新增 score(分值, decimal(5,1), 非空, 默认0.0)
|
||||||
|
-- 2. 存量数据回填:以试题库 question.score 初始化关系分值
|
||||||
|
-- 变更时间: 2026-08-20
|
||||||
|
-- =====================================================================
|
||||||
|
|
||||||
|
ALTER TABLE `paper_question_rel`
|
||||||
|
ADD COLUMN `score` decimal(5, 1) NOT NULL DEFAULT 0.0 COMMENT '分值' AFTER `question_id`;
|
||||||
|
|
||||||
|
-- 存量数据回填(如无需保留历史分值可跳过)
|
||||||
|
UPDATE `paper_question_rel` pqr
|
||||||
|
JOIN `question` q ON pqr.`question_id` = q.`id`
|
||||||
|
SET pqr.`score` = q.`score`
|
||||||
|
WHERE pqr.`delete_enum` = 'false';
|
||||||
|
|
@ -8,6 +8,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 试卷试题关系
|
* 试卷试题关系
|
||||||
*/
|
*/
|
||||||
|
|
@ -31,4 +33,7 @@ public class PaperQuestionRelDO extends BaseEntity {
|
||||||
|
|
||||||
@ApiModelProperty("试题号")
|
@ApiModelProperty("试题号")
|
||||||
private Integer questionNum;
|
private Integer questionNum;
|
||||||
|
|
||||||
|
@ApiModelProperty("分值")
|
||||||
|
private BigDecimal score;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,7 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperDO> implemen
|
||||||
|
|
||||||
// 创建试卷
|
// 创建试卷
|
||||||
PaperDO paper = new PaperDO();
|
PaperDO paper = new PaperDO();
|
||||||
|
paper.setPaperType(PaperTypeEnum.FIXED.getValue());
|
||||||
paper.setPaperName(importDTO.getPaperName().trim());
|
paper.setPaperName(importDTO.getPaperName().trim());
|
||||||
paper.setPaperTotalScore(importDTO.getPaperTotalScore());
|
paper.setPaperTotalScore(importDTO.getPaperTotalScore());
|
||||||
paper.setPaperPassScore(importDTO.getPaperPassScore());
|
paper.setPaperPassScore(importDTO.getPaperPassScore());
|
||||||
|
|
@ -280,6 +281,7 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperDO> implemen
|
||||||
PaperQuestionRelDO rel = new PaperQuestionRelDO();
|
PaperQuestionRelDO rel = new PaperQuestionRelDO();
|
||||||
rel.setPaperId(paper.getId());
|
rel.setPaperId(paper.getId());
|
||||||
rel.setQuestionId(questions.get(i).getId());
|
rel.setQuestionId(questions.get(i).getId());
|
||||||
|
rel.setScore(questions.get(i).getScore());
|
||||||
rel.setQuestionNum(i + 1);
|
rel.setQuestionNum(i + 1);
|
||||||
InsertFieldDefaults.applyIgnoreOrgId(rel);
|
InsertFieldDefaults.applyIgnoreOrgId(rel);
|
||||||
rels.add(rel);
|
rels.add(rel);
|
||||||
|
|
@ -296,8 +298,9 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperDO> implemen
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public PaperBasicInfoVO coursewareQuestionRule(PaperCoursewareQuestionRuleDTO dto) {
|
public PaperBasicInfoVO coursewareQuestionRule(PaperCoursewareQuestionRuleDTO dto) {
|
||||||
// 1. 循环题型规则从关联课件下随机抽题,某题型数量不足直接报错
|
// 1. 循环题型规则从关联课件下随机抽题,某题型数量不足直接报错;按题型规则初始化关系(试题id+每题分值+试题号)
|
||||||
List<Long> questionIds = new ArrayList<>();
|
List<PaperQuestionRelDO> rels = new ArrayList<>();
|
||||||
|
int questionNum = 1;
|
||||||
for (PaperConfigRuleDTO.QuestionTypeRule rule : dto.getQuestionTypeRuleList()) {
|
for (PaperConfigRuleDTO.QuestionTypeRule rule : dto.getQuestionTypeRuleList()) {
|
||||||
List<Long> ids = questionMapper.listRandomQuestionIds(
|
List<Long> ids = questionMapper.listRandomQuestionIds(
|
||||||
dto.getCoursewareManagementIdList(), rule.getQuestionType(), rule.getNum());
|
dto.getCoursewareManagementIdList(), rule.getQuestionType(), rule.getNum());
|
||||||
|
|
@ -307,7 +310,14 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperDO> implemen
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
typeDesc + "题数量不足:需要" + rule.getNum() + "道,当前仅有" + ids.size() + "道");
|
typeDesc + "题数量不足:需要" + rule.getNum() + "道,当前仅有" + ids.size() + "道");
|
||||||
}
|
}
|
||||||
questionIds.addAll(ids);
|
for (Long questionId : ids) {
|
||||||
|
PaperQuestionRelDO rel = new PaperQuestionRelDO();
|
||||||
|
rel.setQuestionId(questionId);
|
||||||
|
rel.setQuestionNum(questionNum++);
|
||||||
|
rel.setScore(rule.getScore());
|
||||||
|
InsertFieldDefaults.applyIgnoreOrgId(rel);
|
||||||
|
rels.add(rel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 创建试卷(规则试卷,保存抽题规则)
|
// 2. 创建试卷(规则试卷,保存抽题规则)
|
||||||
|
|
@ -321,16 +331,8 @@ public class PaperServiceImpl extends ServiceImpl<PaperMapper, PaperDO> implemen
|
||||||
InsertFieldDefaults.applyIgnoreOrgId(paper);
|
InsertFieldDefaults.applyIgnoreOrgId(paper);
|
||||||
this.savePaper(paper);
|
this.savePaper(paper);
|
||||||
|
|
||||||
// 3. 绑定试卷试题关系(含试题号)
|
// 3. 绑定试卷试题关系(回填试卷id后批量保存)
|
||||||
List<PaperQuestionRelDO> rels = new ArrayList<>(questionIds.size());
|
rels.forEach(rel -> rel.setPaperId(paper.getId()));
|
||||||
for (int i = 0; i < questionIds.size(); i++) {
|
|
||||||
PaperQuestionRelDO rel = new PaperQuestionRelDO();
|
|
||||||
rel.setPaperId(paper.getId());
|
|
||||||
rel.setQuestionId(questionIds.get(i));
|
|
||||||
rel.setQuestionNum(i + 1);
|
|
||||||
InsertFieldDefaults.applyIgnoreOrgId(rel);
|
|
||||||
rels.add(rel);
|
|
||||||
}
|
|
||||||
Db.saveBatch(rels);
|
Db.saveBatch(rels);
|
||||||
return paperConvertor.convertEToBasicVo(paper);
|
return paperConvertor.convertEToBasicVo(paper);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<mapper namespace="org.qinan.cedu.mapper.QuestionMapper">
|
<mapper namespace="org.qinan.cedu.mapper.QuestionMapper">
|
||||||
|
|
||||||
<select id="pagePaperQuestions" resultType="org.qinan.cedu.model.vo.PaperQuestionVO">
|
<select id="pagePaperQuestions" resultType="org.qinan.cedu.model.vo.PaperQuestionVO">
|
||||||
SELECT q.id, q.title, q.score, q.answer_question_option_ids, q.analysis
|
SELECT q.id, q.title, pqr.score, q.answer_question_option_ids, q.analysis
|
||||||
, q.question_type, q.tag_type, pqr.question_num,q.answer
|
, q.question_type, q.tag_type, pqr.question_num,q.answer
|
||||||
, cm.courseware_name
|
, cm.courseware_name
|
||||||
FROM paper_question_rel pqr
|
FROM paper_question_rel pqr
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ CREATE TABLE `paper_question_rel`
|
||||||
`id` bigint NOT NULL COMMENT 'id',
|
`id` bigint NOT NULL COMMENT 'id',
|
||||||
`paper_id` bigint NOT NULL COMMENT '试卷id',
|
`paper_id` bigint NOT NULL COMMENT '试卷id',
|
||||||
`question_id` bigint NOT NULL COMMENT '试题id',
|
`question_id` bigint NOT NULL COMMENT '试题id',
|
||||||
|
`score` decimal(5, 1) NOT NULL DEFAULT 0.0 COMMENT '分值',
|
||||||
`delete_enum` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '删除标识true false',
|
`delete_enum` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '删除标识true false',
|
||||||
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
|
`remarks` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '备注',
|
||||||
`create_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人姓名',
|
`create_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '创建人姓名',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue