|
@@ -1,24 +1,35 @@
|
|
package cn.com.qmth.examcloud.core.oe.admin.api.provider;
|
|
package cn.com.qmth.examcloud.core.oe.admin.api.provider;
|
|
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.ExamRecordCloudService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.ExamRecordCloudService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.bean.ExamRecordForSelectScore;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.bean.ExamRecordForSelectScore;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.bean.ToBeMarkExamRecordBean;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.bean.ToBeMarkSubjectiveAnswerBean;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.CheckExamIsStartedReq;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.CheckExamIsStartedReq;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.GetExamPhotoVerifyDataReq;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.GetExamPhotoVerifyDataReq;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.request.GetToBeMarkExamRecordReq;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.QueryExamRecordForSelectScoreReq;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.QueryExamRecordForSelectScoreReq;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.CheckExamIsStartedResp;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.CheckExamIsStartedResp;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.GetExamPhotoVerifyDataResp;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.GetExamPhotoVerifyDataResp;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.api.response.GetToBeMarkExamRecordResp;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.QueryExamRecordForSelectScoreResp;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.QueryExamRecordForSelectScoreResp;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.admin.service.ExamRecordForMarkingService;
|
|
import cn.com.qmth.examcloud.core.oe.common.base.utils.Check;
|
|
import cn.com.qmth.examcloud.core.oe.common.base.utils.Check;
|
|
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamCaptureEntity;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.common.entity.ExamScoreEntity;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamCaptureRepo;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamRecordDataRepo;
|
|
|
|
-import cn.com.qmth.examcloud.core.oe.common.repository.ExamScoreRepo;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.common.entity.*;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.common.repository.*;
|
|
|
|
+import cn.com.qmth.examcloud.question.commons.core.question.AnswerType;
|
|
|
|
+import cn.com.qmth.examcloud.question.commons.core.question.QuestionType;
|
|
|
|
+import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
|
+import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
|
+import com.mysql.cj.util.StringUtils;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
+import org.jsoup.Jsoup;
|
|
|
|
+import org.jsoup.nodes.Document;
|
|
|
|
+import org.jsoup.nodes.Element;
|
|
|
|
+import org.jsoup.select.Elements;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.domain.Example;
|
|
import org.springframework.data.domain.Example;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -27,125 +38,295 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
- * @author chenken
|
|
|
|
- * @date 2018年9月19日 下午2:44:12
|
|
|
|
- * @company QMTH
|
|
|
|
|
|
+ * @author chenken
|
|
|
|
+ * @date 2018年9月19日 下午2:44:12
|
|
|
|
+ * @company QMTH
|
|
* @description ExamRecordCloudServiceProvider.java
|
|
* @description ExamRecordCloudServiceProvider.java
|
|
*/
|
|
*/
|
|
@Api(tags = "考试记录相关接口")
|
|
@Api(tags = "考试记录相关接口")
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("${$rmp.cloud.oe}/examRecord")
|
|
@RequestMapping("${$rmp.cloud.oe}/examRecord")
|
|
-public class ExamRecordCloudServiceProvider extends ControllerSupport implements ExamRecordCloudService{
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- *
|
|
|
|
- */
|
|
|
|
- private static final long serialVersionUID = 7678785677176906341L;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private ExamScoreRepo examScoreRepo;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private ExamRecordDataRepo examRecordDataRepo;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private ExamCaptureRepo examCaptureRepo;
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- @ApiOperation(value = "查询是否已经开考")
|
|
|
|
- @PostMapping("/checkExamIsStarted")
|
|
|
|
- public CheckExamIsStartedResp checkExamIsStarted(@RequestBody CheckExamIsStartedReq examRecordReq) {
|
|
|
|
- Check.isNull(examRecordReq.getExamId(), "examId不能为空");
|
|
|
|
- ExamRecordDataEntity examRecordDataEntity = new ExamRecordDataEntity();
|
|
|
|
- examRecordDataEntity.setExamId(examRecordReq.getExamId());
|
|
|
|
- examRecordDataEntity.setCourseId(examRecordReq.getCourseId());
|
|
|
|
- examRecordDataEntity.setStudentId(examRecordReq.getStudentId());
|
|
|
|
- long examRecordNum = examRecordDataRepo.count(Example.of(examRecordDataEntity));
|
|
|
|
- CheckExamIsStartedResp checkExamIsStartedResp = new CheckExamIsStartedResp();
|
|
|
|
- checkExamIsStartedResp.setIsStarted(examRecordNum>0);
|
|
|
|
- return checkExamIsStartedResp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- @ApiOperation(value = "查询考试记录-供exchange调用")
|
|
|
|
- @PostMapping("/queryExamRecordForSelectScoreByScoreId")
|
|
|
|
- public QueryExamRecordForSelectScoreResp queryExamRecordForSelectScoreByScoreId(@RequestBody QueryExamRecordForSelectScoreReq req) {
|
|
|
|
- QueryExamRecordForSelectScoreResp resp = new QueryExamRecordForSelectScoreResp();
|
|
|
|
- if(req.getExamScoreId() != null){
|
|
|
|
- ExamScoreEntity examScore =GlobalHelper.getEntity(examScoreRepo,req.getExamScoreId(),ExamScoreEntity.class);
|
|
|
|
- ExamRecordDataEntity examRecordData =GlobalHelper.getEntity(examRecordDataRepo,examScore.getExamRecordDataId(),ExamRecordDataEntity.class);
|
|
|
|
- List<ExamRecordForSelectScore> examRecordForSelectScoreList = new ArrayList<ExamRecordForSelectScore>();
|
|
|
|
- examRecordForSelectScoreList.add(buildExamRecordForSelectScore(examRecordData));
|
|
|
|
- resp.setExamRecordForSelectScoreList(examRecordForSelectScoreList);
|
|
|
|
- }
|
|
|
|
- return resp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- @ApiOperation(value = "查询考试记录-供exchange调用")
|
|
|
|
- @PostMapping("/queryExamRecordForSelectScoreByExamStudentId")
|
|
|
|
- public QueryExamRecordForSelectScoreResp queryExamRecordForSelectScoreByExamStudentId(@RequestBody QueryExamRecordForSelectScoreReq req) {
|
|
|
|
- QueryExamRecordForSelectScoreResp resp = new QueryExamRecordForSelectScoreResp();
|
|
|
|
- if(req.getExamStudentId() != null){
|
|
|
|
- List<ExamRecordDataEntity> examRecordList = examRecordDataRepo.findByExamStudentId(req.getExamStudentId());
|
|
|
|
- List<ExamRecordForSelectScore> examRecordForSelectScoreList = new ArrayList<ExamRecordForSelectScore>();
|
|
|
|
- for(ExamRecordDataEntity examRecordData:examRecordList){
|
|
|
|
- examRecordForSelectScoreList.add(buildExamRecordForSelectScore(examRecordData));
|
|
|
|
- }
|
|
|
|
- resp.setExamRecordForSelectScoreList(examRecordForSelectScoreList);
|
|
|
|
- }
|
|
|
|
- return resp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public ExamRecordForSelectScore buildExamRecordForSelectScore(ExamRecordDataEntity examRecordData){
|
|
|
|
- ExamRecordForSelectScore examRecordForSelectScore = new ExamRecordForSelectScore();
|
|
|
|
- examRecordForSelectScore.setExamStudentId(examRecordData.getExamStudentId());
|
|
|
|
- examRecordForSelectScore.setRootOrgId(examRecordData.getRootOrgId());
|
|
|
|
- examRecordForSelectScore.setExamRecordDataId(examRecordData.getId());
|
|
|
|
- examRecordForSelectScore.setStartTime(examRecordData.getStartTime());
|
|
|
|
- examRecordForSelectScore.setEndTime(examRecordData.getEndTime());
|
|
|
|
- examRecordForSelectScore.setCleanTime(examRecordData.getCleanTime());
|
|
|
|
- examRecordForSelectScore.setIsWarn(examRecordData.getIsWarn());
|
|
|
|
- examRecordForSelectScore.setIsAudit(examRecordData.getIsAudit());
|
|
|
|
- examRecordForSelectScore.setIsIllegality(examRecordData.getIsIllegality());
|
|
|
|
- examRecordForSelectScore.setStatus(examRecordData.getExamRecordStatus().name());
|
|
|
|
-
|
|
|
|
- return examRecordForSelectScore;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- @ApiOperation(value = "查询照片数据-供exchange调用")
|
|
|
|
- @PostMapping("/getExamPhotoVerifyData")
|
|
|
|
- public GetExamPhotoVerifyDataResp getExamPhotoVerifyData(@RequestBody GetExamPhotoVerifyDataReq req) {
|
|
|
|
- Long scoreId = req.getScoreId();
|
|
|
|
- ExamScoreEntity examScoreEntity =GlobalHelper.getEntity(examScoreRepo,scoreId,ExamScoreEntity.class);
|
|
|
|
- if(examScoreEntity == null){
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- Long examRecordDataId = examScoreEntity.getExamRecordDataId();
|
|
|
|
- ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo,examRecordDataId,ExamRecordDataEntity.class);
|
|
|
|
- if(examRecordData == null){
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- List<ExamCaptureEntity> examCaptureList = examCaptureRepo.findByExamRecordDataId(examRecordDataId);
|
|
|
|
-
|
|
|
|
- GetExamPhotoVerifyDataResp resp = new GetExamPhotoVerifyDataResp();
|
|
|
|
- resp.setScoreId(scoreId);
|
|
|
|
- resp.setSuccessRate(examRecordData.getFaceSuccessPercent());
|
|
|
|
- int strangerCount = 0;
|
|
|
|
- List<String> photoUrls = new ArrayList<String>();
|
|
|
|
- for(ExamCaptureEntity examCaptureEntity:examCaptureList){
|
|
|
|
- if(examCaptureEntity.getIsStranger()){
|
|
|
|
- strangerCount++;
|
|
|
|
- }
|
|
|
|
- photoUrls.add(examCaptureEntity.getFileUrl());
|
|
|
|
- }
|
|
|
|
- resp.setStrangerCount(strangerCount);
|
|
|
|
- resp.setPhotoUrls(photoUrls);
|
|
|
|
- return resp;
|
|
|
|
- }
|
|
|
|
|
|
+public class ExamRecordCloudServiceProvider extends ControllerSupport implements ExamRecordCloudService {
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ private static final long serialVersionUID = 7678785677176906341L;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamScoreRepo examScoreRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamRecordDataRepo examRecordDataRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamCaptureRepo examCaptureRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamStudentRepo examStudentRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamRecordForMarkingService examRecordForMarkingService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamRecordQuestionsRepo examRecordQuestionsRepo;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @ApiOperation(value = "查询是否已经开考")
|
|
|
|
+ @PostMapping("/checkExamIsStarted")
|
|
|
|
+ public CheckExamIsStartedResp checkExamIsStarted(@RequestBody CheckExamIsStartedReq examRecordReq) {
|
|
|
|
+ Check.isNull(examRecordReq.getExamId(), "examId不能为空");
|
|
|
|
+ ExamRecordDataEntity examRecordDataEntity = new ExamRecordDataEntity();
|
|
|
|
+ examRecordDataEntity.setExamId(examRecordReq.getExamId());
|
|
|
|
+ examRecordDataEntity.setCourseId(examRecordReq.getCourseId());
|
|
|
|
+ examRecordDataEntity.setStudentId(examRecordReq.getStudentId());
|
|
|
|
+ long examRecordNum = examRecordDataRepo.count(Example.of(examRecordDataEntity));
|
|
|
|
+ CheckExamIsStartedResp checkExamIsStartedResp = new CheckExamIsStartedResp();
|
|
|
|
+ checkExamIsStartedResp.setIsStarted(examRecordNum > 0);
|
|
|
|
+ return checkExamIsStartedResp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @ApiOperation(value = "查询考试记录-供exchange调用")
|
|
|
|
+ @PostMapping("/queryExamRecordForSelectScoreByScoreId")
|
|
|
|
+ public QueryExamRecordForSelectScoreResp queryExamRecordForSelectScoreByScoreId(@RequestBody QueryExamRecordForSelectScoreReq req) {
|
|
|
|
+ QueryExamRecordForSelectScoreResp resp = new QueryExamRecordForSelectScoreResp();
|
|
|
|
+ if (req.getExamScoreId() != null) {
|
|
|
|
+ ExamScoreEntity examScore = GlobalHelper.getEntity(examScoreRepo, req.getExamScoreId(), ExamScoreEntity.class);
|
|
|
|
+ ExamRecordDataEntity examRecordData =
|
|
|
|
+ GlobalHelper.getEntity(examRecordDataRepo, examScore.getExamRecordDataId(), ExamRecordDataEntity.class);
|
|
|
|
+ List<ExamRecordForSelectScore> examRecordForSelectScoreList = new ArrayList<ExamRecordForSelectScore>();
|
|
|
|
+ examRecordForSelectScoreList.add(buildExamRecordForSelectScore(examRecordData));
|
|
|
|
+ resp.setExamRecordForSelectScoreList(examRecordForSelectScoreList);
|
|
|
|
+ }
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @ApiOperation(value = "查询考试记录-供exchange调用")
|
|
|
|
+ @PostMapping("/queryExamRecordForSelectScoreByExamStudentId")
|
|
|
|
+ public QueryExamRecordForSelectScoreResp queryExamRecordForSelectScoreByExamStudentId(@RequestBody QueryExamRecordForSelectScoreReq req) {
|
|
|
|
+ QueryExamRecordForSelectScoreResp resp = new QueryExamRecordForSelectScoreResp();
|
|
|
|
+ if (req.getExamStudentId() != null) {
|
|
|
|
+ List<ExamRecordDataEntity> examRecordList = examRecordDataRepo.findByExamStudentId(req.getExamStudentId());
|
|
|
|
+ List<ExamRecordForSelectScore> examRecordForSelectScoreList = new ArrayList<ExamRecordForSelectScore>();
|
|
|
|
+ for (ExamRecordDataEntity examRecordData : examRecordList) {
|
|
|
|
+ examRecordForSelectScoreList.add(buildExamRecordForSelectScore(examRecordData));
|
|
|
|
+ }
|
|
|
|
+ resp.setExamRecordForSelectScoreList(examRecordForSelectScoreList);
|
|
|
|
+ }
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public ExamRecordForSelectScore buildExamRecordForSelectScore(ExamRecordDataEntity examRecordData) {
|
|
|
|
+ ExamRecordForSelectScore examRecordForSelectScore = new ExamRecordForSelectScore();
|
|
|
|
+ examRecordForSelectScore.setExamStudentId(examRecordData.getExamStudentId());
|
|
|
|
+ examRecordForSelectScore.setRootOrgId(examRecordData.getRootOrgId());
|
|
|
|
+ examRecordForSelectScore.setExamRecordDataId(examRecordData.getId());
|
|
|
|
+ examRecordForSelectScore.setStartTime(examRecordData.getStartTime());
|
|
|
|
+ examRecordForSelectScore.setEndTime(examRecordData.getEndTime());
|
|
|
|
+ examRecordForSelectScore.setCleanTime(examRecordData.getCleanTime());
|
|
|
|
+ examRecordForSelectScore.setIsWarn(examRecordData.getIsWarn());
|
|
|
|
+ examRecordForSelectScore.setIsAudit(examRecordData.getIsAudit());
|
|
|
|
+ examRecordForSelectScore.setIsIllegality(examRecordData.getIsIllegality());
|
|
|
|
+ examRecordForSelectScore.setStatus(examRecordData.getExamRecordStatus().name());
|
|
|
|
+
|
|
|
|
+ return examRecordForSelectScore;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @ApiOperation(value = "查询照片数据-供exchange调用")
|
|
|
|
+ @PostMapping("/getExamPhotoVerifyData")
|
|
|
|
+ public GetExamPhotoVerifyDataResp getExamPhotoVerifyData(@RequestBody GetExamPhotoVerifyDataReq req) {
|
|
|
|
+ Long scoreId = req.getScoreId();
|
|
|
|
+ ExamScoreEntity examScoreEntity = GlobalHelper.getEntity(examScoreRepo, scoreId, ExamScoreEntity.class);
|
|
|
|
+ if (examScoreEntity == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ Long examRecordDataId = examScoreEntity.getExamRecordDataId();
|
|
|
|
+ ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
|
|
|
|
+ if (examRecordData == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ List<ExamCaptureEntity> examCaptureList = examCaptureRepo.findByExamRecordDataId(examRecordDataId);
|
|
|
|
+
|
|
|
|
+ GetExamPhotoVerifyDataResp resp = new GetExamPhotoVerifyDataResp();
|
|
|
|
+ resp.setScoreId(scoreId);
|
|
|
|
+ resp.setSuccessRate(examRecordData.getFaceSuccessPercent());
|
|
|
|
+ int strangerCount = 0;
|
|
|
|
+ List<String> photoUrls = new ArrayList<String>();
|
|
|
|
+ for (ExamCaptureEntity examCaptureEntity : examCaptureList) {
|
|
|
|
+ if (examCaptureEntity.getIsStranger()) {
|
|
|
|
+ strangerCount++;
|
|
|
|
+ }
|
|
|
|
+ photoUrls.add(examCaptureEntity.getFileUrl());
|
|
|
|
+ }
|
|
|
|
+ resp.setStrangerCount(strangerCount);
|
|
|
|
+ resp.setPhotoUrls(photoUrls);
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取待阅卷的考试记录
|
|
|
|
+ *
|
|
|
|
+ * @param req
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ @ApiOperation(value = "获取待阅卷的考试记录-供bridge调用")
|
|
|
|
+ @PostMapping("/getExamPhotoVerifyData")
|
|
|
|
+ public GetToBeMarkExamRecordResp getToBeMarkExamRecord(@RequestBody GetToBeMarkExamRecordReq req) {
|
|
|
|
+ if (null == req.getExamStudentIdList() || req.getExamStudentIdList().isEmpty()) {
|
|
|
|
+ throw new StatusException("100101", "考生id不允许为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ GetToBeMarkExamRecordResp resp = new GetToBeMarkExamRecordResp();
|
|
|
|
+ //待阅卷的考试记录集合
|
|
|
|
+ List<ToBeMarkExamRecordBean> toBeMarkExamRecordBeanList = new ArrayList<>();
|
|
|
|
+ for (Long examStudentId : req.getExamStudentIdList()) {
|
|
|
|
+ ExamStudentEntity examStudent =
|
|
|
|
+ GlobalHelper.getEntity(examStudentRepo, examStudentId, ExamStudentEntity.class);
|
|
|
|
+ if (null == examStudent.getStudentId()) {
|
|
|
|
+ throw new StatusException("100101", "考生id:" + examStudentId + "不正确");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Long examId = examStudent.getExamId();
|
|
|
|
+ //待阅的考试列表
|
|
|
|
+ List<ExamRecordForMarkingEntity> examRecordForMarkingList =
|
|
|
|
+ examRecordForMarkingService.queryValidExamRecordList(examId, examStudent.getCourseId());
|
|
|
|
+
|
|
|
|
+ //未参加考试或未违纪的考试数据略过
|
|
|
|
+ if (null == examRecordForMarkingList || examRecordForMarkingList.isEmpty()) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (ExamRecordForMarkingEntity markingRecord : examRecordForMarkingList) {
|
|
|
|
+ Long examRecordDataId = markingRecord.getExamRecordDataId();
|
|
|
|
+ ExamRecordDataEntity examRecordData =
|
|
|
|
+ GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
|
|
|
|
+
|
|
|
|
+ ToBeMarkExamRecordBean toBeMarkExamRecordBean = new ToBeMarkExamRecordBean();
|
|
|
|
+ toBeMarkExamRecordBean.setExamId(markingRecord.getExamId());
|
|
|
|
+ toBeMarkExamRecordBean.setStudentName(examRecordData.getStudentName());
|
|
|
|
+ toBeMarkExamRecordBean.setStudentCode(examRecordData.getStudentCode());
|
|
|
|
+
|
|
|
|
+ CourseCacheBean course = CacheHelper.getCourse(examRecordData.getCourseId());
|
|
|
|
+ toBeMarkExamRecordBean.setCourseCode(course.getCode());
|
|
|
|
+ toBeMarkExamRecordBean.setCourseName(course.getName());
|
|
|
|
+
|
|
|
|
+ toBeMarkExamRecordBean.setPaperType(markingRecord.getPaperType());
|
|
|
|
+ toBeMarkExamRecordBean.setExamStudentId(markingRecord.getExamStudentId());
|
|
|
|
+ toBeMarkExamRecordBean.setExamRecordDataId(markingRecord.getExamRecordDataId());
|
|
|
|
+ //待评阅的主观题集合
|
|
|
|
+ toBeMarkExamRecordBean.setSubjectiveAnswerList(
|
|
|
|
+ getToBeMarkSubjectiveAnswerList(examRecordData.getExamRecordQuestionsId(), examRecordDataId, examId));
|
|
|
|
+
|
|
|
|
+ toBeMarkExamRecordBeanList.add(toBeMarkExamRecordBean);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ resp.setToBeMarkExamRecordBeanList(toBeMarkExamRecordBeanList);
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取待评阅的主观题集合
|
|
|
|
+ *
|
|
|
|
+ * @param recordQuestionsId
|
|
|
|
+ * @param examRecordDataId
|
|
|
|
+ * @param examId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private List<ToBeMarkSubjectiveAnswerBean> getToBeMarkSubjectiveAnswerList(String recordQuestionsId,
|
|
|
|
+ Long examRecordDataId, Long examId) {
|
|
|
|
+ ExamRecordQuestionsEntity questionsEntity;
|
|
|
|
+ if (null != recordQuestionsId) {
|
|
|
|
+ questionsEntity = GlobalHelper.getEntity(examRecordQuestionsRepo, recordQuestionsId, ExamRecordQuestionsEntity.class);
|
|
|
|
+ } else {
|
|
|
|
+ questionsEntity = examRecordQuestionsRepo.findByExamRecordDataId(examRecordDataId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<ExamQuestionEntity> examQuestionList = questionsEntity.getExamQuestionEntities();
|
|
|
|
+ //获取所有的主观题
|
|
|
|
+ List<ExamQuestionEntity> subjectiveQuestionList = examQuestionList.stream().filter(p -> p.getQuestionType() == QuestionType.ESSAY ||
|
|
|
|
+ p.getQuestionType() == QuestionType.FILL_UP).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ List<ToBeMarkSubjectiveAnswerBean> subjectiveAnswerBeanList = new ArrayList<>();
|
|
|
|
+ for (ExamQuestionEntity sq : subjectiveQuestionList) {
|
|
|
|
+ ToBeMarkSubjectiveAnswerBean subjectiveAnswerBean = new ToBeMarkSubjectiveAnswerBean();
|
|
|
|
+ subjectiveAnswerBean.setMainNumber(sq.getMainNumber());
|
|
|
|
+ subjectiveAnswerBean.setOrder(sq.getOrder());
|
|
|
|
+ subjectiveAnswerBean.setQuestionId(sq.getQuestionId());
|
|
|
|
+ subjectiveAnswerBean.setStudentAnswer(transformedStudentAnswer(sq.getStudentAnswer()));//格式化过的答案
|
|
|
|
+ subjectiveAnswerBean.setAnswerType(sq.getAnswerType());
|
|
|
|
+ subjectiveAnswerBean.setRealAnswerType(transformedAnswerType(sq.getAnswerType(), sq.getQuestionType(), examId));//实际的作答类型
|
|
|
|
+
|
|
|
|
+ subjectiveAnswerBeanList.add(subjectiveAnswerBean);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return subjectiveAnswerBeanList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据原始作答类型和学生实际作答推断出真实的作答类型
|
|
|
|
+ *
|
|
|
|
+ * @param answerType 原始作答类型
|
|
|
|
+ * @param questionType 题型
|
|
|
|
+ * @param examId 考试id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private String transformedAnswerType(AnswerType answerType, QuestionType questionType, Long examId) {
|
|
|
|
+ //需要图片作答的考试id(以英文逗号分隔)
|
|
|
|
+ Object oExamId = CacheHelper.getSysProperty("oe.imgAnswer.examId").getValue();
|
|
|
|
+ if (null != oExamId) {
|
|
|
|
+ String strExamId = String.valueOf(oExamId);
|
|
|
|
+ List<String> examIdList = Arrays.asList(strExamId.split(","));
|
|
|
|
+ //如果题型为问答题,且作答类型不为音频作答,且考试为需要图片作答,则此题为图片作答题
|
|
|
|
+ if (questionType == QuestionType.ESSAY &&
|
|
|
|
+ (null == answerType || (null != answerType && answerType != AnswerType.SINGLE_AUDIO))) {
|
|
|
|
+ if (examIdList.stream().anyMatch(eid -> eid.equals(String.valueOf(examId)))) {
|
|
|
|
+ return "image";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null != answerType && answerType == AnswerType.SINGLE_AUDIO) {
|
|
|
|
+ return "audio";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return "text";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 转化过的作答
|
|
|
|
+ *
|
|
|
|
+ * @param studentAnswer
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private String transformedStudentAnswer(String studentAnswer) {
|
|
|
|
+ if (StringUtils.isNullOrEmpty(studentAnswer)) {
|
|
|
|
+ return studentAnswer;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //图片题特殊处理(因为图片作答题中有html标签)
|
|
|
|
+ Document doc = Jsoup.parse(studentAnswer);
|
|
|
|
+ Elements imgElements = doc.select("img[src]");
|
|
|
|
+ String imgStudentAnswer = "";
|
|
|
|
+ for (Element el : imgElements) {
|
|
|
|
+ String src = el.attr("src");
|
|
|
|
+ if (!StringUtils.isNullOrEmpty(src)) {
|
|
|
|
+ imgStudentAnswer += src + "|";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!StringUtils.isNullOrEmpty(imgStudentAnswer)) {
|
|
|
|
+ return imgStudentAnswer.substring(0, imgStudentAnswer.length() - 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return studentAnswer;
|
|
|
|
+ }
|
|
}
|
|
}
|