Kaynağa Gözat

提交开发代码

weiwenhai 6 yıl önce
ebeveyn
işleme
e95a42a813

+ 18 - 0
examcloud-core-questions-api-provider/src/main/java/cn/com/qmth/examcloud/service/core/api/PaperController.java

@@ -622,4 +622,22 @@ public class PaperController extends ControllerSupport{
     	User user = getAccessUser();
 		return paperService.findQuestionStructure(paperId,user);
     }
+    
+    @ApiOperation(value="根绝试卷id查询不同类型,题的数量")
+    @GetMapping(value="/paper/questionNumbers/{paperId}/{publicityType}/{difficultyType}")
+    public ResponseEntity<Object> questionNumbers(@PathVariable String paperId,
+    											  @PathVariable Integer publicityType,
+    											  @PathVariable Integer difficultyType){
+    	int total = paperService.getQuestionTypeNumbers(paperId, publicityType, difficultyType);
+    	return new ResponseEntity<Object>(total,HttpStatus.OK);
+    }
+    
+    @ApiOperation(value="根绝试卷id查询不同类型,题的数量")
+    @GetMapping(value="/paper/questionScores/{paperId}/{publicityType}/{difficultyType}")
+    public ResponseEntity<Object> questionScores(@PathVariable String paperId,
+			  									 @PathVariable Integer publicityType,
+			  									 @PathVariable Integer difficultyType){
+    	double total = paperService.getQuestionTypeScore(paperId, publicityType, difficultyType);
+    	return new ResponseEntity<Object>(total,HttpStatus.OK);
+    }
 }

+ 18 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/PaperService.java

@@ -281,4 +281,22 @@ public interface PaperService {
      * @return
      */
     public PaperExp getDownPaperExp(String paperId) throws Exception;
+    
+    /**
+     * 根据试卷id,公开度,难度查询题目数量
+     * @param paperId
+     * @param publicityType
+     * @param difficultyType
+     * @return
+     */
+    public int getQuestionTypeNumbers(String paperId,Integer publicityType,Integer difficultyType);
+    
+    /**
+     * 根据试卷id,公开度,难度查询题目分数
+     * @param paperId
+     * @param publicityType
+     * @param difficultyType
+     * @return
+     */
+    public double getQuestionTypeScore(String paperId,Integer publicityType,Integer difficultyType);
 }

+ 82 - 0
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PaperServiceImpl.java

@@ -1616,5 +1616,87 @@ public class PaperServiceImpl implements PaperService{
         }
         return pWordMl.toString();
     }
+
+	@Override
+	public int getQuestionTypeNumbers(String paperId, Integer publicityType, Integer difficultyType) {
+		if(publicityType == null || difficultyType == null){
+			return 0;
+		}
+		Boolean publicity = null;
+		String difficulty = null;
+		if(publicityType == 1){
+			publicity = true;
+		}else {
+			publicity = false;
+		}
+		if(difficultyType == 1){
+			difficulty = "易";
+		}else if (difficultyType == 2) {
+			difficulty = "中";
+		}else {
+			difficulty = "难";
+		}
+		String needType = publicity + "-" + difficulty;
+		Paper paper = paperRepo.findOne(paperId);
+		List<PaperDetailUnit> units = paperDetailUnitRepo.findByPaperOrderByNumber(paper);
+		if(units != null && units.size()>0){
+			int total = 0;
+			for(PaperDetailUnit unit:units){
+				if(unit.getQuestion().getPublicity() == null){
+					unit.getQuestion().setPublicity(true);
+				}
+				if(unit.getQuestion().getDifficulty() == null){
+					unit.getQuestion().setDifficulty("中");
+				}
+				String factType = unit.getQuestion().getPublicity() + "-" + unit.getQuestion().getDifficulty();
+				if(needType.equals(factType)){
+					total += 1;
+				}
+			}
+			return total;
+		}
+		return 0;
+	}
+
+	@Override
+	public double getQuestionTypeScore(String paperId, Integer publicityType, Integer difficultyType) {
+		if(publicityType == null || difficultyType == null){
+			return 0;
+		}
+		Boolean publicity = null;
+		String difficulty = null;
+		if(publicityType == 1){
+			publicity = true;
+		}else {
+			publicity = false;
+		}
+		if(difficultyType == 1){
+			difficulty = "易";
+		}else if (difficultyType == 2) {
+			difficulty = "中";
+		}else {
+			difficulty = "难";
+		}
+		String needType = publicity + "-" + difficulty;
+		Paper paper = paperRepo.findOne(paperId);
+		List<PaperDetailUnit> units = paperDetailUnitRepo.findByPaperOrderByNumber(paper);
+		if(units != null && units.size()>0){
+			double total = 0;
+			for(PaperDetailUnit unit:units){
+				if(unit.getQuestion().getPublicity() == null){
+					unit.getQuestion().setPublicity(true);
+				}
+				if(unit.getQuestion().getDifficulty() == null){
+					unit.getQuestion().setDifficulty("中");
+				}
+				String factType = unit.getQuestion().getPublicity() + "-" + unit.getQuestion().getDifficulty();
+				if(needType.equals(factType)){
+					total += unit.getScore();
+				}
+			}
+			return total;
+		}
+		return 0;
+	}
 }