【新增】 学生端错题集相关功能(查询)

This commit is contained in:
dlaren
2025-08-28 17:12:18 +08:00
parent 4ffc0ff98e
commit 5d1188bcf2
13 changed files with 468 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
package pc.exam.pp.module.exam.controller.admin.error;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import pc.exam.pp.framework.common.pojo.CommonResult;
import pc.exam.pp.module.exam.controller.admin.error.vo.ErrorQuestionListVo;
import pc.exam.pp.module.exam.service.error.ExamErrorQuestionService;
import java.util.List;
/**
* 错题集Controller
*
* @author pengchen
*/
@RestController
@RequestMapping("/exam/error_question")
@Tag(name = "错题集管理接口")
@Validated
public class ExamErrorQuestionController {
@Resource
ExamErrorQuestionService examErrorQuestionService;
@GetMapping("/list/{id}")
public CommonResult<List<ErrorQuestionListVo>> list(@PathVariable("id") String id){
return CommonResult.success(examErrorQuestionService.selectByUserId(id));
}
}

View File

@@ -0,0 +1,115 @@
package pc.exam.pp.module.exam.controller.admin.error.vo;
import lombok.Data;
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionFile;
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionKeyword;
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionScore;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class ErrorQuestionListVo {
private String id;
/**
* 试题id
*/
private String quId;
/**
* 任务ID
*/
private String taskId;
private String taskName;
private String errorNumber;
/**
* 章节名称
*/
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;
/**
* 试题答案
*/
private List<ExamQuestionAnswer> answerList;
/**
* 试题文件
*/
private List<ExamQuestionFile> fileUploads;
/**
* 试题判分
*/
private ExamQuestionScore questionScores;
/**
* 试题关键字
*/
private List<ExamQuestionKeyword> questionKeywords;
private LocalDateTime createTime;
private String creator;
/**
* 租户id
*/
private long tenantId;
}

View File

@@ -0,0 +1,129 @@
package pc.exam.pp.module.exam.dal.dataobject.error;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionFile;
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionKeyword;
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionScore;
import java.time.LocalDateTime;
import java.util.List;
/**
* 错题集
*
* @author pengchen
*/
@TableName(value = "exam_error_question", autoResultMap = true)
@Accessors(chain = true)
@Data
public class ExamErrorQuestion {
@TableId
private String id;
/**
* 试题id
*/
private String quId;
/**
* 任务ID
*/
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 String creator;
/**
* 租户id
*/
private long tenantId;
}

View File

@@ -0,0 +1,42 @@
package pc.exam.pp.module.exam.dal.dataobject.error;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* 错题集
*
* @author pengchen
*/
@TableName(value = "exam_error_question_info", autoResultMap = true)
@Accessors(chain = true)
@Data
public class ExamErrorQuestionInfo {
@TableId
private String id;
/**
* 试题id
*/
private String quId;
/**
* 任务ID
*/
private String taskId;
private LocalDateTime createTime;
private String creator;
/**
* 租户id
*/
private long tenantId;
}

View File

@@ -0,0 +1,17 @@
package pc.exam.pp.module.exam.dal.mysql.error;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX;
import pc.exam.pp.module.exam.dal.dataobject.error.ExamErrorQuestionInfo;
/**
* 错题集 Mapper接口
*
* @author pengchen
*/
@Mapper
public interface ExamErrorQuestionInfoMapper extends BaseMapperX<ExamErrorQuestionInfo> {
String selectByQuId(@Param("quId") String quId);
}

View File

@@ -0,0 +1,24 @@
package pc.exam.pp.module.exam.dal.mysql.error;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX;
import pc.exam.pp.module.exam.controller.admin.error.vo.ErrorQuestionListVo;
import pc.exam.pp.module.exam.dal.dataobject.error.ExamErrorQuestion;
import java.util.List;
/**
* 错题集 Mapper接口
*
* @author pengchen
*/
@Mapper
public interface ExamErrorQuestionMapper extends BaseMapperX<ExamErrorQuestion> {
/**
* 根据用户id查询错题集
* @param id 用户id
* @return 错题集列表
*/
List<ErrorQuestionListVo> selectByUserId(@Param("id") String id);
}

View File

@@ -0,0 +1,16 @@
package pc.exam.pp.module.exam.service.error;
import pc.exam.pp.module.exam.controller.admin.error.vo.ErrorQuestionListVo;
import java.util.List;
public interface ExamErrorQuestionInfoService {
/**
* 根据用户id查询错题次数
* @param quId 试题ID
* @return 错题列表
*/
String selectByQuId(String quId);
}

View File

@@ -0,0 +1,17 @@
package pc.exam.pp.module.exam.service.error;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import pc.exam.pp.module.exam.dal.mysql.error.ExamErrorQuestionInfoMapper;
@Service
public class ExamErrorQuestionInfoServiceImpl implements ExamErrorQuestionInfoService{
@Resource
ExamErrorQuestionInfoMapper examErrorQuestionInfoMapper;
@Override
public String selectByQuId(String quId) {
return examErrorQuestionInfoMapper.selectByQuId(quId);
}
}

View File

@@ -0,0 +1,16 @@
package pc.exam.pp.module.exam.service.error;
import pc.exam.pp.module.exam.controller.admin.error.vo.ErrorQuestionListVo;
import java.util.List;
public interface ExamErrorQuestionService {
/**
* 根据用户id查询错题
* @param userId 用户id
* @return 错题列表
*/
List<ErrorQuestionListVo> selectByUserId(String userId);
}

View File

@@ -0,0 +1,28 @@
package pc.exam.pp.module.exam.service.error;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import pc.exam.pp.module.exam.controller.admin.error.vo.ErrorQuestionListVo;
import pc.exam.pp.module.exam.dal.mysql.error.ExamErrorQuestionInfoMapper;
import pc.exam.pp.module.exam.dal.mysql.error.ExamErrorQuestionMapper;
import java.util.List;
@Service
public class ExamErrorQuestionServiceImpl implements ExamErrorQuestionService{
@Resource
ExamErrorQuestionMapper examErrorQuestionMapper;
@Resource
ExamErrorQuestionInfoMapper examErrorQuestionInfoMapper;
@Override
public List<ErrorQuestionListVo> selectByUserId(String userId) {
List<ErrorQuestionListVo> errorQuestionListVos = examErrorQuestionMapper.selectByUserId(userId);
errorQuestionListVos.forEach(item->{
item.setErrorNumber(examErrorQuestionInfoMapper.selectByQuId(item.getQuId()));
});
return errorQuestionListVos;
}
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pc.exam.pp.module.exam.dal.mysql.error.ExamErrorQuestionInfoMapper">
<select id="selectByQuId" resultType="string"
parameterType="string">
SELECT count(*)
FROM exam_error_question_info
WHERE qu_id = #{quId}
</select>
</mapper>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pc.exam.pp.module.exam.dal.mysql.error.ExamErrorQuestionMapper">
<select id="selectByUserId" resultType="pc.exam.pp.module.exam.controller.admin.error.vo.ErrorQuestionListVo"
parameterType="string">
SELECT *, ept.task_name as taskName
FROM exam_error_question eeq
left join education_paper_task ept on eeq.task_id = ept.task_id
WHERE eeq.creator = #{id}
</select>
</mapper>

View File

@@ -98,6 +98,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
}
return user;
}
@Override
public AdminUserDO authenticateOnlyUsername(String username) {
final LoginLogTypeEnum logTypeEnum = LoginLogTypeEnum.LOGIN_USERNAME;
@@ -114,6 +115,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
}
return user;
}
@Override
public AdminUserDO authenticateByNickName(String username, String nickname) {
final LoginLogTypeEnum logTypeEnum = LoginLogTypeEnum.LOGIN_USERNAME;
@@ -130,10 +132,11 @@ public class AdminAuthServiceImpl implements AdminAuthService {
}
return user;
}
@Override
public AuthLoginRespVO login(AuthLoginReqVO reqVO) {
AdminUserDO user = new AdminUserDO();
// 校验验证码
// 校验验证码
validateCaptcha(reqVO);
// 判断用户类型
if (reqVO.getUserType().equals("2")) {