Selaa lähdekoodia

发起考试考号判断 移除考试学生

tags/正式版本
雍文秀 2 vuotta sitten
vanhempi
commit
32038a6992

+ 9
- 6
sexam/src/main/java/com/xhkjedu/sexam/service/exam/EBaseService.java Näytä tiedosto

@@ -73,21 +73,23 @@ public class EBaseService {
73 73
             Integer examid = model.getId();
74 74
 
75 75
             ResultVo vo = saveExam(model, examid);//保存考试基本信息
76
-            if (vo != null) return vo;
76
+            if (vo != null) throw new Exception(vo.getMsg());
77 77
 
78 78
             return new ResultVo(0, "保存成功", examid);
79 79
         } catch (Exception e) {
80 80
             log.error("发起考试失败", e.getMessage());
81 81
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
82
-            return new ResultVo(1, "保存失败");
82
+            return new ResultVo(1, e.getMessage());
83 83
         }
84 84
     }
85 85
 
86 86
     //保存考试基本信息
87 87
     private ResultVo saveExam(EBase model, Integer examid) {
88 88
         List<Integer> classids = model.getClassids();
89
-        Integer num = eClassStudentMapper.getNoExamNoNumByClassIds(classids);//根据班级ids获取没有考号学生数量
90
-        if (num != 0) return new ResultVo(1, "有学生没有考号");
89
+        if(model.getExammode() == 2) {//线下考试必须有考号
90
+            Integer num = eClassStudentMapper.getNoExamNoNumByClassIds(classids);//根据班级ids获取没有考号学生数量
91
+            if (num != 0) return new ResultVo(1, "有学生没有考号");
92
+        }
91 93
         List<EClassStudent> students = eClassStudentMapper.listByClassIds(classids);
92 94
         int stuNum = students.stream().distinct().collect(Collectors.toList()).size();
93 95
         if (stuNum < students.size()) return new ResultVo(1, "有重复学生");
@@ -303,9 +305,10 @@ public class EBaseService {
303 305
     public ResultVo delStu(Integer ecsid) {
304 306
         EClassStudent student = eClassStudentMapper.selectByPrimaryKey(ecsid);
305 307
         EBaseVo exam = eBaseMapper.getExamStateById(student.getExamid());
306
-        if (2 == exam.getExamstate()) return new ResultVo(1, "考试已结束禁止操作");
308
+        if (0 != exam.getExamstate()) return new ResultVo(1, "考试已发布禁止操作");
307 309
         int timestamp = N_Utils.getSecondTimestamp() + 30 * 60;
308
-        if (exam.getBegintime().compareTo(timestamp) != 1) return new ResultVo(1, "开考前30分钟禁止移除学生");
310
+        Integer begintime = exam.getBegintime();
311
+        if (begintime != 0 && begintime.compareTo(timestamp) != 1) return new ResultVo(1, "开考前30分钟禁止移除学生");
309 312
         eClassStudentMapper.deleteByPrimaryKey(ecsid);
310 313
         eClassMapper.updateClassNumByCsId(student.getExamid(), student.getClassid());
311 314
         return new ResultVo(0, "移除考试学生成功");

Loading…
Peruuta
Tallenna