|
@@ -1,5 +1,29 @@
|
|
package com.qmth.cqb.paper.web;
|
|
package com.qmth.cqb.paper.web;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.HashSet;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
+
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
import com.qmth.cqb.paper.dao.PaperRepo;
|
|
import com.qmth.cqb.paper.dao.PaperRepo;
|
|
import com.qmth.cqb.paper.dto.PaperDetailExp;
|
|
import com.qmth.cqb.paper.dto.PaperDetailExp;
|
|
@@ -9,28 +33,18 @@ import com.qmth.cqb.paper.model.Paper;
|
|
import com.qmth.cqb.paper.model.PaperSearchInfo;
|
|
import com.qmth.cqb.paper.model.PaperSearchInfo;
|
|
import com.qmth.cqb.paper.service.PaperService;
|
|
import com.qmth.cqb.paper.service.PaperService;
|
|
import com.qmth.cqb.question.model.Question;
|
|
import com.qmth.cqb.question.model.Question;
|
|
-
|
|
|
|
import com.qmth.cqb.utils.StringSimilarityUtils;
|
|
import com.qmth.cqb.utils.StringSimilarityUtils;
|
|
|
|
+
|
|
import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
|
|
import cn.com.qmth.examcloud.common.dto.question.enums.QuesStructType;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
-import java.util.*;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
-import java.util.stream.Stream;
|
|
|
|
-
|
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Created by songyue on 16/12/28.
|
|
* Created by songyue on 16/12/28.
|
|
*/
|
|
*/
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("${api_cqb}/")
|
|
@RequestMapping("${api_cqb}/")
|
|
public class PaperController {
|
|
public class PaperController {
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
PaperService paperService;
|
|
PaperService paperService;
|
|
|
|
|
|
@@ -77,11 +91,9 @@ public class PaperController {
|
|
*/
|
|
*/
|
|
@ApiOperation(value = "查询所有导入试卷", notes = "查询所有导入试卷")
|
|
@ApiOperation(value = "查询所有导入试卷", notes = "查询所有导入试卷")
|
|
@GetMapping(value = "/importPaper/{curPage}/{pageSize}")
|
|
@GetMapping(value = "/importPaper/{curPage}/{pageSize}")
|
|
- public ResponseEntity getImportPapers(@ModelAttribute PaperSearchInfo paperSearchInfo,
|
|
|
|
- @PathVariable int curPage,
|
|
|
|
- @PathVariable int pageSize) {
|
|
|
|
- return new ResponseEntity(paperService.getImportPapers(paperSearchInfo,
|
|
|
|
- curPage, pageSize), HttpStatus.OK);
|
|
|
|
|
|
+ public ResponseEntity getImportPapers(@ModelAttribute PaperSearchInfo paperSearchInfo, @PathVariable int curPage,
|
|
|
|
+ @PathVariable int pageSize) {
|
|
|
|
+ return new ResponseEntity(paperService.getImportPapers(paperSearchInfo, curPage, pageSize), HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -94,11 +106,9 @@ public class PaperController {
|
|
*/
|
|
*/
|
|
@ApiOperation(value = "查询所有已组试卷", notes = "查询所有已组试卷")
|
|
@ApiOperation(value = "查询所有已组试卷", notes = "查询所有已组试卷")
|
|
@GetMapping(value = "/genPaper/{curPage}/{pageSize}")
|
|
@GetMapping(value = "/genPaper/{curPage}/{pageSize}")
|
|
- public ResponseEntity getGenPapers(@ModelAttribute PaperSearchInfo paperSearchInfo,
|
|
|
|
- @PathVariable int curPage,
|
|
|
|
- @PathVariable int pageSize) {
|
|
|
|
- return new ResponseEntity(paperService.getGenPapers(paperSearchInfo,
|
|
|
|
- curPage, pageSize), HttpStatus.OK);
|
|
|
|
|
|
+ public ResponseEntity getGenPapers(@ModelAttribute PaperSearchInfo paperSearchInfo, @PathVariable int curPage,
|
|
|
|
+ @PathVariable int pageSize) {
|
|
|
|
+ return new ResponseEntity(paperService.getGenPapers(paperSearchInfo, curPage, pageSize), HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -154,7 +164,6 @@ public class PaperController {
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 获取卷库考试试卷
|
|
* 获取卷库考试试卷
|
|
*
|
|
*
|
|
@@ -165,9 +174,8 @@ public class PaperController {
|
|
*/
|
|
*/
|
|
@ApiOperation(value = "获取卷库考试试卷", notes = "获取卷库考试试卷")
|
|
@ApiOperation(value = "获取卷库考试试卷", notes = "获取卷库考试试卷")
|
|
@GetMapping(value = "/paper/list/{examId}/{courseCode}/{groupCode}")
|
|
@GetMapping(value = "/paper/list/{examId}/{courseCode}/{groupCode}")
|
|
- public List<Paper> listPaperById(@PathVariable String examId,
|
|
|
|
- @PathVariable String courseCode,
|
|
|
|
- @PathVariable String groupCode) {
|
|
|
|
|
|
+ public List<Paper> listPaperById(@PathVariable String examId, @PathVariable String courseCode,
|
|
|
|
+ @PathVariable String groupCode) {
|
|
return paperService.listExamPapers(Long.parseLong(examId), courseCode, groupCode);
|
|
return paperService.listExamPapers(Long.parseLong(examId), courseCode, groupCode);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -182,10 +190,8 @@ public class PaperController {
|
|
*/
|
|
*/
|
|
@ApiOperation(value = "新增考试试卷", notes = "新增考试试卷")
|
|
@ApiOperation(value = "新增考试试卷", notes = "新增考试试卷")
|
|
@PostMapping(value = "/paper/join/{examId}/{courseCode}/{groupCode}/{paperId}")
|
|
@PostMapping(value = "/paper/join/{examId}/{courseCode}/{groupCode}/{paperId}")
|
|
- public ResponseEntity joinExamPaper(@PathVariable String examId,
|
|
|
|
- @PathVariable String courseCode,
|
|
|
|
- @PathVariable String groupCode,
|
|
|
|
- @PathVariable String paperId) {
|
|
|
|
|
|
+ public ResponseEntity joinExamPaper(@PathVariable String examId, @PathVariable String courseCode,
|
|
|
|
+ @PathVariable String groupCode, @PathVariable String paperId) {
|
|
paperService.joinToExamPaper(Long.parseLong(examId), courseCode, groupCode, paperId);
|
|
paperService.joinToExamPaper(Long.parseLong(examId), courseCode, groupCode, paperId);
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
}
|
|
}
|
|
@@ -201,10 +207,8 @@ public class PaperController {
|
|
*/
|
|
*/
|
|
@ApiOperation(value = "删除考试试卷", notes = "删除考试试卷")
|
|
@ApiOperation(value = "删除考试试卷", notes = "删除考试试卷")
|
|
@DeleteMapping(value = "/paper/release/{examId}/{courseCode}/{groupCode}/{paperId}")
|
|
@DeleteMapping(value = "/paper/release/{examId}/{courseCode}/{groupCode}/{paperId}")
|
|
- public ResponseEntity releaseExamPaper(@PathVariable String examId,
|
|
|
|
- @PathVariable String courseCode,
|
|
|
|
- @PathVariable String groupCode,
|
|
|
|
- @PathVariable String paperId) {
|
|
|
|
|
|
+ public ResponseEntity releaseExamPaper(@PathVariable String examId, @PathVariable String courseCode,
|
|
|
|
+ @PathVariable String groupCode, @PathVariable String paperId) {
|
|
|
|
|
|
paperService.releaseExamPaper(Long.parseLong(examId), courseCode, groupCode, paperId);
|
|
paperService.releaseExamPaper(Long.parseLong(examId), courseCode, groupCode, paperId);
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
@@ -219,12 +223,10 @@ public class PaperController {
|
|
*/
|
|
*/
|
|
@ApiOperation(value = "获取考试试卷类型集合", notes = "获取考试试卷类型集合")
|
|
@ApiOperation(value = "获取考试试卷类型集合", notes = "获取考试试卷类型集合")
|
|
@GetMapping(value = "/paper/groupCode/{examId}/{courseCode}")
|
|
@GetMapping(value = "/paper/groupCode/{examId}/{courseCode}")
|
|
- public Set<String> listGroup(@PathVariable String examId,
|
|
|
|
- @PathVariable String courseCode) {
|
|
|
|
|
|
+ public Set<String> listGroup(@PathVariable String examId, @PathVariable String courseCode) {
|
|
return paperService.listGroupCodes(Long.parseLong(examId), courseCode);
|
|
return paperService.listGroupCodes(Long.parseLong(examId), courseCode);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 删除考试试卷类型
|
|
* 删除考试试卷类型
|
|
*
|
|
*
|
|
@@ -235,9 +237,8 @@ public class PaperController {
|
|
*/
|
|
*/
|
|
@ApiOperation(value = "删除考试试卷类型", notes = "删除考试试卷类型")
|
|
@ApiOperation(value = "删除考试试卷类型", notes = "删除考试试卷类型")
|
|
@DeleteMapping(value = "/paper/groupCode/{examId}/{courseCode}/{groupCode}")
|
|
@DeleteMapping(value = "/paper/groupCode/{examId}/{courseCode}/{groupCode}")
|
|
- public ResponseEntity deleteGroup(@PathVariable String examId,
|
|
|
|
- @PathVariable String courseCode,
|
|
|
|
- @PathVariable String groupCode) {
|
|
|
|
|
|
+ public ResponseEntity deleteGroup(@PathVariable String examId, @PathVariable String courseCode,
|
|
|
|
+ @PathVariable String groupCode) {
|
|
paperService.deletGroupCode(Long.parseLong(examId), courseCode, groupCode);
|
|
paperService.deletGroupCode(Long.parseLong(examId), courseCode, groupCode);
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
return new ResponseEntity(HttpStatus.OK);
|
|
}
|
|
}
|
|
@@ -265,9 +266,8 @@ public class PaperController {
|
|
*/
|
|
*/
|
|
@ApiOperation(value = "向导入试卷中的新增试题", notes = "向导入试卷中的新增试题")
|
|
@ApiOperation(value = "向导入试卷中的新增试题", notes = "向导入试卷中的新增试题")
|
|
@PostMapping(value = "/paper/addQuestion/{paperId}/{paperDetailId}")
|
|
@PostMapping(value = "/paper/addQuestion/{paperId}/{paperDetailId}")
|
|
- public ResponseEntity insertQuestionToPaper(@PathVariable String paperId,
|
|
|
|
- @PathVariable String paperDetailId,
|
|
|
|
- @RequestBody Question question) {
|
|
|
|
|
|
+ public ResponseEntity insertQuestionToPaper(@PathVariable String paperId, @PathVariable String paperDetailId,
|
|
|
|
+ @RequestBody Question question) {
|
|
return new ResponseEntity(paperService.insertQuestionToPaper(paperId, paperDetailId, question), HttpStatus.OK);
|
|
return new ResponseEntity(paperService.insertQuestionToPaper(paperId, paperDetailId, question), HttpStatus.OK);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -277,13 +277,15 @@ public class PaperController {
|
|
public ResponseEntity reduplicateQuestions(@PathVariable String paperId) {
|
|
public ResponseEntity reduplicateQuestions(@PathVariable String paperId) {
|
|
|
|
|
|
List<PaperDetailUnitExp> allPaperDetailUnitList = new ArrayList<>();
|
|
List<PaperDetailUnitExp> allPaperDetailUnitList = new ArrayList<>();
|
|
-// List<String> reduplicateId = new ArrayList<>();
|
|
|
|
|
|
+ // List<String> reduplicateId = new ArrayList<>();
|
|
List<Set<String>> reduplicateId = new ArrayList<>();
|
|
List<Set<String>> reduplicateId = new ArrayList<>();
|
|
|
|
|
|
PaperExp paperExp = paperService.getPaperDto(paperId);
|
|
PaperExp paperExp = paperService.getPaperDto(paperId);
|
|
List<PaperDetailExp> paperDetailExpList = paperExp.getPaperDetails();
|
|
List<PaperDetailExp> paperDetailExpList = paperExp.getPaperDetails();
|
|
- for (PaperDetailExp paperDetailExp : paperDetailExpList) {
|
|
|
|
- allPaperDetailUnitList.addAll(paperDetailExp.getPaperDetailUnits());
|
|
|
|
|
|
+ if (paperDetailExpList != null && paperDetailExpList.size() > 0) {
|
|
|
|
+ for (PaperDetailExp paperDetailExp : paperDetailExpList) {
|
|
|
|
+ allPaperDetailUnitList.addAll(paperDetailExp.getPaperDetailUnits());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
int length = allPaperDetailUnitList.size();
|
|
int length = allPaperDetailUnitList.size();
|
|
@@ -291,21 +293,26 @@ public class PaperController {
|
|
for (int j = i + 1; j < length; j++) {
|
|
for (int j = i + 1; j < length; j++) {
|
|
PaperDetailUnitExp paperDetailUnitExp1 = allPaperDetailUnitList.get(i);
|
|
PaperDetailUnitExp paperDetailUnitExp1 = allPaperDetailUnitList.get(i);
|
|
PaperDetailUnitExp paperDetailUnitExp2 = allPaperDetailUnitList.get(j);
|
|
PaperDetailUnitExp paperDetailUnitExp2 = allPaperDetailUnitList.get(j);
|
|
- double similarity = StringSimilarityUtils.getSimilarityWithCosinesBySeg(paperDetailUnitExp1.getQuestion().getQuesBody(), paperDetailUnitExp2.getQuestion().getQuesBody());
|
|
|
|
|
|
+ double similarity = StringSimilarityUtils.getSimilarityWithCosinesBySeg(
|
|
|
|
+ paperDetailUnitExp1.getQuestion().getQuesBody(),
|
|
|
|
+ paperDetailUnitExp2.getQuestion().getQuesBody());
|
|
if (similarity > reduplicateSimilarity) {
|
|
if (similarity > reduplicateSimilarity) {
|
|
boolean found = false;
|
|
boolean found = false;
|
|
for (int k = 0; k < reduplicateId.size(); k++) {
|
|
for (int k = 0; k < reduplicateId.size(); k++) {
|
|
- if (reduplicateId.get(k).contains(paperDetailUnitExp1.getId()) && !reduplicateId.get(k).contains(paperDetailUnitExp2.getId())) {
|
|
|
|
|
|
+ if (reduplicateId.get(k).contains(paperDetailUnitExp1.getId())
|
|
|
|
+ && !reduplicateId.get(k).contains(paperDetailUnitExp2.getId())) {
|
|
found = true;
|
|
found = true;
|
|
reduplicateId.get(k).add(paperDetailUnitExp2.getId());
|
|
reduplicateId.get(k).add(paperDetailUnitExp2.getId());
|
|
break;
|
|
break;
|
|
- } else if (!reduplicateId.get(k).contains(paperDetailUnitExp1.getId()) && reduplicateId.get(k).contains(paperDetailUnitExp2.getId())) {
|
|
|
|
|
|
+ } else if (!reduplicateId.get(k).contains(paperDetailUnitExp1.getId())
|
|
|
|
+ && reduplicateId.get(k).contains(paperDetailUnitExp2.getId())) {
|
|
found = true;
|
|
found = true;
|
|
reduplicateId.get(k).add(paperDetailUnitExp1.getId());
|
|
reduplicateId.get(k).add(paperDetailUnitExp1.getId());
|
|
break;
|
|
break;
|
|
- } else if (reduplicateId.get(k).contains(paperDetailUnitExp1.getId()) && reduplicateId.get(k).contains(paperDetailUnitExp2.getId())) {
|
|
|
|
|
|
+ } else if (reduplicateId.get(k).contains(paperDetailUnitExp1.getId())
|
|
|
|
+ && reduplicateId.get(k).contains(paperDetailUnitExp2.getId())) {
|
|
found = true;
|
|
found = true;
|
|
- //两个题都在分组里,就不加了
|
|
|
|
|
|
+ // 两个题都在分组里,就不加了
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -317,8 +324,8 @@ public class PaperController {
|
|
redupSet.add(paperDetailUnitExp2.getId());
|
|
redupSet.add(paperDetailUnitExp2.getId());
|
|
reduplicateId.add(redupSet);
|
|
reduplicateId.add(redupSet);
|
|
}
|
|
}
|
|
-// reduplicateId.add(paperDetailUnitExp1.getId());
|
|
|
|
-// reduplicateId.add(paperDetailUnitExp2.getId());
|
|
|
|
|
|
+ // reduplicateId.add(paperDetailUnitExp1.getId());
|
|
|
|
+ // reduplicateId.add(paperDetailUnitExp2.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -346,14 +353,15 @@ public class PaperController {
|
|
*/
|
|
*/
|
|
@ApiOperation(value = "查询用于选题的试题列表", notes = "查询用于选题的试题列表")
|
|
@ApiOperation(value = "查询用于选题的试题列表", notes = "查询用于选题的试题列表")
|
|
@GetMapping(value = "/paper/listQuestion/{paperId}/{curPage}/{pageSize}")
|
|
@GetMapping(value = "/paper/listQuestion/{paperId}/{curPage}/{pageSize}")
|
|
- public ResponseEntity listQuestionforSelect(@PathVariable String paperId,
|
|
|
|
- @PathVariable int curPage,
|
|
|
|
- @PathVariable int pageSize,
|
|
|
|
- @RequestParam(name = "quesType") String quesType) {
|
|
|
|
|
|
+ public ResponseEntity listQuestionforSelect(@PathVariable String paperId, @PathVariable int curPage,
|
|
|
|
+ @PathVariable int pageSize, @RequestParam(name = "quesType") String quesType) {
|
|
if (StringUtils.isNotEmpty(quesType)) {
|
|
if (StringUtils.isNotEmpty(quesType)) {
|
|
- return new ResponseEntity(paperService.listQuestionforSelect(paperId, curPage, pageSize, QuesStructType.valueOf(quesType)), HttpStatus.OK);
|
|
|
|
|
|
+ return new ResponseEntity(
|
|
|
|
+ paperService.listQuestionforSelect(paperId, curPage, pageSize, QuesStructType.valueOf(quesType)),
|
|
|
|
+ HttpStatus.OK);
|
|
} else {
|
|
} else {
|
|
- return new ResponseEntity(paperService.listQuestionforSelect(paperId, curPage, pageSize, null), HttpStatus.OK);
|
|
|
|
|
|
+ return new ResponseEntity(paperService.listQuestionforSelect(paperId, curPage, pageSize, null),
|
|
|
|
+ HttpStatus.OK);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -368,10 +376,10 @@ public class PaperController {
|
|
*/
|
|
*/
|
|
@ApiOperation(value = "向导入试卷中的新增试题", notes = "向导入试卷中的新增试题")
|
|
@ApiOperation(value = "向导入试卷中的新增试题", notes = "向导入试卷中的新增试题")
|
|
@PostMapping(value = "/paper/selectQuestions/{paperId}/{paperDetailId}")
|
|
@PostMapping(value = "/paper/selectQuestions/{paperId}/{paperDetailId}")
|
|
- public ResponseEntity selectQuestionsToPaper(@PathVariable String paperId,
|
|
|
|
- @PathVariable String paperDetailId,
|
|
|
|
- @RequestBody List<Question> questions) {
|
|
|
|
- return new ResponseEntity(paperService.selectQuestionsToPaper(paperId, paperDetailId, questions), HttpStatus.OK);
|
|
|
|
|
|
+ public ResponseEntity selectQuestionsToPaper(@PathVariable String paperId, @PathVariable String paperDetailId,
|
|
|
|
+ @RequestBody List<Question> questions) {
|
|
|
|
+ return new ResponseEntity(paperService.selectQuestionsToPaper(paperId, paperDetailId, questions),
|
|
|
|
+ HttpStatus.OK);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|