xiatian 2 rokov pred
rodič
commit
9c1134e355

+ 1 - 0
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/CoursePropertyRepo.java

@@ -24,6 +24,7 @@ public interface CoursePropertyRepo extends MongoRepository<CourseProperty, Stri
 
     //根据课程代码查询已开启的课程属性
     List<CourseProperty> findByCourseCodeAndEnable(String courseCode, Boolean enable);
+    List<CourseProperty> findByOrgIdAndCourseCodeAndEnable(Long orgId,String courseCode, Boolean enable);
 
     //根据课程id查询已经开启的课程属性
     List<CourseProperty> findByCourseIdAndEnable(Long courseId, Boolean enable);

+ 2 - 0
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/PropertyRepo.java

@@ -28,4 +28,6 @@ public interface PropertyRepo extends MongoRepository<Property, String>, QueryBy
 
 	void deleteByOrgIdAndBatch(Long rootOrgId, String batch);
 
+	Property findByCoursePropertyIdAndFromId(String coursePropertyId,String string);
+
 }

+ 10 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/YunkaiImportPaperParam.java

@@ -4,12 +4,14 @@ import org.springframework.web.multipart.MultipartFile;
 
 import cn.com.qmth.examcloud.api.commons.security.bean.User;
 import cn.com.qmth.examcloud.core.questions.dao.entity.Course;
+import cn.com.qmth.examcloud.core.questions.dao.entity.CourseProperty;
 
 public class YunkaiImportPaperParam {
 	private User user;
 	private MultipartFile dataFile;
 	private Long rootOrgId;
 	private String courseCode;
+	private CourseProperty courseProperty;
 
 	private Course course;
 
@@ -61,4 +63,12 @@ public class YunkaiImportPaperParam {
 		this.course = course;
 	}
 
+	public CourseProperty getCourseProperty() {
+		return courseProperty;
+	}
+
+	public void setCourseProperty(CourseProperty courseProperty) {
+		this.courseProperty = courseProperty;
+	}
+
 }

+ 35 - 2
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/yunkai/YunkaiService.java

@@ -24,6 +24,7 @@ import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
 import cn.com.qmth.examcloud.core.basic.api.request.GetCourseReq;
 import cn.com.qmth.examcloud.core.basic.api.response.GetCourseResp;
+import cn.com.qmth.examcloud.core.questions.base.Model;
 import cn.com.qmth.examcloud.core.questions.base.converter.utils.FileUtil;
 import cn.com.qmth.examcloud.core.questions.base.enums.PaperStatus;
 import cn.com.qmth.examcloud.core.questions.base.enums.PaperType;
@@ -42,6 +43,7 @@ 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.Property;
 import cn.com.qmth.examcloud.core.questions.dao.entity.QuesOption;
+import cn.com.qmth.examcloud.core.questions.dao.entity.QuesProperty;
 import cn.com.qmth.examcloud.core.questions.dao.entity.QuesTypeName;
 import cn.com.qmth.examcloud.core.questions.dao.entity.Question;
 import cn.com.qmth.examcloud.core.questions.service.PaperService;
@@ -190,6 +192,10 @@ public class YunkaiService {
 		c.setName(res.getCourseBean().getName());
 		c.setOrgId(res.getCourseBean().getRootOrgId().toString());
 		p.setCourse(c);
+		List<CourseProperty> cps=coursePropertyRepo.findByOrgIdAndCourseCodeAndEnable(p.getRootOrgId(),p.getCourseCode(), true);
+		if(CollectionUtils.isNotEmpty(cps)) {
+			p.setCourseProperty(cps.get(0));
+		}
 		for (File paperFile : files) {
 			KdPaper kpaper = JSONObject.parseObject(FileUtil.readFileContent(paperFile), KdPaper.class);
 			kpaper.setCourseCode(p.getCourseCode());
@@ -319,16 +325,43 @@ public class YunkaiService {
 		question.setCourse(p.getCourse());
 		question.setOrgId(p.getRootOrgId().toString());
 		question.setHasAudio(false);
-		question.setDifficulty(que.getDifficulty().getDesc());
-		question.setDifficultyDegree(que.getDifficulty().getType());
+		if(que.getDifficulty()==null) {
+			question.setDifficulty("易");
+			question.setDifficultyDegree(0.5);
+		}else {
+			question.setDifficulty(que.getDifficulty().getDesc());
+			question.setDifficultyDegree(que.getDifficulty().getType());
+		}
 		question.setPublicity(true);
 		question.setCreationBy(p.getUser().getUserId());
 		question.setCreationDate(new Date());
 		question.setCreateTime(getCurDateTime());
 		// 按试题分类初始化题干,答案,选项
 		initQuestionInfo(question, que);
+		initQuestionProp(question, que,p);
 		return question;
 	}
+	
+	private void initQuestionProp(Question question, KdQuestion que,YunkaiImportPaperParam p) {
+		if(CollectionUtils.isEmpty(que.getPropIds())) {
+			return;
+		}
+		List<QuesProperty> quesProperties=new ArrayList<>();
+		for(Long id:que.getPropIds()) {
+			Property prop=propertyRepo.findByCoursePropertyIdAndFromId(p.getCourseProperty().getId(),id.toString());
+			QuesProperty qp=new QuesProperty();
+			quesProperties.add(qp);
+			qp.setCoursePropertyName(p.getCourseProperty().getName());
+			if("0".equals(prop.getParentId())) {
+				qp.setFirstProperty(prop);
+			}else {
+				Property fprop = Model.of(propertyRepo.findById(prop.getParentId()));
+				qp.setFirstProperty(fprop);
+				qp.setSecondProperty(prop);
+			}
+		}
+		question.setQuesProperties(quesProperties);
+	}
 
 	private void initQuestionInfo(Question question, KdQuestion que) {
 		// 单选题