|
@@ -91,25 +91,27 @@ public class ExportThemisPaperServiceImpl implements ExportThemisPaperService {
|
|
|
// int bodyNum = 1;
|
|
|
// 取到题干
|
|
|
ThemisSections body = question.getBody();
|
|
|
- List<ThemisSection> sections = body.getSections();
|
|
|
- if (sections != null && sections.size() > 0) {
|
|
|
- for (ThemisSection section : sections) {
|
|
|
- List<ThemisBlock> blocks = section.getBlocks();
|
|
|
- if (blocks != null && blocks.size() > 0) {
|
|
|
- for (ThemisBlock block : blocks) {
|
|
|
- if (block.getType().equals("audio")) {
|
|
|
- String val = block.getValue().toString();
|
|
|
- String id = val.substring(0, val.lastIndexOf("."));
|
|
|
- QuestionAudio questionAudio = Model.of(questionAudioRepo.findById(id));
|
|
|
- String audioFileName = questionAudio.getId() + "."
|
|
|
- + questionAudio.getFileSuffixes();
|
|
|
- File file = new File(attDirectory + audioFileName);
|
|
|
-
|
|
|
- String filePath = FssHelper.fixFilePath(questionAudio.getFileUrl());
|
|
|
- FssFactory.getInstance().readFile(filePath, file);
|
|
|
-
|
|
|
- count++;
|
|
|
- // bodyNum++;
|
|
|
+ if (body != null) {
|
|
|
+ List<ThemisSection> sections = body.getSections();
|
|
|
+ if (sections != null && sections.size() > 0) {
|
|
|
+ for (ThemisSection section : sections) {
|
|
|
+ List<ThemisBlock> blocks = section.getBlocks();
|
|
|
+ if (blocks != null && blocks.size() > 0) {
|
|
|
+ for (ThemisBlock block : blocks) {
|
|
|
+ if (block.getType().equals("audio")) {
|
|
|
+ String val = block.getValue().toString();
|
|
|
+ String id = val.substring(0, val.lastIndexOf("."));
|
|
|
+ QuestionAudio questionAudio = Model.of(questionAudioRepo.findById(id));
|
|
|
+ String audioFileName = questionAudio.getId() + "."
|
|
|
+ + questionAudio.getFileSuffixes();
|
|
|
+ File file = new File(attDirectory + audioFileName);
|
|
|
+
|
|
|
+ String filePath = FssHelper.fixFilePath(questionAudio.getFileUrl());
|
|
|
+ FssFactory.getInstance().readFile(filePath, file);
|
|
|
+
|
|
|
+ count++;
|
|
|
+ // bodyNum++;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -122,26 +124,29 @@ public class ExportThemisPaperServiceImpl implements ExportThemisPaperService {
|
|
|
// int optionNum = 1;
|
|
|
// 获取选项主体
|
|
|
ThemisSections optionBody = computerTestOption.getBody();
|
|
|
- List<ThemisSection> optionSections = optionBody.getSections();
|
|
|
- if (optionSections != null && optionSections.size() > 0) {
|
|
|
- for (ThemisSection optionSection : optionSections) {
|
|
|
- List<ThemisBlock> blocks = optionSection.getBlocks();
|
|
|
- if (blocks != null && blocks.size() > 0) {
|
|
|
- for (ThemisBlock block : blocks) {
|
|
|
- if (block.getType().equals("audio")) {
|
|
|
- String val = block.getValue().toString();
|
|
|
- String id = val.substring(0, val.lastIndexOf("."));
|
|
|
- QuestionAudio questionAudio = Model
|
|
|
- .of(questionAudioRepo.findById(id));
|
|
|
- String audioFileName = questionAudio.getId() + "."
|
|
|
- + questionAudio.getFileSuffixes();
|
|
|
- File file = new File(attDirectory + audioFileName);
|
|
|
-
|
|
|
- String filePath = FssHelper.fixFilePath(questionAudio.getFileUrl());
|
|
|
- FssFactory.getInstance().readFile(filePath, file);
|
|
|
-
|
|
|
- count++;
|
|
|
- // optionNum++;
|
|
|
+ if (optionBody != null) {
|
|
|
+ List<ThemisSection> optionSections = optionBody.getSections();
|
|
|
+ if (optionSections != null && optionSections.size() > 0) {
|
|
|
+ for (ThemisSection optionSection : optionSections) {
|
|
|
+ List<ThemisBlock> blocks = optionSection.getBlocks();
|
|
|
+ if (blocks != null && blocks.size() > 0) {
|
|
|
+ for (ThemisBlock block : blocks) {
|
|
|
+ if (block.getType().equals("audio")) {
|
|
|
+ String val = block.getValue().toString();
|
|
|
+ String id = val.substring(0, val.lastIndexOf("."));
|
|
|
+ QuestionAudio questionAudio = Model
|
|
|
+ .of(questionAudioRepo.findById(id));
|
|
|
+ String audioFileName = questionAudio.getId() + "."
|
|
|
+ + questionAudio.getFileSuffixes();
|
|
|
+ File file = new File(attDirectory + audioFileName);
|
|
|
+
|
|
|
+ String filePath = FssHelper
|
|
|
+ .fixFilePath(questionAudio.getFileUrl());
|
|
|
+ FssFactory.getInstance().readFile(filePath, file);
|
|
|
+
|
|
|
+ count++;
|
|
|
+ // optionNum++;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|