Exemple #1
0
 @SuppressWarnings("deprecation")
 private String getStr(Que que, Collection queEntrys, int i) {
   // 拼接XML样式,逐个拼接
   // 拼接标题
   doc = DocumentHelper.createDocument();
   root = doc.addElement("div");
   root.setAttributeValue("value", que.getId().toString());
   eleH1 = root.addElement("h1");
   eleH1.setText(i + 1 + ". " + que.getQueDesc().toString());
   eleH1.setAttributeValue("value", que.getId().toString());
   // 拼接明细
   eleDiv = root.addElement("div");
   eleDiv.addAttribute("data-role", "controlgroup");
   int k = 0;
   for (Iterator iter = queEntrys.iterator(); iter.hasNext(); k++) {
     queEntry = (Queentry) iter.next();
     str = que.getId() + "|" + queEntry.getId();
     eleLab = eleDiv.addElement("label");
     eleLab.setText(String.valueOf((char) (charL + k)) + "." + queEntry.getDesc());
     eleLab.addAttribute("for", str);
     eleInput = eleDiv.addElement("input");
     eleInput.addAttribute("id", str);
     eleInput.addAttribute("type", "radio");
     eleInput.addAttribute("name", "put" + i);
     eleInput.addAttribute("value", queEntry.getId().toString());
   }
   return doc.getRootElement().asXML();
 }
Exemple #2
0
  private String checkAnwer(String strAn) {
    // TODO Auto-generated method stub
    a = strAn.split(";");
    // 拼接XML 3列
    doc = DocumentHelper.createDocument();
    root = doc.addElement("table");
    root.addAttribute("data-role", "table");
    root.addAttribute("data-mode", "columntoggle");
    root.addAttribute("class", "ui-responsive table-stripe");
    ele = root.addElement("thead");
    ele = ele.addElement("tr");
    ele.addAttribute("class", "ui-bar-c");
    // 列标题
    ele.addElement("th").setText("题目");
    eleH1 = ele.addElement("th");
    eleH1.setText("选择");
    eleH1.setAttributeValue("data-priority", "1");
    eleH1 = ele.addElement("th");
    eleH1.setText("正确答案");
    eleH1.setAttributeValue("data-priority", "1");
    ele = root.addElement("tbody");
    // 增加信息行
    for (String strA : a) {
      aS = strA.split("\\|"); // 注意 “|”的转义
      ele = ele.addElement("tr");
      que = queDao.findBystrId(aS[0]); // 题目
      queEntry = queEntryDao.findBystrId(aS[1]); // 选择
      // 判断回答是否正确
      // if (queEntry.getId().equals(que.getAnswer())) {
      ele.addElement("td").setText(que.getQueDesc());
      ele.addElement("td").setText(queEntry.getDesc());
      ele.addElement("td").setText(queEntryDao.findBystrId(que.getAnswer()).getDesc());
      // } else {
      // System.out.println("error");
      // }

    }
    return doc.getRootElement().asXML();
  }