Commit ddc84c18 by Wangmin

答题完成修改开始记录状态、新增检查答题卡完整性

parent b6211781
...@@ -70,5 +70,16 @@ public class TestPaperController extends BaseController { ...@@ -70,5 +70,16 @@ public class TestPaperController extends BaseController {
return toAjax(testPaperService.paperTestEnd(bo)); return toAjax(testPaperService.paperTestEnd(bo));
} }
/**
* [小程序端]检查答题卡完整性
*
* @param recordId 答题记录ID
* @return 结果
*/
@Log(title = "检车答题卡完整性", businessType = BusinessType.OTHER)
@GetMapping("/check/{recordId}")
public R<Boolean> checkIntegrality(@PathVariable Long recordId) {
return R.ok(testPaperService.checkTestPaperIntegrality(recordId));
}
} }
...@@ -36,9 +36,10 @@ public class DbTestPaperRecord extends BaseEntity { ...@@ -36,9 +36,10 @@ public class DbTestPaperRecord extends BaseEntity {
/** /**
* 状态 * 状态
* <ul> * <ul>
* <ol>0:正在答题</ol> * <ol>0:答题中</ol>
* <ol>1:待批阅</ol> * <ol>1:待批阅</ol>
* <ol>2:已批阅</ol> * <ol>2:批阅中</ol>
* <ol>3:批阅完成</ol>
* </ul> * </ul>
*/ */
private Integer status; private Integer status;
......
...@@ -39,7 +39,6 @@ public class DbTestPaperRecordDetail extends BaseEntity { ...@@ -39,7 +39,6 @@ public class DbTestPaperRecordDetail extends BaseEntity {
* 答案 * 答案
*/ */
private String answer; private String answer;
/** /**
* 图片答案 * 图片答案
*/ */
......
...@@ -48,7 +48,7 @@ public class DbTestPaperRecordDetailVo { ...@@ -48,7 +48,7 @@ public class DbTestPaperRecordDetailVo {
/** /**
* 图片答案 * 图片答案
*/ */
@ExcelProperty(value = "答案") @ExcelProperty(value = "图片答案")
private String answerPic; private String answerPic;
/** /**
......
...@@ -42,4 +42,12 @@ public interface ITestPaperService { ...@@ -42,4 +42,12 @@ public interface ITestPaperService {
* @return 考试题目 * @return 考试题目
*/ */
TableDataInfo<TestQuestionItemVo> nextQuestion(TestPaperAnswerBo request, PageQuery pageQuery); TableDataInfo<TestQuestionItemVo> nextQuestion(TestPaperAnswerBo request, PageQuery pageQuery);
/**
* 检查答题卡完整性
*
* @param recordId 答题记录ID
* @return 答题完整性
*/
boolean checkTestPaperIntegrality(Long recordId);
} }
...@@ -152,7 +152,41 @@ public class TestPaperServiceImpl implements ITestPaperService { ...@@ -152,7 +152,41 @@ public class TestPaperServiceImpl implements ITestPaperService {
RedisUtils.deleteKeys(key); RedisUtils.deleteKeys(key);
}); });
if (CollUtil.isNotEmpty(insertPaperRecords)) { if (CollUtil.isNotEmpty(insertPaperRecords)) {
return paperRecordDetailService.saveBatch(insertPaperRecords); if (!paperRecordDetailService.saveBatch(insertPaperRecords)) {
throw new ServiceException("答题记录保存失败");
}
// 修改考试记录状态为待批阅
testPaperRecord.setStatus(1);
if (!paperRecordService.updateByBo(BeanUtil.toBean(testPaperService, DbTestPaperRecordBo.class))) {
throw new ServiceException("考试记录状态修改失败");
}
return true;
}
return true;
}
/**
* 检查答题卡完整性
*
* @param recordId 答题记录ID
* @return 答题完整性
*/
@Override
public boolean checkTestPaperIntegrality(Long recordId) {
// 查询试卷对应所有的题目
DbTestPaperRecord testPaperRecord = paperRecordService.getOne(Wrappers.<DbTestPaperRecord>lambdaQuery().eq(DbTestPaperRecord::getId, recordId));
Objects.requireNonNull(testPaperRecord, "未检查到合法考试记录");
DbQuestionBankTestPaperBo queryCondition = new DbQuestionBankTestPaperBo();
queryCondition.setTestPaperId(testPaperRecord.getTestPaperId());
List<DbQuestionBankTestPaperVo> questionList = bankTestPaperService.queryList(queryCondition);
for (DbQuestionBankTestPaperVo question : questionList) {
// 查询Redis中是否有该题的提交记录
String key = String.format(TEST_PAPER_ANSWER_KEY_FORMAT, TEST_PAPER_ANSWER_KEY, recordId, question.getId());
TestPaperAnswerItemBo cacheObject = RedisUtils.getCacheObject(key);
if (cacheObject == null || cacheObject.getId() == null ||
(StringUtils.isEmpty(cacheObject.getAnswer()) && StringUtils.isEmpty(cacheObject.getAnswerPic()))) {
return false;
}
} }
return true; return true;
} }
......
...@@ -13,7 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -13,7 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="good" column="good"/> <result property="good" column="good"/>
<result property="remark" column="remark"/> <result property="remark" column="remark"/>
<result property="status" column="status"/> <result property="status" column="status"/>
<result property="createTime" column="cerate_time"/> <result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/> <result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/> <result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/> <result property="updateBy" column="update_by"/>
......
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