|
@@ -24,15 +24,19 @@ import org.apache.commons.lang3.StringUtils;
|
|
import org.jsoup.Jsoup;
|
|
import org.jsoup.Jsoup;
|
|
import org.jsoup.nodes.Document;
|
|
import org.jsoup.nodes.Document;
|
|
import org.jsoup.nodes.Element;
|
|
import org.jsoup.nodes.Element;
|
|
|
|
+import org.jsoup.nodes.Node;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
public class MyConsumer extends Consumer<String> {
|
|
public class MyConsumer extends Consumer<String> {
|
|
|
|
+ private String paperSuff = "(211)";
|
|
|
|
+ private int maxqc = 100;
|
|
|
|
|
|
private String excelDir = "D:\\kd_export\\";
|
|
private String excelDir = "D:\\kd_export\\";
|
|
|
|
+ private String picFiles = "D:\\files\\";
|
|
|
|
|
|
private Pattern mp3Pat = Pattern.compile("<a[^<]+href=\"([^<\"]+\\.mp3)\"[^<]*>[^<]*</a>");
|
|
private Pattern mp3Pat = Pattern.compile("<a[^<]+href=\"([^<\"]+\\.mp3)\"[^<]*>[^<]*</a>");
|
|
- private Pattern imgPat = Pattern.compile("<img[^<]+src=\"([^<\"]+)\"[^<]*/>");
|
|
|
|
|
|
+ private Pattern imgPat = Pattern.compile("<img[^<]+src=\"([^<\"]+)\"[^<]*>");
|
|
|
|
|
|
private Pattern notmp3Pat = Pattern.compile("<a[^<]+href=\"[^<\"]+(?!\\.mp3)\"[^<]*>([^<]*)</a>");
|
|
private Pattern notmp3Pat = Pattern.compile("<a[^<]+href=\"[^<\"]+(?!\\.mp3)\"[^<]*>([^<]*)</a>");
|
|
|
|
|
|
@@ -169,7 +173,7 @@ public class MyConsumer extends Consumer<String> {
|
|
while (resultSet.next()) {
|
|
while (resultSet.next()) {
|
|
KdQuestion q = new KdQuestion();
|
|
KdQuestion q = new KdQuestion();
|
|
q.setId(resultSet.getLong("id"));
|
|
q.setId(resultSet.getLong("id"));
|
|
- q.setBody(resultSet.getString("questiontext"));
|
|
|
|
|
|
+ q.setBody(disBody(resultSet.getString("questiontext")));
|
|
q.setQtype(resultSet.getString("qtype"));
|
|
q.setQtype(resultSet.getString("qtype"));
|
|
q.setObjective(true);
|
|
q.setObjective(true);
|
|
qs.add(q);
|
|
qs.add(q);
|
|
@@ -237,7 +241,6 @@ public class MyConsumer extends Consumer<String> {
|
|
for (KdQuestion q : qs) {
|
|
for (KdQuestion q : qs) {
|
|
List<Answer> as = getAnswer(connect, q);
|
|
List<Answer> as = getAnswer(connect, q);
|
|
disposeAnswer(q, as);
|
|
disposeAnswer(q, as);
|
|
- removeATag(q);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
qs = removeInvalidQuestion(qs, code);
|
|
qs = removeInvalidQuestion(qs, code);
|
|
@@ -245,17 +248,28 @@ public class MyConsumer extends Consumer<String> {
|
|
noques.add(code);
|
|
noques.add(code);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
- KdPaper paper = new KdPaper();
|
|
|
|
- paper.setTotalScore((double) qs.size());
|
|
|
|
- paper.setName(c.getName());
|
|
|
|
- paper.setCourseCode(c.getCode());
|
|
|
|
- File courseCode = new File(excelDir + paper.getCourseCode() + "\\");
|
|
|
|
|
|
+ File courseCode = new File(excelDir + c.getCode() + "\\");
|
|
courseCode.mkdirs();
|
|
courseCode.mkdirs();
|
|
- File att = new File(excelDir + paper.getCourseCode() + "\\att\\");
|
|
|
|
|
|
+ File att = new File(excelDir + c.getCode() + "\\att\\");
|
|
att.mkdirs();
|
|
att.mkdirs();
|
|
for (KdQuestion q : qs) {
|
|
for (KdQuestion q : qs) {
|
|
- disposeMedia(connect, c.getIdnumber(), q, att);
|
|
|
|
|
|
+ try {
|
|
|
|
+ disposeMedia(connect, c.getIdnumber(), q, att);
|
|
|
|
+ q.setValid(true);
|
|
|
|
+ } catch (MediaNotFoundException e) {
|
|
|
|
+ q.setValid(false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<KdQuestion> tem = new ArrayList<>();
|
|
|
|
+ for (KdQuestion q : qs) {
|
|
|
|
+ if (q.getValid()) {
|
|
|
|
+ tem.add(q);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ qs = tem;
|
|
|
|
+ if (qs.size() == 0) {
|
|
|
|
+ noques.add(code);
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
List<KdQuestion> single = new ArrayList<>();
|
|
List<KdQuestion> single = new ArrayList<>();
|
|
@@ -270,43 +284,96 @@ public class MyConsumer extends Consumer<String> {
|
|
boo.add(q);
|
|
boo.add(q);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ createPapers(single, c, 1);
|
|
|
|
+ createPapers(muti, c, 2);
|
|
|
|
+ createPapers(boo, c, 3);
|
|
|
|
+
|
|
|
|
+// int detailIndx = 0;
|
|
|
|
+// List<KdDetail> des = new ArrayList<>();
|
|
|
|
+// if (single.size() > 0) {
|
|
|
|
+// detailIndx++;
|
|
|
|
+// KdDetail d = new KdDetail();
|
|
|
|
+// d.setName("单选题");
|
|
|
|
+// d.setNumber(detailIndx);
|
|
|
|
+// d.setQuestionCount(single.size());
|
|
|
|
+// d.setTotalScore((double) single.size());
|
|
|
|
+// d.setQuestions(single);
|
|
|
|
+// des.add(d);
|
|
|
|
+// }
|
|
|
|
+// if (muti.size() > 0) {
|
|
|
|
+// detailIndx++;
|
|
|
|
+// KdDetail d = new KdDetail();
|
|
|
|
+// d.setName("多选题");
|
|
|
|
+// d.setNumber(detailIndx);
|
|
|
|
+// d.setQuestionCount(muti.size());
|
|
|
|
+// d.setTotalScore((double) muti.size());
|
|
|
|
+// d.setQuestions(muti);
|
|
|
|
+// des.add(d);
|
|
|
|
+// }
|
|
|
|
+// if (boo.size() > 0) {
|
|
|
|
+// detailIndx++;
|
|
|
|
+// KdDetail d = new KdDetail();
|
|
|
|
+// d.setName("判断题");
|
|
|
|
+// d.setNumber(detailIndx);
|
|
|
|
+// d.setQuestionCount(boo.size());
|
|
|
|
+// d.setTotalScore((double) boo.size());
|
|
|
|
+// d.setQuestions(boo);
|
|
|
|
+// des.add(d);
|
|
|
|
+// }
|
|
|
|
+// paper.setDetails(des);
|
|
|
|
+// paper.setDetailCount(detailIndx);
|
|
|
|
+//
|
|
|
|
+// FileUtil.writeFile(courseCode.getAbsolutePath(), "\\paper.json", JSONObject.toJSONString(paper));
|
|
|
|
+ }
|
|
|
|
|
|
- int detailIndx = 0;
|
|
|
|
- List<KdDetail> des = new ArrayList<>();
|
|
|
|
- if (single.size() > 0) {
|
|
|
|
- detailIndx++;
|
|
|
|
- KdDetail d = new KdDetail();
|
|
|
|
- d.setName("单选题");
|
|
|
|
- d.setNumber(detailIndx);
|
|
|
|
- d.setQuestionCount(single.size());
|
|
|
|
- d.setTotalScore((double) single.size());
|
|
|
|
- d.setQuestions(single);
|
|
|
|
- des.add(d);
|
|
|
|
- }
|
|
|
|
- if (muti.size() > 0) {
|
|
|
|
- detailIndx++;
|
|
|
|
- KdDetail d = new KdDetail();
|
|
|
|
- d.setName("多选题");
|
|
|
|
- d.setNumber(detailIndx);
|
|
|
|
- d.setQuestionCount(muti.size());
|
|
|
|
- d.setTotalScore((double) muti.size());
|
|
|
|
- d.setQuestions(muti);
|
|
|
|
- des.add(d);
|
|
|
|
- }
|
|
|
|
- if (boo.size() > 0) {
|
|
|
|
- detailIndx++;
|
|
|
|
- KdDetail d = new KdDetail();
|
|
|
|
- d.setName("判断题");
|
|
|
|
- d.setNumber(detailIndx);
|
|
|
|
- d.setQuestionCount(boo.size());
|
|
|
|
- d.setTotalScore((double) boo.size());
|
|
|
|
- d.setQuestions(boo);
|
|
|
|
- des.add(d);
|
|
|
|
|
|
+ private void createPapers(List<KdQuestion> qs, Course c, int structType) throws IOException {
|
|
|
|
+ if (qs == null || qs.size() == 0) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (qs.size() <= maxqc) {
|
|
|
|
+ createPaper(qs, c, structType, 1);
|
|
|
|
+ } else {
|
|
|
|
+ int size = qs.size();
|
|
|
|
+ int len = maxqc;
|
|
|
|
+ int count = (size + len - 1) / len;
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < count; i++) {
|
|
|
|
+ List<KdQuestion> subList = qs.subList(i * len, ((i + 1) * len > size ? size : len * (i + 1)));
|
|
|
|
+ createPaper(subList, c, structType, i + 1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- paper.setDetails(des);
|
|
|
|
- paper.setDetailCount(detailIndx);
|
|
|
|
|
|
|
|
- FileUtil.writeFile(courseCode.getAbsolutePath(), "\\paper.json", JSONObject.toJSONString(paper));
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void createPaper(List<KdQuestion> qs, Course c, int structType, int indx) throws IOException {
|
|
|
|
+ if (qs.size() == 0) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ String detailName="";
|
|
|
|
+ if (structType == 1) {
|
|
|
|
+ detailName="单选题";
|
|
|
|
+ } else if (structType == 2) {
|
|
|
|
+ detailName="多选题";
|
|
|
|
+ } else if (structType == 3) {
|
|
|
|
+ detailName="判断题";
|
|
|
|
+ }
|
|
|
|
+ KdPaper paper = new KdPaper();
|
|
|
|
+ paper.setTotalScore((double) qs.size());
|
|
|
|
+ paper.setName(c.getName()+paperSuff+detailName+"_"+indx);
|
|
|
|
+ paper.setCourseCode(c.getCode());
|
|
|
|
+ List<KdDetail> des = new ArrayList<>();
|
|
|
|
+ KdDetail d = new KdDetail();
|
|
|
|
+ d.setName(detailName);
|
|
|
|
+ d.setNumber(1);
|
|
|
|
+ d.setQuestionCount(qs.size());
|
|
|
|
+ d.setTotalScore((double) qs.size());
|
|
|
|
+ d.setQuestions(qs);
|
|
|
|
+ des.add(d);
|
|
|
|
+ paper.setDetails(des);
|
|
|
|
+ paper.setDetailCount(1);
|
|
|
|
+ File paperdir = new File(excelDir + c.getCode() + "\\paper"+structType+"_"+indx+"\\");
|
|
|
|
+ paperdir.mkdirs();
|
|
|
|
+ FileUtil.writeFile(paperdir.getAbsolutePath(), "\\paper.json", JSONObject.toJSONString(paper));
|
|
}
|
|
}
|
|
|
|
|
|
private List<KdQuestion> removeInvalidQuestion(List<KdQuestion> qs, String courseCode) {
|
|
private List<KdQuestion> removeInvalidQuestion(List<KdQuestion> qs, String courseCode) {
|
|
@@ -371,7 +438,7 @@ public class MyConsumer extends Consumer<String> {
|
|
KdQuesOption op = new KdQuesOption();
|
|
KdQuesOption op = new KdQuesOption();
|
|
op.setAnswerId(a.getId());
|
|
op.setAnswerId(a.getId());
|
|
op.setNumber(index);
|
|
op.setNumber(index);
|
|
- op.setBody(a.getBody());
|
|
|
|
|
|
+ op.setBody(disBody(a.getBody()));
|
|
if (a.getScore() > 0) {
|
|
if (a.getScore() > 0) {
|
|
op.setSelect(true);
|
|
op.setSelect(true);
|
|
sb.append(index).append(",");
|
|
sb.append(index).append(",");
|
|
@@ -393,56 +460,117 @@ public class MyConsumer extends Consumer<String> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private String getInStr(List<Long> cids) {
|
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
|
- for (Long id : cids) {
|
|
|
|
- sb.append(id).append(",");
|
|
|
|
|
|
+ private String disBody(String html) {
|
|
|
|
+ Document doc = Jsoup.parse(html);
|
|
|
|
+ Element b = doc.body();
|
|
|
|
+ if (b.childrenSize() == 1 && "p".equals(b.child(0).nodeName())) {
|
|
|
|
+ b.child(0).tagName("span");
|
|
|
|
+ }
|
|
|
|
+ if (b.childrenSize() > 0) {
|
|
|
|
+ for (Element n : b.children()) {
|
|
|
|
+ if ("p".equals(n.nodeName())) {
|
|
|
|
+ boolean[] find = new boolean[] { false };
|
|
|
|
+ findImg(n, find);
|
|
|
|
+ if (!find[0] && StringUtils.isBlank(n.text())) {
|
|
|
|
+ n.tagName("span");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ disNode(n);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- sb.deleteCharAt(sb.length() - 1);
|
|
|
|
- return sb.toString();
|
|
|
|
|
|
+ return b.html();
|
|
}
|
|
}
|
|
|
|
|
|
- private Map<String, String> findAtag(String body) {
|
|
|
|
- Map<String, String> set = new HashMap<>();
|
|
|
|
- if (StringUtils.isBlank(body)) {
|
|
|
|
- return set;
|
|
|
|
- }
|
|
|
|
- Matcher m = notmp3Pat.matcher(body);
|
|
|
|
- while (m.find()) {
|
|
|
|
- String f = m.group(1);
|
|
|
|
- set.put(m.group(), f);
|
|
|
|
|
|
+ private void findImg(Element e, boolean[] find) {
|
|
|
|
+ if (find[0]) {
|
|
|
|
+ return;
|
|
|
|
+ } else {
|
|
|
|
+ if ("img".equals(e.nodeName())) {
|
|
|
|
+ find[0] = true;
|
|
|
|
+ return;
|
|
|
|
+ } else {
|
|
|
|
+ if (e.childrenSize() > 0) {
|
|
|
|
+ for (Element ce : e.children()) {
|
|
|
|
+ findImg(ce, find);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- return set;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private void removeATag(KdQuestion q) throws Exception {
|
|
|
|
- String body = q.getBody();
|
|
|
|
-
|
|
|
|
- Map<String, String> as = findAtag(body);
|
|
|
|
- if (as.size() > 0) {
|
|
|
|
- for (String k : as.keySet()) {
|
|
|
|
- String val = as.get(k);
|
|
|
|
- body = body.replaceAll(k, val);
|
|
|
|
|
|
+ private static void disNode(Node n) {
|
|
|
|
+ if (n instanceof Element) {
|
|
|
|
+ if (!"img".equals(n.nodeName())) {
|
|
|
|
+ n.removeAttr("style");
|
|
}
|
|
}
|
|
- q.setBody(body);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (CollectionUtils.isNotEmpty(q.getOptions())) {
|
|
|
|
- for (KdQuesOption o : q.getOptions()) {
|
|
|
|
- String obody = o.getBody();
|
|
|
|
-
|
|
|
|
- Map<String, String> oas = findAtag(obody);
|
|
|
|
- if (oas.size() > 0) {
|
|
|
|
- for (String k : oas.keySet()) {
|
|
|
|
- String val = oas.get(k);
|
|
|
|
- obody = obody.replaceAll(k, val);
|
|
|
|
- }
|
|
|
|
- o.setBody(obody);
|
|
|
|
|
|
+ if ("h1".equals(n.nodeName()) || "h2".equals(n.nodeName()) || "h3".equals(n.nodeName())
|
|
|
|
+ || "h4".equals(n.nodeName()) || "h5".equals(n.nodeName())) {
|
|
|
|
+ ((Element) n).tagName("h6");
|
|
|
|
+ }
|
|
|
|
+ if ("strong".equals(n.nodeName()) || "a".equals(n.nodeName()) || "u".equals(n.nodeName())
|
|
|
|
+ || "em".equals(n.nodeName())) {
|
|
|
|
+ ((Element) n).tagName("span");
|
|
|
|
+ }
|
|
|
|
+ if (n.childNodeSize() > 0) {
|
|
|
|
+ for (Node cn : n.childNodes()) {
|
|
|
|
+ disNode(cn);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private String getInStr(List<Long> cids) {
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
+ for (Long id : cids) {
|
|
|
|
+ sb.append(id).append(",");
|
|
|
|
+ }
|
|
|
|
+ sb.deleteCharAt(sb.length() - 1);
|
|
|
|
+ return sb.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// private Map<String, String> findAtag(String body) {
|
|
|
|
+// Map<String, String> set = new HashMap<>();
|
|
|
|
+// if (StringUtils.isBlank(body)) {
|
|
|
|
+// return set;
|
|
|
|
+// }
|
|
|
|
+// Matcher m = notmp3Pat.matcher(body);
|
|
|
|
+// while (m.find()) {
|
|
|
|
+// String f = m.group(1);
|
|
|
|
+// set.put(m.group(), f);
|
|
|
|
+// }
|
|
|
|
+// return set;
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// private void removeATag(KdQuestion q) throws Exception {
|
|
|
|
+// String body = q.getBody();
|
|
|
|
+//
|
|
|
|
+// Map<String, String> as = findAtag(body);
|
|
|
|
+// if (as.size() > 0) {
|
|
|
|
+// for (String k : as.keySet()) {
|
|
|
|
+// String val = as.get(k);
|
|
|
|
+// body = body.replaceAll(k, val);
|
|
|
|
+// }
|
|
|
|
+// q.setBody(body);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if (CollectionUtils.isNotEmpty(q.getOptions())) {
|
|
|
|
+// for (KdQuesOption o : q.getOptions()) {
|
|
|
|
+// String obody = o.getBody();
|
|
|
|
+//
|
|
|
|
+// Map<String, String> oas = findAtag(obody);
|
|
|
|
+// if (oas.size() > 0) {
|
|
|
|
+// for (String k : oas.keySet()) {
|
|
|
|
+// String val = oas.get(k);
|
|
|
|
+// obody = obody.replaceAll(k, val);
|
|
|
|
+// }
|
|
|
|
+// o.setBody(obody);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+
|
|
private void disposeMedia(Connection connect, String courseidnumber, KdQuestion q, File att) throws Exception {
|
|
private void disposeMedia(Connection connect, String courseidnumber, KdQuestion q, File att) throws Exception {
|
|
String body = q.getBody();
|
|
String body = q.getBody();
|
|
|
|
|
|
@@ -454,10 +582,11 @@ public class MyConsumer extends Consumer<String> {
|
|
File file = getQuestionFile(connect, q.getId(), courseidnumber, fileName);
|
|
File file = getQuestionFile(connect, q.getId(), courseidnumber, fileName);
|
|
if (file == null) {
|
|
if (file == null) {
|
|
ExportByCourseCode.addNotFd();
|
|
ExportByCourseCode.addNotFd();
|
|
- body = body.replaceAll(k, "[未找到图片文件]");
|
|
|
|
|
|
+// body = body.replaceAll(k, "[未找到图片文件]");
|
|
|
|
+ throw new MediaNotFoundException();
|
|
} else {
|
|
} else {
|
|
ExportByCourseCode.addFd();
|
|
ExportByCourseCode.addFd();
|
|
- body = body.replaceAll(img, FileUtil.fileToBase64Src(file));
|
|
|
|
|
|
+ body = body.replaceAll(img.replaceAll("\\?", "\\\\?"), FileUtil.fileToBase64Src(file));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
q.setBody(body);
|
|
q.setBody(body);
|
|
@@ -471,13 +600,14 @@ public class MyConsumer extends Consumer<String> {
|
|
File file = getQuestionFile(connect, q.getId(), courseidnumber, fileName);
|
|
File file = getQuestionFile(connect, q.getId(), courseidnumber, fileName);
|
|
if (file == null) {
|
|
if (file == null) {
|
|
ExportByCourseCode.addNotFd();
|
|
ExportByCourseCode.addNotFd();
|
|
- body = body.replaceAll(k, "[未找到音频文件]");
|
|
|
|
|
|
+// body = body.replaceAll(k, "[未找到音频文件]");
|
|
|
|
+ throw new MediaNotFoundException();
|
|
} else {
|
|
} else {
|
|
ExportByCourseCode.addFd();
|
|
ExportByCourseCode.addFd();
|
|
File newAudio = new File(att.getAbsoluteFile() + "\\" + file.getName());
|
|
File newAudio = new File(att.getAbsoluteFile() + "\\" + file.getName());
|
|
newAudio.createNewFile();
|
|
newAudio.createNewFile();
|
|
FileUtils.copyFile(file, newAudio);
|
|
FileUtils.copyFile(file, newAudio);
|
|
- body = body.replaceAll(k, "<a id=\"" + file.getName() + "\" name=\"" + file.getName() + "\"></a>");
|
|
|
|
|
|
+ body = body.replaceAll(k.replaceAll("\\?", "\\\\?"), "<a id=\"" + file.getName() + "\" name=\"" + file.getName() + "\"></a>");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
q.setBody(body);
|
|
q.setBody(body);
|
|
@@ -495,10 +625,11 @@ public class MyConsumer extends Consumer<String> {
|
|
File file = getAnswerFile(connect, o.getAnswerId(), courseidnumber, fileName);
|
|
File file = getAnswerFile(connect, o.getAnswerId(), courseidnumber, fileName);
|
|
if (file == null) {
|
|
if (file == null) {
|
|
ExportByCourseCode.addNotFd();
|
|
ExportByCourseCode.addNotFd();
|
|
- obody = obody.replaceAll(k, "[未找到图片文件]");
|
|
|
|
|
|
+// obody = obody.replaceAll(k, "[未找到图片文件]");
|
|
|
|
+ throw new MediaNotFoundException();
|
|
} else {
|
|
} else {
|
|
ExportByCourseCode.addFd();
|
|
ExportByCourseCode.addFd();
|
|
- obody = obody.replaceAll(img, FileUtil.fileToBase64Src(file));
|
|
|
|
|
|
+ obody = obody.replaceAll(img.replaceAll("\\?", "\\\\?"), FileUtil.fileToBase64Src(file));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
o.setBody(obody);
|
|
o.setBody(obody);
|
|
@@ -513,13 +644,14 @@ public class MyConsumer extends Consumer<String> {
|
|
File file = getAnswerFile(connect, o.getAnswerId(), courseidnumber, fileName);
|
|
File file = getAnswerFile(connect, o.getAnswerId(), courseidnumber, fileName);
|
|
if (file == null) {
|
|
if (file == null) {
|
|
ExportByCourseCode.addNotFd();
|
|
ExportByCourseCode.addNotFd();
|
|
- obody = obody.replaceAll(k, "[未找到音频文件]");
|
|
|
|
|
|
+// obody = obody.replaceAll(k, "[未找到音频文件]");
|
|
|
|
+ throw new MediaNotFoundException();
|
|
} else {
|
|
} else {
|
|
ExportByCourseCode.addFd();
|
|
ExportByCourseCode.addFd();
|
|
File newAudio = new File(att.getAbsoluteFile() + "\\" + file.getName());
|
|
File newAudio = new File(att.getAbsoluteFile() + "\\" + file.getName());
|
|
newAudio.createNewFile();
|
|
newAudio.createNewFile();
|
|
FileUtils.copyFile(file, newAudio);
|
|
FileUtils.copyFile(file, newAudio);
|
|
- obody = obody.replaceAll(k,
|
|
|
|
|
|
+ obody = obody.replaceAll(k.replaceAll("\\?", "\\\\?"),
|
|
"<a id=\"" + file.getName() + "\" name=\"" + file.getName() + "\"></a>");
|
|
"<a id=\"" + file.getName() + "\" name=\"" + file.getName() + "\"></a>");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -641,8 +773,7 @@ public class MyConsumer extends Consumer<String> {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
String suff = fileName.substring(fileName.lastIndexOf("."));
|
|
String suff = fileName.substring(fileName.lastIndexOf("."));
|
|
- File directory = new File("");
|
|
|
|
- File file = new File(directory.getAbsolutePath() + "\\files\\" + courseidnumber + "\\" + hash + suff);
|
|
|
|
|
|
+ File file = new File(picFiles + courseidnumber + "\\" + hash + suff);
|
|
if (!file.exists()) {
|
|
if (!file.exists()) {
|
|
qzip.add(quesId + " " + courseidnumber + " " + fileName);
|
|
qzip.add(quesId + " " + courseidnumber + " " + fileName);
|
|
return null;
|
|
return null;
|
|
@@ -679,8 +810,7 @@ public class MyConsumer extends Consumer<String> {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
String suff = fileName.substring(fileName.lastIndexOf("."));
|
|
String suff = fileName.substring(fileName.lastIndexOf("."));
|
|
- File directory = new File("");
|
|
|
|
- File file = new File(directory.getAbsolutePath() + "\\files\\" + courseidnumber + "\\" + hash + suff);
|
|
|
|
|
|
+ File file = new File(picFiles + courseidnumber + "\\" + hash + suff);
|
|
if (!file.exists()) {
|
|
if (!file.exists()) {
|
|
azip.add(answerId + " " + courseidnumber + " " + fileName);
|
|
azip.add(answerId + " " + courseidnumber + " " + fileName);
|
|
return null;
|
|
return null;
|