|
@@ -303,75 +303,82 @@ public abstract class ExportPaperAbstractService {
|
|
|
return String.valueOf(optionNum);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 替换填空
|
|
|
- * 将###替换为下划线_______
|
|
|
- * @param wordMl
|
|
|
- * @param num
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- public String replaceQuesBlank(String wordMl,int num) throws Exception {
|
|
|
- String tmpStr = DocxProcessUtil.BODY_HEADER + wordMl + DocxProcessUtil.BODY_TAIL;
|
|
|
- Body body = (Body)XmlUtils.unmarshalString(tmpStr,Context.jc,Body.class);
|
|
|
- List<Object> pList = body.getContent();
|
|
|
- int index = 0;
|
|
|
- int cur = 0;
|
|
|
- Map<Integer,String> curMap = new HashMap<Integer,String>();
|
|
|
- for(Object pObj:pList){
|
|
|
- if(pObj.getClass().equals(P.class)){
|
|
|
- List<Object> pContent = ((P)pObj).getContent();
|
|
|
- for(Object rObj:pContent){
|
|
|
- if(rObj.getClass().equals(R.class)){
|
|
|
- List<Object> rContent = ((R)rObj).getContent();
|
|
|
- for(Object tObj:rContent){
|
|
|
- if (tObj instanceof JAXBElement)
|
|
|
- tObj = ((JAXBElement<?>) tObj).getValue();
|
|
|
- if(tObj.getClass().equals(Text.class)){
|
|
|
- Text text = (Text)tObj;
|
|
|
- String str = text.getValue();
|
|
|
- //1
|
|
|
- str = str.replaceAll("###","______");
|
|
|
- text.setValue(str);
|
|
|
- //2
|
|
|
- Pattern pattern = Pattern.compile("##\\d{1,}##");
|
|
|
- Matcher m = pattern.matcher(str);
|
|
|
- while(m.find()){
|
|
|
- int curNum = num + index;
|
|
|
- String a = m.group();
|
|
|
- str = str.replaceAll(a, "___"+(curNum)+"___");
|
|
|
- text.setValue(str);
|
|
|
- index++;
|
|
|
- }
|
|
|
- //3
|
|
|
- if(str.startsWith("#") || str.equals("___")){
|
|
|
- curMap.put(cur,str);
|
|
|
- text.setValue("");
|
|
|
- }
|
|
|
- //4
|
|
|
- if(str.matches("^\\d{1,}$")){
|
|
|
- String preStr = curMap.get(cur - 1);
|
|
|
- if(!StringUtils.isEmpty(preStr) && preStr.startsWith("#")){
|
|
|
- int curNum = num + index;
|
|
|
- text.setValue("___"+(curNum)+"___");
|
|
|
- index++;
|
|
|
- }
|
|
|
- }
|
|
|
- cur++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- StringBuffer pWordMl = new StringBuffer();
|
|
|
- for(Object pObj:pList){
|
|
|
- if(pObj instanceof P){
|
|
|
- pWordMl.append(DocxProcessUtil.formatPWordMl(XmlUtils.marshaltoString(pObj)));
|
|
|
- }
|
|
|
- }
|
|
|
- return pWordMl.toString();
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 替换填空
|
|
|
+ * 将###替换为下划线_______
|
|
|
+ * @param wordMl
|
|
|
+ * @param num
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public String replaceQuesBlank(String wordMl,int num) throws Exception {
|
|
|
+ String tmpStr = DocxProcessUtil.BODY_HEADER + wordMl + DocxProcessUtil.BODY_TAIL;
|
|
|
+ Body body = (Body)XmlUtils.unmarshalString(tmpStr,Context.jc,Body.class);
|
|
|
+ List<Object> pList = body.getContent();
|
|
|
+ int index = 0;
|
|
|
+ int cur = 0;
|
|
|
+ Map<Integer,String> curMap = new HashMap<Integer,String>();
|
|
|
+ for(Object pObj:pList){
|
|
|
+ if(pObj.getClass().equals(P.class)){
|
|
|
+ List<Object> pContent = ((P)pObj).getContent();
|
|
|
+ for(Object rObj:pContent){
|
|
|
+ if(rObj.getClass().equals(R.class)){
|
|
|
+ List<Object> rContent = ((R)rObj).getContent();
|
|
|
+ for(Object tObj:rContent){
|
|
|
+ if (tObj instanceof JAXBElement)
|
|
|
+ tObj = ((JAXBElement<?>) tObj).getValue();
|
|
|
+ if(tObj.getClass().equals(Text.class)){
|
|
|
+ Text text = (Text)tObj;
|
|
|
+ String str = text.getValue();
|
|
|
+ //1
|
|
|
+ if("##".equals(str.trim())){
|
|
|
+ str = "___";
|
|
|
+ text.setValue(str);
|
|
|
+ }
|
|
|
+ //2
|
|
|
+ str = str.replaceAll("###","______");
|
|
|
+ text.setValue(str);
|
|
|
+ //3
|
|
|
+ Pattern pattern = Pattern.compile("##\\d{1,}##");
|
|
|
+ Matcher m = pattern.matcher(str);
|
|
|
+ while(m.find()){
|
|
|
+ int curNum = num + index;
|
|
|
+ String a = m.group();
|
|
|
+ str = str.replaceAll(a, "___"+(curNum)+"___");
|
|
|
+ text.setValue(str);
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ //4
|
|
|
+ /*if(str.startsWith("#") || str.equals("___")){
|
|
|
+ curMap.put(cur,str);
|
|
|
+ text.setValue("");
|
|
|
+ }*/
|
|
|
+ //5
|
|
|
+ if(str.matches("^\\d{1,}$")){
|
|
|
+ String preStr = curMap.get(cur - 1);
|
|
|
+ int curNum = num + index;
|
|
|
+ if(!StringUtils.isEmpty(preStr) && preStr.startsWith("#")){
|
|
|
+ text.setValue("___"+(curNum)+"___");
|
|
|
+ }else{
|
|
|
+ text.setValue(curNum+"");
|
|
|
+ }
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ cur++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ StringBuffer pWordMl = new StringBuffer();
|
|
|
+ for(Object pObj:pList){
|
|
|
+ if(pObj instanceof P){
|
|
|
+ pWordMl.append(DocxProcessUtil.formatPWordMl(XmlUtils.marshaltoString(pObj)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return pWordMl.toString();
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 设置题号
|
|
@@ -457,6 +464,8 @@ public abstract class ExportPaperAbstractService {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String appendScoreToQuestionBody(String quesBodyWordMl,double score) throws Exception{
|
|
|
+ String totalScore = BigDecimal.valueOf(score).stripTrailingZeros().toPlainString();
|
|
|
+ String scores = deletePoint(totalScore);
|
|
|
String tmpStr = DocxProcessUtil.BODY_HEADER + quesBodyWordMl + DocxProcessUtil.BODY_TAIL;
|
|
|
Body body = (Body)XmlUtils.unmarshalString(tmpStr,Context.jc,Body.class);
|
|
|
List<Object> pList = body.getContent();
|
|
@@ -469,7 +478,7 @@ public abstract class ExportPaperAbstractService {
|
|
|
List<Object> pContent = p.getContent();
|
|
|
R run = new R();
|
|
|
Text text = new Text();
|
|
|
- text.setValue("("+score+"分)");
|
|
|
+ text.setValue("("+scores+"分)");
|
|
|
run.getContent().add(text);
|
|
|
pContent.add(run);
|
|
|
index++;
|
|
@@ -483,6 +492,14 @@ public abstract class ExportPaperAbstractService {
|
|
|
return pWordMl.toString();
|
|
|
}
|
|
|
|
|
|
+ //去掉分数后面的小数点
|
|
|
+ private String deletePoint(String str) {
|
|
|
+ if(str.indexOf(".0")>-1){
|
|
|
+ return str.replace(".0", "");
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 当大题下小题分数不是全部一样时,在小题题干后面加上小题的分数
|
|
|
* @param details
|
|
@@ -571,6 +588,9 @@ public abstract class ExportPaperAbstractService {
|
|
|
String totalScore = BigDecimal.valueOf(paperDetailExp.getScore()).stripTrailingZeros().toPlainString();
|
|
|
QuesStructType type = paperDetailExp.getPaperDetailUnits().get(0).getQuestionType();
|
|
|
String questionScore = checkPaperDetailUnitScore(paperDetailExp);
|
|
|
+ if(questionScore!=null){
|
|
|
+ questionScore = deletePoint(questionScore);
|
|
|
+ }
|
|
|
String scoreString = questionScore==null?"":"每小题"+questionScore+"分,";
|
|
|
if (type == QuesStructType.SINGLE_ANSWER_QUESTION) {
|
|
|
paperDetailExp.setName("单项选择题");
|