【修改】 错题集相关优化

This commit is contained in:
dlaren
2025-09-04 15:29:40 +08:00
parent cb077de58c
commit 6420ed6ba7
4 changed files with 59 additions and 117 deletions

View File

@@ -59,7 +59,11 @@
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId> <!-- 代码生成器,使用它解析表结构 --> <artifactId>mybatis-plus-generator</artifactId> <!-- 代码生成器,使用它解析表结构 -->
</dependency> </dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.17.1</version> <!-- 请使用最新版本 -->
</dependency>
<dependency> <dependency>
<groupId>pc.exam.gg</groupId> <groupId>pc.exam.gg</groupId>
<artifactId>exam-spring-boot-starter-redis</artifactId> <artifactId>exam-spring-boot-starter-redis</artifactId>

View File

@@ -23,10 +23,15 @@ public class ErrorQuestionListVo {
*/ */
private String taskId; private String taskId;
/**
* 任务名称
*/
private String taskName; private String taskName;
/**
* 错误次数
*/
private String errorNumber; private String errorNumber;
/** /**
* 章节名称 * 章节名称
*/ */
@@ -36,40 +41,17 @@ public class ErrorQuestionListVo {
*/ */
private String subjectName; private String subjectName;
/**
* 题型难度0简单1一般2困难
*/
private Integer quLevel;
/** /**
* 试题内容(带样式:<p>下列表格123</p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td style=\"width: 31.4907%;\">1</td>\) * 试题内容(带样式:<p>下列表格123</p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td style=\"width: 31.4907%;\">1</td>\)
*/ */
private String content; private String content;
/**
* 试题内容(纯文本)
*/
private String contentText; private String contentText;
/**
* 解析(带样式)
*/
private String analysis;
/**
* c语言参考答案
*/
private String answer;
/** /**
* 知识点 * 知识点
*/ */
private String pointNames; private String pointNames;
/**
* 关键字
*/
private String keywords;
/** /**
* 课程类别 * 课程类别
@@ -80,10 +62,7 @@ public class ErrorQuestionListVo {
* 专业分类 * 专业分类
*/ */
private String specialtyName; private String specialtyName;
/**
* 数据库名
*/
private String tname;
/** /**
* 试题答案 * 试题答案
@@ -96,15 +75,12 @@ public class ErrorQuestionListVo {
private List<ExamQuestionFile> fileUploads; private List<ExamQuestionFile> fileUploads;
/** /**
* 试题判分 * 答案
*/ */
private ExamQuestionScore questionScores; private String answer;
/** /**
* 试题关键字 * 创建时间
*/ */
private List<ExamQuestionKeyword> questionKeywords;
private LocalDateTime createTime; private LocalDateTime createTime;
private String creator; private String creator;

View File

@@ -37,89 +37,14 @@ public class ExamErrorQuestion {
private String taskId; private String taskId;
/** /**
* 章节名称 * 创建时间
*/ */
private String chapteridDictText;
/**
* 题型名称
*/
private String subjectName;
/**
* 题型难度0简单1一般2困难
*/
private Integer quLevel;
/**
* 试题内容(带样式:<p>下列表格123</p>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td style=\"width: 31.4907%;\">1</td>\)
*/
private String content;
/**
* 试题内容(纯文本)
*/
private String contentText;
/**
* 解析(带样式)
*/
private String analysis;
/**
* c语言参考答案
*/
private String answer;
/**
* 知识点
*/
private String pointNames;
/**
* 关键字
*/
private String keywords;
/**
* 课程类别
*/
private String courseName;
/**
* 专业分类
*/
private String specialtyName;
/**
* 数据库名
*/
private String tname;
/**
* 试题答案
*/
@TableField(exist = false)
private List<ExamQuestionAnswer> answerList;
/**
* 试题文件
*/
@TableField(exist = false)
private List<ExamQuestionFile> fileUploads;
/**
* 试题判分
*/
@TableField(exist = false)
private ExamQuestionScore questionScores;
/**
* 试题关键字
*/
@TableField(exist = false)
private List<ExamQuestionKeyword> questionKeywords;
private LocalDateTime createTime; private LocalDateTime createTime;
/**
* 创建人
*/
private String creator; private String creator;
/** /**
* 租户id * 租户id

View File

@@ -1,26 +1,63 @@
package pc.exam.pp.module.exam.service.error; package pc.exam.pp.module.exam.service.error;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.jsoup.Jsoup;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import pc.exam.pp.module.exam.controller.admin.error.vo.ErrorQuestionListVo; import pc.exam.pp.module.exam.controller.admin.error.vo.ErrorQuestionListVo;
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
import pc.exam.pp.module.exam.dal.mysql.error.ExamErrorQuestionInfoMapper; import pc.exam.pp.module.exam.dal.mysql.error.ExamErrorQuestionInfoMapper;
import pc.exam.pp.module.exam.dal.mysql.error.ExamErrorQuestionMapper; import pc.exam.pp.module.exam.dal.mysql.error.ExamErrorQuestionMapper;
import pc.exam.pp.module.exam.service.question.IExamQuestionService;
import java.util.List; import java.util.List;
@Service @Service
public class ExamErrorQuestionServiceImpl implements ExamErrorQuestionService{ public class ExamErrorQuestionServiceImpl implements ExamErrorQuestionService {
@Resource @Resource
ExamErrorQuestionMapper examErrorQuestionMapper; ExamErrorQuestionMapper examErrorQuestionMapper;
@Resource @Resource
ExamErrorQuestionInfoMapper examErrorQuestionInfoMapper; ExamErrorQuestionInfoMapper examErrorQuestionInfoMapper;
@Resource
IExamQuestionService examQuestionService;
@Override @Override
public List<ErrorQuestionListVo> selectByUserId(String userId) { public List<ErrorQuestionListVo> selectByUserId(String userId) {
List<ErrorQuestionListVo> errorQuestionListVos = examErrorQuestionMapper.selectByUserId(userId); List<ErrorQuestionListVo> errorQuestionListVos = examErrorQuestionMapper.selectByUserId(userId);
errorQuestionListVos.forEach(item->{ errorQuestionListVos.forEach(item -> {
// 通过试题ID查询对应所有的内容
ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuId(item.getQuId());
item.setErrorNumber(examErrorQuestionInfoMapper.selectByQuId(item.getQuId())); item.setErrorNumber(examErrorQuestionInfoMapper.selectByQuId(item.getQuId()));
item.setChapteridDictText(examQuestion.getChapteridDictTextVo());
item.setSubjectName(examQuestion.getSubjectName());
item.setPointNames(examQuestion.getPointNamesVo());
item.setCourseName(examQuestion.getCourseName());
item.setSpecialtyName(examQuestion.getSpecialtyName());
item.setAnswerList(examQuestion.getAnswerList());
item.setContent(examQuestion.getContent());
item.setFileUploads(examQuestion.getFileUploads());
item.setContentText(Jsoup.parse(item.getContent()).text());
if (examQuestion.getFileUploads() != null) {
// 说明是有文件的
// 答案就是URL文件路径直接下载到本地查看
examQuestion.getFileUploads().forEach(fileUpload -> {
if (fileUpload.getFileType().equals("2")) {
item.setAnswer(fileUpload.getUrl());
}
});
} else {
// 说明没有文件
// 选择题 选择题答案
examQuestion.getAnswerList().forEach(answer -> {
if (answer.getIsRight() != null) {
if (answer.getIsRight().equals("0")) {
item.setAnswer(answer.getContent());
}
} else {
item.setAnswer(item.getAnswer() + answer.getContentIn() + "<br>");
}
});
}
}); });
return errorQuestionListVos; return errorQuestionListVos;
} }