用户测评更新(开启虚拟仿真实验。教学实验)

hehai
mzh820631607 4 years ago
parent 3656bab2c8
commit 9cc6d9fa95
  1. 15
      src/main/java/com/msdw/tms/api/EvaluationRecordControllerApi.java
  2. 197
      src/main/java/com/msdw/tms/controller/EvaluationRecordController.java
  3. 7
      src/main/java/com/msdw/tms/dao/EvaluationRecordDao.java
  4. 14
      src/main/java/com/msdw/tms/dao/FractionEntityDao.java
  5. 25
      src/main/java/com/msdw/tms/entity/FractionEntity.java
  6. 70
      src/main/java/com/msdw/tms/entity/vo/TMSEvaluationRecordVO.java
  7. 27
      src/main/java/com/msdw/tms/service/EvaluationRecordService.java
  8. 12
      src/main/java/com/msdw/tms/service/FractionEntityService.java
  9. 313
      src/main/java/com/msdw/tms/service/impl/EvaluationRecordServiceImpl.java
  10. 34
      src/main/java/com/msdw/tms/service/impl/FractionEntityServiceImpl.java
  11. 2
      src/main/resources/mapper/tms/EvaluationRecordDao.xml
  12. 16
      src/main/resources/mapper/tms/FractionEntityDao.xml

@ -2,6 +2,7 @@ package com.msdw.tms.api;
import com.msdw.tms.common.utils.R;
import com.msdw.tms.entity.vo.EvaluationRecordVO;
import com.msdw.tms.entity.vo.TMSEvaluationRecordVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -39,19 +40,19 @@ public interface EvaluationRecordControllerApi {
* 开始测评返回第一题的数据
*/
@ApiOperation(value = "开始测评", notes = "开始测评")
R startEvaluation(Integer userId);
R startEvaluation(Integer userId,Integer type);
/**
* 上一题
*/
@ApiOperation(value = "上一题", notes = "上一题")
R previousQuestion(EvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException;
R previousQuestion(TMSEvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException;
/**
* 下一题
*/
@ApiOperation(value = "下一题", notes = "下一题")
R nextQuestion(EvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException;
R nextQuestion(TMSEvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException;
/**
* 提交之前查询是否还有未做完的试题
@ -63,7 +64,7 @@ public interface EvaluationRecordControllerApi {
* 提交测评
*/
@ApiOperation(value = "提交测评", notes = "提交测评")
R submitEvaluation(EvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException;
R submitEvaluation(TMSEvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException;
/**
* 成绩详情
@ -76,4 +77,10 @@ public interface EvaluationRecordControllerApi {
*/
@ApiOperation(value = "查询是否能够开启实验", notes = "查询是否能够开启实验")
R isOpenExperiment(Integer userId);
@ApiOperation(value = "查询是否能开启虚拟仿真实验",notes = "查询是否能开启虚拟仿真实验")
R isOpenExercise(Integer userId);
@ApiOperation(value = "查询是否能开启教学实验",notes = "查询是否能开启教学实验")
R isOpenTeaching(Integer userId);
}

@ -2,11 +2,15 @@ package com.msdw.tms.controller;
import com.msdw.tms.api.EvaluationRecordControllerApi;
import com.msdw.tms.common.utils.R;
import com.msdw.tms.entity.FractionEntity;
import com.msdw.tms.entity.vo.EvaluationRecordDetailVO;
import com.msdw.tms.entity.vo.EvaluationRecordSubmitVO;
import com.msdw.tms.entity.vo.EvaluationRecordVO;
import com.msdw.tms.entity.vo.TMSEvaluationRecordVO;
import com.msdw.tms.service.EvaluationRecordService;
import com.msdw.tms.service.FractionEntityService;
import com.msdw.tms.service.QuestionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -28,8 +32,9 @@ public class EvaluationRecordController implements EvaluationRecordControllerApi
@Resource
private QuestionsService questionsService;
// @Override
@Autowired
private FractionEntityService fractionEntityService;
// @Override
// @GetMapping("/has_notmade")
// public R hasNotMadeEvaluation(Integer userId) {
// boolean b = evaluationRecordService.hasNotMadeEvaluation(userId);
@ -52,53 +57,28 @@ public class EvaluationRecordController implements EvaluationRecordControllerApi
@Override
@GetMapping("/start")
public R startEvaluation(@RequestParam(value = "userId") Integer userId) {
EvaluationRecordVO evaluationRecordVO = evaluationRecordService.startEvaluation(userId);
public R startEvaluation(@RequestParam(value = "userId") Integer userId,Integer type) {
TMSEvaluationRecordVO evaluationRecordVO = evaluationRecordService.startEvaluation(userId);
evaluationRecordVO.setTypes(type);
return R.ok().put("data", evaluationRecordVO);
}
@Override
@PostMapping("/previous")
public R previousQuestion(@RequestBody EvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException {
public R previousQuestion(@RequestBody TMSEvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException {
Integer evaluationRecordId = evaluationRecordVO.getId();
String userAnswer = evaluationRecordVO.getUserAnswer();
Integer currentQuestionSortNo = evaluationRecordVO.getCurrentQuestionSortNo();
EvaluationRecordVO recordVO = evaluationRecordService.convertQuestion(evaluationRecordId, currentQuestionSortNo, userAnswer, currentQuestionSortNo - 1);
TMSEvaluationRecordVO recordVO = evaluationRecordService.convertQuestion(evaluationRecordId, currentQuestionSortNo, userAnswer, currentQuestionSortNo - 1);
return R.ok().put("data", recordVO);
}
// 备份:上一题/下一题/提交
// @Override
// @GetMapping("/previous")
// public R previousQuestion(@RequestParam("evaluationRecordId") Integer evaluationRecordId,
// @RequestParam("currentQuestionSortNo") Integer currentQuestionSortNo,
// @RequestParam(value = "userAnswer", required = false) String userAnswer) throws ExecutionException, InterruptedException {
// EvaluationRecordVO evaluationRecordVO = evaluationRecordService.convertQuestion(evaluationRecordId, currentQuestionSortNo, userAnswer, currentQuestionSortNo - 1);
// return R.ok().put("data", evaluationRecordVO);
// }
// @Override
// @GetMapping("/next")
// public R nextQuestion(@RequestParam("evaluationRecordId") Integer evaluationRecordId,
// @RequestParam("currentQuestionSortNo") Integer currentQuestionSortNo,
// @RequestParam(value = "userAnswer", required = false) String userAnswer) throws ExecutionException, InterruptedException {
// EvaluationRecordVO evaluationRecordVO = evaluationRecordService.convertQuestion(evaluationRecordId, currentQuestionSortNo, userAnswer, currentQuestionSortNo + 1);
// return R.ok().put("data", evaluationRecordVO);
// }
// @Override
// @GetMapping("/submit")
// public R submitEvaluation(@RequestParam("evaluationRecordId") Integer evaluationRecordId,
// @RequestParam("currentQuestionSortNo") Integer currentQuestionSortNo,
// @RequestParam(value = "userAnswer", required = false) String userAnswer,
// @RequestParam("userId") Integer userId) throws ExecutionException, InterruptedException {
// EvaluationRecordSubmitVO recordSubmitVO = evaluationRecordService.submitEvaluation(evaluationRecordId, currentQuestionSortNo, userAnswer, userId);
// return R.ok().put("data", recordSubmitVO);
// }
@Override
@PostMapping("/next")
public R nextQuestion(@RequestBody EvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException {
public R nextQuestion(@RequestBody TMSEvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException {
Integer evaluationRecordId = evaluationRecordVO.getId();
String userAnswer = evaluationRecordVO.getUserAnswer();
Integer currentQuestionSortNo = evaluationRecordVO.getCurrentQuestionSortNo();
EvaluationRecordVO recordVO = evaluationRecordService.convertQuestion(evaluationRecordId, currentQuestionSortNo, userAnswer, currentQuestionSortNo + 1);
TMSEvaluationRecordVO recordVO = evaluationRecordService.convertQuestion(evaluationRecordId, currentQuestionSortNo, userAnswer, currentQuestionSortNo + 1);
return R.ok().put("data", recordVO);
}
@ -111,12 +91,19 @@ public class EvaluationRecordController implements EvaluationRecordControllerApi
@Override
@PostMapping("/submit")
public R submitEvaluation(@RequestBody EvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException {
public R submitEvaluation(@RequestBody TMSEvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException {
Integer evaluationRecordId = evaluationRecordVO.getId();
String userAnswer = evaluationRecordVO.getUserAnswer();
Integer currentQuestionSortNo = evaluationRecordVO.getCurrentQuestionSortNo();
Integer userId = evaluationRecordVO.getUserId();
Integer types = evaluationRecordVO.getTypes();
EvaluationRecordSubmitVO recordSubmitVO = evaluationRecordService.submitEvaluation(evaluationRecordId, currentQuestionSortNo, userAnswer, userId);
Integer totalScore = recordSubmitVO.getTotalScore();
FractionEntity fractionEntity = new FractionEntity();
FractionEntity fraction = fractionEntity.setUserId(userId).setFraction(totalScore).setTypes(types);
fractionEntityService.insertRecord(fraction);
return R.ok().put("data", recordSubmitVO);
}
@ -139,6 +126,146 @@ public class EvaluationRecordController implements EvaluationRecordControllerApi
return R.ok().put("data", openExperiment);
}
@Override
@GetMapping("/openExercise")
public R isOpenExercise(Integer userId){
Integer score = fractionEntityService.queryExerciseRecord(userId);
return R.ok();
}
@Override
@GetMapping("/openTeaching")
public R isOpenTeaching(Integer userId){
Integer score = fractionEntityService.queryTeachingRecord(userId);
return R.ok();
}
//// @Override
//// @GetMapping("/has_notmade")
//// public R hasNotMadeEvaluation(Integer userId) {
//// boolean b = evaluationRecordService.hasNotMadeEvaluation(userId);
//// return R.ok().put("data", b);
//// }
//
//// @Override
//// @GetMapping("/clean_time")
//// public R cleanRemainingTime(Integer userId) {
//// evaluationRecordService.cleanRemainingTime(userId);
//// return R.ok();
//// }
//
// @Override
// @GetMapping("/remaining")
// public R getEvaluationRemainingTime(Integer userId) {
// String remainingTime = questionsService.getEvaluationRemainingTime(userId);
// return R.ok().put("data", remainingTime);
// }
//
// @Override
// @GetMapping("/start")
// public R startEvaluation(@RequestParam(value = "userId") Integer userId,Integer type) {
// TMSEvaluationRecordVO evaluationRecordVO = evaluationRecordService.startEvaluation(userId);
// evaluationRecordVO.setType(type);
// return R.ok().put("data", evaluationRecordVO);
// }
//// @Override
//// @GetMapping("/start")
//// public R startEvaluation(@RequestParam(value = "userId") Integer userId) {
//// EvaluationRecordVO evaluationRecordVO = evaluationRecordService.startEvaluation(userId);
//// return R.ok().put("data", evaluationRecordVO);
//// }
//
// @Override
// @PostMapping("/previous")
// public R previousQuestion(@RequestBody EvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException {
// Integer evaluationRecordId = evaluationRecordVO.getId();
// String userAnswer = evaluationRecordVO.getUserAnswer();
// Integer currentQuestionSortNo = evaluationRecordVO.getCurrentQuestionSortNo();
// EvaluationRecordVO recordVO = evaluationRecordService.convertQuestion(evaluationRecordId, currentQuestionSortNo, userAnswer, currentQuestionSortNo - 1);
// return R.ok().put("data", recordVO);
// }
//// @Override
//// @PostMapping("/previous")
//// public R previousQuestion(@RequestBody EvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException {
//// Integer evaluationRecordId = evaluationRecordVO.getId();
//// String userAnswer = evaluationRecordVO.getUserAnswer();
//// Integer currentQuestionSortNo = evaluationRecordVO.getCurrentQuestionSortNo();
//// EvaluationRecordVO recordVO = evaluationRecordService.convertQuestion(evaluationRecordId, currentQuestionSortNo, userAnswer, currentQuestionSortNo - 1);
//// return R.ok().put("data", recordVO);
//// }
//// 备份:上一题/下一题/提交
//// @Override
//// @GetMapping("/previous")
//// public R previousQuestion(@RequestParam("evaluationRecordId") Integer evaluationRecordId,
//// @RequestParam("currentQuestionSortNo") Integer currentQuestionSortNo,
//// @RequestParam(value = "userAnswer", required = false) String userAnswer) throws ExecutionException, InterruptedException {
//// EvaluationRecordVO evaluationRecordVO = evaluationRecordService.convertQuestion(evaluationRecordId, currentQuestionSortNo, userAnswer, currentQuestionSortNo - 1);
//// return R.ok().put("data", evaluationRecordVO);
//// }
//// @Override
//// @GetMapping("/next")
//// public R nextQuestion(@RequestParam("evaluationRecordId") Integer evaluationRecordId,
//// @RequestParam("currentQuestionSortNo") Integer currentQuestionSortNo,
//// @RequestParam(value = "userAnswer", required = false) String userAnswer) throws ExecutionException, InterruptedException {
//// EvaluationRecordVO evaluationRecordVO = evaluationRecordService.convertQuestion(evaluationRecordId, currentQuestionSortNo, userAnswer, currentQuestionSortNo + 1);
//// return R.ok().put("data", evaluationRecordVO);
//// }
//// @Override
//// @GetMapping("/submit")
//// public R submitEvaluation(@RequestParam("evaluationRecordId") Integer evaluationRecordId,
//// @RequestParam("currentQuestionSortNo") Integer currentQuestionSortNo,
//// @RequestParam(value = "userAnswer", required = false) String userAnswer,
//// @RequestParam("userId") Integer userId) throws ExecutionException, InterruptedException {
//// EvaluationRecordSubmitVO recordSubmitVO = evaluationRecordService.submitEvaluation(evaluationRecordId, currentQuestionSortNo, userAnswer, userId);
//// return R.ok().put("data", recordSubmitVO);
//// }
// @Override
// @PostMapping("/next")
// public R nextQuestion(@RequestBody EvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException {
// Integer evaluationRecordId = evaluationRecordVO.getId();
// String userAnswer = evaluationRecordVO.getUserAnswer();
// Integer currentQuestionSortNo = evaluationRecordVO.getCurrentQuestionSortNo();
// EvaluationRecordVO recordVO = evaluationRecordService.convertQuestion(evaluationRecordId, currentQuestionSortNo, userAnswer, currentQuestionSortNo + 1);
// return R.ok().put("data", recordVO);
// }
//
// @Override
// @GetMapping("/not_made")
// public R selectNotMade(@RequestParam("evaluationRecordId") Integer evaluationRecordId) {
// String result = evaluationRecordService.selectNotMade(evaluationRecordId);
// return R.ok().put("data", result);
// }
//
// @Override
// @PostMapping("/submit")
// public R submitEvaluation(@RequestBody EvaluationRecordVO evaluationRecordVO) throws ExecutionException, InterruptedException {
// Integer evaluationRecordId = evaluationRecordVO.getId();
// String userAnswer = evaluationRecordVO.getUserAnswer();
// Integer currentQuestionSortNo = evaluationRecordVO.getCurrentQuestionSortNo();
// Integer userId = evaluationRecordVO.getUserId();
// EvaluationRecordSubmitVO recordSubmitVO = evaluationRecordService.submitEvaluation(evaluationRecordId, currentQuestionSortNo, userAnswer, userId);
// return R.ok().put("data", recordSubmitVO);
// }
//
// @Override
// @GetMapping("/detail")
// public R evaluationScoreDetail(Integer evaluationRecordId) throws ExecutionException, InterruptedException {
// EvaluationRecordDetailVO detailVO = evaluationRecordService.evaluationDetail(evaluationRecordId);
// return R.ok().put("data", detailVO);
// }
//
// /**
// * 查询是否能够开启实验
// * @param userId
// * @return
// */
// @Override
// @GetMapping("/can_experiment")
// public R isOpenExperiment(Integer userId) {
// boolean openExperiment = evaluationRecordService.isOpenExperiment(userId);
// return R.ok().put("data", openExperiment);
// }

@ -3,6 +3,7 @@ package com.msdw.tms.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.msdw.tms.entity.EvaluationRecordEntity;
import com.msdw.tms.entity.vo.EvaluationRecordVO;
import com.msdw.tms.entity.vo.TMSEvaluationRecordVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -17,6 +18,10 @@ import java.util.List;
*/
@Mapper
public interface EvaluationRecordDao extends BaseMapper<EvaluationRecordEntity> {
EvaluationRecordVO selectVOByInfo(@Param("evaluationRecordId") Integer evaluationRecordId,
TMSEvaluationRecordVO selectVOByInfo(@Param("evaluationRecordId") Integer evaluationRecordId,
@Param("questionSortNo") Integer questionSortNo);
// EvaluationRecordVO selectVOByInfo(@Param("evaluationRecordId") Integer evaluationRecordId,
// @Param("questionSortNo") Integer questionSortNo);
}

@ -0,0 +1,14 @@
package com.msdw.tms.dao;
import com.msdw.tms.entity.FractionEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface FractionEntityDao {
void insertRecord(FractionEntity fraction);
Integer queryExerciseRecord(Integer userId);
Integer queryTeachingRecord(Integer userId);
}

@ -0,0 +1,25 @@
package com.msdw.tms.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
@Data
@Accessors(chain = true)
@TableName("tms_evaluation_fraction")
public class FractionEntity implements Serializable {
//主键自增
@TableId(type = IdType.AUTO)
private Integer id;
//绑定用户id
private Integer userId;
//记录总分数
private Integer fraction;
//测评类型(1练习 2虚拟仿真 3教学)
private Integer types;
}

@ -0,0 +1,70 @@
package com.msdw.tms.entity.vo;
import lombok.Data;
/**
* 用户测评信息
*/
@Data
public class TMSEvaluationRecordVO {
/**
* 主键
*/
private Integer id;
/**
* 当前测评的用户的id
*/
private Integer userId;
/**
* 记录当前做到第几题用于刷新页面以后保持在当前题目默认开始时是第一题
*/
private Integer currentQuestionSortNo;
/**
* 总题目数量
*/
private Integer totalQuestionNum;
/**
* 题型
*/
private Integer questionType;
/**
* 题型名称
*/
private String questionTypeName;
/**
* 题干信息
*/
private String questionStem;
/**
* A选项内容
*/
private String optionA;
/**
* B选项内容
*/
private String optionB;
/**
* C选项内容
*/
private String optionC;
/**
* D选项内容
*/
private String optionD;
/**
* E选项内容
*/
private String optionE;
/**
* F选项内容
*/
private String optionF;
/**
* 用户答案
*/
private String userAnswer;
/**
* 测试类型
*/
private Integer types;
}

@ -2,9 +2,11 @@ package com.msdw.tms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.msdw.tms.entity.EvaluationRecordEntity;
import com.msdw.tms.entity.FractionEntity;
import com.msdw.tms.entity.vo.EvaluationRecordDetailVO;
import com.msdw.tms.entity.vo.EvaluationRecordSubmitVO;
import com.msdw.tms.entity.vo.EvaluationRecordVO;
import com.msdw.tms.entity.vo.TMSEvaluationRecordVO;
import java.util.concurrent.ExecutionException;
@ -16,10 +18,9 @@ import java.util.concurrent.ExecutionException;
* @date 2020-08-28 10:15:48
*/
public interface EvaluationRecordService extends IService<EvaluationRecordEntity> {
TMSEvaluationRecordVO startEvaluation(Integer userId);
EvaluationRecordVO startEvaluation(Integer userId);
EvaluationRecordVO convertQuestion(Integer evaluationRecordId,
TMSEvaluationRecordVO convertQuestion(Integer evaluationRecordId,
Integer currentQuestionSortNo,
String userAnswer,
Integer changeSortNo) throws ExecutionException, InterruptedException;
@ -37,6 +38,26 @@ public interface EvaluationRecordService extends IService<EvaluationRecordEntity
boolean isOpenExperiment(Integer userId);
// EvaluationRecordVO startEvaluation(Integer userId);
//
// EvaluationRecordVO convertQuestion(Integer evaluationRecordId,
// Integer currentQuestionSortNo,
// String userAnswer,
// Integer changeSortNo) throws ExecutionException, InterruptedException;
//
// EvaluationRecordSubmitVO submitEvaluation(Integer evaluationRecordId,
// Integer currentQuestionSortNo,
// String userAnswer,
// Integer userId) throws ExecutionException, InterruptedException;
//
// EvaluationRecordDetailVO evaluationDetail(Integer evaluationRecordId) throws ExecutionException, InterruptedException;
//
// String selectNotMade(Integer evaluationRecordId);
//
// void cleanRemainingTime(Integer userId);
//
// boolean isOpenExperiment(Integer userId);
// boolean hasNotMadeEvaluation(Integer userId);
}

@ -0,0 +1,12 @@
package com.msdw.tms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.msdw.tms.entity.FractionEntity;
public interface FractionEntityService {
void insertRecord(FractionEntity fraction);
Integer queryExerciseRecord(Integer userId);
Integer queryTeachingRecord(Integer userId);
}

@ -50,10 +50,9 @@ public class EvaluationRecordServiceImpl extends ServiceImpl<EvaluationRecordDao
ThreadPoolExecutor executor;
private String REMAINING_TINE_KEY = "REMAINING_TINE";
@Override
@Transactional
public EvaluationRecordVO startEvaluation(Integer userId) {
public TMSEvaluationRecordVO startEvaluation(Integer userId) {
//TODO 接口幂等性处理
//根据用户id和是否提交,查询测评记录信息
EvaluationRecordEntity one = this.getOne(new QueryWrapper<EvaluationRecordEntity>().eq("user_id", userId)
@ -89,7 +88,7 @@ public class EvaluationRecordServiceImpl extends ServiceImpl<EvaluationRecordDao
one = evaluationRecord;
}
EvaluationRecordVO evaluationRecordVO = this.getBaseMapper()
TMSEvaluationRecordVO evaluationRecordVO = this.getBaseMapper()
.selectVOByInfo(one.getId(), one.getCurrentQuestionSortNo());
evaluationRecordVO.setQuestionTypeName(getQuestionTypeName(evaluationRecordVO.getQuestionType()));
return evaluationRecordVO;
@ -144,7 +143,7 @@ public class EvaluationRecordServiceImpl extends ServiceImpl<EvaluationRecordDao
@Override
@Transactional
public EvaluationRecordVO convertQuestion(Integer evaluationRecordId,
public TMSEvaluationRecordVO convertQuestion(Integer evaluationRecordId,
Integer currentQuestionSortNo,
String userAnswer,
Integer changeSortNo) throws ExecutionException, InterruptedException {
@ -167,7 +166,7 @@ public class EvaluationRecordServiceImpl extends ServiceImpl<EvaluationRecordDao
// CompletableFuture<EvaluationRecordVO> future = CompletableFuture.supplyAsync(()
// -> this.getBaseMapper().selectVOByInfo(evaluationRecordId, changeSortNo), executor);
EvaluationRecordVO evaluationRecordVO = this.getBaseMapper().selectVOByInfo(evaluationRecordId, changeSortNo);
TMSEvaluationRecordVO evaluationRecordVO = this.getBaseMapper().selectVOByInfo(evaluationRecordId, changeSortNo);
// CompletableFuture.allOf(submitCurrentQuestionFuture, updateCurrentSortNoFuture, future).get();
@ -354,4 +353,308 @@ public class EvaluationRecordServiceImpl extends ServiceImpl<EvaluationRecordDao
evaluationRecordEntity.setId(evaluationRecordId);
this.updateById(evaluationRecordEntity);
}
// @Override
// @Transactional
// public EvaluationRecordVO startEvaluation(Integer userId) {
// //TODO 接口幂等性处理
// //根据用户id和是否提交,查询测评记录信息
// EvaluationRecordEntity one = this.getOne(new QueryWrapper<EvaluationRecordEntity>().eq("user_id", userId)
// .eq("evaluation_status", Constant.Submit.NOT_SUBMIT.getType()));
//
// if (one == null) {
// //随机抽取试题数据
// EvaluationVO evaluation = questionsService.randomQuestions();
//
// //保存测评记录
// EvaluationRecordEntity evaluationRecord = new EvaluationRecordEntity();
// evaluationRecord.setUserId(userId);
// evaluationRecord.setEvaluationStatus(Constant.Submit.NOT_SUBMIT.getType());
// evaluationRecord.setTotalQuestionNum(evaluation.getQuestionNum());
// evaluationRecord.setCurrentQuestionSortNo(1);
// evaluationRecord.setStartTime(new Date());
// this.save(evaluationRecord);
//
// List<EvaluationQuestionEntity> evaluationQuestionList = evaluation.getQuestions().stream().map(question -> {
// EvaluationQuestionEntity evaluationQuestionEntity = new EvaluationQuestionEntity();
// evaluationQuestionEntity.setEvaluationRecordId(evaluationRecord.getId());
// evaluationQuestionEntity.setQuestionId(question);
// return evaluationQuestionEntity;
// }).collect(Collectors.toList());
//
// List<Integer> list = averageValue(evaluation.getQuestionNum());
// for (int i = 0; i < list.size(); i++) {
// evaluationQuestionList.get(i).setQuestionSortNo(i + 1);
// evaluationQuestionList.get(i).setQuestionPoints(list.get(i));
// }
// evaluationQuestionService.saveBatch(evaluationQuestionList);
//
// one = evaluationRecord;
// }
//
// EvaluationRecordVO evaluationRecordVO = this.getBaseMapper()
// .selectVOByInfo(one.getId(), one.getCurrentQuestionSortNo());
// evaluationRecordVO.setQuestionTypeName(getQuestionTypeName(evaluationRecordVO.getQuestionType()));
// return evaluationRecordVO;
// }
//
// private String getQuestionTypeName(Integer questionType) {
// String questionTypeName = "";
// //处理试题类型
// if (questionType.equals(Constant.QuestionType.SINGLE_CHOICE.getType())) {
// //单选题
// questionTypeName = Constant.QuestionType.SINGLE_CHOICE.getDesc();
// } else if (questionType.equals(Constant.QuestionType.MULTIPLE_CHOICE.getType())) {
// //多选题
// questionTypeName = Constant.QuestionType.MULTIPLE_CHOICE.getDesc();
// } else if (questionType.equals(Constant.QuestionType.TRUE_OR_FALSE.getType())) {
// //判断题
// questionTypeName = Constant.QuestionType.TRUE_OR_FALSE.getDesc();
// } else {
// ExceptionCast.cast(CommonCode.QUESTIONTYPE_INVALID);
// }
// return questionTypeName;
// }
//
// /**
// * 平均分配分值
// *
// * @param number 判分点数量
// * @return
// */
// private List<Integer> averageValue(Integer number) {
// if (number == null || number == 0) {
// ExceptionCast.cast(CommonCode.EVALUATION_QUESTION_NUM_INVALID);
// }
// Integer score = 100 / number;
// List<Integer> list = new ArrayList<>();
// if (100 % number == 0) {
// for (int i = 0; i < number; i++) {
// list.add(score);
// }
// } else {
// int n;
// for (int i = 0; i < number; i++) {
// list.add(score);
// }
// for (int i = 100 % number; i > 0; i--) {
// n = score + 1;
// list.set(i, n);
// }
// }
// return list;
// }
//
// @Override
// @Transactional
// public EvaluationRecordVO convertQuestion(Integer evaluationRecordId,
// Integer currentQuestionSortNo,
// String userAnswer,
// Integer changeSortNo) throws ExecutionException, InterruptedException {
// if (currentQuestionSortNo < 1
// || currentQuestionSortNo > this.getById(evaluationRecordId).getTotalQuestionNum()
// || changeSortNo < 1
// || changeSortNo > this.getById(evaluationRecordId).getTotalQuestionNum()) {
// ExceptionCast.cast(CommonCode.INVALID_PARAM);
// }
// //提交当前试题信息
// submitCurrentQuestion(evaluationRecordId, currentQuestionSortNo, userAnswer);
//// CompletableFuture<Void> submitCurrentQuestionFuture = CompletableFuture.runAsync(()
//// -> submitCurrentQuestion(evaluationRecordId, currentQuestionSortNo, userAnswer), executor);
//
// //修改测评记录表当前题目顺序号
// updateCurrentSortNo(changeSortNo, evaluationRecordId);
//// CompletableFuture<Void> updateCurrentSortNoFuture = CompletableFuture.runAsync(()
//// -> updateCurrentSortNo(changeSortNo, evaluationRecordId), executor);
//
//// CompletableFuture<EvaluationRecordVO> future = CompletableFuture.supplyAsync(()
//// -> this.getBaseMapper().selectVOByInfo(evaluationRecordId, changeSortNo), executor);
//
// EvaluationRecordVO evaluationRecordVO = this.getBaseMapper().selectVOByInfo(evaluationRecordId, changeSortNo);
//
//// CompletableFuture.allOf(submitCurrentQuestionFuture, updateCurrentSortNoFuture, future).get();
//
//// EvaluationRecordVO evaluationRecordVO = future.get();
// //查询下一题信息
// evaluationRecordVO.setQuestionTypeName(getQuestionTypeName(evaluationRecordVO.getQuestionType()));
// return evaluationRecordVO;
// }
//
// @Override
// public EvaluationRecordSubmitVO submitEvaluation(Integer evaluationRecordId,
// Integer currentQuestionSortNo,
// String userAnswer,
// Integer userId) throws ExecutionException, InterruptedException {
// //清除redis中的倒计时
// CompletableFuture<Void> deleteKeyFuture = CompletableFuture.runAsync(() -> {
// String key = REMAINING_TINE_KEY + userId;
// redisTemplate.delete(key);
// }, executor);
//
// CompletableFuture<Void> submitCurrentQuestionFuture = CompletableFuture.runAsync(()
// -> submitCurrentQuestion(evaluationRecordId, currentQuestionSortNo, userAnswer), executor);
//
// //修改提交时间和测评记录状态
// CompletableFuture<Void> updateEvaluationFuture = CompletableFuture.runAsync(() -> {
// EvaluationRecordEntity entity = new EvaluationRecordEntity();
// entity.setId(evaluationRecordId);
// entity.setEvaluationStatus(Constant.Submit.SUBMIT.getType());
// entity.setSubmitTime(new Date());
// this.updateById(entity);
// }, executor);
//
// EvaluationRecordSubmitVO submitVO = new EvaluationRecordSubmitVO();
//
// //查询总成绩
// CompletableFuture<Void> sumScoreFuture = CompletableFuture.runAsync(() -> {
// int sumScore = evaluationQuestionDao.sumScore(evaluationRecordId);
// //得分
// submitVO.setTotalScore(sumScore);
// //是否通过
// submitVO.setIsPassed(sumScore > Constant.PASSING_SCORE ? Constant.EVALUATIONN_PASSED : Constant.EVALUATIONN_NOT_PASSED);
// }, executor);
//
// CompletableFuture<EvaluationRecordEntity> getByIdFuture = CompletableFuture.supplyAsync(() -> {
// EvaluationRecordEntity evaluationRecord = this.getById(evaluationRecordId);
// BeanUtils.copyProperties(evaluationRecord, submitVO);
// return evaluationRecord;
// }, executor);
//
// CompletableFuture<Void> countFuture = getByIdFuture.thenAcceptAsync((res) -> {
// QueryWrapper<EvaluationQuestionEntity> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("evaluation_record_id", evaluationRecordId)
// .eq("is_ture", Constant.QuestionIsTure.TRUE.getType());
// //查询答对几题
// int count = evaluationQuestionService.count(queryWrapper);
// //答对几道
// submitVO.setCorrectQuestionNum(count);
// //正确率
// // 创建一个数值格式化对象
// NumberFormat numberFormat = NumberFormat.getInstance();
// // 设置精确到小数点后2位
// numberFormat.setMaximumFractionDigits(2);
// submitVO.setCorrectRate(numberFormat.format((float) count / (float) res.getTotalQuestionNum() * 100) + "%");
//
// }, executor);
//
// CompletableFuture.allOf(deleteKeyFuture, submitCurrentQuestionFuture, updateEvaluationFuture,
// sumScoreFuture, getByIdFuture, countFuture).get();
//
// return submitVO;
// }
//
// @Override
// public EvaluationRecordDetailVO evaluationDetail(Integer evaluationRecordId) throws ExecutionException, InterruptedException {
// EvaluationRecordDetailVO evaluationRecordDetailVO = new EvaluationRecordDetailVO();
//
// CompletableFuture<Void> sumScoreFuture = CompletableFuture.runAsync(() -> {
// //查询总成绩
// int sumScore = evaluationQuestionDao.sumScore(evaluationRecordId);
// evaluationRecordDetailVO.setTotalScore(sumScore);
// }, executor);
//
// CompletableFuture<Void> evaluationDetailVOSFuture = CompletableFuture.runAsync(() -> {
// List<EvaluationDetailVO> evaluationDetailVOS = evaluationQuestionDao.selectDetailByInfo(evaluationRecordId);
// evaluationRecordDetailVO.setEvaluationDetailVOS(evaluationDetailVOS);
// }, executor);
//
// CompletableFuture.allOf(sumScoreFuture, evaluationDetailVOSFuture).get();
// return evaluationRecordDetailVO;
// }
//
// @Override
// public String selectNotMade(Integer evaluationRecordId) {
//
// QueryWrapper<EvaluationQuestionEntity> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("evaluation_record_id", evaluationRecordId)
// .eq("question_status", Constant.QuestionStatus.NOT_MADE.getType());
//
// List<EvaluationQuestionEntity> list = evaluationQuestionService.list(queryWrapper);
// List<Integer> collect = list.stream().map(EvaluationQuestionEntity::getQuestionSortNo).collect(Collectors.toList());
// if (collect.size() == 0) {
// return "已完成全部题目";
// }
// return "还有以下题目未完成" + collect.toString();
// }
//
// @Override
// public void cleanRemainingTime(Integer userId) {
// //清除redis中的倒计时
// String key = REMAINING_TINE_KEY + userId;
// redisTemplate.delete(key);
// }
//
// @Override
// public boolean isOpenExperiment(Integer userId) {
// List<Integer> list = evaluationQuestionDao.sumScoreListByUserId(userId);
// if (list != null && list.size() > 0) {
// for (Integer integer : list) {
// if (integer > Constant.PASSING_SCORE) {
// return true;
// }
// }
// }
// return false;
// }
//
//// @Override
//// public boolean hasNotMadeEvaluation(Integer userId) {
//// //先判断数据库是否已经有了此次测评
//// //如果有,继续,如果没有,重新开始
//// ValueOperations<String, String> ops = redisTemplate.opsForValue();
//// String key = REMAINING_TINE_KEY + userId;
//// if (StringUtils.isNotEmpty(ops.get(key))) {
//// //继续上次
////
//// }
////
//// return false;
//// }
//
// //提交当前试题,并修改当前测评记录表
// private void submitCurrentQuestion(Integer evaluationRecordId,
// Integer currentQuestionSortNo,
// String userAnswer) {
// //1、根据当前传递的evaluationRecordId和currentQuestionSortNo查询当前试题
// EvaluationQuestionVO evaluationQuestionVO = evaluationQuestionDao.selectByInfo(evaluationRecordId, currentQuestionSortNo);
// if (evaluationQuestionVO == null) {
// ExceptionCast.cast(CommonCode.INVALID_PARAM);
// }
// // 题目分值
// Integer questionPoints = evaluationQuestionVO.getQuestionPoints();
// //正确答案
// String answer = evaluationQuestionVO.getAnswer();
// //修改当前试题状态
// //记录用户的答案
// //判断当前试题正误
// //记录试题得分
// EvaluationQuestionEntity evaluationQuestion = new EvaluationQuestionEntity();
// evaluationQuestion.setId(evaluationQuestionVO.getId());
// evaluationQuestion.setUserAnswer(userAnswer);
// //如果用户答案为空,则设置状态为未作,设为错,得分设为0
// if (StringUtils.isEmpty(userAnswer)) {
// evaluationQuestion.setQuestionStatus(Constant.QuestionStatus.NOT_MADE.getType());
// evaluationQuestion.setIsTure(Constant.QuestionIsTure.FALSE.getType());
// evaluationQuestion.setQuestionScore(0);
// } else {
// evaluationQuestion.setQuestionStatus(Constant.QuestionStatus.MADE.getType());
// if (!answer.equals(userAnswer)) {
// evaluationQuestion.setIsTure(Constant.QuestionIsTure.FALSE.getType());
// evaluationQuestion.setQuestionScore(0);
// } else {
// evaluationQuestion.setIsTure(Constant.QuestionIsTure.TRUE.getType());
// evaluationQuestion.setQuestionScore(questionPoints);
// }
// }
// evaluationQuestionDao.updateById(evaluationQuestion);
//
// }
//
// private void updateCurrentSortNo(Integer changeSortNo, Integer evaluationRecordId) {
// //修改测评记录表
// EvaluationRecordEntity evaluationRecordEntity = new EvaluationRecordEntity();
// evaluationRecordEntity.setCurrentQuestionSortNo(changeSortNo);
// evaluationRecordEntity.setId(evaluationRecordId);
// this.updateById(evaluationRecordEntity);
// }
}

@ -0,0 +1,34 @@
package com.msdw.tms.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.msdw.tms.dao.FractionEntityDao;
import com.msdw.tms.entity.FractionEntity;
import com.msdw.tms.service.FractionEntityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class FractionEntityServiceImpl implements FractionEntityService {
@Autowired
private FractionEntityDao fractionMapper;
@Override
public void insertRecord(FractionEntity fraction) {
fractionMapper.insertRecord(fraction);
}
@Override
public Integer queryExerciseRecord(Integer userId) {
Integer score = fractionMapper.queryExerciseRecord(userId);
return score;
}
@Override
public Integer queryTeachingRecord(Integer userId) {
Integer score = fractionMapper.queryTeachingRecord(userId);
return score;
}
}

@ -14,7 +14,7 @@
<result property="submitTime" column="submit_time"/>
</resultMap>
<select id="selectVOByInfo" resultType="com.msdw.tms.entity.vo.EvaluationRecordVO">
<select id="selectVOByInfo" resultType="com.msdw.tms.entity.vo.TMSEvaluationRecordVO">
SELECT
er.id,
er.user_id,

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.msdw.tms.dao.FractionEntityDao">
<insert id="insertRecord" parameterType="int">
INSERT INTO tms_evaluation_fraction(types,fraction,userId) VALUES (#{types},#{fraction},#{userId})
</insert>
<select id="queryExerciseRecord" resultType="int">
SELECT MAX(fraction) FROM tms_evaluation_fraction WHERE userId = #{userId} AND types = 2
</select>
<select id="queryTeachingRecord" resultType="int">
SELECT MAX(fraction) FROM tms_evaluation_fraction WHERE userId = #{userId} AND types = 3
</select>
</mapper>
Loading…
Cancel
Save