Browse Source

Merge branch 'master' of http://git.qmth.com.cn/ExamCloud-3/examcloud-core-examwork.git

wangwei 5 năm trước cách đây
mục cha
commit
52fbff0e4f

+ 11 - 35
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamController.java

@@ -317,6 +317,8 @@ public class ExamController extends ControllerSupport {
 			bean.setCreationTime(next.getCreationTime());
 			bean.setUpdateTime(next.getUpdateTime());
 			bean.setExamLimit(next.getExamLimit());
+			bean.setSpecialSettingsEnabled(next.getSpecialSettingsEnabled());
+			bean.setSpecialSettingsType(next.getSpecialSettingsType());
 
 			if (CollectionUtils.isNotEmpty(propertyKeyList)) {
 				Map<String, String> properties = getProperties(bean.getId(), propertyKeyList);
@@ -480,6 +482,9 @@ public class ExamController extends ControllerSupport {
 		domain.setRootOrgId(cache.getRootOrgId());
 		domain.setStarted(isStarted(cache.getId()));
 		domain.setExamLimit(cache.getExamLimit());
+		domain.setSpecialSettingsEnabled(cache.getSpecialSettingsEnabled());
+		domain.setSpecialSettingsType(cache.getSpecialSettingsType());
+
 		return domain;
 	}
 
@@ -555,6 +560,8 @@ public class ExamController extends ControllerSupport {
 		examInfo.setRemark(domain.getRemark());
 		examInfo.setRootOrgId(accessUser.getRootOrgId());
 		examInfo.setExamLimit(domain.getExamLimit());
+		examInfo.setSpecialSettingsEnabled(domain.getSpecialSettingsEnabled());
+		examInfo.setSpecialSettingsType(domain.getSpecialSettingsType());
 
 		Map<String, String> properties = domain.getProperties();
 		if (null == properties) {
@@ -572,7 +579,7 @@ public class ExamController extends ControllerSupport {
 	@ApiOperation(value = "复制考试批次", notes = "")
 	@PostMapping("copyExam")
 	@Transactional
-	public void copyExam(@RequestBody CopyExamDomain domain) {
+	public ExamEntity copyExam(@RequestBody CopyExamDomain domain) {
 
 		Long srcExamId = domain.getSrcExamId();
 
@@ -594,6 +601,8 @@ public class ExamController extends ControllerSupport {
 		ed.setRootOrgId(srcExam.getRootOrgId());
 		ed.setStarted(isStarted(srcExam.getId()));
 		ed.setExamLimit(srcExam.getExamLimit());
+		ed.setSpecialSettingsEnabled(srcExam.getSpecialSettingsEnabled());
+		ed.setSpecialSettingsType(srcExam.getSpecialSettingsType());
 
 		ed.setName(domain.getDestExamName());
 		ed.setCode(domain.getDestExamCode());
@@ -609,40 +618,7 @@ public class ExamController extends ControllerSupport {
 		ed.setProperties(map);
 
 		ExamEntity savedExam = saveExam(ed, CURD.CREATION);
-
-		Boolean copyOrgSettings = domain.getCopyOrgSettings();
-
-		if (copyOrgSettings) {
-			List<ExamSpecialSettingsEntity> orgSettingsList = examSpecialSettingsRepo
-					.findAllByExamIdAndCourseIdIsNullAndStudentIdIsNullAndOrgIdIsNotNull(
-							srcExam.getId());
-
-			for (ExamSpecialSettingsEntity cur : orgSettingsList) {
-
-				ExamSpecialSettingsInfo info = new ExamSpecialSettingsInfo();
-				info.setBeginTime(cur.getBeginTime());
-				info.setEndTime(cur.getEndTime());
-				info.setOrgId(cur.getOrgId());
-				info.setExamLimit(cur.getExamLimit());
-				info.setRootOrgId(cur.getRootOrgId());
-
-				info.setExamId(savedExam.getId());
-
-				List<ExamOrgPropertyEntity> propList = examOrgPropertyRepo
-						.findByExamIdAndOrgId(cur.getExamId(), cur.getOrgId());
-
-				Map<String, String> orgProperties = Maps.newHashMap();
-				for (ExamOrgPropertyEntity curOrgProp : propList) {
-					DynamicEnum de = manager.getById(curOrgProp.getKeyId());
-					map.put(de.getName(), curOrgProp.getValue());
-				}
-				info.setProperties(orgProperties);
-
-				examService.saveExamSpecialSettings(info);
-
-			}
-		}
-
+		return savedExam;
 	}
 
 	/**

+ 0 - 11
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/CopyExamDomain.java

@@ -18,9 +18,6 @@ public class CopyExamDomain implements JsonSerializable {
 	@NotBlank(message = "destExamName不能为空")
 	private String destExamName;
 
-	@NotNull(message = "copyOrgSettings不能为空")
-	private Boolean copyOrgSettings;
-
 	public Long getSrcExamId() {
 		return srcExamId;
 	}
@@ -45,12 +42,4 @@ public class CopyExamDomain implements JsonSerializable {
 		this.destExamName = destExamName;
 	}
 
-	public Boolean getCopyOrgSettings() {
-		return copyOrgSettings;
-	}
-
-	public void setCopyOrgSettings(Boolean copyOrgSettings) {
-		this.copyOrgSettings = copyOrgSettings;
-	}
-
 }

+ 27 - 0
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/ExamDomain.java

@@ -7,6 +7,7 @@ import javax.persistence.EnumType;
 import javax.persistence.Enumerated;
 import javax.validation.constraints.NotNull;
 
+import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
 import cn.com.qmth.examcloud.api.commons.enums.ExamType;
 import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
 
@@ -95,6 +96,16 @@ public class ExamDomain implements JsonSerializable {
 	 */
 	private Boolean examLimit;
 
+	/**
+	 * 是否开启特殊设置
+	 */
+	private Boolean specialSettingsEnabled;
+
+	/**
+	 * 特殊设置类型
+	 */
+	private ExamSpecialSettingsType specialSettingsType;
+
 	private Map<String, String> properties;
 
 	public Long getId() {
@@ -225,4 +236,20 @@ public class ExamDomain implements JsonSerializable {
 		this.examLimit = examLimit;
 	}
 
+	public ExamSpecialSettingsType getSpecialSettingsType() {
+		return specialSettingsType;
+	}
+
+	public void setSpecialSettingsType(ExamSpecialSettingsType specialSettingsType) {
+		this.specialSettingsType = specialSettingsType;
+	}
+
+	public Boolean getSpecialSettingsEnabled() {
+		return specialSettingsEnabled;
+	}
+
+	public void setSpecialSettingsEnabled(Boolean specialSettingsEnabled) {
+		this.specialSettingsEnabled = specialSettingsEnabled;
+	}
+
 }

+ 14 - 0
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamEntity.java

@@ -98,6 +98,12 @@ public class ExamEntity extends JpaEntity {
 	 */
 	private Boolean examLimit;
 
+	/**
+	 * 开启特殊设置
+	 */
+	@Column(nullable = false)
+	private Boolean specialSettingsEnabled;
+
 	/**
 	 * 特殊设置类型
 	 */
@@ -209,6 +215,14 @@ public class ExamEntity extends JpaEntity {
 		this.examLimit = examLimit;
 	}
 
+	public Boolean getSpecialSettingsEnabled() {
+		return specialSettingsEnabled;
+	}
+
+	public void setSpecialSettingsEnabled(Boolean specialSettingsEnabled) {
+		this.specialSettingsEnabled = specialSettingsEnabled;
+	}
+
 	public ExamSpecialSettingsType getSpecialSettingsType() {
 		return specialSettingsType;
 	}

+ 27 - 0
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/ExamInfo.java

@@ -7,6 +7,7 @@ import javax.persistence.EnumType;
 import javax.persistence.Enumerated;
 import javax.validation.constraints.NotNull;
 
+import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
 import cn.com.qmth.examcloud.api.commons.enums.ExamType;
 import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
 
@@ -78,6 +79,16 @@ public class ExamInfo implements JsonSerializable {
 	 */
 	private Boolean examLimit;
 
+	/**
+	 * 开启特殊设置
+	 */
+	private Boolean specialSettingsEnabled;
+
+	/**
+	 * 特殊设置类型
+	 */
+	private ExamSpecialSettingsType specialSettingsType;
+
 	/**
 	 * 考试属性
 	 */
@@ -179,4 +190,20 @@ public class ExamInfo implements JsonSerializable {
 		this.properties = properties;
 	}
 
+	public Boolean getSpecialSettingsEnabled() {
+		return specialSettingsEnabled;
+	}
+
+	public void setSpecialSettingsEnabled(Boolean specialSettingsEnabled) {
+		this.specialSettingsEnabled = specialSettingsEnabled;
+	}
+
+	public ExamSpecialSettingsType getSpecialSettingsType() {
+		return specialSettingsType;
+	}
+
+	public void setSpecialSettingsType(ExamSpecialSettingsType specialSettingsType) {
+		this.specialSettingsType = specialSettingsType;
+	}
+
 }

+ 2 - 0
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/cache/ExamSettingsCache.java

@@ -44,6 +44,8 @@ public class ExamSettingsCache extends RandomObjectRedisCache<ExamSettingsCacheB
 		bean.setRemark(exam.getRemark());
 		bean.setRootOrgId(exam.getRootOrgId());
 		bean.setExamLimit(exam.getExamLimit());
+		bean.setSpecialSettingsEnabled(exam.getSpecialSettingsEnabled());
+		bean.setSpecialSettingsType(exam.getSpecialSettingsType());
 
 		return bean;
 	}

+ 7 - 0
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamServiceImpl.java

@@ -198,6 +198,7 @@ public class ExamServiceImpl implements ExamService {
 			exam.setExamType(examType);
 			exam.setEnable(true);
 			exam.setExamLimit(false);
+			exam.setSpecialSettingsEnabled(false);
 		} else if (realStatus.equals(CURD.UPDATE)) {
 			if (!exam.getRootOrgId().equals(rootOrgId)) {
 				throw new StatusException("002003", "rootOrgId is wrong");
@@ -207,6 +208,12 @@ public class ExamServiceImpl implements ExamService {
 			}
 		}
 
+		if (null != examInfo.getSpecialSettingsEnabled()) {
+			exam.setSpecialSettingsEnabled(examInfo.getSpecialSettingsEnabled());
+		}
+		if (null != examInfo.getSpecialSettingsType()) {
+			exam.setSpecialSettingsType(examInfo.getSpecialSettingsType());
+		}
 		if (null != examInfo.getBeginTime()) {
 			exam.setBeginTime(examInfo.getBeginTime());
 		}

+ 6 - 0
examcloud-core-examwork-starter/src/main/resources/exam-properties.xml

@@ -252,4 +252,10 @@
 		<desc>冻结时间外活体检测结束分钟数</desc>
 		<valueType>LONG</valueType>
 	</enum>
+	<enum>
+		<id>43</id>
+		<name>LIMITED_IF_NO_SPECIAL_SETTINGS</name>
+		<desc>无特殊设置时禁止考试</desc>
+		<valueType>BOOLEAN</valueType>
+	</enum>
 </enums>