xiatian 2 lat temu
rodzic
commit
58cba714d4

+ 4 - 0
examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/controller/RandomPaperController.java

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
 import cn.com.qmth.examcloud.api.commons.enums.DataRuleType;
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.api.commons.security.bean.UserDataRule;
+import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.core.questions.service.RandomPaperService;
 import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.PaperQuestionViewQuery;
 import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.RandomPaperDomain;
@@ -56,6 +57,9 @@ public class RandomPaperController extends ControllerSupport {
 	@ApiOperation(value = "获取组卷结构试题信息")
 	@PostMapping("struct/question/info")
 	public StructInfo getStructQuestionInfo(@RequestParam String structId) {
+		if(StringUtils.isBlank(structId)) {
+			throw new StatusException("组卷结构ID不能为空");
+		}
 		return randomPaperService.getStructQuestionInfo(structId);
 	}
 

+ 20 - 15
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/RandomPaperServiceImpl.java

@@ -233,9 +233,8 @@ public class RandomPaperServiceImpl implements RandomPaperService {
 						simpleCount = unitStruct.getPublicSimple() + unitStruct.getNoPublicSimple();
 						mediumCount = unitStruct.getPublicMedium() + unitStruct.getNoPublicMedium();
 						difficultyCount = unitStruct.getPublicDifficulty() + unitStruct.getNoPublicDifficulty();
-						sum = simpleCount * paperDetailStruct.getScore() * 0.8
-								+ mediumCount * paperDetailStruct.getScore() * 0.5
-								+ difficultyCount * paperDetailStruct.getScore() * 0.2 + sum;
+						sum = simpleCount * unitStruct.getScore() * 0.8 + mediumCount * unitStruct.getScore() * 0.5
+								+ difficultyCount * unitStruct.getScore() * 0.2 + sum;
 					}
 				}
 			}
@@ -594,9 +593,9 @@ public class RandomPaperServiceImpl implements RandomPaperService {
 
 	private List<PaperDetailUnitDto> findUnitPaperId(String paperId) {
 		Query query = new Query();
-		if(paperId.length()>24) {
+		if (paperId.length() > 24) {
 			query.addCriteria(Criteria.where("paper.$id").is(paperId));
-		}else {
+		} else {
 			query.addCriteria(Criteria.where("paper.$id").is(new ObjectId(paperId)));
 		}
 		List<PaperDetailUnitDto> units = this.mongoTemplate.find(query, PaperDetailUnitDto.class, "paperDetailUnit");
@@ -786,7 +785,7 @@ public class RandomPaperServiceImpl implements RandomPaperService {
 	public DefaultPaper getRandomPaper(String randomPaperId, Integer playTime) {
 		RandomPaperCache rp = getByCache(randomPaperId);
 		PaperStruct ps = paperStructService.getByCache(rp.getPaperStructId());
-		CreateDefaultPaperParam param=new CreateDefaultPaperParam();
+		CreateDefaultPaperParam param = new CreateDefaultPaperParam();
 		param.setFullyObjective(true);
 		param.setRp(rp);
 		DefaultPaper paper = new DefaultPaper();
@@ -838,43 +837,49 @@ public class RandomPaperServiceImpl implements RandomPaperService {
 		paper.setFullyObjective(param.getFullyObjective());
 		return paper;
 	}
-	
+
 	private void createUnitByExact(CreateDefaultPaperParam param) {
 		PaperDetailUnitStructDto us = param.getUs();
 		if (us.getNoPublicDifficulty() > 0) {
 			param.setUnitCount(us.getNoPublicDifficulty());
-			String key=param.getDetailNumber()+"-"+param.getIndex() + "-" + false + "-" + QuestionDifficulty.HARD.getName();
+			String key = param.getDetailNumber() + "-" + param.getIndex() + "-" + false + "-"
+					+ QuestionDifficulty.HARD.getName();
 			param.setKey(key);
 			createUnit(param);
 		}
 		if (us.getPublicDifficulty() > 0) {
 			param.setUnitCount(us.getPublicDifficulty());
-			String key=param.getDetailNumber()+"-"+param.getIndex() + "-" + true + "-" + QuestionDifficulty.HARD.getName();
+			String key = param.getDetailNumber() + "-" + param.getIndex() + "-" + true + "-"
+					+ QuestionDifficulty.HARD.getName();
 			param.setKey(key);
 			createUnit(param);
 		}
 
 		if (us.getNoPublicMedium() > 0) {
 			param.setUnitCount(us.getNoPublicMedium());
-			String key=param.getDetailNumber()+"-"+param.getIndex() + "-" + false + "-" + QuestionDifficulty.MEDIUM.getName();
+			String key = param.getDetailNumber() + "-" + param.getIndex() + "-" + false + "-"
+					+ QuestionDifficulty.MEDIUM.getName();
 			param.setKey(key);
 			createUnit(param);
 		}
 		if (us.getPublicMedium() > 0) {
 			param.setUnitCount(us.getPublicMedium());
-			String key=param.getDetailNumber()+"-"+param.getIndex() + "-" + true + "-" + QuestionDifficulty.MEDIUM.getName();
+			String key = param.getDetailNumber() + "-" + param.getIndex() + "-" + true + "-"
+					+ QuestionDifficulty.MEDIUM.getName();
 			param.setKey(key);
 			createUnit(param);
 		}
 		if (us.getNoPublicSimple() > 0) {
 			param.setUnitCount(us.getNoPublicSimple());
-			String key=param.getDetailNumber()+"-"+param.getIndex() + "-" + false + "-" + QuestionDifficulty.EASY.getName();
+			String key = param.getDetailNumber() + "-" + param.getIndex() + "-" + false + "-"
+					+ QuestionDifficulty.EASY.getName();
 			param.setKey(key);
 			createUnit(param);
 		}
 		if (us.getPublicSimple() > 0) {
 			param.setUnitCount(us.getPublicSimple());
-			String key=param.getDetailNumber()+"-"+param.getIndex() + "-" + true + "-" + QuestionDifficulty.EASY.getName();
+			String key = param.getDetailNumber() + "-" + param.getIndex() + "-" + true + "-"
+					+ QuestionDifficulty.EASY.getName();
 			param.setKey(key);
 			createUnit(param);
 		}
@@ -947,7 +952,7 @@ public class RandomPaperServiceImpl implements RandomPaperService {
 					q.setOptionPermutation(getOption(sub.getOptionCount()));
 					q.setQuestionScore(sub.getScore());
 					q.setQuestionType(getByOldType(sub.getQuestionType()));
-					if(!PaperUtil.isObjecttive(sub.getQuestionType())) {
+					if (!PaperUtil.isObjecttive(sub.getQuestionType())) {
 						param.setFullyObjective(false);
 					}
 				}
@@ -958,7 +963,7 @@ public class RandomPaperServiceImpl implements RandomPaperService {
 				q.setOptionPermutation(getOption(rpq.getOptionCount()));
 				q.setQuestionScore(rpq.getScore());
 				q.setQuestionType(getByOldType(rpq.getQuestionType()));
-				if(!PaperUtil.isObjecttive(rpq.getQuestionType())) {
+				if (!PaperUtil.isObjecttive(rpq.getQuestionType())) {
 					param.setFullyObjective(false);
 				}
 			}