|
@@ -8,9 +8,11 @@ import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
+import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
+import java.util.Map.Entry;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -18,6 +20,7 @@ import java.util.stream.Collectors;
|
|
|
import javax.xml.bind.JAXBElement;
|
|
|
|
|
|
import com.qmth.cqb.question.dao.QuesPkgPathRepo;
|
|
|
+
|
|
|
import main.java.com.UpYun;
|
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
@@ -231,23 +234,24 @@ public abstract class ExportPaperAbstractService {
|
|
|
|
|
|
/**
|
|
|
* 下载试卷
|
|
|
- * @param id
|
|
|
- * @param response
|
|
|
+ * @param paperId
|
|
|
+ * @param zipFileName
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public abstract void downloadPaper(String paperId,String zipFileName)throws Exception;
|
|
|
/**
|
|
|
* 下载答案
|
|
|
* @param paperId
|
|
|
- * @param response
|
|
|
+ * @param zipFileName
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public abstract void downloadPaperAnswer(String paperId,String zipFileName)throws Exception;
|
|
|
/**
|
|
|
* 上传试卷相关文件
|
|
|
- * @param orgName
|
|
|
- * @param examName
|
|
|
+ * @param extractConfig
|
|
|
* @param paperId
|
|
|
+ * @param exportStructure
|
|
|
+ * @param accessUser
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public abstract void uploadFile(ExtractConfig extractConfig,String paperId,ExportStructure exportStructure,AccessUser accessUser) throws Exception;
|
|
@@ -421,7 +425,6 @@ public abstract class ExportPaperAbstractService {
|
|
|
/**
|
|
|
* 给小题选项进行排序
|
|
|
* @param paperDetails
|
|
|
- * @param startIndxt
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void setUnitExpNumber(List<PaperDetailExp> paperDetails) throws Exception {
|
|
@@ -475,17 +478,17 @@ public abstract class ExportPaperAbstractService {
|
|
|
List<Object> pList = body.getContent();
|
|
|
int index = 0;
|
|
|
for(Object pObj:pList){
|
|
|
- if(index < pList.size()-1){
|
|
|
- break;
|
|
|
+ if(index == pList.size()-1){
|
|
|
+ P p = (P) pObj;
|
|
|
+ List<Object> pContent = p.getContent();
|
|
|
+ R run = new R();
|
|
|
+ Text text = new Text();
|
|
|
+ text.setValue("("+scores+"分)");
|
|
|
+ run.getContent().add(text);
|
|
|
+ pContent.add(run);
|
|
|
+
|
|
|
}
|
|
|
- P p = (P) pObj;
|
|
|
- List<Object> pContent = p.getContent();
|
|
|
- R run = new R();
|
|
|
- Text text = new Text();
|
|
|
- text.setValue("("+scores+"分)");
|
|
|
- run.getContent().add(text);
|
|
|
- pContent.add(run);
|
|
|
- index++;
|
|
|
+ index++;
|
|
|
}
|
|
|
StringBuffer pWordMl = new StringBuffer();
|
|
|
for(Object pObj:pList){
|
|
@@ -516,8 +519,10 @@ public abstract class ExportPaperAbstractService {
|
|
|
//判断小题是否为套题
|
|
|
if(paperDetailUnit.getQuestionType() == QuesStructType.NESTED_ANSWER_QUESTION){
|
|
|
List<Question> subQuestions = paperDetailUnit.getQuestion().getSubQuestions();
|
|
|
- for(Question subQuestion:subQuestions){
|
|
|
- String questionBodyWord = appendScoreToQuestionBody(subQuestion.getQuesBodyWord(),subQuestion.getScore());
|
|
|
+ for(int i = 0;i < subQuestions.size();i++){
|
|
|
+ Question subQuestion = subQuestions.get(i);
|
|
|
+ double subScore = paperDetailUnit.getSubScoreList().get(i);
|
|
|
+ String questionBodyWord = appendScoreToQuestionBody(subQuestion.getQuesBodyWord(),subScore);
|
|
|
subQuestion.setQuesBodyWord(questionBodyWord);
|
|
|
}
|
|
|
}else {
|
|
@@ -628,14 +633,14 @@ public abstract class ExportPaperAbstractService {
|
|
|
for (PaperDetailUnitExp unitExp : paperDetailUnitExps) {
|
|
|
//判断套路
|
|
|
if(unitExp.getQuestionType()==QuesStructType.NESTED_ANSWER_QUESTION){
|
|
|
- List<Question> subQuestions = unitExp.getQuestion().getSubQuestions();
|
|
|
- for(Question subQuestion:subQuestions){
|
|
|
- scoreSet.add(subQuestion.getScore());
|
|
|
- }
|
|
|
- /*List<Double> subScoreList = unitExp.getSubScoreList();
|
|
|
+// List<Question> subQuestions = unitExp.getQuestion().getSubQuestions();
|
|
|
+// for(Question subQuestion:subQuestions){
|
|
|
+// scoreSet.add(subQuestion.getScore());
|
|
|
+// }
|
|
|
+ List<Double> subScoreList = unitExp.getSubScoreList();
|
|
|
for(Double score:subScoreList){
|
|
|
scoreSet.add(score);
|
|
|
- }*/
|
|
|
+ }
|
|
|
}else{
|
|
|
scoreSet.add(unitExp.getScore());
|
|
|
}
|
|
@@ -649,8 +654,8 @@ public abstract class ExportPaperAbstractService {
|
|
|
|
|
|
/**
|
|
|
* 创建机考文件,并打包上传至又拍云
|
|
|
- * @param paperId
|
|
|
- * @param currNum
|
|
|
+ * @param extractConfig
|
|
|
+ * @param accessUser
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
protected void uploadComputerTestFile(ExtractConfig extractConfig,AccessUser accessUser) throws IOException{
|
|
@@ -730,7 +735,11 @@ public abstract class ExportPaperAbstractService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void getBodyAndOptionAudioFile(ComputerTestQuestion computerTestQuestion,Sections bodySections,String jsonDirectoryPath,ComputerTestPaper computerTestPaper,String examId){
|
|
|
+ private void getBodyAndOptionAudioFile(ComputerTestQuestion computerTestQuestion,
|
|
|
+ Sections bodySections,
|
|
|
+ String jsonDirectoryPath,
|
|
|
+ ComputerTestPaper computerTestPaper,
|
|
|
+ String examId){
|
|
|
List<Section> sectionList = bodySections.getSections();
|
|
|
for(Section section:sectionList){
|
|
|
List<Block> blocks = section.getBlocks();
|
|
@@ -759,13 +768,19 @@ public abstract class ExportPaperAbstractService {
|
|
|
|
|
|
/**
|
|
|
* 生成试卷或答案Word,上传至又拍云
|
|
|
- * @param orgName
|
|
|
- * @param dataMap
|
|
|
+ * @param paperExp
|
|
|
* @param extractConfig
|
|
|
- * @param paperId
|
|
|
* @param accessUser
|
|
|
+ * @param currNum
|
|
|
+ * @param template
|
|
|
+ * @param examFileType
|
|
|
*/
|
|
|
- protected void uploadPaperOrAnswerFile(PaperExp paperExp,ExtractConfig extractConfig,AccessUser accessUser,String currNum,Template template,ExamFileType examFileType){
|
|
|
+ protected void uploadPaperOrAnswerFile(PaperExp paperExp,
|
|
|
+ ExtractConfig extractConfig,
|
|
|
+ AccessUser accessUser,
|
|
|
+ String currNum,
|
|
|
+ Template template,
|
|
|
+ ExamFileType examFileType){
|
|
|
String paperfileName = currNum+examFileType.name()+DOCX_SUFFIX;
|
|
|
try {
|
|
|
DocxProcessUtil.exportWord(paperExp,paperfileName,template);
|
|
@@ -801,9 +816,11 @@ public abstract class ExportPaperAbstractService {
|
|
|
//根据试卷结构导出设置中的数量补齐客观题
|
|
|
List<PaperDetailExp> paperDetailExps = fillObjectiveQuestions(objectiveDetails,questionTypeNums);
|
|
|
List<ObjectiveQuestionStructure> objectiveQuestionStructureList = new ArrayList<ObjectiveQuestionStructure>();
|
|
|
+
|
|
|
+ String paperType = findPaperType(extractConfig,paperExp.getId());
|
|
|
for(PaperDetailExp paperDetailExp:paperDetailExps){
|
|
|
for(PaperDetailUnitExp unit:paperDetailExp.getPaperDetailUnits()){
|
|
|
- objectiveQuestionStructureList.add(new ObjectiveQuestionStructure(paperExp,paperDetailExp,unit));
|
|
|
+ objectiveQuestionStructureList.add(new ObjectiveQuestionStructure(paperExp,paperDetailExp,unit,paperType));
|
|
|
}
|
|
|
}
|
|
|
ExcelWriter objectiveExcelExporter = new ExcelWriter(ObjectiveQuestionStructure.class);
|
|
@@ -833,9 +850,10 @@ public abstract class ExportPaperAbstractService {
|
|
|
String subjectiveFileName = currNum+ExamFileType.PAPER_STRUCTURE_SUBJECTIVE.name()+EXCEL_SUFFIX;
|
|
|
List<PaperDetailExp> subjectiveDetails = getAllSubjectiveDetails(paperExp);
|
|
|
List<SubjectiveQuestionStructure> subjectiveQuestionStructureList = new ArrayList<SubjectiveQuestionStructure>();
|
|
|
+ String paperType = findPaperType(extractConfig,paperExp.getId());
|
|
|
for(PaperDetailExp paperDetailExp:subjectiveDetails){
|
|
|
for(PaperDetailUnitExp unit:paperDetailExp.getPaperDetailUnits()){
|
|
|
- subjectiveQuestionStructureList.add(new SubjectiveQuestionStructure(paperExp,paperDetailExp,unit));
|
|
|
+ subjectiveQuestionStructureList.add(new SubjectiveQuestionStructure(paperExp,paperDetailExp,unit,paperType));
|
|
|
}
|
|
|
}
|
|
|
ExcelWriter subjectiveExcelExporter = new ExcelWriter(SubjectiveQuestionStructure.class);
|
|
@@ -945,9 +963,23 @@ public abstract class ExportPaperAbstractService {
|
|
|
newPaperDetailExp.setPaperDetailUnits(newPaperDetailUnits);
|
|
|
//设置大题题号
|
|
|
newPaperDetailExp.setNumber(Integer.parseInt(quesStructType.getId()+""));
|
|
|
+ newPaperDetailExp.setSortNumber(paperDetailExp.getSortNumber());
|
|
|
paperDetailExps.add(newPaperDetailExp);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //刷一遍number
|
|
|
+ for(int i = 0;i<paperDetailExps.size();i++){
|
|
|
+ if(paperDetailExps.get(i).getSortNumber() == quesStructType.getId()){
|
|
|
+ List<PaperDetailUnitExp> exps = paperDetailExps.get(i).getPaperDetailUnits();
|
|
|
+ int num = 0;
|
|
|
+ for(int j = 0;j<exps.size();j++){
|
|
|
+ num++;
|
|
|
+ exps.get(j).setNumber(num);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//计算差额、补齐试题
|
|
|
int quantity = getQuantity(questionTypeNums,quesStructType)-currentSize;
|
|
|
PaperDetailExp paperDetailExp = new PaperDetailExp();
|
|
@@ -1009,7 +1041,6 @@ public abstract class ExportPaperAbstractService {
|
|
|
/**
|
|
|
* 检查客观题数量是否小于试卷结构导出设置的数量
|
|
|
* @param paperExp
|
|
|
- * @param objectiveDetails
|
|
|
* @param questionTypeNums
|
|
|
* @return
|
|
|
*/
|
|
@@ -1057,5 +1088,26 @@ public abstract class ExportPaperAbstractService {
|
|
|
return DocxProcessUtil.getPkg(pkgByte);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 筛选出试卷类型
|
|
|
+ * @param extractConfig
|
|
|
+ * @param paperId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String findPaperType(ExtractConfig extractConfig,String paperId){
|
|
|
+ String paperType = "";
|
|
|
+ Map<String,String> paperIdMap = extractConfig.getFinishedPaperIdMap();
|
|
|
+ Set<Entry<String,String>> entry = paperIdMap.entrySet();
|
|
|
+ Iterator<Entry<String,String>> iterator = entry.iterator();
|
|
|
+ while(iterator.hasNext()){
|
|
|
+ Entry<String,String> next = iterator.next();
|
|
|
+ if(paperId.equals(next.getValue())){
|
|
|
+ paperType = next.getKey();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return paperType;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|