Browse Source

缓存中添加切屏次数

yuanjunhao 4 months ago
parent
commit
1ce6cf7bd6

+ 5 - 1
web/src/main/java/com/ynfy/buss/exam/exam/controller/ExamController.java

@@ -324,13 +324,16 @@ public class ExamController extends JeecgController<Exam, IExamService> {
     @PostMapping(value = "/submitExamPaper")
     public Result<?> submitExamPaper(@RequestBody ExamSubmitDTO dto) {
         String biaozhi=examService.submitExamPaper(dto);
+        System.out.println(biaozhi);
         if (biaozhi.equals("0")) {
             return Result.ok();
-        }else {
+        }else if(biaozhi.equals("1")){
             //开启下一套试卷
             LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
             UserExam userExam= examService.createExamPapers(user.getId(), userExamService.getById(dto.getUserExamId()).getExamId());
         return Result.ok(examService.examDetail(userExam.getId()));
+        }else {
+            return Result.ok(examService.examDetail(dto.getUserExamId()));
         }
     }
     /**
@@ -377,6 +380,7 @@ public class ExamController extends JeecgController<Exam, IExamService> {
         examService.cacheExamAnswer(dto);
         return Result.ok();
     }
+
     /**
      * 获取缓存的考试试卷答案
      *

+ 5 - 0
web/src/main/java/com/ynfy/buss/exam/exam/dto/ExamAnswerDTO.java

@@ -39,4 +39,9 @@ public class ExamAnswerDTO {
      * 试题答案(客观题---填空题)
      */
     private String blankAnswer;
+    /**
+     * 坐标
+     */
+//    private String CONNECTIONAnswer;
+    private Object coordinates;
 }

+ 2 - 0
web/src/main/java/com/ynfy/buss/exam/exam/dto/ExamSubmitDTO.java

@@ -17,6 +17,8 @@ public class ExamSubmitDTO {
 
     //用户考试试卷id
     private String paperId;
+    //用户考试切屏次数
+    private String leaveTime;
 
     //考试截止时间(自动交卷时间)
     private Date limitTime;

+ 3 - 4
web/src/main/java/com/ynfy/buss/exam/exam/mapper/xml/ExamMapper.xml

@@ -86,8 +86,7 @@
         <choose>
             <when test="user!=null and user.id!=null and user.id!=''">
                 ,
-                tmp2.try_count,
-                u.passed
+                tmp2.try_count
             </when>
         </choose>
         FROM
@@ -133,7 +132,6 @@
                 exam_id
             ) tmp2
             ON tmp1.ID = tmp2.exam_id
-            LEFT JOIN user_exam_result u on u.exam_id = tmp2.exam_id and u.user_id = #{user.id}
             </when>
         </choose>
         <where>
@@ -147,7 +145,7 @@
                 AND tmp1.state = #{exam.state}
             </if>
         </where>
-            order by tmp1.state
+            order by tmp1.state,tmp2.try_count desc
     </select>
     <select id="selectExamList2" resultType="com.ynfy.buss.exam.exam.entity.Exam">
         SELECT
@@ -217,6 +215,7 @@
             </if>
             AND (tmp1.state='0' or tmp1.state='2')
         </where>
+        order by tmp1.state
     </select>
 
     <select id="listExamIng" resultType="String">

+ 16 - 5
web/src/main/java/com/ynfy/buss/exam/exam/service/impl/ExamServiceImpl.java

@@ -958,6 +958,7 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
     @Override
     public String submitExamPaper(ExamSubmitDTO dto) {
         String biaozhi="";
+        System.out.println("yyz进行交卷");
         if (StringUtils.isEmpty(dto.getUserExamId())) {
             throw new JeecgBootException("考试ID不能为空");
         }
@@ -965,14 +966,22 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
             throw new JeecgBootException("试卷ID不能为空");
         }
         //获取试卷是否已经进行交卷
-        UserExamPapers userExamPapers=iUserExamPapersService.UserExamIdPaperUserExamPapers(dto.getUserExamId(),dto.getPaperId());
+        List<UserExamPapers> listuserExamPapers=iUserExamPapersService.UserExamIdPaperUserExamPapers(dto.getUserExamId(),dto.getPaperId());
+        UserExamPapers userExamPapers=new UserExamPapers();
+        if (listuserExamPapers.size()>0){
+            userExamPapers=listuserExamPapers.get(0);
+        }else {
+            throw new JeecgBootException("未查询到该试卷");
+        }
         if (PaperState.FINISHED.equals(userExamPapers.getState()) || PaperState.WAIT_OPT.equals(userExamPapers.getState())) {
             //试卷已经交卷获取下一场考试试卷的信息
            List<UserExamPapers> userExamPapersLists= iUserExamPapersService.UserExamIdAllUserExamPapers(dto.getUserExamId());
            if(userExamPapersLists.size()==0){
                throw new JeecgBootException("该试卷已经交卷,不允许重复交卷,当前试卷为最后一套试卷,本次考试结束。");
            }else if(userExamPapersLists.size()==1){
-               throw new JeecgBootException("该试卷已经交卷,不允许重复交卷,即将进入下一套试卷。",Integer.parseInt(userExamPapersLists.get(0).getPaperId()));
+//               throw new JeecgBootException("该试卷已经交卷,不允许重复交卷,即将进入下一套试卷。",Integer.parseInt(userExamPapersLists.get(0).getPaperId()));
+               System.out.println("yyz显示:"+userExamPapersLists.get(0).getPaperId());
+               return userExamPapersLists.get(0).getPaperId();
            }
         }
         UserExam userExam = userExamService.listUserExam(dto.getUserExamId());
@@ -1753,9 +1762,6 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
 //            userExamResultService.joinPaperResult(userExam.getUserId(), userExam.getExamId(),userExam.getPaperId(), score, paperpass);
             //更新试卷状态
             iUserExamPapersService.updateById(userExamPapers);
-//            //开启下一套试卷
-//            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-//            createExamPapers(user.getId(), userExam.getExamId());
             return "1";
         }
 //        userExam.setUserScore(score);//最终得分
@@ -1845,6 +1851,8 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
             redisUtil.set(dto.getUserExamId(), JSON.toJSONString(dto), expireSec);
         }
     }
+
+
     /**
      * 缓存考试试卷答案,用于定时任务强制交卷
      *
@@ -1857,6 +1865,9 @@ public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements IE
             long expireMins = DateUtil.between(new Date(), dto.getLimitTime(), DateUnit.MINUTE) + 60 * 24 * 3;
             long expireSec = expireMins * 60;
             String idkey=dto.getUserExamId()+dto.getPaperId();
+            System.out.println("-----------------------------");
+            System.out.println(JSON.toJSONString(dto));
+            System.out.println("-----------------------------");
             redisUtil.set(idkey, JSON.toJSONString(dto), expireSec);
         }
     }

+ 1 - 1
web/src/main/java/com/ynfy/buss/exam/examstatistics/controller/ExamStatisticsController.java

@@ -146,7 +146,7 @@ public class ExamStatisticsController extends JeecgController<ExamStatistics, IE
     }
 
     /**
-     * 考试结果统计
+     * 考试结果统计 定时任务
      *
      * @param examId
      * @return

+ 1 - 1
web/src/main/java/com/ynfy/buss/exam/userexam/service/IUserExamPapersService.java

@@ -18,6 +18,6 @@ public interface IUserExamPapersService extends IService<UserExamPapers> {
     List<UserExamPapers> UserExamIdAllUserExamPapers(String userExamId);
     //根据用户考试id获取已经考完的考试
     List<UserExamPapers> UserExamIdAllUserExamPapers2(String userExamId);
-    UserExamPapers UserExamIdPaperUserExamPapers(String userExamId,String paperId);
+    List<UserExamPapers> UserExamIdPaperUserExamPapers(String userExamId,String paperId);
     List<UserExamPapers> UserExamPapersList(String userExamId,String paperId);
 }

+ 2 - 2
web/src/main/java/com/ynfy/buss/exam/userexam/service/impl/UserExamPapersServiceImpl.java

@@ -37,10 +37,10 @@ public class UserExamPapersServiceImpl extends ServiceImpl<UserExamPapersMapper,
     }
 
     @Override
-    public UserExamPapers UserExamIdPaperUserExamPapers(String userExamId,String paperId) {
+    public List<UserExamPapers> UserExamIdPaperUserExamPapers(String userExamId,String paperId) {
         LambdaQueryWrapper<UserExamPapers> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(UserExamPapers::getUserExamId, userExamId).eq(UserExamPapers::getPaperId, paperId);
-        return this.list(wrapper).get(0);
+        return this.list(wrapper);
     }
     @Override
     public List<UserExamPapers> UserExamPapersList(String userExamId,String paperId) {