Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aminbaig's avatar

Interface approach for an online testing site

Hi,

I am trying to create a website which can help students prepare for studies. I am looking for advise on how to go about designing the database and the frontend and also if Laravel is the best option.

The usage scenario is:

for an subject (take maths for example) there are going to be different type of question like addition or subtraction etc.

The frontend will present the questions in different ways, like for addition it can be like 2+1 = an input box in which the student can enter their answer, or 2+1 and then buttons with 1,2,3,4 on them below the question and the student can select the button and it becomes highlighted as an answer.

My question are:

  1. should I define answer options tables for each different question types separately?
  2. different questions can have different interfaces/frontends, so if I have a test which has 20 questions, 10 of fill in the blanks type, 5 of choose the correct answer and five of another type, how do I implement a front end which can change dynamically for the different question types?

Apologies for a long post but can really use some advise.

0 likes
1 reply
alenabdula's avatar

Without knowing complete scope of what you're trying to do... my suggestion is:

should I define answer options tables for each different question types separately?

Looks like you might need Polymorphic Relations to retrieve a question based on the subject, like math, english, etc. In addition, I would create a boolean column for type of question multiple choice or data entry, so when presenting question in front-end you can display data accordingly. I would keep the answer in the same table as the question, as two are related and there's only one correct answer.

how do I implement a front end which can change dynamically for the different question types?

This sounds to me like an algorithm, in which your application can pick 20 random question, maybe based on difficulty... based on the boolean value mentioned above you can pick, 10 multiple choice, and 10 non-multiple choice to present to the user.

Hope that helps, Best, Alen

Please or to participate in this conversation.