I have one requirement in which server will provide us list of screens, and each screen will have certain set of questions.
These question may vary in their question types. i.e.
- Some may require TextField as to submit the answer (with validations on input),
- Some of may have radio buttons (with YES and NO)
- Some will have Checkbox
- Some have dropdown with dynamic values
From mobile side (iOS), we'll need to get these questions's from Server, dump it into local database and then display a list questions (in Form) based on Screen and the questionType.
Please suggest a good approach !
One way I thought to create custom-views for each question type, i.e. reusable view for radioButton, reusableView for TextInput, etc.
And add all these views into a stack view and display it.
But, problem is how to keep reference of all these added views? I mean if there are 3 questions of type "inputTextfield", we can render a reusable view which contains Question Label, and UITextfield (to submit answer). But how to get values (answer) from each component and submit all the questions and their answers in a form?
Here is a simplified starting solution how you could bind your questions to views and get views values. First you map your data to models and then you should implement mechanism how you update answers inside entries (for instance based on control state change).