|
@@ -780,6 +780,16 @@ public class ImportPaperService {
|
|
|
question.setQuesProperties(quesProperties);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 校验一级属性与二级属性,并保存到试题中
|
|
|
+ * @param firstProperty
|
|
|
+ * @param secondProperty
|
|
|
+ * @param importPaperCheck
|
|
|
+ * @param subQuesNum
|
|
|
+ * @param paper
|
|
|
+ * @param quesProperties
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
private void checkProperty(String firstProperty, String secondProperty,
|
|
|
ImportPaperCheck importPaperCheck, int subQuesNum,Paper paper, List<QuesProperty> quesProperties) throws Exception{
|
|
|
//一级属性为空,二级属性有值
|
|
@@ -792,10 +802,10 @@ public class ImportPaperService {
|
|
|
//根据课程查询所有课程属性树
|
|
|
List<CourseProperty> courseProperties = coursePropertyRepo.findByCourseId(Long.parseLong(paper.getCourse().getId()));
|
|
|
for(CourseProperty courseProperty:courseProperties){
|
|
|
- //查询一级属性是否存在
|
|
|
Property propertyParent = new Property(firstProperty,0l,courseProperty.getId());
|
|
|
- //存在一级属性
|
|
|
+ //查询一级属性是否存在
|
|
|
List<Property> propertieParents = propertyRepo.findAll(Example.of(propertyParent));
|
|
|
+ //存在一级属性
|
|
|
if(propertieParents != null || propertieParents.size()>0){
|
|
|
for(Property proParent:propertieParents){
|
|
|
Property propertySon = new Property(secondProperty,proParent.getId(),courseProperty.getId());
|
|
@@ -804,10 +814,8 @@ public class ImportPaperService {
|
|
|
//存在二级属性
|
|
|
if(propertieSons!=null && propertieSons.size()>0){
|
|
|
for(Property proSon:propertieSons){
|
|
|
- //根据二级查询一级
|
|
|
- Property prParent = propertyRepo.findOne(proSon.getParentId());
|
|
|
//保存一级和二级属性
|
|
|
- QuesProperty quesProperty = new QuesProperty(prParent, proSon);
|
|
|
+ QuesProperty quesProperty = new QuesProperty(proParent, proSon,courseProperty);
|
|
|
quesProperties.add(quesProperty);
|
|
|
}
|
|
|
}else{
|
|
@@ -840,7 +848,7 @@ public class ImportPaperService {
|
|
|
throw new PaperException(importPaperCheck.errorInfo);
|
|
|
}else {
|
|
|
//保存试题属性
|
|
|
- QuesProperty quesProperty = new QuesProperty(proParent, null);
|
|
|
+ QuesProperty quesProperty = new QuesProperty(proParent, null,courseProperty);
|
|
|
quesProperties.add(quesProperty);
|
|
|
}
|
|
|
}
|