package com.alvis.exam.service.impl;
import com.alvis.exam.domain.*;
import com.alvis.exam.domain.enums.ExamPaperAnswerStatusEnum;
import com.alvis.exam.domain.enums.QuestionTypeEnum;
import com.alvis.exam.domain.exam.ExamPaperTitleItemObject;
import com.alvis.exam.repository.*;
import com.alvis.exam.service.ExamPaperAnswerService;
import com.alvis.exam.service.ExamPaperQuestionCustomerAnswerService;
import com.alvis.exam.service.TextContentService;
import com.alvis.exam.utility.DateTimeUtil;
import com.alvis.exam.utility.ExamUtil;
import com.alvis.exam.utility.JsonUtil;
import com.alvis.exam.viewmodel.student.exam.ExamPaperSubmitItemVM;
import com.alvis.exam.viewmodel.student.exam.ExamPaperSubmitVM;
import com.alvis.exam.viewmodel.student.exampaper.ExamPaperAnswerPageVM;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class ExamPaperAnswerServiceImpl extends BaseServiceImpl<ExamPaperAnswer> implements ExamPaperAnswerService {
private final ExamPaperAnswerMapper examPaperAnswerMapper;
private final ExamPaperMapper examPaperMapper;
private final TextContentService textContentService;
private final QuestionMapper questionMapper;
private final ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService;
@Autowired
public ExamPaperAnswerServiceImpl(ExamPaperAnswerMapper examPaperAnswerMapper, ExamPaperMapper examPaperMapper, TextContentService textContentService, QuestionMapper questionMapper, ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService) {
super(examPaperAnswerMapper);
this.examPaperAnswerMapper = examPaperAnswerMapper;
this.examPaperMapper = examPaperMapper;
this.textContentService = textContentService;
this.questionMapper = questionMapper;
this.examPaperQuestionCustomerAnswerService = examPaperQuestionCustomerAnswerService;
}
@Override
public PageInfo<ExamPaperAnswer> studentPage(ExamPaperAnswerPageVM requestVM) {
return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() ->
examPaperAnswerMapper.studentPage(requestVM));
}
@Override
public ExamPaperAnswerInfo calculateExamPaperAnswer(ExamPaperSubmitVM examPaperSubmitVM, User user) {
ExamPaperAnswerInfo examPaperAnswerInfo = new ExamPaperAnswerInfo();
Date now = new Date();
ExamPaper examPaper = examPaperMapper.selectByPrimaryKey(examPaperSubmitVM.getId());
String frameTextContent = textContentService.selectById(examPaper.getFrameTextContentId()).getContent();
List<ExamPaperTitleItemObject> examPaperTitleItemObjects = JsonUtil.toJsonListObject(frameTextContent, ExamPaperTitleItemObject.class);
List<Integer> questionIds = examPaperTitleItemObjects.stream().flatMap(t -> t.getQuestionItems().stream().map(q -> q.getId())).collect(Collectors.toList());
List<Question> questions = questionMapper.selectByIds(questionIds);
List<ExamPaperQuestionCustomerAnswer> examPaperQuestionCustomerAnswers = examPaperTitleItemObjects.stream()
.flatMap(t -> t.getQuestionItems().stream()
.map(q -> {
Question question = questions.stream().filter(tq -> tq.getId().equals(q.getId())).findFirst().get();
ExamPaperSubmitItemVM customerQuestionAnswer = examPaperSubmitVM.getAnswerItems().stream().filter(tq -> tq.getQuestionId().equals(q.getId())).findFirst().orElse(null);
return ExamPaperQuestionCustomerAnswerFromVM(question, customerQuestionAnswer, examPaper, user, now);
})
).collect(Collectors.toList());
ExamPaperAnswer examPaperAnswer = ExamPaperAnswerFromVM(examPaperSubmitVM, examPaper, examPaperQuestionCustomerAnswers, user, now);
examPaperAnswerInfo.setExamPaper(examPaper);
examPaperAnswerInfo.setExamPaperAnswer(examPaperAnswer);
examPaperAnswerInfo.setExamPaperQuestionCustomerAnswers(examPaperQuestionCustomerAnswers);
return examPaperAnswerInfo;
}
@Override
public ExamPaperSubmitVM examPaperAnswerToVM(Integer id) {
ExamPaperSubmitVM examPaperSubmitVM = new ExamPaperSubmitVM();
ExamPaperAnswer examPaperAnswer = examPaperAnswerMapper.selectByPrimaryKey(id);
examPaperSubmitVM.setId(examPaperAnswer.getId());
examPaperSubmitVM.setDoTime(examPaperAnswer.getDoTime());
examPaperSubmitVM.setScore(ExamUtil.scoreToVM(examPaperAnswer.getUserScore()));
List<ExamPaperQuestionCustomerAnswer> examPaperQuestionCustomerAnswers = examPaperQuestionCustomerAnswerService.selectListByPaperAnswerId(examPaperAnswer.getId());
List<ExamPaperSubmitItemVM> examPaperSubmitItemVMS = examPaperQuestionCustomerAnswers.stream().map(a -> examPaperQuestionCustomerAnswerService.examPaperQuestionCustomerAnswerToVM(a)).collect(Collectors.toList());
examPaperSubmitVM.setAnswerItems(examPaperSubmitItemVMS);
return examPaperSubmitVM;
}
@Override
public Integer selectAllCount() {
return examPaperAnswerMapper.selectAllCount();
}
@Override
public List<Integer> selectMothCount() {
Date startTime = DateTimeUtil.getMonthStartDay();
Date endTime = DateTimeUtil.getMonthEndDay();
List<KeyValue> mouthCount = examPaperAnswerMapper.selectCountByDate(startTime, endTime);
List<String> mothStartToNowFormat = DateTimeUtil.MothStartToNowFormat();
return mothStartToNowFormat.stream().map(md -> {
KeyValue keyValue = mouthCount.stream().filter(kv -> kv.getName().equals(md)).findAny().orElse(null);
return null == keyValue ? 0 : keyValue.getValue();
}).collect(Collectors.toList());
}
private ExamPaperQuestionCustomerAnswer ExamPaperQuestionCustomerAnswerFromVM(Question question, ExamPaperSubmitItemVM customerQuestionAnswer, ExamPaper examPaper, User user, Date now) {
ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer = new ExamPaperQuestionCustomerAnswer();
examPaperQuestionCustomerAnswer.setQuestionId(question.getId());
examPaperQuestionCustomerAnswer.setExamPaperId(examPaper.getId());
examPaperQuestionCustomerAnswer.setQuestionScore(question.getScore());
examPaperQuestionCustomerAnswer.setSubjectId(examPaper.getSubjectId());
examPaperQuestionCustomerAnswer.setCreateTime(now);
examPaperQuestionCustomerAnswer.setCreateUser(user.getId());
examPaperQuestionCustomerAnswer.setQuestionType(question.getQuestionType());
examPaperQuestionCustomerAnswer.setQuestionTextContentId(question.getInfoTextContentId());
if (null == customerQuestionAnswer) {
examPaperQuestionCustomerAnswer.setCustomerScore(0);
} else {
setSpecialFromVM(examPaperQuestionCustomerAnswer, question, customerQuestionAnswer);
}
return examPaperQuestionCustomerAnswer;
}
private void setSpecialFromVM(ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer, Question question, ExamPaperSubmitItemVM customerQuestionAnswer) {
QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.fromCode(examPaperQuestionCustomerAnswer.getQuestionType());
switch (questionTypeEnum) {
case SingleChoice:
case TrueFalse:
examPaperQuestionCustomerAnswer.setAnswer(customerQuestionAnswer.getContent());
examPaperQuestionCustomerAnswer.setDoRight(question.getCorrect().equals(customerQuestionAnswer.getContent()));
examPaperQuestionCustomerAnswer.setCustomerScore(examPaperQuestionCustomerAnswer.getDo
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
在线考试系统是一种基于互联网的教育技术工具,用于组织、管理和实施在线考试。这种系统通常由软件应用程序支持,为学生和考生提供了在网上参加考试的机会。在线考试系统可以用于各种教育和培训场景,包括学校教育、职业资格认证、招聘考试等。 【主要特点和优势】: 灵活性和便利性:学生和考生可以通过互联网随时随地参加考试,不再受限于特定的地点和时间。 自动化管理:系统能够自动管理考试安排、考生信息、考试成绩等数据。 安全性:在线考试系统通常具有严格的身份验证和防作弊措施。 实时反馈:考试结束后,系统可以立即生成和发布成绩,提供即时反馈。 多样化的题型:系统支持各种题型,包括选择题、填空题、问答题等多种题型。 数据分析:系统可以收集和分析大量的考试数据,帮助教育机构和考试机构更好地了解学生的表现和需求,优化教学和考试内容。 【引流】 Java、Python、Node.js、Spring Boot、Django、Express、MySQL、PostgreSQL、MongoDB、React、Angular、Vue、Bootstrap、Material-UI、Redis、Docker、Kubernetes
资源推荐
资源详情
资源评论
收起资源包目录
学之思在线考试系统,专注k12教育,支持各种题型、数学公司,扩展性强,部署方便。exam.zip (2000个子文件)
.browserslistrc 21B
.browserslistrc 21B
index.css 414KB
index.css 414KB
ueditor.css 43KB
ueditor.css 43KB
ueditor.min.css 34KB
ueditor.min.css 34KB
video-js.css 21KB
video-js.css 21KB
image.css 18KB
image.css 18KB
video.css 15KB
video.css 15KB
attachment.css 14KB
attachment.css 14KB
ui.css 12KB
ui.css 12KB
video-js.min.css 11KB
video-js.min.css 11KB
fui.css 10KB
fui.css 10KB
fui.min.css 7KB
fui.min.css 7KB
shCoreDefault.css 7KB
shCoreDefault.css 7KB
scrawl.css 4KB
scrawl.css 4KB
codemirror.css 3KB
codemirror.css 3KB
charts.css 3KB
charts.css 3KB
background.css 2KB
background.css 2KB
emotion.css 2KB
emotion.css 2KB
dialogbase.css 2KB
dialogbase.css 2KB
music.css 2KB
music.css 2KB
scrollbar.css 1KB
scrollbar.css 1KB
edittable.css 1KB
edittable.css 1KB
base.css 1KB
base.css 1KB
template.css 1KB
template.css 1KB
webuploader.css 515B
webuploader.css 515B
help.css 389B
help.css 389B
iframe.css 155B
iframe.css 155B
page.css 153B
page.css 153B
.env.dev 96B
.env.dev 96B
.editorconfig 121B
.editorconfig 121B
.env 11B
.env 11B
vjs.eot 3KB
vjs.eot 3KB
.eslintignore 66B
UEditorSnapscreen.exe 508KB
UEditorSnapscreen.exe 508KB
401.gif 160KB
401.gif 160KB
avatar.gif 57KB
wface.gif 49KB
wface.gif 49KB
jxface2.gif 40KB
jxface2.gif 40KB
yface.gif 28KB
yface.gif 28KB
bface.gif 27KB
bface.gif 27KB
icons.gif 20KB
icons.gif 20KB
file-icons.gif 20KB
file-icons.gif 20KB
file-icons.gif 20KB
file-icons.gif 20KB
tface.gif 19KB
tface.gif 19KB
fface.gif 18KB
fface.gif 18KB
cface.gif 8KB
cface.gif 8KB
icons-all.gif 4KB
icons-all.gif 4KB
loading.gif 2KB
loading.gif 2KB
videologo.gif 2KB
videologo.gif 2KB
cancelbutton.gif 1KB
cancelbutton.gif 1KB
button-bg.gif 1KB
button-bg.gif 1KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
枫蜜柚子茶
- 粉丝: 8971
- 资源: 5351
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功