|
@@ -2,18 +2,19 @@ package com.qmth.cqb.paper.web;
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
import com.qmth.cqb.paper.dao.PaperRepo;
|
|
|
+import com.qmth.cqb.paper.dto.PaperDetailExp;
|
|
|
+import com.qmth.cqb.paper.dto.PaperDetailUnitExp;
|
|
|
import com.qmth.cqb.paper.dto.PaperExp;
|
|
|
import com.qmth.cqb.paper.model.Paper;
|
|
|
import com.qmth.cqb.paper.model.PaperSearchInfo;
|
|
|
import com.qmth.cqb.paper.service.PaperService;
|
|
|
import com.qmth.cqb.question.model.Question;
|
|
|
|
|
|
+import com.qmth.cqb.utils.StringSimilarityUtils;
|
|
|
import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
@@ -40,66 +41,71 @@ public class PaperController {
|
|
|
|
|
|
/**
|
|
|
* 根据Id获取试卷
|
|
|
+ *
|
|
|
* @param paperId
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation(value="根据Id获取试卷",notes="根据Id获取试卷")
|
|
|
+ @ApiOperation(value = "根据Id获取试卷", notes = "根据Id获取试卷")
|
|
|
@GetMapping(value = "/paper/{paperId}")
|
|
|
- public ResponseEntity getPaperById(@PathVariable String paperId){
|
|
|
- return new ResponseEntity(gson.toJson(paperService.getPaperDto(paperId)),HttpStatus.OK);
|
|
|
+ public ResponseEntity getPaperById(@PathVariable String paperId) {
|
|
|
+ return new ResponseEntity(gson.toJson(paperService.getPaperDto(paperId)), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存试卷
|
|
|
+ *
|
|
|
* @param paper
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation(value="保存试卷",notes="保存试卷")
|
|
|
+ @ApiOperation(value = "保存试卷", notes = "保存试卷")
|
|
|
@PutMapping(value = "/paper")
|
|
|
- public ResponseEntity savePaperById(@RequestBody PaperExp paper){
|
|
|
- return new ResponseEntity(paperService.savePaper(paper),HttpStatus.OK);
|
|
|
+ public ResponseEntity savePaperById(@RequestBody PaperExp paper) {
|
|
|
+ return new ResponseEntity(paperService.savePaper(paper), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询所有导入试卷
|
|
|
+ *
|
|
|
* @param paperSearchInfo
|
|
|
* @param curPage
|
|
|
* @param pageSize
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation(value="查询所有导入试卷",notes="查询所有导入试卷")
|
|
|
+ @ApiOperation(value = "查询所有导入试卷", notes = "查询所有导入试卷")
|
|
|
@GetMapping(value = "/importPaper/{curPage}/{pageSize}")
|
|
|
public ResponseEntity getImportPapers(@ModelAttribute PaperSearchInfo paperSearchInfo,
|
|
|
@PathVariable int curPage,
|
|
|
- @PathVariable int pageSize){
|
|
|
+ @PathVariable int pageSize) {
|
|
|
return new ResponseEntity(paperService.getImportPapers(paperSearchInfo,
|
|
|
- curPage, pageSize),HttpStatus.OK);
|
|
|
+ curPage, pageSize), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询所有已组试卷
|
|
|
+ *
|
|
|
* @param paperSearchInfo
|
|
|
* @param curPage
|
|
|
* @param pageSize
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation(value="查询所有已组试卷",notes="查询所有已组试卷")
|
|
|
+ @ApiOperation(value = "查询所有已组试卷", notes = "查询所有已组试卷")
|
|
|
@GetMapping(value = "/genPaper/{curPage}/{pageSize}")
|
|
|
public ResponseEntity getGenPapers(@ModelAttribute PaperSearchInfo paperSearchInfo,
|
|
|
@PathVariable int curPage,
|
|
|
- @PathVariable int pageSize){
|
|
|
+ @PathVariable int pageSize) {
|
|
|
return new ResponseEntity(paperService.getGenPapers(paperSearchInfo,
|
|
|
- curPage, pageSize),HttpStatus.OK);
|
|
|
+ curPage, pageSize), HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除试卷
|
|
|
+ *
|
|
|
* @param paperIds
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation(value="删除试卷",notes="删除试卷")
|
|
|
+ @ApiOperation(value = "删除试卷", notes = "删除试卷")
|
|
|
@DeleteMapping(value = "/paper/{paperIds}")
|
|
|
- public ResponseEntity delPaper(@PathVariable String paperIds){
|
|
|
+ public ResponseEntity delPaper(@PathVariable String paperIds) {
|
|
|
List<String> paperList = Stream.of(paperIds.split(",")).collect(Collectors.toList());
|
|
|
paperService.deletePapers(paperList);
|
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
@@ -107,36 +113,39 @@ public class PaperController {
|
|
|
|
|
|
/**
|
|
|
* 批量通过试卷
|
|
|
+ *
|
|
|
* @param paperSearchInfo
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation(value="批量通过试卷",notes="批量通过试卷")
|
|
|
+ @ApiOperation(value = "批量通过试卷", notes = "批量通过试卷")
|
|
|
@PutMapping(value = "/paper/pass")
|
|
|
- public ResponseEntity passPapers(@RequestBody PaperSearchInfo paperSearchInfo){
|
|
|
+ public ResponseEntity passPapers(@RequestBody PaperSearchInfo paperSearchInfo) {
|
|
|
paperService.passPapers(Arrays.asList(paperSearchInfo.getPaperIds()));
|
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 批量不通过试卷
|
|
|
+ *
|
|
|
* @param paperSearchInfo
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation(value="批量不通过试卷",notes="批量不通过试卷")
|
|
|
+ @ApiOperation(value = "批量不通过试卷", notes = "批量不通过试卷")
|
|
|
@PutMapping(value = "/paper/noPass")
|
|
|
- public ResponseEntity noPassPapers(@RequestBody PaperSearchInfo paperSearchInfo){
|
|
|
+ public ResponseEntity noPassPapers(@RequestBody PaperSearchInfo paperSearchInfo) {
|
|
|
paperService.noPassPapers(Arrays.asList(paperSearchInfo.getPaperIds()));
|
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 批量待审核试卷
|
|
|
+ *
|
|
|
* @param paperSearchInfo
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation(value="批量待审核试卷",notes="批量待审核试卷")
|
|
|
+ @ApiOperation(value = "批量待审核试卷", notes = "批量待审核试卷")
|
|
|
@PutMapping(value = "/paper/draft")
|
|
|
- public ResponseEntity initPapers(@RequestBody PaperSearchInfo paperSearchInfo){
|
|
|
+ public ResponseEntity initPapers(@RequestBody PaperSearchInfo paperSearchInfo) {
|
|
|
paperService.backPapers(Arrays.asList(paperSearchInfo.getPaperIds()));
|
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
|
}
|
|
@@ -144,93 +153,94 @@ public class PaperController {
|
|
|
|
|
|
/**
|
|
|
* 获取卷库考试试卷
|
|
|
+ *
|
|
|
* @param examId
|
|
|
* @param courseCode
|
|
|
* @param groupCode
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation(value="获取卷库考试试卷",notes="获取卷库考试试卷")
|
|
|
+ @ApiOperation(value = "获取卷库考试试卷", notes = "获取卷库考试试卷")
|
|
|
@GetMapping(value = "/paper/list/{examId}/{courseCode}/{groupCode}")
|
|
|
public List<Paper> listPaperById(@PathVariable String examId,
|
|
|
@PathVariable String courseCode,
|
|
|
- @PathVariable String groupCode){
|
|
|
+ @PathVariable String groupCode) {
|
|
|
return paperService.listExamPapers(Long.parseLong(examId), courseCode, groupCode);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 新增考试试卷
|
|
|
+ *
|
|
|
* @param examId
|
|
|
* @param courseCode
|
|
|
* @param groupCode
|
|
|
* @param paperId
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation(value="新增考试试卷",notes="新增考试试卷")
|
|
|
+ @ApiOperation(value = "新增考试试卷", notes = "新增考试试卷")
|
|
|
@PostMapping(value = "/paper/join/{examId}/{courseCode}/{groupCode}/{paperId}")
|
|
|
public ResponseEntity joinExamPaper(@PathVariable String examId,
|
|
|
- @PathVariable String courseCode,
|
|
|
- @PathVariable String groupCode,
|
|
|
- @PathVariable String paperId){
|
|
|
- paperService.joinToExamPaper(Long.parseLong(examId),courseCode, groupCode, paperId);
|
|
|
- return new ResponseEntity(HttpStatus.OK);
|
|
|
+ @PathVariable String courseCode,
|
|
|
+ @PathVariable String groupCode,
|
|
|
+ @PathVariable String paperId) {
|
|
|
+ paperService.joinToExamPaper(Long.parseLong(examId), courseCode, groupCode, paperId);
|
|
|
+ return new ResponseEntity(HttpStatus.OK);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 删除考试试卷
|
|
|
+ *
|
|
|
* @param examId
|
|
|
* @param courseCode
|
|
|
* @param groupCode
|
|
|
* @param paperId
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation(value="删除考试试卷",notes="删除考试试卷")
|
|
|
+ @ApiOperation(value = "删除考试试卷", notes = "删除考试试卷")
|
|
|
@DeleteMapping(value = "/paper/release/{examId}/{courseCode}/{groupCode}/{paperId}")
|
|
|
public ResponseEntity releaseExamPaper(@PathVariable String examId,
|
|
|
@PathVariable String courseCode,
|
|
|
@PathVariable String groupCode,
|
|
|
- @PathVariable String paperId){
|
|
|
+ @PathVariable String paperId) {
|
|
|
|
|
|
- paperService.releaseExamPaper(Long.parseLong(examId),courseCode, groupCode, paperId);
|
|
|
+ paperService.releaseExamPaper(Long.parseLong(examId), courseCode, groupCode, paperId);
|
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 获取卷库考试试卷类型集合
|
|
|
+ *
|
|
|
* @param examId
|
|
|
* @param courseCode
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation(value="获取考试试卷类型集合",notes="获取考试试卷类型集合")
|
|
|
+ @ApiOperation(value = "获取考试试卷类型集合", notes = "获取考试试卷类型集合")
|
|
|
@GetMapping(value = "/paper/groupCode/{examId}/{courseCode}")
|
|
|
public Set<String> listGroup(@PathVariable String examId,
|
|
|
- @PathVariable String courseCode){
|
|
|
+ @PathVariable String courseCode) {
|
|
|
return paperService.listGroupCodes(Long.parseLong(examId), courseCode);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 删除考试试卷类型
|
|
|
+ *
|
|
|
* @param examId
|
|
|
* @param courseCode
|
|
|
* @param groupCode
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation(value="删除考试试卷类型",notes="删除考试试卷类型")
|
|
|
+ @ApiOperation(value = "删除考试试卷类型", notes = "删除考试试卷类型")
|
|
|
@DeleteMapping(value = "/paper/groupCode/{examId}/{courseCode}/{groupCode}")
|
|
|
public ResponseEntity deleteGroup(@PathVariable String examId,
|
|
|
@PathVariable String courseCode,
|
|
|
- @PathVariable String groupCode){
|
|
|
- paperService.deletGroupCode(Long.parseLong(examId), courseCode, groupCode);
|
|
|
- return new ResponseEntity(HttpStatus.OK);
|
|
|
+ @PathVariable String groupCode) {
|
|
|
+ paperService.deletGroupCode(Long.parseLong(examId), courseCode, groupCode);
|
|
|
+ return new ResponseEntity(HttpStatus.OK);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
- *
|
|
|
* 删除导入试卷中的试题
|
|
|
- *
|
|
|
- * @param examId
|
|
|
- * @param courseCode
|
|
|
- * @param groupCode
|
|
|
+ * @param questionId
|
|
|
* @return
|
|
|
*/
|
|
|
@ApiOperation(value = "删除导入试卷中的试题", notes = "删除导入试卷中的试题")
|
|
@@ -241,9 +251,8 @@ public class PaperController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
* 向导入试卷中的新增试题
|
|
|
- *
|
|
|
+ *
|
|
|
* @param paperId
|
|
|
* @param paperDetailId
|
|
|
* @param question
|
|
@@ -251,59 +260,113 @@ public class PaperController {
|
|
|
*/
|
|
|
@ApiOperation(value = "向导入试卷中的新增试题", notes = "向导入试卷中的新增试题")
|
|
|
@PostMapping(value = "/paper/addQuestion/{paperId}/{paperDetailId}")
|
|
|
- public ResponseEntity insertQuestionToPaper(@PathVariable String paperId,
|
|
|
+ public ResponseEntity insertQuestionToPaper(@PathVariable String paperId,
|
|
|
@PathVariable String paperDetailId,
|
|
|
@RequestBody Question question) {
|
|
|
return new ResponseEntity(paperService.insertQuestionToPaper(paperId, paperDetailId, question), HttpStatus.OK);
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取试卷的重复试题", notes = "获取试卷的重复试题")
|
|
|
+ @GetMapping(value = "/paper/{paperId}/reduplicate-questions")
|
|
|
+ public ResponseEntity reduplicateQuestions(@PathVariable String paperId) {
|
|
|
+
|
|
|
+ List<PaperDetailUnitExp> allPaperDetailUnitList = new ArrayList<>();
|
|
|
+// List<String> reduplicateId = new ArrayList<>();
|
|
|
+ List<Set<String>> reduplicateId = new ArrayList<>();
|
|
|
+
|
|
|
+ PaperExp paperExp = paperService.getPaperDto(paperId);
|
|
|
+ List<PaperDetailExp> paperDetailExpList = paperExp.getPaperDetails();
|
|
|
+ for (PaperDetailExp paperDetailExp : paperDetailExpList) {
|
|
|
+ allPaperDetailUnitList.addAll(paperDetailExp.getPaperDetailUnits());
|
|
|
+ }
|
|
|
+
|
|
|
+ int length = allPaperDetailUnitList.size();
|
|
|
+ for (int i = 0; i < length - 1; i++) {
|
|
|
+ for (int j = i + 1; j < length; j++) {
|
|
|
+ PaperDetailUnitExp paperDetailUnitExp1 = allPaperDetailUnitList.get(i);
|
|
|
+ PaperDetailUnitExp paperDetailUnitExp2 = allPaperDetailUnitList.get(j);
|
|
|
+ double similarity = StringSimilarityUtils.getSimilarityWithCosinesBySeg(paperDetailUnitExp1.getQuestion().getQuesBody(), paperDetailUnitExp2.getQuestion().getQuesBody());
|
|
|
+ if (similarity > 0.6) {
|
|
|
+ boolean found = false;
|
|
|
+ for (int k = 0; k < reduplicateId.size(); k++) {
|
|
|
+ if (reduplicateId.get(k).contains(paperDetailUnitExp1.getId()) && !reduplicateId.get(k).contains(paperDetailUnitExp2.getId())) {
|
|
|
+ found = true;
|
|
|
+ reduplicateId.get(k).add(paperDetailUnitExp2.getId());
|
|
|
+ break;
|
|
|
+ } else if (!reduplicateId.get(k).contains(paperDetailUnitExp1.getId()) && reduplicateId.get(k).contains(paperDetailUnitExp2.getId())) {
|
|
|
+ found = true;
|
|
|
+ reduplicateId.get(k).add(paperDetailUnitExp1.getId());
|
|
|
+ break;
|
|
|
+ } else if (reduplicateId.get(k).contains(paperDetailUnitExp1.getId()) && reduplicateId.get(k).contains(paperDetailUnitExp2.getId())) {
|
|
|
+ found = true;
|
|
|
+ //两个题都在分组里,就不加了
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!found) {
|
|
|
+ Set<String> redupSet = new HashSet<>();
|
|
|
+
|
|
|
+ redupSet.add(paperDetailUnitExp1.getId());
|
|
|
+ redupSet.add(paperDetailUnitExp2.getId());
|
|
|
+ reduplicateId.add(redupSet);
|
|
|
+ }
|
|
|
+// reduplicateId.add(paperDetailUnitExp1.getId());
|
|
|
+// reduplicateId.add(paperDetailUnitExp2.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ResponseEntity(reduplicateId, HttpStatus.OK);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 根据试题获取试卷名称
|
|
|
- * @param
|
|
|
+ *
|
|
|
+ * @param
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation(value="获取试题所在的试卷名称",notes="获取试题所在的试卷名称")
|
|
|
+ @ApiOperation(value = "获取试题所在的试卷名称", notes = "获取试题所在的试卷名称")
|
|
|
@GetMapping(value = "/paper/listNames/{questionId}")
|
|
|
- public ResponseEntity getPaperNamesByQuesId(@PathVariable String questionId){
|
|
|
- return new ResponseEntity(paperService.getPaperNamesByQuestionId(questionId),HttpStatus.OK);
|
|
|
+ public ResponseEntity getPaperNamesByQuesId(@PathVariable String questionId) {
|
|
|
+ return new ResponseEntity(paperService.getPaperNamesByQuestionId(questionId), HttpStatus.OK);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 根据试题获取试卷名称
|
|
|
- * @param
|
|
|
+ *
|
|
|
+ * @param
|
|
|
* @return
|
|
|
*/
|
|
|
- @ApiOperation(value="查询用于选题的试题列表",notes="查询用于选题的试题列表")
|
|
|
+ @ApiOperation(value = "查询用于选题的试题列表", notes = "查询用于选题的试题列表")
|
|
|
@GetMapping(value = "/paper/listQuestion/{paperId}/{curPage}/{pageSize}")
|
|
|
public ResponseEntity listQuestionforSelect(@PathVariable String paperId,
|
|
|
@PathVariable int curPage,
|
|
|
@PathVariable int pageSize,
|
|
|
- @RequestParam(name = "quesType") String quesType){
|
|
|
- if(StringUtils.isNotEmpty(quesType)){
|
|
|
- return new ResponseEntity(paperService.listQuestionforSelect(paperId,curPage,pageSize,QuesStructType.valueOf(quesType)),HttpStatus.OK);
|
|
|
+ @RequestParam(name = "quesType") String quesType) {
|
|
|
+ if (StringUtils.isNotEmpty(quesType)) {
|
|
|
+ return new ResponseEntity(paperService.listQuestionforSelect(paperId, curPage, pageSize, QuesStructType.valueOf(quesType)), HttpStatus.OK);
|
|
|
} else {
|
|
|
- return new ResponseEntity(paperService.listQuestionforSelect(paperId,curPage,pageSize,null),HttpStatus.OK);
|
|
|
+ return new ResponseEntity(paperService.listQuestionforSelect(paperId, curPage, pageSize, null), HttpStatus.OK);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
- *
|
|
|
* 向试卷中某道大题插入多道试题(已存在的试题)
|
|
|
- *
|
|
|
* @param paperId
|
|
|
* @param paperDetailId
|
|
|
- * @param question
|
|
|
+ * @param questions
|
|
|
* @return
|
|
|
*/
|
|
|
@ApiOperation(value = "向导入试卷中的新增试题", notes = "向导入试卷中的新增试题")
|
|
|
@PostMapping(value = "/paper/selectQuestions/{paperId}/{paperDetailId}")
|
|
|
- public ResponseEntity selectQuestionsToPaper(@PathVariable String paperId,
|
|
|
+ public ResponseEntity selectQuestionsToPaper(@PathVariable String paperId,
|
|
|
@PathVariable String paperDetailId,
|
|
|
@RequestBody List<Question> questions) {
|
|
|
return new ResponseEntity(paperService.selectQuestionsToPaper(paperId, paperDetailId, questions), HttpStatus.OK);
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|