diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseExperimentalTraining.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseExperimentalTraining.java new file mode 100644 index 0000000..488166c --- /dev/null +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseExperimentalTraining.java @@ -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 { + +} diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseLearningEvaluation.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseLearningEvaluation.java new file mode 100644 index 0000000..4fb7b50 --- /dev/null +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/ExerciseLearningEvaluation.java @@ -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> selectObjectQuestionList(@ApiParam("章节Id") @RequestParam String chapterId, + @RequestParam String userId) { + List list =exerciseService.selectObjectQuestionListByChapterId(chapterId,userId); + return new ResultEntity<>(HttpStatus.OK, "客观题列表查询成功",list); + } + + //客观题提交 + @PostMapping("commitObjectQuestionList") + @ApiOperation("客观题提交") + @AnonymousAccess + public ResultEntity commitObjectQuestionList(@RequestBody List 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, "客观题提交失败"); + } + } + +} diff --git a/src/main/java/com/sztzjy/financial_bigdata/controller/stu/TheoryTestController.java b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/TheoryTestController.java new file mode 100644 index 0000000..495a730 --- /dev/null +++ b/src/main/java/com/sztzjy/financial_bigdata/controller/stu/TheoryTestController.java @@ -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> startTheoryTest(@RequestParam String userId) { + List list=theoryTestService.startTheoryTest(userId); + return new ResultEntity<>(HttpStatus.OK, "开始考试、客观题列表查询成功",list); + } + + //结束考试 + //错题集展示 + //移除错题集 + //考试记录查询 + //考试记录详情查询 + //答题次数、平均正确率、排名 + + +} diff --git a/src/main/java/com/sztzjy/financial_bigdata/entity/sys_dto/SysObjectiveQuestionDto.java b/src/main/java/com/sztzjy/financial_bigdata/entity/sys_dto/SysObjectiveQuestionDto.java new file mode 100644 index 0000000..6c208e6 --- /dev/null +++ b/src/main/java/com/sztzjy/financial_bigdata/entity/sys_dto/SysObjectiveQuestionDto.java @@ -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(); + } +} diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/stu/IExerciseService.java b/src/main/java/com/sztzjy/financial_bigdata/service/stu/IExerciseService.java new file mode 100644 index 0000000..60416ab --- /dev/null +++ b/src/main/java/com/sztzjy/financial_bigdata/service/stu/IExerciseService.java @@ -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 selectObjectQuestionListByChapterId(String chapterId, String userId); + + Boolean commitObjectQuestionList(List objectiveQuestionDtoList, String userId, String chapterId); +} diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/stu/ITheoryTestService.java b/src/main/java/com/sztzjy/financial_bigdata/service/stu/ITheoryTestService.java new file mode 100644 index 0000000..4b8762f --- /dev/null +++ b/src/main/java/com/sztzjy/financial_bigdata/service/stu/ITheoryTestService.java @@ -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 startTheoryTest(String userId); +} diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/ExerciseServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/ExerciseServiceImpl.java new file mode 100644 index 0000000..8d0347c --- /dev/null +++ b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/ExerciseServiceImpl.java @@ -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 selectObjectQuestionListByChapterId(String chapterId, String userId) { + StuTrainingExample example = new StuTrainingExample(); + example.createCriteria().andUserIdEqualTo(userId).andChapterIdEqualTo(chapterId); + List stuTrainingWithBLOBs = trainingMapper.selectByExampleWithBLOBs(example); + List objectiveIds = new ArrayList<>(); + List dtos = new ArrayList<>(); + if(stuTrainingWithBLOBs.isEmpty()){ + //根据章节id查询题库 + List 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 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 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 learningEvalAnswerList = Collections.singletonList(bloBs.getLearningEvalAnswer()); + List 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 objectiveQuestionDtoList, String userId, String chapterId) { + StuTrainingExample example = new StuTrainingExample(); + example.createCriteria().andUserIdEqualTo(userId).andChapterIdEqualTo(chapterId); + List stuTrainingWithBLOBs = trainingMapper.selectByExampleWithBLOBs(example); + + if (!stuTrainingWithBLOBs.get(0).getLearningEvalAnswer().isEmpty()){ + return false; + } + List 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; + } +} diff --git a/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/TheoryTestServiceImpl.java b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/TheoryTestServiceImpl.java new file mode 100644 index 0000000..d763d21 --- /dev/null +++ b/src/main/java/com/sztzjy/financial_bigdata/service/stu/impl/TheoryTestServiceImpl.java @@ -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 startTheoryTest(String userId) { + StuTheoryExamExample example = new StuTheoryExamExample(); + example.createCriteria().andUserIdEqualTo(userId); + List stuTheoryExams = theoryExamMapper.selectByExample(example); + if(stuTheoryExams.isEmpty()){ + List objectiveQuestionList= objectiveQuestionMapper.selectRandomObjective100(); + List singleIdList=new ArrayList<>(); + List manyIdList=new ArrayList<>(); + List 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; + } +}