• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struggling to OOP data model a "multiple choice exam"

 
Ranch Hand
Posts: 231
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
}
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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


 
reply
    Bookmark Topic Watch Topic
  • New Topic