weiwenhai 6 роки тому
батько
коміт
cbea61468a

+ 24 - 6
examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/core/questions/api/provider/ExtractConfigCloudServiceProvider.java

@@ -14,8 +14,10 @@ import org.springframework.web.bind.annotation.RestController;
 
 import cn.com.qmth.examcloud.commons.base.exception.StatusException;
 import cn.com.qmth.examcloud.core.questions.api.ExtractConfigCloudService;
+import cn.com.qmth.examcloud.core.questions.api.request.GetBasePaperReq;
 import cn.com.qmth.examcloud.core.questions.api.request.GetPaperReq;
 import cn.com.qmth.examcloud.core.questions.api.request.GetQuestionReq;
+import cn.com.qmth.examcloud.core.questions.api.response.GetBasePaperResp;
 import cn.com.qmth.examcloud.core.questions.api.response.GetPaperResp;
 import cn.com.qmth.examcloud.core.questions.api.response.GetQuestionResp;
 import cn.com.qmth.examcloud.core.questions.service.ExtractConfigProviderService;
@@ -57,36 +59,52 @@ public class ExtractConfigCloudServiceProvider implements ExtractConfigCloudServ
 		}
 		Map<String, Object> map = extractConfigExamService.getDefaultPaper(paperReq.getExamId(),paperReq.getCourseCode(),paperReq.getGroupCode());
 		GetPaperResp resp = new GetPaperResp();
-		resp.setSortQptionOrder((Short)map.get("upSetOptionOrder") == 0 ? false:true);
+		resp.setSortOptionOrder((Short)map.get("upSetOptionOrder") == 0 ? false:true);
 		resp.setSortQuestionOrder((Short)map.get("upSetQuestionOrder") == 0 ? false:true);
+		resp.setPaperId((String)map.get("paperId"));
 		resp.setDefaultPaper((DefaultPaper)map.get("defaultPaper"));
 		return resp;
 	}
 
-	@ApiOperation(value = "根据调卷规则抽取考试试")
+	@ApiOperation(value = "根据调卷规则抽取考试试")
 	@PostMapping("getQuestion")
 	@Override
 	public GetQuestionResp getQuestion(@RequestBody GetQuestionReq questionReq) {
 		Long examId = questionReq.getExamId();
 		if (null == examId) {
-			throw new StatusException("Q-010071", "examId is null");
+			throw new StatusException("Q-010074", "examId is null");
 		}
 		String courseCode = questionReq.getCourseCode(); 
 		if(StringUtils.isBlank(courseCode)){
-			throw new StatusException("Q-010075", "courseCode is null");
+			throw new StatusException("Q-010079", "courseCode is null");
 		}
 		String groupCode = questionReq.getGroupCode();
 		if(StringUtils.isBlank(groupCode)){
-			throw new StatusException("Q-010079", "groupCode is null");
+			throw new StatusException("Q-010083", "groupCode is null");
 		}
 		String questionId = questionReq.getQuestionId();
 		if(StringUtils.isBlank(questionId)){
-			throw new StatusException("Q-010083", "questionId is null");
+			throw new StatusException("Q-010087", "questionId is null");
 		}
 		DefaultQuestion defaultQuestion = extractConfigExamService.getDefaultQuestion(examId, courseCode, groupCode, questionId);
 		GetQuestionResp resp = new GetQuestionResp();
 		resp.setDefaultQuestion(defaultQuestion);
 		return resp;
 	}
+
+
+	@ApiOperation(value = "根据试卷id获取试卷结构")
+	@PostMapping("getBasePaper")
+	@Override
+	public GetBasePaperResp getBasePaper(@RequestBody GetBasePaperReq req) {
+		String paperId = req.getPaperId();
+		if (null == paperId) {
+			throw new StatusException("Q-010102", "paperId is null");
+		}
+		DefaultPaper defaultPaper = extractConfigExamService.getBaseDefaultPaper(paperId);
+		GetBasePaperResp resp = new GetBasePaperResp();
+		resp.setDefaultPaper(defaultPaper);
+		return resp;
+	}
 	
 }

+ 8 - 1
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ExtractConfigProviderService.java

@@ -3,6 +3,7 @@ package cn.com.qmth.examcloud.core.questions.service;
 import java.util.Map;
 
 import cn.com.qmth.examcloud.core.questions.dao.entity.Paper;
+import cn.com.qmth.examcloud.question.core.paper.DefaultPaper;
 import cn.com.qmth.examcloud.question.core.question.DefaultQuestion;
 
 /**
@@ -21,7 +22,7 @@ public interface ExtractConfigProviderService {
 	public Map<String, Object> getDefaultPaper(Long examId,String courseCode,String groupCode);
 	
 	/**
-	 * 
+	 * 根据试题id获取试题
 	 * @param exam_id
 	 * @param course_code
 	 * @param group_code
@@ -30,4 +31,10 @@ public interface ExtractConfigProviderService {
 	 */
 	public DefaultQuestion getDefaultQuestion(Long examId,String courseCode,String groupCode,String questionId);
 	
+	/**
+	 * 根据试卷id获取试卷
+	 * @param paperId
+	 * @return
+	 */
+	public DefaultPaper getBaseDefaultPaper(String paperId);
 }

+ 19 - 4
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExtractConfigProviderServiceImpl.java

@@ -120,6 +120,7 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
 		Short upSetOptionOrder = extractConfig.getScrambling_the_option_order();
 		map.put("upSetQuestionOrder", upSetQuestionOrder);
 		map.put("upSetOptionOrder", upSetOptionOrder);
+		map.put("paperId", basePaper.getId());
 		//构建试卷结构
 		DefaultPaper defaultPaper = buildDefaultByBasePaper(basePaper,String.valueOf(examId),courseCode,groupCode);
 		map.put("defaultPaper", defaultPaper);
@@ -235,10 +236,12 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
 				defaultQuestionStructureWrapper.setQuestionId(paperDetailUnit.getQuestion().getId());
 				defaultQuestionStructureWrapper.setVersion(CommonUtils.QUESTION_VERSION);
 				defaultQuestionStructureWrapper.setQuestionScore(paperDetailUnit.getScore().floatValue());
-				//设置音频播放次数
-				if(paperDetailUnit.getQuestion().getHasAudio() != null && paperDetailUnit.getQuestion().getHasAudio() == true){
-					AudioTimeConfig audioTimeConfig = audioTimeConfigRepo.findOne(Example.of(new AudioTimeConfig(examId,courseCode,groupCode,paperDetailUnit.getQuestion().getId())));
-					defaultQuestionStructureWrapper.setPlayedTimes(audioTimeConfig.getPlayTime());
+				if(examId != null){
+					//设置音频播放次数
+					if(paperDetailUnit.getQuestion().getHasAudio() != null && paperDetailUnit.getQuestion().getHasAudio() == true){
+						AudioTimeConfig audioTimeConfig = audioTimeConfigRepo.findOne(Example.of(new AudioTimeConfig(examId,courseCode,groupCode,paperDetailUnit.getQuestion().getId())));
+						defaultQuestionStructureWrapper.setPlayedTimes(audioTimeConfig.getPlayTime());
+					}
 				}
 				//生成新的题单元包装器
 				List<DefaultQuestionUnitWrapper> defaultQuestionUnitWrappers = new ArrayList<DefaultQuestionUnitWrapper>();
@@ -548,4 +551,16 @@ public class ExtractConfigProviderServiceImpl implements ExtractConfigProviderSe
 		}
 		return true;
 	}
+
+	@Override
+	public DefaultPaper getBaseDefaultPaper(String paperId) {
+		Paper basePaper = paperRepo.findOne(paperId);
+		if(basePaper==null){
+			log.error("该考试和课程下调卷规则中该类型试卷不存在,请检查调卷规则,调卷程序退出");
+			throw new StatusException("Q-020068","该考试和课程下调卷规则中试卷不存在,请重新制定调卷规则");
+		}
+		//构建试卷结构
+		DefaultPaper defaultPaper = buildDefaultByBasePaper(basePaper,null,null,null);
+		return defaultPaper;
+	}
 }

+ 1 - 1
examcloud-core-questions-starter/src/main/resources/application-dev.properties

@@ -3,7 +3,7 @@ spring.data.mongodb.uri=mongodb://192.168.10.30:27017/comm-ques-bank
 spring.data.mongodb.grid-fs-database=comm-ques-bank
 spring.data.mongodb.database=comm-ques-bank
 eureka.client.serviceUrl.defaultZone=http://192.168.10.30:1111/eureka/
-spring.application.name=MASTER-ExamCloud-service-question
+spring.application.name=ExamCloud-service-question
 
 spring.redis.host=192.168.10.30
 spring.redis.port=6379

+ 2 - 2
examcloud-core-questions-starter/src/main/resources/application.properties

@@ -1,7 +1,7 @@
 spring.profiles.active=dev
-server.port=9008
+server.port=8008
 logging.config=classpath:logback-spring.xml
-spring.application.name=MASTER-ExamCloud-service-question
+spring.application.name=ExamCloud-service-question
 hystrix.command.default.execution.timeout.enabled=false
 api_cqb=/api/ecs_ques
 app.api.core=/api/ecs_core