|
@@ -1,7 +1,6 @@
|
|
package cn.com.qmth.examcloud.exchange.outer.api.provider;
|
|
package cn.com.qmth.examcloud.exchange.outer.api.provider;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
-import cn.com.qmth.examcloud.commons.util.JsonUtil;
|
|
|
|
import cn.com.qmth.examcloud.commons.util.RegExpUtil;
|
|
import cn.com.qmth.examcloud.commons.util.RegExpUtil;
|
|
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.PagedToBeMarkExamRecordBean;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.bean.PagedToBeMarkExamRecordBean;
|
|
@@ -10,18 +9,26 @@ import cn.com.qmth.examcloud.core.oe.admin.api.request.GetPagedToBeMarkExamRecor
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.GetPagedToBeMarkExamRecordResp;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.GetPagedToBeMarkExamRecordResp;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.ExamQuestionOuterService;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.ExamQuestionOuterService;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.bean.*;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.bean.*;
|
|
|
|
+import cn.com.qmth.examcloud.exchange.outer.api.request.OuterGetPaperStructReq;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.request.OuterGetQuestionAnswerReq;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.request.OuterGetQuestionAnswerReq;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.request.OuterGetSubjectivePaperStructReq;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.request.OuterGetSubjectivePaperStructReq;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.request.OuterGetSubjectiveQuestionReq;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.request.OuterGetSubjectiveQuestionReq;
|
|
|
|
+import cn.com.qmth.examcloud.exchange.outer.api.response.OuterGetPaperStructResp;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.response.OuterGetQuestionAnswerResp;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.response.OuterGetQuestionAnswerResp;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.response.OuterGetSubjectivePaperStructResp;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.response.OuterGetSubjectivePaperStructResp;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.response.OuterGetSubjectiveQuestionResp;
|
|
import cn.com.qmth.examcloud.exchange.outer.api.response.OuterGetSubjectiveQuestionResp;
|
|
import cn.com.qmth.examcloud.exchange.outer.service.OutletPaperStructService;
|
|
import cn.com.qmth.examcloud.exchange.outer.service.OutletPaperStructService;
|
|
import cn.com.qmth.examcloud.exchange.outer.service.bean.OuterCourseBean;
|
|
import cn.com.qmth.examcloud.exchange.outer.service.bean.OuterCourseBean;
|
|
import cn.com.qmth.examcloud.exchange.outer.service.bean.OuterQuestionBean;
|
|
import cn.com.qmth.examcloud.exchange.outer.service.bean.OuterQuestionBean;
|
|
|
|
+import cn.com.qmth.examcloud.question.commons.core.paper.DefaultPaper;
|
|
|
|
+import cn.com.qmth.examcloud.question.commons.core.paper.DefaultQuestionGroup;
|
|
|
|
+import cn.com.qmth.examcloud.question.commons.core.paper.DefaultQuestionStructureWrapper;
|
|
|
|
+import cn.com.qmth.examcloud.question.commons.core.paper.DefaultQuestionUnitWrapper;
|
|
import cn.com.qmth.examcloud.question.commons.core.question.AnswerType;
|
|
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.question.commons.core.question.QuestionType;
|
|
import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
|
+import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
|
|
|
|
+import cn.com.qmth.examcloud.support.cache.bean.ExtractConfigPaperCacheBean;
|
|
import cn.com.qmth.examcloud.support.cache.bean.QuestionAnswerCacheBean;
|
|
import cn.com.qmth.examcloud.support.cache.bean.QuestionAnswerCacheBean;
|
|
import cn.com.qmth.examcloud.support.enums.BlockType;
|
|
import cn.com.qmth.examcloud.support.enums.BlockType;
|
|
import cn.com.qmth.examcloud.support.handler.richText.RichTextHandler;
|
|
import cn.com.qmth.examcloud.support.handler.richText.RichTextHandler;
|
|
@@ -204,6 +211,94 @@ public class ExamQuestionOuterServiceProvider extends ControllerSupport implemen
|
|
return resp;
|
|
return resp;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @ApiOperation(value = "获取试卷结构(题库中的原始试卷结构)", httpMethod = "POST")
|
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "成功", response = OuterGetQuestionAnswerResp.class),
|
|
|
|
+ @ApiResponse(code = 500, message = "系统异常(异常信息见响应体)", response = StatusResponse.class)})
|
|
|
|
+ @PostMapping("/getPaperStruct")
|
|
|
|
+ @Override
|
|
|
|
+ public OuterGetPaperStructResp getPaperStruct(@RequestBody OuterGetPaperStructReq req) {
|
|
|
|
+ if (null == req.getExamId()) {
|
|
|
|
+ throw new StatusException("103001", "考试记录id不允许为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (null == req.getCourseId()) {
|
|
|
|
+ throw new StatusException("103002", "课程id不允许为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNullOrEmpty(req.getPaperType())) {
|
|
|
|
+ throw new StatusException("103003", "试卷类型不允许为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNullOrEmpty(req.getBasePaperId())) {
|
|
|
|
+ throw new StatusException("103004", "原始试卷id不允许为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ CourseCacheBean course = CacheHelper.getCourse(req.getCourseId());
|
|
|
|
+ if (null == course) {
|
|
|
|
+ throw new StatusException("103005", "课程id不正确");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ExtractConfigPaperCacheBean extractConfigPaper = CacheHelper.getExtractConfigPaper(req.getExamId(),
|
|
|
|
+ course.getCode(), req.getPaperType(), req.getBasePaperId());
|
|
|
|
+
|
|
|
|
+ OuterGetPaperStructResp resp = new OuterGetPaperStructResp();
|
|
|
|
+ if (null != extractConfigPaper.getDefaultPaper()) {
|
|
|
|
+ resp.setDefaultPaper(transferPaperFrom(extractConfigPaper.getDefaultPaper()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return resp;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private DefaultPaperBean transferPaperFrom(DefaultPaper defaultPaper) {
|
|
|
|
+ DefaultPaperBean defaultPaperBean = new DefaultPaperBean();
|
|
|
|
+ defaultPaperBean.setFullyObjective(defaultPaper.getFullyObjective());
|
|
|
|
+ defaultPaperBean.setName(defaultPaper.getName());
|
|
|
|
+
|
|
|
|
+ List<DefaultQuestionGroup> qgList = defaultPaper.getQuestionGroupList();
|
|
|
|
+ List<DefaultQuestionGroupBean> qgBeanList = new ArrayList<>();
|
|
|
|
+ for (DefaultQuestionGroup dqg : qgList) {
|
|
|
|
+ DefaultQuestionGroupBean dqgBean = new DefaultQuestionGroupBean();
|
|
|
|
+ dqgBean.setGroupName(dqg.getGroupName());
|
|
|
|
+ dqgBean.setGroupScore(dqg.getGroupScore());
|
|
|
|
+
|
|
|
|
+ List<DefaultQuestionStructureWrapper> qwList = dqg.getQuestionWrapperList();
|
|
|
|
+ List<DefaultQuestionStructureWrapperBean> qwBeanList = new ArrayList<>();
|
|
|
|
+ for (DefaultQuestionStructureWrapper qw : qwList) {
|
|
|
|
+ DefaultQuestionStructureWrapperBean qwBean = new DefaultQuestionStructureWrapperBean();
|
|
|
|
+ qwBean.setQuestionId(qw.getQuestionId());
|
|
|
|
+ qwBean.setVersion(qw.getVersion());
|
|
|
|
+ qwBean.setQuestionScore(qw.getQuestionScore());
|
|
|
|
+ qwBean.setLimitedPlayTimes(qw.getLimitedPlayTimes());
|
|
|
|
+ qwBean.setPlayedTimes(qw.getPlayedTimes());
|
|
|
|
+ qwBean.setTimeLimit(qw.getTimeLimit());
|
|
|
|
+
|
|
|
|
+ List<DefaultQuestionUnitWrapper> quwList = qw.getQuestionUnitWrapperList();
|
|
|
|
+ List<DefaultQuestionUnitWrapperBean> quwBeanList = new ArrayList<>();
|
|
|
|
+ for (DefaultQuestionUnitWrapper quw : quwList) {
|
|
|
|
+ DefaultQuestionUnitWrapperBean quwBean = new DefaultQuestionUnitWrapperBean();
|
|
|
|
+ quwBean.setOptionPermutation(quw.getOptionPermutation());
|
|
|
|
+ quwBean.setQuestionScore(quw.getQuestionScore());
|
|
|
|
+ quwBean.setQuestionType(quw.getQuestionType() == null ? null : quw.getQuestionType().name());
|
|
|
|
+ quwBean.setAnswerType(quw.getAnswerType() == null ? null : quw.getAnswerType().name());
|
|
|
|
+
|
|
|
|
+ quwBeanList.add(quwBean);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ qwBean.setQuestionUnitWrapperList(quwBeanList);
|
|
|
|
+
|
|
|
|
+ qwBeanList.add(qwBean);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ dqgBean.setQuestionWrapperList(qwBeanList);
|
|
|
|
+
|
|
|
|
+ qgBeanList.add(dqgBean);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ defaultPaperBean.setQuestionGroupList(qgBeanList);
|
|
|
|
+
|
|
|
|
+ return defaultPaperBean;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 构造满足条件的考试记录集合
|
|
* 构造满足条件的考试记录集合
|
|
@@ -271,35 +366,35 @@ public class ExamQuestionOuterServiceProvider extends ControllerSupport implemen
|
|
|
|
|
|
int index;
|
|
int index;
|
|
if (StringUtils.isNullOrEmpty(firstMatch)) {
|
|
if (StringUtils.isNullOrEmpty(firstMatch)) {
|
|
- index=-1;
|
|
|
|
- }else {
|
|
|
|
|
|
+ index = -1;
|
|
|
|
+ } else {
|
|
index = stuAnswer.indexOf(firstMatch);
|
|
index = stuAnswer.indexOf(firstMatch);
|
|
}
|
|
}
|
|
|
|
|
|
//只有文字作答,处理文字
|
|
//只有文字作答,处理文字
|
|
if (index == -1) {
|
|
if (index == -1) {
|
|
richTextHandler = RichTextHandlerFactory.getHandler(BlockType.text.name());
|
|
richTextHandler = RichTextHandlerFactory.getHandler(BlockType.text.name());
|
|
- formattedStudentAnswer=richTextHandler.handle(stuAnswer);
|
|
|
|
|
|
+ formattedStudentAnswer = richTextHandler.handle(stuAnswer);
|
|
} else {
|
|
} else {
|
|
//只有图片作答,处理图片
|
|
//只有图片作答,处理图片
|
|
if (index == 0) {
|
|
if (index == 0) {
|
|
richTextHandler = RichTextHandlerFactory.getHandler(BlockType.image.name());
|
|
richTextHandler = RichTextHandlerFactory.getHandler(BlockType.image.name());
|
|
- formattedStudentAnswer=richTextHandler.handle(stuAnswer);
|
|
|
|
|
|
+ formattedStudentAnswer = richTextHandler.handle(stuAnswer);
|
|
}
|
|
}
|
|
//既有图片又有文字
|
|
//既有图片又有文字
|
|
else {
|
|
else {
|
|
//文字部分
|
|
//文字部分
|
|
- String stuAnswer_text=stuAnswer.substring(0,index);
|
|
|
|
- SectionCollectionBean formattedStudentAnswer_text=
|
|
|
|
|
|
+ String stuAnswer_text = stuAnswer.substring(0, index);
|
|
|
|
+ SectionCollectionBean formattedStudentAnswer_text =
|
|
RichTextHandlerFactory.getHandler(BlockType.text.name()).handle(stuAnswer_text);
|
|
RichTextHandlerFactory.getHandler(BlockType.text.name()).handle(stuAnswer_text);
|
|
|
|
|
|
//图片部分
|
|
//图片部分
|
|
- String stuAnswer_image=stuAnswer.substring(index);
|
|
|
|
- SectionCollectionBean formattedStudentAnswer_image=
|
|
|
|
|
|
+ String stuAnswer_image = stuAnswer.substring(index);
|
|
|
|
+ SectionCollectionBean formattedStudentAnswer_image =
|
|
RichTextHandlerFactory.getHandler(BlockType.image.name()).handle(stuAnswer_image);
|
|
RichTextHandlerFactory.getHandler(BlockType.image.name()).handle(stuAnswer_image);
|
|
|
|
|
|
- formattedStudentAnswer=new SectionCollectionBean();
|
|
|
|
- List<SectionBean> sections=new ArrayList<>();
|
|
|
|
|
|
+ formattedStudentAnswer = new SectionCollectionBean();
|
|
|
|
+ List<SectionBean> sections = new ArrayList<>();
|
|
sections.addAll(formattedStudentAnswer_text.getSections());
|
|
sections.addAll(formattedStudentAnswer_text.getSections());
|
|
sections.addAll(formattedStudentAnswer_image.getSections());
|
|
sections.addAll(formattedStudentAnswer_image.getSections());
|
|
formattedStudentAnswer.setSections(sections);
|
|
formattedStudentAnswer.setSections(sections);
|