wangwei 6 yıl önce
ebeveyn
işleme
0236724733

+ 23 - 6
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamStudentServiceImpl.java

@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import cn.com.qmth.examcloud.commons.base.exception.StatusException;
+import cn.com.qmth.examcloud.commons.base.util.PropertiesUtil;
 import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
 import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
 import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
@@ -79,11 +80,27 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 	@Autowired
 	ExamPaperTypeRelationRepo examPaperTypeRelationRepo;
 
-	private boolean isStarted(Long examId, Long StudentId, Long courseId) {
-		if (2 > 1) {
-			return false;
-		}
+	/**
+	 * 是否强制删除考生
+	 *
+	 * @author WANGWEI
+	 * @return
+	 */
+	private boolean forceDeleteExamStudent() {
+		boolean b = PropertiesUtil.getBoolean("$deleteExamStudent.force", false);
+		return b;
+	}
 
+	/**
+	 * 是否开考
+	 *
+	 * @author WANGWEI
+	 * @param examId
+	 * @param StudentId
+	 * @param courseId
+	 * @return
+	 */
+	private boolean isStarted(Long examId, Long StudentId, Long courseId) {
 		CheckExamIsStartedReq checkExamIsStartedReq = new CheckExamIsStartedReq();
 		checkExamIsStartedReq.setExamId(examId);
 		checkExamIsStartedReq.setCourseId(courseId);
@@ -105,7 +122,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 
 		for (ExamStudentEntity examStudent : examStudents) {
 			// 网考判断
-			if (isStarted(examStudent.getExamId(), null, null)) {
+			if ((!forceDeleteExamStudent()) && isStarted(examStudent.getExamId(), null, null)) {
 				throw new StatusException("E-150112", examStudent.getName() + "已开始考试,不能删除");
 			}
 			examStudentRepo.delete(examStudent);
@@ -154,7 +171,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
 	public void deleteExamStudentsByExamId(Long examId) {
 		ExamEntity exam = examRepo.findOne(examId);
 		// 已经开考
-		if (isStarted(exam.getId(), null, null)) {
+		if ((!forceDeleteExamStudent()) && isStarted(exam.getId(), null, null)) {
 			throw new StatusException("E-150113", "该考试已开始,不能删除");
 		}
 		examStudentRepo.deleteByExamId(examId);

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

@@ -9,4 +9,6 @@ eureka.client.serviceUrl.defaultZone=http://localhost:1111/eureka/
 
 $log.level.default=debug
 
-$tempDir=D:/Temp/examcloud//tempDir
+$tempDir=D:/Temp/examcloud//tempDir
+
+$deleteExamStudent.force=true

+ 3 - 1
examcloud-core-examwork-starter/src/main/resources/application-prod.properties

@@ -13,4 +13,6 @@ spring.redis.host=r-wz97e520d2701e54555.redis.rds.aliyuncs.com
 spring.redis.port=6379
 spring.redis.password=Qmth87863577
 
-$tempDir=/root/project/examcloud/examcloud-core-examwork/tempDir
+$tempDir=/root/project/examcloud/examcloud-core-examwork/tempDir
+
+$deleteExamStudent.force=false

+ 2 - 0
examcloud-core-examwork-starter/src/main/resources/application-test.properties

@@ -12,3 +12,5 @@ eureka.client.serviceUrl.defaultZone=http://eureka-host:1111/eureka/
 $log.level.default=debug
 
 $tempDir=/home/qmth/project/examcloud/examcloud-core-examwork/tempDir
+
+$deleteExamStudent.force=true