|
@@ -12,6 +12,7 @@ import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
+import com.qmth.cqb.utils.enums.PaperStructType;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -131,7 +132,7 @@ public class GenPaperService {
|
|
|
paper.setUnitCount(this.getTotalQuesNum(paperDetailunits));
|
|
|
paper.setPaperType(PaperType.GENERATE);
|
|
|
// 数据入库
|
|
|
- paper = this.persistentPaper(paperDetailunits, paperDetails, paper);
|
|
|
+ paper = this.persistentPaper(PaperStructType.EXACT,paperDetailunits, paperDetails, paper);
|
|
|
msg = "success";
|
|
|
paperMsgMap.put("paper", paper);
|
|
|
paperMsgMap.put("msg", msg);
|
|
@@ -148,7 +149,9 @@ public class GenPaperService {
|
|
|
private boolean checkQuesType(UnitContext uc,Question question){
|
|
|
List<String> quesNames = uc.getUnitStruct().getQuesNames();
|
|
|
if(quesNames != null && quesNames.size() > 0){
|
|
|
- if(quesNames.contains(question.getQuesName()) && !uc.finish() && (uc.getUnitStruct().getQuestionType() == question.getQuestionType())){
|
|
|
+ if(quesNames.contains(question.getQuesName())
|
|
|
+ && !uc.finish()
|
|
|
+ && (uc.getUnitStruct().getQuestionType() == question.getQuestionType())){
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -347,7 +350,7 @@ public class GenPaperService {
|
|
|
}
|
|
|
Paper paper = this.constuctPaperByPaperDetails(details, genPaperDto);
|
|
|
paper.setUnitCount(this.getTotalQuesNum(saveUnits));// 设置小题数量,需统计subQuestion
|
|
|
- paper = this.persistentPaper(saveUnits, details, paper);
|
|
|
+ paper = this.persistentPaper(PaperStructType.SIMPLE,saveUnits, details, paper);
|
|
|
return paper;
|
|
|
|
|
|
}
|
|
@@ -360,7 +363,10 @@ public class GenPaperService {
|
|
|
* @param paper
|
|
|
* @return
|
|
|
*/
|
|
|
- public Paper persistentPaper(List<PaperDetailUnit> selectedUnits, List<PaperDetail> details, Paper paper) {
|
|
|
+ public Paper persistentPaper(PaperStructType paperStructType,
|
|
|
+ List<PaperDetailUnit> selectedUnits,
|
|
|
+ List<PaperDetail> details,
|
|
|
+ Paper paper) {
|
|
|
paper = paperRepo.save(paper);
|
|
|
for (PaperDetail pd : details) {
|
|
|
pd.setPaper(paper);
|
|
@@ -381,17 +387,19 @@ public class GenPaperService {
|
|
|
paperDetailUnit.setNumber(index);
|
|
|
|
|
|
//重新计算套题小题分
|
|
|
- Question question = paperDetailUnit.getQuestion();
|
|
|
- if(question != null && question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION){
|
|
|
- List<Question> subQuestions = question.getSubQuestions();
|
|
|
- List<Double> subScoreList = new ArrayList<>();
|
|
|
- if(subQuestions != null && subQuestions.size() > 0){
|
|
|
- for(Question subQuestion:subQuestions){
|
|
|
- double score = paperDetailUnit.getScore()/ subQuestions.size();
|
|
|
- BigDecimal formatScore = new BigDecimal(score);
|
|
|
- subScoreList.add(formatScore.setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
+ if(paperStructType != PaperStructType.SIMPLE){
|
|
|
+ Question question = paperDetailUnit.getQuestion();
|
|
|
+ if(question != null && question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION){
|
|
|
+ List<Question> subQuestions = question.getSubQuestions();
|
|
|
+ List<Double> subScoreList = new ArrayList<>();
|
|
|
+ if(subQuestions != null && subQuestions.size() > 0){
|
|
|
+ for(Question subQuestion:subQuestions){
|
|
|
+ double score = paperDetailUnit.getScore()/ subQuestions.size();
|
|
|
+ BigDecimal formatScore = new BigDecimal(score);
|
|
|
+ subScoreList.add(formatScore.setScale(2, RoundingMode.HALF_UP).doubleValue());
|
|
|
+ }
|
|
|
+ paperDetailUnit.setSubScoreList(subScoreList);
|
|
|
}
|
|
|
- paperDetailUnit.setSubScoreList(subScoreList);
|
|
|
}
|
|
|
}
|
|
|
}
|