Methods Summary |
---|
protected void | doNew()
curX = new Exam();
|
public void | doPrint()Print the current exam
new PrintDraft(curX).print();
|
public void | doStats()
TStat t = new TStat();
t.nq = curX.getqvs().size();
t.n = new int[4];
for (int i=0; i<t.nq; i++) {
Q tq = curX.getQuestion(i);
if (tq.question == null || tq.question.length() == 0) {
++t.incomplete;
continue;
}
t.complete++;
if (tq.correct == 0) {
++t.noAnswer;
continue;
}
int ans = tq.correct;
if (ans >= 0)
t.n[ans]++;
if (tq.objective < 0) {
++t.noObjective;
continue;
}
}
// System.out.println("TStats t = " + t);
viewctl.showStats(t);
|
public synchronized void | exit(int n)Exit method, just calls System.exit(). Synchronized to prevent
calling System.exit() during a saveFile(), which would be very bad :-)
System.exit(n);
|
public void | loadFile(java.lang.String fn)
if (ls == null)
ls = new XamDataAccessor(viewctl);
String newFN;
if (fn == null) {
viewctl.fc.setVisible(true); // blocking dialog
if ((newFN = ((FileDialog)viewctl.fc).getFile()) == null)
return;
fn = newFN;
}
try {
ls.load(new BufferedReader(new FileReader(curFileName=fn)), curX);
} catch (FileNotFoundException e) {
System.err.println("Can't find file " + curFileName);
} catch (IOException e) {
System.err.println("IO Error in processing " + curFileName + ": " + e);
} catch (Exception e) {
System.err.println("Error in data file " + curFileName + "\n");
e.printStackTrace();
}
|
public static void | main(java.lang.String[] av)"main program" method - just for testing.
// create a TD object
TD td = new TD();
td.loadFile("toy.xam");
|
protected void | mkTitle()
String newt = curX.crsNum + " Exam" +
curX.examName + " " + curX.examVers + " " + curX.crsName;
viewctl.setTitle(newt);
|
public synchronized void | saveFile()Save the current file
saveFile(curFileName);
|
public synchronized void | saveFile(java.lang.String fName)Save the current exam into a file
// System.out.println("Saving file...");
try {
ls.save(new PrintWriter(new FileWriter(fName), true), curX);
} catch (IOException e) {
System.err.println("I/O error " + e);
}
// System.out.println("Save done");
|
public synchronized void | saveHTML(java.lang.String fName)Save the current file AS HTML. This is just an interface to
the XamDataAccessorHTML object, and should be done away with, once
we hava a Properties listing all the different XamDataAccessor subclasses!
// System.out.println("Saving...");
XamDataAccessorHTML hs = new XamDataAccessorHTML(viewctl);
try {
hs.save(new PrintWriter(new FileWriter(fName), true), curX);
} catch (IOException e) {
System.err.println("I/O error " + e);
}
// System.out.println("Save done");
|
protected void | setViewCtl(TV tv)
viewctl = tv;
|