Rails modeling exam object

Course Queries Competitions/Entrance Exams 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Competitions/Entrance Exams related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I am trying to model an exam object and wanted to your opinions.

In a exam, there are multiple types of question, like Multiple Choice (MC), Short Question (SQ), True or False (TF), etc..

Each types of question has its own data, for example: (MC) would need question, potential answers, correct answer and (SQ) would only need a question.

Originally, I was thinking to just have an Exam model and a Question model (with single table inheritance) for the different type of question. However, since different types of question behaves differently and have different data attributes, I don't think that's going to work.

What I am thinking now is to have a Exam object which has_many "ExamQuestion" object which has attributes (exam_id, question_type, question_id).

I think this is going to work, but kinda don't like the fact that I have to have a column like 'question_type' in the "cross section" table like "ExamQuestion". ex. the query might become ugly.

Does anyone see a better way of doing this?

Thanks!

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.