1
0
Go 4 лет назад
Родитель
Сommit
eab57e61d8

+ 42 - 4
front/project/admin/routes/subject/question/page.js

@@ -16,7 +16,18 @@ import { Examination } from '../../../stores/examination';
 import { Exercise } from '../../../stores/exercise';
 
 const QuestionStyleTypeMap = getMap(QuestionStyleType, 'value', 'label');
-
+const DifficultScoreMap = {
+  verbal: {
+    easy: [{ label: 6, value: 6 }, { label: 7.6, value: 7.6 }, { label: 9.2, value: 9.2 }, { label: 10.8, value: 10.8 }, { label: 12.4, value: 12.4 }],
+    medium: [{ label: 14, value: 14 }, { label: 15.6, value: 15.6 }, { label: 17.2, value: 17.2 }, { label: 18.8, value: 18.8 }, { label: 20.4, value: 20.4 }],
+    hard: [{ label: 22, value: 22 }, { label: 23.6, value: 23.6 }, { label: 25.2, value: 25.2 }, { label: 26.8, value: 26.8 }, { label: 28.4, value: 28.4 }],
+  },
+  quant: {
+    easy: [{ label: 12, value: 12 }, { label: 13.5, value: 13.5 }],
+    medium: [{ label: 15, value: 15 }, { label: 16.5, value: 16.5 }, { label: 18, value: 18 }, { label: 19.5, value: 19.5 }, { label: 21, value: 21 }],
+    hard: [{ label: 22.5, value: 22.5 }, { label: 24, value: 24 }, { label: 25.5, value: 25.5 }, { label: 27, value: 27 }, { label: 28.5, value: 28.5 }],
+  },
+};
 export default class extends Page {
   constructor(props) {
     super(props);
@@ -25,6 +36,7 @@ export default class extends Page {
     this.uuid = [];
     this.examinationStructMap = {};
     this.exerciseStructMap = {};
+    this.questionTypeToSubject = {};
   }
 
   init() {
@@ -32,6 +44,11 @@ export default class extends Page {
       Exercise.allStruct().then(result => {
         result = result.filter(row => row.isExamination);
         this.exerciseStructMap = getMap(result, 'id');
+        result.forEach((row) => {
+          if (row.level !== 2) return;
+          const subject = this.exerciseStructMap[row.parentId];
+          this.questionTypeToSubject[row.extend] = subject.extend;
+        });
         return { value: 'exercise', key: 'exercise', label: '练习', title: '练习', children: formatTreeData(result.map(row => { row.title = `${row.titleZh}/${row.titleEn}`; return row; }), 'id', 'title', 'parentId') };
       }),
       Examination.allStruct().then(result => {
@@ -82,7 +99,7 @@ export default class extends Page {
       for (let i = 0; i < col; i += 1) {
         form.getFieldDecorator(`content.table.header[${i}]`);
         for (let j = 0; j < row; j += 1) {
-          console.log(`content.table.data[${j}][${i}]`);
+          // console.log(`content.table.data[${j}][${i}]`);
           form.getFieldDecorator(`content.table.data[${j}][${i}]`);
         }
       }
@@ -93,6 +110,7 @@ export default class extends Page {
       form.getFieldDecorator('content.table.col');
       form.getFieldDecorator('stem');
       form.getFieldDecorator('difficult');
+      form.getFieldDecorator('difficultScore');
       form.getFieldDecorator('questionType');
       form.getFieldDecorator('place');
       form.getFieldDecorator('id');
@@ -102,6 +120,8 @@ export default class extends Page {
       return result;
     })
       .then((result) => {
+        this.refreshPlace(result.questionType);
+        this.refreshDifficultScore(result.questionType, result.difficult);
         this.setState({ associationContentQuestionNos: [], realtionQuestionNos: [] });
         if (result.questionNoIds && result.questionNoIds.length > 0) {
           Question.listNo({ ids: result.questionNoIds }).then(list => {
@@ -140,6 +160,12 @@ export default class extends Page {
     });
   }
 
+  refreshDifficultScore(questionType, difficult) {
+    const subject = this.questionTypeToSubject[questionType];
+    const difficultScore = (DifficultScoreMap[subject] || {})[difficult] || [];
+    this.setState({ difficultScore });
+  }
+
   addNo() {
     const { form } = this.props;
     form.validateFields(['moduleStruct', 'questionNo'], (err) => {
@@ -269,7 +295,7 @@ export default class extends Page {
 
   submit() {
     const { form } = this.props;
-    const fields = ['id', 'questionType', 'place', 'difficult', 'content', 'answer', 'stem', 'keyword', 'questionNoIds', 'officialContent', 'qxContent', 'associationContent'];
+    const fields = ['id', 'questionType', 'place', 'difficult', 'difficultScore', 'content', 'answer', 'stem', 'keyword', 'questionNoIds', 'officialContent', 'qxContent', 'associationContent'];
     form.validateFields(fields, (err) => {
       if (!err) {
         const data = form.getFieldsValue(fields);
@@ -566,6 +592,7 @@ export default class extends Page {
           })(
             <Select select={QuestionType} placeholder='请选择题型' onChange={(v) => {
               this.refreshPlace(v);
+              this.refreshDifficultScore(v, getFieldValue('difficult'));
             }} />,
           )}
         </Form.Item>
@@ -584,7 +611,18 @@ export default class extends Page {
               { required: true, message: '请选择难度' },
             ],
           })(
-            <Select select={QuestionDifficult} placeholder='请选择难度' />,
+            <Select select={QuestionDifficult} placeholder='请选择难度' onChange={(v) => {
+              this.refreshDifficultScore(getFieldValue('questionType'), v);
+            }} />,
+          )}
+        </Form.Item>
+        <Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} label='难度分'>
+          {getFieldDecorator('difficultScore', {
+            rules: [
+              { required: true, message: '请选择难度分' },
+            ],
+          })(
+            <Select select={this.state.difficultScore} placeholder='请选择难度分' />,
           )}
         </Form.Item>
         {/* 阅读题,并且只有一个id才能关联 */}

+ 35 - 0
server/data/src/main/java/com/qxgmat/data/dao/entity/Question.java

@@ -37,6 +37,12 @@ public class Question implements Serializable {
     private String difficult;
 
     /**
+     * 难度分
+     */
+    @Column(name = "`difficult_score`")
+    private Float difficultScore;
+
+    /**
      * 简介:自动从题干提取
      */
     @Column(name = "`description`")
@@ -203,6 +209,24 @@ public class Question implements Serializable {
     }
 
     /**
+     * 获取难度分
+     *
+     * @return difficult_score - 难度分
+     */
+    public Float getDifficultScore() {
+        return difficultScore;
+    }
+
+    /**
+     * 设置难度分
+     *
+     * @param difficultScore 难度分
+     */
+    public void setDifficultScore(Float difficultScore) {
+        this.difficultScore = difficultScore;
+    }
+
+    /**
      * 获取简介:自动从题干提取
      *
      * @return description - 简介:自动从题干提取
@@ -487,6 +511,7 @@ public class Question implements Serializable {
         sb.append(", questionType=").append(questionType);
         sb.append(", place=").append(place);
         sb.append(", difficult=").append(difficult);
+        sb.append(", difficultScore=").append(difficultScore);
         sb.append(", description=").append(description);
         sb.append(", content=").append(content);
         sb.append(", answer=").append(answer);
@@ -568,6 +593,16 @@ public class Question implements Serializable {
         }
 
         /**
+         * 设置难度分
+         *
+         * @param difficultScore 难度分
+         */
+        public Builder difficultScore(Float difficultScore) {
+            obj.setDifficultScore(difficultScore);
+            return this;
+        }
+
+        /**
          * 设置简介:自动从题干提取
          *
          * @param description 简介:自动从题干提取

+ 5 - 3
server/data/src/main/java/com/qxgmat/data/dao/mapping/QuestionMapper.xml

@@ -10,6 +10,7 @@
     <result column="question_type" jdbcType="VARCHAR" property="questionType" />
     <result column="place" jdbcType="VARCHAR" property="place" />
     <result column="difficult" jdbcType="VARCHAR" property="difficult" />
+    <result column="difficult_score" jdbcType="REAL" property="difficultScore" />
     <result column="description" jdbcType="VARCHAR" property="description" />
     <result column="content" jdbcType="VARCHAR" property="content" typeHandler="com.nuliji.tools.mybatis.handler.JsonObjectHandler" />
     <result column="answer" jdbcType="VARCHAR" property="answer" typeHandler="com.nuliji.tools.mybatis.handler.JsonObjectHandler" />
@@ -37,9 +38,10 @@
     <!--
       WARNING - @mbg.generated
     -->
-    `id`, `keyword`, `question_type`, `place`, `difficult`, `description`, `content`, 
-    `answer`, `question_time`, `qx_time`, `official_time`, `association_time`, `association_content`, 
-    `total_time`, `total_number`, `total_correct`, `create_time`, `update_time`, `answer_distributed`
+    `id`, `keyword`, `question_type`, `place`, `difficult`, `difficult_score`, `description`, 
+    `content`, `answer`, `question_time`, `qx_time`, `official_time`, `association_time`, 
+    `association_content`, `total_time`, `total_number`, `total_correct`, `create_time`, 
+    `update_time`, `answer_distributed`
   </sql>
   <sql id="Blob_Column_List">
     <!--

+ 19 - 9
server/gateway-api/src/main/java/com/qxgmat/dto/admin/request/QuestionDto.java

@@ -19,7 +19,7 @@ public class QuestionDto {
     private String description;
 
 //    @NotEmpty(message = "题型不能为空!")
-    private String type;
+    private String questionType;
 
 //    @NotEmpty(message = "考点不能为空!")
     private String place;
@@ -27,6 +27,8 @@ public class QuestionDto {
 //    @NotEmpty(message = "难度不能为空!")
     private String difficult;
 
+    private Float difficultScore;
+
     private Integer[] questionNoIds;
 
     private String qxContent = "";
@@ -49,14 +51,6 @@ public class QuestionDto {
         this.id = id;
     }
 
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
     public String getPlace() {
         return place;
     }
@@ -152,4 +146,20 @@ public class QuestionDto {
     public void setRelationQuestion(int[] relationQuestion) {
         this.relationQuestion = relationQuestion;
     }
+
+    public Float getDifficultScore() {
+        return difficultScore;
+    }
+
+    public void setDifficultScore(Float difficultScore) {
+        this.difficultScore = difficultScore;
+    }
+
+    public String getQuestionType() {
+        return questionType;
+    }
+
+    public void setQuestionType(String questionType) {
+        this.questionType = questionType;
+    }
 }

+ 10 - 0
server/gateway-api/src/main/java/com/qxgmat/dto/admin/response/QuestionDetailDto.java

@@ -21,6 +21,8 @@ public class QuestionDetailDto {
 
     private String difficult;
 
+    private Float difficultScore;
+
 //    private List<QuestionNoExtendDto> questionNos;
     private Integer[] questionNoIds;
 
@@ -129,4 +131,12 @@ public class QuestionDetailDto {
     public void setQuestionType(String questionType) {
         this.questionType = questionType;
     }
+
+    public Float getDifficultScore() {
+        return difficultScore;
+    }
+
+    public void setDifficultScore(Float difficultScore) {
+        this.difficultScore = difficultScore;
+    }
 }

+ 17 - 13
server/gateway-api/src/main/java/com/qxgmat/service/UserPaperService.java

@@ -93,10 +93,9 @@ public class UserPaperService extends AbstractService {
      * @param userId
      * @param origin
      * @param originId
-     * @param IInitPaper
      * @return
      */
-    public UserPaper getByPaper(Integer userId, PaperOrigin origin, PaperModule module, Integer originId, InitPaper IInitPaper){
+    public UserPaper getByPaper(Integer userId, PaperOrigin origin, Integer originId){
         // 查找对应的paper是否有,没有则添加
         Example example = new Example(UserPaper.class);
         UserPaper paper;
@@ -121,23 +120,28 @@ public class UserPaperService extends AbstractService {
             );
 
             paper = one(userPaperMapper, example);
-            if (paper == null){
-                paper = UserPaper.builder()
-                        .userId(userId)
-                        .paperOrigin(origin.key)
-                        .paperModule(module.key)
-                        .originId(originId)
-                        .build();
-                // 回调,根据模块更新设置
-                IInitPaper.callback(paper, originId);
-                paper = add(paper);
-            }
         }
 
         return paper;
     }
 
     /**
+     * 生成用户做题组卷
+     * @param userId
+     * @param origin
+     * @param module
+     * @param originId
+     * @return
+     */
+    public UserPaper newByPaper(Integer userId, PaperOrigin origin, PaperModule module, Integer originId){
+        return UserPaper.builder()
+                .userId(userId)
+                .paperOrigin(origin.key)
+                .paperModule(module.key)
+                .originId(originId)
+                .build();
+    }
+    /**
      * 重置做题信息:不自动关联最后次做题记录
      * @param id
      * @return

+ 2 - 9
server/gateway-api/src/main/java/com/qxgmat/service/UserQuestionService.java

@@ -170,10 +170,9 @@ public class UserQuestionService extends AbstractService {
      * 根据用户report创建下一题
      * @param report
      * @param lastQuestion
-     * @param IInitQuestion
      * @return
      */
-    public UserQuestion addByReport(UserReport report, UserQuestion lastQuestion, InitQuestion IInitQuestion){
+    public UserQuestion newByReport(UserReport report, UserQuestion lastQuestion){
         // 根据report模块获取试题所属模块
         QuestionModule module = QuestionModule.WithPaper(PaperModule.ValueOf(report.getPaperModule()));
         UserQuestion question = UserQuestion.builder()
@@ -183,13 +182,7 @@ public class UserQuestionService extends AbstractService {
                 // 添加题目序号
                 .no(lastQuestion != null ? lastQuestion.getNo() + 1: 1)
                 .build();
-        // 回调,根据模块更新设置
-        boolean result = IInitQuestion.callback(question, report, lastQuestion);
-        if (!result) {
-            // 做题结束
-            return null;
-        }
-        return add(question);
+        return question;
     }
 
     /**

+ 123 - 76
server/gateway-api/src/main/java/com/qxgmat/service/extend/QuestionFlowService.java

@@ -211,59 +211,13 @@ public class QuestionFlowService {
             return true;
         });
         nextCallback.put(PaperModule.EXAMINATION, (question, report, lastQuestion)->{
-            JSONObject setting = report.getSetting();
-            JSONArray order = setting.getJSONArray("order");
-            String stage = setting.getString("stage");
-            JSONObject time = setting.getJSONObject("time");
-            JSONObject number = setting.getJSONObject("number");
-            time.put(stage, time.getIntValue(stage)+ question.getUserTime());
-            Integer totalNumber = toolsService.examinationSubjectNumber(stage);
-            // 判断数量是否已经完成
-            if (number.getIntValue(stage) >= totalNumber){
-                // 进入下一阶段
-                int index = order.indexOf(stage);
-                if (index == order.size() - 1){
-                    // 完成所有阶段,结束考试
-                    return false;
-                }
-                stage = order.getString(index + 1);
-                setting.put("stage", stage);
-            }
-            // 获取本阶段完成数,剩余题目数
-            Integer subnumber =  number.getIntValue(stage);
-            Integer surplus = totalNumber - subnumber;
-            QuestionSubject subject = QuestionSubject.ValueOf(stage);
-            List<String> questionTypes = QuestionType.FromSubject(subject);
-            List<UserQuestion> userQuestionList = userQuestionService.listByReportAndType(report.getUserId(), report.getId(), questionTypes);
-            Collection ids = Transform.getIds(userQuestionList, UserQuestion.class, "questionNoId");
-            // 根据设置出题
-            Integer questionNoId = 0;
             ExaminationPaper paper = examinationPaperService.get(report.getOriginId());
-            if (paper.getIsAdapt() > 0 && QuestionSubject.SupportAdapt(subject)){
-                switch(subject){
-                    case VERBAL:
-                        questionNoId = verbalCompute(paper, setting, subnumber, ids, userQuestionList);
-                        break;
-                    case QUANT:
-                        questionNoId = quantCompute(paper, setting, subnumber, ids, userQuestionList);
-                        break;
-                    default:
-                        throw new ParameterException("模考出题流程错误:"+subject.key+"不支持适应性判断");
-                }
-            }else{
-                questionNoId = randomCompute(subject, paper, questionTypes, setting, subnumber, ids, userQuestionList);
-            }
-            if (questionNoId == 0) {
-                throw new ParameterException("模考出题流程错误:题目生成错误");
+            if (!examinationCompute(paper, report, lastQuestion, question)){
+                return false;
             }
-            QuestionNoRelation relation = questionNoService.getWithRelation(questionNoId);
-            question.setQuestionNoId(relation.getId());
-            question.setQuestionId(relation.getQuestionId());
-            question.setQuestionType(relation.getQuestion().getQuestionType());
-            question.setTime(toolsService.computerTime(relation));
 
             // 保存report: 更新setting
-            userReportService.edit(UserReport.builder().id(report.getId()).setting(setting).build());
+            userReportService.edit(UserReport.builder().id(report.getId()).setting(report.getSetting()).build());
             return true;
         });
 
@@ -381,18 +335,14 @@ public class QuestionFlowService {
             }
         }
 
-        InitPaper callback = makePaperCallback.get(module);
+        UserPaper paper = userPaperService.newByPaper(userId, origin, PaperModule.WithQuestion(module), 0);
+        paper.setQuestionNumber(questionNoIds.size());
+        paper.setQuestionNoIds(questionNoIds.toArray(new Integer[0]));
 
-        UserPaper paper = UserPaper.builder()
-                .userId(userId)
-                .paperOrigin(origin.key)
-                .paperModule(module.key)
-                .questionNoIds(questionNoIds.toArray(new Integer[0]))
-                .questionNumber(questionNoIds.size())
-                .originId(0)
-                .build();
+        InitPaper callback = makePaperCallback.get(module);
         callback.callback(paper, 0);
         paper = userPaperService.add(paper);
+
         // 绑定关系,用于下次处理过滤
         userPaperQuestionService.addOrigin(userId, paper.getId(), questionOrigin, module, questionNoIds);
         return paper;
@@ -421,7 +371,14 @@ public class QuestionFlowService {
     @Transactional
     public UserPaper paper(Integer userId, PaperOrigin origin, Integer paperId){
         PaperModule module = PaperModule.WithOrigin(origin);
-        return userPaperService.getByPaper(userId, origin, module, paperId, initPaperCallback.get(module));
+        UserPaper paper = userPaperService.getByPaper(userId, origin, paperId);
+        if (paper == null){
+            paper = userPaperService.newByPaper(userId, origin, module, paperId);
+            InitPaper callback  = initPaperCallback.get(module);
+            callback.callback(paper, paperId);
+            paper = userPaperService.add(paper);
+        }
+        return paper;
     }
 
     /**
@@ -441,10 +398,14 @@ public class QuestionFlowService {
             paper.setIsReset(0);
             userPaperService.edit(paper);
         }else if(setting == null){
+            // 对于长难句这种没有设置开始页的,读取最后一次
             userReport = userReportService.getLastByPaper(userId, paper.getId());
         }
         if (userReport == null){
-            userReport = userReportService.addByPaper(paper, setting, initReportCallback.get(PaperModule.ValueOf(paper.getPaperModule())));
+            userReport = userReportService.newByPaper(paper, setting);
+            InitReport callback = initReportCallback.get(PaperModule.ValueOf(paper.getPaperModule()));
+            callback.callback(userReport, paper);
+            userReportService.add(userReport);
         }
 
         return relationReport(userReport);
@@ -502,7 +463,11 @@ public class QuestionFlowService {
             if (!userReport.getUserId().equals(userId)){
                 throw new ParameterException("试卷不存在");
             }
-            userQuestion = userQuestionService.addByReport(userReport, userQuestion, nextCallback.get(PaperModule.ValueOf(userReport.getPaperModule())));
+            UserQuestion lastQuestion = userQuestion;
+            userQuestion = userQuestionService.newByReport(userReport, lastQuestion);
+            InitQuestion callback = nextCallback.get(PaperModule.ValueOf(userReport.getPaperModule()));
+            callback.callback(userQuestion, userReport, lastQuestion);
+            userQuestion = userQuestionService.add(userQuestion);
         }
 
         return userQuestion;
@@ -568,27 +533,47 @@ public class QuestionFlowService {
         if (origin != PaperOrigin.EXAMINATION){
             throw new ParameterException("不是模考试卷");
         }
-        JSONObject setting = userReport.getSetting();
 
+        ExaminationPaper paper = examinationPaperService.get(userReport.getOriginId());
+
+        JSONObject setting = userReport.getSetting();
         // 当前stage,补全所有时间,切换成下一个stage
-        String stage = setting.getString("stage");
         JSONArray order = setting.getJSONArray("order");
+        String stage = setting.getString("stage");
         JSONObject time = setting.getJSONObject("time");
         JSONObject number = setting.getJSONObject("number");
         Integer useTime = time.getInteger(stage);
         Integer totalTime = toolsService.examinationSubjectTime(stage);
         time.put(stage, totalTime);
-        setting.put("stage", order.getString(order.indexOf(stage) + 1));
-        // 更新setting
-        userReportService.edit(UserReport.builder().id(userReportId).setting(setting).build());
 
+        // 自动提交所有该stage的题目
+        Integer totalNumber = toolsService.examinationSubjectNumber(stage);
         // 自动提交最后一题
-        UserQuestion userQuestion = userQuestionService.getLastByReport(userId, userReportId);
-        if(userQuestion != null && userQuestion.getUserTime() == 0){
-            userQuestion.setUserTime(totalTime - useTime);
-            userQuestion.setSetting(new JSONObject());
-            userQuestion.setUserAnswer(new JSONObject());
-            this.submit(userId, userQuestion);
+        UserQuestion lastQuestion = userQuestionService.getLastByReport(userId, userReportId);
+        UserQuestion question;
+        if(lastQuestion != null && lastQuestion.getUserTime() == 0){
+            lastQuestion.setUserTime(totalTime - useTime);
+            this.submit(userId, lastQuestion);
+        }
+        // 判断未完成题目数,自动生成
+        question = userQuestionService.newByReport(userReport, lastQuestion);
+        while(number.getIntValue(stage) < totalNumber){
+            examinationCompute(paper, userReport, lastQuestion, question);
+            question = userQuestionService.add(question);
+            lastQuestion = question;
+            question = userQuestionService.newByReport(userReport, lastQuestion);
+        }
+
+        // 更新setting
+        userReportService.edit(UserReport.builder()
+                .id(userReportId)
+                .setting(setting).build());
+
+        // 如果是最后阶段。直接完成
+        int index = order.indexOf(stage);
+        if (index == order.size() - 1){
+            // 完成所有阶段,结束考试
+            this.finish(userId, userReport.getId());
         }
         return true;
     }
@@ -633,6 +618,68 @@ public class QuestionFlowService {
     }
 
     /**
+     * 模考完整出题逻辑
+     * @param paper
+     * @param report
+     * @param lastQuestion
+     * @param question
+     * @return
+     */
+    public boolean examinationCompute(ExaminationPaper paper, UserReport report, UserQuestion lastQuestion, UserQuestion question){
+        JSONObject setting = report.getSetting();
+        JSONArray order = setting.getJSONArray("order");
+        String stage = setting.getString("stage");
+        JSONObject time = setting.getJSONObject("time");
+        JSONObject number = setting.getJSONObject("number");
+        time.put(stage, time.getIntValue(stage)+ lastQuestion.getUserTime());
+        Integer totalNumber = toolsService.examinationSubjectNumber(stage);
+        // 判断数量是否已经完成
+        if (number.getIntValue(stage) >= totalNumber){
+            // 进入下一阶段
+            int index = order.indexOf(stage);
+            if (index == order.size() - 1){
+                // 完成所有阶段,结束考试
+                return false;
+            }
+            stage = order.getString(index + 1);
+            setting.put("stage", stage);
+        }
+        // 获取本阶段完成数,剩余题目数
+        Integer subnumber =  number.getIntValue(stage);
+        Integer surplus = totalNumber - subnumber;
+        QuestionSubject subject = QuestionSubject.ValueOf(stage);
+        List<String> questionTypes = QuestionType.FromSubject(subject);
+        List<UserQuestion> userQuestionList = userQuestionService.listByReportAndType(report.getUserId(), report.getId(), questionTypes);
+        Collection ids = Transform.getIds(userQuestionList, UserQuestion.class, "questionNoId");
+        // 根据设置出题
+        Integer questionNoId = 0;
+        if (paper.getIsAdapt() > 0 && QuestionSubject.SupportAdapt(subject)){
+            switch(subject){
+                case VERBAL:
+                    questionNoId = verbalCompute(paper, setting, subnumber, ids, userQuestionList);
+                    break;
+                case QUANT:
+                    questionNoId = quantCompute(paper, setting, subnumber, ids, userQuestionList);
+                    break;
+                default:
+                    throw new ParameterException("模考出题流程错误:"+subject.key+"不支持适应性判断");
+            }
+        }else{
+            questionNoId = randomCompute(subject, paper, questionTypes, setting, subnumber, ids, userQuestionList);
+        }
+        if (questionNoId == 0) {
+            throw new ParameterException("模考出题流程错误:题目生成错误");
+        }
+        QuestionNoRelation relation = questionNoService.getWithRelation(questionNoId);
+        question.setQuestionNoId(relation.getId());
+        question.setQuestionId(relation.getQuestionId());
+        question.setQuestionType(relation.getQuestion().getQuestionType());
+        question.setTime(toolsService.computerTime(relation));
+        // 更新题目数
+        number.put(stage, subnumber + 1);
+        return true;
+    }
+    /**
      * 语文出题计算
      * @param setting
      * @param subnumber
@@ -1425,7 +1472,6 @@ public class QuestionFlowService {
 
             // 题型难度分计算
             QuestionDifficult questionDifficult = QuestionDifficult.ValueOf(difficultKey);
-            Integer difficultScore = QuestionDifficult.GetScore(questionDifficult);
 
             if (userQuestion.getIsCorrect() > 0){
                 typeInfo.put("diffCorrect", typeInfo.getFloatValue("diffCorrect") + toolsService.diffScore(relation.getTotalNumber(), relation.getTotalCorrect(), questionDifficult));
@@ -1433,7 +1479,8 @@ public class QuestionFlowService {
                 typeInfo.put("diffIncorrect", typeInfo.getFloatValue("diffIncorrect") + toolsService.diffScore(relation.getTotalNumber(), relation.getTotalCorrect(), questionDifficult));
             }
 
-            subjectInfo.put("difficultScore", subjectInfo.getIntValue("difficultScore")+difficultScore);
+            float difficultScore = relation.getQuestion().getDifficultScore();
+            subjectInfo.put("difficultScore", subjectInfo.getFloatValue("difficultScore")+difficultScore);
         }
 
         // 计算难度平均值
@@ -1447,10 +1494,10 @@ public class QuestionFlowService {
         // 学科得分计算
         JSONObject quantSubject = subjectMap.getJSONObject(QuestionSubject.QUANT.key);
         JSONObject quantInfo = quantSubject.getJSONObject("info");
-        Integer quantScore = toolsService.quantScore(quantInfo.getIntValue("number"), quantInfo.getIntValue("userNumber"), quantInfo.getInteger("difficultScore"), quantInfo.getInteger("userCorrect"));
+        Integer quantScore = toolsService.quantScore(quantInfo.getIntValue("number"), quantInfo.getIntValue("userNumber"), quantInfo.getFloatValue("difficultScore"), quantInfo.getInteger("userCorrect"));
         JSONObject verbalSubject = subjectMap.getJSONObject(QuestionSubject.VERBAL.key);
         JSONObject verbalInfo = verbalSubject.getJSONObject("info");
-        Integer verbalScore = toolsService.verbalScore(verbalInfo.getIntValue("number"), verbalInfo.getIntValue("userNumber"), verbalInfo.getInteger("difficultScore"), verbalInfo.getInteger("userCorrect"));
+        Integer verbalScore = toolsService.verbalScore(verbalInfo.getIntValue("number"), verbalInfo.getIntValue("userNumber"), verbalInfo.getFloatValue("difficultScore"), verbalInfo.getInteger("userCorrect"));
         JSONObject irSubject = subjectMap.getJSONObject(QuestionSubject.IR.key);
         JSONObject irInfo = irSubject.getJSONObject("info");
         Integer irScore = toolsService.irScore(irInfo.getIntValue("number"), irInfo.getIntValue("userNumber"), irInfo.getInteger("difficultScore"), irInfo.getInteger("userCorrect"));

+ 36 - 4
server/gateway-api/src/main/java/com/qxgmat/service/extend/ToolsService.java

@@ -32,6 +32,10 @@ public class ToolsService {
     @Value("${examination.quantD}")
     private Integer quantD;
 
+    private Integer scoreMax = 51;
+
+    private Integer scoreMin = 6;
+
     @Resource
     private SettingService settingService;
 
@@ -238,8 +242,22 @@ public class ToolsService {
      * @param correctNumber
      * @return
      */
-    public Integer quantScore(Integer number, Integer userNumber, Integer difficultScore, Integer correctNumber){
-        return quantC * correctNumber / number + quantD * difficultScore / userNumber;
+//    public Integer quantScore(Integer number, Integer userNumber, Integer difficultScore, Integer correctNumber){
+//        return quantC * correctNumber / number + quantD * difficultScore / userNumber;
+//    }
+    /**
+     * Quant分数计算:17+平均正确率*19.45+平均难度*0.72
+     * @param number
+     * @param userNumber
+     * @param difficultScore
+     * @param correctNumber
+     * @return
+     */
+    public Integer quantScore(Integer number, Integer userNumber, float difficultScore, Integer correctNumber){
+        int score = (int)Math.round(17 + 19.45 * correctNumber / number + 0.72 * difficultScore / userNumber);
+        if (score > scoreMax) return scoreMax;
+        if (score < scoreMin) return scoreMin;
+        return score;
     }
 
     /**
@@ -250,8 +268,22 @@ public class ToolsService {
      * @param correctNumber
      * @return
      */
-    public Integer verbalScore(Integer number, Integer userNumber, Integer difficultScore, Integer correctNumber){
-        return verbalA * correctNumber / number + verbalB * difficultScore / userNumber;
+//    public Integer verbalScore(Integer number, Integer userNumber, Integer difficultScore, Integer correctNumber){
+//        return verbalA * correctNumber / number + verbalB * difficultScore / userNumber;
+//    }
+    /**
+     * Verbal分数计算:23.59 + 平均正确率*29.6+平均难度*1.72
+     * @param number
+     * @param userNumber
+     * @param difficultScore
+     * @param correctNumber
+     * @return
+     */
+    public Integer verbalScore(Integer number, Integer userNumber, float difficultScore, Integer correctNumber){
+        int score = (int)Math.round(23.59 + 29.6 * correctNumber / number + 1.72 * difficultScore / userNumber);
+        if (score > scoreMax) return scoreMax;
+        if (score < scoreMin) return scoreMin;
+        return score;
     }
 
     /**

+ 2 - 6
server/gateway-api/src/main/java/com/qxgmat/service/inline/UserReportService.java

@@ -173,11 +173,10 @@ public class UserReportService extends AbstractService {
      * 根据用户paper生成一份新的report记录
      * @param paper
      * @param setting
-     * @param IInitReport
      * @return
      */
-    public UserReport addByPaper(UserPaper paper, JSONObject setting, InitReport IInitReport){
-        UserReport report = UserReport.builder()
+    public UserReport newByPaper(UserPaper paper, JSONObject setting){
+        return UserReport.builder()
                 .paperModule(paper.getPaperModule())
                 .paperOrigin(paper.getPaperOrigin())
                 .originId(paper.getOriginId())
@@ -191,9 +190,6 @@ public class UserReportService extends AbstractService {
                 .userNumber(0)
                 .userTime(0)
                 .build();
-        // 回调,根据模块更新设置
-        IInitReport.callback(report, paper);
-        return add(report);
     }
 
     /**