xiatian há 2 meses atrás
pai
commit
b67dfd01e5

+ 2 - 0
db/am_db.sql

@@ -22,6 +22,8 @@ CREATE TABLE `am_question` (
   `full_score` double NOT NULL,
   `answer` longtext COLLATE utf8mb4_bin DEFAULT NULL,
   `content` longtext COLLATE utf8mb4_bin NOT NULL,
+  `score_grades` longtext COLLATE utf8mb4_bin DEFAULT NULL,
+  `ext` longtext COLLATE utf8mb4_bin DEFAULT NULL,
   `answer_range_type` varchar(1000) COLLATE utf8mb4_bin NOT NULL,
   `image_slice` varchar(1000) COLLATE utf8mb4_bin DEFAULT NULL,
   `prompt_template` varchar(255) NOT NULL,

BIN
file/question-import.xlsx


+ 0 - 26
src/main/java/cn/com/qmth/am/bean/AutoScoreEnRequest.java

@@ -1,26 +0,0 @@
-package cn.com.qmth.am.bean;
-
-import javax.validation.constraints.NotNull;
-
-import org.springframework.validation.annotation.Validated;
-
-import cn.com.qmth.am.bean.ds.AutoScoreRequest;
-
-/**
- * 自动判分请求参数
- */
-@Validated
-public class AutoScoreEnRequest extends AutoScoreRequest {
-
-    @NotNull(message = "题目名称不能为空")
-    private String questionTitle;
-
-    public String getQuestionTitle() {
-        return questionTitle;
-    }
-
-    public void setQuestionTitle(String questionTitle) {
-        this.questionTitle = questionTitle;
-    }
-
-}

+ 34 - 0
src/main/java/cn/com/qmth/am/bean/ds/AutoScoreRequest.java

@@ -33,6 +33,15 @@ public class AutoScoreRequest {
 
     private double intervalScore = 1;
 
+    // 分档
+    private String scoreGrades;
+
+    // 补充说明
+    private String ext;
+
+    // 试题名称
+    private String questionTitle;
+
     public String getSubjectName() {
         return subjectName;
     }
@@ -95,4 +104,29 @@ public class AutoScoreRequest {
     public void setIntervalScore(double intervalScore) {
         this.intervalScore = intervalScore;
     }
+
+    public String getScoreGrades() {
+        return scoreGrades;
+    }
+
+    public void setScoreGrades(String scoreGrades) {
+        this.scoreGrades = scoreGrades;
+    }
+
+    public String getExt() {
+        return ext;
+    }
+
+    public void setExt(String ext) {
+        this.ext = ext;
+    }
+
+    public String getQuestionTitle() {
+        return questionTitle;
+    }
+
+    public void setQuestionTitle(String questionTitle) {
+        this.questionTitle = questionTitle;
+    }
+
 }

+ 22 - 0
src/main/java/cn/com/qmth/am/entity/QuestionEntity.java

@@ -51,6 +51,12 @@ public class QuestionEntity extends IdEntity {
     // 答题区域类型
     private AnswerRangeType answerRangeType;
 
+    // 分档
+    private String scoreGrades;
+
+    // 补充说明
+    private String ext;
+
     @TableField(value = "image_slice", typeHandler = ImageSliceListTypeHandler.class)
     private List<ImageSlice> imageSlice;
 
@@ -158,4 +164,20 @@ public class QuestionEntity extends IdEntity {
         this.answerRangeType = answerRangeType;
     }
 
+    public String getScoreGrades() {
+        return scoreGrades;
+    }
+
+    public void setScoreGrades(String scoreGrades) {
+        this.scoreGrades = scoreGrades;
+    }
+
+    public String getExt() {
+        return ext;
+    }
+
+    public void setExt(String ext) {
+        this.ext = ext;
+    }
+
 }

+ 0 - 21
src/main/java/cn/com/qmth/am/service/impl/DsMarkingServiceImpl.java

@@ -77,27 +77,6 @@ public class DsMarkingServiceImpl implements DsMarkingService {
         return text;
     }
 
-    // @Override
-    // public AutoScoreResult autoScore(AutoScoreRequest request) {
-    // String question = FreeMarkerUtil.getDsMarkingReq(request);
-    // MarkingReq dreq = new MarkingReq(sysProperty.getMarkingModel());
-    // dreq.addMsg(ChatRole.user, question);
-    // String res = marking(dreq);
-    // ChatResult result = JSONObject.parseObject(res, ChatResult.class);
-    // String text = result.getChoices().stream().filter(choice ->
-    // choice.getMessage().getRole() == ChatRole.assistant)
-    // .map(choice -> choice.getMessage().getContent()).findFirst().orElse("");
-    // try {
-    // AutoScoreResult scoreResult = new AutoScoreResult();
-    // String scoreStr = fomatStr(text);
-    // scoreResult.setTotalScore(Double.valueOf(scoreStr));
-    // return scoreResult;
-    // } catch (Exception e) {
-    // log.error(e.getMessage() + " | " + res);
-    // return null;
-    // }
-    // }
-
     @Override
     public AutoScoreResult autoScore(AutoScoreRequest request, QuestionEntity q) {
         String question = FreeMarkerUtil.getMarkingReq(request, q.getPromptTemplate());

+ 18 - 8
src/main/java/cn/com/qmth/am/service/impl/QuestionServiceImpl.java

@@ -54,7 +54,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity
     private Pattern scoreRex = Pattern.compile("\\[\\[([0-9][0-9]*(.[0-9]+){0,1})分\\]\\]");
 
     private static final String[] EXCEL_HEADER = new String[] { "考试ID", "科目代码", "科目名称", "题目名称", "大题号", "小题号", "满分",
-            "试题内容", "试题答案", "作答区域类型", "作答坐标", "模版文件" };
+            "试题内容", "试题答案", "评分档次", "补充说明", "作答区域类型", "作答坐标", "模版文件" };
 
     @Autowired
     private SysProperty sysProperty;
@@ -272,12 +272,18 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity
             imp.setContent(content);
 
             String answer = trimAndNullIfBlank(line.get(EXCEL_HEADER[8]));
-            // if (StringUtils.isBlank(answer)) {
-            // msg.append(" 试题答案不能为空");
-            // }
+            if (StringUtils.isBlank(answer)) {
+                msg.append(" 试题答案不能为空");
+            }
             imp.setAnswer(getStandardAnswer(answer));
 
-            String rangeType = trimAndNullIfBlank(line.get(EXCEL_HEADER[9]));
+            String scoreGrades = trimAndNullIfBlank(line.get(EXCEL_HEADER[9]));
+            imp.setScoreGrades(scoreGrades);
+
+            String ext = trimAndNullIfBlank(line.get(EXCEL_HEADER[10]));
+            imp.setExt(ext);
+
+            String rangeType = trimAndNullIfBlank(line.get(EXCEL_HEADER[11]));
             AnswerRangeType answerRangeType = null;
             if (StringUtils.isBlank(rangeType)) {
                 msg.append("  作答区域类型不能为空");
@@ -291,7 +297,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity
             }
 
             if (AnswerRangeType.FIXED.equals(answerRangeType)) {
-                String imageSlice = trimAndNullIfBlank(line.get(EXCEL_HEADER[10]));
+                String imageSlice = trimAndNullIfBlank(line.get(EXCEL_HEADER[12]));
                 if (StringUtils.isBlank(imageSlice)) {
                     msg.append("  作答坐标不能为空");
                 } else if (imageSlice.length() > 1000) {
@@ -306,7 +312,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity
                 }
             }
 
-            String template = trimAndNullIfBlank(line.get(EXCEL_HEADER[11]));
+            String template = trimAndNullIfBlank(line.get(EXCEL_HEADER[13]));
             if (StringUtils.isBlank(template)) {
                 msg.append("  模版文件不能为空");
             } else {
@@ -314,7 +320,11 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionDao, QuestionEntity
                 if (val == null) {
                     msg.append("  模版文件有误");
                 } else {
-                    imp.setPromptTemplate(val);
+                    if (PromptTemplate.TRANSLATION.equals(val) && StringUtils.isBlank(imp.getScoreGrades())) {
+                        msg.append("  评分档次不能为空");
+                    } else {
+                        imp.setPromptTemplate(val);
+                    }
                 }
             }
 

+ 5 - 3
src/main/java/cn/com/qmth/am/service/impl/StudentScoreServiceImpl.java

@@ -34,7 +34,6 @@ import com.qmth.boot.tools.models.ByteArray;
 
 import cn.com.qmth.am.bean.AiMarkingDto;
 import cn.com.qmth.am.bean.AnswerImageDto;
-import cn.com.qmth.am.bean.AutoScoreEnRequest;
 import cn.com.qmth.am.bean.ImagePosition;
 import cn.com.qmth.am.bean.ImageSize;
 import cn.com.qmth.am.bean.ImageSlice;
@@ -44,6 +43,7 @@ import cn.com.qmth.am.bean.StudentScoreImageDto;
 import cn.com.qmth.am.bean.StudentScoreInfo;
 import cn.com.qmth.am.bean.StudentScoreVo;
 import cn.com.qmth.am.bean.StudentVo;
+import cn.com.qmth.am.bean.ds.AutoScoreRequest;
 import cn.com.qmth.am.bean.ds.AutoScoreResult;
 import cn.com.qmth.am.config.SysProperty;
 import cn.com.qmth.am.dao.local.StudentScoreDao;
@@ -496,7 +496,7 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
                 return;
             }
             dto.setQuestion(q);
-            AutoScoreEnRequest req = new AutoScoreEnRequest();
+            AutoScoreRequest req = new AutoScoreRequest();
             req.setQuestionBody(q.getContent());
             req.setStandardAnswer(q.getAnswer());
             req.setStudentAnswer(score.getAnswer());
@@ -504,6 +504,8 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
             req.setTotalScore(q.getFullScore());
             req.setIntervalScore(0.1);
             req.setQuestionTitle(q.getTitle());
+            req.setExt(q.getExt());
+            req.setScoreGrades(q.getScoreGrades());
             AutoScoreResult ret = aiMarkingDispose(dto, req);
             if (ret != null) {
                 List<Double> stepScore = new ArrayList<>();
@@ -520,7 +522,7 @@ public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreDao, Studen
         }
     }
 
-    private AutoScoreResult aiMarkingDispose(AiMarkingDto dto, AutoScoreEnRequest req) {
+    private AutoScoreResult aiMarkingDispose(AiMarkingDto dto, AutoScoreRequest req) {
         try {
             return dsMarkingService.autoScore(req, dto.getQuestion());
         } catch (Exception e) {

+ 1 - 6
templates/translation.ftl

@@ -9,12 +9,7 @@ ${item.content}
 </#list>
 
 # 评分规则
-5个档次和对应的分数范围如下:
-- **优秀**(14~15): 原文的信息全部传达,语气和文体风格与原文一致;断句恰当,句式正确。选词妥帖。段落之间、句子之间互应自然,有一定文采
-- **良好**(12~13): 除个别次要信息有疏漏之外,原文的重要信息全部传达,语气和文体风格与原文一致;选词较正确、得体。句子组织与安排符合汉语规范
-- **中等**(10~11): 有少量理解错误或个别漏译,但主要精神与原文一致;拘泥于英文的句式,行文不够顺大,但没有重大的选词和句式错误
-- **及格**(9~10): 有个别重大错误或遗漏,部分信息含混,但总体上基本达意;语句不够连贯,行文灰色,有个别重大的选词和句式错误
-- **不及格**(0~8): 误译、漏译较多,不能传达原文主要精神;用词不当,行文不通顺,语言不符合汉语规范
+${scoreGrades}
 
 # 评分流程
 1. 理解试题内容与评分规则,分析考生作答内容,对比参考答案,准确判断考生作答属于哪个档次