Prechádzať zdrojové kódy

模拟考试取题逻辑修改

小么熊🐻 2 rokov pred
rodič
commit
4f58c185e5

+ 4 - 0
nbjk-admin/src/test/java/com/miaxis/test/NormalTest3.java

@@ -15,6 +15,7 @@ import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import java.util.List;
+import java.util.Random;
 
 @ActiveProfiles("dev")
 @SpringBootTest(classes = NbjkApplication.class)
@@ -43,4 +44,7 @@ public class NormalTest3 {
 
 
 
+
+
+
 }

+ 7 - 5
nbjk-admin/src/test/java/com/miaxis/test/Test.java

@@ -1,15 +1,17 @@
 package com.miaxis.test;
 
+import java.util.Random;
+
 public class Test {
 
     public static void main(String[] args) {
+        Random random = new Random();
 
-        for (int i = 0; i < 10; i++) {
-            if(i==5) {
-                continue;
-            }
-            System.out.println("i="+i);
+        for (int i=0; i<100; i++){
+            int r = random.nextInt(3);
+                System.out.println(r);
         }
+
     }
 
 }

+ 7 - 7
nbjk-service/src/main/java/com/miaxis/question/service/impl/QuestionInfoServiceImpl.java

@@ -450,24 +450,24 @@ public class QuestionInfoServiceImpl extends ServiceImpl<QuestionInfoMapper, Que
 
                 int randomNum = 0;
                 for (int j = 0; j < difficult; j++) {
-                    randomNum = random.nextInt(9);
-
                     if(qt.getSubject()==1 || (qt.getSubject()==4 && easyMultiple==0)) {
-                        if (randomNum <= 4) {   //判断题
+                        randomNum = random.nextInt(2); //随机出现 0和1  0表示判断 1表示单选
+                        if (randomNum == 0) {   //判断题
                             diffJudeg++;
                             easyJudge--;
-                        } else if (randomNum <= 9) {  //单选题
+                        } else if (randomNum == 1) {  //单选题
                             diffChoice++;
                             easyChoice--;
                         }
                     } else if(qt.getSubject()==4){
-                        if (randomNum <= 2) {   //判断题
+                        randomNum = random.nextInt(3); //随机出现 0、1、2  0表示判断 1表示单选 2多选
+                        if (randomNum == 0) {   //判断题
                             diffJudeg++;
                             easyJudge--;
-                        } else if (randomNum <= 5) {  //单选题
+                        } else if (randomNum == 1) {  //单选题
                             diffChoice++;
                             easyChoice--;
-                        } else if (randomNum <= 8) {    //多选题
+                        } else if (randomNum == 2) {    //多选题
                             diffMultiple++;
                             easyMultiple--;
                         }