Open VladEfanovNewton opened 2 years ago
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 #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.
Very much interested to see B) implemented. @adar2378
@Numoy Any plan for this? We would also like to prefill the survey with previously completed results from the user.
I will try to integrate this with the next feature release!
Hello I created survey with survey_kit commit: 41f32291e87b4c0e41f75b9d7e6bebaa3723a6c9. 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