Revert "Revert "上传练习模式部分功能""

This reverts commit 54dc4ca4fb.
newBigdata
yz 11 months ago
parent 54dc4ca4fb
commit 8f6327cc2c

@ -0,0 +1,13 @@
package com.sztzjy.financial_bigdata.controller.stu;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//实训演练-实训案例-实验实训
@RestController
@Api(tags = "实训演练-实训案例-实验实训")
@RequestMapping("api/stu/exercise/experimentalTrainingController")
public class ExerciseExperimentalTraining {
}

@ -0,0 +1,54 @@
package com.sztzjy.financial_bigdata.controller.stu;
import com.sztzjy.financial_bigdata.annotation.AnonymousAccess;
import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion;
import com.sztzjy.financial_bigdata.entity.sys_dto.SysObjectiveQuestionDto;
import com.sztzjy.financial_bigdata.service.stu.IExerciseService;
import com.sztzjy.financial_bigdata.service.tea.ITeaObjectiveService;
import com.sztzjy.financial_bigdata.util.ResultEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import java.util.List;
//实训演练-实训案例-学习评测
@RestController
@Api(tags = "实训演练-实训案例-学习评测")
@RequestMapping("api/stu/exercise/learningEvaluationController")
public class ExerciseLearningEvaluation {
@Autowired
IExerciseService exerciseService;
@Autowired
ITeaObjectiveService objectiveService;
//客观题展示、回显
@GetMapping("selectObjectQuestionList")
@ApiOperation("客观题列表查询,回显")
@AnonymousAccess
public ResultEntity<List<SysObjectiveQuestionDto>> selectObjectQuestionList(@ApiParam("章节Id") @RequestParam String chapterId,
@RequestParam String userId) {
List<SysObjectiveQuestionDto> list =exerciseService.selectObjectQuestionListByChapterId(chapterId,userId);
return new ResultEntity<>(HttpStatus.OK, "客观题列表查询成功",list);
}
//客观题提交
@PostMapping("commitObjectQuestionList")
@ApiOperation("客观题提交")
@AnonymousAccess
public ResultEntity commitObjectQuestionList(@RequestBody List<SysObjectiveQuestionDto> objectiveQuestionDtoList,
@RequestParam String userId,
@ApiParam("章节Id")@RequestParam String chapterId){
Boolean flag=exerciseService.commitObjectQuestionList(objectiveQuestionDtoList,userId,chapterId);
if (flag) {
return new ResultEntity<>(HttpStatus.OK, "客观题提交成功");
} else {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "客观题提交失败");
}
}
}

@ -0,0 +1,43 @@
package com.sztzjy.financial_bigdata.controller.stu;
import com.sztzjy.financial_bigdata.annotation.AnonymousAccess;
import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion;
import com.sztzjy.financial_bigdata.service.stu.ITheoryTestService;
import com.sztzjy.financial_bigdata.util.ResultEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@Api(tags = "理论考试")
@RequestMapping("api/stu/theoryTestController")
public class TheoryTestController {
@Autowired
ITheoryTestService theoryTestService;
//开始考试 选择 35道单选每题2分5道多选每题4分10道判断每题1分
@GetMapping("startTheoryTest")
@ApiOperation("开始考试")
@AnonymousAccess
public ResultEntity<List<SysObjectiveQuestion>> startTheoryTest(@RequestParam String userId) {
List<SysObjectiveQuestion> list=theoryTestService.startTheoryTest(userId);
return new ResultEntity<>(HttpStatus.OK, "开始考试、客观题列表查询成功",list);
}
//结束考试
//错题集展示
//移除错题集
//考试记录查询
//考试记录详情查询
//答题次数、平均正确率、排名
}

@ -0,0 +1,239 @@
package com.sztzjy.financial_bigdata.entity.sys_dto;
import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@NoArgsConstructor
public class SysObjectiveQuestionDto extends SysObjectiveQuestion{
@ApiModelProperty("答题状态 0为未答题 1 为答题")
private String stuStatus;
@ApiModelProperty("学生答案")
private String stuAnswer;
@ApiModelProperty("客观题ID")
private String objectiveId;
@ApiModelProperty("课程ID")
private String courseId;
@ApiModelProperty("课程名称")
private String courseName;
@ApiModelProperty("章节ID")
private String chapterId;
@ApiModelProperty("章节名称")
private String chapterName;
@ApiModelProperty("内置,新增")
private String inputType;
@ApiModelProperty("题目类型")
private String type;
@ApiModelProperty("分数")
private BigDecimal score;
@ApiModelProperty("题目内容")
private String content;
@ApiModelProperty("选项A")
private String questionA;
@ApiModelProperty("选项B")
private String questionB;
@ApiModelProperty("选项C")
private String questionC;
@ApiModelProperty("选项D")
private String questionD;
@ApiModelProperty("选项e")
private String questionE;
@ApiModelProperty("答案")
private String answer;
@ApiModelProperty("答案解析")
private String analyze;
@ApiModelProperty("学校Id")
private String schoolId;
public String getStuAnswer() {
return stuAnswer;
}
public void setStuAnswer(String stuAnswer) {
this.stuAnswer = stuAnswer;
}
public String getObjectiveId() {
return objectiveId;
}
public void setObjectiveId(String objectiveId) {
this.objectiveId = objectiveId;
}
public String getCourseId() {
return courseId;
}
public void setCourseId(String courseId) {
this.courseId = courseId;
}
public String getCourseName() {
return courseName;
}
public void setCourseName(String courseName) {
this.courseName = courseName;
}
public String getChapterId() {
return chapterId;
}
public void setChapterId(String chapterId) {
this.chapterId = chapterId;
}
public String getStuStatus() {
return stuStatus;
}
public String getChapterName() {
return chapterName;
}
public void setChapterName(String chapterName) {
this.chapterName = chapterName;
}
public String getInputType() {
return inputType;
}
public void setInputType(String inputType) {
this.inputType = inputType;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public BigDecimal getScore() {
return score;
}
public void setScore(BigDecimal score) {
this.score = score;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getQuestionA() {
return questionA;
}
public void setQuestionA(String questionA) {
this.questionA = questionA;
}
public String getQuestionB() {
return questionB;
}
public void setQuestionB(String questionB) {
this.questionB = questionB;
}
public String getQuestionC() {
return questionC;
}
public void setQuestionC(String questionC) {
this.questionC = questionC;
}
public String getQuestionD() {
return questionD;
}
public void setQuestionD(String questionD) {
this.questionD = questionD;
}
public String getQuestionE() {
return questionE;
}
public void setQuestionE(String questionE) {
this.questionE = questionE;
}
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
public String getAnalyze() {
return analyze;
}
public void setAnalyze(String analyze) {
this.analyze = analyze;
}
public String getSchoolId() {
return schoolId;
}
public void setSchoolId(String schoolId) {
this.schoolId = schoolId;
}
public SysObjectiveQuestionDto(String stuStatus,String stuAnswer,SysObjectiveQuestion sysObjectiveQuestion) {
this.stuStatus=stuStatus;
this.stuAnswer = stuAnswer;
this.objectiveId = sysObjectiveQuestion.getObjectiveId();
this.courseId =sysObjectiveQuestion.getCourseId();
this.courseName =sysObjectiveQuestion.getCourseName();
this.chapterId =sysObjectiveQuestion.getChapterId();
this.chapterName =sysObjectiveQuestion.getChapterName();
this.inputType =sysObjectiveQuestion.getInputType();
this.type =sysObjectiveQuestion.getType();
this.score =sysObjectiveQuestion.getScore();
this.content =sysObjectiveQuestion.getContent();
this.questionA =sysObjectiveQuestion.getQuestionA();
this.questionB =sysObjectiveQuestion.getQuestionB();
this.questionC =sysObjectiveQuestion.getQuestionC();
this.questionD =sysObjectiveQuestion.getQuestionD();
this.questionE =sysObjectiveQuestion.getQuestionE();
this.answer =sysObjectiveQuestion.getAnswer();
this.analyze =sysObjectiveQuestion.getAnalyze();
this.schoolId =sysObjectiveQuestion.getSchoolId();
}
}

@ -0,0 +1,12 @@
package com.sztzjy.financial_bigdata.service.stu;
import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion;
import com.sztzjy.financial_bigdata.entity.sys_dto.SysObjectiveQuestionDto;
import java.util.List;
public interface IExerciseService {
List<SysObjectiveQuestionDto> selectObjectQuestionListByChapterId(String chapterId, String userId);
Boolean commitObjectQuestionList(List<SysObjectiveQuestionDto> objectiveQuestionDtoList, String userId, String chapterId);
}

@ -0,0 +1,9 @@
package com.sztzjy.financial_bigdata.service.stu;
import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion;
import java.util.List;
public interface ITheoryTestService {
List<SysObjectiveQuestion> startTheoryTest(String userId);
}

@ -0,0 +1,134 @@
package com.sztzjy.financial_bigdata.service.stu.impl;
import com.sztzjy.financial_bigdata.entity.StuTraining;
import com.sztzjy.financial_bigdata.entity.StuTrainingExample;
import com.sztzjy.financial_bigdata.entity.StuTrainingWithBLOBs;
import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion;
import com.sztzjy.financial_bigdata.entity.sys_dto.SysObjectiveQuestionDto;
import com.sztzjy.financial_bigdata.mapper.StuTrainingMapper;
import com.sztzjy.financial_bigdata.mapper.SysObjectiveQuestionMapper;
import com.sztzjy.financial_bigdata.service.stu.IExerciseService;
import com.sztzjy.financial_bigdata.service.tea.ITeaObjectiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
@Service
public class ExerciseServiceImpl implements IExerciseService {
@Autowired
StuTrainingMapper trainingMapper;
@Autowired
ITeaObjectiveService objectiveService;
@Autowired
SysObjectiveQuestionMapper objectiveQuestionMapper;
@Override
public List<SysObjectiveQuestionDto> selectObjectQuestionListByChapterId(String chapterId, String userId) {
StuTrainingExample example = new StuTrainingExample();
example.createCriteria().andUserIdEqualTo(userId).andChapterIdEqualTo(chapterId);
List<StuTrainingWithBLOBs> stuTrainingWithBLOBs = trainingMapper.selectByExampleWithBLOBs(example);
List<String> objectiveIds = new ArrayList<>();
List<SysObjectiveQuestionDto> dtos = new ArrayList<>();
if(stuTrainingWithBLOBs.isEmpty()){
//根据章节id查询题库
List<SysObjectiveQuestion> objectiveQuestionList = objectiveService.selectRandomObjective(chapterId);
for (int i = 0; i < objectiveQuestionList.size(); i++) {
SysObjectiveQuestion objectiveQuestion = objectiveQuestionList.get(i);
String objectiveId = objectiveQuestion.getObjectiveId();
objectiveIds.add(objectiveId);
objectiveQuestion.setAnswer("");
SysObjectiveQuestionDto sysObjectiveQuestionDto = new SysObjectiveQuestionDto("0","",objectiveQuestion);
dtos.add(sysObjectiveQuestionDto);
}
StuTrainingWithBLOBs bloBs = new StuTrainingWithBLOBs();
bloBs.setTrainingId(String.valueOf(UUID.randomUUID()));
bloBs.setUserId(userId);
bloBs.setChapterId(chapterId);
bloBs.setLearningEvalIdlist(objectiveIds.toString());
trainingMapper.insert(bloBs);
return dtos;
}else {
StuTrainingWithBLOBs bloBs = stuTrainingWithBLOBs.get(0);
if (bloBs.getLearningEvalIdlist().isEmpty()) {
List<SysObjectiveQuestion> objectiveQuestionList = objectiveService.selectObjectQuestionListByChapterId(chapterId);
for (int i = 0; i < objectiveQuestionList.size(); i++) {
SysObjectiveQuestion objectiveQuestion = objectiveQuestionList.get(i);
String objectiveId = objectiveQuestion.getObjectiveId();
objectiveIds.add(objectiveId);
objectiveQuestion.setAnswer("");
SysObjectiveQuestionDto sysObjectiveQuestionDto = new SysObjectiveQuestionDto("0","",objectiveQuestion);
dtos.add(sysObjectiveQuestionDto);
}
bloBs.setLearningEvalIdlist(String.valueOf(objectiveIds));
trainingMapper.updateByPrimaryKey(bloBs);
return dtos;
}else {
if(bloBs.getLearningEvalAnswer().isEmpty()){ //判断是否提交过 未提交
List<String> learningEvalIdlist = Collections.singletonList(bloBs.getLearningEvalIdlist());
for (int i = 0; i < learningEvalIdlist.size(); i++) {
String objectiveId = learningEvalIdlist.get(i);
SysObjectiveQuestion objectiveQuestion = objectiveQuestionMapper.selectByPrimaryKey(objectiveId);
SysObjectiveQuestionDto sysObjectiveQuestionDto = new SysObjectiveQuestionDto("0","",objectiveQuestion);
dtos.add(sysObjectiveQuestionDto);
}
return dtos;
}else { //提交
List<String> learningEvalAnswerList = Collections.singletonList(bloBs.getLearningEvalAnswer());
List<String> learningEvalIdlist = Collections.singletonList(bloBs.getLearningEvalIdlist());
for (int i = 0; i < learningEvalIdlist.size(); i++) {
String objectiveId = learningEvalIdlist.get(i);
String stuAnswer = learningEvalAnswerList.get(i);
SysObjectiveQuestion objectiveQuestion = objectiveQuestionMapper.selectByPrimaryKey(objectiveId);
SysObjectiveQuestionDto sysObjectiveQuestionDto = new SysObjectiveQuestionDto("1",stuAnswer,objectiveQuestion);
dtos.add(sysObjectiveQuestionDto);
}
return dtos;
}
}
}
}
@Override
public Boolean commitObjectQuestionList(List<SysObjectiveQuestionDto> objectiveQuestionDtoList, String userId, String chapterId) {
StuTrainingExample example = new StuTrainingExample();
example.createCriteria().andUserIdEqualTo(userId).andChapterIdEqualTo(chapterId);
List<StuTrainingWithBLOBs> stuTrainingWithBLOBs = trainingMapper.selectByExampleWithBLOBs(example);
if (!stuTrainingWithBLOBs.get(0).getLearningEvalAnswer().isEmpty()){
return false;
}
List<String> stuAnswerList = new ArrayList<>();
BigDecimal learning_eval_score= BigDecimal.valueOf(0);
for (int i = 0; i < objectiveQuestionDtoList.size(); i++) {
SysObjectiveQuestionDto sysObjectiveQuestionDto = objectiveQuestionDtoList.get(i);
String stuAnswer = sysObjectiveQuestionDto.getStuAnswer();
String objectiveId = sysObjectiveQuestionDto.getObjectiveId();
SysObjectiveQuestion objectiveQuestion = objectiveQuestionMapper.selectByPrimaryKey(objectiveId);
String answer = objectiveQuestion.getAnswer();
stuAnswerList.add(stuAnswer);
if(answer.equals(stuAnswer)){
learning_eval_score= learning_eval_score.add(objectiveQuestion.getScore());
}
}
StuTrainingWithBLOBs bloBs = stuTrainingWithBLOBs.get(0);
bloBs.setLearningEvalAnswer(String.valueOf(stuAnswerList));
bloBs.setLearningEvalScore(learning_eval_score);
bloBs.setLearningEvalCompleteStatus(1);
BigDecimal progress = bloBs.getProgress();
if(progress==null){
progress= BigDecimal.valueOf(1);
}else{
progress=progress.add(BigDecimal.valueOf(1));
}
int i = trainingMapper.updateByPrimaryKey(bloBs);
return i==1;
}
}

@ -0,0 +1,64 @@
package com.sztzjy.financial_bigdata.service.stu.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sztzjy.financial_bigdata.config.Constant;
import com.sztzjy.financial_bigdata.entity.*;
import com.sztzjy.financial_bigdata.mapper.StuTheoryExamMapper;
import com.sztzjy.financial_bigdata.mapper.SysObjectiveQuestionMapper;
import com.sztzjy.financial_bigdata.service.stu.ITheoryTestService;
import com.sztzjy.financial_bigdata.util.PageUtil;
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.UUID;
@Service
public class TheoryTestServiceImpl implements ITheoryTestService {
@Autowired
StuTheoryExamMapper theoryExamMapper;
@Autowired
SysObjectiveQuestionMapper objectiveQuestionMapper;
//开始考试 1 先查询考试时间最近的一堂考试 判断是否超过2小时 如果没超过 根据理论考试表中的题目ID和答案进行回显
// 如果超过了两小时 定时方法算分将数据保存到理论考试表和理论记录表中 如果根据userid查询理论记录表中数据未null 则需要创建
// 之前没有进行考试 从客观题库表中查询 35道单选每题2分5道多选每题4分10道判断每题1分 并将id保存至理论考试表中
@Override
public List<SysObjectiveQuestion> startTheoryTest(String userId) {
StuTheoryExamExample example = new StuTheoryExamExample();
example.createCriteria().andUserIdEqualTo(userId);
List<StuTheoryExam> stuTheoryExams = theoryExamMapper.selectByExample(example);
if(stuTheoryExams.isEmpty()){
List<SysObjectiveQuestion> objectiveQuestionList= objectiveQuestionMapper.selectRandomObjective100();
List<String> singleIdList=new ArrayList<>();
List<String> manyIdList=new ArrayList<>();
List<String> judgeIdList=new ArrayList<>();
for (int i = 0; i < objectiveQuestionList.size(); i++) {
SysObjectiveQuestion objectiveQuestion = objectiveQuestionList.get(i);
String objectiveId = objectiveQuestion.getObjectiveId();
if(Constant.OBJECTIVE_TYPE_SINGLE.equals(objectiveQuestion.getType())){
singleIdList.add(objectiveId);
}else if(Constant.OBJECTIVE_TYPE_Many.equals(objectiveQuestion.getType())){
manyIdList.add(objectiveId);
}else {
judgeIdList.add(objectiveId);
}
}
StuTheoryExamWithBLOBs stuTheoryExam = new StuTheoryExamWithBLOBs();
stuTheoryExam.setTheoryExamId(String.valueOf(UUID.randomUUID()));
stuTheoryExam.setUserId(userId);
stuTheoryExam.setExamTime(new Date());
stuTheoryExam.setExamDuration(120);
stuTheoryExam.setAnswered(false);
stuTheoryExam.setSingleIds(String.valueOf(singleIdList));
stuTheoryExam.setMultipleIds(String.valueOf(manyIdList));
stuTheoryExam.setJudgeIds(String.valueOf(judgeIdList));
theoryExamMapper.insert(stuTheoryExam);
return objectiveQuestionList;
}
return null;
}
}
Loading…
Cancel
Save