deason 1 年之前
父節點
當前提交
45e5f8bce2

+ 12 - 4
src/main/java/cn/com/qmth/examcloud/tool/service/create_random_paper_template/CreateRandomPaperTemplateTask.java

@@ -7,6 +7,7 @@ import cn.com.qmth.examcloud.tool.service.CommonService;
 import cn.com.qmth.examcloud.tool.service.create_random_paper_template.vo.PaperStructVO;
 import cn.com.qmth.examcloud.tool.service.create_random_paper_template.vo.PaperVO;
 import cn.com.qmth.examcloud.tool.service.create_random_paper_template.vo.RandomPaperTemplateVO;
+import cn.com.qmth.examcloud.tool.service.create_random_paper_template.vo.TemplateStructInfo;
 import cn.com.qmth.examcloud.tool.service.export_student_answer_and_score_detail.vo.CourseVO;
 import cn.com.qmth.examcloud.tool.utils.HttpHelper;
 import cn.com.qmth.examcloud.tool.utils.JsonMapper;
@@ -86,7 +87,7 @@ public class CreateRandomPaperTemplateTask {
             // 获取试卷结构
             String paperStructId = this.getPaperStructId(user, course.getCourseCode(), structType, structName);
             if (paperStructId == null) {
-                String msg = String.format("【%s】 课程代码:%s 未找到试卷结构!", index, course.getCourseCode());
+                String msg = String.format("【%s】 课程代码:%s 未找到匹配的试卷结构!", index, course.getCourseCode());
                 messages.add(msg);
                 log.warn(msg);
                 continue;
@@ -180,7 +181,7 @@ public class CreateRandomPaperTemplateTask {
 
         int pageNo = 0, pageSize = 100, total = 0;
 
-        String url;
+        final String url;
         if ("IMPORT".equals(questionPool)) {
             url = user.getServerUrl() + "/api/ecs_ques/importPaper/huoge/%s/" + pageSize;
         } else {
@@ -237,7 +238,7 @@ public class CreateRandomPaperTemplateTask {
         headers.put("token", user.getToken());
 
         Map<String, String> params = new HashMap<>();
-        params.put("name", course.getCourseName() + "-模板");//todo
+        params.put("name", course.getCourseName() + "-抽题模板");//todo
         params.put("courseId", String.valueOf(course.getCourseId()));
         params.put("paperStructType", paperStructType);
         params.put("paperStructId", paperStructId);
@@ -245,7 +246,14 @@ public class CreateRandomPaperTemplateTask {
         params.put("paperIds", StringUtils.join(paperIds, ","));
 
         final String url = user.getServerUrl() + "/api/ecs_ques/randompaper/save?" + HttpHelper.toUrlParams(params);
-        HttpHelper.post(url, headers, null);
+        String json = HttpHelper.post(url, headers, null);
+        TemplateStructInfo info = new JsonMapper().parseJson(json, TemplateStructInfo.class);
+        if (info != null && info.getValid()) {
+            log.info("courseCode:{} 随机抽卷模板保存成功!", course.getCourseCode());
+            return;
+        }
+
+        throw new StatusException("题源不满足,保存随机抽卷模板失败!");
     }
 
 }

+ 22 - 0
src/main/java/cn/com/qmth/examcloud/tool/service/create_random_paper_template/vo/TemplateStructInfo.java

@@ -0,0 +1,22 @@
+package cn.com.qmth.examcloud.tool.service.create_random_paper_template.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+
+@Setter
+@Getter
+public class TemplateStructInfo implements Serializable {
+
+    private static final long serialVersionUID = -201020692066264844L;
+
+    private Boolean valid;//是否有效
+
+    private Double totalScore;//满分
+
+    private Double difficultyDegree;//难度系数
+
+    // private List<StructQuestionInfo> structQuestionInfo;//题数量
+
+}