|
@@ -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;
|
|
|
+ }
|
|
|
|
|
|
}
|