From d8079d98f2a6b707dedb211d67a1a1ed88a0ccb8 Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Mon, 26 Sep 2022 13:03:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=90=86=E8=AE=BA=E8=AF=95=E9=A2=98?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../question/PagerQuestionBankController.java | 4 +-- .../rtss/dao/paper/PagerQuestionDAO.java | 3 +- .../services/papger/PagerQuestionService.java | 31 +++++++------------ .../question/PaperQuestionOptionVO2.java | 26 ++++++++-------- .../pager/question/PaperQuestionVO.java | 7 +++++ 5 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/competition/question/PagerQuestionBankController.java b/src/main/java/club/joylink/rtss/controller/competition/question/PagerQuestionBankController.java index 65598782f..b43038772 100644 --- a/src/main/java/club/joylink/rtss/controller/competition/question/PagerQuestionBankController.java +++ b/src/main/java/club/joylink/rtss/controller/competition/question/PagerQuestionBankController.java @@ -120,8 +120,8 @@ public class PagerQuestionBankController { } - /*@PostMapping(path = "answer/{questionId}") - public void answer(@PathVariable Long questionId,@RequestBody List answer){ +/* @PostMapping(path = "answer/{questionId}") + public void answer(@PathVariable Long questionId,@RequestBody List answer){ this.questionBankService.answer(questionId,answer); }*/ } diff --git a/src/main/java/club/joylink/rtss/dao/paper/PagerQuestionDAO.java b/src/main/java/club/joylink/rtss/dao/paper/PagerQuestionDAO.java index 9f3a5111b..950f9d090 100644 --- a/src/main/java/club/joylink/rtss/dao/paper/PagerQuestionDAO.java +++ b/src/main/java/club/joylink/rtss/dao/paper/PagerQuestionDAO.java @@ -3,6 +3,7 @@ package club.joylink.rtss.dao.paper; import club.joylink.rtss.dao.MyBatisBaseDao; import club.joylink.rtss.entity.paper.question.PaperQuestion; import club.joylink.rtss.entity.paper.question.PaperQuestionExample; +import club.joylink.rtss.entity.project.Project; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select; import org.springframework.stereotype.Repository; @@ -15,7 +16,7 @@ public interface PagerQuestionDAO extends MyBatisBaseDao" + "select * from paper_question where 1 = 1 " + "" + - ""+ + ""+ " and project_code is null" + ""+ " "+ diff --git a/src/main/java/club/joylink/rtss/services/papger/PagerQuestionService.java b/src/main/java/club/joylink/rtss/services/papger/PagerQuestionService.java index efa0df643..b19d7480f 100644 --- a/src/main/java/club/joylink/rtss/services/papger/PagerQuestionService.java +++ b/src/main/java/club/joylink/rtss/services/papger/PagerQuestionService.java @@ -109,29 +109,29 @@ public class PagerQuestionService { /** * 检测题目是否正确 * @param questionId 题目id - * @param answer 检测的答案 + * @param answerIds 检测的答案Id * @return */ - public boolean answer(Long questionId,List answer){ - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!CollectionUtils.isEmpty(answer),"题目答案不能为空"); + public boolean answer(Long questionId,List answerIds){ + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!CollectionUtils.isEmpty(answerIds),"题目答案不能为空"); PaperQuestionVO vo = this.getQuestion(questionId,true); - List newAnswerList = answer.stream().filter(Objects::nonNull).map(String::trim).distinct().collect(Collectors.toList()); - List optionList = vo.getOptionList().stream().filter(PaperQuestionOptionVO2::getCorrect).map(d->d.getContent().trim()).collect(Collectors.toList()); + List newAnswerList = answerIds.stream().filter(Objects::nonNull)/*.map(String::trim)*/.distinct().collect(Collectors.toList()); + List optionList = vo.getOptionList().stream().filter(PaperQuestionOptionVO2::getCorrect).map(d->d.getId()).collect(Collectors.toList()); if(Objects.equals(BusinessConsts.TheoryType.select.name(),vo.getType()) || Objects.equals(BusinessConsts.TheoryType.judge.name(),vo.getType())){ - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() != 1 ,"单选,判断题答案只能有一个!"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() == 1 ,"单选,判断题答案只能有一个!"); }else if(Objects.equals(BusinessConsts.TheoryType.multi.name(),vo.getType())){ - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() < 2 ,"多选题答案最少需要2个"); - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue(newAnswerList.size() > optionList.size(),"多选题答案与标准答案数量不匹配"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() > 2 ,"多选题答案最少需要2个"); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() < optionList.size(),"多选题答案与标准答案数量不匹配"); } - List sourceOptionList = Lists.newArrayList(); + List sourceOptionList = Lists.newArrayList(); sourceOptionList.addAll(optionList); optionList.removeAll(newAnswerList); if(CollectionUtils.isEmpty(optionList)){ return true; } - log.info("检查题目[{}]答案,获取原答案[{}],正确答案[{}] 有[{}]没有答对",questionId, Joiner.on(",").join(answer),Joiner.on(",").join(sourceOptionList),Joiner.on(",").join(optionList)); + log.info("检查题目[{}]答案,获取原答案[{}],正确答案[{}] 有[{}]没有答对",questionId, Joiner.on(",").join(answerIds),Joiner.on(",").join(sourceOptionList),Joiner.on(",").join(optionList)); return false; } @@ -189,15 +189,6 @@ public class PagerQuestionService { }else if(questionVO.isMulti()){ this.checkQuestionTypeForMulti(questionVO,"多选题正确答案必须是2个以上!"); } - /* BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue( - (Objects.equals(BusinessConsts.TheoryType.select.name(), questionVO.getType()) || - Objects.equals(BusinessConsts.TheoryType.judge.name(), questionVO.getType())) && - questionVO.getOptionList().stream().filter(PaperQuestionOptionVO2::getCorrect).count() == 1, - "单选或判断题正确答案有且只有一个!"); - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotTrue( - (Objects.equals(BusinessConsts.TheoryType.multi.name(), questionVO.getType())) && - questionVO.getOptionList().stream().filter(PaperQuestionOptionVO2::getCorrect).count() <= 1, - "多选题正确答案必须是2个以上!");*/ PaperQuestion question = questionVO.convert2DB(); question.setCreateUserId(accountVO.getId()); question.setCreateTime(LocalDateTime.now()); @@ -232,7 +223,7 @@ public class PagerQuestionService { private void checkQuestionTypeForMulti(PaperQuestionVO vo,String errStr){ long answerCount = vo.getOptionList().stream().filter(PaperQuestionOptionVO2::getCorrect).count(); - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(answerCount <=1,errStr); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(answerCount > 2,errStr); } @Transactional diff --git a/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionOptionVO2.java b/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionOptionVO2.java index 7ca8e2ca5..1eb69efba 100644 --- a/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionOptionVO2.java +++ b/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionOptionVO2.java @@ -19,8 +19,8 @@ import java.util.List; @NoArgsConstructor public class PaperQuestionOptionVO2 implements Cloneable { - private Long id; - private Long questionId; + private int id; +// private Long questionId; /** * 选项 */ @@ -33,21 +33,21 @@ public class PaperQuestionOptionVO2 implements Cloneable { private Boolean correct; public PaperQuestionOptionVO2(RaceQuestionOption questionOption) { - this.id = questionOption.getId(); - this.questionId = questionOption.getQuestionId(); + this.id = questionOption.getId().intValue(); +// this.questionId = questionOption.getQuestionId(); this.content = questionOption.getContent(); this.correct = questionOption.getCorrect(); } - public RaceQuestionOption convert2DB() { - RaceQuestionOption questionOption = new RaceQuestionOption(); - questionOption.setId(id); - questionOption.setQuestionId(questionId); - questionOption.setContent(content); - questionOption.setCorrect(correct); - - return questionOption; - } +// public RaceQuestionOption convert2DB() { +// RaceQuestionOption questionOption = new RaceQuestionOption(); +// questionOption.setId(id); +//// questionOption.setQuestionId(questionId); +// questionOption.setContent(content); +// questionOption.setCorrect(correct); +// +// return questionOption; +// } public static List convert2VOList(List options){ List voList = new ArrayList<>(); diff --git a/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionVO.java b/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionVO.java index 685f5c40f..c6cd782a5 100644 --- a/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionVO.java @@ -74,11 +74,18 @@ public class PaperQuestionVO implements Cloneable { question.setTopic(topic); question.setProjectCode(Project.isDefault(Project.valueOf(projectCode)) ? null : projectCode); question.setCompanyId(companyId); + this.setOptionId(); question.setQuestions(JsonUtils.writeValueAsString(this.optionList)); question.setRaceLable(this.raceLable); question.setIsDel(BusinessConsts.DBLogicDelete.NORMAL.ordinal()); return question; } + private void setOptionId(){ + int i = 0; + for (PaperQuestionOptionVO2 vo : this.optionList) { + vo.setId(i++); + } + } public static List convert2VOList(List questions){ From 3489df9245d6b643844312f970c4d8be33de1f33 Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Tue, 27 Sep 2022 14:20:29 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=90=86=E8=AE=BA=E8=AF=95=E9=A2=98?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/20220921-zhouyin.sql | 12 ++-- .../PagerQuestionBankController.java | 2 +- .../entity/paper/question/PaperQuestion.java | 5 +- .../services/papger/PagerQuestionService.java | 22 +++--- .../question/PaperQuestionOptionVO2.java | 2 + .../pager/question/PaperQuestionVO.java | 48 ++++++++++--- .../mybatis/mapper/PaperQuestionDAO.xml | 72 +++++++++++-------- 7 files changed, 109 insertions(+), 54 deletions(-) rename src/main/java/club/joylink/rtss/controller/{competition/question => paper}/PagerQuestionBankController.java (98%) diff --git a/sql/20220921-zhouyin.sql b/sql/20220921-zhouyin.sql index fd2f68441..d89a99d66 100644 --- a/sql/20220921-zhouyin.sql +++ b/sql/20220921-zhouyin.sql @@ -1,14 +1,16 @@ -- 新题库 -DROP TABLE IF EXISTS `race_question2`; -CREATE TABLE `race_question2` ( +DROP TABLE IF EXISTS `paper_question`; +CREATE TABLE `paper_question` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id', `type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '类型 选择题=select,判断题=judge,多选题=multi', - `topic` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '问题内容', + `question` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '问题内容', `create_user_id` bigint DEFAULT NULL COMMENT '创建者id', `create_time` datetime DEFAULT NULL COMMENT '创建时间', `project_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '项目code', `company_id` bigint DEFAULT NULL COMMENT '公司组织id', `race_lable` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '标签', - `questions` longtext, + `question_option` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '问题选项', + `question_answer` varchar(255) DEFAULT NULL COMMENT '答案,号隔开', + `is_del` int DEFAULT '0' COMMENT '是否删除0=否,1=是', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; diff --git a/src/main/java/club/joylink/rtss/controller/competition/question/PagerQuestionBankController.java b/src/main/java/club/joylink/rtss/controller/paper/PagerQuestionBankController.java similarity index 98% rename from src/main/java/club/joylink/rtss/controller/competition/question/PagerQuestionBankController.java rename to src/main/java/club/joylink/rtss/controller/paper/PagerQuestionBankController.java index b43038772..7883d4a8c 100644 --- a/src/main/java/club/joylink/rtss/controller/competition/question/PagerQuestionBankController.java +++ b/src/main/java/club/joylink/rtss/controller/paper/PagerQuestionBankController.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.controller.competition.question; +package club.joylink.rtss.controller.paper; import club.joylink.rtss.services.papger.PagerQuestionService; diff --git a/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestion.java b/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestion.java index afab42b78..e81014141 100644 --- a/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestion.java +++ b/src/main/java/club/joylink/rtss/entity/paper/question/PaperQuestion.java @@ -50,8 +50,9 @@ public class PaperQuestion implements Serializable { * 是否删除0=否,1=是 */ private Integer isDel; - private String topic; + private String question; - private String questions; + private String questionOption; + private String questionAnswer; private static final long serialVersionUID = 1L; } diff --git a/src/main/java/club/joylink/rtss/services/papger/PagerQuestionService.java b/src/main/java/club/joylink/rtss/services/papger/PagerQuestionService.java index b19d7480f..e2aa8b881 100644 --- a/src/main/java/club/joylink/rtss/services/papger/PagerQuestionService.java +++ b/src/main/java/club/joylink/rtss/services/papger/PagerQuestionService.java @@ -116,22 +116,28 @@ public class PagerQuestionService { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(!CollectionUtils.isEmpty(answerIds),"题目答案不能为空"); PaperQuestionVO vo = this.getQuestion(questionId,true); List newAnswerList = answerIds.stream().filter(Objects::nonNull)/*.map(String::trim)*/.distinct().collect(Collectors.toList()); - List optionList = vo.getOptionList().stream().filter(PaperQuestionOptionVO2::getCorrect).map(d->d.getId()).collect(Collectors.toList()); +// List optionList = vo.getOptionList().stream().filter(PaperQuestionOptionVO2::getCorrect).map(d->d.getId()).collect(Collectors.toList()); if(Objects.equals(BusinessConsts.TheoryType.select.name(),vo.getType()) || Objects.equals(BusinessConsts.TheoryType.judge.name(),vo.getType())){ BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() == 1 ,"单选,判断题答案只能有一个!"); }else if(Objects.equals(BusinessConsts.TheoryType.multi.name(),vo.getType())){ BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() > 2 ,"多选题答案最少需要2个"); - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() < optionList.size(),"多选题答案与标准答案数量不匹配"); +// BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(newAnswerList.size() < optionList.size(),"多选题答案与标准答案数量不匹配"); } - List sourceOptionList = Lists.newArrayList(); - sourceOptionList.addAll(optionList); - optionList.removeAll(newAnswerList); - if(CollectionUtils.isEmpty(optionList)){ +// List sourceOptionList = Lists.newArrayList(); +// sourceOptionList.addAll(optionList); +// optionList.removeAll(newAnswerList); +// if(CollectionUtils.isEmpty(optionList)){ +// return true; +// } + Collections.sort(answerIds); + String answerStr = Joiner.on(",").join(answerIds); + if(Objects.equals(answerStr,vo.getQuestionAnswer())){ return true; } - log.info("检查题目[{}]答案,获取原答案[{}],正确答案[{}] 有[{}]没有答对",questionId, Joiner.on(",").join(answerIds),Joiner.on(",").join(sourceOptionList),Joiner.on(",").join(optionList)); + log.info("检查题目[{}]答案,获取原答案[{}],正确答案[{}] ",questionId, answerStr,vo.getQuestionAnswer()); +// log.info("检查题目[{}]答案,获取原答案[{}],正确答案[{}] 有[{}]没有答对",questionId, Joiner.on(",").join(answerIds),Joiner.on(",").join(sourceOptionList),Joiner.on(",").join(optionList)); return false; } @@ -230,7 +236,7 @@ public class PagerQuestionService { public void importProjectQuestion(List questions, String projectCode, Long companyId, AccountVO accountVO) { questions.forEach(questionVO -> { - String topic = questionVO.getTopic(); + String topic = questionVO.getQuestion(); this.checkQuestionType(questionVO,String.format("题库目前只支持单选,多选和判断,题序[%s]",questionVO.getId())); if (questionVO.isSelect() || questionVO.isJudge()) { this.checkQuestionTypeForSelectAndJudge(questionVO,String.format("题序[%s]:单选或判断题[%s]正确答案应当有且只有一个!", questionVO.getId(),topic)); diff --git a/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionOptionVO2.java b/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionOptionVO2.java index 1eb69efba..671cf2ae6 100644 --- a/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionOptionVO2.java +++ b/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionOptionVO2.java @@ -1,6 +1,7 @@ package club.joylink.rtss.vo.client.pager.question; import club.joylink.rtss.entity.RaceQuestionOption; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -30,6 +31,7 @@ public class PaperQuestionOptionVO2 implements Cloneable { * 正确的 */ @NotNull(message = "题目没有设置正确选项") +// @JsonIgnore private Boolean correct; public PaperQuestionOptionVO2(RaceQuestionOption questionOption) { diff --git a/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionVO.java b/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionVO.java index c6cd782a5..d6554aad7 100644 --- a/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/pager/question/PaperQuestionVO.java @@ -5,14 +5,18 @@ import club.joylink.rtss.constants.Project; import club.joylink.rtss.entity.paper.question.PaperQuestion; import club.joylink.rtss.util.JsonUtils; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JavaType; +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; +import com.google.common.collect.Lists; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import org.springframework.util.CollectionUtils; import javax.validation.constraints.NotBlank; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; @@ -24,7 +28,6 @@ import java.util.stream.Collectors; @NoArgsConstructor public class PaperQuestionVO implements Cloneable { - private Long id; /** @@ -37,7 +40,7 @@ public class PaperQuestionVO implements Cloneable { *题目 */ @NotBlank(message = "题目不能为空") - private String topic; + private String question; /** *选项列表 @@ -51,6 +54,9 @@ public class PaperQuestionVO implements Cloneable { private String projectCode; private Long companyId; private String raceLable; + private String questionAnswer; + private String answer; + /** *分值 */ @@ -60,31 +66,53 @@ public class PaperQuestionVO implements Cloneable { public PaperQuestionVO(PaperQuestion question) { this.id = question.getId(); this.type = question.getType(); - this.topic = question.getTopic(); + this.question = question.getQuestion(); this.projectCode = question.getProjectCode(); this.companyId = question.getCompanyId(); this.raceLable = question.getRaceLable(); - this.optionList = JsonUtils.readCollection(question.getQuestions(),ArrayList.class, PaperQuestionOptionVO2.class); + this.optionList = JsonUtils.readCollection(question.getQuestionOption(),ArrayList.class, PaperQuestionOptionVO2.class); + String dd = Objects.isNull(question.getQuestionAnswer()) ? "" : question.getQuestionAnswer(); + this.answer = dd; + List answerList = Splitter.on(",").splitToList(dd); + for (PaperQuestionOptionVO2 vo : this.optionList) { + vo.setCorrect(false); + if(answerList.contains(vo.getId() + "")){ + vo.setCorrect(true); + } + } } public PaperQuestion convert2DB() { PaperQuestion question = new PaperQuestion(); question.setId(this.id); question.setType(type); - question.setTopic(topic); + question.setQuestion(this.question); question.setProjectCode(Project.isDefault(Project.valueOf(projectCode)) ? null : projectCode); question.setCompanyId(companyId); - this.setOptionId(); - question.setQuestions(JsonUtils.writeValueAsString(this.optionList)); + this.setOptionId(question); + + String dd = JsonUtils.writeValueAsString(this.optionList); + + List listMap = JsonUtils.readCollection(dd,List.class,Map.class); + listMap.forEach(d->d.remove("correct")); + + question.setQuestionOption(JsonUtils.writeValueAsString(listMap)); question.setRaceLable(this.raceLable); question.setIsDel(BusinessConsts.DBLogicDelete.NORMAL.ordinal()); +// question.setQuestionAnswer(this.answer); return question; } - private void setOptionId(){ + private void setOptionId(PaperQuestion pq){ int i = 0; + List answerList = Lists.newArrayList(); for (PaperQuestionOptionVO2 vo : this.optionList) { vo.setId(i++); + if(vo.getCorrect()){ + answerList.add(vo.getId() + ""); + } } + + pq.setQuestionAnswer(Joiner.on(",").join(answerList)); } diff --git a/src/main/resources/mybatis/mapper/PaperQuestionDAO.xml b/src/main/resources/mybatis/mapper/PaperQuestionDAO.xml index 522007b5a..1d44ca1f7 100644 --- a/src/main/resources/mybatis/mapper/PaperQuestionDAO.xml +++ b/src/main/resources/mybatis/mapper/PaperQuestionDAO.xml @@ -10,8 +10,9 @@ - - + + +