瀏覽代碼

完善算分。完善考试计时。 添加 answerRight 字段。

tom 5 月之前
父節點
當前提交
9cc6c6a813

+ 14 - 13
pla-sim/01_SQL/02_table/sim_real_exam_fault.sql

@@ -1,17 +1,17 @@
 /*
  Navicat Premium Dump SQL
 
- Source Server         : qdhome.iot321.top-dev
+ Source Server         : 47.104.188.84-sim
  Source Server Type    : MySQL
- Source Server Version : 50740 (5.7.40-log)
- Source Host           : qdhome.iot321.top:33103
+ Source Server Version : 80020 (8.0.20)
+ Source Host           : 47.104.188.84:65006
  Source Schema         : pla-chem-sim-dev-1
 
  Target Server Type    : MySQL
- Target Server Version : 50740 (5.7.40-log)
+ Target Server Version : 80020 (8.0.20)
  File Encoding         : 65001
 
- Date: 18/12/2024 21:39:18
+ Date: 24/12/2024 08:59:02
 */
 
 SET NAMES utf8mb4;
@@ -22,23 +22,24 @@ SET FOREIGN_KEY_CHECKS = 0;
 -- ----------------------------
 DROP TABLE IF EXISTS `sim_real_exam_fault`;
 CREATE TABLE `sim_real_exam_fault`  (
-  `ref_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '关联ID',
-  `exam_id` bigint(20) NOT NULL COMMENT '考试ID',
+  `ref_id` bigint NOT NULL COMMENT '关联ID',
+  `exam_id` bigint NOT NULL COMMENT '考试ID',
   `fault_id` char(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '故障ID',
-  `ref_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '关联类型 1:选择题 2:模拟器维修故障',
-  `flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '7' COMMENT '7:未知\r\n1:选中\r\n0:没有选中',
-  `ref_state` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '故障ID关联状态\r\n0:初始化\r\n1:已经清除故障\r\n2:故障已经下发\r\n3:轮训读取刷新电阻代表值\r\n3:考试结束',
+  `ref_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '关联类型:[1]-选择题,[2]-模拟器维修故障',
+  `flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '7' COMMENT '选择状态:[7]-未知,[1]-选中,[0]-没有选中',
+  `ref_state` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '故障ID关联状态:[0]-初始化,[1]-已经清除故障,[2]故障已经下发,[3]-轮询读取刷新电阻代表值,[4]-考试结束',
+  `answer_right` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '答题正确:[0]-初始化,[1]-正确,[2]-错误',
   `choice_question_value` char(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '选择题的出题数值/正确答案',
   `choice_answer_value` char(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '选择题的答题数值/学院填写答案',
   `sim_fault_question_value` char(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '模拟器出题值/电阻代表值',
-  `sim_fault_answer_value` char(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '模拟器答题值/电阻代表值',
-  `minus` int(2) NULL DEFAULT 0 COMMENT '减分值 计正数',
+  `sim_fault_answer_value` char(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '模拟器答题值/电阻代表值',
+  `minus` int NULL DEFAULT 0 COMMENT '减分值,计正数',
   `create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者',
   `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
   `update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者',
   `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
   `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
   PRIMARY KEY (`ref_id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'sim-考试故障关联表' ROW_FORMAT = DYNAMIC;
+) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'sim-考试故障关联表' ROW_FORMAT = DYNAMIC;
 
 SET FOREIGN_KEY_CHECKS = 1;

文件差異過大導致無法顯示
+ 1333 - 66
pla-sim/01_SQL/03_dev_backup/pla-chem-sim-dev-1.sql


+ 32 - 18
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/RealExamFault.java

@@ -33,31 +33,30 @@ public class RealExamFault extends BaseEntity {
     private String faultId;
 
     /**
-     * 关联类型 1:选择题 2:模拟器维修故障
+     * 关联类型:[1]-选择题,[2]-模拟器维修故障
      */
-    @Excel(name = "关联类型 1:选择题 2:模拟器维修故障")
+    @Excel(name = "关联类型:[1]-选择题,[2]-模拟器维修故障")
     private String refType;
 
     /**
-     * 7:未知
-     * 1:选中
-     * 0:没有选中
+     * 选择状态:[7]-未知,[1]-选中,[0]-没有选中
      */
-    @Excel(name = "flag")
+    @Excel(name = "选择状态:[7]-未知,[1]-选中,[0]-没有选中")
     private String flag;
 
     /**
-     * 故障ID关联状态
-     * 0:初始化
-     * 1:已经清除故障
-     * 2:故障已经下发
-     * 3:轮询读取刷新电阻代表值
-     * 4:考试结束
+     * 故障ID关联状态:[0]-初始化,[1]-已经清除故障,[2]故障已经下发,[3]-轮询读取刷新电阻代表值,[4]-考试结束
      */
-    @Excel(name = "故障ID关联状态")
+    @Excel(name = "故障ID关联状态:[0]-初始化,[1]-已经清除故障,[2]故障已经下发,[3]-轮询读取刷新电阻代表值,[4]-考试结束")
     private String refState;
 
     /**
+     * 答题正确:[0]-初始化,[1]-正确,[2]-错误
+     */
+    @Excel(name = "答题正确:[0]-初始化,[1]-正确,[2]-错误")
+    private String answerRight;
+
+    /**
      * 选择题的出题数值/正确答案
      */
     @Excel(name = "选择题的出题数值/正确答案")
@@ -82,10 +81,10 @@ public class RealExamFault extends BaseEntity {
     private String simFaultAnswerValue;
 
     /**
-     * 减分值 计正数
+     * 减分值,计正数
      */
-    @Excel(name = "减分值 计正数")
-    private Integer minus;
+    @Excel(name = "减分值,计正数")
+    private Long minus;
 
     public void setRefId(Long refId) {
         this.refId = refId;
@@ -135,6 +134,14 @@ public class RealExamFault extends BaseEntity {
         return refState;
     }
 
+    public void setAnswerRight(String answerRight) {
+        this.answerRight = answerRight;
+    }
+
+    public String getAnswerRight() {
+        return answerRight;
+    }
+
     public void setChoiceQuestionValue(String choiceQuestionValue) {
         this.choiceQuestionValue = choiceQuestionValue;
     }
@@ -167,11 +174,11 @@ public class RealExamFault extends BaseEntity {
         return simFaultAnswerValue;
     }
 
-    public void setMinus(Integer minus) {
+    public void setMinus(Long minus) {
         this.minus = minus;
     }
 
-    public Integer getMinus() {
+    public Long getMinus() {
         return minus;
     }
 
@@ -184,6 +191,7 @@ public class RealExamFault extends BaseEntity {
                 .append("refType", getRefType())
                 .append("flag", getFlag())
                 .append("refState", getRefState())
+                .append("answerRight", getAnswerRight())
                 .append("choiceQuestionValue", getChoiceQuestionValue())
                 .append("choiceAnswerValue", getChoiceAnswerValue())
                 .append("simFaultQuestionValue", getSimFaultQuestionValue())
@@ -216,4 +224,10 @@ public class RealExamFault extends BaseEntity {
         String NO = "0";
         String UNKNOWN = "7";
     }
+
+    public interface AnswerRight {
+        String UNKNOWN = "0";
+        String YES = "1";
+        String NO = "2";
+    }
 }

+ 0 - 8
ruoyi-sim/src/main/java/com/ruoyi/sim/domain/vo/RealExamFaultVo.java

@@ -9,14 +9,6 @@ public class RealExamFaultVo extends RealExamFault {
 
     private Fault fault;
 
-    public boolean isAnswerRight() {
-        return answerRight;
-    }
-
-    public void setAnswerRight(boolean answerRight) {
-        this.answerRight = answerRight;
-    }
-
     public Fault getFault() {
         return fault;
     }

+ 26 - 9
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/RealExamFaultService.java

@@ -142,9 +142,10 @@ public class RealExamFaultService {
         return state.equals(f.getRefState());
     }
 
-    public void calculateMinusByRealExamId(long realExamId) {
+    public void calculateMinusByRealExamId(long examId) {
+        l.info("calculateMinusByRealExamId realExamId : {}", examId);
         RealExamFault q = new RealExamFault();
-        q.setExamId(realExamId);
+        q.setExamId(examId);
         selectRealExamFaultList(q).forEach(ref -> {
             calculateMinus(ref.getRefId());
         });
@@ -156,6 +157,7 @@ public class RealExamFaultService {
      * @param refId
      */
     public void calculateMinus(Long refId) {
+        l.info("calculate refId : {}", refId);
         RealExamFault f = selectRealExamFaultByRefId(refId);
         if (f == null) {
             throw new RuntimeException("calculateMinus");
@@ -164,19 +166,35 @@ public class RealExamFaultService {
             throw new RuntimeException("calculateMinus");
         }
         int minus = 0;
+        String answerRight = RealExamFault.AnswerRight.UNKNOWN;
+        l.info("f = {}", f);
+
         if (RealExamFault.Type.TYPE_1.equals(f.getRefType())) {
             // todo:选择题的算减分
+            final String q = f.getChoiceQuestionValue();
+            final String a = f.getChoiceAnswerValue();
         } else if (RealExamFault.Type.TYPE_2.equals(f.getRefType())) {
+            final String q = f.getSimFaultQuestionValue();
+            final String a = f.getSimFaultAnswerValue();
             // 模拟器故障的算减分
-            if (!f.getChoiceQuestionValue().equals(f.getChoiceAnswerValue())) {
-                // 扣0分
-                minus = 0;
-            } else {
-                // 扣25分 故障未排除
+            if (StringUtils.isAllBlank(q, a)) {
+                // todo:不应该出现的情况
                 minus = 25;
+                answerRight = RealExamFault.AnswerRight.NO;
+            } else {
+                if (!StringUtils.equals(q, a)) {
+                    // 扣0分
+                    minus = 0;
+                    answerRight = RealExamFault.AnswerRight.YES;
+                } else {
+                    // 扣25分 故障未排除
+                    minus = 25;
+                    answerRight = RealExamFault.AnswerRight.NO;
+                }
             }
         }
-        f.setMinus(minus);
+        f.setMinus((long) minus);
+        f.setAnswerRight(answerRight);
         // 更新减分数据。
         updateRealExamFault(f);
     }
@@ -190,7 +208,6 @@ public class RealExamFaultService {
         list1.forEach(ref -> {
             RealExamFaultVo vo = new RealExamFaultVo();
             BeanUtils.copyProperties(ref, vo);
-            vo.setAnswerRight(StringUtils.equals(ref.getSimFaultQuestionValue(), ref.getSimFaultAnswerValue()));
             vo.setFault(faultService.selectFaultByFaultId(ref.getFaultId()));
             list2.add(vo);
         });

+ 2 - 1
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/RealExamService.java

@@ -263,9 +263,10 @@ public class RealExamService {
      */
     public AjaxResult studentLoopAnsweringRealExam(Long realExamId) {
         RealExam re = selectRealExamByExamId(realExamId);
+        RealExamCollection rec = realExamCollectionService.selectRealExamCollectionByExamCollectionId(re.getExamCollectionId());
         StudentRealExamIngVo vo = new StudentRealExamIngVo();
         vo.setRealExam(re);
-        long remaining = DateUtils.getNowDate().getTime() - re.getStartTime().getTime();
+        long remaining = (re.getStartTime().getTime() + rec.getLimitDuration() * 60 * 1000) - DateUtils.getNowDate().getTime();
         vo.setRemainingMilliseconds(remaining);
         vo.setCompulsiveSubmit(remaining >= RealExam.EXAM_TIMEOUT_LIMIT);
         return AjaxResult.success(vo);

+ 6 - 0
ruoyi-sim/src/main/resources/mapper/sim/RealExamFaultMapper.xml

@@ -11,6 +11,7 @@
         <result property="refType" column="ref_type"/>
         <result property="flag" column="flag"/>
         <result property="refState" column="ref_state"/>
+        <result property="answerRight" column="answer_right"/>
         <result property="choiceQuestionValue" column="choice_question_value"/>
         <result property="choiceAnswerValue" column="choice_answer_value"/>
         <result property="simFaultQuestionValue" column="sim_fault_question_value"/>
@@ -30,6 +31,7 @@
                ref_type,
                flag,
                ref_state,
+               answer_right,
                choice_question_value,
                choice_answer_value,
                sim_fault_question_value,
@@ -51,6 +53,7 @@
             <if test="refType != null  and refType != ''">and ref_type = #{refType}</if>
             <if test="flag != null  and flag != ''">and flag = #{flag}</if>
             <if test="refState != null  and refState != ''">and ref_state = #{refState}</if>
+            <if test="answerRight != null  and answerRight != ''">and answer_right = #{answerRight}</if>
             <if test="choiceQuestionValue != null  and choiceQuestionValue != ''">and choice_question_value =
                 #{choiceQuestionValue}
             </if>
@@ -83,6 +86,7 @@
             <if test="refType != null and refType != ''">ref_type,</if>
             <if test="flag != null and flag != ''">flag,</if>
             <if test="refState != null and refState != ''">ref_state,</if>
+            <if test="answerRight != null and answerRight != ''">answer_right,</if>
             <if test="choiceQuestionValue != null">choice_question_value,</if>
             <if test="choiceAnswerValue != null">choice_answer_value,</if>
             <if test="simFaultQuestionValue != null">sim_fault_question_value,</if>
@@ -100,6 +104,7 @@
             <if test="refType != null and refType != ''">#{refType},</if>
             <if test="flag != null and flag != ''">#{flag},</if>
             <if test="refState != null and refState != ''">#{refState},</if>
+            <if test="answerRight != null and answerRight != ''">#{answerRight},</if>
             <if test="choiceQuestionValue != null">#{choiceQuestionValue},</if>
             <if test="choiceAnswerValue != null">#{choiceAnswerValue},</if>
             <if test="simFaultQuestionValue != null">#{simFaultQuestionValue},</if>
@@ -121,6 +126,7 @@
             <if test="refType != null and refType != ''">ref_type = #{refType},</if>
             <if test="flag != null and flag != ''">flag = #{flag},</if>
             <if test="refState != null and refState != ''">ref_state = #{refState},</if>
+            <if test="answerRight != null and answerRight != ''">answer_right = #{answerRight},</if>
             <if test="choiceQuestionValue != null">choice_question_value = #{choiceQuestionValue},</if>
             <if test="choiceAnswerValue != null">choice_answer_value = #{choiceAnswerValue},</if>
             <if test="simFaultQuestionValue != null">sim_fault_question_value = #{simFaultQuestionValue},</if>

部分文件因文件數量過多而無法顯示