|
@@ -2,14 +2,12 @@ package com.qmth.cqb.paper.model;
|
|
|
|
|
|
import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
|
|
|
import com.qmth.cqb.question.model.Question;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.data.annotation.Id;
|
|
|
import org.springframework.data.mongodb.core.mapping.DBRef;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
|
|
|
public class PaperDetailUnit implements Serializable, Comparable<PaperDetailUnit> {
|
|
@@ -28,7 +26,7 @@ public class PaperDetailUnit implements Serializable, Comparable<PaperDetailUnit
|
|
|
|
|
|
private Double score;// 小题分数
|
|
|
|
|
|
- private String subScores;//对应套题的情况下,各子题的分数分布
|
|
|
+ private List<Double> subScoreList;//对应套题的情况下,各子题的分数分布
|
|
|
|
|
|
@DBRef
|
|
|
private PaperDetail paperDetail;// 关联的大题
|
|
@@ -73,7 +71,7 @@ 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());
|
|
|
+ initSubScoreList(score, question.getSubQuestions());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -100,7 +98,7 @@ 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());
|
|
|
+ initSubScoreList(score, question.getSubQuestions());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -120,12 +118,19 @@ public class PaperDetailUnit implements Serializable, Comparable<PaperDetailUnit
|
|
|
this.createTime = createTime;
|
|
|
}
|
|
|
|
|
|
- public String getSubScores() {
|
|
|
- return subScores;
|
|
|
+ public List<Double> getSubScoreList() {
|
|
|
+ return subScoreList;
|
|
|
}
|
|
|
|
|
|
- public void setSubScores(String subScores) {
|
|
|
- this.subScores = subScores;
|
|
|
+ public void setSubScoreList(List<Double> subScoreList) {
|
|
|
+ this.subScoreList = subScoreList;
|
|
|
+ if (subScoreList != null) {
|
|
|
+ double totalScore = 0;
|
|
|
+ for (Double score : subScoreList) {
|
|
|
+ totalScore += score;
|
|
|
+ }
|
|
|
+ this.score = totalScore;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public PaperDetailUnit() {
|
|
@@ -150,7 +155,7 @@ public class PaperDetailUnit implements Serializable, Comparable<PaperDetailUnit
|
|
|
* @param totalScore
|
|
|
* @param questionList
|
|
|
*/
|
|
|
- private void initSubScores(double totalScore, List<Question> questionList) {
|
|
|
+ private void initSubScoreList(double totalScore, List<Question> questionList) {
|
|
|
List<Double> scoreList = new ArrayList<>();
|
|
|
int count = questionList.size();
|
|
|
if (count > 0) {
|
|
@@ -163,35 +168,7 @@ public class PaperDetailUnit implements Serializable, Comparable<PaperDetailUnit
|
|
|
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), ",");
|
|
|
- for (String value : values) {
|
|
|
- try {
|
|
|
- list.add(Double.valueOf(value));
|
|
|
- } catch (Exception e) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
- public void updateSubScore(List<Double> list) {
|
|
|
- double totalScore = 0;
|
|
|
- if (list != null) {
|
|
|
- List<String> values = new LinkedList<>();
|
|
|
- for (Double value : list) {
|
|
|
- values.add(SCORE_FORMATER.format(value));
|
|
|
- totalScore += value;
|
|
|
- }
|
|
|
- setSubScores(StringUtils.join(values, ","));
|
|
|
- } else {
|
|
|
- setSubScores(null);
|
|
|
+ this.subScoreList = scoreList;
|
|
|
}
|
|
|
- this.score = totalScore;
|
|
|
}
|
|
|
}
|