@Test public void toXmlAndBackAgainShouldProduceSameQuestion() throws Exception { List<String> extraFragments = Arrays.asList("Wibble", "Wobble"); String questionText = "Question <slot>foo</slot> more question <slot>bar</slot>"; String explanationText = "Explanation <slot>foo</slot> more question <slot>bar</slot>"; boolean reuseFragments = false; DragAndDropQuestion dragAndDropQuestion = new DragAndDropQuestion(questionText, explanationText, extraFragments, reuseFragments); assertEquals(dragAndDropQuestion, new DragAndDropQuestion(dragAndDropQuestion.asXML())); }
public Element asXML() { Element element = new Element("DragAndDropQuestion"); element.setAttribute("reuseFragments", Boolean.toString(reuseFragments)); ReadableElement questionTextElement = new ReadableElement("QuestionText"); questionTextElement.setText(questionText); ReadableElement explanationTextElement = new ReadableElement("ExplanationText"); explanationTextElement.setText(explanationText); Element fragmentListElement = new Element("ExtraFragments"); for (String fragment : extraFragments) { ReadableElement fragmentElement = new ReadableElement("Fragment"); fragmentElement.setText(fragment); fragmentListElement.addContent(fragmentElement); } element.addContent(questionTextElement); element.addContent(fragmentListElement); element.addContent(explanationTextElement); return element; }
DragAndDropQuestion extends AbstractQuestion { public Element asXML() { Element element = new Element("DragAndDropQuestion"); element.setAttribute("reuseFragments", Boolean.toString(reuseFragments)); ReadableElement questionTextElement = new ReadableElement("QuestionText"); questionTextElement.setText(questionText); ReadableElement explanationTextElement = new ReadableElement("ExplanationText"); explanationTextElement.setText(explanationText); Element fragmentListElement = new Element("ExtraFragments"); for (String fragment : extraFragments) { ReadableElement fragmentElement = new ReadableElement("Fragment"); fragmentElement.setText(fragment); fragmentListElement.addContent(fragmentElement); } element.addContent(questionTextElement); element.addContent(fragmentListElement); element.addContent(explanationTextElement); return element; } }
DragAndDropQuestion extends AbstractQuestion { public Element asXML() { Element element = new Element("DragAndDropQuestion"); element.setAttribute("reuseFragments", Boolean.toString(reuseFragments)); ReadableElement questionTextElement = new ReadableElement("QuestionText"); questionTextElement.setText(questionText); ReadableElement explanationTextElement = new ReadableElement("ExplanationText"); explanationTextElement.setText(explanationText); Element fragmentListElement = new Element("ExtraFragments"); for (String fragment : extraFragments) { ReadableElement fragmentElement = new ReadableElement("Fragment"); fragmentElement.setText(fragment); fragmentListElement.addContent(fragmentElement); } element.addContent(questionTextElement); element.addContent(fragmentListElement); element.addContent(explanationTextElement); return element; } DragAndDropQuestion(String questionText, String explanationText, List<String> extraFragments,
            boolean reuseFragments);   DragAndDropQuestion(Element element); }
DragAndDropQuestion extends AbstractQuestion { public Element asXML() { Element element = new Element("DragAndDropQuestion"); element.setAttribute("reuseFragments", Boolean.toString(reuseFragments)); ReadableElement questionTextElement = new ReadableElement("QuestionText"); questionTextElement.setText(questionText); ReadableElement explanationTextElement = new ReadableElement("ExplanationText"); explanationTextElement.setText(explanationText); Element fragmentListElement = new Element("ExtraFragments"); for (String fragment : extraFragments) { ReadableElement fragmentElement = new ReadableElement("Fragment"); fragmentElement.setText(fragment); fragmentListElement.addContent(fragmentElement); } element.addContent(questionTextElement); element.addContent(fragmentListElement); element.addContent(explanationTextElement); return element; } DragAndDropQuestion(String questionText, String explanationText, List<String> extraFragments,
            boolean reuseFragments);   DragAndDropQuestion(Element element); @Override String getQuestionTypeName(); Element asXML(); List<String> getFragments(); List<String> getExtraFragments(); List<String> getCorrectFragments(); boolean canReuseFragments(); int largestFragmentWidth(); @Override int hashCode(); @Override boolean equals(Object obj); boolean isAnswered(Answer generalAnswer); Answer initialAnswer(); boolean isCorrect(Answer answer); }
DragAndDropQuestion extends AbstractQuestion { public Element asXML() { Element element = new Element("DragAndDropQuestion"); element.setAttribute("reuseFragments", Boolean.toString(reuseFragments)); ReadableElement questionTextElement = new ReadableElement("QuestionText"); questionTextElement.setText(questionText); ReadableElement explanationTextElement = new ReadableElement("ExplanationText"); explanationTextElement.setText(explanationText); Element fragmentListElement = new Element("ExtraFragments"); for (String fragment : extraFragments) { ReadableElement fragmentElement = new ReadableElement("Fragment"); fragmentElement.setText(fragment); fragmentListElement.addContent(fragmentElement); } element.addContent(questionTextElement); element.addContent(fragmentListElement); element.addContent(explanationTextElement); return element; } DragAndDropQuestion(String questionText, String explanationText, List<String> extraFragments,
            boolean reuseFragments);   DragAndDropQuestion(Element element); @Override String getQuestionTypeName(); Element asXML(); List<String> getFragments(); List<String> getExtraFragments(); List<String> getCorrectFragments(); boolean canReuseFragments(); int largestFragmentWidth(); @Override int hashCode(); @Override boolean equals(Object obj); boolean isAnswered(Answer generalAnswer); Answer initialAnswer(); boolean isCorrect(Answer answer);  }