Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-zhouyin

This commit is contained in:
tiger_zhou 2022-10-17 08:54:41 +08:00
commit 5f08745963
5 changed files with 100 additions and 22 deletions

View File

@ -40,20 +40,24 @@ public class PaperUserController {
/**
* 获取用户试卷完整信息
*
* @param puId 用户试卷id
*/
@GetMapping("/user/{puId}")
public PaperUserWholeVo findPaperUser(@PathVariable("puId") Long puId, @RequestAttribute AccountVO user) {
return this.paperUserService.findPaperUser(puId);
}
/**
* 删除用户试卷
*
* @param puId 用户试卷id
*/
@DeleteMapping("/user/{puId}")
public void deletePaperUser(@PathVariable("puId") Long puId, @RequestAttribute AccountVO user){
public void deletePaperUser(@PathVariable("puId") Long puId, @RequestAttribute AccountVO user) {
this.paperUserService.deletePaperUser(puId);
}
/**
* 开始答题
*
@ -101,29 +105,41 @@ public class PaperUserController {
* 分页查询某个试卷蓝图的所有用户试卷基本信息
*/
@PostMapping("/user/page/composition")
public PageVO<PaperUserInfoVo>findPaperUserByPage(@RequestBody FindPaperUserForCompositionReqVo req, @RequestAttribute AccountVO user){
public PageVO<PaperUserInfoVo> findPaperUserByPage(@RequestBody FindPaperUserForCompositionReqVo req, @RequestAttribute AccountVO user) {
return this.paperUserFindPageService.findPaperUserByPage(req);
}
/**
* 查看某个班级的某个试卷蓝图的所有学生试卷
*/
@PostMapping("/user/page/class")
public PageVO<PaperUserInfoVo>findPaperUserByPageForClass(@RequestBody FindPaperUserForClassReqVo req, @RequestAttribute AccountVO user){
public PageVO<PaperUserInfoVo> findPaperUserByPageForClass(@RequestBody FindPaperUserForClassReqVo req, @RequestAttribute AccountVO user) {
return this.paperUserFindPageService.findPaperUserByPageForClass(req);
}
/**
* 查看某个账户的某个试卷蓝图的用户试卷
*/
@PostMapping("/user/list/account")
public List<PaperUserInfoVo> findPaperUserForAccount(@RequestBody FindPaperUserForAccountReqVo req, @RequestAttribute AccountVO user){
public List<PaperUserInfoVo> findPaperUserForAccount(@RequestBody FindPaperUserForAccountReqVo req, @RequestAttribute AccountVO user) {
return this.paperUserFindPageService.findPaperUserForAccount(req);
}
/**
* 查看组织的某个账户的某个试卷蓝图的用户试卷
*/
@PostMapping("/{orgId}/user/list/account")
public List<PaperUserInfoVo> findOrgPaperUserForAccount(@PathVariable("orgId") Long orgId,@RequestBody FindPaperUserForAccountReqVo req, @RequestAttribute AccountVO user){
public List<PaperUserInfoVo> findOrgPaperUserForAccount(@PathVariable("orgId") Long orgId, @RequestBody FindPaperUserForAccountReqVo req, @RequestAttribute AccountVO user) {
req.setOrgId(orgId);
return this.paperUserFindPageService.findPaperUserForAccount(req);
}
/**
* 查看组织下某个类型题的数量
*/
@PostMapping("/{orgId}/question/count")
public Long findCountForQuestion(@PathVariable("orgId") Long orgId, @RequestBody FindCountForQuestionReqVo req) {
req.setOrgId(orgId);
return this.paperUserService.findCountForQuestion(req.getOrgId(), req.getGroupType(), req.getSubType(), req.getTags());
}
}

View File

@ -194,11 +194,11 @@ public class PaperUserCreateService {
//
PaperQuestionExample questionExample = new PaperQuestionExample();
if (null == tagArray) {
questionExample.createCriteria().andOrgIdEqualTo(pc.getOrgId()).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType)).andIsDelEqualTo(0);
questionExample.createCriteria().andOrgIdEqualTo(pc.getOrgId()).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType).name()).andIsDelEqualTo(0);
} else {
for (String tag : tagArray) {
questionExample.or().andOrgIdEqualTo(pc.getOrgId()).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType)).andIsDelEqualTo(0).andTagsLike(String.format("%%%s%%", tag));
questionExample.or().andOrgIdEqualTo(pc.getOrgId()).andTypeEqualTo(this.paperUserService.getPaperQuestionType(subType).name()).andIsDelEqualTo(0).andTagsLike(String.format("%%%s%%", tag));
}
}

View File

@ -1,5 +1,6 @@
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.paper.*;
@ -48,7 +49,33 @@ public class PaperUserService {
private PaperQuestionDAO pagerQuestionDAO;
@Autowired
private PublishedTraining2DAO trainingDAO;
@Autowired
private PagerQuestionService paperQuestionService;
/**
* 获取组织某个类型题的数量
*/
@Transactional(readOnly = true)
public Long findCountForQuestion(Long orgId,PaperQType.GroupType groupType,PaperQType.SubType subType,List<String>tags){
if(PaperQType.GroupType.Common.equals(groupType)){
String tagStr=null;
if(!CollectionUtils.isEmpty(tags)){
StringBuilder sb = new StringBuilder();
tags.forEach(tag->{
if(sb.length()>0){
sb.append(",").append(tag);
}else{
sb.append(tag);
}
});
tagStr=sb.toString();
}
BusinessConsts.TheoryType theoryType = this.getPaperQuestionType(subType);
return paperQuestionService.queryCount(orgId,theoryType,tagStr);
}else if(PaperQType.GroupType.Training.equals(groupType)){
PaperExceptionAssert.PdValid.assertTrue(!PaperQType.GroupType.Training.equals(groupType),"不支持查询实训题数量");
}
return 0L;
}
/**
* 获取用户试卷完整信息
*
@ -233,25 +260,26 @@ public class PaperUserService {
}
public PaperQType.SubType getPaperQuestionType(PaperQuestion question) {
switch (question.getType()) {
case "select":
BusinessConsts.TheoryType theoryType = BusinessConsts.TheoryType.valueOf(question.getType());
switch (theoryType) {
case select:
return PaperQType.SubType.Select;
case "judge":
case judge:
return PaperQType.SubType.Judge;
case "multi":
case multi:
return PaperQType.SubType.Multi;
}
return null;
}
public String getPaperQuestionType(PaperQType.SubType qt) {
public BusinessConsts.TheoryType getPaperQuestionType(PaperQType.SubType qt) {
switch (qt) {
case Judge:
return "judge";
return BusinessConsts.TheoryType.judge;
case Select:
return "select";
return BusinessConsts.TheoryType.select;
case Multi:
return "multi";
return BusinessConsts.TheoryType.multi;
}
return null;
}

View File

@ -0,0 +1,32 @@
package club.joylink.rtss.vo.paper;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
* 查询满足条件的题目的数量
*/
@Data
public class FindCountForQuestionReqVo {
/**
* 组织id
*/
private Long orgId;
/**
* 试卷试题大类型:1-理论题2-实训题
*/
@NotNull
private PaperQType.GroupType groupType;
/**
* 试题子类型1-选择题2-多选题3-判断题4-单操实训5-场景实训
*/
@NotNull
private PaperQType.SubType subType;
/**
* 筛选试题的标签列表
*/
private List<String> tags = new ArrayList<>();
}

View File

@ -58,7 +58,9 @@ public class PaperQType {
}
}
}
/**
* 试题子类型1-选择题2-多选题3-判断题4-单操实训5-场景实训
*/
public enum SubType {
Select(1),
Multi(2),