Question structure as YAML #132
Replies: 4 comments 5 replies
-
This is actually closer to the original idea I had a while back (which I wrote a blog post about). The idea was to define all of the questions in a single static file (the original idea was yaml, but json works just the same). I still like this idea, and it could definitely be helpful for large surveys and / or working with large corpuses of standard questions. I guess there are two ways to use it though:
I would want to support both if possible. In terms of implementing it though, we should first agree upon the way we want the user to interface with each approach. For part 1, assuming a user has something like a For part 2, I assume this might just be a separate function to run in the console, something like |
Beta Was this translation helpful? Give feedback.
-
Okay, that sounds great. I'm sorry I didn't find the blog post before. I also think it would make sense to have both options. I've used the time again to think about how it would make sense conceptually in general. I think that we should separate the output of the questions and the possible input into two files. While the output only ever contains the questions that are actually being used, an external import file would have the advantage of also containing additional questions and versioning, a kind of simple question database. In other words, a clear separation between used and generally available questions. As the output of questions to an external file is certainly easier to implement, I would focus on this first. For me, this would also be more useful, especially for further data labeling.
PS: I hadn't even thought about it, but I also think YAML is better than JSON. |
Beta Was this translation helpful? Give feedback.
-
I was also thinking that the questions.json file could have any number of questions in it, so long as each has a unique id. You wouldn't have to use them all - the survey would only use the ones that are included in the survey.qmd file. So you could have tons of questions in the json file, but only use a handful. As for the export option, I wouldn't want this to be part of the As for the data structure, I do think json is actually the better approach as it is sort of the default data structure for web applications. It's easy to convert back and forth to lists or data frames in R using the jsonlite package. For importing questions, I would introduce a new argument to |
Beta Was this translation helpful? Give feedback.
-
Questions are now exported into a I'll leave this discussion open though because there is still the possibility of loading questions via a yml file. |
Beta Was this translation helpful? Give feedback.
-
Description
I already had the idea before, but it has now become more concrete thanks to the work on the label output. I would find it helpful if there could be a questions.json output that actually contains the same values as the sd_question() function:
questions.json
This would be useful if you want to use the option labels to create factor variables in the data wrangling, or using the question labels in a report. If you implement the pull request, all the information are already extracted from the HTML and available and just need to be exported.
One could also think about using this JSON file as an input for the survey.qmd file. This could be helpful if you have a much larger set of standardized questions and just want to choose which ones you want to ask in the new survey. Or often copy the same survey. You just need to specify the question ID in the survey.qmd file with
sq_question("fruit")
, and it will take all the information from a questions.json file in the directory. Or, if you need to, you can define the path to an external questions.json file in the sd_server() function.Just my thoughts. If you also find this useful, I can try to do a pull request on this.
Beta Was this translation helpful? Give feedback.
All reactions