Appsilon / shiny.router

A minimalistic router for your Shiny apps.
http://appsilon.github.io/shiny.router
Other
255 stars 31 forks source link

Building a markdown-based survey platform in {shiny} #135

Open jhelvy opened 11 months ago

jhelvy commented 11 months ago

Hi! I'm not really sure where to post this as it's not quite an issue. Rather, it's an initial conversation to see if you might be interested in / have ideas for how one might build an open-source, markdown-based survey platform using {shiny} (and possibly RMarkdown / Quarto). I've had this idea in mind for years (see this blog post), but I've struggled to find an architecture that achieves the end goal. So I'm posting this in case anyone in the Appsilon team might be interested in the idea as I think a lot of your packages could be key components of making this work, and I figured you all probably would have the best ideas of how to set something like this up.

For example, I never knew about {shiny.router}, and having just discovered it I feel like this could be a key component for controlling navigation through a survey, with questions set on different pages. And packages like {rhino} are probably also super useful for something like this. Apologies that this isn't quite an issue - I just didn't know how else to reach out to the Appsilon team.

My end goal is to build a package such that users can define their survey content using mostly just markdown and code chunks. That is, if the goal is to design a survey, then all we really need is to define the UI. The server code could be generated with some logic based on what's in the UI as we're not using {shiny} in a conventional dashboard way but rather simply for data collection.

For example, in this discussion I describe an example of how I would want a simple survey to be able to be defined, something like this:

---
name: "surveydown demo"
author: "John Paul Helveston"
format: html
self-contained: true
execute:
  echo: false
---

```{r}
#| include: false

library(surveydown)

Welcome!

This is a demo survey! Click the button below to go to the next page.


This is a screener.

You must choose "Red" in the question below, otherwise you will be screened out (meaning you will be sent to the end of the survey)

question(
  name     = 'color',
  type     = 'mc',
  required = TRUE,
  label    = "Do you want to take the red pill or the blue pill?",
  option   = c('Red', 'Blue')
)

Here are some more questions:

question(
  name     = 'animal',
  type     = 'text',
  required = FALSE,
  label    = "What's your favorite animal?"
)

question(
  name     = 'education',
  type     = 'select',
  required = TRUE,
  label    = "What is the highest level of education you have attained?",
  option   = c(
    "Did not attend high school" = "hs_no",
    "Some high school"           = "hs_some",
    "High school graduate"       = "hs_grad",
    "Some college"               = "college_some",
    "College"                    = "college_grad",
    "Graduate Work"              = "grad",
    "Prefer not to say"          = "no_response"
  )
)

Fine

Thank you for taking our survey!



There is no {surveydown} package (yet), but that's the idea. Define a survey in markdown, then render it to a shiny app. The data would be saved to any database - I'm thinking of just saving to a Google sheet for now. But if you defined all of the UI content in a .Rmd or .qmd file, we should be able to define some functions that generate the appropriate UI and server code for a shiny app that simply writes user responses to a database.

Anyway, if this sounds interesting I would appreciate any thoughts / suggestions you have.