Пример #1
0
 private void loadQuestion(Element node, Tutorial tutorial) {
   String question_id = getId(node);
   Question question = tutorial.findOrCreateQuestion(question_id);
   for (Iterator<?> iter = node.elementIterator(); iter.hasNext(); ) {
     Element child = (Element) iter.next();
     String name = child.getName();
     String text = CDom4jHelper.getTrimmedText(child);
     if (name.equals("text")) question.setText(CDom4jHelper.getChildrenAsXml(child));
     else if (name.equals("choice")) loadChoice(child, question);
     else setProperty(question, name, text);
   }
   this.writer.message("updating question: [" + question.getId() + "]");
 }
Пример #2
0
 private void loadChoice(Element node, Question question) {
   String choice_id = getId(node);
   Choice choice = question.findOrCreateChoice(choice_id);
   choice.setCorrect(CDom4jHelper.getBoolAttribute(node, "correct", false));
   for (Iterator<?> iter = node.elementIterator(); iter.hasNext(); ) {
     Element child = (Element) iter.next();
     String name = child.getName();
     String text = CDom4jHelper.getTrimmedText(child);
     if (name.equals("text")) choice.setText(CDom4jHelper.getChildrenAsXml(child));
     else if (name.equals("response")) choice.setResponse(CDom4jHelper.getChildrenAsXml(child));
     else setProperty(choice, name, text);
   }
   this.writer.message("updating choice: [" + choice.getId() + "]");
 }