|
@@ -85,7 +85,7 @@ public class PaperService {
|
|
|
|
|
|
@Autowired
|
|
|
QuesService quesService;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
ExtractConfigService extractConfigService;
|
|
|
|
|
@@ -162,7 +162,8 @@ public class PaperService {
|
|
|
oldPaper.setTitle(paperExp.getTitle());
|
|
|
oldPaper.setName(paperExp.getName().trim());
|
|
|
oldPaper.setLastModifyName(user.getName());
|
|
|
- if (!oldName.equals(paperExp.getName().trim())) {// 假如改变了试卷名称 则要效验试卷名称唯一性
|
|
|
+ if (!oldName.equals(paperExp.getName().trim())) {// 假如改变了试卷名称
|
|
|
+ // 则要效验试卷名称唯一性
|
|
|
String msg = this.checkPaperName(paperExp.getName().trim(), user.getOrgId().toString());
|
|
|
if (msg == null) {
|
|
|
paperRepo.save(oldPaper);
|
|
@@ -279,39 +280,39 @@ public class PaperService {
|
|
|
*
|
|
|
* @param paperIds
|
|
|
*/
|
|
|
- public Map<String,Object> deletePapers(List<String> paperIds) {
|
|
|
- Map<String,Object> msgMap = new HashMap<String,Object>();
|
|
|
+ public Map<String, Object> deletePapers(List<String> paperIds) {
|
|
|
+ Map<String, Object> msgMap = new HashMap<String, Object>();
|
|
|
String msg = "";
|
|
|
List<Paper> papers = CommonUtils.toList(paperRepo.findAll(paperIds));
|
|
|
- if(papers.get(0).getPaperType() == PaperType.IMPORT){
|
|
|
+ if (papers.get(0).getPaperType() == PaperType.IMPORT) {
|
|
|
List<Question> quesList = new ArrayList<Question>();
|
|
|
for (Paper paper : papers) {
|
|
|
List<PaperDetailUnit> paperUnits = paperDetailUnitRepo.findByPaper(paper);
|
|
|
- for(PaperDetailUnit pdu: paperUnits){
|
|
|
- if(pdu.getQuestion() != null ){
|
|
|
- quesList.add(pdu.getQuestion());
|
|
|
+ for (PaperDetailUnit pdu : paperUnits) {
|
|
|
+ if (pdu.getQuestion() != null) {
|
|
|
+ quesList.add(pdu.getQuestion());
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- List<PaperDetailUnit> allUnits = paperDetailUnitRepo.findByQuestionIn(quesList);
|
|
|
- for(PaperDetailUnit pdu: allUnits){
|
|
|
- if(pdu.getPaper()!= null && pdu.getPaper().getPaperType() == PaperType.GENERATE){
|
|
|
+ }
|
|
|
+ List<PaperDetailUnit> allUnits = paperDetailUnitRepo.findByQuestionIn(quesList);
|
|
|
+ for (PaperDetailUnit pdu : allUnits) {
|
|
|
+ if (pdu.getPaper() != null && pdu.getPaper().getPaperType() == PaperType.GENERATE) {
|
|
|
msg = "待删除试卷中有试题被组卷使用,不能删除!";
|
|
|
msgMap.put("msg", msg);
|
|
|
msgMap.put("paperName", pdu.getPaper().getName());
|
|
|
return msgMap;
|
|
|
- // for(PaperDetailUnit ipdu: importPaperUnits){
|
|
|
- // if(ipdu.getQuestion().getId().equals(pdu.getQuestion().getId())){
|
|
|
- //
|
|
|
- // }
|
|
|
- // }
|
|
|
+ // for(PaperDetailUnit ipdu: importPaperUnits){
|
|
|
+ // if(ipdu.getQuestion().getId().equals(pdu.getQuestion().getId())){
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- } else if(papers.get(0).getPaperType() == PaperType.GENERATE){
|
|
|
+ quesRepo.delete(quesList);
|
|
|
+ } else if (papers.get(0).getPaperType() == PaperType.GENERATE) {
|
|
|
for (Paper paper : papers) {
|
|
|
- List<String> examPaperIds = extractConfigService.getExamPaperId(paper.getCourseNo(),paper.getOrgId());
|
|
|
- if(examPaperIds != null && examPaperIds.contains(paper.getId())){
|
|
|
+ List<String> examPaperIds = extractConfigService.getExamPaperId(paper.getCourseNo(), paper.getOrgId());
|
|
|
+ if (examPaperIds != null && examPaperIds.contains(paper.getId())) {
|
|
|
msg = "待删除试卷有被调卷规则使 用,不能删除!";
|
|
|
msgMap.put("msg", msg);
|
|
|
msgMap.put("paperName", paper.getName());
|
|
@@ -324,7 +325,6 @@ public class PaperService {
|
|
|
msg = "success";
|
|
|
msgMap.put("msg", msg);
|
|
|
return msgMap;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -636,7 +636,7 @@ public class PaperService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取试题所的试卷名称
|
|
|
+ * 获取试题所在的试卷名称
|
|
|
*
|
|
|
* @param questionId
|
|
|
* @return
|