|
|
@@ -1,5 +1,6 @@
|
|
|
package vip.xiaonuo.exam.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import vip.xiaonuo.exam.domain.ExamPaperAnswer;
|
|
|
import vip.xiaonuo.exam.domain.ExamPaperQuestionCustomerAnswer;
|
|
|
@@ -20,6 +21,7 @@ import com.github.pagehelper.PageInfo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -57,7 +59,8 @@ public class ExamPaperQuestionCustomerAnswerServiceImpl extends BaseServiceImpl<
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ExamPaperSubmitItemVM examPaperQuestionCustomerAnswerToVM(ExamPaperQuestionCustomerAnswer qa) {
|
|
|
+ public ExamPaperSubmitItemVM examPaperQuestionCustomerAnswerToVM(ExamPaperQuestionCustomerAnswer qa, TextContent textContent) {
|
|
|
+ System.out.println("qaqaqaqaqaqa "+qa);
|
|
|
ExamPaperSubmitItemVM examPaperSubmitItemVM = new ExamPaperSubmitItemVM();
|
|
|
examPaperSubmitItemVM.setId(qa.getId());
|
|
|
examPaperSubmitItemVM.setQuestionId(qa.getQuestionId());
|
|
|
@@ -65,7 +68,7 @@ public class ExamPaperQuestionCustomerAnswerServiceImpl extends BaseServiceImpl<
|
|
|
examPaperSubmitItemVM.setItemOrder(qa.getItemOrder());
|
|
|
examPaperSubmitItemVM.setQuestionScore(ExamUtil.scoreToVM(qa.getQuestionScore()));
|
|
|
examPaperSubmitItemVM.setScore(ExamUtil.scoreToVM(qa.getCustomerScore()));
|
|
|
- setSpecialToVM(examPaperSubmitItemVM, qa);
|
|
|
+ setSpecialToVM(examPaperSubmitItemVM, qa, textContent);
|
|
|
return examPaperSubmitItemVM;
|
|
|
}
|
|
|
|
|
|
@@ -91,22 +94,36 @@ public class ExamPaperQuestionCustomerAnswerServiceImpl extends BaseServiceImpl<
|
|
|
return examPaperQuestionCustomerAnswerMapper.updateScore(examPaperAnswerUpdates);
|
|
|
}
|
|
|
|
|
|
- private void setSpecialToVM(ExamPaperSubmitItemVM examPaperSubmitItemVM, ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer) {
|
|
|
+ private void setSpecialToVM(ExamPaperSubmitItemVM examPaperSubmitItemVM, ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer, TextContent textContent) {
|
|
|
QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.fromCode(examPaperQuestionCustomerAnswer.getQuestionType());
|
|
|
+ List<JSONObject> content = JsonUtil.toJsonListObject(textContent.getContent(), JSONObject.class);
|
|
|
+ int questionId = examPaperQuestionCustomerAnswer.getQuestionId();
|
|
|
switch (questionTypeEnum) {
|
|
|
case MultipleChoice:
|
|
|
examPaperSubmitItemVM.setContent(examPaperQuestionCustomerAnswer.getAnswer());
|
|
|
examPaperSubmitItemVM.setContentArray(ExamUtil.contentToArray(examPaperQuestionCustomerAnswer.getAnswer()));
|
|
|
break;
|
|
|
case GapFilling:
|
|
|
- TextContent textContent = textContentService.selectById(examPaperQuestionCustomerAnswer.getTextContentId());
|
|
|
- List<String> correctAnswer = JsonUtil.toJsonListObject(textContent.getContent(), String.class);
|
|
|
+ List<String> correctAnswer = new ArrayList<String>();
|
|
|
+ assert content != null;
|
|
|
+ for(JSONObject d : content){
|
|
|
+ if(d.getIntValue("questionId") == questionId){
|
|
|
+ correctAnswer = d.getJSONArray("contentArray").toJavaList(String.class);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
examPaperSubmitItemVM.setContentArray(correctAnswer);
|
|
|
break;
|
|
|
default:
|
|
|
if (QuestionTypeEnum.needSaveTextContent(examPaperQuestionCustomerAnswer.getQuestionType())) {
|
|
|
- TextContent content = textContentService.selectById(examPaperQuestionCustomerAnswer.getTextContentId());
|
|
|
- examPaperSubmitItemVM.setContent(content.getContent());
|
|
|
+ String contentAnswer = "";
|
|
|
+ for(JSONObject d : content){
|
|
|
+ if(d.getIntValue("questionId") == questionId){
|
|
|
+ contentAnswer = d.getString("content");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ examPaperSubmitItemVM.setContent(contentAnswer);
|
|
|
} else {
|
|
|
examPaperSubmitItemVM.setContent(examPaperQuestionCustomerAnswer.getAnswer());
|
|
|
}
|