Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
8acadcd71f
@ -18,6 +18,7 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/api/v2/paper")
|
||||
public class PaperUserController {
|
||||
|
||||
@Autowired
|
||||
private PaperUserService paperUserService;
|
||||
@Autowired
|
||||
@ -35,7 +36,8 @@ public class PaperUserController {
|
||||
* @param pcId 试卷蓝图id
|
||||
*/
|
||||
@PostMapping("/{pcId}")
|
||||
public CreatePaperRspVo createPaper(@PathVariable("pcId") Long pcId, @RequestAttribute AccountVO user) {
|
||||
public CreatePaperRspVo createPaper(@PathVariable("pcId") Long pcId,
|
||||
@RequestAttribute AccountVO user) {
|
||||
return this.paperUserCreateService.createPaper(pcId, user);
|
||||
}
|
||||
|
||||
@ -45,31 +47,35 @@ public class PaperUserController {
|
||||
* @param puId 用户试卷id
|
||||
*/
|
||||
@GetMapping("/user/{puId}")
|
||||
public PaperUserWholeVo findPaperUser(@PathVariable("puId") Long puId, @RequestAttribute AccountVO user) {
|
||||
public PaperUserWholeVo findPaperUser(@PathVariable("puId") Long puId,
|
||||
@RequestAttribute AccountVO user) {
|
||||
return this.paperUserService.findPaperUser(puId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 用户交卷
|
||||
*
|
||||
* @param puId 用户试卷id
|
||||
*/
|
||||
@PostMapping("/user/{puId}/submit")
|
||||
public PaperSubmitRspVo paperSubmit(@PathVariable("puId") Long puId,@RequestAttribute AccountVO user) {
|
||||
return this.paperUserService.paperSubmit(puId);
|
||||
public PaperSubmitRspVo paperSubmit(@PathVariable("puId") Long puId,
|
||||
@RequestAttribute AccountVO user) {
|
||||
return this.paperUserService.paperSubmit(puId, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载用户试卷试题
|
||||
*
|
||||
* @param groupType 试卷试题大类型:1-理论题,2-实训题
|
||||
* @param qId 试题id
|
||||
* @param puId 试卷id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/user/question/{groupType}/{qId}/{puId}")
|
||||
public PaperQuestionLoadRspVo loadQuestion(@PathVariable("groupType") Integer groupType, @PathVariable("qId") Long qId,@PathVariable("puId") Long puId, @RequestAttribute AccountVO user) {
|
||||
public PaperQuestionLoadRspVo loadQuestion(@PathVariable("groupType") Integer groupType,
|
||||
@PathVariable("qId") Long qId, @PathVariable("puId") Long puId,
|
||||
@RequestAttribute AccountVO user) {
|
||||
PaperQType.GroupType pgType = PaperQType.GroupType.getItem(groupType);
|
||||
return this.paperUserLoadQuestionService.loadQuestion(pgType, qId, puId, user);
|
||||
}
|
||||
@ -77,11 +83,11 @@ public class PaperUserController {
|
||||
/**
|
||||
* 用户提交答案
|
||||
* <p>
|
||||
* 对于理论题:用户完成一道题提交一道题的答案;<br>
|
||||
* 对于实训题:用户完成实训操作后,由实训系统自己评判实训是否成功完成,前端提交实训是否成功完成的结果即可。
|
||||
* 对于理论题:用户完成一道题提交一道题的答案;<br> 对于实训题:用户完成实训操作后,由实训系统自己评判实训是否成功完成,前端提交实训是否成功完成的结果即可。
|
||||
*/
|
||||
@PostMapping("/user/question/answer")
|
||||
public PaperSubmitAnswerRspVo submitAnswer(@RequestBody PaperSubmitAnswerReqVo req, @RequestAttribute AccountVO user) {
|
||||
public PaperSubmitAnswerRspVo submitAnswer(@RequestBody PaperSubmitAnswerReqVo req,
|
||||
@RequestAttribute AccountVO user) {
|
||||
return this.paperUserSubmitAnswerService.submitAnswer(req, user);
|
||||
}
|
||||
|
||||
@ -97,12 +103,14 @@ public class PaperUserController {
|
||||
* 查看某个班级的某个试卷蓝图的所有学生试卷
|
||||
*/
|
||||
@GetMapping("/user/page")
|
||||
public PageVO<PageUserDetailVO> findPaperUserByPageForClass(@ModelAttribute PageUserDetailQuery req) {
|
||||
public PageVO<PageUserDetailVO> findPaperUserByPageForClass(
|
||||
@ModelAttribute PageUserDetailQuery req) {
|
||||
return this.paperUserFindPageService.findPaperUserByPageForClass(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看某个班级的某个试卷蓝图的所有学生试卷 (柱状图)
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@ -118,8 +126,7 @@ public class PaperUserController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看组织下某个类型题的数量
|
||||
* 参数 tags 目前只支持单个
|
||||
* 查看组织下某个类型题的数量 参数 tags 目前只支持单个
|
||||
*/
|
||||
@PostMapping("/question/count")
|
||||
public Long findCountForQuestion(@RequestBody FindCountForQuestionReqVo req) {
|
||||
|
@ -3,11 +3,13 @@ package club.joylink.rtss.services.paper;
|
||||
import club.joylink.rtss.constants.BusinessConsts;
|
||||
import club.joylink.rtss.dao.PublishedTraining2DAO;
|
||||
import club.joylink.rtss.dao.paper.*;
|
||||
import club.joylink.rtss.entity.UserExam;
|
||||
import club.joylink.rtss.entity.paper.*;
|
||||
import club.joylink.rtss.entity.paper.question.PaperQuestion;
|
||||
import club.joylink.rtss.entity.paper.question.PaperQuestionExample;
|
||||
import club.joylink.rtss.entity.training2.PublishedTraining2;
|
||||
import club.joylink.rtss.entity.training2.PublishedTraining2Example;
|
||||
import club.joylink.rtss.event.UserExamRecordEvent;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.exception.PaperExceptionAssert;
|
||||
import club.joylink.rtss.services.training2.Training2PublishService;
|
||||
@ -43,6 +45,7 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PaperUserService {
|
||||
|
||||
@Autowired
|
||||
private PaperCompositionDAO compositionDAO;
|
||||
@Autowired
|
||||
@ -64,18 +67,22 @@ public class PaperUserService {
|
||||
|
||||
/**
|
||||
* 获取理论或实操的所有标签
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
public Collection<String> findAllLabel(FindCountForQuestionReqVo req) {
|
||||
if (req.getGroupType() == PaperQType.GroupType.Common) {
|
||||
return paperQuestionService.findAllLable(req.getOrgId(),req.getSubType().name().toLowerCase());
|
||||
return paperQuestionService.findAllLable(req.getOrgId(),
|
||||
req.getSubType().name().toLowerCase());
|
||||
} else if (PaperQType.GroupType.Training.equals(req.getGroupType())) {
|
||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(req.getSubType() == PaperQType.SubType.Scene,"不支持此操作");
|
||||
return this.training2PublishService.findAllLabel(req.getMapId(),req.getOrgId(),req.getSubType().name().toUpperCase(),req.getTrainingClient());
|
||||
return this.training2PublishService.findAllLabel(req.getMapId(), req.getOrgId(),
|
||||
req.getSubType().name().toUpperCase(), req.getTrainingClient());
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组织某个类型题的数量
|
||||
*/
|
||||
@ -87,11 +94,13 @@ public class PaperUserService {
|
||||
return paperQuestionService.queryCount(req.getOrgId(), theoryType, tagStr);
|
||||
} else if (PaperQType.GroupType.Training.equals(req.getGroupType())) {
|
||||
// PaperExceptionAssert.PdValid.assertTrue(!PaperQType.GroupType.Training.equals(groupType),"不支持查询实训题数量");
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(req.getSubType() == PaperQType.SubType.Scene,"不支持此操作");
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(
|
||||
req.getSubType() == PaperQType.SubType.Scene, "不支持此操作");
|
||||
return training2PublishService.queryCountForLabel(req);
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户试卷完整信息
|
||||
*
|
||||
@ -109,7 +118,8 @@ public class PaperUserService {
|
||||
PaperUserWholeVo rsp = new PaperUserWholeVo();
|
||||
rsp.setComposition(PaperCompositionConvertor.convert(composition, ruleList));
|
||||
rsp.setPaper(PaperUserConvertor.convert(paper));
|
||||
rsp.setQuestionList(userQuestionList.stream().map(PaperUserQuestionConvertor::convert).collect(Collectors.toList()));
|
||||
rsp.setQuestionList(userQuestionList.stream().map(PaperUserQuestionConvertor::convert)
|
||||
.collect(Collectors.toList()));
|
||||
rsp.setSystemTime(System.currentTimeMillis());
|
||||
return rsp;
|
||||
}
|
||||
@ -157,7 +167,7 @@ public class PaperUserService {
|
||||
* @param puId 用户试卷id
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public PaperSubmitRspVo paperSubmit(Long puId) {
|
||||
public PaperSubmitRspVo paperSubmit(Long puId, AccountVO user) {
|
||||
PaperUser paper = paperUserDAO.selectByPrimaryKey(puId);
|
||||
PaperExceptionAssert.PuExisted.assertNotNull(paper, "该用户的试卷不存在,puId = " + puId);
|
||||
PaperExceptionAssert.PuStart.assertNotNull(paper.getStartTime(), "用户未开始答题");
|
||||
@ -167,7 +177,8 @@ public class PaperUserService {
|
||||
//统计最终结果
|
||||
PaperComposition composition = compositionDAO.selectByPrimaryKey(paper.getPcId());
|
||||
List<PaperRule> ruleList = compositionService.findRuleByPcId(paper.getPcId());
|
||||
Map<Long, PaperRule> ruleIdMap = ruleList.stream().collect(Collectors.toMap(PaperRule::getId,Function.identity()));
|
||||
Map<Long, PaperRule> ruleIdMap = ruleList.stream()
|
||||
.collect(Collectors.toMap(PaperRule::getId, Function.identity()));
|
||||
|
||||
List<PaperUserQuestion> userQuestionList = findUserSortedQuestions(puId);
|
||||
int scoreCommon = 0;
|
||||
@ -178,9 +189,11 @@ public class PaperUserService {
|
||||
|
||||
switch (PaperQType.GroupType.getItem(uq.getType())) {
|
||||
case Common:
|
||||
scoreCommon += calculateCommonScore(uq, rule);break;
|
||||
scoreCommon += calculateCommonScore(uq, rule);
|
||||
break;
|
||||
case Training:
|
||||
scoreTraining += calculateTrainingScore(uq, rule);break;
|
||||
scoreTraining += calculateTrainingScore(uq, rule);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,6 +214,11 @@ public class PaperUserService {
|
||||
rsp.setCommonScore(scoreCommon);
|
||||
rsp.setTrainingScore(scoreTraining);
|
||||
rsp.setPassScore(composition.getPassScore());
|
||||
// UserExam ue = new UserExam();
|
||||
// ue.setExamId();
|
||||
// ue.setUserId(user.getAccount());
|
||||
//TODO 需要将 UserExam 发送 {@link UserExamService.submit 方法}
|
||||
// this.applicationContext.publishEvent(new UserExamRecordEvent(userExam));
|
||||
return rsp;
|
||||
}
|
||||
|
||||
@ -218,7 +236,8 @@ public class PaperUserService {
|
||||
if (score >= sumScore) {
|
||||
return ruleScore;
|
||||
}
|
||||
return new BigDecimal((score / sumScore) * ruleScore).setScale(0,RoundingMode.HALF_UP).intValue();
|
||||
return new BigDecimal((score / sumScore) * ruleScore).setScale(0, RoundingMode.HALF_UP)
|
||||
.intValue();
|
||||
|
||||
/*double t = score / sumScore;
|
||||
if(t <=0.5){
|
||||
@ -231,22 +250,24 @@ public class PaperUserService {
|
||||
* 获取题的最终得分
|
||||
*/
|
||||
private int calculateTrainingScore(PaperUserQuestion puq, PaperRule rule) {
|
||||
if(Objects.equals(puq.getSubType(), PaperQType.SubType.Single.getValue()) && PaperQuestionState.Right.equals(PaperQuestionState.getItem(puq.getState()))){
|
||||
if (Objects.equals(puq.getSubType(), PaperQType.SubType.Single.getValue())
|
||||
&& PaperQuestionState.Right.equals(PaperQuestionState.getItem(puq.getState()))) {
|
||||
return rule.getScore();
|
||||
} else if (Objects.equals(puq.getSubType(), PaperQType.SubType.Scene.getValue())) {
|
||||
if (Strings.isNullOrEmpty(puq.getTmpAnswer())) {
|
||||
return 0;
|
||||
}
|
||||
PaperSubmitAnswerReqVo.AnswerDetail answerDetail = JsonUtils.read(puq.getTmpAnswer(),PaperSubmitAnswerReqVo.AnswerDetail.class);
|
||||
PaperSubmitAnswerReqVo.AnswerDetail answerDetail = JsonUtils.read(puq.getTmpAnswer(),
|
||||
PaperSubmitAnswerReqVo.AnswerDetail.class);
|
||||
int sumScore = answerDetail.getSumScore();
|
||||
double totalScore = answerDetail.getTrainDetail().stream().mapToDouble(PaperTrainAnswerDetail::getScore).sum();
|
||||
double totalScore = answerDetail.getTrainDetail().stream()
|
||||
.mapToDouble(PaperTrainAnswerDetail::getScore).sum();
|
||||
return getPercentage(totalScore, sumScore, rule.getScore());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户试卷试题(已排序)
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user