In case you have any chance of having the list of questions as a .csv, or a .json file it could be managed in a pretty clever way in both of the answers on top. I would add that depending on the backend structure you could come up with multiple scenarios:
In case of Firebase:
- have a collection of ‘questions’ where each item is a json object with a schema like this:
{
"id": "random-generated-by-firebase"
"questionText": "Do you eath healthy?",
"answers": [{
"value": "yes",
"score": 1
},
{
"value": "no",
"score": 0
},
{
"value": "N/A",
"score": null
}]
}
In the app when you are building your logic and layout keep this in mind:
Make a page variable or app variable (depends on use case) which is a list of “texts”.
Then as a layout you’d build a repeated container, which is repeated with the data variable “questions” (that is coming from Firebase).
Inside that repeated container, you have a text that is the question text, and another repeated container that is repeated with the answers array of the question object.
On the answers repeated container a component tap event should trigger a set page variable logic where you add a new item to the list of questions (if the questionaire is “no-going-back” type). For this you can use a formula like this:
WITH_UNIQUE_ITEM(pageVars.responses, {questionId: repeated.question.id, answer: repeated.answer.value, score: repeated.answer.score})
When the user reaches the “Submit” button, there you’d have a logic that does this formula:
SUM_BY_KEY(pageVars.responses, "score")
Wherever you save the above formula value will give you the final result.
The solutiion and approach is similar to any backend that you choose. Some might be easier to import a big dataset like these 300 questions. But with a csv to json converter you could be good.