Procházet zdrojové kódy

Merge branch 'master' of http://git.qmth.com.cn/ExamCloud-2/examcloud-core-questions

deason před 7 roky
rodič
revize
55567e1d22

+ 1 - 0
examcloud-core-questions-dao/src/main/java/cn/com/qmth/examcloud/core/questions/dao/entity/ImportPaperCheck.java

@@ -81,4 +81,5 @@ public class ImportPaperCheck {
         this.nestedQuesNumber = 0;
         this.nestedHeadNumber = 0;
     }
+
 }

+ 30 - 6
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ImportPaperService.java

@@ -1623,28 +1623,42 @@ public class ImportPaperService {
      * @throws PaperException 
      */
     private void checkAnswerISfull(List<PaperDetailUnit> paperDetailUnits,ImportPaperCheck importPaperCheck) throws PaperException{
-    	List<PaperDetailUnit> paperDetailUnitList = new ArrayList<PaperDetailUnit>();
+    	Map<Question,PaperDetailUnit> map = new HashMap<Question, PaperDetailUnit>();
     	for(PaperDetailUnit paperDetailUnit:paperDetailUnits){
     		Question question = paperDetailUnit.getQuestion();
     		if(question.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
                         || question.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION
                         || question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION){
-    			paperDetailUnitList.add(paperDetailUnit);
+    			map.put(question, paperDetailUnit);
+    		}
+    		if(question.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION){
+    			List<Question> subQuestions = question.getSubQuestions();
+    			for(Question subQuestion:subQuestions){
+    				if(subQuestion.getQuestionType() == QuesStructType.SINGLE_ANSWER_QUESTION
+                            || subQuestion.getQuestionType() == QuesStructType.MULTIPLE_ANSWER_QUESTION
+                            || subQuestion.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION){
+    					map.put(subQuestion, paperDetailUnit);
+    				}
+    			}
     		}
     	}
     	boolean isNull = false;
     	boolean isNotNull = false;
     	PaperDetailUnit paperDetailUnit = new PaperDetailUnit();
-    	for(PaperDetailUnit pdu:paperDetailUnitList){
-    		Question question = pdu.getQuestion();
+    	Question subQuestion = new Question();
+    	for(Question question:map.keySet()){
+    		PaperDetailUnit pdu = map.get(question);
     		if(StringUtils.isBlank(question.getQuesAnswer())){
     			isNull = true;
+    			if(pdu.getQuestion().getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION){
+    				subQuestion = question;
+    			}
     			paperDetailUnit = pdu;
     			break;
     		}
     	}
-    	for(PaperDetailUnit pdu:paperDetailUnitList){
-    		Question question = pdu.getQuestion();
+    	for(Question question:map.keySet()){
+    		//PaperDetailUnit pdu = map.get(question);
     		if(StringUtils.isNotBlank(question.getQuesAnswer())){
     			isNotNull = true;
     			break;
@@ -1652,6 +1666,16 @@ public class ImportPaperService {
     	}
     	//不满足(客观题答案要么全有,要么全没有)条件
     	if(isNull&&isNotNull){
+    		if(paperDetailUnit.getQuestion().getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION){
+    			int number=0;
+    			for(int i=0;i<paperDetailUnit.getQuestion().getSubQuestions().size();i++){
+    				if(paperDetailUnit.getQuestion().getSubQuestions().get(i).getId().equals(subQuestion.getId())){
+    					number = i+1;
+    				}
+    			}
+    			importPaperCheck.setErrorInfo("第"+paperDetailUnit.getNumber()+"大题套题中"+ number +"小题答案缺失,请检查");
+    			throw new PaperException(importPaperCheck.errorInfo);
+    		}
     		importPaperCheck.setErrorInfo("第"+paperDetailUnit.getNumber()+"小题答案缺失,请检查");
 	        throw new PaperException(importPaperCheck.errorInfo);
     	}

+ 6 - 6
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExportPaperServiceImpl.java

@@ -114,7 +114,7 @@ public class ExportPaperServiceImpl implements ExportPaperService{
 		Paper paper = paperRepo.findOne(paperId);
 		List<Paper> papers = new ArrayList<Paper>();
 		papers.add(paper);
-		String zipFileName = loginName;
+		String zipFileName = loginName + System.currentTimeMillis() + "";
 		File directory = new File(TEMP_FILE_EXP + File.separator + zipFileName);
 		if(!directory.exists()){
 			directory.mkdirs();
@@ -472,7 +472,7 @@ public class ExportPaperServiceImpl implements ExportPaperService{
 
 	@Override
 	public  void exportPaperFiles(List<String> paperIds,String serviceName,String exportContentList, HttpServletResponse response,String loginName,String examType) throws Exception {
-		ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById("fjsfExportPaperService");
+		ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById("tjdxExportPaperService");
 		//根据试卷id查询所有试卷
 		List<Paper> papers = CommonUtils.toList(paperRepo.findAll(paperIds));
 		String zipFileName = loginName;
@@ -653,18 +653,18 @@ public class ExportPaperServiceImpl implements ExportPaperService{
 		for(Question question:quesList){
 			if(question.getPublicity()){
 				//公开
-				if(question.getDifficulty().equals("难")){
+				if(question.getDifficulty() !=null && question.getDifficulty().equals("难") || question.getDifficultyDegree()<0.4 && question.getDifficultyDegree()>0){
 					map = buildMapSum(questionType*100+1,map);
-				}else if(question.getDifficulty().equals("中")) {
+				}else if(question.getDifficulty() !=null && question.getDifficulty().equals("中") || question.getDifficultyDegree()<0.8 && question.getDifficultyDegree()>0.3) {
 					map = buildMapSum(questionType*100+2,map);
 				}else{
 					map = buildMapSum(questionType*100+3,map);
 				}
 			}else {
 				//非公开
-				if(question.getDifficulty().equals("难")){
+				if(question.getDifficulty() !=null && question.getDifficulty().equals("难") || question.getDifficultyDegree()<0.4 && question.getDifficultyDegree()>0){
 					map = buildMapSum(questionType*100+11,map);
-				}else if(question.getDifficulty().equals("中")){
+				}else if(question.getDifficulty() !=null && question.getDifficulty().equals("中") || question.getDifficultyDegree()<0.8 && question.getDifficultyDegree()>0.3){
 					map = buildMapSum(questionType*100+12,map);
 				}else{
 					map = buildMapSum(questionType*100+13,map);

+ 14 - 4
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/QuesServiceImpl.java

@@ -418,7 +418,9 @@ public class QuesServiceImpl implements QuesService{
             	if(StringUtils.isBlank(quesOption.getOptionBody())){
             		quesOption.setOptionBody("<p></p>");
             	}
-                quesOption.setOptionBodyWord(DocxProcessUtil.html2Docx(wordMLPackage,CommonUtils.formatHtml(quesOption.getOptionBody())));
+            	StringBuffer pWordMl = new StringBuffer();
+                //quesOption.setOptionBodyWord(DocxProcessUtil.html2Docx(wordMLPackage,CommonUtils.formatHtml(quesOption.getOptionBody())));
+                quesOption.setOptionBodyWord(reduceImage(quesOption.getOptionBody(),pWordMl,wordMLPackage));
             }
         }
     }
@@ -446,11 +448,19 @@ public class QuesServiceImpl implements QuesService{
                         			for(Object oin:inList){
                         				Inline inline = (Inline)oin;
                         				CTPositiveSize2D extent = inline.getExtent();
-                        				if(extent.getCx()>4000000){
-                        					extent.setCx(3000000);
+                        				if(extent.getCx()>6000000){
+                        					long cx = extent.getCx();
+                        					long cy = extent.getCy();
+                        					Double ncy = (double) ((cy * 6000000) / cx);
+                        					extent.setCx(6000000);
+                        					extent.setCy(ncy.longValue());
                         				}
                         				if(extent.getCy()>6000000){
-                        					extent.setCy(5000000);
+                        					long cx = extent.getCx();
+                        					long cy = extent.getCy();
+                        					Double ncx = (double) ((cx * 6000000) / cy);
+                        					extent.setCy(6000000);
+                        					extent.setCx(ncx.longValue());
                         				}
                         			}
             					}