Просмотр исходного кода

改试题导入业务功能,问卷题库去除分数答案难度等级

zhaosongshan 7 месяцев назад
Родитель
Сommit
c71656abdb

+ 1 - 1
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/domain/Question.java

@@ -51,7 +51,7 @@ public class Question implements Serializable {
     private Integer infoTextContentId;
 
     /**
-     * 题库类型 1练习题目库  2问卷题目库
+     * 题库类型 1练习题目库  2问卷题目库 3 考试题目库
      */
     private String bankType;
 

+ 1 - 1
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/domain/question/QuestionExcel.java

@@ -21,7 +21,7 @@ public class QuestionExcel {
     @ExcelProperty("题目序号")
     private String id;
     /**
-     * 题库类型 1练习题目库  2问卷题目库
+     * 题库类型 1练习题目库  2问卷题目库 3考试题目库
      */
     @ExcelProperty("所属题库")
     private String bankType;

+ 28 - 20
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/service/impl/QuestionServiceImpl.java

@@ -389,7 +389,8 @@ public class QuestionServiceImpl extends BaseServiceImpl<Question> implements Qu
                     /////////////////////////////////////////////////////////////////////////////////////////////////////
                     if(okExcel.getIsContent()){
                         String questionType = questionList.get(i).getQuestionType();
-                        if(questionType ==null || !questionType.equals("填空题")){
+                        String bankType = questionList.get(i).getBankType();
+                        if(bankType != null && !bankType.equals("问卷题目库") && questionType != null && !questionType.equals("填空题")){
                             String correctContent = questionList.get(i).getCorrectContent();
                             if(correctContent == null || correctContent.trim().isEmpty()){
                                 errorQuestionList.add("题目序号: "+questionId+" , 答案内容为空请检查.");
@@ -401,24 +402,30 @@ public class QuestionServiceImpl extends BaseServiceImpl<Question> implements Qu
                     }
                     /////////////////////////////////////////////////////////////////////////////////////////////////////
                     if(okExcel.getIsContent()){
-                        String itemScore = questionList.get(i).getItemScore();
-                        boolean isItemScore = positiveInteger(itemScore);
-                        if(!isItemScore){
-                            errorQuestionList.add("题目序号: "+questionId+" , 题目分数数据格式错误请检查.");
-                            errorIdSet.add(questionId);
-                        }else{
-                            okExcel.setItemScore(itemScore);
+                        String bankType = questionList.get(i).getBankType();
+                        if(bankType != null && !bankType.equals("问卷题目库")){
+                            String itemScore = questionList.get(i).getItemScore();
+                            boolean isItemScore = positiveInteger(itemScore);
+                            if(!isItemScore){
+                                errorQuestionList.add("题目序号: "+questionId+" , 题目分数数据格式错误请检查.");
+                                errorIdSet.add(questionId);
+                            }else{
+                                okExcel.setItemScore(itemScore);
+                            }
                         }
                     }
                     /////////////////////////////////////////////////////////////////////////////////////////////////////
                     if(okExcel.getIsContent()){
-                        String difficult = questionList.get(i).getDifficult();
-                        boolean isDifficult = positiveInteger(difficult);
-                        if(!isDifficult){
-                            errorQuestionList.add("题目序号: "+questionId+" , 题目难度数据格式错误请检查.");
-                            errorIdSet.add(questionId);
-                        }else{
-                            okExcel.setDifficult(difficult);
+                        String bankType = questionList.get(i).getBankType();
+                        if(bankType != null && !bankType.equals("问卷题目库")){
+                            String difficult = questionList.get(i).getDifficult();
+                            boolean isDifficult = positiveInteger(difficult);
+                            if(!isDifficult){
+                                errorQuestionList.add("题目序号: "+questionId+" , 题目难度数据格式错误请检查.");
+                                errorIdSet.add(questionId);
+                            }else{
+                                okExcel.setDifficult(difficult);
+                            }
                         }
                     }
                     /////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -454,8 +461,12 @@ public class QuestionServiceImpl extends BaseServiceImpl<Question> implements Qu
                 List<QuestionExcel> itemList = questionOKList.stream().filter(item -> item.getId().equals(okExcel.getId())).collect(Collectors.toList());
                 List<String> correct = itemList.stream().map(QuestionExcel::getCorrectContent).filter(Objects::nonNull).collect(Collectors.toList());
                 int questionType = Integer.parseInt(okExcel.getQuestionType());
-                int score = Integer.parseInt(okExcel.getItemScore());
-                int difficult = Integer.parseInt(okExcel.getDifficult());
+                int score = 0, difficult = 0;
+                if(!"3".equals(okExcel.getBankType())){
+                    score = Integer.parseInt(okExcel.getItemScore());
+                    difficult = Integer.parseInt(okExcel.getDifficult());
+                }
+
                 Question question = new Question();
                 question.setBankType(okExcel.getBankType());
                 question.setQuestionType(questionType);
@@ -466,9 +477,6 @@ public class QuestionServiceImpl extends BaseServiceImpl<Question> implements Qu
                 question.setCreateTime(now());
                 question.setDeleted(false);
 
-
-
-
                 if(QuestionTypeEnum.GapFilling.getCode() == questionType){ // 填空题
                    int count = checkEmptyCount(okExcel.getTitleContent());
                    if(count == 0){