|
@@ -67,7 +67,7 @@ public class ExportPaperServiceImpl implements ExportPaperService{
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void exportPaperFile(String paperId,String serviceName,String exportContentList,HttpServletResponse response,String loginName, String examType) throws Exception {
|
|
public void exportPaperFile(String paperId,String serviceName,String exportContentList,HttpServletResponse response,String loginName, String examType) throws Exception {
|
|
- ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById(serviceName);
|
|
|
|
|
|
+ ExportPaperAbstractService exportPaperAbstractService = (ExportPaperAbstractService) SpringContextUtils.getBeanById("tjdxExportPaperService");
|
|
//根据试卷id查询试卷
|
|
//根据试卷id查询试卷
|
|
Paper paper = paperRepo.findOne(paperId);
|
|
Paper paper = paperRepo.findOne(paperId);
|
|
List<Paper> papers = new ArrayList<Paper>();
|
|
List<Paper> papers = new ArrayList<Paper>();
|
|
@@ -163,9 +163,11 @@ public class ExportPaperServiceImpl implements ExportPaperService{
|
|
//设置小题题号
|
|
//设置小题题号
|
|
computerTestQuestion.setNumber(i+1);
|
|
computerTestQuestion.setNumber(i+1);
|
|
//得到小题题干
|
|
//得到小题题干
|
|
- computerTestQuestion.setBody(getBody(paperDetailUnit.getQuestion()));
|
|
|
|
|
|
+ computerTestQuestion.setBody(getBodyOrAnswer(paperDetailUnit.getQuestion().getQuesBody()));
|
|
//得到小题所有选项
|
|
//得到小题所有选项
|
|
computerTestQuestion.setOptions(getOption(paperDetailUnit.getQuestion()));
|
|
computerTestQuestion.setOptions(getOption(paperDetailUnit.getQuestion()));
|
|
|
|
+ //得到小题的答案
|
|
|
|
+ computerTestQuestion.setAnswer(getBodyOrAnswer(paperDetailUnit.getQuestion().getQuesAnswer()));
|
|
//查询小题中的 套题
|
|
//查询小题中的 套题
|
|
List<Question> subQuestionsList = paperDetailUnit.getQuestion().getSubQuestions();
|
|
List<Question> subQuestionsList = paperDetailUnit.getQuestion().getSubQuestions();
|
|
//判断这个小题中是否有套题
|
|
//判断这个小题中是否有套题
|
|
@@ -177,14 +179,14 @@ public class ExportPaperServiceImpl implements ExportPaperService{
|
|
ComputerTestQuestion subcomputerTestQuestion = new ComputerTestQuestion(subQuestion);
|
|
ComputerTestQuestion subcomputerTestQuestion = new ComputerTestQuestion(subQuestion);
|
|
//设置套题中小题题号
|
|
//设置套题中小题题号
|
|
subcomputerTestQuestion.setNumber(j+1);
|
|
subcomputerTestQuestion.setNumber(j+1);
|
|
- subcomputerTestQuestion.setBody(getBody(subQuestion));
|
|
|
|
|
|
+ subcomputerTestQuestion.setBody(getBodyOrAnswer(paperDetailUnit.getQuestion().getQuesBody()));
|
|
subcomputerTestQuestion.setOptions(getOption(subQuestion));
|
|
subcomputerTestQuestion.setOptions(getOption(subQuestion));
|
|
|
|
+ subcomputerTestQuestion.setAnswer(getBodyOrAnswer(paperDetailUnit.getQuestion().getQuesAnswer()));
|
|
subQuestions.add(subcomputerTestQuestion);
|
|
subQuestions.add(subcomputerTestQuestion);
|
|
}
|
|
}
|
|
computerTestQuestion.setSubQuestions(subQuestions);
|
|
computerTestQuestion.setSubQuestions(subQuestions);
|
|
}
|
|
}
|
|
questions.add(computerTestQuestion);
|
|
questions.add(computerTestQuestion);
|
|
-
|
|
|
|
}
|
|
}
|
|
computerTestPaperDetail.setQuestions(questions);
|
|
computerTestPaperDetail.setQuestions(questions);
|
|
//paperDetail中的题数(unitCount)可能不准确,这里以questions的实际size为准
|
|
//paperDetail中的题数(unitCount)可能不准确,这里以questions的实际size为准
|
|
@@ -195,13 +197,14 @@ public class ExportPaperServiceImpl implements ExportPaperService{
|
|
return computerTestPaper;
|
|
return computerTestPaper;
|
|
}
|
|
}
|
|
|
|
|
|
- private Sections getBody(Question question){
|
|
|
|
|
|
+ private Sections getBodyOrAnswer(String str){
|
|
Sections body = new Sections();
|
|
Sections body = new Sections();
|
|
- List<Section> sections = new ArrayList<Section>();
|
|
|
|
- //得到小题题干
|
|
|
|
- String questionBodyString = question.getQuesBody();
|
|
|
|
- //得到小题题干行数
|
|
|
|
- String[] questionRowStrings = questionBodyString.split("</p>");
|
|
|
|
|
|
+ List<Section> sections = new ArrayList<Section>();
|
|
|
|
+ //得到小题题干或者答案行数
|
|
|
|
+ if(StringUtils.isBlank(str)){
|
|
|
|
+ return body;
|
|
|
|
+ }
|
|
|
|
+ String[] questionRowStrings = str.split("</p>");
|
|
for(int i = 0;i<questionRowStrings.length;i++){
|
|
for(int i = 0;i<questionRowStrings.length;i++){
|
|
Section section = new Section();
|
|
Section section = new Section();
|
|
//将小题题干拆分为Block集合
|
|
//将小题题干拆分为Block集合
|
|
@@ -376,9 +379,22 @@ public class ExportPaperServiceImpl implements ExportPaperService{
|
|
}
|
|
}
|
|
//下载机考数据包
|
|
//下载机考数据包
|
|
if(exportContentList.indexOf("COMPUTERTEST_PACKAGE")>-1){
|
|
if(exportContentList.indexOf("COMPUTERTEST_PACKAGE")>-1){
|
|
|
|
+ //创建json文件夹
|
|
|
|
+ String jsonDir = TEMP_FILE_EXP + File.separator + zipFileName + File.separator + "json";
|
|
|
|
+ File jsonDirectory = new File(jsonDir);
|
|
|
|
+ if(!jsonDirectory.exists()){
|
|
|
|
+ jsonDirectory.mkdirs();
|
|
|
|
+ }
|
|
for(Paper paper:papers){
|
|
for(Paper paper:papers){
|
|
ComputerTestPaper computerTestPaper = buildComputerTestPapers(paper);
|
|
ComputerTestPaper computerTestPaper = buildComputerTestPapers(paper);
|
|
- makeComputerTestPaperToJsonFile(paper.getCourse().getCode()+ "_" +paper.getName(),computerTestPaper,TEMP_FILE_EXP+File.separator+zipFileName);
|
|
|
|
|
|
+ makeComputerTestPaperToJsonFile(paper.getCourse().getCode()+ "_" +paper.getName(),computerTestPaper,jsonDir);
|
|
|
|
+ }
|
|
|
|
+ //将文件夹打包成zip压缩包放在docxExport下
|
|
|
|
+ FileDisposeUtil.fileToZip(jsonDir,TEMP_FILE_EXP+File.separator+zipFileName,CommonUtils.getCurDate());
|
|
|
|
+ //删除json文件夹
|
|
|
|
+ File ComputerTestPaperfoler = new File(jsonDir);
|
|
|
|
+ if(ComputerTestPaperfoler.exists()){
|
|
|
|
+ FileUtils.deleteQuietly(ComputerTestPaperfoler);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
FileDisposeUtil.fileToZip(TEMP_FILE_EXP+File.separator+zipFileName,TEMP_FILE_EXP,zipFileName);
|
|
FileDisposeUtil.fileToZip(TEMP_FILE_EXP+File.separator+zipFileName,TEMP_FILE_EXP,zipFileName);
|