use of doc.mathobjects.ProblemGenerator in project OpenNotebook by jaltekruse.
the class ProblemDatabase method exportToXML.
public String exportToXML() {
String output = "";
output += "<" + NAME + ">\n";
for (ProblemGenerator problem : getExportableProblems()) {
output += problem.exportToXML();
}
output += "</" + NAME + ">\n";
return output;
}
use of doc.mathobjects.ProblemGenerator in project OpenNotebook by jaltekruse.
the class Document method addGenerator.
public void addGenerator(ProblemGenerator generator) throws Exception {
for (ProblemGenerator gen : generators) {
if (gen.getProblemID().compareTo(generator.getProblemID()) == 0) {
throw new Exception("UUID already in use");
}
}
generator.setProblemHoldingDocument(this);
generators.add(generator);
}
use of doc.mathobjects.ProblemGenerator in project OpenNotebook by jaltekruse.
the class Document method generateProblems.
public void generateProblems(Vector<ProblemGenerator> generators, Vector<Integer> frequencies, int numberOfProblems, String directions, boolean problemNumbers) {
for (ProblemGenerator gen : generators) {
gen.setProblemHoldingDocument(this);
try {
addGenerator(gen);
} catch (Exception e) {
// problem formula has already been added
}
}
int j = 0;
Vector<GeneratedProblem> newProblems = new Vector<>(numberOfProblems);
for (int i = 0; j < numberOfProblems; j++, i++) {
if (i < numberOfProblems / 3) {
newProblems.add(generators.get(pickRandomIndex(frequencies)).generateProblem(ProblemGenerator.EASY));
} else if (i < numberOfProblems * (2.0 / 3)) {
newProblems.add(generators.get(pickRandomIndex(frequencies)).generateProblem(ProblemGenerator.MEDIUM));
} else {
newProblems.add(generators.get(pickRandomIndex(frequencies)).generateProblem(ProblemGenerator.HARD));
}
}
layoutProblems(newProblems, directions, this, problemNumbers);
docPanel.repaint();
}
use of doc.mathobjects.ProblemGenerator in project OpenNotebook by jaltekruse.
the class Document method exportToXML.
public String exportToXML() {
String output = "";
output += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
output += "<" + OPEN_NOTEBOOK_DOC + " " + "version=\"0.1\" " + FILENAME + "=\"" + getName() + "\" " + AUTHOR + "=\"" + getAuthor() + "\" " + DATE + "=\"" + getDate() + "\" " + LAST_PROBLEM_NUMBER + "=\"" + getLastProblemNumber() + "\" " + X_MARGIN + "=\"" + getxMargin() / 72.0 + "\" " + Y_MARGIN + "=\"" + getyMargin() / 72.0 + "\" " + ">\n";
for (String s : subjectsCovered) {
output += "<subject name=\"" + s + "\"></subject>";
}
output += "<" + GENERATORS + ">\n";
for (ProblemGenerator gen : generators) {
output += gen.exportToXML();
}
output += "</" + GENERATORS + ">\n";
for (Page p : pages) {
output += p.exportToXML();
}
output += "</" + OPEN_NOTEBOOK_DOC + ">";
return output;
}
use of doc.mathobjects.ProblemGenerator in project OpenNotebook by jaltekruse.
the class Document method clone.
public Document clone() {
Document newDoc = new Document(new String(getName()));
newDoc.attributes = new Vector<>();
MathObject lastWithFocus = this.getLastFocused();
for (MathObjectAttribute mAtt : getAttributes()) {
newDoc.addAttribute(mAtt.clone());
}
for (ProblemGenerator gen : generators) {
try {
newDoc.addGenerator((ProblemGenerator) gen.clone());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
for (Page p : pages) {
newDoc.addPage(p.clone());
}
// the last focused member of this document is used to pass back
// its cloned version from the page cloning method
newDoc.setLastFocused(this.getLastFocused());
// the last focused object is saved at the beginning of the method
// to prevent being overridden as described in the above comment
// this.setLastFocused(lastWithFocus);
newDoc.setDocViewerPanel(getDocViewerPanel());
return newDoc;
}
Aggregations