|
@@ -72,6 +72,9 @@ public class PaperDetailUnit implements Serializable, Comparable<PaperDetailUnit
|
|
|
|
|
|
public void setScore(Double score) {
|
|
|
this.score = score;
|
|
|
+ if (question != null && question.getSubQuestions() != null) {
|
|
|
+ initSubScores(score, question.getSubQuestions());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public PaperDetail getPaperDetail() {
|
|
@@ -96,6 +99,9 @@ public class PaperDetailUnit implements Serializable, Comparable<PaperDetailUnit
|
|
|
|
|
|
public void setQuestion(Question question) {
|
|
|
this.question = question;
|
|
|
+ if (score != null && question != null && question.getSubQuestions() != null) {
|
|
|
+ initSubScores(score, question.getSubQuestions());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public String getCreator() {
|
|
@@ -137,6 +143,30 @@ public class PaperDetailUnit implements Serializable, Comparable<PaperDetailUnit
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据预设总分自动拆解套题子题的分数分布
|
|
|
+ * 目前采取均分后累加到最后一题的做法
|
|
|
+ *
|
|
|
+ * @param totalScore
|
|
|
+ * @param questionList
|
|
|
+ */
|
|
|
+ private void initSubScores(double totalScore, List<Question> questionList) {
|
|
|
+ List<Double> scoreList = new ArrayList<>();
|
|
|
+ int count = questionList.size();
|
|
|
+ if (count > 0) {
|
|
|
+ int baseScore = (int) (totalScore / count);
|
|
|
+ double leftScore = totalScore;
|
|
|
+ for (int i = 0; i < count; i++) {
|
|
|
+ scoreList.add((double) baseScore);
|
|
|
+ leftScore -= baseScore;
|
|
|
+ }
|
|
|
+ if (leftScore > 0) {
|
|
|
+ scoreList.set(count - 1, baseScore + leftScore);
|
|
|
+ }
|
|
|
+ updateSubScore(scoreList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public List<Double> getSubScoreList() {
|
|
|
List<Double> list = new ArrayList<>();
|
|
|
String[] values = StringUtils.split(StringUtils.trimToEmpty(subScores), ",");
|
|
@@ -162,6 +192,6 @@ public class PaperDetailUnit implements Serializable, Comparable<PaperDetailUnit
|
|
|
} else {
|
|
|
setSubScores(null);
|
|
|
}
|
|
|
- setScore(totalScore);
|
|
|
+ this.score = totalScore;
|
|
|
}
|
|
|
}
|