|
|
@ -83,42 +83,47 @@ public class PCQuestionController extends BaseController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "getCourseList")
|
|
|
|
@GetMapping(value = "getCourseList")
|
|
|
|
public List<CourseDTO> getCourseList() {
|
|
|
|
public Result<GetCourseList> getCourseList() {
|
|
|
|
return questionDao.getCourseList();
|
|
|
|
GetCourseList getCourseList =new GetCourseList();
|
|
|
|
|
|
|
|
List<CourseDTO> courseList = questionDao.getCourseList();
|
|
|
|
|
|
|
|
getCourseList.setList(courseList);
|
|
|
|
|
|
|
|
return Result.success(getCourseList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping(value = "getIdsByCount")
|
|
|
|
@PostMapping(value = "getIdsByCount")
|
|
|
|
public List<Long> getIdsByCount(@RequestBody GetIdsVo vo) {
|
|
|
|
public Result<CourseList> getIdsByCount(@RequestBody GetIdsVo vo) {
|
|
|
|
List<Long> ids = new ArrayList<>();
|
|
|
|
List<Long> ids = new ArrayList<>();
|
|
|
|
List<Long> courseIds = vo.getCourseIds();
|
|
|
|
List<Long> courseIds = vo.getCourseIds();
|
|
|
|
int judgeCount = vo.getJudgeCount();
|
|
|
|
int judgeCount = vo.getJudgeCount();
|
|
|
|
int singleCount = vo.getSingleCount();
|
|
|
|
int singleCount = vo.getSingleCount();
|
|
|
|
int gapFillingCount = vo.getGapFillingCount();
|
|
|
|
int gapFillingCount = vo.getGapFillingCount();
|
|
|
|
int multyCount = vo.getMultyCount();
|
|
|
|
int multyCount = vo.getMultyCount();
|
|
|
|
|
|
|
|
|
|
|
|
// 随机抽取题目ID
|
|
|
|
// 随机抽取题目ID
|
|
|
|
if (judgeCount > 0) {
|
|
|
|
if (judgeCount > 0) {
|
|
|
|
List<Question> judgeIds = questionDao.findAllByQuestionTypeAndCourseIdIn(3, courseIds);
|
|
|
|
List<Question> judgeIds = questionDao.findAllByQuestionTypeAndCourseIdIn(3, courseIds);
|
|
|
|
List<Long> collect = judgeIds.stream().map(Question::getId).collect(Collectors.toList());
|
|
|
|
List<Long> collect = judgeIds.stream().map(Question::getId).collect(Collectors.toList());
|
|
|
|
ids.addAll(randomSelect(collect, judgeCount));
|
|
|
|
ids.addAll(randomSelect(collect, judgeCount));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (singleCount > 0) {
|
|
|
|
if (singleCount > 0) {
|
|
|
|
List<Question> singleIds = questionDao.findAllByQuestionTypeAndCourseIdIn(1, courseIds);
|
|
|
|
List<Question> singleIds = questionDao.findAllByQuestionTypeAndCourseIdIn(1, courseIds);
|
|
|
|
List<Long> collect = singleIds.stream().map(Question::getId).collect(Collectors.toList());
|
|
|
|
List<Long> collect = singleIds.stream().map(Question::getId).collect(Collectors.toList());
|
|
|
|
ids.addAll(randomSelect(collect, singleCount));
|
|
|
|
ids.addAll(randomSelect(collect, singleCount));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gapFillingCount > 0) {
|
|
|
|
if (gapFillingCount > 0) {
|
|
|
|
List<Question> gapFillingIds = questionDao.findAllByQuestionTypeAndCourseIdIn(4, courseIds);
|
|
|
|
List<Question> gapFillingIds = questionDao.findAllByQuestionTypeAndCourseIdIn(4, courseIds);
|
|
|
|
List<Long> collect = gapFillingIds.stream().map(Question::getId).collect(Collectors.toList());
|
|
|
|
List<Long> collect = gapFillingIds.stream().map(Question::getId).collect(Collectors.toList());
|
|
|
|
ids.addAll(randomSelect(collect, gapFillingCount));
|
|
|
|
ids.addAll(randomSelect(collect, gapFillingCount));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (multyCount > 0) {
|
|
|
|
if (multyCount > 0) {
|
|
|
|
List<Question> multyIds= questionDao.findAllByQuestionTypeAndCourseIdIn(2, courseIds);
|
|
|
|
List<Question> multyIds = questionDao.findAllByQuestionTypeAndCourseIdIn(2, courseIds);
|
|
|
|
List<Long> collect = multyIds.stream().map(Question::getId).collect(Collectors.toList());
|
|
|
|
List<Long> collect = multyIds.stream().map(Question::getId).collect(Collectors.toList());
|
|
|
|
ids.addAll(randomSelect(collect, multyCount));
|
|
|
|
ids.addAll(randomSelect(collect, multyCount));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ids;
|
|
|
|
CourseList courseList = new CourseList();
|
|
|
|
|
|
|
|
courseList.setList(ids);
|
|
|
|
|
|
|
|
return Result.success(courseList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|