|
@@ -1,39 +1,56 @@
|
|
package com.qmth.themis.business.templete.service.impl;
|
|
package com.qmth.themis.business.templete.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.google.common.reflect.TypeToken;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
-import com.qmth.themis.business.bean.cloudmark.SaveExamParams;
|
|
|
|
-import com.qmth.themis.business.bean.cloudmark.SaveStudentParams;
|
|
|
|
-import com.qmth.themis.business.bean.cloudmark.SaveSubjectParams;
|
|
|
|
|
|
+import com.qmth.themis.business.bean.admin.OpenRecordAnswerBean;
|
|
|
|
+import com.qmth.themis.business.bean.admin.OpenRecordAnswerStructBean;
|
|
|
|
+import com.qmth.themis.business.bean.admin.OpenRecordAnswerTempBean;
|
|
|
|
+import com.qmth.themis.business.bean.admin.OpenRecordNeedMarkBean;
|
|
|
|
+import com.qmth.themis.business.bean.cloudmark.FileUploadParams;
|
|
|
|
+import com.qmth.themis.business.cache.RedisKeyHelper;
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamCourseCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamCourseCacheBean;
|
|
|
|
+import com.qmth.themis.business.cache.bean.ExamPaperCacheBean;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.dao.TEExamCourseMapper;
|
|
import com.qmth.themis.business.dao.TEExamCourseMapper;
|
|
import com.qmth.themis.business.dto.ExamStudentImportDto;
|
|
import com.qmth.themis.business.dto.ExamStudentImportDto;
|
|
import com.qmth.themis.business.dto.RoomCodeImportDto;
|
|
import com.qmth.themis.business.dto.RoomCodeImportDto;
|
|
import com.qmth.themis.business.entity.*;
|
|
import com.qmth.themis.business.entity.*;
|
|
|
|
+import com.qmth.themis.business.enums.CloudMarkFileUploadTypeEnum;
|
|
import com.qmth.themis.business.enums.ExamModeEnum;
|
|
import com.qmth.themis.business.enums.ExamModeEnum;
|
|
import com.qmth.themis.business.enums.RoleEnum;
|
|
import com.qmth.themis.business.enums.RoleEnum;
|
|
import com.qmth.themis.business.enums.TaskStatusEnum;
|
|
import com.qmth.themis.business.enums.TaskStatusEnum;
|
|
import com.qmth.themis.business.service.*;
|
|
import com.qmth.themis.business.service.*;
|
|
import com.qmth.themis.business.templete.service.TempleteLogicService;
|
|
import com.qmth.themis.business.templete.service.TempleteLogicService;
|
|
import com.qmth.themis.business.util.CloudMarkUtil;
|
|
import com.qmth.themis.business.util.CloudMarkUtil;
|
|
|
|
+import com.qmth.themis.business.util.JacksonUtil;
|
|
|
|
+import com.qmth.themis.business.util.OssUtil;
|
|
import com.qmth.themis.common.contanst.Constants;
|
|
import com.qmth.themis.common.contanst.Constants;
|
|
import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
import com.qmth.themis.common.util.Base64Util;
|
|
import com.qmth.themis.common.util.Base64Util;
|
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.FileOutputStream;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
+import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -45,6 +62,7 @@ import java.util.stream.Collectors;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class TempleteLogicServiceImpl implements TempleteLogicService {
|
|
public class TempleteLogicServiceImpl implements TempleteLogicService {
|
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(TempleteLogicServiceImpl.class);
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
TEExamStudentService teExamStudentService;
|
|
TEExamStudentService teExamStudentService;
|
|
@@ -76,6 +94,24 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
|
|
@Resource
|
|
@Resource
|
|
TEExamService teExamService;
|
|
TEExamService teExamService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ TEExamPaperService teExamPaperService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ CacheService cacheService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ TOeExamRecordService tOeExamRecordService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ TBTaskHistoryService tbTaskHistoryService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ OssUtil ossUtil;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ TOeExamAnswerService examAnswerService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 考生导入逻辑
|
|
* 考生导入逻辑
|
|
*
|
|
*
|
|
@@ -370,61 +406,586 @@ public class TempleteLogicServiceImpl implements TempleteLogicService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- @Transactional
|
|
|
|
public Map<String, Object> execPushCloudMarkDataLogic(Map<String, Object> map) throws IOException {
|
|
public Map<String, Object> execPushCloudMarkDataLogic(Map<String, Object> map) throws IOException {
|
|
|
|
+ checkData(map);
|
|
|
|
+ Long examId = (Long) map.get(SystemConstant.EXAM_ID);
|
|
|
|
+// Long orgId = (Long) map.get(SystemConstant.ORG_ID);
|
|
|
|
+// String examCode = (String) map.get(SystemConstant.EXAM_CODE);
|
|
|
|
+
|
|
|
|
+ //先推送考试
|
|
|
|
+ ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
|
|
|
|
+ TBTaskHistory tbTaskHistory = (TBTaskHistory) map.get("tbTaskHistory");
|
|
|
|
+ JSONObject jsonObject = Objects.nonNull(tbTaskHistory.getRemark()) ? JSONObject.parseObject(tbTaskHistory.getRemark()) : null;
|
|
|
|
+ Integer totalTaskSize = 1, currentTaskSize = 1, jsTotalTaskSize = 0, jsCurrentTaskSize = 0;
|
|
|
|
+ Long cloudMarkExamId = null;
|
|
|
|
+
|
|
|
|
+ TEExam teExam = teExamService.cacheConvert(examCacheBean);
|
|
|
|
+ if (Objects.isNull(tbTaskHistory.getEntityId())) {
|
|
|
|
+// cloudMarkExamId = cloudMarkUtil.callExamSaveApi(new SaveExamParams(orgId, examId, examCode, examCacheBean.getName(), DateUtil.format(new Date(examCacheBean.getStartTime()), Constants.DEFAULT_DATE_PATTERN)));
|
|
|
|
+ cloudMarkExamId = Long.parseLong((int) (Math.random() * 1000) + "");
|
|
|
|
+ teExam.setUpdateTime(System.currentTimeMillis());
|
|
|
|
+ teExam.setThirdExamId(String.valueOf(cloudMarkExamId));
|
|
|
|
+ teExamService.updateById(teExam);
|
|
|
|
+ teExamService.updateExamCacheBean(examId);
|
|
|
|
+ } else {
|
|
|
|
+ cloudMarkExamId = tbTaskHistory.getEntityId();
|
|
|
|
+ }
|
|
|
|
+ if (Objects.nonNull(cloudMarkExamId)) {
|
|
|
|
+ if (Objects.isNull(jsonObject)) {
|
|
|
|
+ jsonObject = new JSONObject();
|
|
|
|
+ jsonObject.put("examSize", 1);
|
|
|
|
+ jsonObject.put("totalTaskSize", totalTaskSize);
|
|
|
|
+ jsonObject.put("currentTaskSize", currentTaskSize);
|
|
|
|
+ tbTaskHistory.setEntityId(cloudMarkExamId);
|
|
|
|
+ tbTaskHistory.setRemark(jsonObject.toJSONString());
|
|
|
|
+ } else {
|
|
|
|
+ jsTotalTaskSize = jsonObject.getInteger("totalTaskSize");
|
|
|
|
+ jsCurrentTaskSize = jsonObject.getInteger("currentTaskSize");
|
|
|
|
+ tbTaskHistory.setStatus(TaskStatusEnum.RUNNING);
|
|
|
|
+ }
|
|
|
|
+ tbTaskHistoryService.updateById(tbTaskHistory);
|
|
|
|
+
|
|
|
|
+ //推送试卷科目
|
|
|
|
+ Set<Long> examPaperIdSet = pushExamPaperLogic(map, jsonObject, totalTaskSize, jsCurrentTaskSize, currentTaskSize, cloudMarkExamId);
|
|
|
|
+
|
|
|
|
+ //获取所有待阅卷的考生
|
|
|
|
+ List<TEExamStudent> teExamStudentList = getExamStudentNeedMarkAll(map, jsonObject, teExam, examPaperIdSet, jsTotalTaskSize, jsCurrentTaskSize);
|
|
|
|
+
|
|
|
|
+ //获取只有一次考试记录的考生
|
|
|
|
+ List<TOeExamRecord> tOeExamRecordList = getExamRecordOnce(map, jsonObject, examPaperIdSet);
|
|
|
|
+
|
|
|
|
+ //获取多次考试记录的考试
|
|
|
|
+ List<TOeExamRecord> tOeExamRecordManyList = tOeExamRecordService.findExamRecordNeedMarkAll(examId, examPaperIdSet, true);
|
|
|
|
+ if (!CollectionUtils.isEmpty(tOeExamRecordManyList)) {
|
|
|
|
+ Set<Long> manyExamStudentIdSet = tOeExamRecordManyList.stream().map(s -> s.getExamStudentId()).collect(Collectors.toSet());
|
|
|
|
+ jsonObject.put("examRecordManyListSize", manyExamStudentIdSet.size());
|
|
|
|
+ tbTaskHistory.setRemark(jsonObject.toJSONString());
|
|
|
|
+ tbTaskHistoryService.updateById(tbTaskHistory);
|
|
|
|
+ if (teExamStudentList.size() != tOeExamRecordList.size() + manyExamStudentIdSet.size()) {
|
|
|
|
+ throw new BusinessException("待阅卷的考试记录和考生数不匹配");
|
|
|
|
+ }
|
|
|
|
+ List<TOeExamRecord> resultExamRecordList = filterManyExamRecord(tOeExamRecordManyList, teExam);
|
|
|
|
+ tOeExamRecordList.addAll(resultExamRecordList);
|
|
|
|
+ //推送多次考试记录的考生
|
|
|
|
+ } else {
|
|
|
|
+ if (teExamStudentList.size() != tOeExamRecordList.size()) {
|
|
|
|
+ throw new BusinessException("待阅卷的考试记录和考生数不匹配");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //推送考试记录的考生开始
|
|
|
|
+ pushExamStudentLogic(map,
|
|
|
|
+ jsonObject,
|
|
|
|
+ teExamStudentList,
|
|
|
|
+ tOeExamRecordList,
|
|
|
|
+ jsCurrentTaskSize,
|
|
|
|
+ cloudMarkExamId);
|
|
|
|
+ }
|
|
|
|
+ return pushDataSuccess(map, jsonObject);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 推送数据成功
|
|
|
|
+ *
|
|
|
|
+ * @param map
|
|
|
|
+ * @param jsonObject
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private Map<String, Object> pushDataSuccess(Map<String, Object> map,
|
|
|
|
+ JSONObject jsonObject) {
|
|
|
|
+ TBTaskHistory tbTaskHistory = (TBTaskHistory) map.get("tbTaskHistory");
|
|
|
|
+ List<String> txtList = (List<String>) map.get("txtList");
|
|
|
|
+ StringJoiner stringJoiner = new StringJoiner("");
|
|
|
|
+ stringJoiner.add("推送数据成功:共推送了").add(String.valueOf(jsonObject.getInteger("examSize"))).add("个考试,")
|
|
|
|
+ .add(String.valueOf(jsonObject.getInteger("examPaperSize"))).add("个试卷科目,")
|
|
|
|
+ .add(String.valueOf(jsonObject.getInteger("examExamStudentSize"))).add("个考生");
|
|
|
|
+ txtList.add(DateUtil.format(new Date(), Constants.DEFAULT_DATE_PATTERN) + "->" + stringJoiner.toString());
|
|
|
|
+
|
|
|
|
+ tbTaskHistory.setSummary(txtList.toString());
|
|
|
|
+ tbTaskHistory.setStatus(TaskStatusEnum.FINISH);
|
|
|
|
+ tbTaskHistory.setFinishTime(System.currentTimeMillis());
|
|
|
|
+ tbTaskHistoryService.updateById(tbTaskHistory);
|
|
|
|
+ return map;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取只有一次考试记录的考生
|
|
|
|
+ *
|
|
|
|
+ * @param map
|
|
|
|
+ * @param jsonObject
|
|
|
|
+ * @param examPaperIdSet
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<TOeExamRecord> getExamRecordOnce(Map<String, Object> map,
|
|
|
|
+ JSONObject jsonObject,
|
|
|
|
+ Set<Long> examPaperIdSet) {
|
|
|
|
+ Long examId = (Long) map.get(SystemConstant.EXAM_ID);
|
|
|
|
+ TBTaskHistory tbTaskHistory = (TBTaskHistory) map.get("tbTaskHistory");
|
|
|
|
+ List<TOeExamRecord> tOeExamRecordList = tOeExamRecordService.findExamRecordNeedMarkAll(examId, examPaperIdSet, false);
|
|
|
|
+ if (CollectionUtils.isEmpty(tOeExamRecordList)) {
|
|
|
|
+ throw new BusinessException("没有待阅卷的考试记录");
|
|
|
|
+ }
|
|
|
|
+ jsonObject.put("examRecordListSize", tOeExamRecordList.size());
|
|
|
|
+
|
|
|
|
+ Integer totalTaskSize = jsonObject.getInteger("totalTaskSize");
|
|
|
|
+ Integer currentTaskSize = jsonObject.getInteger("currentTaskSize");
|
|
|
|
+
|
|
|
|
+ BigDecimal progress = new BigDecimal(0);
|
|
|
|
+ BigDecimal b = new BigDecimal(100);
|
|
|
|
+ progress = new BigDecimal(currentTaskSize).divide(new BigDecimal(totalTaskSize), 2, BigDecimal.ROUND_HALF_UP).multiply(b);
|
|
|
|
+ if (Objects.isNull(tbTaskHistory.getProgress()) || (Objects.nonNull(tbTaskHistory.getProgress()) && tbTaskHistory.getProgress().doubleValue() < progress.doubleValue())) {
|
|
|
|
+ tbTaskHistory.setProgress(progress.doubleValue());
|
|
|
|
+ tbTaskHistoryService.updateById(tbTaskHistory);
|
|
|
|
+ }
|
|
|
|
+ tbTaskHistory.setRemark(jsonObject.toJSONString());
|
|
|
|
+ return tOeExamRecordList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取所有待阅卷的考生
|
|
|
|
+ *
|
|
|
|
+ * @param map
|
|
|
|
+ * @param jsonObject
|
|
|
|
+ * @param teExam
|
|
|
|
+ * @param examPaperIdSet
|
|
|
|
+ * @param jsTotalTaskSize
|
|
|
|
+ * @param jsCurrentTaskSize
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<TEExamStudent> getExamStudentNeedMarkAll(Map<String, Object> map,
|
|
|
|
+ JSONObject jsonObject,
|
|
|
|
+ TEExam teExam,
|
|
|
|
+ Set<Long> examPaperIdSet,
|
|
|
|
+ Integer jsTotalTaskSize,
|
|
|
|
+ Integer jsCurrentTaskSize) {
|
|
|
|
+ Long examId = (Long) map.get(SystemConstant.EXAM_ID);
|
|
|
|
+ TBTaskHistory tbTaskHistory = (TBTaskHistory) map.get("tbTaskHistory");
|
|
|
|
+ List<TEExamStudent> teExamStudentList = teExamStudentService.findExamStudentNeedMarkAll(examId, examPaperIdSet);
|
|
|
|
+ if (CollectionUtils.isEmpty(teExamStudentList)) {
|
|
|
|
+ throw new BusinessException("没有待阅卷的考生");
|
|
|
|
+ }
|
|
|
|
+ Integer totalTaskSize = jsonObject.getInteger("totalTaskSize");
|
|
|
|
+ Integer currentTaskSize = jsonObject.getInteger("currentTaskSize");
|
|
|
|
+ totalTaskSize = totalTaskSize.intValue() + teExamStudentList.size();
|
|
|
|
+ if (jsCurrentTaskSize.intValue() > currentTaskSize.intValue() && jsTotalTaskSize.intValue() > 0 && jsTotalTaskSize.intValue() != totalTaskSize.intValue()) {
|
|
|
|
+ teExam.setUpdateTime(System.currentTimeMillis());
|
|
|
|
+ teExam.setThirdExamId(null);
|
|
|
|
+ teExamService.updateById(teExam);
|
|
|
|
+ teExamService.updateExamCacheBean(examId);
|
|
|
|
+ throw new BusinessException("数据已发生改变,需重新推送");
|
|
|
|
+ }
|
|
|
|
+ jsonObject.put("examExamStudentSize", teExamStudentList.size());
|
|
|
|
+ jsonObject.put("totalTaskSize", totalTaskSize);
|
|
|
|
+ tbTaskHistory.setRemark(jsonObject.toJSONString());
|
|
|
|
+ return teExamStudentList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 推送考生和考试记录逻辑
|
|
|
|
+ *
|
|
|
|
+ * @param map
|
|
|
|
+ * @param jsonObject
|
|
|
|
+ * @param teExamStudentList
|
|
|
|
+ * @param tOeExamRecordList
|
|
|
|
+ * @param jsCurrentTaskSize
|
|
|
|
+ * @param cloudMarkExamId
|
|
|
|
+ */
|
|
|
|
+ private void pushExamStudentLogic(Map<String, Object> map,
|
|
|
|
+ JSONObject jsonObject,
|
|
|
|
+ List<TEExamStudent> teExamStudentList,
|
|
|
|
+ List<TOeExamRecord> tOeExamRecordList,
|
|
|
|
+ Integer jsCurrentTaskSize,
|
|
|
|
+ Long cloudMarkExamId) throws IOException {
|
|
|
|
+ Long orgId = (Long) map.get(SystemConstant.ORG_ID);
|
|
|
|
+ TBTaskHistory tbTaskHistory = (TBTaskHistory) map.get("tbTaskHistory");
|
|
|
|
+ BigDecimal progress = new BigDecimal(0);
|
|
|
|
+ BigDecimal b = new BigDecimal(100);
|
|
|
|
+ TBOrg tbOrg = cacheService.addOrgCache(orgId);
|
|
|
|
+
|
|
|
|
+ Integer totalTaskSize = jsonObject.getInteger("totalTaskSize");
|
|
|
|
+ Integer currentTaskSize = jsonObject.getInteger("currentTaskSize");
|
|
|
|
+
|
|
|
|
+ Map<Long, TOeExamRecord> tOeExamRecordMap = tOeExamRecordList.stream().collect(
|
|
|
|
+ Collectors.toMap(TOeExamRecord::getExamStudentId, Function.identity(), (dto1, dto2) -> dto1));
|
|
|
|
+
|
|
|
|
+ Map<Long, Map<String, Integer>> paperStructMap = new HashMap<>();
|
|
|
|
+ List<File> recordJsonList = new ArrayList<>(teExamStudentList.size());
|
|
|
|
+ map.put("recordJsonList", recordJsonList);
|
|
|
|
+ //推送考试记录的考生
|
|
|
|
+ int min = 0;
|
|
|
|
+ int max = SystemConstant.MAX_IMPORT_SIZE, size = teExamStudentList.size();
|
|
|
|
+ if (max >= size) {
|
|
|
|
+ max = size;
|
|
|
|
+ }
|
|
|
|
+ while (max <= size) {
|
|
|
|
+ List<TEExamStudent> subList = teExamStudentList.subList(min, max);
|
|
|
|
+ for (int y = 0; y < subList.size(); y++) {
|
|
|
|
+// if (y == 300) {
|
|
|
|
+// int k = 1 / 0;
|
|
|
|
+// }
|
|
|
|
+ TEExamStudent t = subList.get(y);
|
|
|
|
+ if (jsCurrentTaskSize.intValue() > 0 && currentTaskSize.intValue() < jsCurrentTaskSize.intValue()) {
|
|
|
|
+ jsonObject.put("currentTaskSize", currentTaskSize);
|
|
|
|
+ currentTaskSize++;
|
|
|
|
+ tbTaskHistory.setRemark(jsonObject.toJSONString());
|
|
|
|
+ continue;
|
|
|
|
+ } else {
|
|
|
|
+// cloudMarkUtil.callStudentSaveApi(new SaveStudentParams(orgId, cloudMarkExamId, SystemConstant.VALUE_OF_BLANK_REQUIRED_FIELD,
|
|
|
|
+// t.getIdentity(),
|
|
|
|
+// t.getName(),
|
|
|
|
+// tbOrg.getName(),
|
|
|
|
+// t.getClassNo(), SystemConstant.VALUE_OF_BLANK_REQUIRED_FIELD,
|
|
|
|
+// t.getCourseCode(),
|
|
|
|
+// t.getCourseName()));
|
|
|
|
+ TOeExamRecord tOeExamRecord = tOeExamRecordMap.get(t.getId());
|
|
|
|
+// if (Objects.isNull(tOeExamRecord)) {
|
|
|
|
+// continue;
|
|
|
|
+// }
|
|
|
|
+ Optional.ofNullable(tOeExamRecord).orElseThrow(() -> new BusinessException(ExceptionResultEnum.NOT_FOUND_EXAM_RECORD));
|
|
|
|
+
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
+ OpenRecordNeedMarkBean openRecordNeedMarkBean = gson.fromJson(gson.toJson(tOeExamRecord), OpenRecordNeedMarkBean.class);
|
|
|
|
+ List<OpenRecordAnswerTempBean> answersTemp = examAnswerService.findByExamRecordId(tOeExamRecord.getId());
|
|
|
|
+ List<OpenRecordAnswerBean> answers = new ArrayList<>(answersTemp.size());
|
|
|
|
+ List<OpenRecordAnswerBean> finalAnswers = answers;
|
|
|
|
+ answersTemp.forEach(s -> {
|
|
|
|
+ OpenRecordAnswerBean openRecordAnswerBean = new OpenRecordAnswerBean(s.getMainNumber(), s.getSubNumber(), s.getSubIndex());
|
|
|
|
+ try {
|
|
|
|
+ openRecordAnswerBean.setAnswer(gson.fromJson(s.getAnswer(), new TypeToken<List<OpenRecordAnswerStructBean>>() {
|
|
|
|
+ }.getType()));
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("错误答案:{}", s.getAnswer(), e);
|
|
|
|
+ }
|
|
|
|
+ finalAnswers.add(openRecordAnswerBean);
|
|
|
|
+ });
|
|
|
|
+ openRecordNeedMarkBean.setAnswers(answers.stream().filter(answer -> {
|
|
|
|
+ Map<String, Integer> struct = paperStructMap.get(tOeExamRecord.getPaperId());
|
|
|
|
+ if (struct == null) {
|
|
|
|
+ struct = teExamPaperService.getPaperStructCacheBean(tOeExamRecord.getPaperId());
|
|
|
|
+ if (struct != null) {
|
|
|
|
+ paperStructMap.put(tOeExamRecord.getPaperId(), struct);
|
|
|
|
+ } else {
|
|
|
|
+ log.error("找不到对应的试卷结构,paperId=" + tOeExamRecord.getPaperId());
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Integer type = struct.get(RedisKeyHelper
|
|
|
|
+ .examAnswerHashKey(answer.getMainNumber(), answer.getSubNumber(),
|
|
|
|
+ answer.getSubIndex()));
|
|
|
|
+ //过滤单选、多选、判断题
|
|
|
|
+ return type != null && type != 1 && type != 2 && type != 3;
|
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
|
+
|
|
|
|
+ File fileAnswerJson = new File(SystemConstant.TEMP_FILES_DIR + File.separator + CloudMarkFileUploadTypeEnum.ANSWER.getCode() + File.separator + SystemConstant.getUuid() + ".json");
|
|
|
|
+ if (!fileAnswerJson.exists()) {
|
|
|
|
+ fileAnswerJson.getParentFile().mkdirs();
|
|
|
|
+ fileAnswerJson.createNewFile();
|
|
|
|
+ }
|
|
|
|
+ IOUtils.write(JacksonUtil.parseJson(openRecordNeedMarkBean).getBytes(SystemConstant.CHARSET_NAME), new FileOutputStream(fileAnswerJson));
|
|
|
|
+ recordJsonList.add(fileAnswerJson);
|
|
|
|
+ FileUploadParams fileUploadParamsAnswerJson = new FileUploadParams(orgId, cloudMarkExamId, String.valueOf(tOeExamRecord.getId()), fileAnswerJson);
|
|
|
|
+// cloudMarkUtil.callFileUploadApi(fileUploadParamsAnswerJson);
|
|
|
|
+
|
|
|
|
+ jsonObject.put("currentTaskSize", currentTaskSize);
|
|
|
|
+ currentTaskSize++;
|
|
|
|
+ tbTaskHistory.setRemark(jsonObject.toJSONString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ progress = new BigDecimal(currentTaskSize).divide(new BigDecimal(totalTaskSize), 2, BigDecimal.ROUND_HALF_UP).multiply(b);
|
|
|
|
+ if (Objects.isNull(tbTaskHistory.getProgress()) || (Objects.nonNull(tbTaskHistory.getProgress()) && tbTaskHistory.getProgress().doubleValue() < progress.doubleValue())) {
|
|
|
|
+ tbTaskHistory.setProgress(progress.doubleValue());
|
|
|
|
+ tbTaskHistoryService.updateById(tbTaskHistory);
|
|
|
|
+ }
|
|
|
|
+ if (max == size) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ min = max;
|
|
|
|
+ max += SystemConstant.MAX_IMPORT_SIZE;
|
|
|
|
+ if (max >= size) {
|
|
|
|
+ max = size;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ jsonObject.put("currentTaskSize", currentTaskSize);
|
|
|
|
+ tbTaskHistory.setRemark(jsonObject.toJSONString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 过滤多条考试记录的考生
|
|
|
|
+ *
|
|
|
|
+ * @param tOeExamRecordManyList
|
|
|
|
+ * @param teExam
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<TOeExamRecord> filterManyExamRecord(List<TOeExamRecord> tOeExamRecordManyList, TEExam teExam) {
|
|
|
|
+ List<TOeExamRecord> result = null;
|
|
|
|
+ LinkedMultiValueMap<Long, TOeExamRecord> tOeExamRecordLinkedMultiValueMap = new LinkedMultiValueMap<>();
|
|
|
|
+ for (TOeExamRecord bean : tOeExamRecordManyList) {
|
|
|
|
+ tOeExamRecordLinkedMultiValueMap.add(bean.getExamStudentId(), bean);
|
|
|
|
+ }
|
|
|
|
+ if (!CollectionUtils.isEmpty(tOeExamRecordLinkedMultiValueMap)) {
|
|
|
|
+ result = new ArrayList<>();
|
|
|
|
+ List<TOeExamRecord> finalResult = result;
|
|
|
|
+ tOeExamRecordLinkedMultiValueMap.forEach((k, v) -> {
|
|
|
|
+ double highestObjectiveScore = 0.0;
|
|
|
|
+ long maxFinishTime = 0L;
|
|
|
|
+ boolean subjective = false;
|
|
|
|
+ List<TOeExamRecord> tempResult = new ArrayList<>(v.size());
|
|
|
|
+ for (TOeExamRecord bean : v) {
|
|
|
|
+ //获取对应的试卷信息
|
|
|
|
+ ExamPaperCacheBean paper = teExamPaperService.getExamPaperCacheBean(bean.getPaperId());
|
|
|
|
+ if (Objects.isNull(paper)) {
|
|
|
|
+ log.error("找不到对应的试卷信息, paperId=" + bean.getPaperId());
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //根据试卷结构过滤没有主观题的情况
|
|
|
|
+ if (paper.getTotalSubjectiveScore().doubleValue() == 0D) {
|
|
|
|
+ subjective = true;
|
|
|
|
+ maxFinishTime = Math.max(maxFinishTime, bean.getFinishTime());
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ highestObjectiveScore = Math.max(highestObjectiveScore, bean.getObjectiveScore());
|
|
|
|
+ maxFinishTime = Math.max(maxFinishTime, bean.getFinishTime());
|
|
|
|
+ tempResult.add(bean);
|
|
|
|
+ }
|
|
|
|
+ if (tempResult.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ switch (teExam.getRecordSelectStrategy()) {
|
|
|
|
+ case HIGHEST_OBJECTIVE_SCORE:
|
|
|
|
+ if (subjective) {
|
|
|
|
+ final long time = maxFinishTime;
|
|
|
|
+ finalResult.addAll(v.stream().filter(bean -> bean.getFinishTime() == time).collect(Collectors.toList()));
|
|
|
|
+ } else {
|
|
|
|
+ //客观分最高,客观分相同则全部提交阅卷
|
|
|
|
+ final double score = highestObjectiveScore;
|
|
|
|
+ finalResult.addAll(tempResult.stream().filter(bean -> bean.getObjectiveScore() == score).collect(Collectors.toList()));
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case LATEST:
|
|
|
|
+ //最后一次提交
|
|
|
|
+ final long time = maxFinishTime;
|
|
|
|
+ finalResult.addAll(tempResult.stream().filter(bean -> bean.getFinishTime() == time).collect(Collectors.toList()));
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ //总分最高,全部提交阅卷
|
|
|
|
+ finalResult.addAll(tempResult);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 推送试卷逻辑
|
|
|
|
+ *
|
|
|
|
+ * @param map
|
|
|
|
+ * @param jsonObject
|
|
|
|
+ * @param totalTaskSize
|
|
|
|
+ * @param jsCurrentTaskSize
|
|
|
|
+ * @param currentTaskSize
|
|
|
|
+ * @param cloudMarkExamId
|
|
|
|
+ * @return
|
|
|
|
+ * @throws IOException
|
|
|
|
+ */
|
|
|
|
+ private Set<Long> pushExamPaperLogic(Map<String, Object> map,
|
|
|
|
+ JSONObject jsonObject,
|
|
|
|
+ Integer totalTaskSize,
|
|
|
|
+ Integer jsCurrentTaskSize,
|
|
|
|
+ Integer currentTaskSize,
|
|
|
|
+ Long cloudMarkExamId) throws IOException {
|
|
|
|
+ Long examId = (Long) map.get(SystemConstant.EXAM_ID);
|
|
|
|
+ Long orgId = (Long) map.get(SystemConstant.ORG_ID);
|
|
|
|
+ TBTaskHistory tbTaskHistory = (TBTaskHistory) map.get("tbTaskHistory");
|
|
|
|
+ List<File> paperJsonList = null;
|
|
|
|
+
|
|
|
|
+ QueryWrapper<TEExamPaper> teExamPaperQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ teExamPaperQueryWrapper.lambda().eq(TEExamPaper::getExamId, examId)
|
|
|
|
+ .gt(TEExamPaper::getTotalSubjectiveScore, 0).orderByAsc(TEExamPaper::getId);
|
|
|
|
+ List<TEExamPaper> teExamPaperList = teExamPaperService.list(teExamPaperQueryWrapper);
|
|
|
|
+ if (CollectionUtils.isEmpty(teExamPaperList)) {
|
|
|
|
+ throw new BusinessException("没有考试试卷");
|
|
|
|
+ }
|
|
|
|
+ totalTaskSize = totalTaskSize.intValue() + teExamPaperList.size();
|
|
|
|
+ jsonObject.put("totalTaskSize", totalTaskSize);
|
|
|
|
+ jsonObject.put("examPaperSize", teExamPaperList.size());
|
|
|
|
+ tbTaskHistory.setRemark(jsonObject.toJSONString());
|
|
|
|
+ Set<Long> examPaperIdSet = new HashSet<>(teExamPaperList.size());
|
|
|
|
+
|
|
|
|
+ if (!CollectionUtils.isEmpty(teExamPaperList)) {
|
|
|
|
+ paperJsonList = new ArrayList<>(teExamPaperList.size());
|
|
|
|
+ map.put("paperJsonList", paperJsonList);
|
|
|
|
+ for (int i = 0; i < teExamPaperList.size(); i++) {
|
|
|
|
+// if (i == 10) {
|
|
|
|
+// int y = 1 / 0;
|
|
|
|
+// }
|
|
|
|
+ TEExamPaper t = teExamPaperList.get(i);
|
|
|
|
+ examPaperIdSet.add(t.getId());
|
|
|
|
+ if (jsCurrentTaskSize.intValue() > 0 && currentTaskSize.intValue() < jsCurrentTaskSize.intValue()) {
|
|
|
|
+ jsonObject.put("currentTaskSize", currentTaskSize);
|
|
|
|
+ currentTaskSize++;
|
|
|
|
+ tbTaskHistory.setRemark(jsonObject.toJSONString());
|
|
|
|
+ continue;
|
|
|
|
+ } else {
|
|
|
|
+ String courseCode = t.getCourseCode() + SystemConstant.JOINT_MARK + t.getId();
|
|
|
|
+// cloudMarkUtil.callSubjectSaveApi(new SaveSubjectParams(orgId, cloudMarkExamId, courseCode, t.getName()));
|
|
|
|
+ //解析试卷JSON文件
|
|
|
|
+ JSONObject paperResult = JSONObject.parseObject(new String(ossUtil.download(false, t.getPaperViewPath()), StandardCharsets.UTF_8));
|
|
|
|
+ paperResult.put(SystemConstant.ID, t.getId());
|
|
|
|
+ paperResult.put("code", t.getCode());
|
|
|
|
+ paperResult.put(SystemConstant.NAME, t.getName());
|
|
|
|
+ if (Objects.nonNull(t.getAnswerPath())) {
|
|
|
|
+ JSONArray detailCollection = new JSONArray();
|
|
|
|
+ JSONArray paperDetails = paperResult.getJSONArray("details");
|
|
|
|
+ //解析答案JSON文件
|
|
|
|
+ JSONObject answerJson = JSONObject.parseObject(new String(ossUtil.download(false, t.getAnswerPath()), StandardCharsets.UTF_8));
|
|
|
|
+ JSONArray answerDetails = answerJson.getJSONArray("details");
|
|
|
|
+ for (int j = 0; j < paperDetails.size(); j++) {
|
|
|
|
+ //遍历所有大题
|
|
|
|
+ JSONObject paperDetail = paperDetails.getJSONObject(j);
|
|
|
|
+ JSONObject answerDetail = findJsonObject(answerDetails, paperDetail.getIntValue("number"));
|
|
|
|
+ //按条件过滤需要的小题同时合并答案
|
|
|
|
+ JSONArray questionCollection = filterQuestions(paperDetail.getJSONArray("questions"),
|
|
|
|
+ Objects.nonNull(answerDetail) ? answerDetail.getJSONArray("questions") : null, true,
|
|
|
|
+ true);
|
|
|
|
+ //有小题的情况下,本大题才需要被包含
|
|
|
|
+ if (questionCollection.size() > 0) {
|
|
|
|
+ paperDetail.put("questions", questionCollection);
|
|
|
|
+ detailCollection.add(paperDetail);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ paperResult.put("details", detailCollection);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ File filePaperJson = new File(SystemConstant.TEMP_FILES_DIR + File.separator + CloudMarkFileUploadTypeEnum.PAPER.getCode() + File.separator + SystemConstant.getUuid() + ".json");
|
|
|
|
+ if (!filePaperJson.exists()) {
|
|
|
|
+ filePaperJson.getParentFile().mkdirs();
|
|
|
|
+ filePaperJson.createNewFile();
|
|
|
|
+ }
|
|
|
|
+ IOUtils.write(paperResult.toJSONString().getBytes(SystemConstant.CHARSET_NAME), new FileOutputStream(filePaperJson));
|
|
|
|
+ paperJsonList.add(filePaperJson);
|
|
|
|
+ FileUploadParams fileUploadParamsPaperJson = new FileUploadParams(orgId, cloudMarkExamId, courseCode, CloudMarkFileUploadTypeEnum.PAPER, filePaperJson);
|
|
|
|
+ fileUploadParamsPaperJson.setFormat(CloudMarkFileUploadTypeEnum.JSON.getCode());
|
|
|
|
+// cloudMarkUtil.callFileUploadApi(fileUploadParamsPaperJson);
|
|
|
|
+
|
|
|
|
+ jsonObject.put("currentTaskSize", currentTaskSize);
|
|
|
|
+ currentTaskSize++;
|
|
|
|
+ tbTaskHistory.setRemark(jsonObject.toJSONString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ jsonObject.put("currentTaskSize", currentTaskSize);
|
|
|
|
+ tbTaskHistory.setRemark(jsonObject.toJSONString());
|
|
|
|
+ tbTaskHistoryService.updateById(tbTaskHistory);
|
|
|
|
+ }
|
|
|
|
+ return examPaperIdSet;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 数据检查
|
|
|
|
+ *
|
|
|
|
+ * @param map
|
|
|
|
+ */
|
|
|
|
+ private void checkData(Map<String, Object> map) {
|
|
Long examId = (Long) map.get(SystemConstant.EXAM_ID);
|
|
Long examId = (Long) map.get(SystemConstant.EXAM_ID);
|
|
if (Objects.isNull(examId)) {
|
|
if (Objects.isNull(examId)) {
|
|
throw new RuntimeException("考试id为空");
|
|
throw new RuntimeException("考试id为空");
|
|
}
|
|
}
|
|
Long orgId = (Long) map.get(SystemConstant.ORG_ID);
|
|
Long orgId = (Long) map.get(SystemConstant.ORG_ID);
|
|
if (Objects.isNull(orgId)) {
|
|
if (Objects.isNull(orgId)) {
|
|
- throw new RuntimeException("机构id为空");
|
|
|
|
|
|
+ throw new BusinessException("机构id为空");
|
|
}
|
|
}
|
|
String examCode = (String) map.get(SystemConstant.EXAM_CODE);
|
|
String examCode = (String) map.get(SystemConstant.EXAM_CODE);
|
|
if (Objects.isNull(examCode)) {
|
|
if (Objects.isNull(examCode)) {
|
|
throw new RuntimeException("考试编码为空");
|
|
throw new RuntimeException("考试编码为空");
|
|
}
|
|
}
|
|
- Long createId = (Long) map.get(SystemConstant.CREATE_ID);
|
|
|
|
- createId = Objects.isNull(createId) ? -1L : createId;
|
|
|
|
|
|
+ TBOrg tbOrg = cacheService.addOrgCache(orgId);
|
|
|
|
+ Optional.ofNullable(tbOrg).orElseThrow(() -> new BusinessException(ExceptionResultEnum.ORG_NO));
|
|
|
|
|
|
//先推送考试
|
|
//先推送考试
|
|
ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
|
|
ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
|
|
Optional.ofNullable(examCacheBean).orElseThrow(() -> new BusinessException(ExceptionResultEnum.EXAM_NO));
|
|
Optional.ofNullable(examCacheBean).orElseThrow(() -> new BusinessException(ExceptionResultEnum.EXAM_NO));
|
|
|
|
|
|
- int line = 0;
|
|
|
|
- SaveExamParams saveExamParams = new SaveExamParams(orgId, examId, examCode);
|
|
|
|
- Long cloudMarkExamId = cloudMarkUtil.callExamSaveApi(saveExamParams);
|
|
|
|
- if (Objects.nonNull(cloudMarkExamId)) {
|
|
|
|
- line++;
|
|
|
|
- TEExam teExam = teExamService.cacheConvert(examCacheBean);
|
|
|
|
- teExam.setUpdateTime(System.currentTimeMillis());
|
|
|
|
- teExam.setThirdExamId(String.valueOf(cloudMarkExamId));
|
|
|
|
- teExamService.updateById(teExam);
|
|
|
|
|
|
+ if (Objects.isNull(examCacheBean.getEnable()) || examCacheBean.getEnable().intValue() == 0) {
|
|
|
|
+ throw new BusinessException("考试批次已禁用");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- //推送科目
|
|
|
|
- QueryWrapper<TEExamCourse> teExamCourseQueryWrapper = new QueryWrapper<>();
|
|
|
|
- teExamCourseQueryWrapper.lambda().eq(TEExamCourse::getExamId, examId);
|
|
|
|
- List<TEExamCourse> teExamCourseList = teExamCourseService.list(teExamCourseQueryWrapper);
|
|
|
|
- if (!CollectionUtils.isEmpty(teExamCourseList)) {
|
|
|
|
- for (TEExamCourse t : teExamCourseList) {
|
|
|
|
- line++;
|
|
|
|
- cloudMarkUtil.callSubjectSaveApi(new SaveSubjectParams(orgId, cloudMarkExamId, t.getCourseCode(), t.getCourseName()));
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 过滤答案
|
|
|
|
+ *
|
|
|
|
+ * @param array
|
|
|
|
+ * @param number
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private JSONObject findJsonObject(JSONArray array, int number) {
|
|
|
|
+ if (array != null) {
|
|
|
|
+ for (int i = 0; i < array.size(); i++) {
|
|
|
|
+ JSONObject item = array.getJSONObject(i);
|
|
|
|
+ if (item.getIntValue("number") == number) {
|
|
|
|
+ return item;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
|
|
- //推送考生
|
|
|
|
- QueryWrapper<TEExamStudent> teExamStudentQueryWrapper = new QueryWrapper<>();
|
|
|
|
- teExamStudentQueryWrapper.lambda().eq(TEExamStudent::getExamId, examId);
|
|
|
|
- List<TEExamStudent> teExamStudentList = teExamStudentService.list(teExamStudentQueryWrapper);
|
|
|
|
- if (!CollectionUtils.isEmpty(teExamStudentList)) {
|
|
|
|
- for (TEExamStudent t : teExamStudentList) {
|
|
|
|
- line++;
|
|
|
|
-// cloudMarkUtil.callStudentSaveApi(new SaveStudentParams(orgId, cloudMarkExamId, t.getCourseCode(), t.getCourseName()));
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 过滤题目
|
|
|
|
+ *
|
|
|
|
+ * @param questions
|
|
|
|
+ * @param answers
|
|
|
|
+ * @param acceptObjective
|
|
|
|
+ * @param acceptSubjective
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private JSONArray filterQuestions(JSONArray questions, JSONArray answers, boolean acceptObjective,
|
|
|
|
+ boolean acceptSubjective) {
|
|
|
|
+ JSONArray collection = new JSONArray();
|
|
|
|
+ for (int i = 0; i < questions.size(); i++) {
|
|
|
|
+ JSONObject question = questions.getJSONObject(i);
|
|
|
|
+ //根据题号查找答案
|
|
|
|
+ JSONObject answer = findJsonObject(answers, question.getIntValue("number"));
|
|
|
|
+ boolean accept = true;
|
|
|
|
+ //判断结构类型
|
|
|
|
+ switch (question.getIntValue("structType")) {
|
|
|
|
+ case 1:
|
|
|
|
+ //单选
|
|
|
|
+ case 2:
|
|
|
|
+ //多选
|
|
|
|
+ case 3:
|
|
|
|
+ //判断
|
|
|
|
+ accept = acceptObjective;
|
|
|
|
+ break;
|
|
|
|
+ case 4:
|
|
|
|
+ //填空
|
|
|
|
+ case 5:
|
|
|
|
+ //问答
|
|
|
|
+ accept = acceptSubjective;
|
|
|
|
+ break;
|
|
|
|
+ case 6:
|
|
|
|
+ //套题
|
|
|
|
+ //按条件过滤套题下所有子题
|
|
|
|
+ JSONArray subAnswers = answer != null ? answer.getJSONArray("subQuestions") : null;
|
|
|
|
+ JSONArray subCollection = filterQuestions(question.getJSONArray("subQuestions"), subAnswers,
|
|
|
|
+ acceptObjective, acceptSubjective);
|
|
|
|
+ //没有子题,则本题也被过滤掉
|
|
|
|
+ if (subCollection.size() > 0) {
|
|
|
|
+ question.put("subQuestions", subCollection);
|
|
|
|
+ } else {
|
|
|
|
+ accept = false;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ accept = false;
|
|
|
|
+ }
|
|
|
|
+ if (accept) {
|
|
|
|
+ if (answer != null) {
|
|
|
|
+ question.put("answer", answer.get("answer"));
|
|
}
|
|
}
|
|
|
|
+ collection.add(question);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- map.put("line", line);
|
|
|
|
- return map;
|
|
|
|
|
|
+ return collection;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|