|
@@ -1,47 +1,31 @@
|
|
package cn.com.qmth.examcloud.core.questions.service.impl;
|
|
package cn.com.qmth.examcloud.core.questions.service.impl;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Collections;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.HashSet;
|
|
|
|
-import java.util.LinkedList;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Set;
|
|
|
|
-import java.util.UUID;
|
|
|
|
-
|
|
|
|
|
|
+import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
|
|
+import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
|
|
|
|
+import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
|
|
import cn.com.qmth.examcloud.core.questions.base.Model;
|
|
import cn.com.qmth.examcloud.core.questions.base.Model;
|
|
import cn.com.qmth.examcloud.core.questions.base.enums.PaperStructType;
|
|
import cn.com.qmth.examcloud.core.questions.base.enums.PaperStructType;
|
|
-
|
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.Course;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.context.DetailContext;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.context.PaperContext;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.context.UnitContext;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.dto.GenPaperDto;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.service.bean.dto.NumberDto;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
|
|
import cn.com.qmth.examcloud.core.questions.dao.PaperDetailRepo;
|
|
import cn.com.qmth.examcloud.core.questions.dao.PaperDetailRepo;
|
|
import cn.com.qmth.examcloud.core.questions.dao.PaperDetailUnitRepo;
|
|
import cn.com.qmth.examcloud.core.questions.dao.PaperDetailUnitRepo;
|
|
import cn.com.qmth.examcloud.core.questions.dao.PaperRepo;
|
|
import cn.com.qmth.examcloud.core.questions.dao.PaperRepo;
|
|
import cn.com.qmth.examcloud.core.questions.dao.PaperStructRepo;
|
|
import cn.com.qmth.examcloud.core.questions.dao.PaperStructRepo;
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.Paper;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetail;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailUnit;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.PaperStruct;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.dao.entity.*;
|
|
import cn.com.qmth.examcloud.core.questions.service.PaperDetailUnitService;
|
|
import cn.com.qmth.examcloud.core.questions.service.PaperDetailUnitService;
|
|
import cn.com.qmth.examcloud.core.questions.service.PaperService;
|
|
import cn.com.qmth.examcloud.core.questions.service.PaperService;
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.QuesProperty;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
|
|
|
|
-import cn.com.qmth.examcloud.core.questions.base.question.enums.QuesStructType;
|
|
|
|
-import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
|
|
|
|
-import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
|
|
|
|
-import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.bean.context.DetailContext;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.bean.context.PaperContext;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.bean.context.UnitContext;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.bean.dto.GenPaperDto;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.bean.dto.NumberDto;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class GenPaperService {
|
|
public class GenPaperService {
|
|
@@ -233,8 +217,8 @@ public class GenPaperService {
|
|
* 按分数在选定的试卷中随机抽取题,组成一套新的试卷
|
|
* 按分数在选定的试卷中随机抽取题,组成一套新的试卷
|
|
*
|
|
*
|
|
* @param genPaperDto
|
|
* @param genPaperDto
|
|
- * @author weiwenhai
|
|
|
|
* @return Map<String, Object>
|
|
* @return Map<String, Object>
|
|
|
|
+ * @author weiwenhai
|
|
*/
|
|
*/
|
|
public Map<String, Object> genPaperByScore(GenPaperDto genPaperDto, User user) {
|
|
public Map<String, Object> genPaperByScore(GenPaperDto genPaperDto, User user) {
|
|
Map<String, Object> paperMsgMap = extractByQuestioScore(genPaperDto, user);
|
|
Map<String, Object> paperMsgMap = extractByQuestioScore(genPaperDto, user);
|
|
@@ -398,8 +382,8 @@ public class GenPaperService {
|
|
* 按每套试卷需要抽取的题目数量随机抽取题,组成一套新的试卷
|
|
* 按每套试卷需要抽取的题目数量随机抽取题,组成一套新的试卷
|
|
*
|
|
*
|
|
* @param genPaperDto
|
|
* @param genPaperDto
|
|
- * @author weiwenhai
|
|
|
|
* @return Map<String, Object>
|
|
* @return Map<String, Object>
|
|
|
|
+ * @author weiwenhai
|
|
*/
|
|
*/
|
|
public Map<String, Object> genPaperByQuestionNum(GenPaperDto genPaperDto, User user) {
|
|
public Map<String, Object> genPaperByQuestionNum(GenPaperDto genPaperDto, User user) {
|
|
Map<String, Object> paperMsgMap = extractByQuestionNum(genPaperDto, user);
|
|
Map<String, Object> paperMsgMap = extractByQuestionNum(genPaperDto, user);
|
|
@@ -676,7 +660,7 @@ public class GenPaperService {
|
|
if (paper.getTotalScore() < 0.1) {
|
|
if (paper.getTotalScore() < 0.1) {
|
|
paper.setDifficultyDegree(0d);
|
|
paper.setDifficultyDegree(0d);
|
|
} else {
|
|
} else {
|
|
- BigDecimal b = new BigDecimal(sum / paper.getTotalScore());
|
|
|
|
|
|
+ BigDecimal b = BigDecimal.valueOf(sum / paper.getTotalScore());
|
|
Double difficulty = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
Double difficulty = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
//赋值难度
|
|
//赋值难度
|
|
paper.setDifficultyDegree(difficulty);
|
|
paper.setDifficultyDegree(difficulty);
|
|
@@ -717,10 +701,10 @@ public class GenPaperService {
|
|
//构建新的大题
|
|
//构建新的大题
|
|
private List<PaperDetail> buildPaperDetail(Map<String, List<PaperDetailUnit>> map, GenPaperDto genPaperDto) {
|
|
private List<PaperDetail> buildPaperDetail(Map<String, List<PaperDetailUnit>> map, GenPaperDto genPaperDto) {
|
|
//定义新的大题集合
|
|
//定义新的大题集合
|
|
- List<PaperDetail> paperDetails = new ArrayList<PaperDetail>();
|
|
|
|
|
|
+ List<PaperDetail> paperDetails = new ArrayList<>();
|
|
for (String name : map.keySet()) {
|
|
for (String name : map.keySet()) {
|
|
Double score = 0d;
|
|
Double score = 0d;
|
|
- BigDecimal b1 = new BigDecimal(Double.toString(score));
|
|
|
|
|
|
+ BigDecimal b1 = BigDecimal.valueOf(score);
|
|
PaperDetail paperDetail = new PaperDetail();
|
|
PaperDetail paperDetail = new PaperDetail();
|
|
paperDetail.setName(name);
|
|
paperDetail.setName(name);
|
|
paperDetail.setCreateTime(CommonUtils.getCurDateTime());
|
|
paperDetail.setCreateTime(CommonUtils.getCurDateTime());
|
|
@@ -731,7 +715,7 @@ public class GenPaperService {
|
|
if (unit.getScore() == null) {
|
|
if (unit.getScore() == null) {
|
|
unit.setScore(0d);
|
|
unit.setScore(0d);
|
|
}
|
|
}
|
|
- BigDecimal b2 = new BigDecimal(Double.toString(unit.getScore()));
|
|
|
|
|
|
+ BigDecimal b2 = BigDecimal.valueOf(unit.getScore());
|
|
b1 = b1.add(b2);
|
|
b1 = b1.add(b2);
|
|
}
|
|
}
|
|
paperDetail.setScore(b1.doubleValue());
|
|
paperDetail.setScore(b1.doubleValue());
|
|
@@ -786,9 +770,9 @@ public class GenPaperService {
|
|
Paper paper = new Paper();
|
|
Paper paper = new Paper();
|
|
if (details != null && details.size() > 0) {
|
|
if (details != null && details.size() > 0) {
|
|
Double score = 0d;
|
|
Double score = 0d;
|
|
- BigDecimal b1 = new BigDecimal(Double.toString(score));
|
|
|
|
|
|
+ BigDecimal b1 = BigDecimal.valueOf(score);
|
|
for (PaperDetail pd : details) {
|
|
for (PaperDetail pd : details) {
|
|
- BigDecimal b2 = new BigDecimal(Double.toString(pd.getScore() == null ? 0 : pd.getScore()));
|
|
|
|
|
|
+ BigDecimal b2 = BigDecimal.valueOf(pd.getScore() == null ? 0d : pd.getScore());
|
|
b1 = b1.add(b2);
|
|
b1 = b1.add(b2);
|
|
}
|
|
}
|
|
paper.setId(UUID.randomUUID().toString());
|
|
paper.setId(UUID.randomUUID().toString());
|
|
@@ -855,8 +839,8 @@ public class GenPaperService {
|
|
//向下取整,包含0.5
|
|
//向下取整,包含0.5
|
|
double formatScore = CommonUtils.formatDoubleFloor(avgScore);
|
|
double formatScore = CommonUtils.formatDoubleFloor(avgScore);
|
|
if (j == subQuesLen - 1) {
|
|
if (j == subQuesLen - 1) {
|
|
- BigDecimal b1 = new BigDecimal(Double.toString(subTotalScore));
|
|
|
|
- BigDecimal b2 = new BigDecimal(Double.toString(formatScore * j));
|
|
|
|
|
|
+ BigDecimal b1 = BigDecimal.valueOf(subTotalScore);
|
|
|
|
+ BigDecimal b2 = BigDecimal.valueOf(formatScore * j);
|
|
subScoreList.add(b1.subtract(b2).doubleValue());
|
|
subScoreList.add(b1.subtract(b2).doubleValue());
|
|
} else {
|
|
} else {
|
|
subScoreList.add(formatScore);
|
|
subScoreList.add(formatScore);
|