Эх сурвалжийг харах

在线考试:已结束考试

qinchao 4 жил өмнө
parent
commit
6b839afef4

+ 12 - 0
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamControlController.java

@@ -49,6 +49,18 @@ public class ExamControlController extends ControllerSupport {
         return examStudentService.queryOnlineExamList(user.getUserId(), ExamType.ONLINE);
     }
 
+    /**
+     * 获取在线考试已结束列表
+     *
+     * @return
+     */
+    @ApiOperation(value = "获取在线考试已结束列表")
+    @GetMapping("/queryExamEndList")
+    public List<OnHandExamInfo> queryExamEndList() {
+        User user = getAccessUser();
+        return examStudentService.queryOnlineExamEndList(user.getUserId(), ExamType.ONLINE);
+    }
+
     /**
      * 获取在线作业待考列表
      *

+ 1 - 0
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamStudentService.java

@@ -150,4 +150,5 @@ public interface ExamStudentService {
 
     List<ExamStudentInfo> getExamStudentInfoListForAsync(ExamStudentQuery query);
 
+    List<OnHandExamInfo> queryOnlineExamEndList(Long userId, ExamType online);
 }

+ 64 - 5
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamStudentServiceImpl.java

@@ -15,6 +15,7 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.text.DecimalFormat;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -341,6 +342,54 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         setPhone(examStudentInfoList, query.getRootOrgId());
         return examStudentInfoList;
     }
+
+    @Override
+    public List<OnHandExamInfo> queryOnlineExamEndList(Long studentId, ExamType examType) {
+        StudentCacheBean studentBean = CacheHelper.getStudent(studentId);
+
+        //获取可以考的和即将考的考试Id
+        GetOngoingExamListReq getOngoingExamListReq = new GetOngoingExamListReq();
+        getOngoingExamListReq.setExamType(examType.name());
+        getOngoingExamListReq.setRootOrgId(studentBean.getRootOrgId());
+        getOngoingExamListReq.setOrgId(studentBean.getOrgId());
+        getOngoingExamListReq.setStudentId(studentId);
+        GetOngoingExamListResp getOngoingExamListResp = examCloudService.getOngoingExamList(getOngoingExamListReq);
+
+        //获取学生所在组织机构的所有考试列表集合
+        List<ExamSpecialSettingsBean> examSpecialSettingsBeanList = getOngoingExamListResp.getExamSpecialSettingsList();
+        if (examSpecialSettingsBeanList == null || examSpecialSettingsBeanList.size() == 0) {
+            return null;
+        }
+        List<Long> examIds = examSpecialSettingsBeanList.stream().map(ExamSpecialSettingsBean::getExamId).collect(Collectors.toList());
+
+        //只查没有禁用的考生
+        List<ExamStudentEntity> examStudents =
+                examStudentRepo.findByStudentIdAndEnableAndExamIdIn(studentId, true, examIds);
+
+        List<OnHandExamInfo> examStudentDtoList = new ArrayList<OnHandExamInfo>();
+        Date now = new Date();
+        for (ExamStudentEntity examStudent : examStudents) {
+            assemblingExamStudentDto(examStudent, now, examStudentDtoList, true);
+        }
+
+        for(OnHandExamInfo info:examStudentDtoList) {
+            ExamPropertyCacheBean examCycleEnabledCache = CacheHelper.getExamProperty(info.getExamId(), ExamProperties.EXAM_CYCLE_ENABLED.name());
+            if(examCycleEnabledCache!=null&&StringUtil.isTrue(examCycleEnabledCache.getValue())) {
+                info.setExamCycleEnabled(true);
+
+                ExamPropertyCacheBean examCycleWeekCache = CacheHelper.getExamProperty(info.getExamId(), ExamProperties.EXAM_CYCLE_WEEK.name());
+
+                info.setExamCycleWeek(JSONObject.parseArray(examCycleWeekCache.getValue()));
+                ExamPropertyCacheBean examCycleTimeRangeCache = CacheHelper.getExamProperty(info.getExamId(), ExamProperties.EXAM_CYCLE_TIME_RANGE.name());
+                info.setExamCycleTimeRange(JSONObject.parseArray(examCycleTimeRangeCache.getValue()));
+            }else {
+                info.setExamCycleEnabled(false);
+            }
+        }
+
+        return examStudentDtoList;
+    }
+
     private void setPhone(List<ExamStudentInfo> dataList,Long rootOrgId) {
     	GetStudentListByIdsReq req= new GetStudentListByIdsReq();
         BatchSetDataUtil<ExamStudentInfo> tool = new BatchSetDataUtil<ExamStudentInfo>() {
@@ -1077,7 +1126,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         List<OnHandExamInfo> examStudentDtoList = new ArrayList<OnHandExamInfo>();
         Date now = new Date();
         for (ExamStudentEntity examStudent : examStudents) {
-            assemblingExamStudentDto(examStudent, now, examStudentDtoList);
+            assemblingExamStudentDto(examStudent, now, examStudentDtoList, false);
         }
         
         for(OnHandExamInfo info:examStudentDtoList) {
@@ -1098,7 +1147,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         return examStudentDtoList;
     }
 
-    private void assemblingExamStudentDto(ExamStudentEntity examStudent, Date now, final List<OnHandExamInfo> resultList) {
+    private void assemblingExamStudentDto(ExamStudentEntity examStudent, Date now, final List<OnHandExamInfo> resultList, boolean end) {
         Long examId = examStudent.getExamId();
         Long studentId = examStudent.getStudentId();
         Long examStageId = examStudent.getExamStageId();
@@ -1113,9 +1162,19 @@ public class ExamStudentServiceImpl implements ExamStudentService {
                 return;
             }
 
-            //如果当前时间超过场次结束时间,不允许考试
-            if (now.after(examBean.getEndTime())) {
-                return;
+            if (end) {
+                Calendar calendar = Calendar.getInstance();
+                calendar.setTime(examBean.getEndTime());
+                calendar.add(Calendar.DATE, 30);
+                Date leftTime = calendar.getTime();
+                //已结束且结束时间30天以内的
+                if(now.after(leftTime)||now.before(examBean.getEndTime())){
+                    return;
+                }
+            } else {
+                if (now.after(examBean.getEndTime())) {
+                    return;
+                }
             }
 
         }