Form responses to csv #275
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
We want a way to automatically export all response data for a form to an easy-to-read csv.
What
Created a response-to-csv.ts function to flatten all of the data for responses into a csv, with each row corresponding to a user, and all subsequent columns corresponding to each individual question.
Implemented with a export-csv.tsx component to sit as a button on each form card on the homepage. This button will be greyed out when 0 responses exist. Additionally, it will poll every window refresh for the updated count.
Response count is also shown on the form card.
The exported csv has the file format of {name}-responses-{date and time} for clarity.
Test Plan
This form has been responded to, edited, re-responded to, and edited again. Blank spaces are fine for the csv and so is exporting after edits and more responses.
I followed the exact same logic for grabbing the names and emails, the reason that they do not populate is 99.99999% probably due to the fact that my blade account is chud and broken rn (it doesnt think im a member so probably cant grab my data) but i absolutely encourage someone else to try this out and confirm its just me