上传练习模式部分功能
parent
91a61fe945
commit
5c344089b5
@ -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,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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue