Преглед на файлове

试题导入接口fixbug难度

xiatian преди 1 година
родител
ревизия
fd8c619399

+ 104 - 84
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/util/PaperUtil.java

@@ -424,100 +424,120 @@ public class PaperUtil {
 			return false;
 		}
 	}
-	
-	public static void checkUpdate(PaperDetailUnitExp updateUnit,PaperDetailUnit baseUnit,String msg) {
-    	Question baseQuestion = baseUnit.getQuestion();
-        Question updateQuestion = updateUnit.getQuestion();
-    	if (baseUnit.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
-            if (updateQuestion.getId().equals(baseQuestion.getId())) {
-            	return;
-            } else {
-                int size = baseQuestion.getSubQuestions().size();
-                // 判断更新的对象是哪个子题
-                for (int index = 1; index <= size; index++) {
-
-                    Question sub = baseQuestion.getSubQuestions().get(index - 1);
-                    if (updateQuestion.getId().equals(sub.getId())) {
-                    	if(updateQuestion.getScore().doubleValue()!=baseUnit.getSubScoreList().get(index - 1).doubleValue()) {
+
+	public static void checkUpdate(PaperDetailUnitExp updateUnit, PaperDetailUnit baseUnit, String msg) {
+		Question baseQuestion = baseUnit.getQuestion();
+		Question updateQuestion = updateUnit.getQuestion();
+		if (baseUnit.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
+			if (updateQuestion.getId().equals(baseQuestion.getId())) {
+				return;
+			} else {
+				int size = baseQuestion.getSubQuestions().size();
+				// 判断更新的对象是哪个子题
+				for (int index = 1; index <= size; index++) {
+
+					Question sub = baseQuestion.getSubQuestions().get(index - 1);
+					if (updateQuestion.getId().equals(sub.getId())) {
+						if (updateQuestion.getScore().doubleValue() != baseUnit.getSubScoreList().get(index - 1)
+								.doubleValue()) {
 //                    		throw new StatusException("500", msg+"不能修改分数");
-                    	}
-                        checkUpdate(updateQuestion, sub,msg);
-
-                    }
-                }
-            }
-        } else {
-        	if(updateUnit.getScore().doubleValue()!=baseUnit.getScore().doubleValue()) {
+						}
+						checkUpdate(updateQuestion, sub, msg);
+
+					}
+				}
+			}
+		} else {
+			if (updateUnit.getScore().doubleValue() != baseUnit.getScore().doubleValue()) {
 //        		throw new StatusException("500", msg+"不能修改分数");
-        	}
-        	checkUpdate(updateQuestion, baseQuestion,msg);
-        }
-    }
-	public static void checkUpdate(Question update,Question base,String msg) {
-    	if(QuesStructType.SINGLE_ANSWER_QUESTION.equals(base.getQuestionType())
-    			||QuesStructType.MULTIPLE_ANSWER_QUESTION.equals(base.getQuestionType())){
-	    	if(update.getQuesOptions().size()!=base.getQuesOptions().size()) {
-	    		throw new StatusException("500", msg+"不能修改选项数量");
-	    	}
-    	}
-    	if(QuesStructType.SINGLE_ANSWER_QUESTION.equals(base.getQuestionType())
-    			||QuesStructType.MULTIPLE_ANSWER_QUESTION.equals(base.getQuestionType())
-    			||QuesStructType.BOOL_ANSWER_QUESTION.equals(base.getQuestionType())){
-	    	if(!update.getQuesAnswer().equals(base.getQuesAnswer())) {
+			}
+			checkUpdate(updateQuestion, baseQuestion, msg);
+		}
+	}
+
+	public static void checkUpdate(Question update, Question base, String msg) {
+		if (QuesStructType.SINGLE_ANSWER_QUESTION.equals(base.getQuestionType())
+				|| QuesStructType.MULTIPLE_ANSWER_QUESTION.equals(base.getQuestionType())) {
+			if (update.getQuesOptions().size() != base.getQuesOptions().size()) {
+				throw new StatusException("500", msg + "不能修改选项数量");
+			}
+		}
+		if (QuesStructType.SINGLE_ANSWER_QUESTION.equals(base.getQuestionType())
+				|| QuesStructType.MULTIPLE_ANSWER_QUESTION.equals(base.getQuestionType())
+				|| QuesStructType.BOOL_ANSWER_QUESTION.equals(base.getQuestionType())) {
+			if (!update.getQuesAnswer().equals(base.getQuesAnswer())) {
 //	    		throw new StatusException("500", msg+"不能修改客观题答案");
-	    	}
-    	}
-    	if(!answerTypeEquals(update.getAnswerType(),base.getAnswerType())) {
-    		throw new StatusException("500", msg+"不能修改作答类型");
-    	}
-    }
-	
-	private static boolean answerTypeEquals(AnswerType now,AnswerType old) {
-		if(now==null&&old==null) {
+			}
+		}
+		if (!answerTypeEquals(update.getAnswerType(), base.getAnswerType())) {
+			throw new StatusException("500", msg + "不能修改作答类型");
+		}
+	}
+
+	private static boolean answerTypeEquals(AnswerType now, AnswerType old) {
+		if (now == null && old == null) {
 			return true;
 		}
-		if(now==null&&old!=null) {
+		if (now == null && old != null) {
 			return false;
 		}
-		if(AnswerType.DIVERSIFIED_TEXT.equals(now)&&old==null) {
+		if (AnswerType.DIVERSIFIED_TEXT.equals(now) && old == null) {
 			return true;
 		}
 		return now.equals(old);
 	}
-    
-    public static void checkUpdateOption(PaperDetailUnitExp updateUnit,PaperDetailUnit baseUnit,String msg) {
-    	Question baseQuestion = baseUnit.getQuestion();
-        Question updateQuestion = updateUnit.getQuestion();
-    	if (baseUnit.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
-            if (updateQuestion.getId().equals(baseQuestion.getId())) {
-            	return;
-            } else {
-                int size = baseQuestion.getSubQuestions().size();
-                // 判断更新的对象是哪个子题
-                for (int index = 1; index <= size; index++) {
-
-                    Question sub = baseQuestion.getSubQuestions().get(index - 1);
-                    if (updateQuestion.getId().equals(sub.getId())) {
-                    	checkUpdateOption(updateQuestion, sub,msg);
-
-                    }
-                }
-            }
-        } else {
-        	checkUpdateOption(updateQuestion, baseQuestion,msg);
-        }
-    }
-    
-    public static void checkUpdateOption(Question update,Question base,String msg) {
-    	if(QuesStructType.SINGLE_ANSWER_QUESTION.equals(base.getQuestionType())
-    			||QuesStructType.MULTIPLE_ANSWER_QUESTION.equals(base.getQuestionType())){
-	    	if(update.getQuesOptions().size()!=base.getQuesOptions().size()) {
-	    		throw new StatusException("500", msg+"不能修改选项数量");
-	    	}
-    	}
-    	if(!answerTypeEquals(update.getAnswerType(),base.getAnswerType())) {
-    		throw new StatusException("500", msg+"不能修改作答类型");
-    	}
-    }
+
+	public static void checkUpdateOption(PaperDetailUnitExp updateUnit, PaperDetailUnit baseUnit, String msg) {
+		Question baseQuestion = baseUnit.getQuestion();
+		Question updateQuestion = updateUnit.getQuestion();
+		if (baseUnit.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION) {
+			if (updateQuestion.getId().equals(baseQuestion.getId())) {
+				return;
+			} else {
+				int size = baseQuestion.getSubQuestions().size();
+				// 判断更新的对象是哪个子题
+				for (int index = 1; index <= size; index++) {
+
+					Question sub = baseQuestion.getSubQuestions().get(index - 1);
+					if (updateQuestion.getId().equals(sub.getId())) {
+						checkUpdateOption(updateQuestion, sub, msg);
+
+					}
+				}
+			}
+		} else {
+			checkUpdateOption(updateQuestion, baseQuestion, msg);
+		}
+	}
+
+	public static void checkUpdateOption(Question update, Question base, String msg) {
+		if (QuesStructType.SINGLE_ANSWER_QUESTION.equals(base.getQuestionType())
+				|| QuesStructType.MULTIPLE_ANSWER_QUESTION.equals(base.getQuestionType())) {
+			if (update.getQuesOptions().size() != base.getQuesOptions().size()) {
+				throw new StatusException("500", msg + "不能修改选项数量");
+			}
+		}
+		if (!answerTypeEquals(update.getAnswerType(), base.getAnswerType())) {
+			throw new StatusException("500", msg + "不能修改作答类型");
+		}
+	}
+
+	public static String getDifficulty(Double difficultyDegree) {
+		if (difficultyDegree == null) {
+			throw new StatusException("试题难度值不能为空");
+		}
+		if (difficultyDegree < 0 || difficultyDegree > 1) {
+			throw new StatusException("试题难度值只能是0到1.0");
+		}
+		String difficulty;
+		if (difficultyDegree >= 0 && difficultyDegree < 0.4) {
+			difficulty = "难";
+		} else if (difficultyDegree >= 0.4 && difficultyDegree < 0.8) {
+			difficulty = "中";
+		} else {
+			difficulty = "易";
+		}
+		return difficulty;
+	}
 
 }

+ 9 - 9
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/KdQuestion.java

@@ -9,7 +9,7 @@ public class KdQuestion {
 	private Integer number;
 	private Double score;
 	private QuesStructType quesStructType;
-	private YunkaiDifficulty difficulty;
+	private Double difficultyDegree;
 	private String body;
 	private String answer;
 	private Boolean haveAudio;
@@ -74,14 +74,6 @@ public class KdQuestion {
 		this.propIds = propIds;
 	}
 
-	public YunkaiDifficulty getDifficulty() {
-		return difficulty;
-	}
-
-	public void setDifficulty(YunkaiDifficulty difficulty) {
-		this.difficulty = difficulty;
-	}
-
 	public QuesStructType getQuesStructType() {
 		return quesStructType;
 	}
@@ -114,4 +106,12 @@ public class KdQuestion {
 		this.score = score;
 	}
 
+	public Double getDifficultyDegree() {
+		return difficultyDegree;
+	}
+
+	public void setDifficultyDegree(Double difficultyDegree) {
+		this.difficultyDegree = difficultyDegree;
+	}
+
 }

+ 0 - 89
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/YunkaiDifficulty.java

@@ -1,89 +0,0 @@
-package cn.com.qmth.examcloud.core.questions.service.yunkai;
-
-public enum YunkaiDifficulty {
-	
-	RONGYI(1,"容易",1.0,"易"),
-	JIAORONGYI(2,"较容易",0.7,"易"),
-	ZHONGDENG(3,"中等",0.5,"中"),
-	JIAONAN(4,"较难",0.3,"难"),
-	KUNNAN(5,"困难",0.1,"难"),
-	;
-	
-	private Integer yunKaiType;
-	private String yunKaiDesc;
-	private Double type;
-	private String desc;
-	
-	private YunkaiDifficulty(Integer yunKaiType, String yunKaiDesc, Double type, String desc) {
-		this.yunKaiType = yunKaiType;
-		this.yunKaiDesc = yunKaiDesc;
-		this.type = type;
-		this.desc = desc;
-	}
-	
-	
-		
-	public Integer getYunKaiType() {
-		return yunKaiType;
-	}
-
-
-
-	public void setYunKaiType(Integer yunKaiType) {
-		this.yunKaiType = yunKaiType;
-	}
-
-
-
-	public String getYunKaiDesc() {
-		return yunKaiDesc;
-	}
-
-
-
-	public void setYunKaiDesc(String yunKaiDesc) {
-		this.yunKaiDesc = yunKaiDesc;
-	}
-
-
-
-	public Double getType() {
-		return type;
-	}
-
-
-
-	public void setType(Double type) {
-		this.type = type;
-	}
-
-
-
-	public String getDesc() {
-		return desc;
-	}
-
-
-
-	public void setDesc(String desc) {
-		this.desc = desc;
-	}
-
-
-
-
-
-	public static YunkaiDifficulty getByYunKaiType(Integer yunKaiType) {
-		if(yunKaiType==null) {
-			return null;
-		}
-		for(YunkaiDifficulty t:YunkaiDifficulty.values()) {
-			if(t.getYunKaiType().equals(yunKaiType)) {
-				return t;
-			}
-		}
-		return null;
-	}
-	
-}
-

+ 0 - 109
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/YunkaiQuesStructType.java

@@ -1,109 +0,0 @@
-package cn.com.qmth.examcloud.core.questions.service.yunkai;
-
-public enum YunkaiQuesStructType {
-	
-	DANXUAN(1,"单选题",1,"单选题",true),
-	DUOXUAN(2,"多选题",2,"多选题",true),
-	BUDINGXIANG(3,"不定项选择题",2,"多选题",true),
-	PANDUAN(4,"判断题",3,"判断题",true),
-	JIANDA(5,"简答题",5,"问答题",false),
-	MIGNCIJIESHI(6,"名词解释",5,"问答题",false),
-	LIJIETI(7,"理解题",5,"问答题",false),
-	ANLITI(8,"案例题",5,"问答题",false),
-	LUNSHUTI(9,"论述题",5,"问答题",false),
-	FENXITI(10,"分析题",5,"问答题",false),
-	ZONGHETI(11,"综合题",5,"问答题",false),
-	JISUANTI(12,"计算题",5,"问答题",false),
-	TIANKONGTI(13,"填空题",4,"填空题",false),
-	;
-	
-	private Integer yunKaiType;
-	private String yunKaiDesc;
-	private Integer type;
-	private String desc;
-	private boolean objective;//是否是客观题
-	
-	private YunkaiQuesStructType(Integer yunKaiType, String yunKaiDesc, Integer type, String desc, boolean objective) {
-		this.yunKaiType = yunKaiType;
-		this.yunKaiDesc = yunKaiDesc;
-		this.type = type;
-		this.desc = desc;
-		this.objective = objective;
-	}
-	
-	
-		
-	public Integer getYunKaiType() {
-		return yunKaiType;
-	}
-
-
-
-	public void setYunKaiType(Integer yunKaiType) {
-		this.yunKaiType = yunKaiType;
-	}
-
-
-
-	public String getYunKaiDesc() {
-		return yunKaiDesc;
-	}
-
-
-
-	public void setYunKaiDesc(String yunKaiDesc) {
-		this.yunKaiDesc = yunKaiDesc;
-	}
-
-
-
-	public Integer getType() {
-		return type;
-	}
-
-
-
-	public void setType(Integer type) {
-		this.type = type;
-	}
-
-
-
-	public String getDesc() {
-		return desc;
-	}
-
-
-
-	public void setDesc(String desc) {
-		this.desc = desc;
-	}
-
-
-
-	public boolean isObjective() {
-		return objective;
-	}
-
-
-
-	public void setObjective(boolean objective) {
-		this.objective = objective;
-	}
-
-
-
-	public static YunkaiQuesStructType getByYunKaiType(Integer yunKaiType) {
-		if(yunKaiType==null) {
-			throw new RuntimeException("题型异常");
-		}
-		for(YunkaiQuesStructType t:YunkaiQuesStructType.values()) {
-			if(t.getYunKaiType().equals(yunKaiType)) {
-				return t;
-			}
-		}
-		throw new RuntimeException("题型异常");
-	}
-	
-}
-

+ 9 - 8
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/YunkaiService.java

@@ -51,6 +51,7 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.QuesOption;
 import cn.com.qmth.examcloud.core.questions.dao.entity.QuesProperty;
 import cn.com.qmth.examcloud.core.questions.dao.entity.QuesTypeName;
 import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
+import cn.com.qmth.examcloud.core.questions.service.util.PaperUtil;
 import cn.com.qmth.examcloud.web.config.SystemProperties;
 
 @Component
@@ -368,12 +369,12 @@ public class YunkaiService {
 		question.setCourse(p.getCourse());
 		question.setOrgId(p.getRootOrgId().toString());
 		question.setHasAudio(false);
-		if (que.getDifficulty() == null) {
-			question.setDifficulty("");
+		if (que.getDifficultyDegree() == null) {
+			question.setDifficulty("");
 			question.setDifficultyDegree(0.5);
 		} else {
-			question.setDifficulty(que.getDifficulty().getDesc());
-			question.setDifficultyDegree(que.getDifficulty().getType());
+			question.setDifficulty(PaperUtil.getDifficulty(que.getDifficultyDegree()));
+			question.setDifficultyDegree(que.getDifficultyDegree());
 		}
 		question.setPublicity(true);
 		question.setCreationBy(p.getUser().getUserId());
@@ -400,12 +401,12 @@ public class YunkaiService {
 				subQuestion.setCourse(p.getCourse());
 				subQuestion.setOrgId(p.getRootOrgId().toString());
 				subQuestion.setHasAudio(que.getHaveAudio());
-				if (que.getDifficulty() == null) {
-					subQuestion.setDifficulty("");
+				if (que.getDifficultyDegree() == null) {
+					subQuestion.setDifficulty("");
 					subQuestion.setDifficultyDegree(0.5);
 				} else {
-					subQuestion.setDifficulty(que.getDifficulty().getDesc());
-					subQuestion.setDifficultyDegree(que.getDifficulty().getType());
+					subQuestion.setDifficulty(PaperUtil.getDifficulty(que.getDifficultyDegree()));
+					subQuestion.setDifficultyDegree(que.getDifficultyDegree());
 				}
 				subQuestion.setPublicity(true);
 				// 按试题分类初始化题干,答案,选项