Bay 5 anni fa
parent
commit
0a47ac1a51

+ 37 - 7
seecoder-bok-client/src/test/java/cn/seecoder/bok/client/SeecoderBokClientTest.java

@@ -17,8 +17,8 @@ import static org.junit.jupiter.api.Assertions.*;
 
 class SeecoderBokClientTest {
 
-    //    private final SeecoderBokClient seecoderBokClient = new SeecoderBokClient("http://bok.seec.seecoder.cn");
-    private final SeecoderBokClient seecoderBokClient = new SeecoderBokClient("http://localhost:8080");
+    private final SeecoderBokClient seecoderBokClient = new SeecoderBokClient("http://bok.seec.seecoder.cn");
+//    private final SeecoderBokClient seecoderBokClient = new SeecoderBokClient("http://localhost:8080");
 
     @Test
     void getKnowledgeNode() {
@@ -46,12 +46,42 @@ class SeecoderBokClientTest {
 
     @Test
     void getQuestionById() {
-        QuestionVO questionVO = seecoderBokClient.getQuestionById("[test]a+b").get();
-        assertEquals("1017", questionVO.getId());
+        QuestionVO questionVO = seecoderBokClient.getQuestionById("test-1").get();
+        assertEquals("test-1", questionVO.getId());
     }
 
     @Test
-    void updateQuestion() {
+    void updateQuestion1() {
+        CodeQuestionVO codeQuestionVO = new CodeQuestionVO();
+        Map<String, String> inputOutputMapping = new HashMap<>();
+        inputOutputMapping.put("1 2\n", "3\n");
+        inputOutputMapping.put("2 3\n", "5\n");
+        codeQuestionVO.setInputOutputMapping(inputOutputMapping);
+        codeQuestionVO.setStem("a + b");
+        codeQuestionVO.setTitle("测试用_a+b");
+        codeQuestionVO.setId("test-1");
+        codeQuestionVO.setMemoryLimit(100000);
+        codeQuestionVO.setMillisecondLimit(3000);
+        seecoderBokClient.createQuestion(QuestionVOMapper.INSTANCE.codeQuestionToQuestion(codeQuestionVO));
+    }
+
+    @Test
+    void updateQuestion2() {
+        CodeQuestionVO codeQuestionVO = new CodeQuestionVO();
+        Map<String, String> inputOutputMapping = new HashMap<>();
+        inputOutputMapping.put("1\n14", "3\n");
+        inputOutputMapping.put("2\n14\n10", "3\n2\n");
+        codeQuestionVO.setInputOutputMapping(inputOutputMapping);
+        codeQuestionVO.setStem("1^2 + 2^2 + ... + n^2");
+        codeQuestionVO.setTitle("测试用_平方和");
+        codeQuestionVO.setId("test-3");
+        codeQuestionVO.setMemoryLimit(100000);
+        codeQuestionVO.setMillisecondLimit(3000);
+        seecoderBokClient.createQuestion(QuestionVOMapper.INSTANCE.codeQuestionToQuestion(codeQuestionVO));
+    }
+
+    @Test
+    void updateQuestion3() {
         CodeQuestionVO codeQuestionVO = new CodeQuestionVO();
         Map<String, String> inputOutputMapping = new HashMap<>();
         inputOutputMapping.put("3 2\n", "1\n");
@@ -59,9 +89,9 @@ class SeecoderBokClientTest {
         codeQuestionVO.setInputOutputMapping(inputOutputMapping);
         codeQuestionVO.setStem("a - b");
         codeQuestionVO.setTitle("测试用_a-b");
-        codeQuestionVO.setId("test-2");
+        codeQuestionVO.setId("test-3");
         codeQuestionVO.setMemoryLimit(100000);
-        codeQuestionVO.setMillisecondLimit(3000);
+        codeQuestionVO.setMillisecondLimit(30000);
         seecoderBokClient.createQuestion(QuestionVOMapper.INSTANCE.codeQuestionToQuestion(codeQuestionVO));
     }
 

+ 14 - 0
seecoder-bok-common/src/main/java/cn/seecoder/bok/common/vo/question/AbstractQuestionVO.java

@@ -34,6 +34,11 @@ public abstract class AbstractQuestionVO {
      */
     protected String analysis;
 
+    /**
+     * 难度 1 - 5
+     */
+    protected Integer weight;
+
     /**
      * TODO: 关键字?
      */
@@ -107,6 +112,14 @@ public abstract class AbstractQuestionVO {
         this.keyPoints = keyPoints;
     }
 
+    public Integer getWeight() {
+        return weight;
+    }
+
+    public void setWeight(Integer weight) {
+        this.weight = weight;
+    }
+
     public List<String> getTags() {
         return tags;
     }
@@ -147,6 +160,7 @@ public abstract class AbstractQuestionVO {
                 ", title='" + title + '\'' +
                 ", stem='" + stem + '\'' +
                 ", analysis='" + analysis + '\'' +
+                ", weight=" + weight +
                 ", keyPoints='" + keyPoints + '\'' +
                 ", tags=" + tags +
                 ", knowledgeId=" + knowledgeId +

+ 12 - 0
seecoder-bok-server/src/main/java/cn/seecoder/seecoderbokserver/domain/Question.java

@@ -33,6 +33,9 @@ public class Question {
     @Field(name = "stem", type = FieldType.Text)
     private String stem;
 
+    @Field(name = "weight", type = FieldType.Integer)
+    private Integer weight;
+
     @Field(name = "analysis", type = FieldType.Text)
     private String analysis;
 
@@ -95,6 +98,14 @@ public class Question {
         this.title = title;
     }
 
+    public Integer getWeight() {
+        return weight;
+    }
+
+    public void setWeight(Integer weight) {
+        this.weight = weight;
+    }
+
     public String getStem() {
         return stem;
     }
@@ -206,6 +217,7 @@ public class Question {
                 ", type=" + type +
                 ", title='" + title + '\'' +
                 ", stem='" + stem + '\'' +
+                ", weight=" + weight +
                 ", analysis='" + analysis + '\'' +
                 ", keyPoints='" + keyPoints + '\'' +
                 ", tags=" + tags +