wood burning stoves 2.0*
The moose likes Java in General and the fly likes Struggling to OOP data model a Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Struggling to OOP data model a "multiple choice exam"" Watch "Struggling to OOP data model a "multiple choice exam"" New topic
Author

Struggling to OOP data model a "multiple choice exam"

James Elsey
Ranch Hand

Joined: Dec 21, 2007
Posts: 228

Hi guys,

I'm trying to create an application which is essentially a multiple choice simulator. There will be a "Quiz", the quiz will have a number of questions which I'll refer to a list of "QuizItem"s.

Each "QuizItem" has a "Question", and that question has a number of "Answers".

Here is what I've worked out so far..




I'm not convinced that datamodel is entirely correct, and I'm struggling to find resources on the net, or at least any pointers with this type of data model.

Would it be best to have the QuizItem only aware of answers, and have the answers depend on a Question?

I know this should be simple, but please help!

Thanks


Kind Regards, James. OCPJP 1.6 || My SCJP / OCJCP Study Notes
Interested in : SCJP, Google App Engine, Stripes, Android;|| My Bite-Size SCJP Study Blog
Lanny Gilbert
Ranch Hand

Joined: Jun 11, 2002
Posts: 103
I'd remove QuizItem entirely.. Now, you have a quiz that consists of a list of Questions. each Question has a questionText (the actual question) and a list of
answers. Does this look like what you want???



public class Quiz
{
private int id;
private List<Question> questionList;

//accessors
}

public class Question
{
private int id;
private String questionText;
private List<Answer> answers;

//accessors
}

public class Answer
{
private int id;
private boolean isCorrect;
private boolean isUserSelected;
private String answerText;

//accessors
}
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5

I think you are mixing up the question data - which should be the same for all users taking the exam - with the individual user results.

The exam - consisting of a list of Questions - should not be affected by individual user actions.

A single user should have a Serializable object which stores his/her state of taking the exam - link to the Question set, current question number, answers, graded/not graded, etc etc. I say Serializable because then you can store the user's current state and recover it.

Based on my extensive experience with exam simulators, try to make it easy for exam authors to create question scripts. Personally I ended up with XML for maximum flexibility.

Bill


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struggling to OOP data model a "multiple choice exam"