Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update survey default values with data from DB when filling survey #78

Open
VladEfanovNewton opened this issue Aug 10, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@VladEfanovNewton
Copy link

Hello
I created survey with survey_kit commit: 41f3229.
At the beginning of the survey, the person's ID is asked. After inserting the person id, I want to check in the DB if the person already exists. If yes, the default survey values will be replaced with the values from the DB. Can I do it and how?
Also, I want to log after every step that goes through in the survey. Can I do it and how?
Thanks in advance

@ezmegy
Copy link
Contributor

ezmegy commented Aug 16, 2022

Hey @VladEfanovNewton ,

Pre-loading survey with existing results; I think there are two parts of this: A) you have to persist previous results and B) you'd need to populate the survey object.

  • For A) check out SurveyResult toJson #79 - I think you could use the toJson and fromJson methods implemented there and store the results in your DB.

  • For B) this functionality is not yet implemented in the plugin. If you're interested in doing it, maybe start by looking around in survey_presenter.dart. I'd think changing theSurveyPresenter() constructor to get the pre-loaded SurveyResult object and init the Set<QuestionResult> results field with that (instead of setting it empty) could work. At that point you'd need to change how you call SurveyPresenter() in survey_kit.dart but it might not be a lot of work actually altogether.

  • Alternatively, if your questionnaire is not too long, you might get away with using something else. For example form-management plugins like
    reactive_forms or
    flutter_form_builder
    that are more fine-tuned for realtime validation and can pre-populate form fields with existing values.

Logging: you can only catch navigation events and e.g. log something when those happen (see SurveyController), listening to single user taps (selections of an answer) is not provided by the plugin.
I'd start at looking at createView() in question_step.dart: all the different answer view types would probably need to provide an onAnswerChanged() or similar callback that you can then use at QuestionStep level... It would be certainly more effort to implement than the previous point.

Both features would be very nice to have though so consider opening separate new tickets for enhancement.

@ayushin
Copy link

ayushin commented Aug 16, 2022

Very much interested to see B) implemented. @adar2378

@adar2378
Copy link
Contributor

@Numoy Any plan for this? We would also like to prefill the survey with previously completed results from the user.

@Numoy Numoy added the enhancement New feature or request label Dec 1, 2022
@Numoy
Copy link
Member

Numoy commented Dec 1, 2022

I will try to integrate this with the next feature release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants