Closed StefanMunnes closed 1 month ago
Very cool! Yeah I was thinking this might be the right approach - scrape the question label and option labels from the html and pass them through. Nice work! I've got a busy few days (teaching), but I'll try to look through this by Friday at the latest.
This is now in the main branch, with the version bumped to v0.3.7. Thanks again for adding this!
As suggested in the feature request, I added the option to display the question label and the labels of the chosen options with the sd_output() function. The main idea is, to get these labels also from the rendered HTML inside the get_question_structure() function in the config.R file. In the sd_server() function in the server.R file, add these labels (for option labels, select just chosen ones) than to the output list object. The
local({...})
environment in the lapply function is necessary, otherwise theobserveEvent({})
would just show the same value for all three options. Finally, add this option in the ui.R file to the sd_output() function, also with documentation.I tested this with all mc question types, also multiple, and select input. I provide a test survey (txt bc qmd not supported from GitHub) survey.txt. Everything looks good. For the select input question type, if nothing was chosen, just the default "Choose an option..." is presented. Maybe something to change? For matrix questions I wasn't able to show the question label, nor the values and options chosen. Needs to be done in the future. Numeric input question types will respond with an empty string for the option label.