Architecture for Quiz App
What do people recommend for structuring the backend for a quiz app that:
- Users sign up
- Users join groups
- Each day a prompt is posted to the group
- A group member can only see the response of other members once they themselves have submitted a response
Currently I have these tables:
- Group
- User (with table reference to group)
- Prompt (text questions)
- Response (text response with table references to user and prompt)
Am thinking a reverse add-on might work whereby GET /groups endpoint would:
- Return groups in which authenticated user is a member
- For each group:
- Return responses (ideally grouped by prompt) where authenticated user is among the users who provided a response
Answers
-
Hi, Shaun. It sounds like you're on the right track. It sounds like you would need the Prompt or the Group table to have a reference to the other to make sure that questions belong to certain groups.
-
Ah okay. I may have been thinking about this wrong. I might need an additional table to house raw questions (e.g., question text, question category, question likes/feedback).
For the MVP of this, every group is going to get the same question each day. So it sounds like I should have some process that runs each day that pulls a question from the questions table and, for each active group, creates an entry in prompts that links to both the question being asked as well as the group (and then any responses from those group members that are created). In other word, the prompt table represents "questions asked to a group" vs. just a list of raw questions (which is how I was thinking of it before).
This setup then would allow for more complex logic in the future. For example: when choosing a question to convert into a prompt for a particular group, scan list of existing prompts asked to that group and the underlying question_ids and ensure not selecting a question that has already been asked. Or, only use questions of a certain category when creating prompts for a particular group. etc. etc
Does this sound like it makes sense?
-
Yes, great idea! I hadn't considered preparing for questions that have already been asked.
-
Ah okay. I may have been thinking about this wrong. I might need an additional table to house raw questions (e.g., question text, question category, question likes/feedback).
For the MVP of this, every group is going to get the same question each day. So it sounds like I should have some process that runs each day that pulls a question from the questions table and, for each active group, creates an entry in prompts that links to both the question being asked as well as the group (and then any responses from those group members that are created). In other word, the prompt table represents "questions asked to a group" vs. just a list of raw questions (which is how I was thinking of it before).
This setup then would allow for more complex logic in the future. For example: when choosing a question to convert into a prompt for a particular group, scan list of existing prompts asked to that group and the underlying question_ids and ensure not selecting a question that has already been asked. Or, only use questions of a certain category when creating prompts for a particular group. etc. etc
Does this sound good?
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback