TView *d = validView( new TChDirDialog( 0, cmChangeDir ) );
if( d != 0 )
{
deskTop->execView( d );
destroy( d );
}
}
// Read
void TVTest::loadAnswers()
{
if( !theTest.isEmpty() &&
(messageBox("The test already in RAM will be lost. Continue?", mfInformation | mfYesButton | mfNoButton ) != cmYes) )
return;
TFileDialog *d= (TFileDialog *)validView(
new TFileDialog( "*.ANS", "Load Test Answers", "~N~ame", fdOpenButton, 100 ));
if( d != 0 && deskTop->execView( d ) != cmCancel ) {
char fileName[MAXPATH];
d->getFileName( fileName );
if(theTest.loadAnswers(fileName)) {
if(theTest.isNotComplete())
TakeTest(0);
else
if(theTest.ResultForm())
showTest();
}
else
messageBox( "Could not read ANSwer file.", mfError | mfOKButton );
}
destroy( d );
}
void TVTest::saveAnswers()
{
TFileDialog *d= (TFileDialog *)validView(
new TFileDialog( "*.ANS", "Save Test Answers", "~N~ame", fdOKButton, 100 ));
if( d != 0 && deskTop->execView( d ) != cmCancel ) {
char fileName[MAXPATH];
d->getFileName( fileName );
if(!theTest.saveAnswers(fileName))
messageBox( "Could not write ANSwer file.", mfError | mfOKButton );
}
destroy( d );
}
// Run through the test questions
void TVTest::TakeTest(int CHEAT)
{
MMPIQuestion *current;
int answer;
if(theTest.isEmpty()) {
theTest.clearAnswers();
current = theTest.first();
}
else {
// Find the first unanswered question
current = theTest.isNotComplete();
if( current ) {
if(messageBox("There is a partial test in RAM.\nResume this test?", mfInformation | mfYesButton | mfNoButton ) == cmYes )
current = theTest.current();
else {
theTest.clearAnswers();
current = theTest.first();
}
}
else {
if(messageBox("The test already in RAM will be lost. Continue?", mfInformation | mfYesButton | mfNoButton ) == cmYes ) {
theTest.clearAnswers();
current = theTest.first();
}
else
return;
}
}
if( !theTest.gender )
switch(GetGender()) {
case cmYes:
theTest.gender=MALE;
break;
case cmNo:
theTest.gender=FEMALE;
break;
default:
return;
};
if(current) {
do {
answer = ask(current,CHEAT);
switch(answer) {
case cmCancel:
switch(abortTest()) {
case cmNo:
if( !(current=theTest.prev()) )
current=theTest.first();
break;
case cmYes:
if( !theTest.isEmpty() &&
(messageBox( "You may resume this test by saving it now, then loading it at another time.\n\3Save it now?", mfInformation | mfYesButton | mfNoButton ) == cmYes)