Commit 2051ae55 authored by 陈立彬's avatar 陈立彬

fix

parent 2f767039
...@@ -42,11 +42,12 @@ public class ExamController { ...@@ -42,11 +42,12 @@ public class ExamController {
@GetMapping(value = "/get_question") @GetMapping(value = "/get_question")
public ApiResponse<ElehKnowledgeDo> getQuestion(@RequestParam("tenant") Integer tenant, public ApiResponse<ElehKnowledgeDo> getQuestion(@RequestParam("tenant") Integer tenant,
@RequestParam("code") String code, @RequestParam("code") String code,
@RequestParam("session_id") String sessionId) { @RequestParam("session_id") String sessionId,
@RequestParam("user_id") String userId) {
ElehKnowledgeTagDo tagDo = tagMapper.selectByCode(tenant, code); ElehKnowledgeTagDo tagDo = tagMapper.selectByCode(tenant, code);
Long maxQuestionId = qaRecordMapper.selectSessionMaxQuestionId(tenant, sessionId); Long maxQuestionId = qaRecordMapper.selectSessionMaxQuestionId(tenant, sessionId, userId);
maxQuestionId = Objects.nonNull(maxQuestionId) ? maxQuestionId : 0; maxQuestionId = Objects.nonNull(maxQuestionId) ? maxQuestionId : 0;
ElehKnowledgeDo knowledgeDo = knowledgeMapper.selectQuestion(tenant, tagDo.getId(), maxQuestionId); ElehKnowledgeDo knowledgeDo = knowledgeMapper.selectQuestion(tenant, tagDo.getId(), maxQuestionId);
return ApiResponse.ok(knowledgeDo); return ApiResponse.ok(knowledgeDo);
...@@ -78,13 +79,15 @@ public class ExamController { ...@@ -78,13 +79,15 @@ public class ExamController {
@GetMapping(value = "/get_final_result") @GetMapping(value = "/get_final_result")
public ApiResponse<Double> getFinalResult(@RequestParam("tenant") Integer tenant, public ApiResponse<Double> getFinalResult(@RequestParam("tenant") Integer tenant,
@RequestParam("session_id") String sessionId) { @RequestParam("session_id") String sessionId,
@RequestParam("user_id") String userId) {
Double avgScore = 0D; Double avgScore = 0D;
LambdaQueryWrapper<ElehSessionQaRecordDo> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ElehSessionQaRecordDo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ElehSessionQaRecordDo::getTenant, tenant); queryWrapper.eq(ElehSessionQaRecordDo::getTenant, tenant);
queryWrapper.eq(ElehSessionQaRecordDo::getSessionId, sessionId); queryWrapper.eq(ElehSessionQaRecordDo::getSessionId, sessionId);
queryWrapper.eq(ElehSessionQaRecordDo::getUserId, userId);
List<ElehSessionQaRecordDo> qaRecordDos = qaRecordMapper.selectList(queryWrapper); List<ElehSessionQaRecordDo> qaRecordDos = qaRecordMapper.selectList(queryWrapper);
if(!CollectionUtils.isEmpty(qaRecordDos)) { if(!CollectionUtils.isEmpty(qaRecordDos)) {
double sum = qaRecordDos.stream().mapToDouble(ElehSessionQaRecordDo::getScore).sum(); double sum = qaRecordDos.stream().mapToDouble(ElehSessionQaRecordDo::getScore).sum();
......
...@@ -10,7 +10,7 @@ import org.apache.ibatis.annotations.Select; ...@@ -10,7 +10,7 @@ import org.apache.ibatis.annotations.Select;
public interface ElehSessionQaRecordMapper extends BaseMapper<ElehSessionQaRecordDo> { public interface ElehSessionQaRecordMapper extends BaseMapper<ElehSessionQaRecordDo> {
@Select(value = "select max(question_id) from eleh_session_qa_record where tenant = #{tenant} and session_id = #{sessionId}") @Select(value = "select max(question_id) from eleh_session_qa_record where tenant = #{tenant} and session_id = #{sessionId} and user_id = #{userId}")
Long selectSessionMaxQuestionId(@Param("tenant") Integer tenant, @Param("sessionId") String sessionId); Long selectSessionMaxQuestionId(@Param("tenant") Integer tenant, @Param("sessionId") String sessionId, @Param("userId") String userId);
} }
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